public static void Postfix(OrderSequence __instance, bool __state) { Mech mech = __instance.owningActor as Mech; if (__instance == null || __instance.owningActor == null || mech == null) { return; // Nothing to do } Mod.ActivationLog.Debug?.Write($"OS:OU - entered for Mech: {CombatantUtils.Label(mech)} with autoBrace: {mech.AutoBrace}"); // If state is true, orders were complete before we headed into the sequence, so skip if (__state) { return; } // If the seqeuence doesn't consume activation, it's not one we target. Ignore it. if (!__instance.ConsumesActivation) { Mod.ActivationLog.Debug?.Write($" -- !consumesActivation: {__instance.ConsumesActivation}, skipping"); return; } if (mech.IsShutDown) { Mod.ActivationLog.Debug?.Write(" -- Mech is shutdown, assuming a MechStartupSequence will handle this - skipping."); return; } bool isInterleaved = SharedState.Combat?.TurnDirector?.IsInterleaved == true; if (isInterleaved) { Mod.ActivationLog.Debug?.Write(" -- Combat is interleaved, should be handled by OnUpdate() or MechStartupSequence - skipping."); return; } DoneWithActorSequence dwaSeq = __instance as DoneWithActorSequence; if (dwaSeq != null) { Mod.ActivationLog.Debug?.Write($" -- sequence is DoneWithActorSequence: {dwaSeq != null}, skipping."); return; // Either a complete ending sequence, or the specific sequence doesn't consume activation so return } // Finally, check to see if the sequence isn't complete yet Traverse sequenceIsCompleteT = Traverse.Create(__instance).Property("sequenceIsComplete"); bool sequenceIsComplete = sequenceIsCompleteT.GetValue <bool>(); if (!sequenceIsComplete) { Mod.ActivationLog.Debug?.Write($" -- !sequenceIsComplete: {sequenceIsComplete}, skipping"); return; } // At this point, ___state should be false and sequenceIsComplete is true. This represents OnUpdate flipping the value during it's processing. Mod.ActivationLog.Info?.Write($" -- AT ACTIVATION END, checking for heat sequence creation. "); Mod.ActivationLog.Info?.Write($" -- isInterleavePending => {SharedState.Combat?.TurnDirector?.IsInterleavePending} " + $"highestEnemyContactLevel => {SharedState.Combat?.LocalPlayerTeam?.VisibilityCache.HighestEnemyContactLevel}"); // By default OrderSequence:OnUpdate doesn't apply a MechHeatSequence if you are in non-interleaved mode. Why? I don't know. Force it to add one here. MechHeatSequence heatSequence = mech.GenerateEndOfTurnHeat(__instance); if (heatSequence != null) { Mod.ActivationLog.Info?.Write($" -- Creating heat sequence for non-interleaved mode"); __instance.AddChildSequence(heatSequence, __instance.MessageIndex); } else { Mod.ActivationLog.Warn?.Write($"FAILED TO CREATE HEAT SEQUENCE FOR MECH: {mech.DistinctId()} - UNIT WILL CONTINUE TO GAIN HEAT!"); } }
// Token: 0x060000F2 RID: 242 RVA: 0x000142C4 File Offset: 0x000124C4 public static void Postfix(OrderSequence __instance, bool __state) { Mech mech = __instance.owningActor as Mech; if (__instance == null || __instance.owningActor == null || mech == null) { return; } if (__state) { return; } if (!__instance.ConsumesActivation) { Mod.Log.Debug($" -- !consumesActivation: {__instance.ConsumesActivation}, skipping"); return; } if (mech.IsShutDown) { Mod.Log.Debug(" -- Mech is shutdown, assuming a MechStartupSequence will handle this - skipping."); return; } bool isInterleaved = true; if (isInterleaved) { Mod.Log.Debug(" -- Combat is interleaved, should be handled by OnUpdate() or MechStartupSequence - skipping."); return; } DoneWithActorSequence dwaSeq = __instance as DoneWithActorSequence; if (dwaSeq != null) { Mod.Log.Debug($" -- sequence is DoneWithActorSequence: {dwaSeq != null}, skipping."); return; } Traverse sequenceIsCompleteT = Traverse.Create(__instance).Property("sequenceIsComplete"); bool sequenceIsComplete = sequenceIsCompleteT.GetValue <bool>(); if (!sequenceIsComplete) { Mod.Log.Debug($" -- !sequenceIsComplete: {sequenceIsComplete}, skipping"); return; } MechHeatSequence heatSequence = mech.GenerateEndOfTurnHeat(__instance); if (heatSequence != null) { Mod.Log.Debug($" -- Creating heat sequence for non-interleaved mode"); __instance.AddChildSequence(heatSequence, __instance.MessageIndex); } else { Mod.Log.Trace($"FAILED TO CREATE HEAT SEQUENCE FOR MECH: {mech} - UNIT WILL CONTINUE TO GAIN HEAT!"); } }