Exemplo n.º 1
0
        internal override void ActionCommand(Game game)
        {
            if (!IsRunning)
            {
                Entity  parentEntity = EntityCommanding.GetDataBlob <OrbitDB>().Parent;
                Vector2 newVector    = OrbitProcessor.InstantaneousOrbitalVelocityVector(EntityCommanding.GetDataBlob <OrbitDB>(), _db.ActionOnDateTime);
                newVector += _db.DeltaVToExpend_AU;
                var     spdmps      = Distance.AuToMt(newVector.Length());
                Vector3 newVector3d = new Vector3(newVector.X, newVector.Y, 0);
                OrbitDB newOrbit    = OrbitDB.FromVector(parentEntity, EntityCommanding, newVector3d, _db.ActionOnDateTime);

                /*
                 * 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
                 * }
                 */


                EntityCommanding.SetDataBlob(newOrbit);
                newOrbit.SetParent(parentEntity);
            }
        }
Exemplo n.º 2
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);
        }