public static bool Prefix(MechShutdownSequence __instance) { try { var mech = __instance.OwningMech; var receiveShutdownInjury = __instance.Combat.Constants.Heat.ShutdownCausesInjury || mech.StatCollection.ReceiveShutdownInjury().Get(); if (receiveShutdownInjury && mech.IsOverheated) { var sourceID = __instance.instigatorGUID; var stackItemUID = __instance.RootSequenceGUID; ShutdownInjuryProtectionFeature.SetInjury(mech, sourceID, stackItemUID); } return(false); } catch (Exception e) { Control.Logger.Error.Log(e); } return(true); }
public static void Postfix(MechShutdownSequence __instance) { try { Mech mech = (Mech)AccessTools.Property(typeof(MechShutdownSequence), "OwningMech").GetValue(__instance, null); Pilot pilot = mech.pilot; Logger.Debug($"[MechShutdownSequence_CheckForHeatDamage_POSTFIX] ({mech.DisplayName}) Is shutting down"); if (!Actor.TryResistStressIncrease(mech, pilot, out int stressLevel)) { string floatieMessage = Miscellaneous.GetStressLevelString(stressLevel); mech.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(new ShowActorInfoSequence(mech, floatieMessage, FloatieMessage.MessageNature.PilotInjury, true))); } } catch (Exception e) { Logger.Error(e); } }
public static void Prefix(MechShutdownSequence __instance) { try { var traverse = Traverse.Create(__instance); var combat = traverse.Property("Combat").GetValue <CombatGameState>(); if (combat.Constants.Heat.ShutdownCausesInjury) { return; } var mech = traverse.Property("OwningMech").GetValue <Mech>(); overrideShutdownCausesInjury = !CockpitHandler.Shared.ProtectsAgainstShutdownInjury(mech.MechDef); } catch (Exception e) { Control.mod.Logger.LogError(e); } }
public static bool Prefix(MechShutdownSequence __instance) { try { Mech mech = (Mech)AccessTools.Property(typeof(MechShutdownSequence), "OwningMech").GetValue(__instance, null); Pilot pilot = mech.pilot; Logger.Debug($"[MechShutdownSequence_CheckForHeatDamage_PREFIX] ({mech.DisplayName}) Is shutting down"); bool pilotHealthOne = pilot.Health - pilot.Injuries <= 1; bool shutdownCausesInjury = LazySingletonBehavior <UnityGameInstance> .Instance.Game.Simulation.CombatConstants.Heat.ShutdownCausesInjury; bool isGoingToDie = pilotHealthOne && shutdownCausesInjury; Logger.Debug($"[MechShutdownSequence_CheckForHeatDamage_PREFIX] ({mech.DisplayName}) Is going to die: {isGoingToDie}"); if (isGoingToDie && Actor.RollForEjection(mech, SimpleEjectionSystem.Settings.PointlessEjectionChance)) { // Off he goes mech.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(new ShowActorInfoSequence(mech, "PANICKED!", FloatieMessage.MessageNature.PilotInjury, true))); mech.EjectPilot(mech.GUID, -1, DeathMethod.PilotEjection, false); return(false); } Logger.Debug($"[MechShutdownSequence_CheckForHeatDamage_PREFIX] ({mech.DisplayName}) Pilot is desperate: {pilot.IsDesperate()}"); if (pilot.IsDesperate() && Actor.RollForEjection(mech, pilot.GetLastEjectionChance())) { // Off he goes mech.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(new ShowActorInfoSequence(mech, "PANICKED!", FloatieMessage.MessageNature.PilotInjury, true))); mech.EjectPilot(mech.GUID, -1, DeathMethod.PilotEjection, false); return(false); } return(true); } catch (Exception e) { Logger.Error(e); return(true); } }
public static void Prefix(MechShutdownSequence __instance) { try { if (!ShutdownInjuryProtectionFeature.settings.ShutdownInjuryEnabled) { return; } var traverse = Traverse.Create(__instance); var combat = traverse.Property("Combat").GetValue <CombatGameState>(); if (combat.Constants.Heat.ShutdownCausesInjury) { return; } var mech = traverse.Property("OwningMech").GetValue <Mech>(); receiveShutdownInjury = mech.StatCollection.ReceiveShutdownInjury(); } catch (Exception e) { Control.mod.Logger.LogError(e); } }