コード例 #1
0
        public override void OnStart(PartModule.StartState state)
        {
            // old legacy stuff
            if (baseThrust == 0 && maxThrust > 0)
            {
                baseThrust = maxThrust;
            }

            if (partMass == 0)
            {
                partMass = part.mass;
            }

            if (String.IsNullOrEmpty(displayName))
            {
                displayName = part.partInfo.title;
            }

            String[] resources_to_supply = { ResourceManager.FNRESOURCE_WASTEHEAT };
            this.resources_to_supply = resources_to_supply;

            attachedRCS       = this.part.FindModuleImplementing <ModuleRCS>();
            oldThrustLimiter  = thrustLimiter;
            oldPowerEnabled   = powerEnabled;
            efficencyModifier = GameConstants.STANDARD_GRAVITY * 0.5 / 1000 / efficency;
            efficencyStr      = (efficency * 100).ToString() + "%";

            if (!String.IsNullOrEmpty(AnimationName))
            {
                rcsStates = PluginHelper.SetUpAnimation(AnimationName, this.part);
            }

            // initialize propellant
            _propellants = ElectricEnginePropellant.GetPropellantsEngineForType(type);
            SetupPropellants(true, _propellants.Count);
            currentThrustMultiplier = hasSufficientPower ? Current_propellant.ThrustMultiplier : Current_propellant.ThrustMultiplierCold;

            base.OnStart(state);
        }
コード例 #2
0
        public override void OnStart(PartModule.StartState state)
        {
            definitionMegajoule = PartResourceLibrary.Instance.GetDefinition(ResourceManager.FNRESOURCE_MEGAJOULES);

            try
            {
                attachedRCS         = this.part.FindModuleImplementing <ModuleRCS>();
                attachedModuleRCSFX = attachedRCS as FNModuleRCSFX;

                if (!isInitialised)
                {
                    precisionFactorLimiter = attachedRCS.precisionFactor * 100;
                    fullThrustMinLimiter   = attachedRCS.fullThrustMin * 100;
                    useThrotleEnabled      = attachedRCS.useThrottle;
                    fullThrustEnabled      = attachedRCS.fullThrust;
                    useLeverEnabled        = attachedRCS.useLever;
                }

                if (attachedModuleRCSFX != null)
                {
                    attachedModuleRCSFX.Fields["RCS"].guiActive         = true;
                    attachedModuleRCSFX.Fields["enableYaw"].guiActive   = true;
                    attachedModuleRCSFX.Fields["enablePitch"].guiActive = true;
                    attachedModuleRCSFX.Fields["enableRoll"].guiActive  = true;
                    attachedModuleRCSFX.Fields["enableX"].guiActive     = true;
                    attachedModuleRCSFX.Fields["enableY"].guiActive     = true;
                    attachedModuleRCSFX.Fields["enableZ"].guiActive     = true;
                }

                attachedRCS.precisionFactor = precisionFactorLimiter / 100;
                attachedRCS.fullThrustMin   = fullThrustMinLimiter / 100;
                attachedRCS.useThrottle     = useThrotleEnabled;
                attachedRCS.fullThrust      = fullThrustEnabled;
                attachedRCS.useLever        = useLeverEnabled;

                // old legacy stuff
                if (baseThrust == 0 && maxThrust > 0)
                {
                    baseThrust = maxThrust;
                }

                if (partMass == 0)
                {
                    partMass = part.mass;
                }

                if (String.IsNullOrEmpty(displayName))
                {
                    displayName = part.partInfo.title;
                }

                String[] resources_to_supply = { ResourceManager.FNRESOURCE_WASTEHEAT };
                this.resources_to_supply = resources_to_supply;

                oldThrustLimiter = thrustLimiter;
                oldPowerEnabled  = powerEnabled;
                //efficiencyModifier = g0 * 0.5 / 1000 / efficiency;
                efficiencyStr = (efficiency * 100).ToString() + "%";

                if (!String.IsNullOrEmpty(AnimationName))
                {
                    rcsStates = PluginHelper.SetUpAnimation(AnimationName, this.part);
                }

                // initialize propellant
                _propellants = ElectricEnginePropellant.GetPropellantsEngineForType(type);

                delayedVerificationPropellant = true;
                // find correct fuel mode index
                if (!String.IsNullOrEmpty(fuel_mode_name))
                {
                    Debug.Log("[KSPI] - ElectricRCSController OnStart loaded fuelmode " + fuel_mode_name);
                    Current_propellant = _propellants.FirstOrDefault(p => p.PropellantName == fuel_mode_name);
                }
                if (Current_propellant != null && _propellants.Contains(Current_propellant))
                {
                    fuel_mode = _propellants.IndexOf(Current_propellant);
                    Debug.Log("[KSPI] - ElectricRCSController OnStart index of fuelmode " + Current_propellant.PropellantGUIName + " = " + fuel_mode);
                }

                base.OnStart(state);

                Fields["electricalPowerConsumptionStr"].guiActive = showConsumption;
            }
            catch (Exception e)
            {
                Debug.LogError("[KSPI] - ElectricRCSController OnStart Error: " + e.Message);
                throw;
            }
        }
コード例 #3
0
        public override void OnStart(StartState state)
        {
            String[] resourcesToSupply = { ResourceManager.FNRESOURCE_WASTEHEAT };
            this.resources_to_supply = resourcesToSupply;

            base.OnStart(state);

            radiatedThermalPower       = 0;
            convectedThermalPower      = 0;
            CurrentRadiatorTemperature = 0;
            update_count          = 0;
            radiator_deploy_delay = 0;
            explode_counter       = 0;

            DetermineGenerationType();

            maxRadiatorTemperature = (float)MaxRadiatorTemperature;

            if (hasSurfaceAreaUpgradeTechReq)
            {
                part.emissiveConstant = 1.6;
            }

            radiatorType = RadiatorType;

            effectiveRadiatorArea = EffectiveRadiatorArea;

            deployRadiatorEvent  = Events["DeployRadiator"];
            retractRadiatorEvent = Events["RetractRadiator"];

            thermalPowerConvStrField = Fields["thermalPowerConvStr"];
            radiatorIsEnabledField   = Fields["radiatorIsEnabled"];
            isAutomatedField         = Fields["isAutomated"];
            pivotEnabledField        = Fields["pivotEnabled"];

            var preventDeplyField = Fields["preventShieldedDeploy"];

            preventDeplyField.guiActive       = isDeployable;
            preventDeplyField.guiActiveEditor = isDeployable;

            Actions["DeployRadiatorAction"].guiName = Events["DeployRadiator"].guiName = "Deploy Radiator";
            Actions["ToggleRadiatorAction"].guiName = String.Format("Toggle Radiator");

            Actions["RetractRadiatorAction"].guiName = "Retract Radiator";
            Events["RetractRadiator"].guiName        = "Retract Radiator";

            var myAttachedEngine = part.FindModuleImplementing <ModuleEngines>();

            if (myAttachedEngine == null)
            {
                partMass = part.mass;
                Fields["partMass"].guiActiveEditor        = true;
                Fields["partMass"].guiActive              = true;
                Fields["convectiveBonus"].guiActiveEditor = true;
            }

            if (!String.IsNullOrEmpty(thermalAnim))
            {
                heatStates = PluginHelper.SetUpAnimation(thermalAnim, this.part);

                if (heatStates != null)
                {
                    SetHeatAnimationRatio(0);
                }
            }

            deployAnimation = part.FindModelAnimators(animName).FirstOrDefault();
            if (deployAnimation != null)
            {
                deployAnimation[animName].layer = 1;
                deployAnimation[animName].speed = 0;

                deployAnimation[animName].normalizedTime = radiatorIsEnabled ? 1 : 0;
            }

            _moduleActiveRadiator = part.FindModuleImplementing <ModuleActiveRadiator>();
            if (_moduleActiveRadiator != null)
            {
                _moduleActiveRadiator.Events["Activate"].guiActive = false;
                _moduleActiveRadiator.Events["Shutdown"].guiActive = false;
            }
            _moduleDeployableRadiator = part.FindModuleImplementing <ModuleDeployableRadiator>();
            if (_moduleDeployableRadiator != null)
            {
                radiatorState = _moduleDeployableRadiator.deployState;
            }

            var radiatorfield = Fields["radiatorIsEnabled"];

            radiatorfield.guiActive        = showControls;
            radiatorfield.guiActiveEditor  = showControls;
            radiatorfield.OnValueModified += radiatorIsEnabled_OnValueModified;

            var automatedfield = Fields["isAutomated"];

            automatedfield.guiActive       = showControls;
            automatedfield.guiActiveEditor = showControls;

            var pivotfield = Fields["pivotEnabled"];

            pivotfield.guiActive       = showControls;
            pivotfield.guiActiveEditor = showControls;

            if (_moduleActiveRadiator != null)
            {
                var generationValue = 1 + ((int)CurrentGenerationType);
                _maxEnergyTransfer = radiatorArea * 1000 * generationValue * generationValue;
                _moduleActiveRadiator.maxEnergyTransfer = _maxEnergyTransfer;
                _moduleActiveRadiator.overcoolFactor    = 0.20 + ((int)CurrentGenerationType * 0.025);
            }

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

            var depth = 0;

            star = FlightGlobals.currentMainBody;
            while (depth < 10 && star != null && star.GetTemperature(0) < 2000)
            {
                star = star.referenceBody;
                depth++;
            }
            if (star == null)
            {
                star = FlightGlobals.Bodies[0];
            }

            if (ResearchAndDevelopment.Instance != null)
            {
                upgradeCostStr = ResearchAndDevelopment.Instance.Science + "/" + upgradeCost.ToString("0") + " Science";
            }

            renderArray = part.FindModelComponents <Renderer>().ToArray();

            if (radiatorInit == false)
            {
                radiatorInit = true;
            }

            part.maxTemp = maxRadiatorTemperature;

            radiatorTempStr = maxRadiatorTemperature + "K";

            maxVacuumTemperature     = String.IsNullOrEmpty(surfaceAreaUpgradeTechReq) ? Math.Min((float)PluginHelper.RadiatorTemperatureMk3, maxRadiatorTemperature) :  Math.Min(maxVacuumTemperature, maxRadiatorTemperature);
            maxAtmosphereTemperature = String.IsNullOrEmpty(surfaceAreaUpgradeTechReq) ? Math.Min((float)PluginHelper.RadiatorTemperatureMk3, maxRadiatorTemperature) : Math.Min(maxAtmosphereTemperature, maxRadiatorTemperature);

            resourceBuffers = new ResourceBuffers();
            resourceBuffers.AddConfiguration(new ResourceBuffers.TimeBasedConfig(ResourceManager.FNRESOURCE_WASTEHEAT, wasteHeatMultiplier, 2.0e+6));
            resourceBuffers.UpdateVariable(ResourceManager.FNRESOURCE_WASTEHEAT, this.part.mass);
            resourceBuffers.Init(this.part);
        }
コード例 #4
0
        public override void OnStart(PartModule.StartState state)
        {
            definitionMegajoule = PartResourceLibrary.Instance.GetDefinition(ResourceManager.FNRESOURCE_MEGAJOULES);

            try
            {
                attachedRCS = this.part.FindModuleImplementing <ModuleRCSFX>();

                // old legacy stuff
                if (baseThrust == 0 && maxThrust > 0)
                {
                    baseThrust = maxThrust;
                }

                if (partMass == 0)
                {
                    partMass = part.mass;
                }

                if (String.IsNullOrEmpty(displayName))
                {
                    displayName = part.partInfo.title;
                }

                String[] resources_to_supply = { ResourceManager.FNRESOURCE_WASTEHEAT };
                this.resources_to_supply = resources_to_supply;

                oldPowerEnabled = powerEnabled;
                efficiencyStr   = (efficiency * 100).ToString() + "%";

                if (!String.IsNullOrEmpty(AnimationName))
                {
                    rcsStates = PluginHelper.SetUpAnimation(AnimationName, this.part);
                }

                // initialize propellant
                _propellants = ElectricEnginePropellant.GetPropellantsEngineForType(type);

                delayedVerificationPropellant = true;
                // find correct fuel mode index
                if (!String.IsNullOrEmpty(fuel_mode_name))
                {
                    Debug.Log("[KSPI]: ElectricRCSController OnStart loaded fuelmode " + fuel_mode_name);
                    Current_propellant = _propellants.FirstOrDefault(p => p.PropellantName == fuel_mode_name);
                }
                if (Current_propellant != null && _propellants.Contains(Current_propellant))
                {
                    fuel_mode = _propellants.IndexOf(Current_propellant);
                    Debug.Log("[KSPI]: ElectricRCSController OnStart index of fuelmode " + Current_propellant.PropellantGUIName + " = " + fuel_mode);
                }

                base.OnStart(state);

                Fields["electricalPowerConsumptionStr"].guiActive = showConsumption;

                maxStoredPower = bufferMult * maxThrust * maxIsp * 9.81 / efficiency / 1000;
            }
            catch (Exception e)
            {
                Debug.LogError("[KSPI]: ElectricRCSController OnStart Error: " + e.Message);
                throw;
            }
        }