Example #1
0
        private void Init()
        {
            try
            {
                NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME;
                NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;

                m_iThrust                  = Entity as IMyThrust;
                m_thrust                   = m_iThrust as MyThrust;
                m_cubeBlock                = (m_iThrust as IMyCubeBlock) as MyCubeBlock;
                m_slimBlock                = (m_iThrust as IMyCubeBlock).SlimBlock;
                m_termBlock                = m_iThrust as IMyTerminalBlock;
                m_entityId                 = m_iThrust.EntityId;
                m_minMultiplier            = m_iThrust.ThrustMultiplier;
                m_maxHeat                  = m_slimBlock.MaxIntegrity;
                m_damageHeat               = m_maxHeat * 2;
                MaxMultiplier              = m_minMultiplier * Overclock;
                m_iThrust.ThrustMultiplier = MaxMultiplier;
                _cubeGridEntityId          = m_cubeBlock.CubeGrid.EntityId;

                if (Sync.IsServer)
                {
                    NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;
                }

                m_initialized = true;
            }
            catch (Exception e)
            {
                Debug.HandleException(e);
                MyAPIGateway.Parallel.Sleep(1000);
                Init();
            }
        }
        public float[] GetAccelerationsByDirection(IMyCubeGrid grid)
        {
            if (grid == null || grid.Physics == null)
            {
                return(new float[6]);
            }

            float mass = ((MyCubeGrid)grid).GetCurrentMass();

            float[] accelerations = new float[6];

            foreach (IMySlimBlock slim in (grid as MyCubeGrid).CubeBlocks)
            {
                if (!(slim.FatBlock is IMyThrust))
                {
                    continue;
                }

                IMyThrust thruster = slim.FatBlock as IMyThrust;

                Direction direction = GetDirection(thruster.GridThrustDirection);

                accelerations[(int)direction] += thruster.MaxThrust;
            }

            // convert from force to accleration (m = f/a)
            for (int i = 0; i < 6; i++)
            {
                accelerations[i] /= mass;
            }

            return(accelerations);
        }
Example #3
0
            public int powerDownThrusters(List <IMyTerminalBlock> thrusters, int iTypes = thrustAll, bool bForceOff = false)
            {
                int iCount = 0;

                for (int thrusterIndex = 0; thrusterIndex < thrusters.Count; thrusterIndex++)
                {
                    int iThrusterType = ThrusterType(thrusters[thrusterIndex]);
                    if ((iThrusterType & iTypes) > 0)
                    {
                        iCount++;
                        IMyThrust thruster = thrusters[thrusterIndex] as IMyThrust;
                        thruster.ThrustOverride = 0;
                        //                    thruster.SetValueFloat("Override", 0);
                        if (thruster.IsWorking && bForceOff && thruster.Enabled == true) // Yes, the check is worth it
                        {
                            thruster.Enabled = false;                                    // ApplyAction("OnOff_Off");
                        }
                        else if (!thruster.IsWorking && !bForceOff && thruster.Enabled == false)
                        {
                            thruster.Enabled = true;// ApplyAction("OnOff_On");
                        }
                    }
                }
                return(iCount);
            }
Example #4
0
    Program()
    {
        // Создаем списки
        ThrList      = new List <IMyThrust>();
        MassList     = new List <IMyArtificialMassBlock>();
        gravigenlist = new List <IMyGravityGenerator>();

        // Находим генераторы гравитации
        GridTerminalSystem.GetBlocksOfType <IMyGravityGenerator>(gravigenlist);

        //Находим гироскоп
        gyroscope = GridTerminalSystem.GetBlockWithName("MB-1 Gyro GD") as IMyGyro;

        // Находим движки
        GridTerminalSystem.GetBlocksOfType <IMyThrust>(ThrList);
        foreach (IMyThrust thr in ThrList)
        {
            if (thr.CustomName.Contains("[Backward]"))
            {
                ThrBackward = thr;
            }
            else if (thr.CustomName.Contains("[Forward]"))
            {
                ThrForward = thr;
            }
        }
        // Находим блоки искусст. массы

        GridTerminalSystem.GetBlocksOfType <IMyArtificialMassBlock>(MassList);

        Runtime.UpdateFrequency = UpdateFrequency.Update1;
    }
        bool CollectParts(IMyTerminalBlock block)
        {
            if (Context.Reference.CubeGrid.EntityId != block.CubeGrid.EntityId)
            {
                return(false);
            }

            if (block is IMyShipController && ((IMyShipController)block).CanControlShip)
            {
                controller = (IMyShipController)block;
            }

            if (block is IMyThrust)
            {
                IMyThrust thruster = (IMyThrust)block;
                thrustersList.Add(thruster);
                thruster.ThrustOverride = 0;
                thrusterManager.AddThruster(thruster);
            }

            if (block is IMyGyro)
            {
                IMyGyro gyro = (IMyGyro)block;
                gyros.Add(gyro);
                gyro.Pitch        = 0;
                gyro.Yaw          = 0;
                gyro.Roll         = 0;
                gyro.GyroOverride = false;
            }

            return(false);
        }
Example #6
0
        int powerUpThrusters(List <IMyTerminalBlock> thrusters, float fPower, int iTypes = thrustAll)
        {
            int iCount = 0;

            if (fPower > 100)
            {
                fPower = 100;
            }
            if (fPower < 0)
            {
                fPower = 0;
            }
            for (int thrusterIndex = 0; thrusterIndex < thrusters.Count; thrusterIndex++)
            {
                int iThrusterType = thrusterType(thrusters[thrusterIndex]);
                if ((iThrusterType & iTypes) > 0)
                {
                    IMyThrust thruster = thrusters[thrusterIndex] as IMyThrust;
//                    float maxThrust = thruster.GetMaximum<float>("Override");
                    if (!thruster.IsWorking)
                    {
                        thruster.Enabled = true;// ApplyAction("OnOff_On");
                    }
                    iCount += 1;
                    thruster.ThrustOverridePercentage = fPower;
//                    thruster.SetValueFloat("Override", maxThrust * (fPower / 100.0f));
                }
            }
            return(iCount);
        }
Example #7
0
            /// <summary>
            /// Turns on thrusters and sets the override.
            /// </summary>
            /// <param name="thrusters">list of thrusters to use</param>
            /// <param name="fPower">power setting 0->100</param>
            /// <param name="iTypes">Type of thrusters to control. Default is all</param>
            /// <returns>number of thrusters changed</returns>
            public int powerUpThrusters(List <IMyTerminalBlock> thrusters, float fPower, int iTypes = thrustAll)
            {
                int iCount = 0;

                if (fPower > 100)
                {
                    fPower = 100;
                }
                if (fPower < 0)
                {
                    fPower = 0;
                }
                for (int thrusterIndex = 0; thrusterIndex < thrusters.Count; thrusterIndex++)
                {
                    int iThrusterType = ThrusterType(thrusters[thrusterIndex]);
                    if ((iThrusterType & iTypes) > 0)
                    {
                        IMyThrust thruster = thrusters[thrusterIndex] as IMyThrust;
                        if (!thruster.IsWorking)
                        {
                            if (!thruster.Enabled) // yes, this is worth the cost to check.
                            {
                                thruster.Enabled = true;
                            }
                        }
                        iCount += 1;
                        thruster.ThrustOverridePercentage = fPower / 100f;
                    }
                }
                return(iCount);
            }
Example #8
0
 public void Main(string argument, UpdateType updateSource)
 {
     str = "";
     if (Me.CustomData == "0")
     {
         foreach (var th in thrusters)
         {
             IMyThrust thr = th as IMyThrust;
             th.ApplyAction("OnOff_On");
             thr.ThrustOverridePercentage = 0;
         }
         foreach (var item in Gyros)
         {
             item.GyroOverride = false;
         }
     }
     else
     {
         foreach (var th in thrusters)
         {
             IMyThrust thr = th as IMyThrust;
             thrusterControllr(thr);
         }
         gyroControll();
     }
     text.WritePublicText(str);
     Echo(Me.CustomData);
 }
        public override void Init(MyObjectBuilder_EntityBase objectBuilder)
        {
            m_thruster = Entity as IMyThrust;

            var blockDefinition = m_thruster.SlimBlock.BlockDefinition as MyThrustDefinition;

            m_flameIdleColor = blockDefinition.FlameIdleColor;
            m_flameFullColor = blockDefinition.FlameFullColor;

            lock (m_customControls)
            {
                if (m_customControls.Count == 0)
                {
                    CreateTerminalControls();
                }
            }

            OnCustomDataChanged(m_thruster);

            m_buildRatio = m_thruster.SlimBlock.BuildLevelRatio;
            m_thruster.CustomDataChanged += OnCustomDataChanged;

            // Multiplayer clients don't receive OnBlockIntegrityChange events, so don't bother...
            if (MyAPIGateway.Multiplayer.IsServer)
            {
                m_thruster.CubeGrid.OnBlockIntegrityChanged += OnIntegrityChanged;
            }

            NeedsUpdate |= (MyEntityUpdateEnum.BEFORE_NEXT_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME);

            m_initialized = true;
        }
Example #10
0
    public Thruster(IMyThrust t, MatrixD m, MyGridProgram argPg)
    {
        pg = argPg;
        th = t;
        double force = 0;

        if (t.DetailedInfo.Contains("Atmospheric"))
        {
            TYPE = ATM;
        }
        else if (t.DetailedInfo.Contains("Hydrogen"))
        {
            TYPE = HY;
        }
        else if (t.DetailedInfo.Contains("Thruster"))
        {
            TYPE = ION;
        }
        else
        {
        }
        force = t.MaxEffectiveThrust;

        FORCE = new Vector3D(0, 0, 0);
        if (t.WorldMatrix.Forward == m.Forward)
        {
            FORCE_DIM  = 2;
            FORCE_MULT = 1;
        }
        else if (t.WorldMatrix.Forward == m.Backward)
        {
            FORCE_DIM  = 2;
            FORCE_MULT = -1;
        }
        else if (t.WorldMatrix.Forward == m.Right)
        {
            FORCE_DIM  = 0;
            FORCE_MULT = -1;
        }
        else if (t.WorldMatrix.Forward == m.Left)
        {
            FORCE_DIM  = 0;
            FORCE_MULT = 1;
        }
        else if (t.WorldMatrix.Forward == m.Up)
        {
            FORCE_DIM  = 1;
            FORCE_MULT = -1;
        }
        else if (t.WorldMatrix.Forward == m.Down)
        {
            FORCE_DIM  = 1;
            FORCE_MULT = 1;
        }
        else
        {
            throw new Exception("Thruster(): invalid matrix");
        }
        FORCE.SetDim(FORCE_DIM, FORCE_MULT);
    }
Example #11
0
        public void assign_thruster(IMyThrust thruster_ref)
        {
            var thruster = (MyThrust)thruster_ref;

            if (MyAPIGateway.Multiplayer == null || MyAPIGateway.Multiplayer.IsServer)
            {
                thruster.SetValueFloat("Override", 0.0f);
            }
            var new_thruster = new thruster_info();

            new_thruster.grid_centre_pos  = (thruster.Min + thruster.Max) * (_grid.GridSize / 2.0f);
            new_thruster.max_force        = new_thruster.actual_max_force = thruster.BlockDefinition.ForceMagnitude;
            new_thruster.CoM_offset       = new_thruster.reference_vector = new_thruster.grid_centre_pos - _grid_CoM_location;
            new_thruster.static_moment    = new_thruster.grid_centre_pos * new_thruster.max_force;
            new_thruster.nozzle_direction = get_nozzle_orientation(thruster);
            new_thruster.override_cleared = false;
            new_thruster.is_RCS           = new_thruster.group_no_RCS = _thruster_added_or_removed = true;

            _max_force[(int)new_thruster.nozzle_direction] += new_thruster.max_force;
            _lin_force[(int)new_thruster.nozzle_direction] += new_thruster.max_force;
            _thrusters[(int)new_thruster.nozzle_direction].Add(thruster, new_thruster);
            //log_ECU_action("assign_thruster", string.Format("{0} ({1}) [{2}]\n\t\t\tCentre position: {3}",
            //    ((PB.IMyTerminalBlock) thruster).CustomName, new_thruster.nozzle_direction.ToString(), thruster.EntityId,
            //    new_thruster.grid_centre_pos));
        }
Example #12
0
        /**
         * SpaceEngineersIngameScript1
         * ==============
         * Copyright 2017 Thomas Klose <*****@*****.**>
         * License: https://github.com/BaconFist/SpaceEngineersIngameScript/blob/master/LICENSE
         *
         * Description
         * ===========
         *
         */

        public void Main(string argument)
        {
            List <IMyThrust> TL = new List <IMyThrust>();

            GridTerminalSystem.GetBlocksOfType <IMyThrust>(TL);
            if (TL.Count > 0)
            {
                IMyThrust T = TL[0];

                Vector3I directrionFromThruster = T.GridThrustDirection;

                List <IMyShipController> CL = new List <IMyShipController>();
                GridTerminalSystem.GetBlocksOfType <IMyShipController>(CL);
                string s = "";
                foreach (IMyShipController C in CL)
                {
                    Matrix m;
                    C.Orientation.GetMatrix(out m);
                    s += $"- [{C.CustomName}] T: {directrionFromThruster} => F: {m.Forward}\n";
                    s += $"- [{C.CustomName}] T: {directrionFromThruster} => B: {m.Backward}\n";
                    s += $"- [{C.CustomName}] T: {directrionFromThruster} => L: {m.Left}\n";
                    s += $"- [{C.CustomName}] T: {directrionFromThruster} => R: {m.Right}\n";
                    s += $"- [{C.CustomName}] T: {directrionFromThruster} => U: {m.Up}\n";
                    s += $"- [{C.CustomName}] T: {directrionFromThruster} => D: {m.Down}\n";
                    s += $"-------------------------------------------\n";
                }
                Me.CustomData = s;
                Echo($"{CL.Count} Controllers");
            }
            else
            {
                Echo("no Thruster");
            }
        }
Example #13
0
        private void OnEntityCreate(MyEntity ent)
        {
            //// Demo of adding an inventory with constraints to a block.
            //IMyBeacon beacon = ent as IMyBeacon;
            //if (beacon != null)
            //{
            //	if (!beacon.HasInventory)
            //	{
            //		MyInventoryConstraint constraint = new MyInventoryConstraint("testConstraint")
            //		{
            //			m_useDefaultIcon = false,
            //			Icon = $@"Textures\GUI\Icons\filter_uranium.dds",
            //			IsWhitelist = true
            //		};
            //		constraint.Add(new MyDefinitionId(typeof(MyObjectBuilder_Component), "InteriorPlate"));
            //		MyInventoryBase inventory = new MyInventory(5000, Vector3.One, MyInventoryFlags.CanReceive | MyInventoryFlags.CanSend)
            //		{
            //			Constraint = constraint
            //		};
            //		beacon.Components.Add(inventory);
            //	}
            //}


            IMyThrust thrust = ent as IMyThrust;

            if (thrust == null)
            {
                return;
            }
            DetailedThruster detailedThrust = new DetailedThruster(thrust);

            detailedThrust.OnWriteToLog += WriteToLog;
            _thrusters.Add(detailedThrust);
        }
Example #14
0
 internal static void sample_thruster(IMyThrust thruster)
 {
     if (!_thruster_controls_set && _sample_thruster == null)
     {
         _sample_thruster = thruster;
     }
 }
Example #15
0
        void SortThruster(IMyThrust thrust)
        {
            Vector3D front = thrust.WorldMatrix.Forward;

            if (front == control.WorldMatrix.Backward)
            {
                thruster[Side.Front].Add(thrust);
                maxThrust[Side.Front] += thrust.MaxThrust;
            }
            else if (front == control.WorldMatrix.Forward)
            {
                thruster[Side.Back].Add(thrust);
                maxThrust[Side.Back] += thrust.MaxThrust;
            }
            else if (front == control.WorldMatrix.Left)
            {
                thruster[Side.Right].Add(thrust);
                maxThrust[Side.Right] += thrust.MaxThrust;
            }
            else if (front == control.WorldMatrix.Right)
            {
                thruster[Side.Left].Add(thrust);
                maxThrust[Side.Left] += thrust.MaxThrust;
            }
            else if (front == control.WorldMatrix.Up)
            {
                thruster[Side.Down].Add(thrust);
                maxThrust[Side.Down] += thrust.MaxThrust;
            }
            else if (front == control.WorldMatrix.Down)
            {
                thruster[Side.Up].Add(thrust);
                maxThrust[Side.Up] += thrust.MaxThrust;
            }
        }
 public ControllableThruster(IMyThrust thisThruster, ThrustDirection thisDirection)
 {
     _thisIThruster         = thisThruster;
     ThrustDirection        = thisDirection;
     _thisThruster          = (MyThrust)thisThruster;
     _thisDefinition        = _thisThruster.BlockDefinition;
     _thisThruster.OnClose += Close;
 }
	public static void setThrust(this IMyThrust thruster, Vector3D desired) {
		var proj = desired.project(thruster.WorldMatrix.Backward);

		if(proj.dot(thruster.WorldMatrix.Backward) > 0) {//negative * negative is positive... so if its greater than 0, you ignore it.
			thruster.ThrustOverride = 0;
			return;
		}

		thruster.ThrustOverride = (float)proj.Length();
	}
Example #18
0
 public void ParserThrust(IMyThrust block)
 {
     WriteText($"=== Thrust Info ===", true);
     WriteText($"ThrustOverride={block.ThrustOverride}", true);
     WriteText($"ThrustOverridePercentage={block.ThrustOverridePercentage}", true);
     WriteText($"MaxThrust={block.MaxThrust}", true);
     WriteText($"MaxEffectiveThrust={block.MaxEffectiveThrust}", true);
     WriteText($"CurrentThrust={block.CurrentThrust}", true);
     WriteText($"GridThrustDirection={block.GridThrustDirection}", true);
 }
Example #19
0
        public override void Close()
        {
            if (m_block != null)
            {
                m_block.IsWorkingChanged -= OnIsWorkingChanged;
                m_block = null;
            }

            base.Close();
        }
        private void Exec_Setup()
        {
            _projector = GetBlocksOfTypeWithName <IMyProjector>("_MTB").FirstOrDefault();
            _timer     = GetBlocksOfTypeWithName <IMyTimerBlock>("_MTB").FirstOrDefault();
            _welders   = GetBlocksOfTypeWithName <IMyShipWelder>("_MTB");
            _cutters   = GetBlocksOfTypeWithName <IMyThrust>("_MTB");
            _torpDock  = GetBlocksOfTypeWithName <IMyShipConnector>("_MTB").FirstOrDefault();
            _piston    = GetBlocksOfTypeWithName <IMyPistonBase>("_MTB").FirstOrDefault();

            EchoText(
                "==SETUP== \n" +
                "\n" +
                "Projector: " + ((_projector != null) ? "Ok ✅" : "Not found") + "\n" +
                "Timer: " + ((_timer != null) ? "Ok ✅" : "Not found") + "\n" +
                "Welders: " + ((_welders != null) ? (_welders.Count > 0) ? "Ok ✅" : "Not found" : "Not found") + " (" + _cutters.Count + ")" + "\n" +
                "Torpedo Dock: " + ((_torpDock != null) ? "Ok ✅" : "Not found") + "\n" +
                "Piston: " + ((_piston != null) ? "Ok ✅" : "Not found") + "\n" +
                "Cutters: " + ((_cutters != null) ? (_cutters.Count > 0) ? "Ok ✅" : "Not found" : "Not found") + " (" + _cutters.Count + ")"
                );

            if (_projector == null || _timer == null || _welders == null || _cutters == null || _torpDock == null)
            {
                return;
            }

            if (_cutters.Count == 0)
            {
                return;
            }

            _shipTag = ParseTag(_torpDock.CubeGrid.CustomName);

            _projector.CustomName = _shipTag + "_MTB_" + "Projector";
            _timer.CustomName     = _shipTag + "_MTB_" + "Timer"; //..setup timer actions automatically?
            _torpDock.CustomName  = _shipTag + "_MTB_" + "TorpedoDock";
            _piston.CustomName    = _shipTag + "_MTB_" + "Piston";

            //..name the welders
            for (int i = 0; i < _welders.Count; ++i)
            {
                IMyShipWelder w = _welders[i];
                w.Enabled    = false;
                w.CustomName = _shipTag + "_MTB_" + "Welder_" + (i + 1);
            }

            //..make sure all the cutters are off to begin with
            for (int i = 0; i < _cutters.Count; ++i)
            {
                IMyThrust t = _cutters[i];

                t.ThrustOverridePercentage = 1;
                t.Enabled    = false;
                t.CustomName = _shipTag + "_MTB_" + "Cutter_" + (i + 1);
            }
        }
        private void Update()
        {
            //-Prepare data
            //  >get local gravity vector
            //  >normalise vector to simplify angle calculation
            Vector3D
                worldGravity = controller.GetNaturalGravity();

            worldGravity.Normalize();

            //Check each thruster to see if it is safe to enable
            //-only check thrusters on our grid
            //-check that we have access to the thruster
            //-disable any that are pointing down
            //  >(with safetyCutoff tolerance)
            //  >enable any others
            GridTerminalSystem.GetBlocksOfType <IMyThrust>(temp);
            int count = 0;

            for (int i = 0; i < temp.Count; i++)
            {
                IMyThrust thruster = (IMyThrust)temp[i];

                if (thruster.CubeGrid != controller.CubeGrid)
                {
                    continue;
                }

                count++;
                //Check if we can actually use the thruster
                if (ValidateBlock(thruster, callbackRequired: false))
                {
                    Vector3D
                        worldThruster = GridToWorld(
                        Base6Directions.GetIntVector(thruster.Orientation.Forward),
                        thruster.CubeGrid);
                    //Compare the dot product of gravity and thrust direction (normalised)
                    // 1.0 => 0 degrees
                    // 0.0 => 90 degrees
                    //-1.0 => 180 degrees
                    //safe iff angle <= safetyCutoffAngle
                    //=> safe iff dot product >= cos(safetyCutoffAngle)
                    bool
                        safe = Vector3D.Dot(worldGravity, worldThruster) >= safetyCutoff *worldThruster.Length();

                    if (thruster.Enabled != safe)
                    {
                        thruster.RequestEnable(safe);
                    }
                }
            }             //end for

            Echo(temp.Count.ToString() + " thrusters found.");
            Echo(count.ToString() + " processed.");
        }
Example #22
0
        bool FuncTest(IMyThrust block)
        {
            //Small Thruster
            //Large Thruster
            //Interface name: IMyThrust
            //Parent: IMyFunctionalBlock
            //Fields:
            float ThrustOverride = block.ThrustOverride;

            return(true);
        }
Example #23
0
        public HoverEngineDriver(IMyThrust hoverDriveTerminalBlock)
        {
            Block = hoverDriveTerminalBlock;

            var sliderSuffix = Block.CubeGrid.GridSizeEnum == MyCubeSize.Large ? "_L" : "_S";

            _altitudeMinName     += sliderSuffix;
            _altitudeRangeName   += sliderSuffix;
            _altitudeRegDistName += sliderSuffix;

            MaxThrust = Block.MaxThrust;
        }
Example #24
0
        public override void Init(MyObjectBuilder_EntityBase objectBuilder)
        {
            base.Init(objectBuilder);

            thruster = (Entity as IMyThrust);

            if (thruster != null || power != null)
            {
                NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
                NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME;
            }
        }
Example #25
0
 public bool checkStatus()
 {
     if (th == null)
     {
         return(true);
     }
     if ((th.CubeGrid.GetCubeBlock(th.Position))?.FatBlock != th)
     {
         th = null;
         return(true);
     }
     return(false);
 }
Example #26
0
        public Thrusters(IMyTerminalBlock referenceBlock, List <IMyTerminalBlock> blocks)
            : base(referenceBlock)
        {
            UpdateThrusters(blocks);

            Dictionary <VRageMath.Vector3, List <IMyThrust> > .ValueCollection.Enumerator enumerator = thrusterBlocks.Values.GetEnumerator();
            enumerator.MoveNext();
            IMyThrust thrust = enumerator.Current[0];

            MinAcceleration     = thrust.GetMininum <float>("Override");
            MaxAcceleration     = thrust.GetMaximum <float>("Override");
            DefaultAcceleration = thrust.GetDefaultValue <float>("Override");
        }
        void ManeuveringThrust()
        {
            if (maneuveringThrusters.Count == 0)
            {
                Echo("No side thrust found");
            }

            GridTerminalSystem.SearchBlocksOfName(maneuveringThrustersName, maneuveringThrusters);
            for (int i = 0; i < maneuveringThrusters.Count; i++)
            {
                IMyThrust Thrust = maneuveringThrusters[i] as IMyThrust;
                Thrust.ApplyAction("OnOff_On");
            }
        }
        void ThrusterOverride()
        {
            if (forwardThrusters.Count == 0)
            {
                Echo("No forward thrust found");
            }

            GridTerminalSystem.SearchBlocksOfName(forwardThrustName, forwardThrusters);
            for (int i = 0; i < forwardThrusters.Count; i++)
            {
                IMyThrust Thrust = forwardThrusters[i] as IMyThrust;
                Thrust.ApplyAction("OnOff_On");
                Thrust.SetValue <float>("Override", float.MaxValue);
            }
        }
Example #29
0
            public void Reset()
            {
                for (int i = 0; i < thrusters.Count; i++)
                {
                    IMyThrust t = thrusters [i];
                    if (t == null)
                    {
                        thrusters.RemoveAtFast(i);
                        continue;
                    }

                    t.Enabled        = true;
                    t.ThrustOverride = 0;
                }
            }
Example #30
0
 public DetailedThruster(IMyEntity thruster)
 {
     Id                        = thruster.EntityId.ToString();
     _thisEntity               = (MyEntity)thruster;
     _thisIEntity              = thruster;
     _thisThrust               = (MyThrust)thruster;
     _thisIThrust              = (IMyThrust)thruster;
     _thisTerminal             = (IMyTerminalBlock)thruster;
     _thisBlock                = (MyCubeBlock)thruster;
     _thisIBlock               = (IMyCubeBlock)thruster;
     _thisIGrid                = _thisBlock.CubeGrid;
     _thisGrid                 = _thisBlock.CubeGrid;
     _thisThrustDefinition     = _thisThrust.BlockDefinition;
     _thisEntity.AddedToScene += OnAddedToScene;
 }
Example #31
0
 public ThrusterState(IMyThrust thruster)
 {
     Enabled = thruster.Enabled;
     Override = thruster.GetValue<float>("Override");
 }
Example #32
0
 private void AddThruster(Base6Directions.Direction direction, IMyThrust thruster)
 {
     var thrusterList = GetThrusters(direction); // collect must be null to modify original list
     thrusterList.Add(thruster);
 }
Example #33
0
            public ThrusterProperties(IMyThrust thruster)
            {
                thruster.throwIfNull_argument("thruster");

                this.thruster = thruster;
                this.force = (DefinitionCache.GetCubeBlockDefinition(thruster) as MyThrustDefinition).ForceMagnitude;
                //this.dampingForce = force * 10;
                this.forceDirect = Base6Directions.GetFlippedDirection(thruster.Orientation.Forward);
            }