using System; namespace Server { public interface IEntity : IPoint3D, IComparable { Serial Serial { get; } Point3D Location { get; } Map Map { get; } bool Deleted { get; } void MoveToWorld(Point3D location, Map map); void Delete(); void ProcessDelta(); bool InRange(Point2D p, int range); bool InRange(Point3D p, int range); bool InRange(IPoint2D p, int range); } public class Entity : IEntity, IComparable { public Entity(Serial serial, Point3D loc, Map map) { Serial = serial; Location = loc; Map = map; Deleted = false; } public int CompareTo(Entity other) => CompareTo((IEntity)other); public int CompareTo(IEntity other) => other == null ? -1 : Serial.CompareTo(other.Serial); public Serial Serial { get; } public Point3D Location { get; private set; } public int X => Location.X; public int Y => Location.Y; public int Z => Location.Z; public Map Map { get; private set; } public virtual void MoveToWorld(Point3D newLocation, Map map) { Location = newLocation; Map = map; } public bool Deleted { get; } public void Delete() { } public void ProcessDelta() { } public bool InRange(Point2D p, int range) => p.m_X >= Location.m_X - range && p.m_X <= Location.m_X + range && p.m_Y >= Location.m_Y - range && p.m_Y <= Location.m_Y + range; public bool InRange(Point3D p, int range) => p.m_X >= Location.m_X - range && p.m_X <= Location.m_X + range && p.m_Y >= Location.m_Y - range && p.m_Y <= Location.m_Y + range; public bool InRange(IPoint2D p, int range) => p.X >= Location.m_X - range && p.X <= Location.m_X + range && p.Y >= Location.m_Y - range && p.Y <= Location.m_Y + range; } }