コード例 #1
0
    private static void RefreshBarColor(MechLabLocationWidget widget, bool isRearArmor)
    {
        var isLocked  = ArmorLocationLocker.IsLocked(widget.loadout.Location, isRearArmor);
        var lanceStat = isRearArmor ? widget.rearArmorBar : widget.armorBar;

        lanceStat.fillColor.SetUIColor(isLocked ? UIColor.Gold : UIColor.White);
        lanceStat.nameTextColor.SetUIColor(isLocked ? UIColor.Gold : UIColor.White);
    }
コード例 #2
0
    internal static void OnArmorAddOrSubtract(MechLabLocationWidget widget, bool isRearArmor, float direction)
    {
        var stepPrecision = ArmorMaximizerFeature.Shared.Settings.StepPrecision.Get() ?? ArmorStructureRatioFeature.ArmorPerStep;
        var stepSize      = ArmorMaximizerFeature.Shared.Settings.StepSize.Get() ?? ArmorStructureRatioFeature.ArmorPerStep;

        var stepDirection = direction < 0 ? -1 : 1;
        var current       = isRearArmor ? widget.currentRearArmor : widget.currentArmor;

        var updated = stepDirection > 0
            ? PrecisionUtils.RoundUp(current + stepSize, stepPrecision)
            : PrecisionUtils.RoundDown(current - stepSize, stepPrecision);

        Control.Logger.Trace?.Log($"HandleArmorUpdate stepDirection={stepDirection} current={current} precision={stepPrecision} isRearArmor={isRearArmor}");
        if (stepDirection > 0)
        {
            var max = isRearArmor ? widget.maxRearArmor : widget.maxArmor;
            updated = Mathf.Min(updated, max);

            var maxTotal     = ArmorStructureRatioFeature.GetMaximumArmorPoints(widget.chassisLocationDef);
            var maxOther     = maxTotal - updated;
            var currentOther = isRearArmor ? widget.currentArmor : widget.currentRearArmor;
            var updatedOther = Mathf.Min(currentOther, maxOther);

            var otherNotChanged = PrecisionUtils.Equals(currentOther, updatedOther);
            if (otherNotChanged || !ArmorLocationLocker.IsLocked(widget.loadout.Location, !isRearArmor))
            {
                widget.SetArmor(isRearArmor, updated);
                widget.SetArmor(!isRearArmor, updatedOther);
            }

            Control.Logger.Trace?.Log($"HandleArmorUpdate updated={updated} maxTotal={maxTotal} maxOther={maxOther} currentOther={currentOther} updatedOther={updatedOther} isRearArmor={updatedOther}");
        }
        else
        {
            updated = Mathf.Max(updated, 0);
            widget.SetArmor(isRearArmor, updated);
            Control.Logger.Trace?.Log($"HandleArmorUpdate updated={updated}");
        }
    }
コード例 #3
0
 internal static void OnBarClick(MechLabLocationWidget widget, bool isRearArmor)
 {
     ArmorLocationLocker.ToggleLock(widget.loadout.Location, isRearArmor);
     RefreshBarColor(widget, isRearArmor);
 }