コード例 #1
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);
            }
        }
コード例 #2
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;
     }
 }
コード例 #3
0
        public static double CalcDVDifference_m(Entity entity1, Entity entity2)
        {
            double dvDif = 0;

            Entity parent;
            double parentMass;
            double sgp;
            double r1;
            double r2;

            Entity soi1 = Entity.GetSOIParentEntity(entity1);
            Entity soi2 = Entity.GetSOIParentEntity(entity2);


            if (soi1 == soi2)
            {
                parent     = soi1;
                parentMass = parent.GetDataBlob <MassVolumeDB>().MassDry;
                sgp        = OrbitMath.CalculateStandardGravityParameterInM3S2(0, parentMass);


                var state1 = Entity.GetRalitiveState(entity1);
                var state2 = Entity.GetRalitiveState(entity2);
                r1 = state1.pos.Length();
                r2 = state2.pos.Length();
            }
            else
            {
                StaticRefLib.EventLog.AddEvent(new Event("Cargo calc failed, entities must have same soi parent"));
                return(double.PositiveInfinity);
            }

            var hohmann = InterceptCalcs.Hohmann(sgp, r1, r2);

            return(dvDif = hohmann[0].deltaV.Length() + hohmann[1].deltaV.Length());
        }