public void PushOrSucc(float amount) { if (!otherHole) { return; } var otherComponent = otherHole.GetComponent <HoleSphereBehaviour>(); lock (otherComponent.storedItems) { foreach (Collider collider in Physics.OverlapSphere(item.transform.position, 0.1f, 218119169)) { if (type == Black && otherHole != null && collider && CosmicSelfMerge.ShouldAffectRigidbody(collider.attachedRigidbody)) { collider.attachedRigidbody.gameObject.GetComponent <Item>()?.handlers.ForEach(handler => handler.TryRelease()); otherComponent.storedItems.Enqueue(collider.attachedRigidbody.gameObject); nomEffect.Spawn(item.transform).Play(); collider.attachedRigidbody.gameObject.SetActive(false); } } } foreach (Collider collider in Physics.OverlapSphere(item.transform.position, 10.0f, 218119169)) { if (CosmicSelfMerge.ShouldAffectRigidbody(collider.attachedRigidbody)) { AddForce(collider.attachedRigidbody, amount); } } }
public void TriggerHeadThrow(Rigidbody rb) { rb.gameObject.transform.position = item.transform.position; List <Creature> creatures = Creature.list.Where( creature => creature != Player.currentCreature && creature.state != Creature.State.Dead && (creature.ragdoll.headPart.transform.position - item.transform.position).magnitude < throwTrackRange).ToList(); if (creatures.Count > 0) { Creature target = creatures[new System.Random().Next(creatures.Count)]; Debug.Log($"Throwing at {target.name}"); rb.position = (target.ragdoll.headPart.transform.position - item.transform.position).normalized * 0.2f; rb.velocity = Vector3.zero; float modifier = 1; if (rb.mass < 1) { modifier *= rb.mass * 2; } else { modifier *= rb.mass; } rb.AddForce((target.ragdoll.headPart.transform.position - item.transform.position).normalized * modifier * throwTrackForce, ForceMode.Impulse); if (rb.gameObject.GetComponent <Item>().data.type != ItemPhysic.Type.Prop) { CosmicSelfMerge.PointItemFlyRefAtTarget(rb.gameObject.GetComponent <Item>(), (target.ragdoll.headPart.transform.position - item.transform.position).normalized, 1); } } pewEffect.Spawn(item.transform).Play(); rb.gameObject.GetComponent <Item>()?.Throw(); }
public void Update() { if (target) { item.rb.useGravity = false; item.transform.position = Vector3.Lerp(item.transform.position, target.transform.TransformPoint(offset), Time.deltaTime * 10f); CosmicSelfMerge.PointItemFlyRefAtTarget(item, item.transform.position + target.forward, Time.deltaTime * 10f); } }
public void Begin(HoleType type, ref Item otherHole, CosmicSelfMerge spellData) { nomEffect = nomEffect ?? Catalog.GetData <EffectData>("HoleAbsorb"); pewEffect = pewEffect ?? Catalog.GetData <EffectData>("HoleFire"); ambientEffect = ambientEffect ?? Catalog.GetData <EffectData>((type == Black) ? "BlackHoleAmbient" : "WhiteHoleAmbient"); itemSpamDelay = spellData.itemSpamDelay; friction = spellData.friction; throwTrackRange = spellData.throwTrackRange; throwTrackForce = spellData.throwTrackForce; throwForce = spellData.throwForce; pushForce = spellData.pushForce; pullForce = spellData.pullForce; if (active) { return; } this.otherHole = otherHole; item = GetComponent <Item>(); effect = ambientEffect.Spawn(transform); effect.Play(); this.type = type; }