Пример #1
0
 public static string GetFactionShortName(Faction faction, DataManager manager)
 {
     try {
         return(FactionDef.GetFactionDefByEnum(manager, faction).ShortName.Replace("the ", "").Replace("The ", ""));
     }
     catch (Exception ex) {
         Logger.LogError(ex);
         return(null);
     }
 }
Пример #2
0
        static void Prefix(SimGameState __instance)
        {
            Mod.Log.Trace?.Write("SGS:ARSM entered.");
            SimGameConstantOverride sgco = __instance.ConstantOverrides;

            if (sgco.ConstantOverrides.ContainsKey("CareerMode"))
            {
                // Patch starting mechs
                if (sgco.ConstantOverrides["CareerMode"].ContainsKey(ModStats.HBS_RandomMechs))
                {
                    string startingMechsS = sgco.ConstantOverrides["CareerMode"][ModStats.HBS_RandomMechs];
                    Mod.Log.Info?.Write($"Replacing starting random mechs with:{startingMechsS}");
                    string[] startingMechs = startingMechsS.Split(',');
                    __instance.Constants.CareerMode.StartingRandomMechLists = startingMechs;
                }
                else
                {
                    Mod.Log.Debug?.Write($"key: {ModStats.HBS_RandomMechs} not found");
                }

                // Patch faction reputation
                if (sgco.ConstantOverrides["CareerMode"].ContainsKey(ModStats.HBS_FactionRep))
                {
                    string   factionRepS = sgco.ConstantOverrides["CareerMode"][ModStats.HBS_FactionRep];
                    string[] factions    = factionRepS.Split(',');
                    foreach (string factionToken in factions)
                    {
                        string[] factionSplit = factionToken.Split(':');
                        string   factionId    = factionSplit[0];
                        int      factionRep   = int.Parse(factionSplit[1]);
                        Mod.Log.Info?.Write($"Applying rep: {factionRep} to faction: ({factionId})");
                        FactionDef factionDef = FactionDef.GetFactionDefByEnum(__instance.DataManager, factionId);
                        __instance.AddReputation(factionDef.FactionValue, factionRep, false);
                    }
                }
                else
                {
                    Mod.Log.Debug?.Write($"key: {ModStats.HBS_RandomMechs} not found");
                }
            }
            else if (!sgco.ConstantOverrides.ContainsKey("CareerMode"))
            {
                Mod.Log.Debug?.Write("key:CareerMode not found");
            }
        }
Пример #3
0
        private bool DoesFactionMatchSearch(string factionID, string search)
        {
            Main.HBSLog.Log(factionID);
            try
            {
                var def = FactionDef.GetFactionDefByEnum(UnityGameInstance.BattleTechGame.DataManager, factionID);

                var name      = def.Name.ToLower();
                var shortName = def.ShortName.ToLower();

                // TODO: "the" thing is a hack, tbh
                return(name.StartsWith(search) || shortName.StartsWith(search) || name.StartsWith("the " + search) ||
                       shortName.StartsWith("the " + search));
            }
            catch
            {
                return(false);
            }
        }