예제 #1
0
 public static void Postfix(SimGameState __instance, bool refund)
 {
     if (refund)
     {
         ShipModuleUpgrade shipModuleUpgrade = __instance.DataManager.ShipUpgradeDefs.Get(__instance.CurrentUpgradeEntry.upgradeID);
         Traverse.Create(shipModuleUpgrade).Property("PurchaseCost").SetValue(originalCost);
     }
 }
예제 #2
0
 public static void Postfix(SGEngineeringScreen __instance)
 {
     try
     {
         if (__instance.transform.FindRecursive("BDUpgradePanel") != null)
         {
             GameObject        primelayout = __instance.transform.FindRecursive("BDUpgradePanel").gameObject;
             List <GameObject> engineeringShipUpgradePipList = new List <GameObject>();
             GameObject        driverPipSlots = primelayout.transform.FindRecursive("BDDropTonnage").gameObject;
             foreach (Transform transform in driverPipSlots.transform)
             {
                 if ((UnityEngine.Object)transform.gameObject.GetComponent <SGEngineeringShipUpgradePip>() != (UnityEngine.Object)null)
                 {
                     engineeringShipUpgradePipList.Add(transform.gameObject);
                 }
             }
             GameObject structurePipSlots = primelayout.transform.FindRecursive("BDMechControl").gameObject;
             foreach (Transform transform in structurePipSlots.transform)
             {
                 if ((UnityEngine.Object)transform.gameObject.GetComponent <SGEngineeringShipUpgradePip>() != (UnityEngine.Object)null)
                 {
                     engineeringShipUpgradePipList.Add(transform.gameObject);
                 }
             }
             GameObject powerPipSlots = primelayout.transform.FindRecursive("BDMechDrops").gameObject;
             foreach (Transform transform in powerPipSlots.transform)
             {
                 if ((UnityEngine.Object)transform.gameObject.GetComponent <SGEngineeringShipUpgradePip>() != (UnityEngine.Object)null)
                 {
                     engineeringShipUpgradePipList.Add(transform.gameObject);
                 }
             }
             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);
             engineeringShipUpgradePipList.ForEach((Action <GameObject>)(item =>
             {
                 string id = "uixPrfIndc_SIM_argoUpgradePipUnavailable-element";
                 ShipModuleUpgrade upgradeModule = item.GetComponent <SGEngineeringShipUpgradePip>().UpgradeModule;
                 if (available.Contains(upgradeModule))
                 {
                     id = "uixPrfIndc_SIM_argoUpgradePipAvailable-element";
                 }
                 else if (purchased.Contains(upgradeModule))
                 {
                     id = "uixPrfIndc_SIM_argoUpgradePip-element";
                 }
                 simGame.DataManager.PoolGameObject(id, item);
             }));
         }
     }
     catch (Exception e)
     {
         Logger.LogError(e);
     }
 }
예제 #3
0
        public static void Prefix(SGEngineeringScreen __instance)
        {
            var sim = UnityGameInstance.BattleTechGame.Simulation;
            ShipModuleUpgrade selectedUpgrade = (ShipModuleUpgrade)Traverse.Create(__instance).Property("SelectedUpgrade").GetValue();

            originalCost = selectedUpgrade.PurchaseCost;
            float multiplier = PilotQuirkManager.Instance.getArgoUpgradeCostModifier(sim.PilotRoster.ToList(),
                                                                                     selectedUpgrade.Description.Id, false);

            Traverse.Create(selectedUpgrade).Property("PurchaseCost").SetValue((int)(originalCost * multiplier));
        }
예제 #4
0
        public static void Prefix(SimGameState __instance, bool refund)
        {
            ShipModuleUpgrade shipModuleUpgrade = __instance.DataManager.ShipUpgradeDefs.Get(__instance.CurrentUpgradeEntry.upgradeID);

            float multiplier = PilotQuirkManager.Instance.getArgoUpgradeCostModifier(__instance.PilotRoster.ToList(),
                                                                                     shipModuleUpgrade.Description.Id, false);

            if (refund)
            {
                originalCost = shipModuleUpgrade.PurchaseCost;
                Traverse.Create(shipModuleUpgrade).Property("PurchaseCost").SetValue((int)(originalCost * multiplier));
            }
        }
예제 #5
0
        public static void Prefix(SGShipModuleUpgradeViewPopulator __instance, ShipModuleUpgrade upgrade)
        {
            var   sim        = UnityGameInstance.BattleTechGame.Simulation;
            float multiplier = PilotQuirkManager.Instance.getArgoUpgradeCostModifier(sim.PilotRoster.ToList(),
                                                                                     upgrade.Description.Id, false);
            float upkeepMultiplier = PilotQuirkManager.Instance.getArgoUpgradeCostModifier(sim.PilotRoster.ToList(),
                                                                                           upgrade.Description.Id, true);

            originalCost   = upgrade.PurchaseCost;
            originalUpkeep = upgrade.AdditionalCost;

            Traverse.Create(upgrade).Property("PurchaseCost").SetValue((int)(originalCost * multiplier));
            Traverse.Create(upgrade).Property("AdditionalCost").SetValue((int)(originalUpkeep * upkeepMultiplier));
        }
예제 #6
0
 public static bool Prefix(SGEngineeringScreen __instance, ShipModuleUpgrade upgrade)
 {
     return(true);
 }
예제 #7
0
 public static void UpgradeSelected(this SGEngineeringScreen screen, ShipModuleUpgrade upgrade)
 {
     AccessTools.Method(typeof(SGEngineeringScreen), "OnUpgradeSelected").Invoke(screen, new object[] { upgrade });
 }
예제 #8
0
파일: Patch.cs 프로젝트: CWolfs/BiggerDrops
        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);
        }
예제 #9
0
 public static void Postfix(ShipModuleUpgrade upgrade)
 {
     Traverse.Create(upgrade).Property("PurchaseCost").SetValue(originalCost);
     Traverse.Create(upgrade).Property("AdditionalCost").SetValue(originalUpkeep);
 }
예제 #10
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);
        }
예제 #11
0
        public static void Add(string param)
        {
            SimGameState simGameState = SceneSingletonBehavior <UnityGameInstance> .Instance.Game.Simulation;
            DataProvider dataProvider = new DataProvider();

            if (param == "help")
            {
                string help = "";
                help += "• This command will add modules to your dropship";
                help += Environment.NewLine;
                help += "• Params: 'All', 'all' or the id of some module";
                help += Environment.NewLine;
                help += "• Example: '/upgr argoUpgrade_power2'";
                help += Environment.NewLine;
                help += "• Example: '/upgr all'";
                PopupHelper.Info(help);

                return;
            }



            if (simGameState.CurDropship != DropshipType.Argo)
            {
                string message = $"You need a better dropship first.";
                Logger.Debug($"[Cheater_Upgrade_Add] {message}");
                PopupHelper.Info(message);

                return;
            }

            List <ShipModuleUpgrade> ___shipUpgrades          = (List <ShipModuleUpgrade>)AccessTools.Field(typeof(SimGameState), "shipUpgrades").GetValue(simGameState);
            List <string>            ___purchasedArgoUpgrades = (List <string>)AccessTools.Field(typeof(SimGameState), "purchasedArgoUpgrades").GetValue(simGameState);
            TagSet        ___companyTags    = (TagSet)AccessTools.Field(typeof(SimGameState), "companyTags").GetValue(simGameState);
            List <string> argoUpgradesToAdd = dataProvider.ArgoUpgradeIds;

            foreach (string id in ___purchasedArgoUpgrades)
            {
                argoUpgradesToAdd.Remove(id);
            }

            if (argoUpgradesToAdd.Count <= 0)
            {
                string message = $"No upgrades left to build.";
                Logger.Debug($"[Cheater_Upgrade_Add] {message}");
                PopupHelper.Info(message);

                return;
            }


            if (param == "All" || param == "all")
            {
                foreach (string id in argoUpgradesToAdd)
                {
                    ShipModuleUpgrade upgrade = simGameState.DataManager.ShipUpgradeDefs.Get(id);
                    //__instance.AddArgoUpgrade(upgrade);

                    // BEN: Custom AddArgoUpgrade (No timeline refresh, this will be applied later ONE TIME ONLY)
                    ___shipUpgrades.Add(upgrade);
                    ___purchasedArgoUpgrades.Add(upgrade.Description.Id);
                    if (simGameState.CurDropship == DropshipType.Argo)
                    {
                        if (upgrade.Tags != null && !upgrade.Tags.IsEmpty)
                        {
                            ___companyTags.AddRange(upgrade.Tags);
                        }
                        foreach (SimGameStat companyStat in upgrade.Stats)
                        {
                            simGameState.SetCompanyStat(companyStat);
                        }
                        // Apply Actions?

                        /*
                         * if (upgrade.Actions != null)
                         * {
                         *  SimGameResultAction[] actions = upgrade.Actions;
                         *  for (int i = 0; i < actions.Length; i++)
                         *  {
                         *      SimGameState.ApplyEventAction(actions[i], null);
                         *  }
                         * }
                         */
                    }
                    string message = $"Added upgrade {id} to the Argo.";
                    Logger.Debug($"[Cheater_Upgrade_Add] {message}");
                    PopupHelper.Info(message);
                }
                // Refresh timeline ONCE
                simGameState.RoomManager.RefreshTimeline(false);
            }
            else
            {
                if (argoUpgradesToAdd.Contains(param))
                {
                    ShipModuleUpgrade upgrade = simGameState.DataManager.ShipUpgradeDefs.Get(param);
                    simGameState.AddArgoUpgrade(upgrade);

                    string message = $"Added upgrade {param} to the Argo.";
                    Logger.Debug($"[Cheater_Upgrade_Add] {message}");
                    PopupHelper.Info(message);
                }
                else
                {
                    string message = $"Upgrade is unknown or already built: {param}";
                    Logger.Debug($"[Cheater_Upgrade_Add] {message}");
                    PopupHelper.Info(message);
                }
            }
        }
예제 #12
0
        public static void Postfix(SGEngineeringScreen __instance)
        {
            ShipModuleUpgrade selectedUpgrade = (ShipModuleUpgrade)Traverse.Create(__instance).Property("SelectedUpgrade").GetValue();

            Traverse.Create(selectedUpgrade).Property("PurchaseCost").SetValue(originalCost);
        }