private void OnCollisionExit2D(Collision2D other) { if (IsPenguin(other.collider)) { OnCollisionExit.Invoke(currentPenguin); } }
public override void Update(double totalSeconds) { base.Update(totalSeconds); #region Collision update if (TranslationVector != Vector2.Zero) { _boundingCircle.Center = new Point2(WorldPosition.X, WorldPosition.Y); } foreach (AEntity entity in GameDatas.AllEntities.Values) { if (entity is CollidableEntity && this != entity) { if (_boundingCircle.Intersects(((CollidableEntity)entity)._boundingCircle)) { if (!_collideWith.ContainsKey(entity.Id)) { ((CollidableEntity)entity).OnCollisionEnter?.Invoke(null, this); OnCollisionEnter?.Invoke(null, (CollidableEntity)entity); } else { ((CollidableEntity)entity).OnCollisionStay?.Invoke(null, this); OnCollisionStay?.Invoke(null, (CollidableEntity)entity); } } else { ((CollidableEntity)entity).OnCollisionExit?.Invoke(null, this); OnCollisionExit?.Invoke(null, (CollidableEntity)entity); } } } #endregion Collision update }
public void HandlePhysicsEvents() { for (int i = 0; i < currentlyCollidingWith.Count; i++) { if (lastCollidedWith.Contains(currentlyCollidingWith[i])) { //Collided with it last frame. if (coll.isTrigger) { OnTriggerStay?.Invoke(currentlyCollidingWith[i]); } else { OnCollisionStay?.Invoke(new TFCollision(currentlyCollidingWith[i])); } } else { //Did not collide with last frame. if (coll.isTrigger) { OnTriggerEnter?.Invoke(currentlyCollidingWith[i]); } else { OnCollisionEnter?.Invoke(new TFCollision(currentlyCollidingWith[i])); } } } for (int w = 0; w < lastCollidedWith.Count; w++) { //If we've exited collision with a collider. if (!currentlyCollidingWith.Contains(lastCollidedWith[w])) { if (coll.isTrigger) { OnTriggerExit?.Invoke(lastCollidedWith[w]); } else { OnCollisionExit?.Invoke(new TFCollision(lastCollidedWith[w])); } } } lastCollidedWith = new List <TFCollider>(currentlyCollidingWith); currentlyCollidingWith.Clear(); }
public override void Update(float deltaTime) { Vector2 mousePos = Scene.Active.MainViewport.ScreenToWorldCoordinates(InputHandler.MousePosition); // TODO bool contains = this.shape.Contains(GameObject.Transform, mousePos); if (contains && !contained) { OnCollisionEnter?.Invoke(this, null, null); // TODO } else if (!contains && contained) { OnCollisionExit?.Invoke(this, null, null); // TODO } this.contained = contains; }
public void CheckIfStillIntersecting() { foreach (Collider item in IntersectingColliders) { if (shape.Intersects(item.shape)) { OnCollisionStay?.Invoke(this, new Collision() { Caller = this, otherCollider = item }); } else { OnCollisionExit?.Invoke(this, new Collision() { Caller = this, otherCollider = item }); } } }
void DispatchOnCollisionExit(Collision collision) { OnCollisionExit?.Invoke(collision, GetCollidingBone(collision)); }
void OnCollisionExit2D(Collision2D collision) { OnCollisionExit?.Invoke(collision); }
private void OnCollisionExit2D(Collision2D other) { OnCollisionExit?.Invoke(other); }
private void OnCollisionExit2D(Collision2D other) { OnCollisionExit?.Invoke(other, gameObject); }
public void DoCollisionCheck(bool triggered = false, CollidAble collidable = null) { if (IsActiv) { List <CollidAble> collisions; List <int> alreadyExists = new List <int>(); if (!triggered) { grids = CollisionDetection.ActivCollisionDetection.UpdateGrids(this); collisions = CollisionDetection.ActivCollisionDetection.CheckCollision(this); } else { collisions = new List <CollidAble>(); collisions.Add(collidable); } if (OnCollisionExit != null || OnTriggerExit != null) { for (int i = 0; i < previouseCollisions.Length; i++) { if (!collisions.Contains(previouseCollisions[i])) { if (blocking && previouseCollisions[i].blocking) { OnCollisionExit?.Invoke(previouseCollisions[i], new CollisionArgs(previouseCollisions[i])); if (!triggered) { collisions[i].DoCollisionCheck(true, this); } } else { OnTriggerExit?.Invoke(previouseCollisions[i], new CollisionArgs(previouseCollisions[i])); if (!triggered) { collisions[i].DoCollisionCheck(true, this); } } } else { alreadyExists.Add(i); } } } for (int i = 0; i < collisions.Count; i++) { if (!alreadyExists.Contains(i)) { if (blocking && collisions[i].blocking) { OnCollisionEnter?.Invoke(collisions[i], new CollisionArgs(collisions[i])); if (!triggered) { collisions[i].DoCollisionCheck(true, this); } } else { OnTriggerEnter?.Invoke(collisions[i], new CollisionArgs(collisions[i])); if (!triggered) { collisions[i].DoCollisionCheck(true, this); } } } else { if (blocking && collisions[i].blocking) { OnCollision?.Invoke(collisions[i], new CollisionArgs(collisions[i])); if (!triggered) { collisions[i].DoCollisionCheck(true, this); } } else { OnTrigger?.Invoke(collisions[i], new CollisionArgs(collisions[i])); if (!triggered) { collisions[i].DoCollisionCheck(true, this); } } } } } }
void DispatchOnCollisionExit(Collision collision, CollisionEventDispatcher dispatcher) { OnCollisionExit?.Invoke(collision, bones[dispatcher]); }
private void OnCollExit(Collider other) { OnCollisionExit?.Invoke(other); }
void OnTriggerExit(Collider other) { OnCollisionExit?.Invoke(); }
public static void CollisionExit(BC_CollisionData data) { //DebugManager.LogToFile("[OnCollisionExit] " + data.collider.name + " exited collision with " + data.myCollider.name + " at point " + data.point.ToString() + " with normal of " + data.normal.ToString()); OnCollisionExit?.Invoke(data); }