private void OnCollisionEnded(EventData_Collision eventData) { CleanCurrentCollisions(); bool areaOneIsThis = eventData.ColliderOne.MyArea.InstanceID == this.InstanceID; bool colOneIsInArea = _areaColliders.Contains(eventData.ColliderOne); bool colTwoIsInArea = _areaColliders.Contains(eventData.ColliderTwo); if (!IsValidCollision(colOneIsInArea, colTwoIsInArea)) { return; } CollisionArea thisArea = this; CollisionArea hittingArea = areaOneIsThis ? eventData.ColliderTwo.MyArea : eventData.ColliderOne.MyArea; Collider hitCollider = colOneIsInArea ? eventData.ColliderOne : eventData.ColliderTwo; Collider hittingCollider = colOneIsInArea ? eventData.ColliderTwo : eventData.ColliderOne; _currentCollisions.Remove(hittingCollider); bool isLastCollider = !_currentCollisions.Contains(hittingCollider); if (isLastCollider || !collidersOnlyExitOnLast) { SendCollisionAreaEnded(thisArea, hittingArea, hitCollider, hittingCollider); } }
public void SetColliderIgnoreArea(CollisionArea theArea) { for (int i = 0; i < _areaColliders.Count; i++) { _areaColliders[i].ignoreAreas.Add(theArea); } }
private void SendCollisionAreaEnded(CollisionArea thisArea, CollisionArea hittingArea, Collider hitCollider, Collider hittingCollider) { #if DebugExit DebugLog.Simple("<color=red>Collision Ended</color>\r\nCol One: ", ourCollider, "Col Two: ", hittingCollider); #endif EventData_Collision eventData = new EventData_Collision(); eventData.HitArea = thisArea; eventData.HittingArea = hittingArea; eventData.HitCollider = hitCollider; eventData.HittingCollider = hittingCollider; GameManager.Events.Broadcast <EventType_Collision> ((int)EventType_Collision.AreaCollisionEnded, eventData); }