// crit engine reduces speed
        // destroyed engine destroys CT
        public static bool Prefix(MechComponent __instance, CombatGameState ___combat, WeaponHitInfo hitInfo, ComponentDamageLevel damageLevel, bool applyEffects)
        {
            try
            {
                if (__instance.mechComponentRef.Is <Flags>(out var f) && f.IsSet("ignore_damage"))
                {
                    MechCheckForCritPatch.Message = null;
                    return(false);
                }

                if (!CirticalHitStatesHandler.Shared.ProcessWeaponHit(__instance, ___combat, hitInfo, damageLevel, applyEffects, MechCheckForCritPatch.MessageAdditions))
                {
                    MechCheckForCritPatch.Message = null;
                    return(false);
                }

                if (!EngineCrits.ProcessWeaponHit(__instance, hitInfo, damageLevel, applyEffects, MechCheckForCritPatch.MessageAdditions))
                {
                    MechCheckForCritPatch.Message = null;
                    return(false);
                }
            }
            catch (Exception e)
            {
                Control.mod.Logger.LogError(e);
            }

            return(true);
        }
        // crit engine reduces speed
        // destroyed engine destroys CT
        public static bool Prefix(MechComponent __instance, WeaponHitInfo hitInfo, ComponentDamageLevel damageLevel, bool applyEffects)
        {
            try
            {
                if (!EngineCrits.ProcessWeaponHit(__instance, hitInfo, damageLevel, applyEffects, MechCheckForCritPatch.MessageAdditions))
                {
                    MechCheckForCritPatch.Message = null;
                    return(false);
                }

                if (!Armor.ProcessWeaponHit(__instance, hitInfo, damageLevel, applyEffects))
                {
                    MechCheckForCritPatch.Message = null;
                    return(false);
                }

                if (!Structure.ProcessWeaponHit(__instance, hitInfo, damageLevel, applyEffects))
                {
                    MechCheckForCritPatch.Message = null;
                    return(false);
                }
            }
            catch (Exception e)
            {
                Control.mod.Logger.LogError(e);
            }

            return(true);
        }
예제 #3
0
        public static bool Prefix(MechComponent __instance, CombatGameState ___combat, WeaponHitInfo hitInfo, ComponentDamageLevel damageLevel, bool applyEffects)
        {
            try
            {
                var messages = new List <MessageAddition>();
                void ClearMessageAndPublishAdditions()
                {
                    MechCheckForCritPatch.Message = null;
                    foreach (var message in messages)
                    {
                        var actor        = __instance.parent;
                        var stackMessage = new AddSequenceToStackMessage(new ShowActorInfoSequence(actor, message.Text, message.Nature, true));
                        actor.Combat.MessageCenter.PublishMessage(stackMessage);
                    }
                }

                if (__instance.mechComponentRef.Def.IsIgnoreDamage())
                {
                    ClearMessageAndPublishAdditions();
                    return(false);
                }

                if (!CirticalHitStatesHandler.Shared.ProcessWeaponHit(__instance, ___combat, hitInfo, damageLevel, applyEffects, messages))
                {
                    ClearMessageAndPublishAdditions();
                    return(false);
                }

                if (!EngineCrits.ProcessWeaponHit(__instance, ___combat, hitInfo, damageLevel, applyEffects, messages))
                {
                    ClearMessageAndPublishAdditions();
                    return(false);
                }
            }
            catch (Exception e)
            {
                Control.mod.Logger.LogError(e);
            }

            return(true);
        }