static void Postfix(SGEventPanel __instance, SimGameEventOption option,
                            SimGameInterruptManager.EventPopupEntry ___thisEntry)
        {
            if (___thisEntry != null && ___thisEntry.parameters != null &&
                ___thisEntry.parameters[0] is SimGameEventDef eventDef)
            {
                if (ModConsts.Event_ContractExpired.Equals(eventDef.Description.Id))
                {
                    // Handle updating the contract length in the def; funds are handled by the event.
                    if (ModConsts.Event_Option_ContractExpired_Hire_NoBonus.Equals(option.Description.Id) ||
                        ModConsts.Event_Option_ContractExpired_Hire_Bonus.Equals(option.Description.Id))
                    {
                        (Pilot Pilot, CrewDetails Details)expired = ModState.ExpiredContracts.Peek();

                        Mod.Log.Debug?.Write($"Pilot {expired.Pilot.Name} was re-hired w/o a bonus");
                        expired.Details.ExpirationDay = ModState.SimGameState.DaysPassed + expired.Details.ContractTerm;
                        ModState.UpdateOrCreateCrewDetails(expired.Pilot.pilotDef, expired.Details);
                    }
                }
                else if (ModConsts.Event_HeadHunting.Equals(eventDef.Description.Id))
                {
                    // TODO: Anything?
                }
            }
        }
Esempio n. 2
0
        internal static void Postfix(SGEventPanel __instance, SimGameEventDef evt)
        {
            ForcedTimelineEvent e = ForcedEvents.ForcedTimelineEvents.Find((ev) => ev.EventID.Equals(evt.Description.Id));

            if (e != null)
            {
                Traverse.Create(__instance).Field("eventTime").GetValue <LocalizableText>().SetText($"{e.DateToFire:yyyy M d}", new object[] { });
            }
        }
Esempio n. 3
0
 public static void Postfix(SGEventPanel __instance)
 {
     try
     {
         int             daysPassed = UnityGameInstance.BattleTechGame.Simulation.DaysPassed;
         string          message    = GetTimelineDate(daysPassed);
         LocalizableText eventTime  = (LocalizableText)ReflectionHelper.GetPrivateField(__instance, "eventTime");
         eventTime.SetText(message);
     }
     catch (Exception e)
     {
         Logger.LogError(e);
     }
 }
Esempio n. 4
0
 public static void Postfix(SGEventPanel __instance)
 {
     try
     {
         int             daysPassed     = UnityGameInstance.BattleTechGame.Simulation.DaysPassed;
         string          message        = GetTimelineDate(daysPassed);
         TextMeshProUGUI timePassedText = (TextMeshProUGUI)ReflectionHelper.GetPrivateField(__instance, "eventTime");
         timePassedText.text = message;
     }
     catch (Exception e)
     {
         Logger.LogError(e);
     }
 }
 // Populate the target mechwarrior before the event
 static void Prefix(SGEventPanel __instance, SimGameEventDef evt)
 {
     Mod.Log.Debug?.Write("SGEP:SetEvent:PRE");
     if (ModConsts.Event_ContractExpired.Equals(evt.Description.Id) && ModState.ExpiredContracts.Count > 0)
     {
         (Pilot Pilot, CrewDetails Details)expired = ModState.ExpiredContracts.Peek();
         Mod.Log.Trace?.Write($"SGEventPanel details setting targetMechwarrior: {expired.Pilot.Name}");
         ModState.SimGameState.Context.SetObject(GameContextObjectTagEnum.TargetMechWarrior, expired.Pilot);
     }
     else if (ModConsts.Event_HeadHunting.Equals(evt.Description.Id) && ModState.HeadHuntedPilot != null)
     {
         Mod.Log.Trace?.Write($"SGEventPanel details setting targetMechwarrior: {ModState.HeadHuntedPilot.Name}");
         ModState.SimGameState.Context.SetObject(GameContextObjectTagEnum.TargetMechWarrior, ModState.HeadHuntedPilot);
     }
 }
 public static void ModifyOptions(SimGameEventDef evt, SGEventPanel __instance,
                                  TextMeshProUGUI ___eventDescription,
                                  DataManager ___dm, RectTransform ___optionParent, List <SGEventOption> ___optionsList)
 {
     try
     {
         Control.LogDebug("Started Event: " + evt.Description.Id);
         if (evt.Description.Id != "CustomSalvageAssemblyEvent")
         {
             return;
         }
         ChassisHandler.MakeOptions(___eventDescription, __instance, ___dm, ___optionParent, ___optionsList);
     }
     catch (Exception e)
     {
         Control.LogError("ModifyOptions error", e);
     }
 }
Esempio n. 7
0
    internal static void SetupRelationPanel()
    {
        try
        {
            LogDebug("SetupRelationPanel");
            var dm         = UIManager.Instance.dataManager;
            var prefabName = UIManager.Instance.GetPrefabName <SGEventPanel>("");
            var uiModule   = (UIModule)dm.PooledInstantiate(
                prefabName, BattleTechResourceType.UIModulePrefabs, null, null)
                             .GetComponent(typeof(SGEventPanel));
            uiModule.SetPrefabName("GaW RelationPanel");
            UIManager.Instance.AddModule(uiModule, UIManager.Instance.popupNode, -1, false);
            eventPanel = (SGEventPanel)uiModule;
            eventPanel.gameObject.SetActive(true);

            var go = eventPanel.gameObject.FindFirstChildNamed("Representation");
            go.FindFirstChildNamed("event_ResponseOptions").SetActive(false);
            go.FindFirstChildNamed("label_chevron").SetActive(false);
            go.FindFirstChildNamed("uixPrfPanl_spotIllustration_750-MANAGED").SetActive(false);
            go.FindFirstChildNamed("event_TopBar").SetActive(false);
            go.FindFirstChildNamed("T_brackets_cap").SetActive(false);
            go.FindFirstChildNamed("event_ResponseOptions").SetActive(false);
            go.FindFirstChildNamed("results_buttonContainer").SetActive(false);
            go.FindFirstChildNamed("choiceCrumb").SetActive(false);
            go.FindFirstChildNamed("resultTagsContent").SetActive(false);
            go.FindFirstChildNamed("B_brackets_results").SetActive(false);
            go.FindFirstChildNamed("label_Text").SetActive(false);

            var event_OverallLayoutVlg = go.FindFirstChildNamed("event_OverallLayout").GetComponent <VerticalLayoutGroup>();
            event_OverallLayoutVlg.childControlHeight     = true;
            event_OverallLayoutVlg.childForceExpandHeight = true;

            var event_OverallLayout = (RectTransform)go.FindFirstChildNamed("event_OverallLayout").transform;
            event_OverallLayout.sizeDelta = new Vector2(750, 580);

            var results_TextllLayout = (RectTransform)go.FindFirstChildNamed("results_TextllLayout").transform;
            results_TextllLayout.sizeDelta = new Vector2(750, 900);

            // jebus there is a space after "Viewport"
            var viewport = go.GetComponentsInChildren <RectTransform>().First(x => x.name == "Viewport ");
            viewport.sizeDelta = new Vector2(0, 500);

            foreach (var tmpText in eventPanel.gameObject.GetComponentsInChildren <TMP_Text>(true))
            {
                switch (tmpText.name)
                {
                case "title_week-day": tmpText.text = UnityGameInstance.BattleTechGame.Simulation.CurrentDate.ToLongDateString();
                    break;

                case "event_titleText": tmpText.text = "Relationship Summary";
                    tmpText.alignment = TextAlignmentOptions.Center;
                    break;

                case "descriptionText":
                    descriptionText   = tmpText;
                    tmpText.text      = BuildRelationString();
                    tmpText.alignment = TextAlignmentOptions.Center;
                    break;
                }
            }

            eventPanel.gameObject.SetActive(false);
            LogDebug("RelationPanel created");
        }
        catch (Exception ex)
        {
            LogDebug(ex);
        }
    }
Esempio n. 8
0
        public static void Postfix(SGEventPanel __instance)
        {
            var eventTime = Traverse.Create(__instance).Field("eventTime").GetValue <TextMeshProUGUI>();

            eventTime.text = CurrentDate.GetTimelineDateString(__instance.Sim);
        }
Esempio n. 9
0
        public static void MakeOptions(TextMeshProUGUI eventDescription, SGEventPanel sgEventPanel, DataManager dataManager, RectTransform optionParent, List <SGEventOption> optionsList)
        {
            void set_info(SGEventOption option, string text, UnityAction <SimGameEventOption> action)
            {
                Traverse.Create(option).Field <TextMeshProUGUI>("description").Value.SetText(text);
                option.OptionSelected.RemoveAllListeners();
                option.OptionSelected.AddListener(action);
            }

            void set_add_part(SGEventOption option, int num)
            {
                if (num < used_parts.Count)
                {
                    var info = used_parts[num];
                    if (info.used < info.count)
                    {
                        if (info.cbills > 0)
                        {
                            set_info(option, $"Add <color=#20ff20>{info.mechname}</color> for <color=#ffff00>{SimGameState.GetCBillString(info.cbills)}</color>, {info.count - info.used} {(info.count - info.used == 1 ? "part" : "parts") } parts left",
                                     arg =>
                            {
                                info.used += 1;
                                MakeOptions(eventDescription, sgEventPanel, dataManager, optionParent, optionsList);
                            });
                        }
                        else
                        {
                            set_info(option, $"Add <color=#20ff20>{info.mechname}</color> {info.count - info.used} {(info.count - info.used == 1 ? "part" : "parts") } left",
                                     arg =>
                            {
                                info.used += 1;
                                MakeOptions(eventDescription, sgEventPanel, dataManager, optionParent, optionsList);
                            });
                        }
                    }
                    else
                    {
                        set_info(option, $"<i><color=#a0a0a0>{info.mechname}</color>: <color=#ff4040>All parts used</color></i>", arg => { });
                    }
                }
                else
                {
                    set_info(option, "---", arg => { });
                }
            }

            int count = used_parts.Sum(i => i.used);

            eventDescription.SetText(GetCurrentDescription());


            if (count < mechBay.Sim.Constants.Story.DefaultMechPartMax)
            {
                if (used_parts.Count > 5)
                {
                    set_add_part(optionsList[0], 1 + page * 3);
                    set_add_part(optionsList[1], 2 + page * 3);
                    set_add_part(optionsList[2], 3 + page * 3);
                    set_info(optionsList[3], "Next Page >>", arg =>
                    {
                        page = (page + 1) % ((used_parts.Count - 1) / 3 + 1);
                        MakeOptions(eventDescription, sgEventPanel, dataManager, optionParent, optionsList);
                    });
                }
                else
                {
                    set_add_part(optionsList[0], 1);
                    set_add_part(optionsList[1], 2);
                    set_add_part(optionsList[2], 3);
                    set_add_part(optionsList[3], 4);
                }
            }
            else
            {
                int funds = mechBay.Sim.Funds;
                int total = used_parts.Sum(i => i.cbills * i.used);
                if (funds >= total)
                {
                    set_info(optionsList[0], "Confirm", arg => { CompeteMech(); sgEventPanel.Dismiss(); });
                }
                else
                {
                    set_info(optionsList[0], "<color=#ff2020><i>Not enough C-Bills</i></color>", arg => { sgEventPanel.Dismiss(); });
                }
                set_info(optionsList[1], "Cancel", arg => { sgEventPanel.Dismiss(); });
                set_info(optionsList[2], "---", arg => { });
                set_info(optionsList[3], "---", arg => { });
            }
        }