Пример #1
0
        public static bool Prefix(CombatHUDPhaseTrack __instance, CombatHUDIconTracker tracker, int phase, int ___currentPhase, List <CombatHUDPhaseIcons> ___PhaseIcons)
        {
            Mod.Log.Trace?.Write($"CHUDPT:STP - entered at phase: {phase}.");

            int[] bounds      = PhaseHelper.CalcPhaseIconBounds(___currentPhase);
            int   phaseAsInit = (Mod.MaxPhase + 1) - phase;

            Mod.Log.Trace?.Write($"Phase {phase} is init {phaseAsInit} within currentPhase: {___currentPhase} with bounds: {bounds[0]}-{bounds[4]}");

            if (phaseAsInit > bounds[1])
            {
                Mod.Log.Trace?.Write($"  -- Phase icon is higher than {bounds[1]}, setting to P phase.");
                ___PhaseIcons[0].AddIconTrackerToPhase(tracker);
            }
            else if (phaseAsInit < bounds[3])
            {
                Mod.Log.Trace?.Write($"  -- Phase icon is higher than {bounds[3]}, setting to F phase.");
                ___PhaseIcons[4].AddIconTrackerToPhase(tracker);
            }
            else
            {
                for (int i = 0; i < 5; i++)
                {
                    if (bounds[i] == phaseAsInit)
                    {
                        Mod.Log.Trace?.Write($"  -- Setting phase icon for phaseAsInit: {phaseAsInit} / bounds: {bounds[i]} at index {i}");
                        ___PhaseIcons[i].AddIconTrackerToPhase(tracker);
                    }
                }
            }

            return(false);
        }
Пример #2
0
        public static bool Prefix(CombatHUDPhaseTrack __instance, bool isPlayer, Hostility hostility, int ___currentPhase, CombatHUDPhaseBar[] ___phaseBars)
        {
            Mod.Log.Trace?.Write("CHUDPT::RPC - entered.");

            if (__instance == null || ___phaseBars == null)
            {
                return(true);
            }
            if (!ModState.Combat.TurnDirector.IsInterleaved)
            {
                return(true);
            }

            // Reconcile phase (from 1 - X) with display (X to 1)
            int initNum = (Mod.MaxPhase + 1) - ___currentPhase;

            int[] phaseBounds = PhaseHelper.CalcPhaseIconBounds(___currentPhase);
            Mod.Log.Trace?.Write($" For currentPhase: {___currentPhase}  phaseBounds are: [ {phaseBounds[0]} {phaseBounds[1]} {phaseBounds[2]} {phaseBounds[3]} {phaseBounds[4]} ]");

            for (int i = 0; i < 5; i++)
            {
                if (phaseBounds[i] > initNum)
                {
                    Mod.Log.Trace?.Write($" Setting phase: {phaseBounds[i]} as past phase.");
                    ___phaseBars[i].IndicatePastPhase();
                }
                else if (phaseBounds[i] == initNum)
                {
                    Mod.Log.Trace?.Write($" Setting phase: {phaseBounds[i]} as current phase.");
                    ___phaseBars[i].IndicateCurrentPhase(isPlayer, hostility);
                }
                else
                {
                    Mod.Log.Trace?.Write($" Setting phase: {phaseBounds[i]} as future phase.");
                    ___phaseBars[i].IndicateFuturePhase(isPlayer, hostility);
                }
                ___phaseBars[i].Text.SetText($"{phaseBounds[i]}");
            }

            if (phaseBounds[0] != Mod.MaxPhase)
            {
                ___phaseBars[0].Text.SetText("P");
            }
            if (phaseBounds[4] != Mod.MinPhase)
            {
                ___phaseBars[4].Text.SetText("F");
            }

            return(false);
        }
Пример #3
0
        public static void Postfix(LanceLoadoutSlot __instance, GameObject ___initiativeObj, TextMeshProUGUI ___initiativeText,
                                   UIColorRefTracker ___initiativeColor, HBSTooltip ___initiativeTooltip, LanceConfiguratorPanel ___LC)
        {
            Mod.Log.Trace?.Write("LLS:RID:post - entered.");

            if (___initiativeObj == null || ___initiativeText == null || ___initiativeColor == null || ___initiativeTooltip == null)
            {
                return;
            }

            bool bothSelected = __instance.SelectedMech != null && __instance.SelectedPilot != null;

            if (!bothSelected)
            {
                ___initiativeText.SetText("-");
                ___initiativeColor.SetUIColor(UIColor.MedGray);
            }
            else
            {
                // --- MECH ---
                MechDef       selectedMechDef = __instance.SelectedMech.MechDef;
                List <string> details         = new List <string>();

                // Static initiative from tonnage
                int initPhase    = PhaseHelper.TonnageToPhase((int)Math.Ceiling(__instance.SelectedMech.MechDef.Chassis.Tonnage));
                int initLabelVal = (Mod.MaxPhase + 1) - initPhase;
                details.Add(new Text(Mod.Config.LocalizedText[ModConfig.LT_TT_BASE], new object[] { initLabelVal }).ToString());

                // Any bonuses from equipment
                int    componentBonus = UnitHelper.GetNormalizedComponentModifier(__instance.SelectedMech.MechDef);
                string componentColor = "FFFFFF";
                if (componentBonus > 0)
                {
                    componentColor = "00FF00";
                }
                if (componentBonus < 0)
                {
                    componentColor = "FF0000";
                }
                details.Add(new Text(Mod.Config.LocalizedText[ModConfig.LT_TT_COMPONENT], new object[] { componentColor, componentBonus }).ToString());
                Mod.Log.Debug?.Write($"Component bonus is: {componentBonus}");

                // --- LANCE ---
                int lanceBonus = 0;
                if (___LC != null)
                {
                    lanceBonus = ___LC.lanceInitiativeModifier;
                }
                string lanceColor = "FFFFFF";
                if (lanceBonus > 0)
                {
                    lanceColor = "00FF00";
                }
                if (lanceBonus < 0)
                {
                    lanceColor = "FF0000";
                }
                details.Add(new Text(Mod.Config.LocalizedText[ModConfig.LT_TT_LANCE], new object[] { lanceColor, lanceBonus }).ToString());

                // --- PILOT ---
                // TODO: Get pilot modifiers from abilities - coordinate with BD
                Pilot selectedPilot = __instance.SelectedPilot.Pilot;
                int   pilotBonus    = 0;
                foreach (Ability ability in selectedPilot.PassiveAbilities)
                {
                    foreach (EffectData effectData in ability.Def.EffectData)
                    {
                        if (effectData.effectType == EffectType.StatisticEffect && effectData.statisticData != null && effectData.statisticData.statName == "BaseInitiative")
                        {
                            int mod = Int32.Parse(effectData.statisticData.modValue) * -1;
                            if (effectData.statisticData.operation == StatCollection.StatOperation.Int_Add)
                            {
                                pilotBonus += mod;
                            }
                            else if (effectData.statisticData.operation == StatCollection.StatOperation.Int_Subtract)
                            {
                                pilotBonus -= mod;
                            }
                        }
                    }
                }

                string pilotColor = "FFFFFF";
                if (pilotBonus > 0)
                {
                    pilotColor = "00FF00";
                }
                if (pilotBonus < 0)
                {
                    pilotColor = "FF0000";
                }
                details.Add(new Text(Mod.Config.LocalizedText[ModConfig.LT_TT_PILOT], new object[] { pilotColor, pilotBonus }).ToString());

                // --- Badge ---
                int summaryInitLabel = initLabelVal + componentBonus + pilotBonus + lanceBonus;
                if (summaryInitLabel > Mod.MaxPhase)
                {
                    summaryInitLabel = Mod.MaxPhase;
                }
                else if (summaryInitLabel < Mod.MinPhase)
                {
                    summaryInitLabel = Mod.MinPhase;
                }
                ___initiativeText.SetText($"{summaryInitLabel}");
                ___initiativeText.color = Color.black;
                ___initiativeColor.SetUIColor(UIColor.White);

                // --- Tooltip ---
                string             tooltipTitle   = $"{selectedMechDef.Name}: {selectedPilot.Name}";
                string             detailsS       = String.Join("\n", details.ToArray());
                string             tooltipText    = new Text(Mod.Config.LocalizedText[ModConfig.LT_LC_TT_SUMMARY], new object[] { detailsS, summaryInitLabel }).ToString();
                BaseDescriptionDef initiativeData = new BaseDescriptionDef("LLS_MECH_TT", tooltipTitle, tooltipText, null);
                ___initiativeTooltip.enabled = true;
                ___initiativeTooltip.SetDefaultStateData(TooltipUtilities.GetStateDataFromObject(initiativeData));
            }
        }
Пример #4
0
        public static void Postfix(MechBayMechInfoWidget __instance, MechDef ___selectedMech,
                                   GameObject ___initiativeObj, TextMeshProUGUI ___initiativeText, HBSTooltip ___initiativeTooltip)
        {
            Mod.Log.Trace?.Write("MBMIW:SI:post - entered.");

            if (___initiativeObj == null || ___initiativeText == null)
            {
                return;
            }

            if (___selectedMech == null)
            {
                ___initiativeObj.SetActive(true);
                ___initiativeText.SetText("-");
            }
            else
            {
                List <string> details = new List <string>();

                // Static initiative from tonnage

                int initPhase    = PhaseHelper.TonnageToPhase((int)Math.Ceiling(___selectedMech.Chassis.Tonnage));
                int initLabelVal = (Mod.MaxPhase + 1) - initPhase;
                details.Add(new Text(Mod.Config.LocalizedText[ModConfig.LT_TT_BASE], new object[] { initLabelVal }).ToString());

                // Any bonuses from equipment
                int    componentBonus = UnitHelper.GetNormalizedComponentModifier(___selectedMech);
                string componentColor = "FFFFFF";
                if (componentBonus > 0)
                {
                    componentColor = "00FF00";
                }
                if (componentBonus < 0)
                {
                    componentColor = "FF0000";
                }
                details.Add(new Text(Mod.Config.LocalizedText[ModConfig.LT_TT_COMPONENT], new object[] { componentColor, componentBonus }).ToString());
                Mod.Log.Debug?.Write($"Component bonus is: {componentBonus}");

                // No Lance bonus
                // No Pilot bonus

                // --- Badge ---
                int summaryInitLabel = initLabelVal + componentBonus;
                if (summaryInitLabel > Mod.MaxPhase)
                {
                    summaryInitLabel = Mod.MaxPhase;
                }
                else if (summaryInitLabel < Mod.MinPhase)
                {
                    summaryInitLabel = Mod.MinPhase;
                }

                ___initiativeObj.SetActive(true);
                ___initiativeText.SetText($"{summaryInitLabel}");

                // --- Tooltip ---
                string             tooltipTitle   = $"{___selectedMech.Name}";
                string             detailsS       = String.Join("\n", details.ToArray());
                string             tooltipText    = new Text(Mod.Config.LocalizedText[ModConfig.LT_MB_TT_SUMMARY], new object[] { detailsS, summaryInitLabel }).ToString();
                BaseDescriptionDef initiativeData = new BaseDescriptionDef("MB_MIW_MECH_TT", tooltipTitle, tooltipText, null);
                ___initiativeTooltip.enabled = true;
                ___initiativeTooltip.SetDefaultStateData(TooltipUtilities.GetStateDataFromObject(initiativeData));
            }
        }