コード例 #1
0
        /// <summary>
        /// Easter Egg. If the ancestral mech is a FLEA, and the setting is enabled, then infest the ship...
        /// </summary>
        /// <param name="simGame"></param>
        private static void Infestation(SimGameState simGame)
        {
            // Open bays 0-11, the extra 2 drop spots, and command consoles to match (assumes BT:R)
            simGame.AddArgoUpgrade(simGame.DataManager.ShipUpgradeDefs.Get("argoUpgrade_structure1"));
            simGame.AddArgoUpgrade(simGame.DataManager.ShipUpgradeDefs.Get("argoUpgrade_mechBay2"));
            simGame.AddArgoUpgrade(simGame.DataManager.ShipUpgradeDefs.Get("argoUpgrade_JunkyardLeopard"));
            simGame.AddArgoUpgrade(simGame.DataManager.ShipUpgradeDefs.Get("argoUpgrade_DropSlot"));
            simGame.AddArgoUpgrade(simGame.DataManager.ShipUpgradeDefs.Get("argoUpgrade_DropSlot1"));
            simGame.AddArgoUpgrade(simGame.DataManager.ShipUpgradeDefs.Get("argoUpgrade_PilotSlot"));
            simGame.AddArgoUpgrade(simGame.DataManager.ShipUpgradeDefs.Get("argoUpgrade_PilotSlot1"));
            simGame.ApplyArgoUpgrades();
            List <MechDef> lance   = new List <MechDef>();
            var            fle4    = simGame.DataManager.MechDefs.Get("mechdef_flea_FLE-4");
            var            fle15   = simGame.DataManager.MechDefs.Get("mechdef_flea_FLE-15");
            var            fle4rv  = simGame.DataManager.MechDefs.Get("mechdef_flea_FLE-4-RV");
            var            fle15rv = simGame.DataManager.MechDefs.Get("mechdef_flea_FLE-15-RV");

            lance.Add(fle4);
            lance.Add(fle4);
            lance.Add(fle4);
            lance.Add(fle4);
            lance.Add(fle4rv);
            lance.Add(fle4rv);
            lance.Add(fle15);
            lance.Add(fle15);
            lance.Add(fle15);
            lance.Add(fle15);
            lance.Add(fle15rv);
            lance.Add(fle15rv);
            //ApplyLance(simGame, lance);
            // For some reason, bays 6-11 still aren't marked as available at this point
            // ... but manually forcing the mechs into those bays seems to work fine.
            for (int i = 0; i < lance.Count; ++i)
            {
                var mech = new MechDef(lance[i], simGame.GenerateSimGameUID());
                Logger.Log($"\tAdding {mech.ChassisID} to bay {i}");
                simGame.AddMech(i, mech, true, true, false);
            }
        }
コード例 #2
0
        public static void MyMethod(SimGameState simulation)
        {
            if (Cheats.cSettings.cheatStart)
            {
                Logger.Debug($"Welcome You Cheater!");

                if (Cheats.cSettings.cheatArgo)
                {
                    for (int i = 0; i < Cheats.cSettings.cheatArgoUpgrades.Count; i++)
                    {
                        simulation.AddArgoUpgrade(simulation.DataManager.ShipUpgradeDefs.Get(Cheats.cSettings.cheatArgoUpgrades[i]));
                        Logger.Debug($"Upgrade Added: {Cheats.cSettings.cheatArgoUpgrades[i]}");
                    }
                }

                if (Cheats.cSettings.cheatPilots)
                {
                    Logger.Debug($"Number of Pilots: {simulation.PilotRoster.Count}");
                    foreach (var pilot in simulation.PilotRoster)
                    {
                        Logger.Debug($"Pilot: {pilot.Name}");
                        pilot.AddExperience(0, "Cheat XP", Cheats.cSettings.iCheatXP);
                        Logger.Debug($"XP Added: {Cheats.cSettings.iCheatXP}");
                    }
                    simulation.Constants.Story.CommanderStartingExperience += Cheats.cSettings.iCheatXP;
                }

                if (Cheats.cSettings.cheatMoney)
                {
                    simulation.Constants.Story.StartingCBills += Cheats.cSettings.iCheatMoney;
                    Logger.Debug($"CBills Added: {Cheats.cSettings.iCheatMoney}");
                }

                if (Cheats.cSettings.cheatLance)
                {
                    //__instance.Constants.Progression.PilotingSkills.Add()
                    var tempLance = new List <MechDef>();
                    Logger.Debug($"Readying Mechs: {simulation.ReadyingMechs.Count}");
                    for (int k = 0; k < simulation.ReadyingMechs.Count; k++)
                    {
                        Logger.Debug($"Readying Mechs: {simulation.ReadyingMechs[k].Description.Id}");

                        tempLance.Add(simulation.ReadyingMechs[k]);
                    }

                    Logger.Debug($"Active Mechs: {simulation.ActiveMechs.Count}");
                    for (int j = 0; j < simulation.ActiveMechs.Count; j++)
                    {
                        Logger.Debug($"Active Mech: {simulation.ActiveMechs[j].Description.Id}");

                        tempLance.Add(simulation.ActiveMechs[j]);
                    }

                    Logger.Debug($"Store Mechs");
                    for (int l = 0; l < tempLance.Count; l++)
                    {
                        Logger.Debug($"Storing Mech: {tempLance[l]}");

                        simulation.UnreadyMech(l, tempLance[l]);
                    }

                    for (int i = 0; i < Cheats.cSettings.cheatAddMechs.Count; i++)
                    {
                        Logger.Debug($"Add Cheat Mechs");

                        var curMechDef = new MechDef(simulation.DataManager.MechDefs.Get(Cheats.cSettings.cheatAddMechs[i]), simulation.GenerateSimGameUID());

                        simulation.AddMech(i, curMechDef, true, true, false);
                        Logger.Debug($"Adding... {curMechDef.Description.Id}");
                    }
                }

                if (Cheats.cSettings.cheatRep)
                {
                    Random RNG = new Random();

                    if (Cheats.cSettings.cheatLocalRep)
                    {
                        foreach (KeyValuePair <Faction, FactionDef> pair in simulation.FactionsDict)
                        {
                            int randVal = RNG.Next(Cheats.cSettings.iMinRepVal, Cheats.cSettings.iMaxRepVal);
                            AccessTools.Method(typeof(SimGameState), "SetReputation").Invoke(simulation, new object[] { pair.Key, randVal, StatCollection.StatOperation.Set, null });
                        }
                    }

                    if (Cheats.cSettings.cheatAllRep)
                    {
                        foreach (KeyValuePair <Faction, FactionDef> pair in simulation.FactionsDict)
                        {
                            int iVal = Cheats.cSettings.iAllRepVal;
                            AccessTools.Method(typeof(SimGameState), "SetReputation").Invoke(simulation, new object[] { pair.Key, iVal, StatCollection.StatOperation.Int_Add, null });
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: Upgrade.cs プロジェクト: mad2342/FellOffACargoShip
        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);
                }
            }
        }