Beispiel #1
0
            public static bool Prefix(MechLabStockInfoPopup __instance, ref string ___stockMechDefId, MechDef ___baseMechDef, UIManager ___uiManager)
            {
                try
                {
                    Logger.Debug("[MechLabStockInfoPopup_LoadStockMech_PREFIX] ___baseMechDef.Description.Id: " + ___baseMechDef.Description.Id);

                    if (!string.IsNullOrEmpty(___baseMechDef.Description.Model))
                    {
                        Logger.Debug("[MechLabStockInfoPopup_LoadStockMech_PREFIX] ___baseMechDef.Description.Model: " + ___baseMechDef.Description.Model);

                        ___stockMechDefId = ___baseMechDef.Description.Model.Replace("model", "mechdef");
                        Logger.Debug("[MechLabStockInfoPopup_LoadStockMech_PREFIX] ___stockMechDefId: " + ___stockMechDefId);



                        LoadRequest loadRequest = ___uiManager.dataManager.CreateLoadRequest(null, false);
                        // Created extension method MechLabStockInfoPopup.OverrideStockMechDefLoaded for callback
                        loadRequest.AddLoadRequest <MechDef>(BattleTechResourceType.MechDef, ___stockMechDefId, new Action <string, MechDef>(__instance.OverrideStockMechDefLoaded), false);
                        loadRequest.ProcessRequests(10u);

                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                    return(true);
                }
            }
Beispiel #2
0
        // This method duplicates functionality of MechLabStockInfoPopup.StockMechDefLoaded
        static void OverrideStockMechDefLoaded(this MechLabStockInfoPopup __instance, string id, MechDef def)
        {
            Logger.Debug("[MechLabStockInfoPopup.OverrideStockMechDefLoaded] called.");

            MechDef ___stockMechDef = Traverse.Create(__instance).Field("stockMechDef").GetValue <MechDef>();
            MechBayMechInfoWidget ___mechInfoWidget  = Traverse.Create(__instance).Field("mechInfoWidget").GetValue <MechBayMechInfoWidget>();
            DataManager           ___dataManager     = Traverse.Create(__instance).Field("dataManager").GetValue <DataManager>();
            LocalizableText       ___descriptionText = Traverse.Create(__instance).Field("descriptionText").GetValue <LocalizableText>();

            ___stockMechDef = def;
            ___mechInfoWidget.SetData(___stockMechDef, ___dataManager);
            ___descriptionText.SetText(___stockMechDef.Description.Details, Array.Empty <object>());
        }
Beispiel #3
0
 public static void Postfix(MechLabStockInfoPopup __instance, MechDef def, LocalizableText ___descriptionText)
 {
     if (def != null)
     {
         Main.modLog.LogMessage($"finding mechdef affinity descriptor for {def.Description.UIName}");
         string affinityDescriptors = PilotAffinityManager.Instance.getMechChassisAffinityDescription(def);
         //Main.modLog.LogMessage(affinityDescriptors);
         ___descriptionText.AppendTextAndRefresh(affinityDescriptors, (object[])Array.Empty <object>());
         //descriptor.SetValue(__instance, bioText);
         __instance.ForceRefreshImmediate();
     }
     else
     {
         Main.modLog.LogMessage("mechdef is null!");
     }
 }