Exemplo n.º 1
0
 public TranslateMoveDB(TranslateMoveDB db)
 {
     TargetPositionDB = db.TargetPositionDB;
     CurrentVector    = db.CurrentVector;
     MoveRangeInKM    = db.MoveRangeInKM;
     IsAtTarget       = db.IsAtTarget;
 }
Exemplo n.º 2
0
 public TranslationMoveVM(Game game, CommandReferences cmdRef, Entity entity)
 {
     _tMoveDB = entity.GetDataBlob <TranslateMoveDB>();
     _posDB   = entity.GetDataBlob <PositionDB>();
     _propDB  = entity.GetDataBlob <PropulsionDB>();
     _cmdRef  = cmdRef;
     TargetList.SelectionChangedEvent += OnTargetSelectonChange;
     UpdateTargetList(entity.GetDataBlob <OwnedDB>().OwnedByFaction, entity.Manager);
 }
Exemplo n.º 3
0
        public TranslationMoveVM(Game game, CommandReferences cmdRef, Entity entity)
        {
            _tMoveDB = entity.GetDataBlob <TranslateMoveDB>();
            _posDB   = entity.GetDataBlob <PositionDB>();
            _propDB  = entity.GetDataBlob <PropulsionAbilityDB>();
            _cmdRef  = cmdRef;
            TargetList.SelectionChangedEvent += OnTargetSelectonChange;
            Entity faction;

            entity.Manager.FindEntityByGuid(entity.FactionOwner, out faction);
            UpdateTargetList(faction, entity.Manager);
        }
Exemplo n.º 4
0
        internal override void ActionCommand(Game game)
        {
            if (!IsRunning)
            {
                (Vector3 pos, DateTime eti)targetIntercept = InterceptCalcs.GetInterceptPosition(_entityCommanding, _targetEntity.GetDataBlob <OrbitDB>(), TransitStartDateTime, TargetOffsetPosition_AU);
                OrbitDB orbitDB    = _entityCommanding.GetDataBlob <OrbitDB>();
                Vector3 currentPos = OrbitProcessor.GetAbsolutePosition_AU(orbitDB, TransitStartDateTime);
                var     ralPos     = OrbitProcessor.GetPosition_AU(orbitDB, TransitStartDateTime);
                var     masses     = _entityCommanding.GetDataBlob <MassVolumeDB>().Mass + orbitDB.Parent.GetDataBlob <MassVolumeDB>().Mass;
                var     sgp        = GameConstants.Science.GravitationalConstant * masses / 3.347928976e33;

                //Vector4 currentVec = OrbitProcessor.PreciseOrbitalVector(sgp, ralPos, orbitDB.SemiMajorAxis);
                Vector2 currentVec = OrbitProcessor.GetOrbitalVector(orbitDB, TransitStartDateTime);
                _db = new TranslateMoveDB(targetIntercept.pos);
                _db.TranslateRalitiveExit_AU = TargetOffsetPosition_AU;
                _db.EntryDateTime            = TransitStartDateTime;
                _db.PredictedExitTime        = targetIntercept.eti;
                _db.TranslateEntryPoint_AU   = currentPos;
                _db.SavedNewtonionVector_AU  = currentVec;

                _db.ExpendDeltaV_AU = ExpendDeltaV;
                if (_targetEntity.HasDataBlob <SensorInfoDB>())
                {
                    _db.TargetEntity = _targetEntity.GetDataBlob <SensorInfoDB>().DetectedEntity;
                }
                else
                {
                    _db.TargetEntity = _targetEntity;
                }
                if (EntityCommanding.HasDataBlob <OrbitDB>())
                {
                    EntityCommanding.RemoveDataBlob <OrbitDB>();
                }
                EntityCommanding.SetDataBlob(_db);
                TranslateMoveProcessor.StartNonNewtTranslation(EntityCommanding);
                IsRunning = true;


                var distance   = (currentPos - targetIntercept.Item1).Length();
                var distancekm = Distance.AuToKm(distance);

                var time = targetIntercept.Item2 - TransitStartDateTime;

                double spd = _entityCommanding.GetDataBlob <PropulsionAbilityDB>().MaximumSpeed_MS;
                spd = Distance.MToAU(spd);
                var distb   = spd * time.TotalSeconds;
                var distbKM = Distance.AuToKm(distb);

                var dif = distancekm - distbKM;
                //Assert.AreEqual(distancekm, distbKM);
            }
        }
Exemplo n.º 5
0
        public TranslateMoveDB(TranslateMoveDB db)
        {
            LastProcessDateTime         = db.LastProcessDateTime;
            SavedNewtonionVector_AU     = db.SavedNewtonionVector_AU;
            TranslateEntryPoint_AU      = db.TranslateEntryPoint_AU;
            TranslateExitPoint_AU       = db.TranslateExitPoint_AU;
            CurrentNonNewtonionVectorMS = db.CurrentNonNewtonionVectorMS;
            ExpendDeltaV_AU             = db.ExpendDeltaV_AU;
            IsAtTarget   = db.IsAtTarget;
            TargetEntity = db.TargetEntity;

            TargetPositionDB = db.TargetPositionDB;
        }
Exemplo n.º 6
0
 internal override void ActionCommand(Game game)
 {
     if (!IsRunning)
     {
         _db = new TranslateMoveDB(_targetEntity.GetDataBlob <PositionDB>());
         _db.MoveRangeInKM = RangeInKM;
         if (EntityCommanding.HasDataBlob <OrbitDB>())
         {
             EntityCommanding.RemoveDataBlob <OrbitDB>();
         }
         EntityCommanding.SetDataBlob(_db);
         IsRunning = true;
     }
 }
Exemplo n.º 7
0
        /*
         * private static void SetOrbitClone(OrbitDB detectedEntitesOrbit, SensorInfoDB sensorInfo)
         * {
         *
         *  //var quality = sensorInfo.HighestDetectionQuality.detectedSignalQuality.Percent; //quality shouldn't affect positioning.
         *  double signalBestMagnatude = sensorInfo.HighestDetectionQuality.SignalStrength_kW;
         *  double signalNowMagnatude = sensorInfo.LatestDetectionQuality.SignalStrength_kW;
         *  if (signalNowMagnatude > 0)
         *  {
         *      OrbitDB sensorEntityOrbit = GenericClone<OrbitDB>(detectedEntitesOrbit, sensorInfo);
         *      //tweak add some random noise to the ecentricity etc of the sensorEntityOrbit depending on magnatude;
         *  }
         * }
         */

        private static void SetTranslateClone(TranslateMoveDB detectedEntitiesMove, SensorInfoDB sensorInfo)
        {
            //var quality = sensorInfo.HighestDetectionQuality.detectedSignalQuality.Percent; //quality shouldn't affect positioning.
            //double signalBestMagnatude = sensorInfo.HighestDetectionQuality.detectedSignalStrength_kW;
            double signalNowMagnatude = sensorInfo.LatestDetectionQuality.SignalStrength_kW;

            if (signalNowMagnatude > 0.0)
            {
                var sensorEntityMove = GenericClone <TranslateMoveDB>(detectedEntitiesMove, sensorInfo);

                sensorEntityMove.TargetPositionDB = null; //the sensorEntity shouldn't know the final destination.

                Vector4 velocityDetectionInacuracy = new Vector4()
                {
                };                                                      //some random noise depending on quality value

                sensorEntityMove.CurrentVector = detectedEntitiesMove.CurrentVector + velocityDetectionInacuracy;
            }
        }
Exemplo n.º 8
0
 internal override void ActionCommand(Game game)
 {
     if (!IsRunning)
     {
         var targetIntercept = InterceptCalcs.GetInterceptPosition(_entityCommanding, _targetEntity.GetDataBlob <OrbitDB>(), _entityCommanding.Manager.ManagerSubpulses.StarSysDateTime);
         _db = new TranslateMoveDB(targetIntercept.Item1);
         _db.EntryDateTime          = _entityCommanding.Manager.ManagerSubpulses.StarSysDateTime;
         _db.PredictedExitTime      = targetIntercept.Item2;
         _db.TranslateEntryPoint_AU = _entityCommanding.GetDataBlob <PositionDB>().AbsolutePosition_AU;
         _db.TargetEntity           = _targetEntity;
         if (EntityCommanding.HasDataBlob <OrbitDB>())
         {
             EntityCommanding.RemoveDataBlob <OrbitDB>();
         }
         EntityCommanding.SetDataBlob(_db);
         TranslateMoveProcessor.StartNonNewtTranslation(EntityCommanding);
         IsRunning = true;
     }
 }
Exemplo n.º 9
0
        void SetOrbitHere(Entity entity, PropulsionAbilityDB propulsionDB, PositionDB positionDB, TranslateMoveDB moveDB, DateTime atDateTime)
        {
            propulsionDB.CurrentVectorMS = new Vector3(0, 0, 0);

            double targetSOI = OrbitProcessor.GetSOI(moveDB.TargetEntity);

            Entity targetEntity;

            if (moveDB.TargetEntity.GetDataBlob <PositionDB>().GetDistanceTo(positionDB) > targetSOI)
            {
                targetEntity = moveDB.TargetEntity.GetDataBlob <OrbitDB>().Parent; //TODO: it's concevable we could be in another SOI not the parent (ie we could be in a target's moon's SOI)
            }
            else
            {
                targetEntity = moveDB.TargetEntity;
            }
            OrbitDB targetOrbit         = targetEntity.GetDataBlob <OrbitDB>();
            var     orbitalVector       = OrbitProcessor.GetOrbitalVector(targetOrbit, atDateTime);
            var     insertionVector2d   = OrbitProcessor.GetOrbitalInsertionVector(moveDB.SavedNewtonionVector_AU, targetOrbit, atDateTime);
            Vector3 parentOrbitalVector = new Vector3(orbitalVector.X, orbitalVector.Y, 0);
            Vector3 insertionVector     = new Vector3(insertionVector2d.X, insertionVector2d.Y, 0);

            insertionVector             += moveDB.ExpendDeltaV_AU; //TODO: only use it if we have it.
            propulsionDB.RemainingDV_MS -= (float)Distance.AuToMt(moveDB.ExpendDeltaV_AU).Length();
            OrbitDB newOrbit = OrbitDB.FromVector(targetEntity, entity, insertionVector, atDateTime);

            if (newOrbit.Periapsis > targetSOI)
            {
                //TODO: find who's SOI we're currently in and create an orbit for that;
            }
            if (newOrbit.Apoapsis > targetSOI)
            {
                //TODO: change orbit to new parent at SOI change
            }

            positionDB.SetParent(targetEntity);
            moveDB.IsAtTarget = true;
            entity.RemoveDataBlob <TranslateMoveDB>();
            entity.SetDataBlob(newOrbit);
            newOrbit.SetParent(targetEntity);
        }