internal bool checkValidDockCommand(MessageShipCommand msg) { if (msg.Command.CommandType == ShipCommandEnum.Dock && _model.DockedPlanet == null && _model.ShipState != ShipStateEnum.Docked) { return true; } return false; }
internal bool checkValidSetDestinationCommand(MessageShipCommand msg) { if (msg.Command.CommandType == ShipCommandEnum.SetDestination) { return true; } return false; }
internal bool ReceiveCommandForShip(MessageShipCommand msg) { bool success = false; ShipController sc = _shipCs[msg.ShipId]; // check the ship *could* execute this command if (msg.Command.CommandType == ShipCommandEnum.Undock) { success = ShipUndock(msg, sc); } else if (msg.Command.CommandType == ShipCommandEnum.SetDestination) { success = ShipSetDestination(msg, sc); } else if (msg.Command.CommandType == ShipCommandEnum.Dock) { success = ShipDock(msg, sc); } return success; }
private void receiveCommandForShip(MessageShipCommand msg) { bool success = _solarSystemC.ReceiveCommandForShip(msg); MessageShipResponse msr = new MessageShipResponse(success, msg, _curTick); Sender.Tell(msr); }
private object pilotingShip(MessageTick tick) { if (isPilotingShip()) { if (_model.CurrentShipDestinationScId != _memory.CurrentDestinationScId) { IMessageShipCommandData msd = new MessageShipSetDestination(ShipCommandEnum.SetDestination, _memory.CurrentDestinationScId); MessageShipCommand msc = new MessageShipCommand(msd, tick.Tick, _model.CurrentShipId); ScPlanet curDest = StarChart.GetPlanet(_memory.CurrentDestinationScId); //_actorTextOutput.Tell("Agent Piloting Ship towards " + curDest.Name); return msc; } } return null; }
public MessageShipResponse(bool response, MessageShipCommand sentCommand, Int64 tickSent) { Response = response; SentCommand = sentCommand; TickSent = tickSent; }
private bool ShipUndock(MessageShipCommand msg, ShipController sc) { bool success = false; if (sc.checkValidUndockCommand(msg)) { _planetCs[sc.DockedPlanet.PlanetId].UndockShip(msg.ShipId); sc.Undock(); success = true; } return success; }
private bool ShipDock(MessageShipCommand msg, ShipController sc) { bool success = false; if (sc.checkValidDockCommand(msg)) { Ship s = _model.Ships.Where(x => x.ShipId == msg.ShipId).First(); _planetCs[sc.GetDestination.PlanetId].DockShip(s); sc.Dock(); success = true; } return success; }
private static bool ShipSetDestination(MessageShipCommand msg, ShipController sc) { bool success = false; if (sc.checkValidSetDestinationCommand(msg)) { MessageShipSetDestination msd = (MessageShipSetDestination)msg.Command; sc.SetDestination(msd.DestinationScId); success = true; } return success; }