コード例 #1
0
        public static void Postfix(AttackDirector __instance, MessageCenterMessage message)
        {
            Mod.Log.Debug("AD:OASE - entered.");

            AttackSequenceEndMessage attackSequenceEndMessage = (AttackSequenceEndMessage)message;
            int sequenceId = attackSequenceEndMessage.sequenceId;

            AttackDirector.AttackSequence attackSequence = __instance.GetAttackSequence(sequenceId);

            if (ModState.BreachAttackId != attackSequence.id)
            {
                Mod.Log.Error("INCOHERENT ATTACK SEQUENCE- SKIPPING!");
                return;
            }

            if (attackSequence.chosenTarget is Mech targetMech)
            {
                Mod.Log.Debug($"Checking hull breaches for targetMech: {CombatantUtils.Label(targetMech)}");
                ResolveMechHullBreaches(targetMech);
            }
            if (attackSequence.chosenTarget is Turret targetTurret)
            {
                Mod.Log.Debug($"Checking hull breaches for targetTurret: {CombatantUtils.Label(targetTurret)}");
                ResolveTurretHullBreaches(targetTurret);
            }
            if (attackSequence.chosenTarget is Vehicle targetVehicle)
            {
                Mod.Log.Debug($"Checking hull breaches for targetVehicle: {CombatantUtils.Label(targetVehicle)}");
                ResolveVehicleHullBreaches(targetVehicle);
            }

            // Reset state
            ModState.BreachAttackId = 0;
            ModState.BreachHitsMech.Clear();
            ModState.BreachHitsTurret.Clear();
            ModState.BreachHitsVehicle.Clear();

            Mod.Log.Debug("AD:OASE - exiting.");
        }
コード例 #2
0
        public static void Postfix(AttackDirector __instance, MessageCenterMessage message)
        {
            Mod.Log.Debug?.Write("AD:OASE - entered.");

            // Nothing to do
            if (ModState.BreachAttackId == ModState.NO_ATTACK_SEQUENCE_ID)
            {
                return;
            }

            AttackSequenceEndMessage attackSequenceEndMessage = message as AttackSequenceEndMessage;

            if (__instance == null || attackSequenceEndMessage == null)
            {
                return;
            }

            int sequenceId = attackSequenceEndMessage.sequenceId;

            AttackDirector.AttackSequence attackSequence = __instance.GetAttackSequence(sequenceId);

            if (attackSequence == null)
            {
                Mod.Log.Info?.Write($"Could not find attack sequence with id: {sequenceId}. CAC may have killed it, or there's an error in processing. Skipping hull breach checks.");
                return;
            }

            // No chosen target, nothing to damage
            if (attackSequence.chosenTarget == null)
            {
                return;
            }

            if (ModState.BreachAttackId != attackSequence.id)
            {
                Mod.Log.Debug?.Write($"Attack sequence ID {attackSequence.id} does not match Hull Breach Attack Id - skipping hull breach resolution.");
                return;
            }

            float structureDamage = attackSequence.GetStructureDamageDealt(attackSequence.chosenTarget.GUID);

            Mod.Log.Debug?.Write($"Attack sequence {sequenceId} did {structureDamage} structure damage to target: {attackSequence.chosenTarget.GUID}");
            if (structureDamage == 0f)
            {
                Mod.Log.Debug?.Write($"Attack did no structure damage, skipping.");
                return;
            }

            if (attackSequence.chosenTarget is Mech targetMech)
            {
                Mod.Log.Debug?.Write($"Checking hull breaches for targetMech: {CombatantUtils.Label(targetMech)}");
                ResolveMechHullBreaches(targetMech);
            }
            if (attackSequence.chosenTarget is Turret targetTurret)
            {
                Mod.Log.Debug?.Write($"Checking hull breaches for targetTurret: {CombatantUtils.Label(targetTurret)}");
                ResolveTurretHullBreaches(targetTurret);
            }
            if (attackSequence.chosenTarget is Vehicle targetVehicle)
            {
                Mod.Log.Debug?.Write($"Checking hull breaches for targetVehicle: {CombatantUtils.Label(targetVehicle)}");
                ResolveVehicleHullBreaches(targetVehicle);
            }

            // Reset state
            ModState.BreachAttackId = ModState.NO_ATTACK_SEQUENCE_ID;
            ModState.BreachHitsMech.Clear();
            ModState.BreachHitsTurret.Clear();
            ModState.BreachHitsVehicle.Clear();

            Mod.Log.Debug?.Write("AD:OASE - exiting.");
        }