private static void Prefix(Team __instance, List <IStackSequence> __result)
        {
            Mod.Log.Debug?.Write($"T:DWAAA invoked");
            if (!__instance.IsLocalPlayer)
            {
                return;
            }

            if (__instance.Combat.TurnDirector.IsInterleavePending)
            {
                if (__result == null)
                {
                    Mod.Log.Debug?.Write("Result was null, adding a new list.");
                    __result = new List <IStackSequence>();
                }

                int numUnitsEndingActivation = 0;
                foreach (AbstractActor unit in __instance.units)
                {
                    Mod.Log.Debug?.Write($"Processing unit: {unit.DisplayName}_{unit.GetPilot().Name}");
                    if (!unit.IsCompletingActivation && !unit.IsDead && !unit.IsFlaggedForDeath)
                    {
                        Mod.Log.Info?.Write($"  Ending activation for unit {CombatantUtils.Label(unit)}");
                        IStackSequence item = unit.DoneWithActor();
                        numUnitsEndingActivation++;
                        __result.Add(item);
                    }
                }

                Traverse numUnitsEndingActivationT = Traverse.Create(__instance).Field("numUnitsEndingActivation");
                int      currentValue = numUnitsEndingActivationT.GetValue <int>();
                numUnitsEndingActivationT.SetValue(currentValue + numUnitsEndingActivation);
            }
        }
Exemplo n.º 2
0
        private static bool shouldIgnoreSequence(IStackSequence stackSequence)
        {
            bool isTeamActivation = stackSequence.GetType() == typeof(TeamActivationSequence);

            if (isTeamActivation)
            {
                TeamActivationSequence teamSequence = (TeamActivationSequence)stackSequence;
                return(teamSequence.team.IsLocalPlayer);
            }

            return(isTeamActivation);
        }
Exemplo n.º 3
0
        public static void Postfix(StackManager __instance)
        {
            Logger.Minimal(".");
            stackManager = __instance;

            List <IStackSequence> sequenceStack = Traverse.Create(__instance).Property("SequenceStack").
                                                  GetValue <List <IStackSequence> >();

            if (sequenceStack.Count > 0 && !shouldIgnoreSequence(sequenceStack[0]))
            {
                currentSequence = sequenceStack[0];

                if (isNewSequence())
                {
                    Logger.Minimal(String.Format("SequenceStack count: {0}, curr seq: {1}, Guid: {2}",
                                                 sequenceStack.Count, currentSequence.GetType(), currentSequence.SequenceGUID));
                    setNewSequenceAndStartTimer();
                    return;
                }

                if (isTimedOut())
                {
                    Logger.Minimal("timed out");
                    fixHangingSequence();
                    resetTimer();
                    return;
                }
            }

            if (sequenceStack.Count == 0)
            {
                if (previousSequence != null)
                {
                    Logger.Minimal("sequenceStack empty");
                    previousSequence = null;
                    startTimer();
                    return;
                }

                if (isTimedOut())
                {
                    Logger.Minimal("sequenceStack empty timeout");
                    fixHangingSequenceStack();
                    resetTimer();
                    return;
                }
            }
        }
Exemplo n.º 4
0
        // Create a falling sequence, publish a floatie with the error
        public static void AddFallingSequence(Mech mech, MultiSequence parentSequence, string floatieText)
        {
            Mod.Log.Info?.Write($"Adding falling sequence for mech: {mech.DistinctId()}");

            MechFallSequence mechFallSequence = new MechFallSequence(mech, floatieText, new Vector2(0f, -1f));

            string        fallDebuffText   = new Text(Mod.LocalizedText.Floaties[floatieText]).ToString();
            MultiSequence showInfoSequence = new ShowActorInfoSequence(mech, fallDebuffText, FloatieMessage.MessageNature.Debuff, false)
            {
                RootSequenceGUID = mechFallSequence.SequenceGUID
            };

            mechFallSequence.AddChildSequence(showInfoSequence, mechFallSequence.MessageIndex);
            mech.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(mechFallSequence));
            Mod.Log.Info?.Write(" -- published fall sequence.");

            IStackSequence doneWithActorSequence = mech.DoneWithActor();

            mech.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(doneWithActorSequence));
            Mod.Log.Info?.Write(" -- published doneWithActor sequence.");
        }
Exemplo n.º 5
0
 private static void setNewSequenceAndStartTimer()
 {
     previousSequence = currentSequence;
     timer.Reset();
     timer.Start();
 }