void OnCollision(SEntityEvent arg) { if (arg._event != EEntityEvent.ENTITY_EVENT_COLLISION) { Logger.LogError("Event passed into OnCollision was not a Collision."); return; } // As the only attached Entity event is the collision event, get physics of the collision. var collision = arg.GetEventPhysCollision(); // Retrieve both entities which are part of the collision. var entOne = Env.EntitySystem.GetEntityFromPhysics(collision.GetFirstEntity()); var entTwo = Env.EntitySystem.GetEntityFromPhysics(collision.GetSecondEntity()); if (entOne == null || entTwo == null) { return; } IEntity collider; if (entOne.GetId() == GameObject.Id) { collider = entTwo; } else { collider = entOne; } OnCollide?.Invoke(new CollisionEvent(collision, collider)); }
void OnCollision(SEntityEvent arg) { if (arg._event != EEntityEvent.ENTITY_EVENT_COLLISION) { return; } // As the only attached Entity event is the collision event, get physics of the collision. var collision = arg.GetEventPhysCollision(); // Retrieve both entities which are part of the collision. var entOne = Global.gEnv.pEntitySystem.GetEntityFromPhysics(collision.GetFirstEntity()); var entTwo = Global.gEnv.pEntitySystem.GetEntityFromPhysics(collision.GetSecondEntity()); IEntity collider = null; if (entOne != null && entTwo != null) { if (entOne.GetId() == Entity.Id) { collider = entTwo; } else { collider = entOne; } } OnCollide?.Invoke(new CollisionEvent(this, collision, collider)); }
public void OnCollisionEnter(Collision other) { var towerMB = other.collider.GetComponent <TowerElementMonoBehaviour>(); if (towerMB) { OnCollide.Invoke(towerMB); } }
private void OnTriggerEnter2D(Collider2D collision) { GameObject obj = collision.gameObject; if (obj.CompareTag(tags.ToString())) { OnCollide?.Invoke(obj); } }
private void OnCollisionEnter2D(Collision2D other) { if (!other.gameObject.CompareTag("BrickAndGround")) { return; } OnCollide?.Invoke(this); }
public void Update(int ticks) { _xTicks += ticks; _yTicks += ticks; while (_xTicks >= XRate || _yTicks >= YRate) { int dX = 0; int dY = 0; if (_xTicks >= XRate) { dX = XSign; _xTicks -= XRate; } if (_yTicks >= YRate) { dY = YSign; _yTicks -= YRate; } Coord newPos = Parent.Position + new Coord(dX, dY); if (Parent.CurrentMap?.GetEntity <IGameObject>(newPos, Parent.CurrentMap.LayerMasker.Mask(Parent.Layer)) is IGameObject collideWith) { OnCollide?.Invoke(collideWith); _destroyOnCollide?.DoDamage(new Damage(int.MaxValue)); break; } if (!Parent.CurrentMap?.WalkabilityView[newPos] ?? false) { OnCollide?.Invoke(Parent.CurrentMap.GetObject(newPos)); _destroyOnCollide?.DoDamage(new Damage(int.MaxValue)); break; } Parent.Position = newPos; } }
private void OnControllerColliderHit(ControllerColliderHit hit) { OnCollide?.Invoke(this.gameObject); }
public void CollideWith(Collider collider) => OnCollide?.Invoke(collider);
public void Collide(Entity other) { OnCollide?.Invoke(this, other); }