private void UpdateAmounts() { capacityStr = PluginHelper.formatMassStr(antimatterResource.amount * antimatterDensity); maxAmountStr = PluginHelper.formatMassStr(antimatterResource.maxAmount * antimatterDensity); }
public void Update() { var antimatterResource = part.Resources[resourceName]; showAntimatterFields = antimatterResource != null && antimatterResource.resourceName == resourceName; TemperatureStrField.guiActive = canExplodeFromHeat; TemperatureStrField.guiActiveEditor = canExplodeFromHeat; GeeforceStrField.guiActive = canExplodeFromGeeForce; GeeforceStrField.guiActiveEditor = canExplodeFromGeeForce; if (antimatterResource == null) { antimatterResource = part.Resources.OrderByDescending(m => m.maxAmount).FirstOrDefault(); if (antimatterResource == null) { return; } } capacityStrField.guiActive = showAntimatterFields; capacityStrField.guiActiveEditor = showAntimatterFields; maxAmountStrField.guiActive = showAntimatterFields; maxAmountStrField.guiActiveEditor = showAntimatterFields; // restore antimatter amount when stolen if (HighLogic.LoadedSceneIsEditor) { storedAmount = antimatterResource.amount; } else if (vessel.missionTime < 1 && storedAmount > 0 && antimatterResource.amount == 0) { antimatterResource.amount = storedAmount; storedAmount = 0; } capacityStr = PluginHelper.formatMassStr(antimatterResource.amount * antimatterDensity); maxAmountStr = PluginHelper.formatMassStr(antimatterResource.maxAmount * antimatterDensity); part.explosionPotential = (float)antimatterResource.amount * explosionPotentialMultiplier; UpdateTargetMass(); UpdateTolerances(); var newRatio = antimatterResource.amount / antimatterResource.maxAmount; // if closed and changed if (deploymentAnimation != null && deploymentAnimation.GetScalar == 0 && newRatio != resourceRatio && HighLogic.LoadedSceneIsEditor) { // open up deploymentAnimation.Toggle(); } resourceRatio = newRatio; partMass = part.mass; partCost = part.partInfo.cost; if (HighLogic.LoadedSceneIsEditor) { chargestatus = maxCharge; Fields["maxGeeforce"].guiActiveEditor = canExplodeFromGeeForce; Fields["maxTemperature"].guiActiveEditor = canExplodeFromHeat; return; } chargeStatusStr = chargestatus.ToString("0.0") + " / " + maxCharge.ToString("0.0"); TemperatureStr = part.temperature.ToString("0") + " / " + maxTemperature.ToString("0"); GeeforceStr = effectiveMaxGeeforce == 0 ? maxGeeforce.ToString("0.0") + " when full" : currentGeeForce.ToString("0.000") + " / " + effectiveMaxGeeforce.ToString("0.000"); minimimAnimatterAmount = antimatterDensityModifier * antimatterResource.maxAmount; Events["StartCharge"].active = antimatterResource.amount <= minimimAnimatterAmount && !should_charge; Events["StopCharge"].active = antimatterResource.amount <= minimimAnimatterAmount && should_charge; if (maxCharge <= 60 && !charging && antimatterResource.amount > minimimAnimatterAmount) { ScreenMessages.PostScreenMessage(Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Postmsg6", chargestatus.ToString("0")), 0.5f, ScreenMessageStyle.UPPER_CENTER);//"Warning!: Antimatter storage unpowered, tank explosion in: " + + "s" } if (antimatterResource.amount > minimimAnimatterAmount) { statusStr = charging ? Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Statu1") : Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Statu2");//"Charging.""Discharging!" } else { statusStr = should_charge ? Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Statu1") : Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Statu3");//"Charging.""No Power Required." } }
public void Update() { var antimatterResource = part.Resources[resourceName]; showAntimatterFields = antimatterResource != null && antimatterResource.resourceName == resourceName; TemperatureStrField.guiActive = canExplodeFromHeat; TemperatureStrField.guiActiveEditor = canExplodeFromHeat; GeeforceStrField.guiActive = canExplodeFromGeeForce; GeeforceStrField.guiActiveEditor = canExplodeFromGeeForce; if (antimatterResource == null) { antimatterResource = part.Resources.OrderByDescending(m => m.maxAmount).FirstOrDefault(); if (antimatterResource == null) { return; } } capacityStrField.guiActive = showAntimatterFields; capacityStrField.guiActiveEditor = showAntimatterFields; maxAmountStrField.guiActive = showAntimatterFields; maxAmountStrField.guiActiveEditor = showAntimatterFields; capacityStr = PluginHelper.formatMassStr(antimatterResource.amount * antimatterDensity); maxAmountStr = PluginHelper.formatMassStr(antimatterResource.maxAmount * antimatterDensity); UpdateTargetMass(); var newRatio = antimatterResource.amount / antimatterResource.maxAmount; // if closed and changed if (deploymentAnimation != null && deploymentAnimation.GetScalar == 0 && newRatio != resourceRatio && HighLogic.LoadedSceneIsEditor) { // open up deploymentAnimation.Toggle(); } resourceRatio = newRatio; partMass = part.mass; partCost = part.partInfo.cost; if (HighLogic.LoadedSceneIsEditor) { chargestatus = maxCharge; Fields["maxGeeforce"].guiActiveEditor = canExplodeFromGeeForce; Fields["maxTemperature"].guiActiveEditor = canExplodeFromHeat; return; } chargeStatusStr = chargestatus.ToString("0.0") + " / " + maxCharge.ToString("0.0"); TemperatureStr = part.temperature.ToString("0") + " / " + maxTemperature.ToString("0"); GeeforceStr = part.vessel.geeForce.ToString("0.0") + " / " + maxGeeforce.ToString("0.0"); minimimAnimatterAmount = antimatterDensityModifier * antimatterResource.maxAmount; Events["StartCharge"].active = antimatterResource.amount <= minimimAnimatterAmount && !should_charge; Events["StopCharge"].active = antimatterResource.amount <= minimimAnimatterAmount && should_charge; if (maxCharge <= 60 && !charging && antimatterResource.amount > minimimAnimatterAmount) { ScreenMessages.PostScreenMessage("Warning!: Antimatter storage unpowered, tank explosion in: " + chargestatus.ToString("0") + "s", 0.5f, ScreenMessageStyle.UPPER_CENTER); } if (antimatterResource.amount > minimimAnimatterAmount) { if (charging) { statusStr = "Charging."; } else { statusStr = "Discharging!"; } } else { if (should_charge) { statusStr = "Charging."; } else { statusStr = "No Power Required."; } } }