Exemple #1
0
        public void moveShip(ref StateOfShip ship)
        {
            Vector3D speed_Bship = ship.m_arrControlShip[0].m_shipControl.GetShipVelocities().LinearVelocity;

            Vector3D.Rotate(ref speed_Bship, ref Babs_2_Bship, out speed_Bship);


            if (USE_DEBUG)
            {
                ship.m_arrControlShip.ForEach(advCock => advCock.DebugSpeed());
            }


            Vector3 allCockpitInput_Bship = new Vector3(0, 0, 0);

            ship.m_arrControlShip.ForEach(advCock => allCockpitInput_Bship += advCock.getMoveIndicator_Bship());

            if (allCockpitInput_Bship.AbsMax() > 1)
            {
                allCockpitInput_Bship /= allCockpitInput_Bship.AbsMax();
            }

            Vector3 direction_Bship;

            if (ship.m_arrControlShip[0].m_shipControl.DampenersOverride)
            {
                var dampenersMoveIndicator = -speed_Bship / ship.maxSpeedBy10Ticks_Bship_ms_noZero;
                if (dampenersMoveIndicator.AbsMax() > 1)
                {
                    dampenersMoveIndicator /= dampenersMoveIndicator.AbsMax();
                }

                direction_Bship = new Vector3(
                    allCockpitInput_Bship.X == 0 && Math.Abs(speed_Bship.X) > 0.0009 ? dampenersMoveIndicator.X : allCockpitInput_Bship.X,
                    allCockpitInput_Bship.Y == 0 && Math.Abs(speed_Bship.Y) > 0.0009 ? dampenersMoveIndicator.Y : allCockpitInput_Bship.Y,
                    allCockpitInput_Bship.Z == 0 && Math.Abs(speed_Bship.Z) > 0.0009 ? dampenersMoveIndicator.Z : allCockpitInput_Bship.Z);
            }
            else
            {
                direction_Bship = allCockpitInput_Bship;
            }

            if (direction_Bship != lastDirection_Bship)
            {
                ship.SetPower(direction_Bship);

                lastDirection_Bship = direction_Bship;
            }
        }
Exemple #2
0
        public Program()
        {
            // The constructor, called only once every session and
            // always before any other method is called. Use it to
            // initialize your script.
            //
            // The constructor is optional and can be removed if not
            // needed.
            //
            // It's recommended to set RuntimeInfo.UpdateFrequency
            // here, which will allow your script to run itself without a
            // timer block.

            // Me.CustomData = defaultParam_ini;
            bool             needResetIni = false;
            MyIniParseResult result;

            if (!param_ini.TryParse(Me.CustomData, out result))
            {
                Me.CustomData = "";
                param_ini.TryParse("", out result);

                needResetIni = true;
            }
            param_ini.AddSection("Thruster_architecture");
            param_ini.SetSectionComment("Thruster_architecture", " Each modifiaction need a recompile to be apply\n Delete a line \"Key = Value\" to recover default value\n (or delete all Custom data)");

            needResetIni |= getOrAddIniBool("Thruster_architecture", "AUTO_FIT_GRAVITY_FEILD", ref AUTO_FIT_GRAVITY_FEILD, com_autoFit);
            needResetIni |= getOrAddIniFloat("Thruster_architecture", "FILLING_OF_GRAVITY_FEILD", ref FILLING_OF_GRAVITY_FEILD, com_filling);

            needResetIni |= getOrAddIniString("Thrusters_components", "GROUP_NAME_OF_THRUSTER_COMPONENT", ref GROUP_NAME_OF_THRUSTER_COMPONENT, com_groupName);
            needResetIni |= getOrAddIniBool("Thrusters_components", "RENAME_GRAVITY_GENERATOR", ref RENAME_GRAVITY_GENERATOR, com_rename);

            needResetIni |= getOrAddIniInt("Time_optimisation", "NB_SIMPLEX_STEPS_PER_TICKS", ref NB_SIMPLEX_STEPS_PER_TICKS, com_nbSimplex);

            param_ini.AddSection("Developper_option");
            param_ini.SetSectionComment("Developper_option", about);

            needResetIni |= getOrAddIniBool("Developper_option", "USE_DEBUG", ref USE_DEBUG, com_useDebug);
            needResetIni |= getOrAddIniBool("Developper_option", "COMPUTE_NEW_STATS_SHIP_EVERY_TIME", ref COMPUTE_NEW_STATS_SHIP_EVERY_TIME);

            if (needResetIni)
            {
                Me.CustomData = param_ini.ToString();
            }


            setFont(Me.GetSurface(0));
            setFontBIG(Me.GetSurface(1));

            Me.GetSurface(0).WriteText("::GRAVITY THRUSTER::");

            stateOfShip    = new StateOfShip[2];
            stateOfShip[0] = new StateOfShip(this);
            stateOfShip[1] = new StateOfShip(this);
            //stateOfShip[0] = new StateOfShip(this);
            idCurrentStateOfShip = 0;
            idNextStateOfShip    = 1;

            //nexStateOfShip = new StateOfShip(this);

            firstCompute = true;

            NewStateOfShipNeedMoreComputeTime = stateOfShip[idNextStateOfShip].ComputeNewStateMachine_OverTime(NB_SIMPLEX_STEPS_PER_TICKS);

            //PrintLog();
            Runtime.UpdateFrequency = UpdateFrequency.Once | UpdateFrequency.Update10;
        }