public void ResolveOrder(Actor self, Order order) { if (order.OrderString == "Move") { var cell = self.World.Map.Clamp(order.TargetLocation); var explored = self.Owner.Shroud.IsExplored(cell); if (!explored && !Info.MoveIntoShroud) { return; } UnReserve(); var target = Target.FromCell(self.World, cell); self.SetTargetLine(target, Color.Green); self.CancelActivity(); self.QueueActivity(new Fly(self, target)); self.QueueActivity(new FlyCircle()); } else if (order.OrderString == "Enter") { if (Reservable.IsReserved(order.TargetActor)) { return; } UnReserve(); self.SetTargetLine(Target.FromOrder(self.World, order), Color.Green); self.CancelActivity(); self.QueueActivity(new ReturnToBase(self, order.TargetActor)); self.QueueActivity(new ResupplyAircraft()); } else if (order.OrderString == "Stop") { UnReserve(); self.CancelActivity(); } else if (order.OrderString == "ReturnToBase") { var airfield = ReturnToBase.ChooseAirfield(self, true); if (airfield == null) { return; } UnReserve(); self.CancelActivity(); self.SetTargetLine(Target.FromActor(airfield), Color.Green); self.QueueActivity(new ReturnToBase(self, airfield)); self.QueueActivity(new ResupplyAircraft()); } else { // Game.Debug("Unreserve due to unhandled order: {0}".F(order.OrderString)); UnReserve(); } }
public void ResolveOrder(Actor self, Order order) { if (order.OrderString == "Move") { UnReserve(); var target = self.World.ClampToWorld(order.TargetLocation); self.SetTargetLine(Target.FromCell(target), Color.Green); self.CancelActivity(); self.QueueActivity(Fly.ToCell(target)); self.QueueActivity(new FlyCircle()); } else if (order.OrderString == "Enter") { if (Reservable.IsReserved(order.TargetActor)) { return; } UnReserve(); self.SetTargetLine(Target.FromOrder(order), Color.Green); self.CancelActivity(); self.QueueActivity(new ReturnToBase(self, order.TargetActor)); self.QueueActivity(new ResupplyAircraft()); } else if (order.OrderString == "Stop") { UnReserve(); self.CancelActivity(); } else if (order.OrderString == "ReturnToBase") { var airfield = ReturnToBase.ChooseAirfield(self); if (airfield == null) { return; } UnReserve(); self.CancelActivity(); self.SetTargetLine(Target.FromActor(airfield), Color.Green); self.QueueActivity(new ReturnToBase(self, airfield)); self.QueueActivity(new ResupplyAircraft()); } else { // Game.Debug("Unreserve due to unhandled order: {0}".F(order.OrderString)); UnReserve(); } }
public void TickIdle(Actor self) { // We're on the ground, let's stay there. if (self.CenterPosition.Z == 0) { return; } var airfield = ReturnToBase.ChooseAirfield(self, true); if (airfield != null) { self.QueueActivity(new ReturnToBase(self, airfield)); self.QueueActivity(new ResupplyAircraft()); } else { // nowhere to land, pick something friendly and circle over it. // i'd prefer something we own var someBuilding = self.World.ActorsWithTrait <Building>() .Select(a => a.Actor) .FirstOrDefault(a => a.Owner == self.Owner); // failing that, something unlikely to shoot at us if (someBuilding == null) { someBuilding = self.World.ActorsWithTrait <Building>() .Select(a => a.Actor) .FirstOrDefault(a => self.Owner.Stances[a.Owner] == Stance.Ally); } if (someBuilding == null) { // ... going down the garden to eat worms ... self.QueueActivity(new FlyOffMap()); self.QueueActivity(new RemoveSelf()); return; } self.QueueActivity(Fly.ToCell(someBuilding.Location)); self.QueueActivity(new FlyCircle()); } }