public static bool Prefix(MechStartupInvocation __instance, CombatGameState combatGameState, ref bool __result)
 {
     if (Core.Settings.StoodUpPilotingRoll == false)
     {
         return(true);
     }
     try {
         __result = true;
         Mech actorByGuid = combatGameState.FindActorByGUID(__instance.MechGUID) as Mech;
         if (actorByGuid == null)
         {
             Log.LogWrite("MechStartupInvocation.Invoke failed! Unable to Mech!\n");
             return(true);
         }
         Log.LogWrite("Mech stoodup roll\n");
         float limit = actorByGuid.StoodUpRoll();
         float roll  = Random.Range(0f, 1f);
         Log.LogWrite(" roll = " + roll + " against " + limit + "\n");
         if (roll < limit)
         {
             Log.LogWrite(" success\n");
             return(true);
         }
         else
         {
             Log.LogWrite(" fail to stand up\n");
             combatGameState.MessageCenter.PublishMessage((MessageCenterMessage) new FloatieMessage(__instance.MechGUID, __instance.MechGUID, "__/CAE.StandUpFail/__", FloatieMessage.MessageNature.Buff));
             combatGameState.MessageCenter.PublishMessage((MessageCenterMessage) new AddSequenceToStackMessage(actorByGuid.DoneNoAnimation()));
         }
         return(false);
     } catch (Exception e) {
         Log.LogWrite(e.ToString() + "\n");
     }
     return(true);
 }
示例#2
0
        // Token: 0x0600866D RID: 34413 RVA: 0x0022E4D0 File Offset: 0x0022C6D0
        public override bool Invoke(CombatGameState combatGameState)
        {
            InvocationMessage.logger.Log("Invoking a MOVE!");
            AbstractActor abstractActor = combatGameState.FindActorByGUID(this.ActorGUID);

            if (abstractActor == null)
            {
                InvocationMessage.logger.LogError(string.Format("MechMovement.Invoke Actor with GUID {0} not found!", this.ActorGUID));
                return(false);
            }
            ICombatant combatant = null;

            if (!string.IsNullOrEmpty(this.MeleeTargetGUID))
            {
                combatant = combatGameState.FindCombatantByGUID(this.MeleeTargetGUID, false);
                if (combatant == null)
                {
                    InvocationMessage.logger.LogError(string.Format("MechMovement.Invoke ICombatant with GUID {0} not found!", this.MeleeTargetGUID));
                    return(false);
                }
            }
            if (!combatGameState.TurnDirector.IsInterleaved && this.MoveType != MoveType.Sprinting)
            {
                abstractActor.AutoBrace = true;
            }
            ActorMovementSequence stackSequence = new ActorMovementSequence(abstractActor, this.Waypoints, this.FinalOrientation, this.MoveType, combatant, this.AbilityConsumesFiring);

            base.PublishStackSequence(combatGameState.MessageCenter, stackSequence, this);
            return(true);
        }
 public static bool Prefix(MechStartupInvocation __instance, CombatGameState combatGameState, ref bool __result)
 {
     if (Core.Settings.StartupByHeatControl == false)
     {
         return(true);
     }
     try {
         __result = true;
         Mech actorByGuid = combatGameState.FindActorByGUID(__instance.MechGUID) as Mech;
         if (actorByGuid == null)
         {
             Log.LogWrite("MechStartupInvocation.Invoke failed! Unable to Mech!\n");
             return(true);
         }
         if (actorByGuid.CurrentHeatAsRatio >= Core.Settings.StartupMinHeatRatio)
         {
             combatGameState.MessageCenter.PublishMessage((MessageCenterMessage) new FloatieMessage(__instance.MechGUID, __instance.MechGUID, "__/CAE.ReactroTooHot/__", FloatieMessage.MessageNature.Buff));
             combatGameState.MessageCenter.PublishMessage((MessageCenterMessage) new AddSequenceToStackMessage(actorByGuid.DoneNoAnimation()));
         }
         else
         {
             return(true);
         }
         return(false);
     } catch (Exception e) {
         Log.LogWrite(e.ToString() + "\n");
     }
     return(true);
 }
示例#4
0
        // Token: 0x06000056 RID: 86
        private void Postfix(CombatGameState combatGameState)
        {
            AbstractActor abstractActor = combatGameState.FindActorByGUID(this.ActorGUID);

            if (abstractActor != null && !abstractActor.Combat.TurnDirector.IsInterleaved)
            {
                abstractActor.AutoBrace = true;
            }
        }
示例#5
0
        // The last actor that the player activated. Used to determine visibility in targetingHUD between activations

        public static AbstractActor GetLastPlayerActivatedActor(CombatGameState Combat)
        {
            if (LastPlayerActor == null)
            {
                List <AbstractActor> playerActors = HostilityHelper.PlayerActors(Combat);
                LastPlayerActor = playerActors[0].GUID;
            }
            return(Combat.FindActorByGUID(LastPlayerActor));
        }
示例#6
0
        private static void OnFloatie(MessageCenterMessage message)
        {
            FloatieMessage floatieMessage = (FloatieMessage)message;

            AbstractActor target = combat.FindActorByGUID(floatieMessage.affectedObjectGuid);

            if (target == null)
            {
                return;
            }

            if (floatieMessage.text == null)
            {
                return;
            }

            try {
                string senderColor;
                if (combat.HostilityMatrix.IsLocalPlayerEnemy(target.TeamId))
                {
                    senderColor = "#" + ColorUtility.ToHtmlStringRGBA(LazySingletonBehavior <UIManager> .Instance.UIColorRefs.redHalf);
                }
                else if (combat.HostilityMatrix.IsLocalPlayerNeutral(target.TeamId))
                {
                    senderColor = "#" + ColorUtility.ToHtmlStringRGBA(LazySingletonBehavior <UIManager> .Instance.UIColorRefs.blueHalf);
                }
                else
                {
                    senderColor = "#" + ColorUtility.ToHtmlStringRGBA(LazySingletonBehavior <UIManager> .Instance.UIColorRefs.greenHalf);
                }

                string sender          = (target.IsPilotable && target.GetPilot() != null) ? $"{target.DisplayName}-{target.GetPilot().Name}" : $"{target.DisplayName}";
                string senderWithColor = $"&lt;{senderColor}&gt;{sender}&lt;/color&gt;";
                Mod.Log.Debug($"ChatMessage senderWithColor: '{senderWithColor}'");

                string logMessage = floatieMessage.text.ToString();
                switch (floatieMessage.nature)
                {
                case FloatieMessage.MessageNature.ArmorDamage:
                    logMessage = $"{logMessage} armor damage";
                    break;

                case FloatieMessage.MessageNature.StructureDamage:
                    logMessage = $"{logMessage} structure damage";
                    break;

                default:
                    break;
                }

                messageCenter.PublishMessage(new ChatMessage(senderWithColor, logMessage, false));
            } catch (Exception e) {
                Mod.Log.Error($"Failed to send floatieMessage: {floatieMessage}");
                Mod.Log.Error(e);
            }
        }
            public static void Postfix(SensorLockInvocation __instance, CombatGameState combatGameState)
            {
                var abstractActor = combatGameState.FindActorByGUID(__instance.SourceGUID);

                var p    = abstractActor.GetPilot();
                var stat = p.StatCollection.GetStatistic("effectXP");

                p.StatCollection.Int_Add(stat, ModInit.modSettings.sensorLockXP);
                ModInit.modLog.LogMessage($"Adding {ModInit.modSettings.sensorLockXP} to {abstractActor.GetPilot().Description.Callsign}'s 'effectXP' pilot stat for Sensor Lock.");
            }
示例#8
0
        // Token: 0x060000F9 RID: 249 RVA: 0x00014B50 File Offset: 0x00012D50
        public override bool Postfix(CombatGameState combatGameState)
        {
            AbstractActor abstractActor = combatGameState.FindActorByGUID(this.ActorGUID);

            if (abstractActor != null)
            {
                if (!abstractActor.Combat.TurnDirector.IsInterleaved)
                {
                    abstractActor.AutoBrace = true;
                }
            }
        }
示例#9
0
        // Records actor selected events to allow id of the last player unit a player selected
        public static void OnActorSelectedMessage(MessageCenterMessage message)
        {
            ActorSelectedMessage actorSelectedMessage = message as ActorSelectedMessage;
            AbstractActor        actor = Combat.FindActorByGUID(actorSelectedMessage.affectedObjectGuid);

            if (actor.team.IsLocalPlayer)
            {
                Mod.Log.Info?.Write($"Updating last activated actor to: ({CombatantUtils.Label(actor)})");
                ModState.LastPlayerActorActivated = actor;

                EWState actorState = new EWState(actor);
                if (actorState.HasNightVision() && ModState.GetMapConfig().isDark)
                {
                    Mod.Log.Info?.Write($"Enabling night vision mode.");
                    VfxHelper.EnableNightVisionEffect(actor);
                }
                else
                {
                    if (ModState.IsNightVisionMode)
                    {
                        VfxHelper.DisableNightVisionEffect();
                    }
                }

                // Refresh the unit's vision
                VfxHelper.RedrawFogOfWar(actor);
                actor.VisibilityCache.RebuildCache(actor.Combat.GetAllImporantCombatants());
                CombatHUDHelper.ForceNameRefresh(actor.Combat);

                // Hack - turn on Vision indicator?
                VisRangeIndicator visRangeIndicator = VisRangeIndicator.Instance;
                visRangeIndicator.SetState(VisRangeIndicator.VisRangeIndicatorState.On);

                // Refresh any CombatHUDMarkDisplays
                foreach (CombatHUDMarkDisplay chudMD in ModState.MarkContainerRefs.Keys)
                {
                    chudMD.RefreshInfo();
                }
            }
        }
            public static void Postfix(ActiveProbeInvocation __instance, CombatGameState combatGameState)
            {
                var abstractActor = combatGameState.FindActorByGUID(__instance.SourceGUID);

                int modStat;

                if (!ModInit.modSettings.activeProbeXP_PerTarget)
                {
                    modStat = ModInit.modSettings.activeProbeXP;
                    ModInit.modLog.LogMessage($"Adding {modStat} to {abstractActor.GetPilot().Description.Callsign}'s 'effectXP' pilot stat for Probing the Enemy, Actively.");
                }
                else
                {
                    modStat = ModInit.modSettings.activeProbeXP * __instance.TargetGUIDs.Count;
                    ModInit.modLog.LogMessage($"Adding {modStat} to {abstractActor.GetPilot().Description.Callsign}'s 'effectXP' pilot stat for Probing {__instance.TargetGUIDs.Count} Enemies, Actively.");
                }
                var p    = abstractActor.GetPilot();
                var stat = p.StatCollection.GetStatistic("effectXP");

                p.StatCollection.Int_Add(stat, modStat);
            }
示例#11
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);
        }
示例#12
0
        public static void OnActorTargeted(MessageCenterMessage message)
        {
            Mod.Log.Trace?.Write("CHUD:STM:OAT - entered.");

            ActorTargetedMessage actorTargetedMessage = message as ActorTargetedMessage;

            if (message == null || actorTargetedMessage == null || actorTargetedMessage.affectedObjectGuid == null)
            {
                return;                                                                                                     // Nothing to do, bail
            }
            ICombatant combatant = Combat.FindActorByGUID(actorTargetedMessage.affectedObjectGuid);

            if (combatant == null)
            {
                combatant = Combat.FindCombatantByGUID(actorTargetedMessage.affectedObjectGuid);
            }

            try {
                if (Combat.LocalPlayerTeam.VisibilityToTarget(combatant) >= VisibilityLevel.Blip0Minimum)
                {
                    Mod.Log.Trace?.Write("CombatHUD:SubscribeToMessages:OnActorTargeted - Visibility >= Blip0, showing target.");
                    if (ShowTargetMethod != null)
                    {
                        ShowTargetMethod.GetValue(combatant);
                    }
                    else
                    {
                        Mod.Log.Info?.Write("WARNING: CHUD:STM caled with a null traverse!");
                    }
                }
                else
                {
                    Mod.Log.Trace?.Write("CombatHUD:SubscribeToMessages:OnActorTargeted - Visibility < Blip0, hiding target.");
                }
            } catch (Exception e) {
                Mod.Log.Error?.Write($"Failed to display HUD target: {CombatantUtils.Label(combatant)}!");
                Mod.Log.Error?.Write(e);
            }
        }
        public void ShowFor(CombatGameState combat, InvocationMessage message)
        {
            switch (message)
            {
            case AbstractActorMovementInvocation move:
            {
                var unit          = combat.FindActorByGUID(move.ActorGUID);
                var finalPosition = unit.CurrentPosition;
                var rotation      = Quaternion.LookRotation(move.FinalOrientation, Vector3.up);

                if (move.Waypoints != null && move.Waypoints.Count > 0)
                {
                    finalPosition = move.Waypoints.Last().Position;
                }

                var linePoints = GetPointsForWaypoints(move.Waypoints);
                VisualizeMovement(unit, finalPosition, rotation, linePoints);
                break;
            }

            case AttackInvocation attack:
            {
                var unit = combat.FindActorByGUID(attack.SourceGUID);

                foreach (var subAttack in attack.subAttackInvocations)
                {
                    var target     = combat.FindActorByGUID(subAttack.targetGUID);
                    var isIndirect = !unit.HasLOFToTargetUnit(target, float.MaxValue, false);

                    VisualizeAttack(unit.CurrentPosition + _attackLineOffset, target, false, isIndirect);
                }
                break;
            }

            case MechDFAInvocation dfa:
            {
                var unit       = combat.FindActorByGUID(dfa.SourceGUID);
                var target     = combat.FindActorByGUID(dfa.TargetGUID);
                var linePoints = GetPointsForJump(unit.CurrentPosition, dfa.JumpLocation);

                VisualizeMovement(unit, dfa.JumpLocation, dfa.JumpRotation, linePoints);
                VisualizeAttack(dfa.JumpLocation, target, true, false);
                break;
            }

            case MechJumpInvocation jump:
            {
                var unit          = combat.FindActorByGUID(jump.MechGUID);
                var finalPosition = jump.FinalDestination;
                var linePoints    = GetPointsForJump(unit.CurrentPosition, finalPosition);

                VisualizeMovement(unit, finalPosition, jump.FinalRotation, linePoints);
                break;
            }

            case MechMeleeInvocation melee:
            {
                var unit     = combat.FindActorByGUID(melee.MechGUID);
                var target   = combat.FindActorByGUID(melee.TargetGUID);
                var rotation = Quaternion.FromToRotation(melee.desiredMeleePosition, target.CurrentPosition);

                VisualizeMovement(unit, melee.desiredMeleePosition, rotation, new [] { unit.CurrentPosition, melee.desiredMeleePosition });
                VisualizeAttack(melee.desiredMeleePosition, target, true, false);
                break;
            }

            // TODO: finish visualization for Reserve/SensorLock/Stand/Startup/"MoraleDefend"
            default:
            {
                AIPause.PausePopup.AppendText(message.GetType().Name);
                break;
            }
            }

            ParentObject.SetActive(true);
        }
示例#14
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);
        }
示例#15
0
        private static void OnFloatie(MessageCenterMessage message)
        {
            FloatieMessage floatieMessage = (FloatieMessage)message;

            AbstractActor target = combat.FindActorByGUID(floatieMessage.affectedObjectGuid);

            if (target == null)
            {
                return;
            }

            if (floatieMessage.text == null)
            {
                return;
            }

            try {
                string senderColor;
                if (combat.HostilityMatrix.IsLocalPlayerEnemy(target.TeamId))
                {
                    senderColor = "#" + ColorUtility.ToHtmlStringRGBA(LazySingletonBehavior <UIManager> .Instance.UIColorRefs.redHalf);
                }
                else if (combat.HostilityMatrix.IsLocalPlayerNeutral(target.TeamId))
                {
                    senderColor = "#" + ColorUtility.ToHtmlStringRGBA(LazySingletonBehavior <UIManager> .Instance.UIColorRefs.blueHalf);
                }
                else
                {
                    senderColor = "#" + ColorUtility.ToHtmlStringRGBA(LazySingletonBehavior <UIManager> .Instance.UIColorRefs.greenHalf);
                }

                string sender          = (target.IsPilotable && target.GetPilot() != null) ? $"{target.GetPilot().Name}" : $"{target.DisplayName}";
                string senderWithColor = $"&lt;{senderColor}&gt;{sender}&lt;/color&gt;";
                Mod.Log.Debug($"ChatMessage senderWithColor: '{senderWithColor}'");

                string logMessage = floatieMessage.text.ToString();
                switch (floatieMessage.nature)
                {
                case FloatieMessage.MessageNature.ArmorDamage:
                    logMessage = $"{logMessage} armor damage";
                    break;

                case FloatieMessage.MessageNature.StructureDamage:
                    logMessage = $"{logMessage} structure damage";
                    break;

                default:
                    break;
                }


                ChatMessage chatMessage = new ChatMessage(senderWithColor, logMessage, false);
                Mod.Log.Debug($"Chat message is: '{chatMessage.Message}'");
                try
                {
                    int i = clog_count++;
                    ChatListViewItem view = _views.GetOrCreateView(i);
                    view.gameObject.transform.SetAsLastSibling();
                    view.ItemIndex = i;
                    ChatListViewItem_SetData(view, chatMessage, (LocalizableText)lt_field_info.GetValue(view));

                    if (i > max_messages)
                    {
                        int p = i - max_messages;
                        _views.Pool(p);
                    }
                    if (!CanvasUpdateRegistry.IsRebuildingLayout())
                    {
                        _activeChatList.gameObject.GetComponentsInChildren <RectTransform>(false, layoutcomponents);
                        foreach (RectTransform componentsInChild in layoutcomponents)
                        {
                            LayoutRebuilder.MarkLayoutForRebuild(componentsInChild);
                        }
                        layoutcomponents.Clear();
                    }
                    _activeChatList.ScrollToBottom();
                }
                catch (Exception e)
                {
                    Mod.Log.Error($"Failed to send a message:{e.Message}");
                    Mod.Log.Error($"{e.StackTrace}");
                }
            }
            catch (Exception e) {
                Mod.Log.Error($"Failed to send floatieMessage: {floatieMessage}");
                Mod.Log.Error(e);
            }
        }