public void InvokeTriggerEnter(GameObject obj, FCollision collision)
 {
     if (onTriggerEnter.ContainsKey(obj))
     {
         onTriggerEnter[obj]?.Invoke(collision);
     }
 }
Пример #2
0
        protected void TriggerCollisionEnter(PhysCompoundCollider other)
        {
            if (other.IsValid)
            {
                collisionSet.Add(other);
            }

            FCollision collision = new FCollision()
            {
                Other          = other.gameObject,
                OtherCollider  = other,
                OtherRigidbody = other as PhysRigidbody
            };

            if (other.IsTrigger || IsTrigger)
            {
                PhysicsEngine.EventManager.InvokeTriggerEnter(gameObject, collision);
            }
            else
            {
                PhysicsEngine.EventManager.InvokeCollisionEnter(gameObject, collision);
            }

            if (collision.OtherRigidbody == null)
            {
                other.RemoteRegisterCollision(this);

                collision = new FCollision()
                {
                    Other          = this.gameObject,
                    OtherCollider  = this,
                    OtherRigidbody = this
                };

                if (other.IsTrigger || IsTrigger)
                {
                    PhysicsEngine.EventManager.InvokeTriggerEnter(other.gameObject, collision);
                }
                else
                {
                    PhysicsEngine.EventManager.InvokeCollisionEnter(other.gameObject, collision);
                }
            }
        }
Пример #3
0
        protected void TriggerCollisionExit(PhysCompoundCollider other)
        {
            collisionSet.Remove(other);

            FCollision collision = new FCollision()
            {
                Other          = other.gameObject,
                OtherCollider  = other,
                OtherRigidbody = other as PhysRigidbody
            };

            if (other.IsTrigger || IsTrigger)
            {
                PhysicsEngine.EventManager.InvokeTriggerExit(gameObject, collision);
            }
            else
            {
                PhysicsEngine.EventManager.InvokeCollisionExit(gameObject, collision);
            }

            if (!(other is PhysRigidbody))
            {
                other.RemoteUnregisterCollision(this);

                collision = new FCollision()
                {
                    Other          = this.gameObject,
                    OtherCollider  = this,
                    OtherRigidbody = this
                };

                if (other.IsTrigger || IsTrigger)
                {
                    PhysicsEngine.EventManager.InvokeTriggerExit(other.gameObject, collision);
                }
                else
                {
                    PhysicsEngine.EventManager.InvokeCollisionExit(other.gameObject, collision);
                }
            }
        }
Пример #4
0
        protected virtual void FixedUpdate()
        {
            //TODO: May result in performance problems. But we have to iterate through a copy in order to withstand a possible deletion of a collider component.
            HashSet <PhysCompoundCollider> copy = new HashSet <PhysCompoundCollider>(collisionSet);

            foreach (PhysCompoundCollider other in copy)
            {
                FCollision coll = new FCollision()
                {
                    Other          = other.gameObject,
                    OtherCollider  = other,
                    OtherRigidbody = other as PhysRigidbody
                };

                if (IsTrigger || other.IsTrigger)
                {
                    PhysicsEngine.EventManager.InvokeTriggerStay(this.gameObject, coll);
                }
                else
                {
                    PhysicsEngine.EventManager.InvokeCollisionStay(this.gameObject, coll);
                }
            }
        }
Пример #5
0
 private void CollisionStay(FCollision obj)
 {
     Debug.Log("Collision stay");
 }
Пример #6
0
 private void CollisionExit(FCollision obj)
 {
     Debug.Log("Collision exit");
 }
Пример #7
0
 private void CollisionEnter(FCollision obj)
 {
     Debug.Log("Collision enter");
 }