Example #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;
        }
Example #2
0
        public override void OnStart(PartModule.StartState state)
        {
            if (state == StartState.Editor)
            {
                return;
            }

            bool manual_upgrade = false;

            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER | HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX)
            {
                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();
        }