Exemplo n.º 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);
             }
         }
     }
 }
Exemplo n.º 2
0
        /*
         * private void OnOrbitCommand()
         * {
         *  OrbitBodyCommand newmove = new OrbitBodyCommand()
         *  {
         *      RequestingFactionGuid = _cmdRef.FactionGuid,
         *      EntityCommandingGuid = _cmdRef.EntityGuid,
         *      CreatedDate = _cmdRef.GetSystemDatetime,
         *      TargetEntityGuid = TargetList.SelectedKey,
         *      ApoapsisInKM = this.Range,
         *      PeriapsisInKM = this.Perihelion,
         *  };
         *  _cmdRef.Handler.HandleOrder(newmove);
         * }*/

        private void OnMoveCommand()
        {
            TranslateMoveCommand newmove = new TranslateMoveCommand()
            {
                RequestingFactionGuid = _cmdRef.FactionGuid,
                EntityCommandingGuid  = _cmdRef.EntityGuid,
                CreatedDate           = _cmdRef.GetSystemDatetime,
                TargetEntityGuid      = TargetList.SelectedKey,
                RangeInKM             = Range,
            };

            _cmdRef.Handler.HandleOrder(newmove);
        }