コード例 #1
0
        public void RetrofitCore()
        {
            if (ResearchAndDevelopment.Instance == null)
            {
                return;
            }
            if (isupgraded || ResearchAndDevelopment.Instance.Science < upgradeCost)
            {
                return;
            }

            var curReaction = this.part.Modules["ModuleReactionWheel"] as ModuleReactionWheel;

            curReaction.PitchTorque = 5;
            curReaction.RollTorque  = 5;
            curReaction.YawTorque   = 5;

            ConfigNode[] namelist = ComputerCore.getNames();
            Random       rands    = new Random();
            ConfigNode   myName   = namelist[rands.Next(0, namelist.Length)];

            nameStr = myName.GetValue("name");

            computercoreType = upgradedName;
            isupgraded       = true;
            ResearchAndDevelopment.Instance.Science = ResearchAndDevelopment.Instance.Science - upgradeCost;
        }
コード例 #2
0
        public void upgradePartModule()
        {
            computercoreType = upgradedName;
            if (nameStr == "")
            {
                ConfigNode[]  namelist = ComputerCore.getNames();
                System.Random rands    = new System.Random();
                ConfigNode    myName   = namelist[rands.Next(0, namelist.Length)];
                nameStr = myName.GetValue("name");
            }

            isupgraded = true;
            canDeploy  = true;

            _experiment_node = GameDatabase.Instance.GetConfigNodes("EXPERIMENT_DEFINITION").FirstOrDefault(nd => nd.GetValue("id") == experimentID);
        }
コード例 #3
0
 public void upgradePartModule()
 {
     computercoreType = upgradedName;
     if (nameStr == "")
     {
         ConfigNode[]  namelist = ComputerCore.getNames();
         System.Random rands    = new System.Random();
         ConfigNode    myName   = namelist[rands.Next(0, namelist.Length)];
         nameStr = myName.GetValue("name");
     }
     if (part.Modules.Contains("ModuleReactionWheel"))
     {
         ModuleReactionWheel reaction_wheel = this.part.Modules["ModuleReactionWheel"] as ModuleReactionWheel;
         reaction_wheel.PitchTorque = 5;
         reaction_wheel.RollTorque  = 5;
         reaction_wheel.YawTorque   = 5;
     }
     isupgraded       = true;
     _experiment_node = GameDatabase.Instance.GetConfigNodes("EXPERIMENT_DEFINITION").FirstOrDefault(nd => nd.GetValue("id") == experimentID);
 }
コード例 #4
0
        public override void OnStart(PartModule.StartState state)
        {
            if (state == StartState.Editor)
            {
                return;
            }

            bool manual_upgrade = false;

            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
            {
                if (upgradeTechReq != null)
                {
                    if (PluginHelper.hasTech(upgradeTechReq))
                    {
                        hasrequiredupgrade = true;
                    }
                    else if (upgradeTechReq == "none")
                    {
                        manual_upgrade = true;
                    }
                }
                else
                {
                    manual_upgrade = true;
                }
            }
            else
            {
                hasrequiredupgrade = true;
            }

            if (coreInit == false)
            {
                coreInit = true;
                if (hasrequiredupgrade)
                {
                    isupgraded = true;
                }
            }

            if (manual_upgrade)
            {
                hasrequiredupgrade = true;
            }

            if (isupgraded)
            {
                computercoreType = upgradedName;
                if (nameStr == "")
                {
                    ConfigNode[] namelist = ComputerCore.getNames();
                    Random       rands    = new Random();
                    ConfigNode   myName   = namelist[rands.Next(0, namelist.Length)];
                    nameStr = myName.GetValue("name");
                }

                double now                 = Planetarium.GetUniversalTime();
                double time_diff           = now - last_active_time;
                float  altitude_multiplier = (float)(vessel.altitude / (vessel.mainBody.Radius));
                altitude_multiplier = Math.Max(altitude_multiplier, 1);

                double science_to_add = baseScienceRate * time_diff / 86400 * electrical_power_ratio * PluginHelper.getScienceMultiplier(vessel.mainBody.flightGlobalsIndex, vessel.LandedOrSplashed) / ((float)Math.Sqrt(altitude_multiplier));
                science_awaiting_addition = science_to_add;

                var curReaction = this.part.Modules["ModuleReactionWheel"] as ModuleReactionWheel;
                curReaction.PitchTorque = 5;
                curReaction.RollTorque  = 5;
                curReaction.YawTorque   = 5;
            }
            else
            {
                computercoreType = originalName;
            }


            this.part.force_activate();
        }