Example #1
0
        public override void OnStart(PartModule.StartState state)
        {
            this.part.force_activate();
            if (ModuleID != "")
            {
                colorChanger = this.GetComponents <ModuleColorChanger>().ToList().Find(i => i.moduleID == ModuleID);
            }

            // Set up the UI slider
            var range = (UI_FloatRange)this.Fields["dischargeActual"].uiControlEditor;

            range.minValue = DischargeRate * DischargeRateMinimumScalar;
            range.maxValue = DischargeRate;

            range          = (UI_FloatRange)this.Fields["dischargeActual"].uiControlFlight;
            range.minValue = DischargeRate * DischargeRateMinimumScalar;
            range.maxValue = DischargeRate;

            // Set up the discharge rate
            if (FirstLoad)
            {
                this.dischargeActual = DischargeRate;
                FirstLoad            = false;
            }

            if (colorChanger != null)
            {
                colorChanger.SetScalar(CurrentCharge / MaximumCharge);
            }

            // Prepare the localization
            Events["ShowCapacitorControl"].guiName = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Action_ToggleUI"));
            Events["Discharge"].guiName            = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Event_Discharge"));
            Events["Enable"].guiName  = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Event_EnableCharge"));
            Events["Disable"].guiName = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Event_DisableCharge"));

            Actions["DischargeAction"].guiName   = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Action_Discharge"));
            Actions["EnableAction"].guiName      = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Action_EnableCharge"));
            Actions["DisableAction"].guiName     = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Action_DisableCharge"));
            Actions["ToggleAction"].guiName      = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Action_ToggleCharge"));
            Actions["TogglePanelAction"].guiName = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Action_ToggleUI"));

            Fields["dischargeActual"].guiName = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Field_DischargeRate"));
            Fields["CapacitorStatus"].guiName = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Field_Status"));

            if (HighLogic.LoadedSceneIsFlight)
            {
                DoCatchup();

                assignedGroups = new List <int>();
                for (int i = 0; i < CapacitorGroups.Length; i++)
                {
                    assignedGroups.Add((int)CapacitorGroups[i]);
                }
            }
        }
 public void FixedUpdate()
 {
     if (HighLogic.LoadedSceneIsFlight && scalarModule != null && heatModule != null)
     {
         scalarModule.SetScalar(Mathf.Clamp01((heatModule.currentLoopTemperature - draperPoint) / maxTempAnimation));
     }
 }
Example #3
0
 private void FixedUpdate()
 {
     if (HighLogic.LoadedSceneIsFlight)
     {
         if (GetResourceAmount(DangerousFuel) <= 0d)
         {
             Events["TransferWaste"].guiActive = false;
         }
         else
         {
             Events["TransferWaste"].guiActive = true;
         }
         if (GetResourceAmount(SafeFuel) <= 0d)
         {
             Events["TransferFuel"].guiActive = false;
         }
         else
         {
             Events["TransferFuel"].guiActive = true;
         }
         // Generate heat
         if (TimeWarp.CurrentRate <= 100f)
         {
             // Spent fuel needs cooling!
             double wasteAmount = GetResourceAmount(DangerousFuel);
             part.AddThermalFlux(HeatFluxPerWasteUnit * (float)wasteAmount);
         }
     }
     if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor)
     {
         if (fuelColorChanger)
         {
             fuelColorChanger.SetScalar((float)(GetResourceAmount(SafeFuel, false) / GetResourceAmount(SafeFuel, true)));
         }
         if (wasteColorChanger)
         {
             wasteColorChanger.SetScalar((float)(GetResourceAmount(DangerousFuel, false) / GetResourceAmount(DangerousFuel, true)));
         }
     }
 }
        private void FixedUpdate()
        {
            if (HighLogic.LoadedSceneIsFlight)
            {
                if (FlightGlobals.ActiveVessel.evaController != null)
                {
                    if (FlightGlobals.ActiveVessel.evaController.ModuleInventoryPartReference.TotalAmountOfPartStored(RefuelCargoPartName) >= 1)
                    {
                        if (GetResourceAmount(WasteResourceName) <= 0d)
                        {
                            Events["CollectWaste"].active = false;
                        }
                        else
                        {
                            Events["CollectWaste"].active = true;
                        }
                        if (GetResourceAmount(FuelResourceName) <= 0d)
                        {
                            Events["CollectFuel"].active = false;
                        }
                        else
                        {
                            Events["CollectFuel"].active = true;
                        }

                        if (GetResourceEVAAmount(WasteResourceName) <= 0d)
                        {
                            Events["StoreWaste"].active = false;
                        }
                        else
                        {
                            Events["StoreWaste"].active = true;
                        }
                        if (GetResourceEVAAmount(FuelResourceName) <= 0d)
                        {
                            Events["StoreFuel"].active = false;
                        }
                        else
                        {
                            Events["StoreFuel"].active = true;
                        }
                    }
                    else
                    {
                        Events["CollectWaste"].active = false;
                        Events["CollectFuel"].active  = false;
                        Events["StoreFuel"].active    = false;
                        Events["StoreWaste"].active   = false;
                    }
                }
            }
            if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor)
            {
                if (fuelColorChanger)
                {
                    fuelColorChanger.SetScalar((float)(GetResourceAmount(FuelResourceName, false) / GetResourceAmount(FuelResourceName, true)));
                }
                if (wasteColorChanger)
                {
                    wasteColorChanger.SetScalar((float)(GetResourceAmount(WasteResourceName, false) / GetResourceAmount(WasteResourceName, true)));
                }
            }
        }