Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
            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!");
                }
            }
Beispiel #4
0
            // 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!");
                }
            }