コード例 #1
0
ファイル: Planets.cs プロジェクト: dumbdiscord/FlightControl
 public static Planet GetBestGuessFromInitialData(IMyShipController remote)
 {
     if (!double.IsNaN(remote.GetNaturalGravity().Length()))
     {
         Planet   p = new Planet();
         Vector3D center;
         remote.TryGetPlanetPosition(out center);
         p.Center = center;
         double curdist = Vector3D.Distance(center, remote.GetPosition());
         double sealevelelevation;
         double curgrav = remote.GetNaturalGravity().Length();
         remote.TryGetPlanetElevation(MyPlanetElevation.Sealevel, out sealevelelevation);
         p.Radius            = curdist - sealevelelevation;
         p.GravityMathNumber = curgrav * Math.Pow(curdist, p.GravityExponent);
         if (curdist > p.Radius * (1 + p.HillParameter))
         {
             double mathvalue = curgrav * Math.Pow(curdist, p.GravityExponent);
             p.SurfaceGravity = mathvalue / Math.Pow(p.Radius * p.HillParameter + p.Radius, p.GravityExponent);
         }
         else
         {
             p.SurfaceGravity = curgrav;
         }
         return(p);
     }
     return(null);
 }
コード例 #2
0
        bool CollectParts(IMyTerminalBlock block, IMyCubeBlock reference)
        {
            if (reference.CubeGrid.EntityId != block.CubeGrid.EntityId)
            {
                return(false);
            }

            if (block is IMyGyro)
            {
                Drive.AddGyro((IMyGyro)block);
            }

            if (block is IMySmallGatlingGun)
            {
                Gats.Add((IMySmallGatlingGun)block);
            }

            if (block is IMyCameraBlock)
            {
                Cameras.Add((IMyCameraBlock)block);
            }

            if (block is IMyMotorStator)
            {
                TurretRotor = (IMyMotorStator)block;
            }

            if (block is IMyLargeTurretBase)
            {
                Designator = (IMyLargeTurretBase)block;
            }

            if (block is IMyThrust)
            {
                Drive.AddEngine(new HoverEngineDriver((IMyThrust)block));
            }

            if (block is IMyRadioAntenna)
            {
                Antenna = (IMyRadioAntenna)block;
            }

            if (block is IMyBeacon)
            {
                ((IMyBeacon)block).Enabled = false;
            }

            if (block is IMyShipController)
            {
                Controller = (IMyShipController)block;
                Controller.TryGetPlanetPosition(out PlanetPos);
                Drive.Controller = Controller;
            }

            return(false);
        }
コード例 #3
0
    private void Alignment(ShipControlCommons shipControl, IMyShipController controller)
    {
        Vector3D center;

        if (DropTarget == null || !controller.TryGetPlanetPosition(out center))
        {
            return;
        }

        // Project the target position to our sphere
        var targetRayDirection = Vector3D.Normalize((Vector3D)DropTarget - center);
        var myRayLength        = (shipControl.ReferencePoint - center).Length();
        var targetPosition     = center + targetRayDirection * myRayLength;

        // Now get offset to target point on our sphere
        // (not all that accurate over large distances, but eh)
        var targetOffset = targetPosition - shipControl.ReferencePoint;

        // Project targetOffset along each reference vector,
        // set cruiser speed appropriately
        AlignmentThrust(shipControl, targetOffset, LongCruiser);
        AlignmentThrust(shipControl, targetOffset, LatCruiser);
    }
コード例 #4
0
ファイル: vtvlhelper.cs プロジェクト: ZerothAngel/SEScripts
    private void Alignment(ShipControlCommons shipControl, IMyShipController controller)
    {
        Vector3D center;
        if (DropTarget == null || !controller.TryGetPlanetPosition(out center)) return;

        // Project the target position to our sphere
        var targetRayDirection = Vector3D.Normalize((Vector3D)DropTarget - center);
        var myRayLength = (shipControl.ReferencePoint - center).Length();
        var targetPosition = center + targetRayDirection * myRayLength;

        // Now get offset to target point on our sphere
        // (not all that accurate over large distances, but eh)
        var targetOffset = targetPosition - shipControl.ReferencePoint;

        // Project targetOffset along each reference vector,
        // set cruiser speed appropriately
        AlignmentThrust(shipControl, targetOffset, LongCruiser);
        AlignmentThrust(shipControl, targetOffset, LatCruiser);
    }