public void Update()
        {
            var antimatterResource = part.Resources.Get(_antimatterDefinition.id);

            _showAntimatterFields = antimatterResource != null;

            _temperatureStrField.guiActive       = _showAntimatterFields && canExplodeFromHeat;
            _temperatureStrField.guiActiveEditor = _showAntimatterFields && canExplodeFromHeat;
            _geeforceStrField.guiActive          = _showAntimatterFields && canExplodeFromGeeForce;
            _geeforceStrField.guiActiveEditor    = _showAntimatterFields && canExplodeFromGeeForce;

            _capacityStrField.guiActive        = _showAntimatterFields && showCapacity;
            _capacityStrField.guiActiveEditor  = _showAntimatterFields && showCapacity;
            _maxAmountStrField.guiActive       = _showAntimatterFields && showMaxAmount;
            _maxAmountStrField.guiActiveEditor = _showAntimatterFields && showMaxAmount;

            if (antimatterResource == null)
            {
                return;
            }

            // determine TechLevel maximum storage amount only in editor
            if (HighLogic.LoadedSceneIsEditor && maxStorage != 0)
            {
                var currentStorageRatio = antimatterResource.amount / antimatterResource.maxAmount;
                var newMaximum          = maxStorage * storedResourceCostMultiplier * StorageCapacityModifier;
                var newAmount           = antimatterResource.maxAmount * currentStorageRatio;

                if (Math.Abs(antimatterResource.maxAmount - newMaximum) > 1)
                {
                    antimatterResource.maxAmount = newMaximum;
                    antimatterResource.amount    = newAmount;
                }
            }

            // charge if there is any significant antimatter
            _shouldCharge = antimatterResource.amount > _minimumAntimatterAmount;

            // 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);

            var explosionPowerInTnt = antimatterResource.amount * antimatterResource.info.density * volumeMultiplier * explosionMultiplier;

            part.explosionPotential = (float)explosionPowerInTnt * 10;

            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;

            if (HighLogic.LoadedSceneIsEditor)
            {
                chargeStatus = maxCharge;

                Fields[nameof(maxGeeforce)].guiActiveEditor    = calculatedMass && canExplodeFromGeeForce;
                Fields[nameof(maxTemperature)].guiActiveEditor = calculatedMass && 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");

            _minimumAntimatterAmount = _antimatterDensityModifier * antimatterResource.maxAmount;

            Events[nameof(StartCharge)].active = antimatterResource.amount <= _minimumAntimatterAmount && !_shouldCharge;
            Events[nameof(StopCharge)].active  = antimatterResource.amount <= _minimumAntimatterAmount && _shouldCharge;

            if (maxCharge <= 60 && !_charging && antimatterResource.amount > _minimumAntimatterAmount)
            {
                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 > _minimumAntimatterAmount)
            {
                statusStr = _charging ? Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Statu1") : Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Statu2");//"Charging.""Discharging!"
            }
            else
            {
                statusStr = _shouldCharge ? 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;

            // 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;

            if (HighLogic.LoadedSceneIsEditor)
            {
                chargeStatus = maxCharge;

                Fields[nameof(maxGeeforce)].guiActiveEditor    = canExplodeFromGeeForce;
                Fields[nameof(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");

            _minimumAntimatterAmount = _antimatterDensityModifier * antimatterResource.maxAmount;

            Events[nameof(StartCharge)].active = antimatterResource.amount <= _minimumAntimatterAmount && !_shouldCharge;
            Events[nameof(StopCharge)].active  = antimatterResource.amount <= _minimumAntimatterAmount && _shouldCharge;

            if (maxCharge <= 60 && !_charging && antimatterResource.amount > _minimumAntimatterAmount)
            {
                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 > _minimumAntimatterAmount)
            {
                statusStr = _charging ? Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Statu1") : Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Statu2");//"Charging.""Discharging!"
            }
            else
            {
                statusStr = _shouldCharge ? Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Statu1") : Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Statu3");//"Charging.""No Power Required."
            }
        }