Beispiel #1
0
        public static bool Prefix(SGEngineeringScreen __instance, ShipModuleUpgrade upgrade)
        {
            if (!BiggerDrops.settings.showAdditionalArgoUpgrades)
            {
                return(true);
            }
            try
            {
                //Todo: upgrades at or below this are vanilla
                if (upgrade.ShipUpgradeCategoryValue.IsVanilla /*upgrade.ShipUpgradeCategoryValue.ID <= ShipUpgradeCategoryEnumeration.GetShipUpgradeCategoryByName("TRAINING").ID*/)
                {
                    return(true);
                }

                if (__instance.transform.FindRecursive("BDUpgradePanel") != null)
                {
                    GameObject primelayout             = __instance.transform.FindRecursive("BDUpgradePanel").gameObject;
                    Transform  BDMechDrops             = primelayout.transform.FindRecursive("BDMechDrops");
                    Transform  BDMechControl           = primelayout.transform.FindRecursive("BDMechControl");
                    Transform  BDDropTonnage           = primelayout.transform.FindRecursive("BDDropTonnage");
                    List <ShipModuleUpgrade> available = (List <ShipModuleUpgrade>)AccessTools.Field(typeof(SGEngineeringScreen), "AvailableUpgrades").GetValue(__instance);
                    List <ShipModuleUpgrade> purchased = (List <ShipModuleUpgrade>)AccessTools.Field(typeof(SGEngineeringScreen), "PurchasedUpgrades").GetValue(__instance);
                    SimGameState             simGame   = (SimGameState)AccessTools.Property(typeof(SGEngineeringScreen), "simState").GetValue(__instance);
                    UIManager uiManager = (UIManager)AccessTools.Field(typeof(SGEngineeringScreen), "uiManager").GetValue(__instance);
                    Transform parent;
                    if (upgrade.ShipUpgradeCategoryValue.Name == "BDDropTonnage")
                    {
                        parent = BDDropTonnage;
                    }
                    else if (upgrade.ShipUpgradeCategoryValue.Name == "BDMechControl")
                    {
                        parent = BDMechControl;
                    }
                    else if (upgrade.ShipUpgradeCategoryValue.Name == "BDMechDrops")
                    {
                        parent = BDMechDrops;
                    }
                    else
                    {
                        Debug.LogWarning((object)string.Format("Invalid location ({0}) for ship module {1}", (object)upgrade.Location, (object)upgrade.Description.Id));
                        return(false);
                    }
                    string id = "uixPrfIndc_SIM_argoUpgradePipUnavailable-element";
                    if (available.Contains(upgrade))
                    {
                        id = "uixPrfIndc_SIM_argoUpgradePipAvailable-element";
                    }
                    else if (purchased.Contains(upgrade))
                    {
                        id = "uixPrfIndc_SIM_argoUpgradePip-element";
                    }
                    SGEngineeringShipUpgradePip component = uiManager.dataManager.PooledInstantiate(id, BattleTechResourceType.UIModulePrefabs, new Vector3?(), new Quaternion?(), parent).GetComponent <SGEngineeringShipUpgradePip>();
                    component.transform.localScale = Vector3.one;
                    component.SetUpgadeModule(upgrade);
                    simGame.RequestItem <SVGAsset>(upgrade.Description.Icon, new Action <SVGAsset>(component.SetIcon), BattleTechResourceType.SVGAsset);
                    component.OnModuleSelected.RemoveAllListeners();
                    component.OnModuleSelected.AddListener(new UnityAction <ShipModuleUpgrade>(__instance.UpgradeSelected));
                }
            }
            catch (Exception e)
            {
                Logger.LogError(e);
            }
            return(false);
        }
Beispiel #2
0
        public static bool Prefix(SGEngineeringScreen __instance, ShipModuleUpgrade upgrade)
        {
            if (!BiggerDrops.settings.showAdditionalArgoUpgrades)
            {
                return(true);
            }
            try
            {
                //Todo: clean this up once ShipUpgradeCategory is made into a dynamic enum
                if (upgrade.Location != DropshipLocation.UNKNOWN)
                {
                    return(true);
                }

                if (__instance.transform.FindRecursive("BDUpgradePanel") != null)
                {
                    GameObject primelayout             = __instance.transform.FindRecursive("BDUpgradePanel").gameObject;
                    Transform  driverPipSlots          = primelayout.transform.FindRecursive("BDMechDrops");
                    Transform  structurePipSlots       = primelayout.transform.FindRecursive("BDMechControl");
                    Transform  powerPipSlots           = primelayout.transform.FindRecursive("BDDropTonnage");
                    List <ShipModuleUpgrade> available = (List <ShipModuleUpgrade>)AccessTools.Field(typeof(SGEngineeringScreen), "AvailableUpgrades").GetValue(__instance);
                    List <ShipModuleUpgrade> purchased = (List <ShipModuleUpgrade>)AccessTools.Field(typeof(SGEngineeringScreen), "PurchasedUpgrades").GetValue(__instance);
                    SimGameState             simGame   = (SimGameState)AccessTools.Property(typeof(SGEngineeringScreen), "simState").GetValue(__instance);
                    UIManager uiManager = (UIManager)AccessTools.Field(typeof(SGEngineeringScreen), "uiManager").GetValue(__instance);
                    Transform parent;
                    switch (upgrade.Category)
                    {
                    case ShipUpgradeCategory.POWER_SYSTEM:
                        parent = powerPipSlots;
                        break;

                    case ShipUpgradeCategory.STRUCTURE:
                        parent = structurePipSlots;
                        break;

                    case ShipUpgradeCategory.DRIVE_SYSTEM:
                        parent = driverPipSlots;
                        break;

                    default:
                        Debug.LogWarning((object)string.Format("Invalid location ({0}) for ship module {1}", (object)upgrade.Location, (object)upgrade.Description.Id));
                        return(false);
                    }
                    string id = "uixPrfIndc_SIM_argoUpgradePipUnavailable-element";
                    if (available.Contains(upgrade))
                    {
                        id = "uixPrfIndc_SIM_argoUpgradePipAvailable-element";
                    }
                    else if (purchased.Contains(upgrade))
                    {
                        id = "uixPrfIndc_SIM_argoUpgradePip-element";
                    }
                    SGEngineeringShipUpgradePip component = uiManager.dataManager.PooledInstantiate(id, BattleTechResourceType.UIModulePrefabs, new Vector3?(), new Quaternion?(), parent).GetComponent <SGEngineeringShipUpgradePip>();
                    component.transform.localScale = Vector3.one;
                    component.SetUpgadeModule(upgrade);
                    simGame.RequestItem <SVGAsset>(upgrade.Description.Icon, new Action <SVGAsset>(component.SetIcon), BattleTechResourceType.SVGAsset);
                    component.OnModuleSelected.RemoveAllListeners();
                    component.OnModuleSelected.AddListener(new UnityAction <ShipModuleUpgrade>(__instance.UpgradeSelected));
                }
            }
            catch (Exception e)
            {
                Logger.LogError(e);
            }
            return(false);
        }