public override void Execute() { // sanity check var emp = Executor.Owner; if (emp != Issuer) { Issuer.Log.Add(Issuer.CreateLogMessage("We cannot issue a command to delete another empire's waypoints!", LogMessages.LogMessageType.Error)); return; } Executor.Dispose(); Issuer.Log.Add(Issuer.CreateLogMessage(Executor.AlteredQueuesOnDelete + " vehicles' orders were truncated when " + Executor + " was deleted.", LogMessages.LogMessageType.Warning)); }
public override void Execute() { // sanity check var emp = Executor.Owner; if (emp != Issuer) { Issuer.Log.Add(Issuer.CreateLogMessage("We cannot issue a command to hotkey another empire's waypoints!")); return; } // replace old waypoint var oldWaypoint = emp.NumberedWaypoints[Hotkey]; emp.NumberedWaypoints[Hotkey] = Executor; if (Redirect) { int count = 0; foreach (var sobj in Galaxy.Current.FindSpaceObjects <IMobileSpaceObject>()) { bool found = false; // check if space object has orders to move to this waypoint // if so, change that order's waypoint to this one foreach (var order in sobj.Orders) { if (order is WaypointOrder) { var wo = order as WaypointOrder; if (wo.Target == oldWaypoint) { wo.Target = Executor; found = true; } } } if (found) { count++; } } if (count > 0) { emp.Log.Add(Issuer.CreateLogMessage(count + " vehicles were redirected from " + oldWaypoint + " to " + Executor + ".")); } } }