Example #1
0
        private double UpdateGauge(VInfoBox vi, string resource)
        {
            double got = 0.0;
            double max = 0.0;

            if (vessel != null)
            {
                foreach (Part p in vessel.parts)
                {
                    if (p.Resources.Contains(resource))
                    {
                        got += p.Resources[resource].amount;
                        max += p.Resources[resource].maxAmount;
                    }
                }
            }
            if (max > 0.0)
            {
                vi.SetValue((float)(got / max));
            }
            else
            {
                vi.SetValue(0.0f);
            }

            return(got);
        }
        public override void OnStart(PartModule.StartState state)
        {
            g0 = PluginHelper.GravityConstant;
            modifiedEngineBaseISP = baseISP * PluginHelper.ElectricEngineIspMult;

            String[] resources_to_supply = { FNResourceManager.FNRESOURCE_WASTEHEAT };
            _attached_engine         = this.part.Modules["ModuleEnginesFX"] as ModuleEnginesFX;
            this.resources_to_supply = resources_to_supply;
            _propellants             = getPropellantsEngineType();
            base.OnStart(state);

            if (state == StartState.Editor)
            {
                if (this.HasTechsRequiredToUpgrade())
                {
                    upgradePartModule();
                }

                return;
            }

            if (this.HasTechsRequiredToUpgrade())
            {
                _hasrequiredupgrade = true;
            }

            if (_attached_engine != null)
            {
                _attached_engine.Fields["finalThrust"].guiFormat = "F5";
            }

            fuel_gauge         = part.stackIcon.DisplayInfo();
            Current_propellant = fuel_mode < _propellants.Count ? _propellants[fuel_mode] : _propellants.FirstOrDefault();
            setupPropellants();
        }
 protected void UpdateOverheatBox(double val, double minVal)
 {
     if (val >= (minVal - 0.00001d))
     {
         if (overheatBox == null)
         {
             overheatBox = part.stackIcon.DisplayInfo();
             overheatBox.SetMsgBgColor(XKCDColors.DarkRed.A(0.6f));
             overheatBox.SetMsgTextColor(XKCDColors.OrangeYellow.A(0.6f));
             overheatBox.SetMessage("Eng. Int.");
             overheatBox.SetProgressBarBgColor(XKCDColors.DarkRed.A(0.6f));
             overheatBox.SetProgressBarColor(XKCDColors.OrangeYellow.A(0.6f));
         }
         double scalar   = 1d / (1d - minVal);
         double scaleFac = 1f - scalar;
         float  gaugeMin = (float)(scalar * minVal + scaleFac);
         overheatBox.SetValue(Mathf.Clamp01((float)(val * scalar + scaleFac)), gaugeMin, 1.0f);
     }
     else
     {
         if (overheatBox != null)
         {
             part.stackIcon.RemoveInfo(overheatBox);
             overheatBox = null;
         }
     }
 }
        public override void OnStart(PartModule.StartState state)
        {
            String[] resources_to_supply = { FNResourceManager.FNRESOURCE_WASTEHEAT };
            attachedEngine           = this.part.Modules["ModuleEnginesFX"] as ModuleEnginesFX;
            this.resources_to_supply = resources_to_supply;
            propellants = getPropellants();
            base.OnStart(state);

            if (state == StartState.Editor)
            {
                if (this.HasTechsRequiredToUpgrade())
                {
                    upgradePartModule();
                }
                return;
            }

            if (this.HasTechsRequiredToUpgrade())
            {
                hasrequiredupgrade = true;
            }

            if (attachedEngine != null)
            {
                attachedEngine.Fields["finalThrust"].guiFormat = "F5";
            }

            fuel_gauge         = part.stackIcon.DisplayInfo();
            current_propellant = fuel_mode < propellants.Count ? propellants[fuel_mode] : propellants.FirstOrDefault();
            setupPropellants();
        }
Example #5
0
		void UpdateReloadMeter()
		{
			if(Time.time-timeFired < (60/roundsPerMinute) && Time.time-timeFired > 0.1f)
			{
				if(reloadBar == null)
				{
					reloadBar = InitReloadBar();
					if(reloadAudioClip)
					{
						audioSource.PlayOneShot(reloadAudioClip);
					}
				}
				reloadBar.SetValue(Time.time-timeFired, 0, 60/roundsPerMinute);
			}
			else if(reloadBar != null)
			{
				part.stackIcon.ClearInfoBoxes();
				reloadBar = null;
				if(reloadCompleteAudioClip)
				{
					audioSource.PlayOneShot(reloadCompleteAudioClip);
				}
				
			}
		}
Example #6
0
 public void ShowIndicator()
 {
     thisIndicator = this.stackIcon.DisplayInfo();
     thisIndicator.SetMessage("SAS force");
     thisIndicator.SetMsgBgColor(XKCDColors.DarkAqua );
     thisIndicator.SetMsgTextColor(XKCDColors.BrightCyan);
     thisIndicator.SetProgressBarBgColor(XKCDColors.DarkAqua );
     thisIndicator.SetProgressBarColor(XKCDColors.BrightCyan);
 }
Example #7
0
    public void SwitchEngine()
    {
        ConfigNode nextEngine;

        if (currentMode == primaryModeName)
        {
            currentMode = secondaryModeName;
            nextEngine  = secondaryEngine;
        }
        else
        {
            currentMode = primaryModeName;
            nextEngine  = primaryEngine;
        }

        var engineActive = ActiveEngine.getIgnitionState;

        ActiveEngine.propellants = new List <Propellant> ();

        if (meter != null)
        {
            part.stackIcon.RemoveInfo(meter);
            meter = null;
        }

        ActiveEngine.velocityCurve   = new FloatCurve();
        ActiveEngine.atmosphereCurve = new FloatCurve();

        ActiveEngine.Fields.Load(nextEngine);

        if (nextEngine.HasValue("useVelocityCurve") && (nextEngine.GetValue("useVelocityCurve").ToLowerInvariant() == "true"))
        {
            ActiveEngine.velocityCurve.Load(nextEngine.GetNode("velocityCurve"));
        }
        else
        {
            ActiveEngine.useVelocityCurve = false;
        }

        foreach (ConfigNode n in nextEngine.nodes)
        {
            if (n.name == "PROPELLANT")
            {
                var prop = new Propellant();
                prop.Load(n);
                ActiveEngine.propellants.Add(prop);
            }
        }

        ActiveEngine.SetupPropellant();

        if (engineActive)
        {
            ActiveEngine.Actions ["ActivateAction"].Invoke(new KSPActionParam(KSPActionGroup.None, KSPActionType.Activate));
        }
    }
Example #8
0
        public override void OnStart(PartModule.StartState state)
        {
            engineType       = originalName;
            myAttachedEngine = this.part.Modules["ModuleEngines"] as ModuleEngines;
            // find attached thermal source
            FindAttachedThermalSource();

            if (state == StartState.Editor)
            {
                part.OnEditorAttach += OnEditorAttach;
                propellants          = getPropellants(isJet);
                if (this.HasTechsRequiredToUpgrade() && isJet)
                {
                    isupgraded = true;
                    upgradePartModule();
                }
                setupPropellants();
                estimateEditorPerformance();
                return;
            }
            else
            {
                UpdateRadiusModifier();
            }

            fuel_gauge = part.stackIcon.DisplayInfo();

            // if engine isn't already initialised, initialise it
            if (engineInit == false)
            {
                engineInit = true;
            }

            // if we can upgrade, let's do so
            if (isupgraded && isJet)
            {
                upgradePartModule();
            }
            else
            {
                if (this.HasTechsRequiredToUpgrade() && isJet)
                {
                    hasrequiredupgrade = true;
                }

                // if not, use basic propellants
                propellants = getPropellants(isJet);
            }

            heatExchangerThrustDivisor         = (float)GetHeatExchangerThrustDivisor();
            maxPressureTresholdAtKerbinSurface = exitArea * (float)GameConstants.EarthAthmospherePresureAtSeaLevel;
            setupPropellants();
            hasstarted = true;
        }
Example #9
0
    VInfoBox SetupMeter()
    {
        meter = part.stackIcon.DisplayInfo();
        meter.SetMessage("Air");
        meter.SetProgressBarColor(XKCDColors.White);
        meter.SetProgressBarBgColor(XKCDColors.Grey);
        meter.SetLength(1f);
        meter.SetValue(0f);

        return(meter);
    }
Example #10
0
        private VInfoBox InitReloadBar()
		{
			VInfoBox v = part.stackIcon.DisplayInfo();
			
			v.SetMsgBgColor(XKCDColors.DarkGrey);
			v.SetMsgTextColor(XKCDColors.White);
			v.SetMessage("Reloading");
			v.SetProgressBarBgColor(XKCDColors.DarkGrey);
			v.SetProgressBarColor(XKCDColors.Silver);
			
			return v;
		}
Example #11
0
		private VInfoBox InitHeatGauge()  //thanks DYJ
		{
			VInfoBox v = part.stackIcon.DisplayInfo();
			
			v.SetMsgBgColor(XKCDColors.DarkRed);
			v.SetMsgTextColor(XKCDColors.Orange);
			v.SetMessage("Overheat");
			v.SetProgressBarBgColor(XKCDColors.DarkRed);
			v.SetProgressBarColor(XKCDColors.Orange);
			
			return v;
		}
Example #12
0
        private VInfoBox CreateGauge(string title)
        {
            VInfoBox vi = part.stackIcon.DisplayInfo();

            vi.SetMsgBgColor(XKCDColors.DarkLime.A(0.6f));
            vi.SetMsgTextColor(XKCDColors.ElectricLime.A(0.6f));
            vi.SetProgressBarColor(XKCDColors.Yellow.A(0.6f));
            vi.SetProgressBarBgColor(XKCDColors.DarkLime.A(0.6f));
            vi.SetLength(2.0f);
            vi.SetMessage(title);
            return(vi);
        }
        public override void OnStart(PartModule.StartState state)
        {
            engineType = originalName;
            // check whether we have the technologies available to be able to perform an upgrade
            if (state == StartState.Editor)
            {
                if (this.HasTechsRequiredToUpgrade())
                {
                    isupgraded = true;
                    upgradePartModule();
                }
                return;
            }
            fuel_gauge       = part.stackIcon.DisplayInfo();
            myAttachedEngine = this.part.Modules["ModuleEnginesFX"] as ModuleEnginesFX;
            // if engine isn't already initialised, initialise it
            if (engineInit == false)
            {
                engineInit = true;
            }
            // if we can upgrade, let's do so
            if (isupgraded && isJet)
            {
                upgradePartModule();
            }
            else
            {
                propellants = getPropellants(isJet);
            }
            // find attached thermal source
            foreach (AttachNode attach_node in part.attachNodes)
            {
                if (attach_node.attachedPart != null)
                {
                    List <IThermalSource> sources = attach_node.attachedPart.FindModulesImplementing <IThermalSource> ();
                    if (sources.Count > 0)
                    {
                        myAttachedReactor = sources.First();
                        if (myAttachedReactor != null)
                        {
                            break;
                        }
                    }
                }
            }

            setupPropellants();
            hasstarted = true;

            //print ("Start Complete");
        }
Example #14
0
    protected override void onPartStart()
    {
        this.stackIcon.SetIcon(DefaultIcons.FUEL_TANK);
        this.stackIcon.SetIconColor(XKCDColors.LightGrassGreen);
        this.stackIconGrouping = StackIconGrouping.SAME_MODULE;

        info = this.stackIcon.DisplayInfo();
        info.SetLength(1.0f);
        info.SetMsgBgColor(XKCDColors.OliveGreen);
        info.SetMsgTextColor(XKCDColors.LightGrassGreen);
        info.SetMessage("Kethane");
        info.SetProgressBarBgColor(XKCDColors.LightGrassGreen);
        info.SetProgressBarColor(XKCDColors.LightGrassGreen);
    }
Example #15
0
    protected override void onPartStart()
    {
        this.stackIcon.SetIcon(DefaultIcons.FUEL_TANK);
        this.stackIcon.SetIconColor(XKCDColors.LightGrassGreen);
        this.stackIconGrouping = StackIconGrouping.SAME_MODULE;

        info = this.stackIcon.DisplayInfo();
        info.SetLength(1.0f);
        info.SetMsgBgColor(XKCDColors.OliveGreen);
        info.SetMsgTextColor(XKCDColors.LightGrassGreen);
        info.SetMessage("Kethane");
        info.SetProgressBarBgColor(XKCDColors.LightGrassGreen);
        info.SetProgressBarColor(XKCDColors.LightGrassGreen);
    }
Example #16
0
    public bool getFuel(string fuelType, float amount)
    {
        if ((state == PartStates.DEAD) || (fuelType != type) || (fuel <= 0))
        {
            return false;
        }

        if (state != PartStates.ACTIVE)
        {
            force_activate();
        }

        fuel = Mathf.Clamp(fuel - amount, 0, fullFuel);
        mass = Mathf.Lerp(dryMass, fullMass, fuel / fullFuel);
        explosionPotential = Mathf.Lerp(emptyExplosionPotential, fullExplosionPotential, fuel / fullFuel);

        if (fuelBox == null)
        {
            fuelBox = stackIcon.DisplayInfo();
            fuelBox.SetLength(2.0F);
            XKCDColors.NextColorAlpha = 0.6F;
            fuelBox.SetMsgBgColor(XKCDColors.DarkLime);
            fuelBox.SetMsgTextColor(XKCDColors.ElectricLime);
            fuelBox.SetMessage(type);
            fuelBox.SetProgressBarBgColor(XKCDColors.DarkLime);
            fuelBox.SetProgressBarColor(XKCDColors.Yellow);
            XKCDColors.NextColorAlpha = 1.0F;
        }

        fuelBox.SetValue(fuel / fullFuel);

        if (fuel <= 0)
        {
            if (state == PartStates.ACTIVE)
            {
                deactivate();
            }

            stackIcon.SetIconColor(XKCDColors.SlateGrey);

            if (fuelBox != null)
            {
                stackIcon.ClearInfoBoxes();
                fuelBox = null;
            }
        }

        return true;
    }
Example #17
0
    public bool getFuel(string fuelType, float amount)
    {
        if ((state == PartStates.DEAD) || (fuelType != type) || (fuel <= 0))
        {
            return(false);
        }

        if (state != PartStates.ACTIVE)
        {
            force_activate();
        }

        fuel = Mathf.Clamp(fuel - amount, 0, fullFuel);
        mass = Mathf.Lerp(dryMass, fullMass, fuel / fullFuel);
        explosionPotential = Mathf.Lerp(emptyExplosionPotential, fullExplosionPotential, fuel / fullFuel);

        if (fuelBox == null)
        {
            fuelBox = stackIcon.DisplayInfo();
            fuelBox.SetLength(2.0F);
            XKCDColors.NextColorAlpha = 0.6F;
            fuelBox.SetMsgBgColor(XKCDColors.DarkLime);
            fuelBox.SetMsgTextColor(XKCDColors.ElectricLime);
            fuelBox.SetMessage(type);
            fuelBox.SetProgressBarBgColor(XKCDColors.DarkLime);
            fuelBox.SetProgressBarColor(XKCDColors.Yellow);
            XKCDColors.NextColorAlpha = 1.0F;
        }

        fuelBox.SetValue(fuel / fullFuel);

        if (fuel <= 0)
        {
            if (state == PartStates.ACTIVE)
            {
                deactivate();
            }

            stackIcon.SetIconColor(XKCDColors.SlateGrey);

            if (fuelBox != null)
            {
                stackIcon.ClearInfoBoxes();
                fuelBox = null;
            }
        }

        return(true);
    }
        public override void OnStart(PartModule.StartState state)
        {
            engineType       = originalName;
            myAttachedEngine = this.part.Modules["ModuleEngines"] as ModuleEngines;
            // find attached thermal source
            FindAttachedThermalSource();

            if (state == StartState.Editor)
            {
                part.OnEditorAttach += OnEditorAttach;
                propellants          = getPropellants(isJet);
                if (this.HasTechsRequiredToUpgrade() && isJet)
                {
                    isupgraded = true;
                    upgradePartModule();
                }
                setupPropellants();
                estimateEditorPerformance();
                return;
            }

            fuel_gauge = part.stackIcon.DisplayInfo();

            // if engine isn't already initialised, initialise it
            if (engineInit == false)
            {
                engineInit = true;
            }

            // if we can upgrade, let's do so
            if (isupgraded && isJet)
            {
                upgradePartModule();
            }
            else
            {
                if (this.HasTechsRequiredToUpgrade() && isJet)
                {
                    hasrequiredupgrade = true;
                }

                // if not, use basic propellants
                propellants = getPropellants(isJet);
            }

            setupPropellants();
            hasstarted = true;
        }
Example #19
0
		void UpdateHeatMeter()
		{
			//heat
			if(heat > maxHeat/3)
			{
				if(heatGauge == null)
				{
					heatGauge = InitHeatGauge();
				}
				heatGauge.SetValue(heat, maxHeat/3, maxHeat);
			}
			else if(heatGauge != null && heat < maxHeat/4)
			{
				part.stackIcon.ClearInfoBoxes();
				heatGauge = null;
			}
		}
Example #20
0
        public override void OnStart(PartModule.StartState state)
        {
            UnityEngine.Debug.Log("[KSPI] - Start Initializing ElectricEngineControllerFX");
            try
            {
                // initialise resources
                this.resources_to_supply = new string[] { FNResourceManager.FNRESOURCE_WASTEHEAT };
                base.OnStart(state);
                AttachToEngine();

                _g0 = PluginHelper.GravityConstant;
                _hasGearTechnology     = String.IsNullOrEmpty(gearsTechReq) || PluginHelper.upgradeAvailable(gearsTechReq);
                _modifiedEngineBaseISP = baseISP * PluginHelper.ElectricEngineIspMult;
                _hasrequiredupgrade    = this.HasTechsRequiredToUpgrade();

                if (_hasrequiredupgrade && (isupgraded || state == StartState.Editor))
                {
                    upgradePartModule();
                }
                UpdateEngineTypeString();

                // calculate WasteHeat Capacity
                var wasteheatPowerResource = part.Resources.list.FirstOrDefault(r => r.resourceName == FNResourceManager.FNRESOURCE_WASTEHEAT);
                if (wasteheatPowerResource != null)
                {
                    var ratio = wasteheatPowerResource.amount / wasteheatPowerResource.maxAmount;
                    wasteheatPowerResource.maxAmount = part.mass * 1.0e+5 * wasteHeatMultiplier;
                    wasteheatPowerResource.amount    = wasteheatPowerResource.maxAmount * ratio;
                }

                if (HighLogic.LoadedSceneIsFlight)
                {
                    fuel_gauge = part.stackIcon.DisplayInfo();
                }

                // initialize propellant
                _propellants = ElectricEnginePropellant.GetPropellantsEngineForType(type);
                SetupPropellants(true);
            }
            catch (Exception e)
            {
                UnityEngine.Debug.LogError("[KSPI] - Error OnStart ElectricEngineControllerFX " + e.Message);
            }
            UnityEngine.Debug.Log("[KSPI] - End Initializing ElectricEngineControllerFX");
        }
        public override void OnStart(PartModule.StartState state)
        {
            if (UseStagingIcon)
            {
                this.part.stagingIcon = "FUEL_TANK";
            }
            else
            {
                Debug.Log("NFPP:Reactor Staging Icon Disabled");
            }

            PressureCurve = new FloatCurve();
            PressureCurve.Add(0f, 0f);
            PressureCurve.Add(1f, 2f);



            if (state != StartState.Editor)
            {
                if (UseStagingIcon)
                {
                    infoBox = this.part.stackIcon.DisplayInfo();

                    infoBox.SetMsgBgColor(XKCDColors.RedOrange);
                    infoBox.SetMsgTextColor(XKCDColors.Orange);
                    infoBox.SetLength(1.0f);
                    infoBox.SetMessage("CoreHeat");
                    infoBox.SetProgressBarBgColor(XKCDColors.RedOrange);
                    infoBox.SetProgressBarColor(XKCDColors.Orange);
                }
                generatorAnimation = part.Modules.OfType <FissionGeneratorAnimator>().First();
                SetupRadiators();

                if (UseForcedActivation)
                {
                    this.part.force_activate();
                }
                RenderingManager.AddToPostDrawQueue(0, DrawGUI);

                FuelUpdate();
            }

            // LogItAll();
        }
Example #22
0
        public override void OnStart(PartModule.StartState state)
        {
            if (UseStagingIcon)
            {
                this.part.stagingIcon = "FUEL_TANK";
            }
            else
            {
                Debug.Log("NFT: Fission Reactor: Staging Icon Disabled!");
            }

            if (state != StartState.Editor)
            {
                WindCurve = new FloatCurve();
                WindCurve.Add(0f, 0f);
                WindCurve.Add(1000f, 20f);
                WindCurve.Add(200000f, 0f);

                if (UseStagingIcon)
                {
                    infoBox = this.part.stackIcon.DisplayInfo();

                    infoBox.SetMsgBgColor(XKCDColors.RedOrange);
                    infoBox.SetMsgTextColor(XKCDColors.Orange);
                    infoBox.SetLength(1.0f);
                    infoBox.SetMessage("CoreHeat");
                    infoBox.SetProgressBarBgColor(XKCDColors.RedOrange);
                    infoBox.SetProgressBarColor(XKCDColors.Orange);
                }
                generatorAnimation = part.Modules.OfType <FissionGeneratorAnimator>().First();
                SetupRadiators();

                if (UseForcedActivation)
                {
                    this.part.force_activate();
                }

                FuelUpdate();
                oldHighlight = part.highlightColor;
            }

            // LogItAll();
        }
        public override void OnStart(PartModule.StartState state)
        {
            if (UseStagingIcon)
            {
                this.part.stagingIcon = "FUEL_TANK";
            }
            else
            {
                Utils.LogWarn("Fission Reactor: Staging Icon Disabled!");
            }

            if (state != StartState.Editor)
            {
                // Get heat module
                heatModule = GetComponent <SystemHeat.ModuleSystemHeat>();

                // Set up staging icon heat bar
                if (UseStagingIcon)
                {
                    infoBox = this.part.stackIcon.DisplayInfo();
                    infoBox.SetMsgBgColor(XKCDColors.RedOrange);
                    infoBox.SetMsgTextColor(XKCDColors.Orange);
                    infoBox.SetLength(1.0f);
                    infoBox.SetMessage("CoreDamage");
                    infoBox.SetProgressBarBgColor(XKCDColors.RedOrange);
                    infoBox.SetProgressBarColor(XKCDColors.Orange);
                }


                if (UseForcedActivation)
                {
                    this.part.force_activate();
                }

                // Perform a FuelUpdate
                FuelUpdate();
                oldHighlight = part.highlightColor;
            }

            // LogItAll();
        }
Example #24
0
 protected override void onPartFixedUpdate()
 {
     if (tempIndicator == null)
     {
         tempIndicator = stackIcon.DisplayInfo();
         if (tempIndicator != null)
         {
             XKCDColors.NextColorAlpha = 0.6F;
             tempIndicator.SetMsgBgColor(XKCDColors.DarkRed);
             tempIndicator.SetMsgTextColor(XKCDColors.OrangeYellow);
             tempIndicator.SetMessage("Heat");
             tempIndicator.SetProgressBarBgColor(XKCDColors.DarkRed);
             tempIndicator.SetProgressBarColor(XKCDColors.OrangeYellow);
             XKCDColors.NextColorAlpha = 1.0F;
         }
     }
     if (tempIndicator != null)
     {
         tempIndicator.SetValue(temperature / maxTemp, 0.0F, 1.0F);
     }
 }
Example #25
0
 protected override void onPartFixedUpdate()
 {
     if (tempIndicator == null)
     {
         tempIndicator = stackIcon.DisplayInfo();
         if (tempIndicator != null)
         {
             XKCDColors.NextColorAlpha = 0.6F;
             tempIndicator.SetMsgBgColor(XKCDColors.DarkRed);
             tempIndicator.SetMsgTextColor(XKCDColors.OrangeYellow);
             tempIndicator.SetMessage("Heat");
             tempIndicator.SetProgressBarBgColor(XKCDColors.DarkRed);
             tempIndicator.SetProgressBarColor(XKCDColors.OrangeYellow);
             XKCDColors.NextColorAlpha = 1.0F;
         }
     }
     if (tempIndicator != null)
     {
         tempIndicator.SetValue(temperature / maxTemp, 0.0F, 1.0F);
     }
 }
Example #26
0
 void UpdateHeatMeter()
 {
     //heat
     if(heat > maxHeat/3)
     {
         if(heatGauge == null)
         {
             heatGauge = InitHeatGauge();
         }
         heatGauge.SetValue(heat, maxHeat/3, maxHeat);
     }
     else if(heatGauge != null && heat < maxHeat/4)
     {
         part.stackIcon.ClearInfoBoxes();
         heatGauge = null;
     }
 }
        public override void OnStart(PartModule.StartState state)
        {
            String[] resources_to_supply = {FNResourceManager.FNRESOURCE_WASTEHEAT};
            this.resources_to_supply = resources_to_supply;

            base.OnStart (state);

            Actions["TogglePropellantAction"].guiName = Events["TogglePropellant"].guiName = String.Format("Toggle Propellant");

            if (state == StartState.Editor) { return; }
            //this.part.force_activate();

            fuel_gauge = part.stackIcon.DisplayInfo();

            var curEngine = this.part.Modules["ModuleEngines"] as ModuleEngines;
            if (curEngine != null) {
                initial_thrust = curEngine.maxThrust;
                initialIsp = curEngine.atmosphereCurve.Evaluate(0);
            }

            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 (engineInit == false) {
                engineInit = true;
                if(hasrequiredupgrade && upgradeCost > 0) {
                    isupgraded = true;
                    ConfigNode node = new ConfigNode("RESOURCE");
                    node.AddValue("name", "VacuumPlasma");
                    node.AddValue("maxAmount", 10);
                    node.AddValue("amount", 10);
                    part.AddResource(node);
                    fuel_mode = 0;
                }
            }

            propellants = getPropellants(isupgraded);

            if(manual_upgrade) {
                hasrequiredupgrade = true;
            }

            if(isupgraded) {
                engineType = upgradedName;
            }else{
                engineType = originalName;
            }

            evaluateMaxThrust();
        }
Example #28
0
		public override void OnFixedUpdate()
		{
			
			if(!vessel.IsControllable)
			{
				turretEnabled = false;
			}
			
			//laser
			if(weaponType == "laser")
			{
				foreach(Transform tf in part.FindModelTransforms("fireTransform"))
				{
					LineRenderer lr = tf.gameObject.GetComponent<LineRenderer>();
					lr.SetPosition(0, tf.position);
					lr.SetPosition(1, tf.position);
				}
			}

			if(showReloadMeter)
			{
				if(Time.time-timeCheck < (60/roundsPerMinute) && Time.time-timeCheck > 0.1f)
				{
					if(reloadBar == null)
					{
						reloadBar = InitReloadBar(part);
						if(reloadAudioClip)
						{
							audioSource.PlayOneShot(reloadAudioClip);
						}
					}
					reloadBar.SetValue(Time.time-timeCheck, 0, 60/roundsPerMinute);
				}
				else if(reloadBar != null)
				{
					part.stackIcon.ClearInfoBoxes();
					reloadBar = null;
					if(reloadCompleteAudioClip)
					{
						audioSource.PlayOneShot(reloadCompleteAudioClip);
					}

				}
			}
			else
			{
				//heat
				if(heat > maxHeat/3)
				{
					if(heatGauge == null)
					{
						heatGauge = InitHeatGauge(part);
					}
					heatGauge.SetValue(heat, maxHeat/3, maxHeat);
				}
				else if(heatGauge != null && heat < maxHeat/4)
				{
					part.stackIcon.ClearInfoBoxes();
					heatGauge = null;
				}
			}
			
			heat = Mathf.Clamp(heat - heatLoss * TimeWarp.fixedDeltaTime, 0, Mathf.Infinity);
			if(heat>maxHeat && !isOverheated)
			{
				isOverheated = true;
				autoFire = false;
				autoFireTarget = null;
				audioSource.Stop ();
				wasFiring = false;
				audioSource2.volume = Mathf.Sqrt (GameSettings.SHIP_VOLUME);
				audioSource2.PlayOneShot(overheatSound);
			}
			if(heat < maxHeat/3 && isOverheated) //reset on cooldown
			{
				isOverheated = false;
				heat = 0;
			}
			//
			
			
			
			//finding number of guns for fire volume reduction  
			//TODO: make central counter so this check doesn't happen every frame
			numberOfGuns = 0;
			foreach(BahaTurret bt in vessel.FindPartModulesImplementing<BahaTurret>())
			{
				if(bt.deployed)
				{
					numberOfGuns++;	
				}
			}	
			if(numberOfGuns<1)
			{
				numberOfGuns = 1;	
			}
			//

			if(!turretEnabled && !turretZeroed)
			{
				deployed = false;
				ReturnTurret();
			}
			
			//animation handling
			if(deployAnimName!="")
			{
				foreach(AnimationState anim in deployStates)
				{
					//animation clamping
					if(anim.normalizedTime>1)
					{
						anim.speed = 0;
						anim.normalizedTime = 1;
					}
					if(anim.normalizedTime < 0)
					{
						anim.speed = 0;
						anim.normalizedTime = 0;
					}
					
					//deploying
					if(turretEnabled)
					{
						if(anim.normalizedTime<1 && anim.speed<1)
						{
							anim.speed = 1;	
							deployed = false;
						}
						if(anim.normalizedTime == 1)
						{
							deployed = true;
							anim.enabled = false;
						}
					}
					
					//retracting
					if(!turretEnabled)
					{
						if(turretZeroed)
						{
							anim.enabled = true;
							if(anim.normalizedTime > 0 && anim.speed > -1)
							{
								anim.speed = -1;	
							}
						}
					}
				}
			}
			else
			{
				deployed = turretEnabled;	
			}
			//aim+shooting
			if(deployed && (TimeWarp.WarpMode!=TimeWarp.Modes.HIGH || TimeWarp.CurrentRate == 1))
			{
				Aim ();	
				CheckTarget ();

				bool userFiring = (Input.GetKey(BDArmorySettings.FIRE_KEY) && (vessel.isActiveVessel || BDArmorySettings.REMOTE_SHOOTING) && !MapView.MapIsEnabled && !guardMode);
				
				if((userFiring || autoFire) && inTurretRange)
				{
					if(weaponType == "ballistic" || weaponType == "cannon") Fire ();
					else if(weaponType == "laser")
					{
						if(!FireLaser ())
						{
							audioSource.Stop ();	
						}
					}
				}
				else
				{
					if(spinDownAnimation) spinningDown = true;
					if(weaponType == "laser") audioSource.Stop ();
					if(!oneShotSound && wasFiring)
						{
							audioSource.Stop ();
							wasFiring = false;
							audioSource2.volume = Mathf.Sqrt (GameSettings.SHIP_VOLUME);
							audioSource2.PlayOneShot(overheatSound);	
						}
					
				}
				
				if(spinningDown && spinDownAnimation)
				{
					foreach(AnimationState anim in fireStates)
					{
						if(anim.normalizedTime>1) anim.normalizedTime = 0;
						anim.speed = fireAnimSpeed;
						fireAnimSpeed = Mathf.Lerp(fireAnimSpeed, 0, 0.04f);
					}
				}
				
					

			}
			else
			{
				audioSource.Stop ();
				autoFire = false;
				autoFireTarget = null;
			}
			
			if(autoFire && Time.time-autoFireTimer > autoFireLength)
			{
				autoFire = false;
				autoFireTarget = null;
			}
			
			if(!oneShotSound &&  !Input.GetKey(BDArmorySettings.FIRE_KEY) && !autoFire && wasFiring)
			{
				wasFiring = false;
				audioSource.Stop ();
				audioSource2.volume = Mathf.Sqrt(GameSettings.SHIP_VOLUME);
				audioSource2.PlayOneShot(overheatSound);
			}
			
			
	
			
		}
        public override void OnStart(PartModule.StartState state)
        {
            String[] resources_to_supply = { FNResourceManager.FNRESOURCE_WASTEHEAT };
            _attached_engine = this.part.Modules["ModuleEnginesFX"] as ModuleEnginesFX;
            this.resources_to_supply = resources_to_supply;
            _propellants = getPropellants();
            base.OnStart(state);

            if (state == StartState.Editor)
            {
                if (this.HasTechsRequiredToUpgrade())
                {
                    upgradePartModule();
                }
                return;
            }

            if (this.HasTechsRequiredToUpgrade())
            {
                _hasrequiredupgrade = true;
            }

            if (_attached_engine != null)
            {
                _attached_engine.Fields["finalThrust"].guiFormat = "F5";
            }

            fuel_gauge = part.stackIcon.DisplayInfo();
            _current_propellant = fuel_mode < _propellants.Count ? _propellants[fuel_mode] : _propellants.FirstOrDefault();
            setupPropellants();
        }
		public override void OnStart(PartModule.StartState state) {
            engineType = originalName;
            // check whether we have the technologies available to be able to perform an upgrade
            if (state == StartState.Editor) {
                if (this.HasTechsRequiredToUpgrade())
                {
                    isupgraded = true;
                    upgradePartModule();
                }
                return;
            }
			fuel_gauge = part.stackIcon.DisplayInfo();
			myAttachedEngine = this.part.Modules["ModuleEnginesFX"] as ModuleEnginesFX;
			// if engine isn't already initialised, initialise it
			if (engineInit == false) {
				engineInit = true;
			}
			// if we can upgrade, let's do so
			if (isupgraded && isJet) {
				upgradePartModule ();
			} else {
				propellants = getPropellants (isJet);
			}
			// find attached thermal source
			foreach (AttachNode attach_node in part.attachNodes) {
				if (attach_node.attachedPart != null) {
					List<IThermalSource> sources = attach_node.attachedPart.FindModulesImplementing<IThermalSource> ();
					if (sources.Count > 0) {
						myAttachedReactor = sources.First ();
						if (myAttachedReactor != null) {
							break;
						}
					}
				}
			}

			setupPropellants();
			hasstarted = true;

			//print ("Start Complete");
		}
        public override void OnStart(PartModule.StartState state)
        {
            if (UseStagingIcon)
                this.part.stagingIcon = "FUEL_TANK";
            else
                Utils.LogWarn("Fission Reactor: Staging Icon Disabled!");

            if (state != StartState.Editor)
            {
                // Get heat module
                //heatModule = GetComponent<SystemHeat.ModuleSystemHeat>();

                // Set up staging icon heat bar
                if (UseStagingIcon)
                {
                    infoBox = this.part.stackIcon.DisplayInfo();
                    infoBox.SetMsgBgColor(XKCDColors.RedOrange);
                    infoBox.SetMsgTextColor(XKCDColors.Orange);
                    infoBox.SetLength(1.0f);
                    infoBox.SetMessage("CoreDamage");
                    infoBox.SetProgressBarBgColor(XKCDColors.RedOrange);
                    infoBox.SetProgressBarColor(XKCDColors.Orange);
                }

                if (UseForcedActivation)
                    this.part.force_activate();

                // Perform a FuelUpdate
                FuelUpdate();
                oldHighlight = part.highlightColor;
            }

            // LogItAll();
        }
Example #32
0
 protected void UpdateOverheatBox(double val, double minVal)
 {
     if (val >= (minVal - 0.00001d))
     {
         if (overheatBox == null)
         {
             overheatBox = part.stackIcon.DisplayInfo();
             overheatBox.SetMsgBgColor(XKCDColors.DarkRed.A(0.6f));
             overheatBox.SetMsgTextColor(XKCDColors.OrangeYellow.A(0.6f));
             overheatBox.SetMessage("Eng. Int.");
             overheatBox.SetProgressBarBgColor(XKCDColors.DarkRed.A(0.6f));
             overheatBox.SetProgressBarColor(XKCDColors.OrangeYellow.A(0.6f));
         }
         double scalar = 1d / (1d - minVal);
         double scaleFac = 1f - scalar;
         float gaugeMin = (float)(scalar * minVal + scaleFac);
         overheatBox.SetValue(Mathf.Clamp01((float)(val * scalar + scaleFac)), gaugeMin, 1.0f);
     }
     else
     {
         if (overheatBox != null)
         {
             part.stackIcon.RemoveInfo(overheatBox);
             overheatBox = null;
         }
     }
 }
		public override void OnStart(PartModule.StartState state) {
            engineType = originalName;
            myAttachedEngine = this.part.Modules["ModuleEngines"] as ModuleEngines;
            // find attached thermal source
            foreach (AttachNode attach_node in part.attachNodes) {
                if (attach_node.attachedPart != null) {
                    List<IThermalSource> sources = attach_node.attachedPart.FindModulesImplementing<IThermalSource>();
                    if (sources.Count > 0) {
                        myAttachedReactor = sources.First();
                        if (myAttachedReactor != null) {
                            break;
                        }
                    }
                }
            }

            if (state == StartState.Editor) {
                part.OnEditorAttach += OnEditorAttach;
                propellants = getPropellants(isJet);
                if (this.HasTechsRequiredToUpgrade() && isJet)
                {
                    isupgraded = true;
                    upgradePartModule();
                }
                setupPropellants();
                estimateEditorPerformance();
                return;
            }
			fuel_gauge = part.stackIcon.DisplayInfo();
			
            // if engine isn't already initialised, initialise it
			if (engineInit == false) {
				engineInit = true;
			}
			// if we can upgrade, let's do so
			if (isupgraded && isJet) {
				upgradePartModule ();
			} else {
                if (this.HasTechsRequiredToUpgrade() && isJet)
                {
                    hasrequiredupgrade = true;
                }
				// if not, use basic propellants
				propellants = getPropellants (isJet);
			}
			
			setupPropellants();
			hasstarted = true;

			//print ("Start Complete");
		}
        public override void OnStart(PartModule.StartState state)
        {
            if (state == StartState.Editor) { return; }
            Actions["TogglePropellantAction"].guiName = Events["TogglePropellant"].guiName = String.Format("Toggle Propellant");
            fuel_gauge = part.stackIcon.DisplayInfo();
            if (isHybrid) {
                propellants = getPropellantsHybrid();
            }else {
                propellants = getPropellants(isJet);
            }
            engineType = originalName;
            if (isupgraded) {
                engineType = upgradedName;
            }

            setupPropellants();
        }
		public override void OnStart(PartModule.StartState state) 
        {
            engineType = originalName;
            myAttachedEngine = this.part.Modules["ModuleEngines"] as ModuleEngines;
            // find attached thermal source
            FindAttachedThermalSource();

            if (state == StartState.Editor) 
            {
                part.OnEditorAttach += OnEditorAttach;
                propellants = getPropellants(isJet);
                if (this.HasTechsRequiredToUpgrade() && isJet)
                {
                    isupgraded = true;
                    upgradePartModule();
                }
                setupPropellants();
                estimateEditorPerformance();
                return;
            }

			fuel_gauge = part.stackIcon.DisplayInfo();
			
            // if engine isn't already initialised, initialise it
			if (engineInit == false) 
				engineInit = true;
			
			// if we can upgrade, let's do so
			if (isupgraded && isJet) 
				upgradePartModule ();
            else 
            {
                if (this.HasTechsRequiredToUpgrade() && isJet)
                    hasrequiredupgrade = true;

				// if not, use basic propellants
				propellants = getPropellants (isJet);
			}
			
			setupPropellants();
			hasstarted = true;
		}
Example #36
0
        void UpdateReloadMeter()
        {
            if(Time.time-timeFired < (60/roundsPerMinute) && Time.time-timeFired > 0.1f)
            {
                if(reloadBar == null)
                {
                    reloadBar = InitReloadBar();
                    if(reloadAudioClip)
                    {
                        audioSource.PlayOneShot(reloadAudioClip);
                    }
                }
                reloadBar.SetValue(Time.time-timeFired, 0, 60/roundsPerMinute);
            }
            else if(reloadBar != null)
            {
                part.stackIcon.ClearInfoBoxes();
                reloadBar = null;
                if(reloadCompleteAudioClip)
                {
                    audioSource.PlayOneShot(reloadCompleteAudioClip);
                }

            }
        }
Example #37
0
 private void CreateAllGauges()
 {
     plasma_gauge   = CreateGauge("WarpPlasma");
     electric_gauge = CreateGauge("ElectricCharge");
 }
        public override void OnStart(PartModule.StartState state)
        {
            if (UseStagingIcon)
                this.part.stagingIcon = "FUEL_TANK";
            else
                Debug.Log("NFPP:Reactor Staging Icon Disabled");

            PressureCurve = new FloatCurve();
            PressureCurve.Add(0f, 0f);
            PressureCurve.Add(1f, 2f);

            if (state != StartState.Editor)
            {
                if (UseStagingIcon)
                {
                    infoBox = this.part.stackIcon.DisplayInfo();

                    infoBox.SetMsgBgColor(XKCDColors.RedOrange);
                    infoBox.SetMsgTextColor(XKCDColors.Orange);
                    infoBox.SetLength(1.0f);
                    infoBox.SetMessage("CoreHeat");
                    infoBox.SetProgressBarBgColor(XKCDColors.RedOrange);
                    infoBox.SetProgressBarColor(XKCDColors.Orange);
                }
                generatorAnimation = part.Modules.OfType<FissionGeneratorAnimator>().First();
                SetupRadiators();

                if (UseForcedActivation)
                    this.part.force_activate();
                RenderingManager.AddToPostDrawQueue(0, DrawGUI);

                FuelUpdate();
            }

            // LogItAll();
        }
Example #39
0
        public override void OnStart(PartModule.StartState state)
        {
            String[] resources_to_supply = { FNResourceManager.FNRESOURCE_WASTEHEAT };
            this.resources_to_supply = resources_to_supply;

            base.OnStart(state);

            Actions["TogglePropellantAction"].guiName = Events["TogglePropellant"].guiName = String.Format("Toggle Propellant");

            if (state == StartState.Editor)
            {
                return;
            }
            //this.part.force_activate();

            fuel_gauge = part.stackIcon.DisplayInfo();


            var curEngine = this.part.Modules["ModuleEngines"] as ModuleEngines;

            if (curEngine != null)
            {
                initial_thrust = curEngine.maxThrust;
                initialIsp     = curEngine.atmosphereCurve.Evaluate(0);
            }

            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 (engineInit == false)
            {
                engineInit = true;
                if (hasrequiredupgrade && upgradeCost > 0)
                {
                    isupgraded = true;
                    ConfigNode node = new ConfigNode("RESOURCE");
                    node.AddValue("name", "VacuumPlasma");
                    node.AddValue("maxAmount", 10);
                    node.AddValue("amount", 10);
                    part.AddResource(node);
                    fuel_mode = 0;
                }
            }

            propellants = getPropellants(isupgraded);

            if (manual_upgrade)
            {
                hasrequiredupgrade = true;
            }

            if (isupgraded)
            {
                engineType = upgradedName;
            }
            else
            {
                engineType = originalName;
            }


            evaluateMaxThrust();
        }
        public override void OnStart(PartModule.StartState state)
        {
            UnityEngine.Debug.Log("[KSPI] - Start Initializing ElectricEngineControllerFX");
            try
            {
                // initialise resources
                this.resources_to_supply = new string[] { FNResourceManager.FNRESOURCE_WASTEHEAT };
                base.OnStart(state);
                AttachToEngine();

                _g0 = PluginHelper.GravityConstant;
                _hasGearTechnology = String.IsNullOrEmpty(gearsTechReq) || PluginHelper.upgradeAvailable(gearsTechReq);
                _modifiedEngineBaseISP = baseISP * PluginHelper.ElectricEngineIspMult;
                _hasrequiredupgrade = this.HasTechsRequiredToUpgrade();

                if (_hasrequiredupgrade && (isupgraded || state == StartState.Editor))
                    upgradePartModule();
                UpdateEngineTypeString();

                // calculate WasteHeat Capacity
                var wasteheatPowerResource = part.Resources.list.FirstOrDefault(r => r.resourceName == FNResourceManager.FNRESOURCE_WASTEHEAT);
                if (wasteheatPowerResource != null)
                {
                    var ratio = wasteheatPowerResource.amount / wasteheatPowerResource.maxAmount;
                    wasteheatPowerResource.maxAmount = part.mass * 1.0e+5 * wasteHeatMultiplier;
                    wasteheatPowerResource.amount = wasteheatPowerResource.maxAmount * ratio;
                }

                if (HighLogic.LoadedSceneIsFlight)
                    fuel_gauge = part.stackIcon.DisplayInfo();

                // initialize propellant
                _propellants = ElectricEnginePropellant.GetPropellantsEngineForType(type);
                SetupPropellants(true);
            }
            catch (Exception e)
            {
                UnityEngine.Debug.LogError("[KSPI] - Error OnStart ElectricEngineControllerFX " + e.Message);
            }
            UnityEngine.Debug.Log("[KSPI] - End Initializing ElectricEngineControllerFX");
        }
Example #41
0
 public void HideIndicator()
 {
     this.stackIcon.RemoveInfo(thisIndicator);
     thisIndicator = null;
 }
Example #42
0
        public override void OnStart(PartModule.StartState state)
        {
            engineType       = originalName;
            myAttachedEngine = this.part.Modules["ModuleEngines"] as ModuleEngines;
            // find attached thermal source
            foreach (AttachNode attach_node in part.attachNodes)
            {
                if (attach_node.attachedPart != null)
                {
                    List <IThermalSource> sources = attach_node.attachedPart.FindModulesImplementing <IThermalSource>();
                    if (sources.Count > 0)
                    {
                        myAttachedReactor = sources.First();
                        if (myAttachedReactor != null)
                        {
                            break;
                        }
                    }
                }
            }

            if (state == StartState.Editor)
            {
                part.OnEditorAttach += OnEditorAttach;
                propellants          = getPropellants(isJet);
                if (this.HasTechsRequiredToUpgrade() && isJet)
                {
                    isupgraded = true;
                    upgradePartModule();
                }
                setupPropellants();
                estimateEditorPerformance();
                return;
            }
            fuel_gauge = part.stackIcon.DisplayInfo();

            // if engine isn't already initialised, initialise it
            if (engineInit == false)
            {
                engineInit = true;
            }
            // if we can upgrade, let's do so
            if (isupgraded && isJet)
            {
                upgradePartModule();
            }
            else
            {
                if (this.HasTechsRequiredToUpgrade() && isJet)
                {
                    hasrequiredupgrade = true;
                }
                // if not, use basic propellants
                propellants = getPropellants(isJet);
            }

            setupPropellants();
            hasstarted = true;

            //print ("Start Complete");
        }
        public override void OnStart(PartModule.StartState state)
        {
            String[] resources_to_supply = {FNResourceManager.FNRESOURCE_WASTEHEAT};
            this.resources_to_supply = resources_to_supply;

            base.OnStart (state);

            Actions["TogglePropellantAction"].guiName = Events["TogglePropellant"].guiName = String.Format("Toggle Propellant");

            if (state == StartState.Editor) { return; }
            //this.part.force_activate();

            fuel_gauge = part.stackIcon.DisplayInfo();
            propellants = getPropellants(isupgraded);

            var curEngine = this.part.Modules["ModuleEngines"] as ModuleEngines;
            if (curEngine != null) {
                initial_thrust = curEngine.maxThrust;
                initial_isp = curEngine.atmosphereCurve.Evaluate(0);
            }

            if(isupgraded) {
                engineType = upgradedName;
            }else{
                engineType = originalName;
            }

            evaluateMaxThrust();
        }
        public override void OnStart(PartModule.StartState state)
        {
            if (UseStagingIcon)
                this.part.stagingIcon = "FUEL_TANK";
            else
                Utils.LogWarn("Fission Reactor: Staging Icon Disabled!");

            if (state != StartState.Editor)
            {
                SetupResourceRatios();
                // Set up staging icon heat bar
                if (UseStagingIcon)
                {
                    infoBox = this.part.stackIcon.DisplayInfo();
                    infoBox.SetMsgBgColor(XKCDColors.RedOrange);
                    infoBox.SetMsgTextColor(XKCDColors.Orange);
                    infoBox.SetLength(1.0f);
                    infoBox.SetValue(0.0f);
                    infoBox.SetMessage("Ineffic.");
                    infoBox.SetProgressBarBgColor(XKCDColors.RedOrange);
                    infoBox.SetProgressBarColor(XKCDColors.Orange);
                }

                if (OverheatAnimation != "")
                {
                    overheatStates = Utils.SetUpAnimation(OverheatAnimation, this.part);

                }
                if (UseForcedActivation)
                    this.part.force_activate();
            }
        }
        public override void OnStart(PartModule.StartState state)
        {
            _g0 = PluginHelper.GravityConstant;
            _hasGearTechnology = String.IsNullOrEmpty(gearsTechReq) || PluginHelper.upgradeAvailable(gearsTechReq);
            _modifiedEngineBaseISP = baseISP * PluginHelper.ElectricEngineIspMult;

            //_attached_engine = this.part.Modules["ModuleEnginesFX"] as ModuleEnginesFX;
            _attached_engine = this.part.FindModuleImplementing<ModuleEnginesFX>();

            var wasteheatPowerResource = part.Resources.list.FirstOrDefault(r => r.resourceName == FNResourceManager.FNRESOURCE_WASTEHEAT);
            // calculate WasteHeat Capacity
            if (wasteheatPowerResource != null)
            {
                var ratio = wasteheatPowerResource.amount / wasteheatPowerResource.maxAmount;
                wasteheatPowerResource.maxAmount = part.mass * 1.0e+5 * wasteHeatMultiplier;
                wasteheatPowerResource.amount = wasteheatPowerResource.maxAmount * ratio;
            }

            String[] resources_to_supply = { FNResourceManager.FNRESOURCE_WASTEHEAT };
            this.resources_to_supply = resources_to_supply;
            _propellants = getPropellantsEngineType();
            base.OnStart(state);

            if (state == StartState.Editor)
            {
                if (this.HasTechsRequiredToUpgrade())
                    upgradePartModule();

                return;
            }

            if (this.HasTechsRequiredToUpgrade())
                _hasrequiredupgrade = true;

            if (_attached_engine != null)
                _attached_engine.Fields["finalThrust"].guiFormat = "F5";

            fuel_gauge = part.stackIcon.DisplayInfo();
            Current_propellant = fuel_mode < _propellants.Count ? _propellants[fuel_mode] : _propellants.FirstOrDefault();
            setupPropellants();
        }