2026-03-22 18:31:05 +01:00
|
|
|
using ONDServer.Map;
|
2026-03-08 16:55:49 +01:00
|
|
|
|
2026-03-22 18:31:05 +01:00
|
|
|
namespace ONDServer.Enemies;
|
2026-03-08 16:55:49 +01:00
|
|
|
|
|
|
|
|
public class EnemyManager {
|
|
|
|
|
private static Dictionary<int, Enemy> enemies = new();
|
|
|
|
|
|
|
|
|
|
public static void Update() {
|
|
|
|
|
foreach (var pair in enemies){
|
|
|
|
|
if (pair.Value.Spawned) pair.Value.Update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Enemy AddEnemy(Enemy enemy) {
|
|
|
|
|
enemies.Add(enemy.Id, enemy);
|
|
|
|
|
return enemy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Enemy[] GetByLocation(MapTile tile) {
|
|
|
|
|
List<Enemy> output = new();
|
|
|
|
|
foreach (var e in enemies.Values){
|
|
|
|
|
if (e.Location == tile){
|
|
|
|
|
output.Add(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return output.ToArray();
|
|
|
|
|
}
|
2026-03-19 21:18:06 +01:00
|
|
|
|
|
|
|
|
public static Enemy Get(int id) => enemies[id];
|
|
|
|
|
public static Enemy[] GetAll() => enemies.Values.ToArray();
|
2026-03-08 16:55:49 +01:00
|
|
|
}
|