コード例 #1
0
        private void CalculateInstability(Mech attacker, AbstractActor target, int hexesMoved)
        {
            Mod.MeleeLog.Info?.Write($"Calculating CHARGE instability for attacker: {CombatantUtils.Label(attacker)} " +
                                     $"vs. target: {CombatantUtils.Label(target)} at hexesMoved: {hexesMoved}");

            float targetTonnage = 0;

            if (target is Vehicle vehicle)
            {
                targetTonnage = vehicle.tonnage;
            }
            else if (target is Mech mech)
            {
                targetTonnage = mech.tonnage;
            }
            Mod.MeleeLog.Info?.Write($" - Target tonnage is: {targetTonnage}");

            // Resolve attacker instability
            float attackerInstab = attacker.ChargeAttackerInstability(targetTonnage, hexesMoved);

            attackerInstab           = attacker.ApplyChargeInstabReduction(attackerInstab);
            this.AttackerInstability = attackerInstab;

            // Resolve target instability
            float targetInstab = attacker.ChargeTargetInstability(targetTonnage, hexesMoved);

            targetInstab           = target.ApplyChargeInstabReduction(targetInstab);
            this.TargetInstability = targetInstab;
        }