public void NextTech() { BatteryType = (int)RealBatteryConfiguration.getNextConfigKey((BatteryTypes)BatteryType); LoadConfig(); return; }
private void LoadConfig(ConfigNode node = null) { // handle config BatteryConfig batCfg = RealBatteryConfiguration.GetConfig((BatteryTypes)BatteryType); if (!batCfg.isPopulated) { batCfg = RealBatteryConfiguration.GetConfig(BatteryTypes.CFG_lead_acid); if (!batCfg.isPopulated) { throw new Exception("No default battery config for RealBattery!"); } } BatteryTech = RealBatteryConfiguration.getBatteryTypesFriendlyName((BatteryTypes)BatteryType); PowerDensity = batCfg.PowerDensity; EnergyDensity = batCfg.EnergyDensity; ChargeEfficiencyCurve = batCfg.ChargeEfficiencyCurve; //finish loading this batteries config double DischargeRate = part.mass * PowerDensity; //kW DischargeInfoEditor = String.Format("{0:F2}", DischargeRate); ChargeInfoEditor = String.Format("{0:F2}", DischargeRate * ChargeEfficiencyCurve.Evaluate(0f)); PartResource StoredCharge = part.Resources.Get("StoredCharge"); if (StoredCharge == null) { StoredCharge = part.Resources.Add("StoredCharge", 10, 10, true, true, true, true, PartResource.FlowMode.None); } StoredCharge.maxAmount = part.mass * EnergyDensity; StoredCharge.amount = SC_SOC * part.mass * EnergyDensity; // setup ECbufferRatio PartResource ElectricCharge = part.Resources.Get("ElectricCharge"); if (ElectricCharge == null) { ElectricCharge = part.Resources.Add("ElectricCharge", 10, 10, true, true, true, true, PartResource.FlowMode.Both); } ElectricCharge.maxAmount = DischargeRate; ElectricCharge.amount = DischargeRate; UIPartActionWindow[] partWins = FindObjectsOfType <UIPartActionWindow>(); foreach (UIPartActionWindow partWin in partWins) { partWin.displayDirty = true; } }
public override string GetInfo() { RBlog("RealBattery: INF GetInfo"); LoadConfig(); double DischargeRate = part.mass * PowerDensity; return("Type: " + RealBatteryConfiguration.getBatteryTypesFriendlyName((BatteryTypes)BatteryType) + "\n" + String.Format("Discharge Rate: {0:F2} EC/s", DischargeRate) + "\n" + String.Format("Charge Rate: {0:F2} EC/s", DischargeRate * ChargeEfficiencyCurve.Evaluate(0f))); }