using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Cpp2IL.Core.Extensions;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UniverseLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("CitizenImporter")]
[assembly: AssemblyConfiguration("IL2CPP")]
[assembly: AssemblyDescription("An example mod that works on both IL2CPP and Mono game branches")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+eeed22640ccc7cb11f68a8b621d1df6dbac39896")]
[assembly: AssemblyProduct("CitizenImporter")]
[assembly: AssemblyTitle("CitizenImporter")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace CitizenImporter
{
[BepInPlugin("CitizenImporter", "CitizenImporter", "1.0.0")]
public class CitizenImporterPlugin : BasePlugin
{
private class HumanOverride
{
public int id;
public static int idCounter;
public static Dictionary<int, HumanOverride> createdHumans;
public int gameId = -1;
public string firstName;
public string lastName;
public string casualName;
public string dayOfBirth;
public string monthOfBirth;
public string age;
public string gender;
public string attractedTo;
public string ethnicity1;
public string ethnicity2;
public string height;
public string buildType;
public string hairColour;
public string hairColourExact = "";
public string hairType;
public string eyeColour;
public string glasses;
public string beard;
public string moustache;
public string partner;
public HumanOverride()
{
id = ++idCounter;
createdHumans[id] = this;
}
public static void ResetIdCounter()
{
idCounter = 1;
createdHumans = new Dictionary<int, HumanOverride>();
}
}
[HarmonyPatch(typeof(CitizenCreator), "Populate")]
public class CitizenCreator_Populate
{
public static void Prefix()
{
PluginLogger.LogInfo((object)"Reloading citizen overrides");
Creator_SetComplete.citizensLoadedFromFile = ReloadCitizensFromFile();
Creator_SetComplete.unusedPartnersCount = 0;
}
}
[HarmonyPatch(typeof(Creator), "SetComplete")]
public class Creator_SetComplete
{
public static bool citizensLoadedFromFile;
public static int unusedPartnersCount;
public static int directSpawnedCitCount;
public static int partnerSpawnedCitCount;
public static void Postfix(Creator __instance)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Expected O, but got Unknown
if (!citizensLoadedFromFile || !(ReflectionExtensions.GetActualType((object)__instance) == typeof(CitizenCreator)))
{
return;
}
ManualLogSource pluginLogger = PluginLogger;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(75, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Citizen overrides applied. ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(loadedHumanOverrides.Aggregate(0, (int total, KeyValuePair<Gender, List<HumanOverride>> tuple) => total + tuple.Value.Count) + unusedPartnersCount);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" overrides were not used (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(unusedPartnersCount);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" were unused partners)");
}
pluginLogger.LogWarning(val);
Enumerator<Citizen> enumerator = CityData.Instance.citizenDirectory.GetEnumerator();
while (enumerator.MoveNext())
{
Citizen current = enumerator.Current;
if ((Object)(object)((Human)current).partner != (Object)null)
{
partnerSpawnedCitCount++;
}
else if ((Object)(object)((Human)current).home != (Object)null)
{
directSpawnedCitCount++;
}
}
ManualLogSource pluginLogger2 = PluginLogger;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(23, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(partnerSpawnedCitCount);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" have partners, ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(directSpawnedCitCount);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" do not");
}
pluginLogger2.LogInfo(val2);
}
}
[HarmonyPatch(typeof(Human), "SetSexualityAndGender")]
public class Human_SetSexualityAndGender
{
public static void Postfix(ref Human __instance)
{
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_02af: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Expected O, but got Unknown
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
if ((!SessionData.Instance.isFloorEdit && !CityConstructor.Instance.generateNew) || loadedHumanOverrides.Count <= 0)
{
return;
}
int i;
for (i = 0; i < loadedHumanOverrides[__instance.gender].Count; i++)
{
HumanOverride humanOverride = loadedHumanOverrides[__instance.gender][i];
if (int.TryParse(humanOverride.partner, out var result) && HumanOverride.createdHumans[result].gameId != -1)
{
loadedHumanOverrides[__instance.gender].RemoveAt(i);
Creator_SetComplete.unusedPartnersCount++;
continue;
}
if (HumanOverride.createdHumans.ContainsKey(result) && Enum.TryParse<Gender>(HumanOverride.createdHumans[result].gender, ignoreCase: true, out Gender result2))
{
if (__instance.attractedTo.Contains(result2))
{
__instance.attractedTo.Clear();
__instance.attractedTo.Add(result2);
break;
}
continue;
}
if (Enum.TryParse<Gender>(humanOverride.attractedTo, ignoreCase: true, out Gender result3))
{
if (__instance.attractedTo.Contains(result3))
{
__instance.attractedTo.Clear();
__instance.attractedTo.Add(result3);
break;
}
continue;
}
break;
}
if (i < loadedHumanOverrides[__instance.gender].Count)
{
overridenHumans[__instance.humanID] = (__instance, MiscExtensions.RemoveAndReturn<HumanOverride>(loadedHumanOverrides[__instance.gender], i));
overridenHumans[__instance.humanID].Item2.gameId = __instance.humanID;
if (__instance.attractedTo.Count > 1)
{
__instance.attractedTo.Remove((Gender)2);
}
if (overridenHumans[__instance.humanID].Item2.partner != "")
{
SocialStatistics.Instance.seriousRelationshipsRatio = 1f;
}
else if (overridenHumans[__instance.humanID].Item2.attractedTo == "none")
{
SocialStatistics.Instance.seriousRelationshipsRatio = 0f;
}
ManualLogSource pluginLogger = PluginLogger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(36, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Setting override: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(overridenHumans[__instance.humanID].Item2.firstName);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(overridenHumans[__instance.humanID].Item2.lastName);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(overridenHumans[__instance.humanID].Item2.id);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") will replace ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(__instance.humanID);
}
pluginLogger.LogInfo(val);
}
}
}
[HarmonyPatch(typeof(Human), "GenerateSuitableGenderAndSexualityForParnter")]
public class Human_GenerateSuitableGenderAndSexualityForParnter
{
public static void Postfix(Human __instance, Citizen newPartner)
{
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Expected O, but got Unknown
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Expected O, but got Unknown
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Expected O, but got Unknown
SocialStatistics.Instance.seriousRelationshipsRatio = seriousRelationshipsRatioCache;
if (!SessionData.Instance.isFloorEdit && !CityConstructor.Instance.generateNew)
{
return;
}
if (!overridenHumans.ContainsKey(((Human)newPartner).humanID) || !int.TryParse(overridenHumans[((Human)newPartner).humanID].Item2.partner, out var partnerHumanId))
{
return;
}
int num = -1;
Gender key = __instance.gender;
Gender[] array = (Gender[])(object)new Gender[3]
{
default(Gender),
(Gender)1,
(Gender)2
};
foreach (Gender val in array)
{
num = loadedHumanOverrides[val].FindIndex((HumanOverride ho) => ho.id == partnerHumanId);
key = val;
if (num > -1)
{
break;
}
}
bool flag = default(bool);
if (num >= 0)
{
HumanOverride humanOverride = MiscExtensions.RemoveAndReturn<HumanOverride>(loadedHumanOverrides[key], num);
if (humanOverride.gender == "" || (Enum.TryParse<Gender>(humanOverride.gender, ignoreCase: true, out Gender result) && ((Human)newPartner).attractedTo.Contains(result)))
{
overridenHumans[__instance.humanID] = (__instance, humanOverride);
overridenHumans[__instance.humanID].Item2.gameId = __instance.humanID;
ManualLogSource pluginLogger = PluginLogger;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(50, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Setting override: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(overridenHumans[__instance.humanID].Item2.firstName);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(overridenHumans[__instance.humanID].Item2.lastName);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" will replace ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(__instance.humanID);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" as a partner of ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(((Human)newPartner).humanID);
}
pluginLogger.LogInfo(val2);
}
else
{
ManualLogSource pluginLogger2 = PluginLogger;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(29, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Invalid partner for ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(partnerHumanId);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (Gender)");
}
pluginLogger2.LogInfo(val2);
}
}
else
{
ManualLogSource pluginLogger3 = PluginLogger;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(20, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Invalid partner for ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(partnerHumanId);
}
pluginLogger3.LogInfo(val2);
}
}
}
[HarmonyPatch(typeof(Human), "CalculateAge")]
public class Human_CalculateAge
{
public static void Postfix(Human __instance)
{
if (!overridenHumans.ContainsKey(__instance.humanID))
{
return;
}
HumanOverride item = overridenHumans[__instance.humanID].Item2;
if (int.TryParse(item.dayOfBirth, out var result) && result > 0 && result <= 31 && int.TryParse(item.monthOfBirth, out var result2) && result2 > 0 && result2 <= 12 && int.TryParse(item.age, out var result3))
{
int num = SessionData.Instance.publicYear - result3 + 1;
if (result2 > SessionData.Instance.monthInt)
{
num--;
}
else if (result2 == SessionData.Instance.monthInt && result > SessionData.Instance.dayInt)
{
num--;
}
__instance.birthday = result2 + "/" + result + "/" + num;
}
}
}
[HarmonyPatch(typeof(Toolbox), "RandomRangeWeightedSeedContained")]
public class Toolbox_RandomRangeWeightedSeedContained
{
public static void Postfix(ref string inputSeed, ref float __result)
{
if (inputSeed.StartsWith("piecitizenoverride"))
{
string[] array = inputSeed.Split('_');
inputSeed = array[2];
__result = float.Parse(array[1]);
}
}
}
[HarmonyPatch(typeof(Descriptors), "GenerateEthnicity")]
public class Descriptors_GenerateEthnicity
{
private static Dictionary<EthnicGroup, EthnicityStats> ethStats;
public static void Prefix(Descriptors __instance)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Expected O, but got Unknown
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Expected O, but got Unknown
if (ethStats == null)
{
ethStats = new Dictionary<EthnicGroup, EthnicityStats>();
Enumerator<EthnicityStats> enumerator = SocialStatistics.Instance.ethnicityStats.GetEnumerator();
while (enumerator.MoveNext())
{
EthnicityStats current = enumerator.Current;
ethStats.Add(current.group, current);
}
}
if (!overridenHumans.ContainsKey(__instance.citizen.humanID))
{
return;
}
HumanOverride item = overridenHumans[__instance.citizen.humanID].Item2;
if (item.ethnicity1 != null && item.ethnicity1 != "")
{
if (item.ethnicity2 == null || item.ethnicity2 == "")
{
item.ethnicity2 = item.ethnicity1;
}
if (!Enum.TryParse<EthnicGroup>(item.ethnicity1, ignoreCase: true, out EthnicGroup result))
{
LogParseFailure(__instance.citizen, item, "ethnicity1");
return;
}
if (!Enum.TryParse<EthnicGroup>(item.ethnicity2, ignoreCase: true, out EthnicGroup result2))
{
LogParseFailure(__instance.citizen, item, "ethnicity2");
return;
}
__instance.ethnicities.Add(new EthnicitySetting
{
group = result,
ratio = 1f,
stats = ethStats[result]
});
__instance.ethnicities.Add(new EthnicitySetting
{
group = result2,
ratio = 1f,
stats = ethStats[result2]
});
}
}
}
[HarmonyPatch(typeof(Descriptors), "GenerateEyes")]
public class Descriptors_GenerateEyes
{
public static void Postfix(Descriptors __instance)
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
if (!overridenHumans.ContainsKey(__instance.citizen.humanID))
{
return;
}
HumanOverride item = overridenHumans[__instance.citizen.humanID].Item2;
if (item.eyeColour != null && item.eyeColour != "")
{
if (Enum.TryParse<EyeColour>(item.eyeColour, ignoreCase: true, out EyeColour result))
{
__instance.eyeColour = result;
}
else
{
LogParseFailure(__instance.citizen, item, "eyeColour");
}
}
}
}
[HarmonyPatch(typeof(Descriptors), "GenerateNameAndSkinColour")]
public class Descriptors_GenerateNameAndSkinColour
{
public static void Postfix(Descriptors __instance)
{
if (overridenHumans.ContainsKey(__instance.citizen.humanID))
{
HumanOverride item = overridenHumans[__instance.citizen.humanID].Item2;
__instance.citizen.firstName = ((item.firstName.Length > 0) ? item.firstName : __instance.citizen.firstName);
__instance.citizen.surName = ((item.lastName.Length > 0) ? item.lastName : __instance.citizen.surName);
__instance.citizen.casualName = ((item.casualName.Length > 0) ? item.casualName : __instance.citizen.firstName);
__instance.citizen.citizenName = __instance.citizen.firstName + " " + __instance.citizen.surName;
((Object)((Component)__instance.citizen).gameObject).name = __instance.citizen.citizenName;
((Object)__instance.citizen).name = __instance.citizen.citizenName;
}
}
}
[HarmonyPatch(typeof(Descriptors), "GenerateHair")]
public class Descriptors_GenerateHair
{
public static void Postfix(Descriptors __instance)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
if (!overridenHumans.ContainsKey(__instance.citizen.humanID))
{
return;
}
HumanOverride item = overridenHumans[__instance.citizen.humanID].Item2;
if (item.hairColour != "")
{
if (Enum.TryParse<HairColour>(item.hairColour, ignoreCase: true, out HairColour result))
{
__instance.hairColourCategory = result;
if (item.hairColourExact != "")
{
Color hairColour = default(Color);
if (ColorUtility.TryParseHtmlString(item.hairColourExact, ref hairColour))
{
__instance.hairColour = hairColour;
}
else
{
LogParseFailure(__instance.citizen, item, "exactHairColour");
}
}
else
{
Enumerator<HairSetting> enumerator = SocialStatistics.Instance.hairColourSettings.GetEnumerator();
while (enumerator.MoveNext())
{
HairSetting current = enumerator.Current;
if (current.colour == __instance.hairColourCategory)
{
string seed = __instance.citizen.seed;
__instance.hairColour = Color.Lerp(current.hairColourRange1, current.hairColourRange2, Toolbox.Instance.GetPsuedoRandomNumberContained(0f, 1f, ref seed));
__instance.citizen.seed = seed;
break;
}
}
}
}
else
{
LogParseFailure(__instance.citizen, item, "hairColour");
}
}
if (item.hairType != "")
{
if (Enum.TryParse<HairStyle>(item.hairType, ignoreCase: true, out HairStyle result2))
{
__instance.hairType = result2;
}
else
{
LogParseFailure(__instance.citizen, item, "hairType");
}
}
}
}
[HarmonyPatch(typeof(Descriptors), "GenerateBuild")]
public class Descriptors_GenerateBuild
{
public static void Postfix(Descriptors __instance)
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
if (!overridenHumans.ContainsKey(__instance.citizen.humanID))
{
return;
}
HumanOverride item = overridenHumans[__instance.citizen.humanID].Item2;
if (item.buildType != "")
{
if (Enum.TryParse<BuildType>(item.buildType, ignoreCase: true, out BuildType result))
{
__instance.build = result;
}
else
{
LogParseFailure(__instance.citizen, item, "buildType");
}
}
if (item.height != "" && float.TryParse(item.height, out var result2))
{
__instance.citizen.seed = $"piecitizenoverride_{result2}_{__instance.citizen.seed}";
}
}
}
[HarmonyPatch(typeof(Descriptors), "GenerateFacialFeatures")]
public class Descriptors_GenerateFacialFeatures
{
private enum OverrideFeature
{
None,
On,
Off
}
public static void Postfix(Descriptors __instance)
{
}
}
public static ManualLogSource PluginLogger;
private static Dictionary<Gender, List<HumanOverride>> loadedHumanOverrides = new Dictionary<Gender, List<HumanOverride>>
{
{
(Gender)0,
new List<HumanOverride>()
},
{
(Gender)1,
new List<HumanOverride>()
},
{
(Gender)2,
new List<HumanOverride>()
}
};
private static Dictionary<int, (Human, HumanOverride)> overridenHumans = new Dictionary<int, (Human, HumanOverride)>();
public static float seriousRelationshipsRatioCache;
public override void Load()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
PluginLogger = ((BasePlugin)this).Log;
ManualLogSource pluginLogger = PluginLogger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CitizenImporter");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
pluginLogger.LogInfo(val);
Harmony val2 = new Harmony("CitizenImporter");
val2.PatchAll();
ManualLogSource pluginLogger2 = PluginLogger;
val = new BepInExInfoLogInterpolatedStringHandler(19, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CitizenImporter");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is patched!");
}
pluginLogger2.LogInfo(val);
}
private static bool ReloadCitizensFromFile()
{
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
seriousRelationshipsRatioCache = SocialStatistics.Instance.seriousRelationshipsRatio;
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "citizens.csv");
if (!File.Exists(path))
{
PluginLogger.LogError((object)"Citizen file not found, no citizen overrides will be loaded. See https://docs.google.com/spreadsheets/d/11OvB572ezm2j-iO2rd89XHInrTNXey83eLdw2VJcujE/edit#gid=1379962932");
return false;
}
string[] array = File.ReadAllLines(path);
loadedHumanOverrides[(Gender)0].Clear();
loadedHumanOverrides[(Gender)1].Clear();
loadedHumanOverrides[(Gender)2].Clear();
HumanOverride.ResetIdCounter();
for (int i = 1; i < array.Length; i++)
{
string[] source = array[i].Split(",");
HumanOverride humanOverride = new HumanOverride
{
firstName = source.ElementAtOrDefault(0),
lastName = source.ElementAtOrDefault(1),
casualName = source.ElementAtOrDefault(2),
dayOfBirth = source.ElementAtOrDefault(3),
monthOfBirth = source.ElementAtOrDefault(4),
age = source.ElementAtOrDefault(5),
gender = source.ElementAtOrDefault(6),
attractedTo = source.ElementAtOrDefault(7),
ethnicity1 = source.ElementAtOrDefault(8),
ethnicity2 = source.ElementAtOrDefault(9),
height = source.ElementAtOrDefault(10),
buildType = source.ElementAtOrDefault(11),
hairColour = source.ElementAtOrDefault(12),
hairType = source.ElementAtOrDefault(13),
eyeColour = source.ElementAtOrDefault(14),
glasses = source.ElementAtOrDefault(15),
beard = source.ElementAtOrDefault(16),
moustache = source.ElementAtOrDefault(17),
partner = source.ElementAtOrDefault(18)
};
Gender result = (Gender)Random.Range(0, 2);
if (humanOverride.gender.Length != 0 && !Enum.TryParse<Gender>(humanOverride.gender, ignoreCase: true, out result))
{
LogParseFailure(null, humanOverride, "gender");
}
loadedHumanOverrides[result].Add(humanOverride);
}
if (loadedHumanOverrides.Aggregate(0, (int total, KeyValuePair<Gender, List<HumanOverride>> tuple) => total + tuple.Value.Count) == 0)
{
PluginLogger.LogError((object)"Citizen file found, but no citizen overrides loaded. No overrides will be applied.");
return false;
}
return true;
}
private static void LogParseFailure(Human? human, HumanOverride humanOverride, string field)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
ManualLogSource pluginLogger = PluginLogger;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(42, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Human ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int?>((human != null) ? new int?(human.humanID) : null);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (Override name: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(humanOverride.firstName);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(humanOverride.lastName);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") failed to parse ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(field);
}
pluginLogger.LogWarning(val);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "CitizenImporter";
public const string PLUGIN_NAME = "CitizenImporter";
public const string PLUGIN_VERSION = "1.0.0";
}
}