public override void OnStart(StartState state)
        {
            try
            {
                Debug.Log("[KSPI] - Start State: " + state.ToString());
                Debug.Log("[KSPI] - Already Launched: " + Launched);

                curEngineT    = this.part.FindModuleImplementing <ModuleEngines>();
                curEngineWarp = this.part.FindModuleImplementing <ModuleEnginesWarp>();

                InitializeGUI();

                if (state.ToString().Contains(StartState.Editor.ToString()))
                {
                    Debug.Log("[KSPI] - Editor");
                    hideEmpty        = false;
                    selectedTank     = selectedFuel;
                    selectedTankName = FuelConfigurations[selectedFuel].ConfigName;
                    UpdateResources();
                    Debug.Log("[KSPI] - OnStart calls UpdateFuel");
                    UpdateFuel(true);
                }
                else
                {
                    hideEmpty = true;
                    if (state.ToString().Contains(StartState.PreLaunch.ToString())) // startstate normally == prelaunch,landed
                    {
                        Debug.Log("[KSPI] - PreLaunch");
                        hideEmpty = true;
                        UpdateResources();
                        //UpdateusefulConfigurations();
                        InitializeFuelSelector();
                        Debug.Log("[KSPI] - OnStart calls UpdateFuel");
                        UpdateFuel();
                    }
                    else
                    {
                        Debug.Log("[KSPI] - No PreLaunch");
                    }
                }
                Events["ShowFuels"].active = hideEmpty;
                Events["HideFuels"].active = !hideEmpty;
            }
            catch (Exception e)
            {
                Debug.LogError("EngineECU2 OnStart eception: " + e.Message);
            }

            base.OnStart(state);
        }
示例#2
0
 public override void OnStart(StartState state)
 {
     base.OnStart(state);
     KSPLog.print("Core: OnStart(" + state.ToString() + ")");
     if (vessel)
     {
         //KSPLog.print(vessel.situation.ToString());
         if ((vessel.situation | Vessel.Situations.PRELAUNCH) == Vessel.Situations.PRELAUNCH)
         {
             //KSPLog.print(exoticEnergy.amount.ToString() + "/" + exoticEnergy.maxAmount.ToString());
             //Perform prelaunch conversion
             //if ((vessel.situation & Vessel.Situations.PRELAUNCH) == Vessel.Situations.PRELAUNCH)
             //generateEE(exoticEnergy.maxAmount - exoticEnergy.amount);
         }
         //KSPLog.print(Planetarium.GetUniversalTime());
         //KSPLog.print(saveTime);
         //KSPLog.print(Planetarium.GetUniversalTime() - saveTime);
         if (saveTime != 0)
         {
             generateEE(EEGeneration * (Planetarium.GetUniversalTime() - saveTime));
         }
     }
     if (active)
     {
         Events["CoreToggle"].guiName = "Deactivate Core";
     }
 }
示例#3
0
        public override void OnStart(StartState state)
        {
            if (state.ToString().Contains(StartState.PreLaunch.ToString()))
            {
                Debug.Log("[KSPI]: PreLaunch uses InitialGearRatio:" + InitialGearRatio);
                SelectedIsp = ((MaxIsp - MinIsp) * Math.Max(0, Math.Min(1, InitialGearRatio))) + MinIsp;
            }

            Fields[nameof(selectedFuel)].guiName = fuelSwitchName;

            Fields[nameof(currentMaximumPowerRequirement)].guiActive = powerRequirement > 0;
            Fields[nameof(laserWasteheat)].guiActive    = powerRequirement > 0 && fusionWasteHeat > 0;
            Fields[nameof(absorbedWasteheat)].guiActive = powerRequirement > 0 && fusionWasteHeat > 0;
            Fields[nameof(fusionRatio)].guiActive       = powerRequirement > 0;

            Fields[nameof(powerRequirementMax)].guiActiveEditor = powerRequirement > 0;
            Fields[nameof(fusionWasteHeatMax)].guiActiveEditor  = fusionWasteHeat > 0;

            part.maxTemp             = maxTemp;
            part.thermalMass         = 1;
            part.thermalMassModifier = 1;

            curEngineT = part.FindModuleImplementing <ModuleEngines>();
            if (curEngineT == null)
            {
                Debug.LogError("[KSPI]: FusionEngine OnStart Engine not found");
                return;
            }
            BaseFloatCurve = curEngineT.atmosphereCurve;

            curveMaxISP = GetMaxKey(BaseFloatCurve);
            if (hasMultipleConfigurations)
            {
                FcSetup();
            }

            InitializeKerbalismEmitter();

            DetermineTechLevel();
            powerRequirementMax = PowerRequirementMaximum;
            fusionWasteHeatMax  = FusionWasteHeat;

            resourceBuffers = new ResourceBuffers();
            resourceBuffers.AddConfiguration(new WasteHeatBufferConfig(wasteHeatMultiplier, 1.0e+4, true));
            resourceBuffers.UpdateVariable(ResourceSettings.Config.WasteHeatInMegawatt, this.part.mass);
            resourceBuffers.Init(this.part);

            if (state != StartState.Editor)
            {
                part.emissiveConstant = maxTempatureRadiators > 0 ? 1 - coldBathTemp / maxTempatureRadiators : 0.01;
            }

            base.OnStart(state);

            Fields["localIsp"].guiActive       = selectableIsp;
            Fields["localIsp"].guiActiveEditor = selectableIsp;
        }
示例#4
0
        public override void OnStart(StartState state)
        {
            Log.post(this.ClassName + " start-callback: " + state.ToString());

            if (HighLogic.LoadedScene == GameScenes.FLIGHT)
            {
                part.force_activate();

                Log.post("Searching for drainable resources");
                List <string> drainResourceNames = new List <string>();
                foreach (AirshipDrainResource dr in GetComponents <AirshipDrainResource>())
                {
                    if (dr.Resource != null)
                    {
                        drainResources.Add(dr);
                        drainResourceNames.Add(dr.displayName);
                        Log.post("Found drainable resource: " + dr.displayName, LogLevel.LOG_INFORMATION);
                    }
                    else
                    {
                        Log.post("Found drainable resource: " + dr.displayName + " but resource is not available on part", LogLevel.LOG_INFORMATION);
                    }
                }
                Log.post("Finished searching for drainable resources");

                Log.post("adding drainable resources to tweakable choose field");
                BaseField field = Fields["drainResource"];
                if (field != null)
                {
                    UI_ChooseOption options = (UI_ChooseOption)field.uiControlFlight;

                    if (options != null)
                    {
                        if (drainResourceNames.Count > 0)
                        {
                            options.options = drainResourceNames.ToArray();
                            drainResource   = drainResourceNames[0];
                        }
                        else
                        {
                            Log.post("No drainable resources. tweakable disabled.", LogLevel.LOG_INFORMATION);
                            options.controlEnabled = false;
                        }
                    }
                    else
                    {
                        Log.post("Field 'drainResource' does not have a UI_ChooseOption attribute", LogLevel.LOG_ERROR);
                    }
                }
                else
                {
                    Log.post("Field 'drainResource' does not exist", LogLevel.LOG_ERROR);
                }
            }
        }
示例#5
0
        public override void OnStart(StartState state)
        {
            Log.post(this.ClassName + " OnStart-callback: " + state.ToString());

            setupUI();

            if (state != StartState.Editor)
            {
                part.force_activate();
            }
        }
        public override void OnStart(StartState state)
        {
            Log.post(this.ClassName + " OnStart-callback: " + state.ToString());

            Actions["toggleDump"].guiName   = "toggle " + resourceName + " dumping";
            Actions["startDumping"].guiName = "dump " + resourceName;
            Actions["stopDumping"].guiName  = "stop dumping " + resourceName;

            ((UI_FloatEdit)Fields["dumpRate"].uiControlFlight).minValue = minDumpRate;
            ((UI_FloatEdit)Fields["dumpRate"].uiControlFlight).maxValue = maxDumpRate;
            //((UI_FloatEdit)Fields["dumpRate"].uiControlFlight).maxValue = maxDumpRate;
        }
        public override void OnStart(StartState state)
        {
            try
            {
                Debug.Log("[KSPI]: Start State: " + state.ToString());
                Debug.Log("[KSPI]: Already Launched: " + Launched);

                curEngineT    = this.part.FindModuleImplementing <ModuleEngines>();
                curEngineWarp = this.part.FindModuleImplementing <ModuleEnginesWarp>();

                InitializeGUI();

                _fuelConfigurationWithEffect = FuelConfigurations.Where(m => !string.IsNullOrEmpty(m.effectname)).ToList();
                _fuelConfigurationWithEffect.ForEach(prop => part.Effect(prop.effectname, 0, -1));

                if (state == StartState.Editor)
                {
                    Debug.Log("[KSPI]: Editor");
                    hideEmpty        = false;
                    selectedTank     = selectedFuel;
                    selectedTankName = FuelConfigurations[selectedFuel].ConfigName;
                    //UpdateResources();
                }
                else
                {
                    hideEmpty = true;
                    if (state == StartState.PreLaunch) // startstate normally == prelaunch,landed
                    {
                        Debug.Log("[KSPI]: PreLaunch");
                        hideEmpty = true;
                        //UpdateResources();
                        //UpdateusefulConfigurations();
                        InitializeFuelSelector();
                    }
                    else
                    {
                        Debug.Log("[KSPI]: No PreLaunch");
                    }
                }

                Debug.Log("[KSPI]: OnStart calls UpdateFuel");
                UpdateFuel();

                Events["ShowFuels"].active = hideEmpty;
                Events["HideFuels"].active = !hideEmpty;
            }
            catch (Exception e)
            {
                Debug.LogError("EngineECU2 OnStart eception: " + e.Message);
            }

            base.OnStart(state);
        }
        public override void OnStart(StartState state)
        {
            Debug.Log ("Starting KAS_AnimationPlayerModule: " + state.ToString ());

            try
            {
                ReloadAnimations ();
            }
            catch(Exception e)
            {
                Debug.LogException (e);
            }
        }
        public override void OnStart(StartState state)
        {
            Debug.Log("Starting KAS_AnimationPlayerModule: " + state.ToString());

            try
            {
                ReloadAnimations();
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
示例#10
0
        public override void OnStart(StartState state)
        {
            String[] resources_to_supply = { ResourceManager.FNRESOURCE_MEGAJOULES, ResourceManager.FNRESOURCE_WASTEHEAT };
            this.resources_to_supply = resources_to_supply;

            try
            {
                Debug.Log("[KSPI]: Start Current State: " + (int)state + " " + state.ToString());
                Debug.Log("[KSPI]: OnStart Already Launched: " + Launched);

                curEngineT    = this.part.FindModuleImplementing <ModuleEngines>();
                curEngineWarp = this.part.FindModuleImplementing <ModuleEnginesWarp>();

                if ((state & StartState.PreLaunch) == StartState.PreLaunch)
                {
                    hideEmpty = true;
                }

                InitializeGUI();

                _fuelConfigurationWithEffect = FuelConfigurations.Where(m => !string.IsNullOrEmpty(m.effectname)).ToList();
                _fuelConfigurationWithEffect.ForEach(prop => part.Effect(prop.effectname, 0, -1));

                if (state == StartState.Editor)
                {
                    hideEmpty        = false;
                    selectedTank     = selectedFuel;
                    selectedTankName = FuelConfigurations[selectedFuel].ConfigName;
                }

                UpdateFuel();
                Events["ShowFuels"].active = hideEmpty;
                Events["HideFuels"].active = !hideEmpty;

                Fields["upgradeTechReq1"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq1);
                Fields["upgradeTechReq2"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq2);
                Fields["upgradeTechReq3"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq3);
                Fields["upgradeTechReq4"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq4);

                Fields["maxThrustUpgraded1"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq1);
                Fields["maxThrustUpgraded2"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq2);
                Fields["maxThrustUpgraded3"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq3);
                Fields["maxThrustUpgraded4"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq4);
            }
            catch (Exception e)
            {
                Debug.LogError("EngineECU2 OnStart eception: " + e.Message);
            }

            base.OnStart(state);
        }
示例#11
0
        public override void OnStart(StartState state)
        {
            // Add stuff to the log
            Log.post(this.ClassName + " OnStart-callback: " + state.ToString());



            if (state != StartState.Editor)
            {
                Log.post("force activate envelope");
                part.force_activate();
            }



            setupUI();
        }
        public override void OnStart(StartState state)
        {
            Log.post(this.ClassName + " OnStart-callback: " + state.ToString());

            //setupUI();


            if (!util.editorActive())
            {
                part.force_activate();
                if (getCurrentLiftingGas().combustible)
                {
                    part.maxTemp = getCurrentLiftingGas().maxTemperature;
                }
            }

            damageTimer = -10.0f;

            Log.post("AirshipEnvelope Module started", LogLevel.LOG_INFORMATION);
        }
示例#13
0
        private void StartStateMachineInternal()
        {
            var state = GetState(StartState);

            if (AssociatedVisualStateManager != null)
            {
                AssociatedVisualStateManager.TransitionState(Name, null, StartState.ToString());
            }


            state.Enter(StartState);

            CurrentState = StartState;

            if (!state.TryAutomaticTransition())
            {
                state.ResumeTransitions();
            }

            RaiseStateMachineStarted();
        }
        public override void OnStart(StartState state)
        {
            String[] resources_to_supply = { ResourceSettings.Config.ElectricPowerInMegawatt, ResourceSettings.Config.WasteHeatInMegawatt };
            this.resources_to_supply = resources_to_supply;

            Debug.Log("[KSPI]: Start Current State: " + (int)state + " " + state.ToString());
            Debug.Log("[KSPI]: OnStart Already Launched: " + Launched);

            curEngineT    = this.part.FindModuleImplementing <ModuleEngines>();
            curEngineWarp = this.part.FindModuleImplementing <ModuleEnginesWarp>();

            if ((state & StartState.PreLaunch) == StartState.PreLaunch)
            {
                hideEmpty = true;
            }

            InitializeGUI();

            _fuelConfigurationWithEffect = FuelConfigurations.Where(m => !string.IsNullOrEmpty(m.effectname)).ToList();
            _fuelConfigurationWithEffect.ForEach(prop => part.Effect(prop.effectname, 0, -1));

            if (state == StartState.Editor)
            {
                hideEmpty        = false;
                selectedTank     = selectedFuel;
                selectedTankName = FuelConfigurations[selectedFuel].ConfigName;
            }

            UpdateFuel();
            Events["ShowFuels"].active = hideEmpty;
            Events["HideFuels"].active = !hideEmpty;

            translatedTechMk1 = PluginHelper.DisplayTech(upgradeTechReq1);
            translatedTechMk2 = PluginHelper.DisplayTech(upgradeTechReq2);
            translatedTechMk3 = PluginHelper.DisplayTech(upgradeTechReq3);
            translatedTechMk4 = PluginHelper.DisplayTech(upgradeTechReq4);

            base.OnStart(state);
        }
示例#15
0
//		bool _originalActivatesEventIfDisconnected;

        public override void OnStart(StartState state)
        {
            Log.Write($"OnStart({state.ToString()})");

            Log.Write($"addStagingOption: {addStagingOption}, selfDestructOnStage: {selfDestructOnStage}");

            Fields["selfDestructOnStage"].OnValueModified += selfDestructOnStageChanged;

//			Log.Write($"partModule.stagingEnabled is {stagingEnabled}, part.stagingOn = {part.stagingOn}, part.hasStagingIcon = {part.hasStagingIcon}");
//			Fields["selfDestructOnStage"].guiActiveEditor = stagingEnabled;
//			Fields["selfDestructOnStage"].guiActive = stagingEnabled;

//			_originalActivatesEventIfDisconnected = part.ActivatesEvenIfDisconnected;
            part.ActivatesEvenIfDisconnected = true;
            //			if (stagingEnabled) {
//			if (selfDestructOnStage) {
//					part.stackIcon.Highlight(true);
            //				part.stackIcon.SetIconColor(XKCDColors.FireEngineRed);
//				part.ActivatesEvenIfDisconnected = true;
//				if (addStagingOption)
//					EnableStaging();
//			} else {
//					part.stackIcon.Highlight(false);
//				part.ActivatesEvenIfDisconnected = _originalActivatesEventIfDisconnected;
//				if (addStagingOption)
//					DisableStaging();
            //		}
//			}
            //if (!canStage) {
            //	Invoke("DisableStaging", 0.5f);
            //} else {
            //	UpdateStagingEvents();
            //}

            //UpdateSelfDestructEvents();
            //GameEvents.onVesselChange.Add(OnVesselChange);
        }
示例#16
0
        public override void OnStart(StartState state)
        {
            Debug.Log("ModuleEngineThrustController OnStart(" + state.ToString() + ")");
            m_state = state;

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

            BindEngine();

            if (minimumThrustPercent < 0.0f)
            {
                minimumThrustPercent = 0.0f;
            }
            if (minimumThrustPercent > 1.0f)
            {
                minimumThrustPercent = 1.0f;
            }

            if (maximumThrustPercent < 0.0f)
            {
                maximumThrustPercent = 0.0f;
            }
            if (maximumThrustPercent > 1.0f)
            {
                maximumThrustPercent = 1.0f;
            }

            if (minimumThrustPercent > maximumThrustPercent)
            {
                minimumThrustPercent = maximumThrustPercent;
            }

            if (initialThrust < minimumThrustPercent)
            {
                initialThrust = minimumThrustPercent;
            }
            if (initialThrust > maximumThrustPercent)
            {
                initialThrust = maximumThrustPercent;
            }

            // Save original engine data.
            if (engine != null)
            {
                originalMaxThrust      = engine.maxThrust;
                originalHeatProduction = engine.heatProduction;
                if (((int)state & (int)StartState.PreLaunch) > 0)
                {
                    thrustPercent = initialThrust;
                }
                else if (state == StartState.Editor)
                {
                    thrustPercent = initialThrust;
                }

                engine.maxThrust      = originalMaxThrust * thrustPercent;
                engine.heatProduction = originalHeatProduction * thrustPercent;
            }
            else if (engineFX != null)
            {
                originalMaxThrust      = engineFX.maxThrust;
                originalHeatProduction = engineFX.heatProduction;
                if (((int)state & (int)StartState.PreLaunch) > 0)
                {
                    thrustPercent = initialThrust;
                }
                else if (state == StartState.Editor)
                {
                    thrustPercent = initialThrust;
                }

                engineFX.maxThrust      = originalMaxThrust * thrustPercent;
                engineFX.heatProduction = originalHeatProduction * thrustPercent;
            }
            Debug.Log("Data saved:" + originalMaxThrust.ToString() + " " + thrustPercent.ToString("0%"));

            if (state == StartState.Editor)
            {
                EngineThrustControllerGUI.GetInstance().CheckClear();
                if (showItemInList == true)
                {
                    EngineThrustControllerGUIItem item = new EngineThrustControllerGUIItem(EngineThrustControllerGUI.GetInstance(), this);
                }
                return;
            }
            else
            {
                EngineThrustControllerGUI.GetInstance().ClearGUIItem();
            }

            if (canAdjustAtAnytime == true)
            {
                Events["ContextMenuIncreaseThrust"].guiName = "Increase Thrust by " + percentAdjustmentStep.ToString("0%");
                Events["ContextMenuDecreaseThrust"].guiName = "Decrease Thrust by " + percentAdjustmentStep.ToString("0%");
            }
            else
            {
                Events["ContextMenuIncreaseThrust"].guiActive = false;
                Events["ContextMenuIncreaseThrust"].active    = false;
                Events["ContextMenuDecreaseThrust"].guiActive = false;
                Events["ContextMenuDecreaseThrust"].active    = false;
            }
            Events["Group1"].guiName   = "Set Group 1";
            Events["Group2"].guiName   = "Set Group 2";
            Events["Group1"].guiActive = false;
            Events["Group2"].guiActive = false;
            base.OnStart(state);
        }
示例#17
0
        /// <summary>
        /// Start
        /// </summary>
        /// <param name="state"></param>
        public override void OnStart(StartState state)
        {
            GSA.Durability.Debug.Log("GSA Durability: [OnStart][" + state.ToString() + "]: " + this.name);
            base.OnStart(state);
            try
            {
                _state = state;
                AvailablePart currentPartInfo = PartLoader.getPartInfoByName(part.name.Replace("(Clone)", ""));
                _initCost = currentPartInfo.cost;
                if (state == StartState.Editor)
                {
                    return;
                }
                if (part.Resources.Contains("Quality"))
                {
                    quality = (part.Resources["Quality"].amount / (part.Resources["Quality"].maxAmount / 100)) / 100;
                }

                if (basicWear.findCurveMinMaxInterations == 0)
                {
                    basicWear = new FloatCurve();
                    basicWear.Add(0.1f, 0.69f);
                    basicWear.Add(0.5f, 0.000181f);
                    basicWear.Add(1f, 0.00001f);
                }
                _currentWear = basicWear.Evaluate((float)quality);
                _lastUpdateTime = vessel.missionTime;
                _sun = Planetarium.fetch.Sun;
                //gameObject.AddComponent(typeof(LineRenderer));

                if (part.Modules.Contains("ModuleCommand"))
                {
                    _command = (ModuleCommand)part.Modules["ModuleCommand"];
                    GSA.Durability.Debug.Log("GSA Durability: [OnStart]: _command = " + _command.name);
                }

                if (part.Modules.Contains("ModuleReactionWheel"))
                {
                    _reactionWheel = (ModuleReactionWheel)part.Modules["ModuleReactionWheel"];
                    GSA.Durability.Debug.Log("GSA Durability: [OnStart]: _reactionWheel = " + _reactionWheel.name);
                }

                if (part.Modules.Contains("ModuleEngines"))
                {
                    _engine = (ModuleEngines)part.Modules["ModuleEngines"];
                    GSA.Durability.Debug.Log("GSA Durability: [OnStart]: _engine = " + _engine.name);
                }
                if (part.Modules.Contains("ModuleScienceExperiment"))
                {
                    _scienceExperiment = (ModuleScienceExperiment)part.Modules["ModuleScienceExperiment"];
                    GSA.Durability.Debug.Log("GSA Durability: [OnStart]: _scienceExperiment = " + _scienceExperiment.name);
                }

                checkStatus();
                setEventLabel();
            }
            catch (Exception ex)
            {
                GSA.Durability.Debug.LogError("GSA Durability: [OnStart]: Message: " + ex.Message);
                GSA.Durability.Debug.LogError("GSA Durability: [OnStart]: StackTrace: " + ex.StackTrace);
            }

            GSA.Durability.Debug.Log("GSA Durability: [OnStart]: quality:" + quality.ToString());
            GSA.Durability.Debug.Log("GSA Durability: [OnStart]: damageRate: " + _currentWear.ToString("0.000000"));
            GSA.Durability.Debug.Log("GSA Durability: [OnStart]: vessel.missionTime: " + vessel.missionTime.ToString());
            GSA.Durability.Debug.Log("GSA Durability: [OnStart]: lastReduceRange: " + lastReduceRange.ToString());
            GSA.Durability.Debug.Log("GSA Durability: [OnStart]: lastUpdateTime: " + _lastUpdateTime.ToString());
            GSA.Durability.Debug.Log("GSA Durability: [OnStart]: maxRepair: " + maxRepair.ToString());
            GSA.Durability.Debug.Log("GSA Durability: [OnStart]: canRepair: " + canRepair.ToString());
        }
        public override void OnStart(StartState state)
        {
            Debug.Log("ModuleEngineThrustController OnStart(" + state.ToString() + ")");
            m_state = state;

            if (state == StartState.None) return;

            BindEngine();

            if (minimumThrustPercent < 0.0f) minimumThrustPercent = 0.0f;
            if (minimumThrustPercent > 1.0f) minimumThrustPercent = 1.0f;

            if (maximumThrustPercent < 0.0f) maximumThrustPercent = 0.0f;
            if (maximumThrustPercent > 1.0f) maximumThrustPercent = 1.0f;

            if (minimumThrustPercent > maximumThrustPercent) minimumThrustPercent = maximumThrustPercent;

            if (initialThrust < minimumThrustPercent) initialThrust = minimumThrustPercent;
            if (initialThrust > maximumThrustPercent) initialThrust = maximumThrustPercent;

            // Save original engine data.
            if (engine != null)
            {
                originalMaxThrust = engine.maxThrust;
                originalHeatProduction = engine.heatProduction;
                if (((int)state & (int)StartState.PreLaunch) > 0)
                    thrustPercent = initialThrust;
                else if (state == StartState.Editor)
                    thrustPercent = initialThrust;

                engine.maxThrust = originalMaxThrust * thrustPercent;
                engine.heatProduction = originalHeatProduction * thrustPercent;
            }
            else if (engineFX != null)
            {
                originalMaxThrust = engineFX.maxThrust;
                originalHeatProduction = engineFX.heatProduction;
                if (((int)state & (int)StartState.PreLaunch) > 0)
                    thrustPercent = initialThrust;
                else if (state == StartState.Editor)
                    thrustPercent = initialThrust;

                engineFX.maxThrust = originalMaxThrust * thrustPercent;
                engineFX.heatProduction = originalHeatProduction * thrustPercent;
            }
            Debug.Log("Data saved:" + originalMaxThrust.ToString() + " " + thrustPercent.ToString("0%"));

            if (state == StartState.Editor)
            {
                EngineThrustControllerGUI.GetInstance().CheckClear();
                if (showItemInList == true)
                {
                    EngineThrustControllerGUIItem item = new EngineThrustControllerGUIItem(EngineThrustControllerGUI.GetInstance(), this);
                }
                return;
            }
            else
            {
                EngineThrustControllerGUI.GetInstance().ClearGUIItem();
            }

            if (canAdjustAtAnytime == true)
            {
                Events["ContextMenuIncreaseThrust"].guiName = "Increase Thrust by " + percentAdjustmentStep.ToString("0%");
                Events["ContextMenuDecreaseThrust"].guiName = "Decrease Thrust by " + percentAdjustmentStep.ToString("0%");
            }
            else
            {
                Events["ContextMenuIncreaseThrust"].guiActive = false;
                Events["ContextMenuIncreaseThrust"].active = false;
                Events["ContextMenuDecreaseThrust"].guiActive = false;
                Events["ContextMenuDecreaseThrust"].active = false;
            }
            Events["Group1"].guiName = "Set Group 1";
            Events["Group2"].guiName = "Set Group 2";
            Events["Group1"].guiActive = false;
            Events["Group2"].guiActive = false;
            base.OnStart(state);
        }
        public override void OnStart(StartState state)
        {
            try
            {
                if (state.ToString().Contains(StartState.PreLaunch.ToString()))
                {
                    Debug.Log("[KSPI]: PreLaunch uses InitialGearRatio:" + InitialGearRatio);
                    SelectedIsp = ((MaxIsp - MinIsp) * Math.Max(0, Math.Min(1, InitialGearRatio))) + MinIsp;
                }

                Fields["selectedFuel"].guiName = fuelSwitchName;

                Fields["currentMaximumPowerRequirement"].guiActive = powerRequirement > 0;
                Fields["laserWasteheat"].guiActive    = powerRequirement > 0 && fusionWasteHeat > 0;
                Fields["absorbedWasteheat"].guiActive = powerRequirement > 0 && fusionWasteHeat > 0;
                Fields["fusionRatio"].guiActive       = powerRequirement > 0;

                Fields["powerRequirement"].guiActiveEditor          = powerRequirement > 0;
                Fields["powerRequirementUpgraded1"].guiActiveEditor = powerRequirementUpgraded1 > 0;
                Fields["powerRequirementUpgraded2"].guiActiveEditor = powerRequirementUpgraded2 > 0;
                Fields["powerRequirementUpgraded3"].guiActiveEditor = powerRequirementUpgraded3 > 0;
                Fields["powerRequirementUpgraded4"].guiActiveEditor = powerRequirementUpgraded4 > 0;

                Fields["fusionWasteHeat"].guiActiveEditor          = fusionWasteHeat > 0;
                Fields["fusionWasteHeatUpgraded1"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq1);
                Fields["fusionWasteHeatUpgraded2"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq2);
                Fields["fusionWasteHeatUpgraded3"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq3);
                Fields["fusionWasteHeatUpgraded4"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq4);

                part.maxTemp             = maxTemp;
                part.thermalMass         = 1;
                part.thermalMassModifier = 1;

                curEngineT = this.part.FindModuleImplementing <ModuleEngines>();
                if (curEngineT == null)
                {
                    Debug.LogError("[KSPI]: FusionEngine OnStart Engine not found");
                    return;
                }
                BaseFloatCurve = curEngineT.atmosphereCurve;

                curveMaxISP = GetMaxKey(BaseFloatCurve);
                if (hasMultipleConfigurations)
                {
                    FcSetup();
                }

                InitializeKerbalismEmitter();

                DetermineTechLevel();

                resourceBuffers = new ResourceBuffers();
                resourceBuffers.AddConfiguration(new ResourceBuffers.TimeBasedConfig(ResourceManager.FNRESOURCE_WASTEHEAT, wasteHeatMultiplier, 1.0e+4, true));
                resourceBuffers.UpdateVariable(ResourceManager.FNRESOURCE_WASTEHEAT, this.part.mass);
                resourceBuffers.Init(this.part);

                if (state != StartState.Editor)
                {
                    part.emissiveConstant = maxTempatureRadiators > 0 ? 1 - coldBathTemp / maxTempatureRadiators : 0.01;
                }

                base.OnStart(state);

                Fields["localIsp"].guiActive       = selectableIsp;
                Fields["localIsp"].guiActiveEditor = selectableIsp;
            }
            catch (Exception e)
            {
                Debug.LogError("[KSPI]: FusionEngine OnStart eception: " + e.Message);
            }
        }
        public override void OnStart(StartState state)
        {
            if (Global.Debug2) Utils.Log("state {0}", state.ToString());
            base.OnStart(state);

            // side step serialization issues and use the saved config
            _startState = state;
            if (state == StartState.Editor)
            {
                if (originalConfig == null)
                {
                    if (Global.Debug1) Utils.Log("originalConfig is null");
                }
                else loadConfig(originalConfig);
            }

            if (label != string.Empty) Events["editTextureEvent"].guiName = label;

            _ok = false;
            try
            {
                if (Global.Debug1) Utils.Log("part {0}", this.part.name);

                fillTransformNamesList();
                fillTransformsList();

                if (_transforms == null || _transforms[0] == null)
                {
                    Utils.LogError("No useable transforms, disabling plugin");
                    return;
                }

                findTextures();

                if (_imageModifiers == null) _imageModifiers = new ImageModifiers();
                if (_boundingBox == null) _boundingBox = new BoundingBox();
                if (_baseTexture == null) _baseTexture = new IM.AutoBaseTexture();

                _baseTexture.set(kspTextureInfo);

                if (!_baseTexture.valid)
                {
                    Utils.LogError("invalid base texture trying auto");
                    _baseTexture = new IM.AutoBaseTexture();
                    _baseTexture.set(kspTextureInfo);
                }

                if (_baseTexture.valid)
                {
                    if (_imageModifiers.modifiers.Count > 0) writeTexture();
                    _ok = true;
                }
            }
            catch
            {
                Utils.LogError("Something went wrong in OnStart disabling plugin");
            }
        }
示例#21
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public CommandStatus StartStopUnit(bool immd, PowerControl pc, StartState state)
        {
            if (m_logger != null)
            {
                string args = immd.ToString() + ", " + pc.ToString() + ", " + state.ToString();
                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 8, "Bwg.Scsi.Device.StartStopUnit(" + args + ")"));
            }

            using (Command cmd = new Command(ScsiCommandCode.StartStopUnit, 6, 0, Command.CmdDirection.None, 30))
            {
                if (immd)
                    cmd.SetCDB8(1, 1) ;

                byte b = (byte)(((byte)pc << 4) | ((byte)state)) ;
                cmd.SetCDB8(4, b) ;

                CommandStatus st = SendCommand(cmd);
                if (st != CommandStatus.Success)
                    return st;
            }
            return CommandStatus.Success; 
        }
示例#22
0
        public override void OnStart(StartState state)
        {
#if DEBUG
            print("========ModuleFuelTanks.OnStart( State == " + state.ToString() + ")=======");
#endif
            if (basemass == 0 && part != null)
            {
                basemass = part.mass;
            }
            if (fuelList == null)
            {
                fuelList = new List <ModuleFuelTanks.FuelTank> ();
            }

            if (fuelList.Count == 0)
            {
                // when we get called from the editor, the fuelList won't be populated
                // because OnLoad() was never called. This is a hack to fix that.
                Part prefab = part.symmetryCounterparts.Find(pf => pf.Modules.Contains("ModuleFuelTanks") &&
                                                             ((ModuleFuelTanks)pf.Modules["ModuleFuelTanks"]).fuelList.Count > 0);
                if (prefab)
                {
#if DEBUG
                    print("ModuleFuelTanks.OnStart: copying from a symmetryCounterpart with a ModuleFuelTanks PartModule");
#endif
                }
                else
                {
                    AvailablePart partData = PartLoader.getPartInfoByName(part.partInfo.name);
                    if (partData == null)
                    {
                        print("ModuleFuelTanks.OnStart could not find AvailablePart for " + part.partInfo.name);
                    }
                    else if (partData.partPrefab == null)
                    {
                        print("ModuleFuelTanks.OnStart: AvailablePart.partPrefab is null.");
                    }
                    else
                    {
                        prefab = partData.partPrefab;
                        if (!prefab.Modules.Contains("ModuleFuelTanks"))
                        {
                            print("ModuleFuelTanks.OnStart: AvailablePart.partPrefab does not contain a ModuleFuelTanks.");
                            prefab = null;
                        }
                    }
                }
                if (prefab)
                {
                    ModuleFuelTanks pModule = (ModuleFuelTanks)prefab.Modules["ModuleFuelTanks"];
                    if (pModule == this)
                    {
                        print("ModuleFuelTanks.OnStart: Copying from myself won't do any good.");
                    }
                    else
                    {
                        ConfigNode node = new ConfigNode("MODULE");
                        pModule.OnSave(node);
                                                #if DEBUG
                        print("ModuleFuelTanks.OnStart node from prefab:" + node);
                                                #endif
                        this.OnLoad(node);
                    }
                }
            }
            foreach (FuelTank tank in fuelList)
            {
                tank.module = this;
            }

            if (radius > 0 && length > 0)
            {
                part.transform.localScale = new Vector3(rscale / radius, length, rscale / radius);
                foreach (AttachNode n in part.attachNodes)
                {
                    if (n.nodeType == AttachNode.NodeType.Stack)
                    {
                        n.offset.y *= length;
                    }
                }
            }
            part.mass = basemass + tank_mass;

            if (HighLogic.LoadedSceneIsEditor)
            {
                UpdateSymmetryCounterparts();
                // if we detach and then re-attach a configured tank with symmetry on, make sure the copies are configured.
            }
        }
示例#23
0
 /// <summary>
 /// Returns a hash code for this instance.
 /// </summary>
 public override int GetHashCode()
 {
     return(StartState.ToString().GetHashCode() ^ Signal.ToString().GetHashCode());
 }