2026-03-17 20:14:29 +01:00
|
|
|
using GlobalClassLib;
|
2026-03-22 18:31:05 +01:00
|
|
|
using ONDServer.Map;
|
2026-03-28 09:59:31 +01:00
|
|
|
using ONDServer.Net;
|
2026-03-17 20:14:29 +01:00
|
|
|
using PacketLib;
|
|
|
|
|
|
2026-03-22 18:31:05 +01:00
|
|
|
namespace ONDServer.Enemies;
|
2026-03-17 20:14:29 +01:00
|
|
|
|
|
|
|
|
public class MareEnemy : Enemy {
|
|
|
|
|
|
|
|
|
|
public override string Name{ get; } = "Mare";
|
2026-03-28 09:59:31 +01:00
|
|
|
public override EnemyType Type{ get; } = EnemyType.MARE;
|
2026-03-17 20:14:29 +01:00
|
|
|
public override bool BlocksTile{ get; set; } = true;
|
|
|
|
|
|
2026-03-28 09:59:31 +01:00
|
|
|
private readonly RoamingPathfinder pathfinder;
|
2026-03-25 16:37:18 +01:00
|
|
|
|
|
|
|
|
public ServerPlayer? Target{ get; set; }
|
|
|
|
|
public MareEnemy(int difficulty) : base(difficulty, 6000) {
|
2026-03-28 09:59:31 +01:00
|
|
|
pathfinder = new RoamingPathfinder(this, 1){ AdditionalConnectorFilter = c => c.Type != ConnectorType.VENT };
|
2026-03-17 20:14:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Reset() {
|
2026-03-19 20:10:45 +01:00
|
|
|
pathfinder.TakenPath.Clear();
|
2026-03-17 20:14:29 +01:00
|
|
|
Target = Server.OtherPlayer(Target);
|
2026-03-28 09:59:31 +01:00
|
|
|
Pathfinder.Decision decision = pathfinder.DecideNext(MapManager.Get(Target.State.OfficeTileId));
|
2026-03-17 20:14:29 +01:00
|
|
|
if (decision.type == Pathfinder.Decision.MoveType){
|
|
|
|
|
Location = decision.nextTile!;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 16:37:18 +01:00
|
|
|
Server.SendUpdateToAll([GameEvent.ENEMY_RESET(Id, Location.Id)]);
|
2026-03-17 20:14:29 +01:00
|
|
|
}
|
2026-03-28 09:59:31 +01:00
|
|
|
|
2026-03-17 20:14:29 +01:00
|
|
|
public override void Spawn(MapTile location) {
|
|
|
|
|
base.Spawn(location);
|
2026-03-28 09:59:31 +01:00
|
|
|
if (Server.P1.State.Power > Server.P2.State.Power){
|
2026-03-25 16:37:18 +01:00
|
|
|
Target = Server.P2;
|
|
|
|
|
}
|
2026-03-28 09:59:31 +01:00
|
|
|
else if(Server.P1.State.Power < Server.P2.State.Power){
|
2026-03-25 16:37:18 +01:00
|
|
|
Target = Server.P1;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
Target = new Random().Next(2) == 0 ? Server.P1 : Server.P2;
|
|
|
|
|
}
|
2026-03-17 20:14:29 +01:00
|
|
|
|
2026-03-28 09:59:31 +01:00
|
|
|
MovementOpportunity.Start();
|
2026-03-19 20:10:45 +01:00
|
|
|
pathfinder.TakenPath.Add(Location);
|
2026-03-28 09:59:31 +01:00
|
|
|
Server.SendUpdateToAll([GameEvent.ENEMY_SPAWN(Type, Id, Difficulty, Location.Id)]);
|
2026-03-17 20:14:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Update() {
|
|
|
|
|
base.Update();
|
|
|
|
|
|
2026-03-28 09:59:31 +01:00
|
|
|
if (MovementOpportunity.CheckAndRoll()){
|
2026-03-17 20:14:29 +01:00
|
|
|
if (Location.Owner != null && Location.Lit){
|
|
|
|
|
Attack(Location.Owner);
|
|
|
|
|
}
|
2026-03-25 16:37:18 +01:00
|
|
|
|
|
|
|
|
if (Target == null) return;
|
2026-03-17 20:14:29 +01:00
|
|
|
|
2026-03-28 09:59:31 +01:00
|
|
|
Pathfinder.Decision decision = pathfinder.DecideNext(MapManager.Get(Target.State.OfficeTileId));
|
2026-03-17 20:14:29 +01:00
|
|
|
switch (decision.type){
|
|
|
|
|
case Pathfinder.Decision.MoveType:
|
|
|
|
|
Location = decision.nextTile!;
|
|
|
|
|
Server.SendUpdateToAll([GameEvent.ENEMY_MOVEMENT(Id, Location.Id)]);
|
2026-03-28 09:59:31 +01:00
|
|
|
Console.WriteLine($"Enemy {Type} ({Name}) moving to {Location.IdAsString})");
|
2026-03-17 20:14:29 +01:00
|
|
|
break;
|
|
|
|
|
case Pathfinder.Decision.AttackType:
|
|
|
|
|
Attack(decision.attackTarget!);
|
|
|
|
|
break;
|
|
|
|
|
case Pathfinder.Decision.ResetType:
|
|
|
|
|
Reset();
|
|
|
|
|
break;
|
|
|
|
|
case Pathfinder.Decision.WaitType:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|