예제 #1
0
 internal override void ActionCommand(Game game)
 {
     OrderableProcessor.ProcessOrderList(game, NestedCommands);
     if (NestedCommands.Count == 0)
     {
         if (!IsRunning)
         {
             var    entPos     = _entityCommanding.GetDataBlob <PositionDB>().PositionInKm;
             var    tarPos     = _targetEntity.GetDataBlob <PositionDB>().PositionInKm;
             double distanceAU = PositionDB.GetDistanceBetween(_entityCommanding.GetDataBlob <PositionDB>(), _targetEntity.GetDataBlob <PositionDB>());
             var    rangeAU    = ApihelionInKM / GameConstants.Units.KmPerAu;
             if (Math.Abs(rangeAU - distanceAU) <= 500 / GameConstants.Units.MetersPerAu) //distance within 500m
             {
                 DateTime datenow  = _entityCommanding.Manager.ManagerSubpulses.SystemLocalDateTime;
                 var      newOrbit = ShipMovementProcessor.CreateOrbitHereWithPerihelion(_entityCommanding, _targetEntity, PerhelionInKM, datenow);
                 _entityCommanding.SetDataBlob(newOrbit);
                 IsRunning = true;
             }
             else //insert new translate move
             {
                 var cmd = new TranslateMoveCommand()
                 {
                     RequestingFactionGuid = this.RequestingFactionGuid, EntityCommandingGuid = this.EntityCommandingGuid, CreatedDate = this.CreatedDate, TargetEntityGuid = this.TargetEntityGuid, RangeInKM = this.ApihelionInKM
                 };
                 NestedCommands.Insert(0, cmd);
                 cmd.IsValidCommand(game);
                 cmd.ActionCommand(game);
             }
         }
     }
 }
예제 #2
0
 public void HandleOrder(EntityCommand entityCommand)
 {
     if (entityCommand.IsValidCommand(Game))
     {
         entityCommand.EntityCommanding.GetDataBlob <OrderableDB>().ActionList.Add(entityCommand);
         var commandList = entityCommand.EntityCommanding.GetDataBlob <OrderableDB>().ActionList;
         OrderableProcessor.ProcessOrderList(Game, commandList);
     }
 }