private static void PublishMessage(this MechComponent component, Text message, FloatieMessage.MessageNature nature) { var actor = component.parent; if (actor == null) { return; } var stackMessage = new AddSequenceToStackMessage(new ShowActorInfoSequence(actor, message, nature, true)); actor.Combat?.MessageCenter?.PublishMessage(stackMessage); }
public static void Postfix(Mech __instance) { if (Message != null) { __instance.Combat.MessageCenter.PublishMessage(Message); Message = null; } foreach (var addition in MessageAdditions) { var message = new AddSequenceToStackMessage(new ShowActorInfoSequence(__instance, addition.Text, addition.Nature, true)); __instance.Combat.MessageCenter.PublishMessage(message); } MessageAdditions.Clear(); }
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); }
public static bool Prefix(MechStartupInvocation __instance, CombatGameState combatGameState) { Mech mech = combatGameState.FindActorByGUID(__instance.MechGUID) as Mech; if (mech == null) { return(true); } // Check to see if we should restart automatically float heatCheck = mech.HeatCheckMod(Mod.Config.Piloting.SkillMulti); int futureHeat = mech.CurrentHeat - mech.AdjustedHeatsinkCapacity; bool passedStartupCheck = CheckHelper.DidCheckPassThreshold(Mod.Config.Heat.Shutdown, futureHeat, mech, heatCheck, ModConfig.FT_Check_Startup); if (passedStartupCheck) { return(true); } // Do the normal startup process Mod.Log.Debug($"Mech: {CombatantUtils.Label(mech)} failed a startup roll, venting heat but remaining offline."); QuipHelper.PublishQuip(mech, Mod.Config.Qips.Startup); DoneWithActorSequence doneWithActorSequence = (DoneWithActorSequence)mech.GetDoneWithActorOrders(); MechHeatSequence mechHeatSequence = new MechHeatSequence(mech, true, true, "STARTUP"); doneWithActorSequence.AddChildSequence(mechHeatSequence, mechHeatSequence.MessageIndex); InvocationStackSequenceCreated message = new InvocationStackSequenceCreated(doneWithActorSequence, __instance); combatGameState.MessageCenter.PublishMessage(message); AddSequenceToStackMessage.Publish(combatGameState.MessageCenter, doneWithActorSequence); //mech.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(mechHeatSequence)); //mech.OnStartupComplete(mechHeatSequence.SequenceGUID); //mech.DoneWithActor(); return(false); }
public static bool Prefix(MechStartupInvocation __instance, CombatGameState combatGameState) { Mech mech = combatGameState.FindActorByGUID(__instance.MechGUID) as Mech; if (mech == null) { return(true); } Mod.Log.Info?.Write($"Processing startup for Mech: {CombatantUtils.Label(mech)}"); // Check to see if we should restart automatically float heatCheck = mech.HeatCheckMod(Mod.Config.SkillChecks.ModPerPointOfGuts); int futureHeat = mech.CurrentHeat - mech.AdjustedHeatsinkCapacity; bool passedStartupCheck = CheckHelper.DidCheckPassThreshold(Mod.Config.Heat.Shutdown, futureHeat, mech, heatCheck, ModText.FT_Check_Startup); Mod.Log.Info?.Write($" -- futureHeat: {futureHeat} = current: {mech.CurrentHeat} - HSCapacity: {mech.AdjustedHeatsinkCapacity} vs. heatCheck: {heatCheck} => passedStartup: {passedStartupCheck}"); bool failedInjuryCheck = CheckHelper.ResolvePilotInjuryCheck(mech, futureHeat, -1, -1, heatCheck); if (failedInjuryCheck) { Mod.Log.Info?.Write(" -- unit did not pass injury check!"); } bool failedSystemFailureCheck = CheckHelper.ResolveSystemFailureCheck(mech, futureHeat, -1, heatCheck); if (failedSystemFailureCheck) { Mod.Log.Info?.Write(" -- unit did not pass system failure check!"); } bool failedAmmoCheck = CheckHelper.ResolveRegularAmmoCheck(mech, futureHeat, -1, heatCheck); if (failedAmmoCheck) { Mod.Log.Info?.Write(" -- unit did not pass ammo explosion check!"); } bool failedVolatileAmmoCheck = CheckHelper.ResolveVolatileAmmoCheck(mech, futureHeat, -1, heatCheck); if (failedVolatileAmmoCheck) { Mod.Log.Info?.Write(" -- unit did not pass volatile ammo explosion check!"); } if (passedStartupCheck) { Mod.Log.Debug?.Write($" -- passed startup roll, going through regular MechStartupSequence."); return(true); } Mod.Log.Info?.Write($" -- failed startup roll, venting heat but remaining offline."); DoneWithActorSequence doneWithActorSequence = (DoneWithActorSequence)mech.GetDoneWithActorOrders(); MechHeatSequence mechHeatSequence = new MechHeatSequence(OwningMech: mech, performHeatSinkStep: true, applyStartupHeatSinks: false, instigatorID: "STARTUP"); doneWithActorSequence.AddChildSequence(mechHeatSequence, mechHeatSequence.MessageIndex); QuipHelper.PublishQuip(mech, Mod.LocalizedText.Quips.Startup); InvocationStackSequenceCreated message = new InvocationStackSequenceCreated(doneWithActorSequence, __instance); combatGameState.MessageCenter.PublishMessage(message); AddSequenceToStackMessage.Publish(combatGameState.MessageCenter, doneWithActorSequence); Mod.Log.Debug?.Write($" -- sent sequence to messageCenter"); return(false); }