public static void MoveEntity(Map map, Player player, BaseNPC entity) { Vector2 v1 = new Vector2(entity.x, entity.y); Vector2 v2 = new Vector2(player.x, player.y); Cell newPosition = null; int distance = map.DistanceFrom(v1, v2); if (distance > entity.Aggro) { Cell start = map[entity.x, entity.y]; Point target = map.RandomPointInRandomRoom(); entity.AssignPath(GetPath(map, start, map[target])); } else { if (distance <= 1) { return; } Cell start = map[entity.x, entity.y]; Cell target = map[player.x, player.y]; entity.AssignPath(GetPath(map, start, target)); } if (entity.PathLength > 1) { entity.GetNextCell(); } newPosition = entity.GetNextCell(); entity.SetPosition(new Point(newPosition.x, newPosition.y)); }