public bool Contains(BoxEntity box) { return(Position.X - Size.X - box.Size.X <= box.Position.X && Position.Y - Size.Y - box.Size.Y <= box.Position.Y && box.Position.X <= Position.X + Size.X + box.Size.X && box.Position.Y <= Position.Y + Size.Y + box.Size.Y); }
public void ForEachCollidingEntity(BoxEntity source, Action <Entity> action) { foreach (Entity e in CollidingEntities) { if (source.Contains(e.Position) || (e is BoxEntity && source.Contains((BoxEntity)e))) { action(e); } } }
public override bool Collide(Entity source, RectangleF tileBB, float timestep, out int direction, out float time, out bool corner) { if (!(source is IEnemy)) { direction = 0; time = -1; corner = false; return(false); } return(BoxEntity.CollideMovable((Movable)source, tileBB, timestep, out direction, out time, out corner)); }
public override bool Collide(Entity source, RectangleF tileBB, float timestep, out int direction, out float time, out bool corner) { if (BoxEntity.CollideMovable((Movable)source, tileBB, timestep, out direction, out time, out corner)) { direction = direction & ~PassThroughs; if (source is Player) { if (((Player)source).FallThrough) { direction = direction & ~Chunk.Down; } } return(direction == 0 ? false : true); } return(false); }
public override bool Collide(Entity source, RectangleF tileBB, float timestep, out int direction, out float time, out bool corner) { return(BoxEntity.CollideMovable((Movable)source, tileBB, timestep, out direction, out time, out corner)); }