Decompiled source of LethalUtilities v1.2.21
LethalUtilities.dll
Decompiled 11 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalUtilities.Configuration; using Newtonsoft.Json; using TMPro; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("LethalUtilities")] [assembly: AssemblyDescription("A Lethal Company mod made by Kyxino.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Kyxino")] [assembly: AssemblyProduct("LethalUtilities")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("d1273c8d-cadb-4ba8-9306-763e5ed6813c")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] public enum ClockType { Display12Hour, Display24Hour, DisplayMilitary } public enum RunConfig { Enabled, UseLoadSettings, ConfigDisabled } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace LethalEditor { internal class ConfigUtils { public static string MakeNameFileSafe(string FileName) { return (FileName == "") ? $"MISSING_NAME_{Random.Range(0, 1000)}" : Regex.Replace(FileName, "[\\/:*?\"<>|]", ""); } } internal class AnimationCurve_TypeConverter : TypeConverter { public AnimationCurve_TypeConverter() { ((TypeConverter)this).ConvertToObject = delegate(string input, Type type) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) if (type != typeof(AnimationCurve)) { return (object)new AnimationCurve(); } string text = Regex.Replace(input, "[\\s%()%[\\]]+", ""); string[] array2 = text.Split(new char[1] { ',' }); if (string.IsNullOrEmpty(array2[0])) { return (object)new AnimationCurve(); } Keyframe[] array3 = (Keyframe[])(object)new Keyframe[array2.Length]; Keyframe val2 = default(Keyframe); for (int j = 0; j < array3.Length; j++) { string[] array4 = array2[j].Split(new char[1] { ';' }); string[] array5 = ((array4 != null && array4.Length >= 1) ? ((array4 != null) ? array4[0]?.Split(new char[1] { ':' }) : null) : null); string[] array6 = ((array4 != null && array4.Length >= 2) ? ((array4 != null) ? array4[1]?.Split(new char[1] { '|' }) : null) : null); string[] array7 = ((array4 != null && array4.Length >= 3) ? ((array4 != null) ? array4[2]?.Split(new char[1] { ':' }) : null) : null); string[] array8 = ((array7 != null && array7.Length >= 2) ? ((array7 != null) ? array7[1] : null) : ((array7 != null) ? array7[0] : null))?.Split(new char[1] { '|' }); float result = (float.TryParse(((array5 != null) ? array5[0] : null) ?? "0", out result) ? result : 0f); float result2 = (float.TryParse((array5 != null && array5.Length >= 2) ? ((array5 != null) ? array5[1] : null) : "0", out result2) ? result2 : 0f); float result3 = (float.TryParse(((array6 != null) ? array6[0] : null) ?? "0", out result3) ? result3 : 0f); float result4 = (float.TryParse((array6 != null && array6.Length >= 2) ? ((array6 != null) ? array6[1] : null) : (((array6 != null) ? array6[0] : null) ?? "0"), out result4) ? result4 : 0f); float result5 = (float.TryParse(((array8 != null) ? array8[0] : null) ?? "0", out result5) ? result5 : 0f); float result6 = (float.TryParse((array8 != null && array8.Length >= 2) ? ((array8 != null) ? array8[1] : null) : (((array8 != null) ? array8[0] : null) ?? "0"), out result6) ? result6 : 0f); int result7 = (int.TryParse(((array7 != null) ? array7[0] : null) ?? "0", out result7) ? result7 : 0); ((Keyframe)(ref val2))..ctor(result, result2, result3, result4, result5, result6); ((Keyframe)(ref val2)).weightedMode = (WeightedMode)result7; array3[j] = val2; } return (object)new AnimationCurve(array3); }; ((TypeConverter)this).ConvertToString = delegate(object input, Type type) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected I4, but got Unknown if (type != typeof(AnimationCurve)) { return ""; } Keyframe[] keys = ((AnimationCurve)input).keys; if (keys.Length == 0) { return ""; } if (keys.Length == 1) { return ((Keyframe)(ref keys[0])).value.ToString(); } StringBuilder stringBuilder = new StringBuilder(); Keyframe[] array = keys; for (int i = 0; i < array.Length; i++) { Keyframe val = array[i]; float time = ((Keyframe)(ref val)).time; float value = ((Keyframe)(ref val)).value; float inTangent = ((Keyframe)(ref val)).inTangent; float outTangent = ((Keyframe)(ref val)).outTangent; float inWeight = ((Keyframe)(ref val)).inWeight; float outWeight = ((Keyframe)(ref val)).outWeight; int num = (int)((Keyframe)(ref val)).weightedMode; stringBuilder.Append($"{time}:{value}"); if (inTangent != 0f || outTangent != 0f) { if (inTangent == outTangent) { stringBuilder.Append($";({inTangent})"); } else { stringBuilder.Append($";({inTangent}|{outTangent})"); } if (inWeight != 0f || outWeight != 0f) { if (num != 0) { stringBuilder.Append($";{num}:"); } else { stringBuilder.Append(";"); } if (inWeight == outWeight) { stringBuilder.Append($"[{inWeight}]"); } else { stringBuilder.Append($"[{inWeight}|{outWeight}]"); } } else if (num != 0) { stringBuilder.Append($";{num}"); } } stringBuilder.Append(", "); } return stringBuilder.ToString(0, Math.Max(0, stringBuilder.Length - 2)); }; } } internal class StringArray_TypeConverter : TypeConverter { public StringArray_TypeConverter() { ((TypeConverter)this).ConvertToObject = (string input, Type type) => (type != typeof(string[])) ? new string[0] : JsonConvert.DeserializeObject<string[]>(input); ((TypeConverter)this).ConvertToString = (object input, Type type) => (type != typeof(string[])) ? "[]" : JsonConvert.SerializeObject(input); } } internal class Battery_TypeConverter : TypeConverter { public Battery_TypeConverter() { ((TypeConverter)this).ConvertToObject = (string input, Type type) => (type != typeof(Battery)) ? ((object)new Battery(false, 1f)) : ((object)JsonConvert.DeserializeObject<Battery>(input)); ((TypeConverter)this).ConvertToString = (object input, Type type) => (type != typeof(Battery)) ? JsonConvert.SerializeObject((object)new Battery(false, 1f)) : JsonConvert.SerializeObject(input); } } internal class IntWithRarityArray_TypeConverter : TypeConverter { public IntWithRarityArray_TypeConverter() { ((TypeConverter)this).ConvertToObject = delegate(string input, Type type) { //IL_0041: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown if (type != typeof(IntWithRarity[])) { return new IntWithRarity[0]; } Dictionary<int, int> dictionary2 = JsonConvert.DeserializeObject<Dictionary<int, int>>(input); List<IntWithRarity> list = new List<IntWithRarity>(); foreach (KeyValuePair<int, int> item in dictionary2) { list.Add(new IntWithRarity { id = item.Key, rarity = item.Value }); } return list.ToArray(); }; ((TypeConverter)this).ConvertToString = delegate(object input, Type type) { if (type != typeof(IntWithRarity[])) { return "{}"; } Dictionary<int, int> dictionary = new Dictionary<int, int>(); IntWithRarity[] array = (IntWithRarity[])input; foreach (IntWithRarity val in array) { dictionary.Add(val.id, val.rarity); } return JsonConvert.SerializeObject((object)dictionary); }; } } internal class CompatibleNounArray_TypeConverter : TypeConverter { public CompatibleNounArray_TypeConverter() { ((TypeConverter)this).ConvertToObject = delegate(string input, Type type) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown if (type != typeof(CompatibleNoun[])) { return new CompatibleNoun[0]; } Dictionary<string, string> dictionary2 = JsonConvert.DeserializeObject<Dictionary<string, string>>(input); List<CompatibleNoun> list = new List<CompatibleNoun>(); foreach (KeyValuePair<string, string> PAIR in dictionary2) { IEnumerable<TerminalKeyword> source = from X in Resources.FindObjectsOfTypeAll<TerminalKeyword>() where ConfigUtils.MakeNameFileSafe(((Object)X).name) == PAIR.Key select X; IEnumerable<TerminalNode> source2 = from X in Resources.FindObjectsOfTypeAll<TerminalNode>() where ConfigUtils.MakeNameFileSafe(((Object)X).name) == PAIR.Value select X; list.Add(new CompatibleNoun { noun = ((source.Count() > 0) ? source.First() : null), result = ((source2.Count() > 0) ? source2.First() : null) }); } return list.ToArray(); }; ((TypeConverter)this).ConvertToString = delegate(object input, Type type) { if (type != typeof(CompatibleNoun[])) { return "{}"; } Dictionary<string, string> dictionary = new Dictionary<string, string>(); CompatibleNoun[] array = (CompatibleNoun[])input; foreach (CompatibleNoun val in array) { if (!((Object)(object)val.noun == (Object)null)) { TerminalKeyword noun = val.noun; if (!dictionary.ContainsKey(((noun != null) ? ((Object)noun).name : null) ?? "")) { TerminalKeyword noun2 = val.noun; string key = ((noun2 != null) ? ((Object)noun2).name : null) ?? ""; TerminalNode result = val.result; dictionary.Add(key, ((result != null) ? ((Object)result).name : null) ?? ""); } } } return JsonConvert.SerializeObject((object)dictionary); }; } } internal class TerminalKeyword_TypeConverter : TypeConverter { public TerminalKeyword_TypeConverter() { ((TypeConverter)this).ConvertToObject = delegate(string input, Type type) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if (type != typeof(TerminalKeyword)) { return (object)new TerminalKeyword(); } IEnumerable<TerminalKeyword> source = from X in Resources.FindObjectsOfTypeAll<TerminalKeyword>() where ConfigUtils.MakeNameFileSafe(((Object)X).name) == input select X; return (source.Count() > 0) ? source.First() : null; }; ((TypeConverter)this).ConvertToString = (object input, Type type) => (type != typeof(TerminalKeyword)) ? "" : ((Object)(TerminalKeyword)input).name; } } internal class TerminalNode_TypeConverter : TypeConverter { public TerminalNode_TypeConverter() { ((TypeConverter)this).ConvertToObject = delegate(string input, Type type) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if (type != typeof(TerminalNode)) { return (object)new TerminalNode(); } IEnumerable<TerminalNode> source = from X in Resources.FindObjectsOfTypeAll<TerminalNode>() where ConfigUtils.MakeNameFileSafe(((Object)X).name) == input select X; return (source.Count() > 0) ? source.First() : null; }; ((TypeConverter)this).ConvertToString = (object input, Type type) => (type != typeof(TerminalNode)) ? "" : ((Object)(TerminalNode)input).name; } } internal class SpawnableEnemyWithRarityArray_TypeConverter : TypeConverter { public SpawnableEnemyWithRarityArray_TypeConverter() { ((TypeConverter)this).ConvertToObject = delegate(string input, Type type) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown if (type != typeof(SpawnableEnemyWithRarity[])) { return new SpawnableEnemyWithRarity[0]; } Dictionary<string, int> dictionary2 = JsonConvert.DeserializeObject<Dictionary<string, int>>(input); List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>(); foreach (KeyValuePair<string, int> PAIR in dictionary2) { IEnumerable<EnemyType> source = from X in Resources.FindObjectsOfTypeAll<EnemyType>() where ConfigUtils.MakeNameFileSafe(X.enemyName) == PAIR.Key select X; list.Add(new SpawnableEnemyWithRarity { enemyType = ((source.Count() > 0) ? source.First() : null), rarity = PAIR.Value }); } return list.ToArray(); }; ((TypeConverter)this).ConvertToString = delegate(object input, Type type) { if (type != typeof(SpawnableEnemyWithRarity[])) { return "{}"; } Dictionary<string, int> dictionary = new Dictionary<string, int>(); SpawnableEnemyWithRarity[] array = (SpawnableEnemyWithRarity[])input; foreach (SpawnableEnemyWithRarity val in array) { string key = val.enemyType?.enemyName ?? "LE-MISSING"; if (dictionary.ContainsKey(key)) { dictionary[key] += val.rarity; } else { dictionary.Add(key, val.rarity); } } return JsonConvert.SerializeObject((object)dictionary); }; } } internal class SpawnableItemWithRarityArray_TypeConverter : TypeConverter { public SpawnableItemWithRarityArray_TypeConverter() { ((TypeConverter)this).ConvertToObject = delegate(string input, Type type) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown if (type != typeof(SpawnableItemWithRarity[])) { return new SpawnableItemWithRarity[0]; } Dictionary<string, int> dictionary2 = JsonConvert.DeserializeObject<Dictionary<string, int>>(input); List<SpawnableItemWithRarity> list = new List<SpawnableItemWithRarity>(); foreach (KeyValuePair<string, int> PAIR in dictionary2) { IEnumerable<Item> source = from X in Resources.FindObjectsOfTypeAll<Item>() where ConfigUtils.MakeNameFileSafe(X.itemName) == PAIR.Key select X; list.Add(new SpawnableItemWithRarity { spawnableItem = ((source.Count() > 0) ? source.First() : null), rarity = PAIR.Value }); } return list.ToArray(); }; ((TypeConverter)this).ConvertToString = delegate(object input, Type type) { if (type != typeof(SpawnableItemWithRarity[])) { return "{}"; } Dictionary<string, int> dictionary = new Dictionary<string, int>(); SpawnableItemWithRarity[] array = (SpawnableItemWithRarity[])input; foreach (SpawnableItemWithRarity val in array) { string key = val.spawnableItem?.itemName ?? "LE-MISSING"; if (dictionary.ContainsKey(key)) { dictionary[key] += val.rarity; } else { dictionary.Add(key, val.rarity); } } return JsonConvert.SerializeObject((object)dictionary); }; } } internal class SpawnableEnemyWithRarityList_TypeConverter : TypeConverter { public SpawnableEnemyWithRarityList_TypeConverter() { ((TypeConverter)this).ConvertToObject = delegate(string input, Type type) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown if (type != typeof(List<SpawnableEnemyWithRarity>)) { return new List<SpawnableEnemyWithRarity>(); } Dictionary<string, int> dictionary2 = JsonConvert.DeserializeObject<Dictionary<string, int>>(input); List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>(); foreach (KeyValuePair<string, int> PAIR in dictionary2) { IEnumerable<EnemyType> source = from X in Resources.FindObjectsOfTypeAll<EnemyType>() where ConfigUtils.MakeNameFileSafe(X.enemyName) == PAIR.Key select X; list.Add(new SpawnableEnemyWithRarity { enemyType = ((source.Count() > 0) ? source.First() : null), rarity = PAIR.Value }); } return list; }; ((TypeConverter)this).ConvertToString = delegate(object input, Type type) { if (type != typeof(List<SpawnableEnemyWithRarity>)) { return "{}"; } Dictionary<string, int> dictionary = new Dictionary<string, int>(); foreach (SpawnableEnemyWithRarity item in (List<SpawnableEnemyWithRarity>)input) { string key = item.enemyType?.enemyName ?? "LE-MISSING"; if (dictionary.ContainsKey(key)) { dictionary[key] += item.rarity; } else { dictionary.Add(key, item.rarity); } } return JsonConvert.SerializeObject((object)dictionary); }; } } internal class SpawnableItemWithRarityList_TypeConverter : TypeConverter { public SpawnableItemWithRarityList_TypeConverter() { ((TypeConverter)this).ConvertToObject = delegate(string input, Type type) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown if (type != typeof(List<SpawnableItemWithRarity>)) { return new List<SpawnableItemWithRarity>(); } Dictionary<string, int> dictionary2 = JsonConvert.DeserializeObject<Dictionary<string, int>>(input); List<SpawnableItemWithRarity> list = new List<SpawnableItemWithRarity>(); foreach (KeyValuePair<string, int> PAIR in dictionary2) { IEnumerable<Item> source = from X in Resources.FindObjectsOfTypeAll<Item>() where ConfigUtils.MakeNameFileSafe(X.itemName) == PAIR.Key select X; list.Add(new SpawnableItemWithRarity { spawnableItem = ((source.Count() > 0) ? source.First() : null), rarity = PAIR.Value }); } return list; }; ((TypeConverter)this).ConvertToString = delegate(object input, Type type) { if (type != typeof(List<SpawnableItemWithRarity>)) { return "{}"; } Dictionary<string, int> dictionary = new Dictionary<string, int>(); foreach (SpawnableItemWithRarity item in (List<SpawnableItemWithRarity>)input) { string key = item.spawnableItem?.itemName ?? "LE-MISSING"; if (dictionary.ContainsKey(key)) { dictionary[key] += item.rarity; } else { dictionary.Add(key, item.rarity); } } return JsonConvert.SerializeObject((object)dictionary); }; } } internal class EnemyType_TypeConverter : TypeConverter { public EnemyType_TypeConverter() { ((TypeConverter)this).ConvertToObject = delegate(string input, Type type) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if (type != typeof(EnemyType)) { return (object)new EnemyType(); } IEnumerable<EnemyType> source = from X in Resources.FindObjectsOfTypeAll<EnemyType>() where ConfigUtils.MakeNameFileSafe(X.enemyName) == input select X; return (source.Count() > 0) ? source.First() : null; }; ((TypeConverter)this).ConvertToString = (object input, Type type) => (type != typeof(EnemyType)) ? "" : ((EnemyType)input).enemyName; } } internal class ItemGroupList_TypeConverter : TypeConverter { public ItemGroupList_TypeConverter() { ((TypeConverter)this).ConvertToObject = delegate(string input, Type type) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown if (type != typeof(List<ItemGroup>)) { return new List<ItemGroup>(); } List<ItemGroup> list2 = new List<ItemGroup>(); foreach (string item in JsonConvert.DeserializeObject<List<string>>(input)) { list2.Add(new ItemGroup { name = item }); } return list2; }; ((TypeConverter)this).ConvertToString = delegate(object input, Type type) { if (type != typeof(List<ItemGroup>)) { return "{}"; } List<string> list = new List<string>(); foreach (ItemGroup item2 in (List<ItemGroup>)input) { list.Add(((Object)item2).name); } return JsonConvert.SerializeObject((object)list); }; } } internal class RandomWeatherWithVariablesArray_TypeConverter : TypeConverter { public RandomWeatherWithVariablesArray_TypeConverter() { ((TypeConverter)this).ConvertToObject = delegate(string input, Type type) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00b3: Expected O, but got I4 //IL_005f->IL005f: Incompatible stack types: O vs I4 //IL_005d->IL005f: Incompatible stack types: I4 vs O //IL_005d->IL005f: Incompatible stack types: O vs I4 if (type != typeof(RandomWeatherWithVariables[])) { return new RandomWeatherWithVariables[0]; } Dictionary<string, List<int>> dictionary2 = JsonConvert.DeserializeObject<Dictionary<string, List<int>>>(input); List<RandomWeatherWithVariables> list = new List<RandomWeatherWithVariables>(); foreach (KeyValuePair<string, List<int>> item in dictionary2) { object obj = list; ? val2 = new RandomWeatherWithVariables(); val2 = val2; int num; if (!Enum.TryParse<LevelWeatherType>(item.Key, out LevelWeatherType result)) { num = -1; obj = num; num = (int)obj; } else { obj = result; num = (int)obj; } ((RandomWeatherWithVariables)val2).weatherType = (LevelWeatherType)obj; ((RandomWeatherWithVariables)val2).weatherVariable = ((item.Value.Count > 0) ? item.Value[0] : 0); ((RandomWeatherWithVariables)val2).weatherVariable2 = ((item.Value.Count > 1) ? item.Value[1] : 0); ((List<RandomWeatherWithVariables>)num).Add((RandomWeatherWithVariables)val2); } return list.ToArray(); }; ((TypeConverter)this).ConvertToString = delegate(object input, Type type) { if (type != typeof(RandomWeatherWithVariables[])) { return "{}"; } Dictionary<string, List<int>> dictionary = new Dictionary<string, List<int>>(); RandomWeatherWithVariables[] array = (RandomWeatherWithVariables[])input; foreach (RandomWeatherWithVariables val in array) { dictionary.Add(((object)(LevelWeatherType)(ref val.weatherType)).ToString(), new List<int> { val.weatherVariable, val.weatherVariable2 }); } return JsonConvert.SerializeObject((object)dictionary); }; } } } namespace LethalUtilities { public enum MapLevel { None = -1, CompanyBuilding = 3, Level1Experimentation = 0, Level2Assurance = 1, Level3Vow = 2, Level7Offense = 7, Level4March = 4, Level5Rend = 5, Level6Dine = 6, Level8Titan = 8 } internal static class MapSettings { public static ConfigEntry<bool> ConfigEnabled = UtilsMod.MapConfig.Bind("Active Settings", "ConfigEnabled", defaultValue: false, "Whether or not the MapConfig executes.", 0); public static ConfigEntry<bool> ScrapModifiersEnabled = UtilsMod.MapConfig.Bind("Active Settings", "ScrapModifiersEnabled", defaultValue: false, "Whether or not the scrap multipliers apply.", 0); public static ConfigEntry<bool> MapModifiersEnabled = UtilsMod.MapConfig.Bind("Active Settings", "MapModifiersEnabled", defaultValue: false, "Whether or not the map multipliers apply.", 0); public static ConfigEntry<bool> TimeModifiersEnabled = UtilsMod.MapConfig.Bind("Active Settings", "TimeModifiersEnabled", defaultValue: false, "Whether or not the time multipliers apply.", 0); public static ConfigEntry<bool> SpawnModifiersEnabled = UtilsMod.MapConfig.Bind("Active Settings", "SpawnModifiersEnabled", defaultValue: false, "Whether or not the map spawn modifiers will apply.", 0); public static ConfigEntry<float> ScrapAmountScalar = UtilsMod.MapConfig.Bind("Global Map Settings", "ScrapAmountScalar", 1f, "The overall multiplier of spawned scrap.\n(Multiplies on top of individual scalars.)", 1); public static ConfigEntry<float> ScrapValueScalar = UtilsMod.MapConfig.Bind("Global Map Settings", "ScrapValueScalar", 0.4f, "The overall multiplier of scrap value.\n(Multiplies on top of individual scalars.)", 1); public static ConfigEntry<float> MapScalar = UtilsMod.MapConfig.Bind("Global Map Settings", "MapScalar", 1f, "The overall map scale.\nValues under 1 will be capped off at 1 before applying because it crashes the game.\n(Multiplies on top of individual scalars.)", 1); public static ConfigEntry<float> DayScalar = UtilsMod.MapConfig.Bind("Global Map Settings", "DayScalar", 1f, "[LU-DEPRECATED]: Please use TimeSpeedScalar instead or individual map time settings.\nThe overall map day speed multiplier.\n(Ex: 0 starts at 6:00AM, 1 starts at 7:40AM, disregarding ship landing time.)\n(Multiplies on top of individual scalars.)", 1); public static ConfigEntry<float> TimeSpeedScalar = UtilsMod.MapConfig.Bind("Global Map Settings", "TimeSpeedScalar", 1.4f, "The overall time speed multiplier.\n(Multiplies on top of individual scalars.)", 1); public static Dictionary<MapLevel, Dictionary<string, ConfigEntryBase>> Settings = new Dictionary<MapLevel, Dictionary<string, ConfigEntryBase>> { [MapLevel.Level1Experimentation] = AddMapSettings("Experimentation", 11, 1f, 0f, 1f, 4f, 5f, 8, 12, 4, 8, 5, 51, 58, 28, 13, 16, 31, 1, 28, 1, 0, 0, 0, 0, 75, 0, 56, 0, 22, 74, 52), [MapLevel.Level2Assurance] = AddMapSettings("Assurance", 12, 1f, 0f, 1f, 3f, 10f, 13, 17, 6, 8, 7, 93, 69, 78, 14, 24, 28, 1, 14, 1, 0, 0, 0, 0, 78, 1, 95, 20, 58, 100, 43), [MapLevel.Level3Vow] = AddMapSettings("Vow", 13, 2.5f, 0f, 1.15f, 3f, 7f, 10, 13, 7, 6, 17, 61, 40, 63, 80, 9, 28, 0, 19, 0, 6, 0, 0, 0, 4, 100, 18, 0, 61, 100, 67), [MapLevel.Level7Offense] = AddMapSettings("Offense", 15, 2f, 0f, 1.25f, 4f, 10f, 14, 18, 12, 8, 20, 27, 44, 16, 3, 55, 32, 0, 7, 2, 25, 0, 0, 0, 100, 9, 37, 60, 58, 100, 43), [MapLevel.Level4March] = AddMapSettings("March", 16, 2.75f, 0f, 2f, 4f, 7f, 13, 17, 14, 12, 20, 38, 64, 36, 56, 74, 15, 0, 9, 3, 10, 1, 0, 0, 38, 64, 16, 72, 72, 83, 49), [MapLevel.Level5Rend] = AddMapSettings("Rend", 17, 2.7f, 0f, 1.2f, 3f, 10f, 18, 26, 10, 6, 20, 31, 43, 0, 51, 0, 6, 20, 7, 100, 70, 69, 0, 25, 74, 60, 18), [MapLevel.Level6Dine] = AddMapSettings("Dine", 18, 2.7f, 0f, 1.3f, 4f, 10f, 20, 28, 15, 6, 20, 52, 64, 48, 25, 48, 39, 18, 16, 60, 53, 66, 0, 0, 79, 28, 57), [MapLevel.Level8Titan] = AddMapSettings("Titan", 19, 6f, 0f, 2.35f, 2f, 10f, 23, 38, 18, 7, 20, 54, 59, 38, 62, 54, 20, 28, 16, 32, 59, 71, 0, 32, 80, 32, 4) }; private static ConfigEntry<T> NewFormattedEntry<T>(string PrefixName, string Variable, T DefaultValue, string Description, int Order = -1) { return UtilsMod.MapConfig.Bind(PrefixName + " Settings", Variable ?? "", DefaultValue, Description.Replace("$VAR", Variable), Order); } private static Dictionary<string, ConfigEntryBase> AddMapSettings(string MapName, int Order = -1, float TimeToArrive = 1f, float OffsetFromGlobalTime = 0f, float FactorySizeMultiplier = 1f, float SpawnProbabilityRange = 1f, float DaytimeEnemiesProbabilityRange = 1f, int MinScrapAmount = 0, int MaxScrapAmount = 0, int MaxEnemyPower = 10, int MaxOutsideEnemyPower = 10, int MaxDaytimeEnemyPower = 20, int Centipede = 0, int SandSpider = 0, int HoarderBug = 0, int Flowerman = 0, int Crawler = 0, int Blob = 0, int DressGirl = 0, int Puffer = 0, int Nutcracker = 0, int SpringMan = 0, int Jester = 0, int LassoMan = 0, int Mask = 0, int MouthDog = 0, int ForestGiant = 0, int SandWorm = 0, int BaboonHawk = 0, int RedLocustBees = 0, int Doublewing = 0, int DocileLocustBees = 0) { return new Dictionary<string, ConfigEntryBase> { ["ScrapAmountScalar"] = NewFormattedEntry(MapName + " Scrap", "ScrapAmountScalar", 1f, "The " + MapName + " multiplier of spawned scrap.", Order), ["ScrapValueScalar"] = NewFormattedEntry(MapName + " Scrap", "ScrapValueScalar", 1f, "The " + MapName + " multiplier of scrap value.", Order), ["MapScalar"] = NewFormattedEntry(MapName + " Map", "MapScalar", 1f, "The " + MapName + " scalar of the inside.\nValues under 1 will be capped off at 1 before applying because it crashes the game.", Order), ["DayScalar"] = NewFormattedEntry(MapName + " Time", "DayScalar", 1f, "[LU-DEPRECATED]: Please use TimeSpeedScalar instead or individual map time settings.\nThe " + MapName + " speed scalar of the day.\n(Ex: 0 starts at 6:00AM, 1 starts at 7:40AM, disregarding ship landing time.)", Order), ["TimeSpeedScalar"] = NewFormattedEntry(MapName + " Time", "TimeSpeedScalar", 1f, "The " + MapName + " time scalar of the day.", Order), ["LengthOfHours"] = NewFormattedEntry(MapName + " Time", "LengthOfHours", 100f, "The " + MapName + " length of hours.", Order), ["NumberOfHours"] = NewFormattedEntry(MapName + " Time", "NumberOfHours", 7, "The " + MapName + " number of hours. (I think this is for day time?)", Order), ["TimeToArrive"] = NewFormattedEntry(MapName + " Time", "TimeToArrive", TimeToArrive, "The " + MapName + " $VAR.", Order), ["OffsetFromGlobalTime"] = NewFormattedEntry(MapName + " Time", "OffsetFromGlobalTime", OffsetFromGlobalTime, "The " + MapName + " $VAR.", Order), ["SpawnProbabilityRange"] = NewFormattedEntry(MapName + " Spawn", "SpawnProbabilityRange", SpawnProbabilityRange, "(Careful) The " + MapName + " $VAR.", Order), ["DaytimeEnemiesProbabilityRange"] = NewFormattedEntry(MapName + " Spawn", "DaytimeEnemiesProbabilityRange", DaytimeEnemiesProbabilityRange, "(Careful) The " + MapName + " $VAR.", Order), ["MinScrapAmount"] = NewFormattedEntry(MapName + " Scrap", "MinScrapAmount", MinScrapAmount, "The " + MapName + " $VAR.", Order), ["MaxScrapAmount"] = NewFormattedEntry(MapName + " Scrap", "MaxScrapAmount", MaxScrapAmount, "The " + MapName + " $VAR.", Order), ["MinEnemiesToSpawn"] = NewFormattedEntry(MapName + " Spawn", "MinEnemiesToSpawn", 0, "(Careful) The " + MapName + " $VAR.", Order), ["MinOutsideEnemiesToSpawn"] = NewFormattedEntry(MapName + " Spawn", "MinOutsideEnemiesToSpawn", 0, "(Careful) The " + MapName + " $VAR.", Order), ["HourTimeBetweenEnemySpawnBatches"] = NewFormattedEntry(MapName + " Spawn", "HourTimeBetweenEnemySpawnBatches", 2, "The " + MapName + " $VAR.", Order), ["MaxEnemyPower"] = NewFormattedEntry(MapName + " Spawn", "MaxInsideEnemyPower", MaxEnemyPower, "(Careful) The " + MapName + " $VAR.", Order), ["MaxOutsideEnemyPower"] = NewFormattedEntry(MapName + " Spawn", "MaxOutsideEnemyPower", MaxOutsideEnemyPower, "(Careful) The " + MapName + " $VAR.", Order), ["MaxDaytimeEnemyPower"] = NewFormattedEntry(MapName + " Spawn", "MaxDaytimeEnemyPower", MaxDaytimeEnemyPower, "(Careful) The " + MapName + " $VAR.", Order), ["CentipedeSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "CentipedeSpawnWeight", Centipede, "(Inside) The " + MapName + " $VAR.", Order), ["Bunker SpiderSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "SandSpiderSpawnWeight", SandSpider, "(Inside) The " + MapName + " $VAR.", Order), ["Hoarding bugSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "HoarderBugSpawnWeight", HoarderBug, "(Inside) The " + MapName + " $VAR.", Order), ["FlowermanSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "FlowermanSpawnWeight", Flowerman, "(Inside) The " + MapName + " $VAR.", Order), ["CrawlerSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "CrawlerSpawnWeight", Crawler, "(Inside) The " + MapName + " $VAR.", Order), ["BlobSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "BlobSpawnWeight", Blob, "(Inside) The " + MapName + " $VAR.", Order), ["GirlSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "DressGirlSpawnWeight", DressGirl, "(Inside) The " + MapName + " $VAR.", Order), ["PufferSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "PufferSpawnWeight", Puffer, "(Inside) The " + MapName + " $VAR.", Order), ["NutcrackerSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "NutcrackerSpawnWeight", Nutcracker, "(Inside) The " + MapName + " $VAR.", Order), ["SpringSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "SpringManSpawnWeight", SpringMan, "(Inside) The " + MapName + " $VAR.", Order), ["JesterSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "JesterSpawnWeight", Jester, "(Inside) The " + MapName + " $VAR.", Order), ["LassoSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "LassoManSpawnWeight", LassoMan, "(Inside) The " + MapName + " $VAR.", Order), ["MaskedSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "MaskSpawnWeight", Mask, "(Inside) The " + MapName + " $VAR.", Order), ["MouthDogSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "MouthDogSpawnWeight", MouthDog, "(Outside) The " + MapName + " $VAR.", Order), ["ForestGiantSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "ForestGiantSpawnWeight", ForestGiant, "(Outside) The " + MapName + " $VAR.", Order), ["Earth LeviathanSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "SandWormSpawnWeight", SandWorm, "(Outside) The " + MapName + " $VAR.", Order), ["Baboon hawkSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "BaboonHawkSpawnWeight", BaboonHawk, "(Outside) The " + MapName + " $VAR.", Order), ["Red Locust BeesSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "RedLocustBeesSpawnWeight", RedLocustBees, "(Daytime) The " + MapName + " $VAR.", Order), ["ManticoilSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "DoublewingSpawnWeight", Doublewing, "(Daytime) (Manticoil) The " + MapName + " $VAR.", Order), ["Docile Locust BeesSpawnWeight"] = NewFormattedEntry(MapName + " Spawn", "DocileLocustBeesSpawnWeight", DocileLocustBees, "(Daytime) The " + MapName + " $VAR.", Order) }; } } internal class MapPatch { [HarmonyPatch(typeof(RoundManager), "GenerateNewFloor")] [HarmonyPrefix] private static void PatchLevelMultiplierSettings(RoundManager __instance) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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) float num = (float)MapSettings.MapScalar.DefaultValue; MapLevel levelID = (MapLevel)__instance.currentLevel.levelID; LevelWeatherType currentWeather = __instance.currentLevel.currentWeather; if (MapSettings.MapModifiersEnabled.Value) { num = MapSettings.MapScalar.Value; if (MapSettings.Settings.ContainsKey(levelID)) { Dictionary<string, ConfigEntryBase> dictionary = MapSettings.Settings[levelID]; num *= (dictionary["MapScalar"] as ConfigEntry<float>).Value; } } else if (MapSettings.Settings.ContainsKey(levelID)) { Dictionary<string, ConfigEntryBase> dictionary2 = MapSettings.Settings[levelID]; num *= (float)(dictionary2["MapScalar"] as ConfigEntry<float>).DefaultValue; } if (WeatherSettings.MapModifiersEnabled.Value && WeatherSettings.Settings.ContainsKey(currentWeather)) { Dictionary<string, ConfigEntryBase> dictionary3 = WeatherSettings.Settings[currentWeather]; num *= (dictionary3["MapScalar"] as ConfigEntry<float>).Value; } __instance.mapSizeMultiplier = Mathf.Max(num, 1f); } } internal static class TimeSettings { } internal class TimePatch { [HarmonyPatch(typeof(TimeOfDay), "Update")] [HarmonyPrefix] public static void Update(TimeOfDay __instance, bool ___timeStartedThisFrame) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) if (!__instance.currentDayTimeStarted || !___timeStartedThisFrame) { return; } MapLevel levelID = (MapLevel)__instance.currentLevel.levelID; LevelWeatherType currentWeather = __instance.currentLevel.currentWeather; float num = 1f; float num2 = 1.4f; if (MapSettings.ConfigEnabled.Value && MapSettings.TimeModifiersEnabled.Value) { num = MapSettings.DayScalar.Value; num2 = MapSettings.TimeSpeedScalar.Value; if (MapSettings.Settings.ContainsKey(levelID)) { Dictionary<string, ConfigEntryBase> dictionary = MapSettings.Settings[levelID]; num *= (dictionary["DayScalar"] as ConfigEntry<float>).Value; num2 *= (dictionary["TimeSpeedScalar"] as ConfigEntry<float>).Value; __instance.lengthOfHours = (dictionary["LengthOfHours"] as ConfigEntry<float>).Value; __instance.numberOfHours = (dictionary["NumberOfHours"] as ConfigEntry<int>).Value; } } if (WeatherSettings.ConfigEnabled.Value && WeatherSettings.TimeModifiersEnabled.Value && WeatherSettings.Settings.TryGetValue(currentWeather, out var value)) { num *= (value["DayScalar"] as ConfigEntry<float>).Value; num2 *= (value["TimeSpeedScalar"] as ConfigEntry<float>).Value; } __instance.currentLevel.DaySpeedMultiplier = num; __instance.globalTimeSpeedMultiplier = num2; UtilsMod.MLS.LogWarning((object)"IT'S A BRAND NEW DAYYYYYYY."); } [HarmonyPatch(typeof(RoundManager), "LoadNewLevel")] [HarmonyPrefix] [HarmonyPriority(1114)] private static void TimePatchLoadNewLevel(ref SelectableLevel newLevel) { if (MapSettings.TimeModifiersEnabled.Value && MapSettings.Settings.TryGetValue((MapLevel)newLevel.levelID, out var value)) { newLevel.timeToArrive = ((ConfigEntry<float>)value["TimeToArrive"]).Value; newLevel.OffsetFromGlobalTime = ((ConfigEntry<float>)value["OffsetFromGlobalTime"]).Value; } } } internal static class WeatherSettings { public static ConfigEntry<bool> ConfigEnabled = UtilsMod.WeatherConfig.Bind("Active Settings", "ConfigEnabled", defaultValue: false, "Whether or not the WeatherConfig executes."); public static ConfigEntry<bool> ScrapModifiersEnabled = UtilsMod.WeatherConfig.Bind("Active Settings", "ScrapModifiersEnabled", defaultValue: false, "Whether or not the scrap multipliers apply."); public static ConfigEntry<bool> MapModifiersEnabled = UtilsMod.WeatherConfig.Bind("Active Settings", "MapModifiersEnabled", defaultValue: false, "Whether or not the map multipliers apply. (Why not? Make Eclipsed have giant maps if you want.)"); public static ConfigEntry<bool> TimeModifiersEnabled = UtilsMod.WeatherConfig.Bind("Active Settings", "TimeModifiersEnabled", defaultValue: false, "Whether or not the time multipliers apply."); public static ConfigEntry<bool> SpawnModifiersEnabled = UtilsMod.WeatherConfig.Bind("Active Settings", "SpawnModifiersEnabled", defaultValue: false, "Whether or not the weather spawn modifiers will apply. (Will set default values beforehand for compatibility/stability reasons.)"); public static Dictionary<LevelWeatherType, Dictionary<string, ConfigEntryBase>> Settings = new Dictionary<LevelWeatherType, Dictionary<string, ConfigEntryBase>> { [(LevelWeatherType)(-1)] = AddMapSettings("Normal"), [(LevelWeatherType)0] = AddMapSettings("Dusty"), [(LevelWeatherType)1] = AddMapSettings("Rainy"), [(LevelWeatherType)2] = AddMapSettings("Stormy"), [(LevelWeatherType)3] = AddMapSettings("Foggy"), [(LevelWeatherType)4] = AddMapSettings("Flooded"), [(LevelWeatherType)5] = AddMapSettings("Eclipsed") }; private static ConfigEntry<float> NewFloatEntryWithMapVar(string PrefixName, string Variable, string AddPrefixToNew, float DefaultValue, string Description) { ConfigDefinition configDefinition = new ConfigDefinition(PrefixName + " Weather Settings", ((PrefixName == "Normal") ? "DefaultWeather" : PrefixName) + Variable); ConfigEntry<float> configEntry = UtilsMod.WeatherConfig.Bind(configDefinition, DefaultValue); ConfigEntry<float> configEntry2 = UtilsMod.WeatherConfig.Bind(PrefixName + " " + AddPrefixToNew + " Settings", Variable, DefaultValue, Description.Replace("$VAR", Variable)); if (configEntry.Value != (float)configEntry.DefaultValue && configEntry2.Value == (float)configEntry2.DefaultValue) { configEntry2.Value = configEntry.Value; } UtilsMod.WeatherConfig.Remove(configDefinition); UtilsMod.WeatherConfig.Save(); return configEntry2; } private static ConfigEntry<T> NewEntry<T>(string PrefixName, string Variable, T DefaultValue, string Description) { return UtilsMod.WeatherConfig.Bind(PrefixName + " Settings", Variable ?? "", DefaultValue, Description.Replace("$VAR", Variable)); } private static Dictionary<string, ConfigEntryBase> AddMapSettings(string WeatherType) { Dictionary<string, ConfigEntryBase> dictionary = new Dictionary<string, ConfigEntryBase>(); dictionary["ScrapAmountScalar"] = NewFloatEntryWithMapVar(WeatherType, "ScrapAmountScalar", "Scrap", 1f, "The " + WeatherType + " multiplier of spawned scrap."); dictionary["ScrapValueScalar"] = NewFloatEntryWithMapVar(WeatherType, "ScrapValueScalar", "Scrap", 1f, "The " + WeatherType + " multiplier of scrap value."); dictionary["MapScalar"] = NewFloatEntryWithMapVar(WeatherType, "MapScalar", "Map", 1f, "The " + WeatherType + " scalar of the inside.\nValues under 1 will be capped off at 1 before applying because it crashes the game."); dictionary["DayScalar"] = NewFloatEntryWithMapVar(WeatherType, "DayScalar", "Time", 1f, "The " + WeatherType + " speed scalar of the day.\n(Ex: 0 starts at 6:00AM, 1 starts at 7:40AM, disregarding ship landing time.)"); dictionary["TimeSpeedScalar"] = NewEntry(WeatherType + " Time", "TimeSpeedScalar", 1f, "The " + WeatherType + " time scalar of the day."); dictionary["CentipedeMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "CentipedeMapSpawnMultiplier", 1f, "(Inside) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["CentipedeAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "CentipedeAddSpawnWeight", 0, "(Inside) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["Bunker SpiderMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "SandSpiderMapSpawnMultiplier", 1f, "(Inside) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["Bunker SpiderAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "SandSpiderAddSpawnWeight", 0, "(Inside) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["Hoarding bugMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "HoarderBugMapSpawnMultiplier", 1f, "(Inside) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["Hoarding bugAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "HoarderBugAddSpawnWeight", 0, "(Inside) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["FlowermanMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "FlowermanMapSpawnMultiplier", 1f, "(Inside) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["FlowermanAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "FlowermanAddSpawnWeight", 0, "(Inside) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["CrawlerMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "CrawlerMapSpawnMultiplier", 1f, "(Inside) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["CrawlerAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "CrawlerAddSpawnWeight", 0, "(Inside) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["BlobMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "BlobMapSpawnMultiplier", 1f, "(Inside) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["BlobAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "BlobAddSpawnWeight", 0, "(Inside) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["GirlMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "DressGirlMapSpawnMultiplier", 1f, "(Inside) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["GirlAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "DressGirlAddSpawnWeight", 0, "(Inside) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["PufferMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "PufferMapSpawnMultiplier", 1f, "(Inside) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["PufferAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "PufferAddSpawnWeight", 0, "(Inside) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["NutcrackerMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "NutcrackerMapSpawnMultiplier", 1f, "(Inside) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["NutcrackerAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "NutcrackerAddSpawnWeight", 0, "(Inside) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["SpringMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "SpringManMapSpawnMultiplier", 1f, "(Inside) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["SpringAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "SpringManAddSpawnWeight", 0, "(Inside) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["JesterMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "JesterMapSpawnMultiplier", 1f, "(Inside) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["JesterAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "JesterAddSpawnWeight", 0, "(Inside) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["LassoMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "LassoManMapSpawnMultiplier", 1f, "(Inside) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["LassoAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "LassoManAddSpawnWeight", 0, "(Inside) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["MaskedMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "MaskMapSpawnMultiplier", 1f, "(Inside) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["MaskedAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "MaskAddSpawnWeight", 0, "(Inside) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["MouthDogMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "MouthDogMapSpawnMultiplier", 1f, "(Outside) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["MouthDogAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "MouthDogAddSpawnWeight", 0, "(Outside) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["ForestGiantMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "ForestGiantMapSpawnMultiplier", 1f, "(Outside) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["ForestGiantAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "ForestGiantAddSpawnWeight", 0, "(Outside) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["Earth LeviathanMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "SandWormMapSpawnMultiplier", 1f, "(Outside) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["Earth LeviathanAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "SandWormAddSpawnWeight", 0, "(Outside) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["Baboon hawkMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "BaboonHawkMapSpawnMultiplier", 1f, "(Outside) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["Baboon hawkAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "BaboonHawkAddSpawnWeight", 0, "(Outside) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["Red Locust BeesMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "RedLocustBeesMapSpawnMultiplier", 1f, "(Daytime) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["Red Locust BeesAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "RedLocustBeesAddSpawnWeight", 0, "(Daytime) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["ManticoilMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "DoublewingMapSpawnMultiplier", 1f, "(Daytime) (Manticoil) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["ManticoilAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "DoublewingAddSpawnWeight", 0, "(Daytime) (Manticoil) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); dictionary["Docile Locust BeesMapSpawnMultiplier"] = NewEntry(WeatherType + " Spawn", "DocileLocustBeesMapSpawnMultiplier", 1f, "(Daytime) The " + WeatherType + " $VAR.\n(Multiplier of the map spawn weight during " + WeatherType + " weather."); dictionary["Docile Locust BeesAddSpawnWeight"] = NewEntry(WeatherType + " Spawn", "DocileLocustBeesAddSpawnWeight", 0, "(Daytime) The " + WeatherType + " $VAR.\n(Additional spawn weight (aka chance, somewhat) added to the enemy during " + WeatherType + " weather.)"); return dictionary; } } internal class WeatherPatch { } internal static class SpawnSettings { } internal class SpawnPatch { [HarmonyPatch(typeof(RoundManager), "LoadNewLevel")] [HarmonyPostfix] private static void PatchCHECK(ref SelectableLevel newLevel) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) MapLevel levelID = (MapLevel)newLevel.levelID; LevelWeatherType currentWeather = newLevel.currentWeather; UtilsMod.MLS.LogInfo((object)$"{RoundManager.Instance.hourTimeBetweenEnemySpawnBatches} {RoundManager.Instance.minEnemiesToSpawn} {RoundManager.Instance.minOutsideEnemiesToSpawn} {newLevel.maxEnemyPowerCount} {newLevel.maxOutsideEnemyPowerCount} {newLevel.maxDaytimeEnemyPowerCount} {newLevel.spawnProbabilityRange} {newLevel.daytimeEnemiesProbabilityRange} {newLevel.timeToArrive} {newLevel.OffsetFromGlobalTime}"); } private static void AddEnemiesToLevel(List<SpawnableEnemyWithRarity> TypeOfEnemies, List<SpawnableEnemyWithRarity> AddToEnemies) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown foreach (SpawnableEnemyWithRarity AddToEnemy in AddToEnemies) { EnemyType enemyType = AddToEnemy.enemyType; GameObject enemyPrefab = enemyType.enemyPrefab; EnemyAI component = enemyPrefab.GetComponent<EnemyAI>(); if (!Object.op_Implicit((Object)(object)component)) { continue; } bool flag = false; foreach (SpawnableEnemyWithRarity TypeOfEnemy in TypeOfEnemies) { if (TypeOfEnemy.enemyType.enemyName != enemyType.enemyName) { continue; } flag = true; break; } if (!flag) { SpawnableEnemyWithRarity val = new SpawnableEnemyWithRarity(); val.enemyType = enemyType; val.rarity = 0; TypeOfEnemies.Add(val); } } } private static void ChangeEnemyRarities(List<SpawnableEnemyWithRarity> TypeOfEnemies, MapLevel Map, LevelWeatherType Weather) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < TypeOfEnemies.Count; i++) { SpawnableEnemyWithRarity val = TypeOfEnemies[i]; if (!MapSettings.Settings.ContainsKey(Map)) { continue; } Dictionary<string, ConfigEntryBase> dictionary = MapSettings.Settings[Map]; if (dictionary.ContainsKey(((Object)val.enemyType).name + "SpawnWeight")) { ConfigEntry<int> configEntry = (ConfigEntry<int>)dictionary[((Object)val.enemyType).name + "SpawnWeight"]; val.rarity = (MapSettings.SpawnModifiersEnabled.Value ? configEntry.Value : ((int)configEntry.DefaultValue)); if (WeatherSettings.SpawnModifiersEnabled.Value && WeatherSettings.Settings.ContainsKey(Weather)) { Dictionary<string, ConfigEntryBase> dictionary2 = WeatherSettings.Settings[Weather]; val.rarity = (int)((float)val.rarity * (dictionary2[((Object)val.enemyType).name + "MapSpawnMultiplier"] as ConfigEntry<float>).Value) + (dictionary2[((Object)val.enemyType).name + "AddSpawnWeight"] as ConfigEntry<int>).Value; } } } } [HarmonyPatch(typeof(RoundManager), "LoadNewLevel")] [HarmonyPrefix] [HarmonyPriority(1114)] private static void PatchLoadNewLevel(ref SelectableLevel newLevel) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) MapLevel levelID = (MapLevel)newLevel.levelID; LevelWeatherType currentWeather = newLevel.currentWeather; if (MapSettings.Settings.ContainsKey(levelID)) { Dictionary<string, ConfigEntryBase> dictionary = MapSettings.Settings[levelID]; if (MapSettings.SpawnModifiersEnabled.Value) { if (((ConfigEntry<int>)dictionary["HourTimeBetweenEnemySpawnBatches"]).Value != 2) { RoundManager.Instance.hourTimeBetweenEnemySpawnBatches = ((ConfigEntry<int>)dictionary["HourTimeBetweenEnemySpawnBatches"]).Value; } if (((ConfigEntry<int>)dictionary["MinEnemiesToSpawn"]).Value != 0) { RoundManager.Instance.minEnemiesToSpawn = ((ConfigEntry<int>)dictionary["MinEnemiesToSpawn"]).Value; } if (((ConfigEntry<int>)dictionary["MinOutsideEnemiesToSpawn"]).Value != 0) { RoundManager.Instance.minOutsideEnemiesToSpawn = ((ConfigEntry<int>)dictionary["MinOutsideEnemiesToSpawn"]).Value; } newLevel.maxEnemyPowerCount = ((ConfigEntry<int>)dictionary["MaxEnemyPower"]).Value; newLevel.maxOutsideEnemyPowerCount = ((ConfigEntry<int>)dictionary["MaxOutsideEnemyPower"]).Value; newLevel.maxDaytimeEnemyPowerCount = ((ConfigEntry<int>)dictionary["MaxDaytimeEnemyPower"]).Value; newLevel.spawnProbabilityRange = ((ConfigEntry<float>)dictionary["SpawnProbabilityRange"]).Value; newLevel.daytimeEnemiesProbabilityRange = ((ConfigEntry<float>)dictionary["DaytimeEnemiesProbabilityRange"]).Value; } } UtilsMod.MLS.LogInfo((object)$"{RoundManager.Instance.hourTimeBetweenEnemySpawnBatches} {RoundManager.Instance.minEnemiesToSpawn} {RoundManager.Instance.minOutsideEnemiesToSpawn} {newLevel.maxEnemyPowerCount} {newLevel.maxOutsideEnemyPowerCount} {newLevel.maxDaytimeEnemyPowerCount} {newLevel.spawnProbabilityRange} {newLevel.daytimeEnemiesProbabilityRange} {newLevel.timeToArrive} {newLevel.OffsetFromGlobalTime}"); List<SpawnableEnemyWithRarity> enemies = newLevel.Enemies; List<SpawnableEnemyWithRarity> outsideEnemies = newLevel.OutsideEnemies; List<SpawnableEnemyWithRarity> daytimeEnemies = newLevel.DaytimeEnemies; SelectableLevel[] levels = StartOfRound.Instance.levels; for (int i = 0; i < levels.Length; i++) { AddEnemiesToLevel(enemies, levels[i].Enemies); AddEnemiesToLevel(outsideEnemies, levels[i].OutsideEnemies); AddEnemiesToLevel(daytimeEnemies, levels[i].DaytimeEnemies); } ChangeEnemyRarities(enemies, levelID, currentWeather); ChangeEnemyRarities(outsideEnemies, levelID, currentWeather); ChangeEnemyRarities(daytimeEnemies, levelID, currentWeather); } } public enum UsernameFilter { Default, Nothing } internal static class LobbySettings { public static ConfigEntry<bool> ConfigEnabled = UtilsMod.LobbyConfig.Bind("Active Settings", "ConfigEnabled", defaultValue: false, "Whether or not the LobbyConfig executes. (NOT TESTED)"); public static ConfigEntry<UsernameFilter> UsernameFiltering = UtilsMod.LobbyConfig.Bind("Lobby Settings", "UsernameFiltering", UsernameFilter.Default, "How names should be filtered. (Nothing might be unstable, but unknown.)"); } internal class LobbyPatch { [HarmonyPatch(typeof(PlayerControllerB), "NoPunctuation")] [HarmonyPrefix] public static bool PlayerNoPunctuation(ref string __result, string input) { if (LobbySettings.UsernameFiltering.Value == UsernameFilter.Default) { return true; } __result = input; return false; } [HarmonyPatch(typeof(GameNetworkManager), "NoPunctuation")] [HarmonyPrefix] public static bool NetworkNoPunctuation(ref string __result, string input) { if (LobbySettings.UsernameFiltering.Value == UsernameFilter.Default) { return true; } __result = input; return false; } [HarmonyPatch(typeof(StartOfRound), "NoPunctuation")] [HarmonyPrefix] public static bool RoundNoPunctuation(ref string __result, string input) { if (LobbySettings.UsernameFiltering.Value == UsernameFilter.Default) { return true; } __result = input; return false; } } public enum DoorInSpace { DoesNothing, OpenWithBarrier } internal static class ShipSettings { public static ConfigEntry<bool> ConfigEnabled = UtilsMod.ShipConfig.Bind("Active Settings", "ConfigEnabled", defaultValue: false, "Whether or not the ShipConfig executes."); public static ConfigEntry<DoorInSpace> DoorInSpaceOptions = UtilsMod.ShipConfig.Bind("Ship Settings", "DoorInSpace", DoorInSpace.DoesNothing, "Settings for the door while in space."); } internal class ShipPatch { [HarmonyPatch(typeof(HangarShipDoor), "PlayDoorAnimation")] [HarmonyPrefix] private static void SetPlayDoorAnimation(HangarShipDoor __instance, ref bool ___buttonsEnabled) { if (ShipSettings.DoorInSpaceOptions.Value != 0) { __instance.buttonsEnabled = true; } } } public enum UponDeathShipLoses { Nothing, ScrapOnly } internal static class RoundSettings { public static ConfigEntry<bool> ConfigEnabled = UtilsMod.RoundConfig.Bind("Active Settings", "ConfigEnabled", defaultValue: false, "Whether or not the RoundConfig executes."); public static ConfigEntry<UponDeathShipLoses> LoseUponDeath = UtilsMod.RoundConfig.Bind("Round Settings", "LoseUponDeath", UponDeathShipLoses.ScrapOnly, "What you lose when everybody dies."); } internal class RoundPatch { public static bool AllPlayersDead; [HarmonyPatch(typeof(RoundManager), "DespawnPropsAtEndOfRound")] [HarmonyPrefix] private static void PreSkipPropDespawn() { if (RoundSettings.LoseUponDeath.Value != UponDeathShipLoses.ScrapOnly) { AllPlayersDead = StartOfRound.Instance.allPlayersDead; StartOfRound.Instance.allPlayersDead = false; } } [HarmonyPatch(typeof(RoundManager), "DespawnPropsAtEndOfRound")] [HarmonyPostfix] private static void PostSkipPropDespawn() { if (RoundSettings.LoseUponDeath.Value == UponDeathShipLoses.ScrapOnly) { StartOfRound.Instance.allPlayersDead = AllPlayersDead; } } } public enum MonsterAggression { Hostile, OnlyVerbal, NonHostile } internal static class CompanySettings { public static ConfigEntry<bool> ConfigEnabled = UtilsMod.CompanyConfig.Bind("Active Settings", "ConfigEnabled", defaultValue: false, "Whether or not the CompanyConfig executes."); public static ConfigEntry<MonsterAggression> SetMonsterAggression = UtilsMod.CompanyConfig.Bind("Company Settings", "SetMonsterAggression", MonsterAggression.Hostile, "Whether or not the monster will attack you."); public static ConfigEntry<bool> AlwaysFullBuyingRate = UtilsMod.CompanyConfig.Bind("Company Settings", "AlwaysFullBuyingRate", defaultValue: false, "Whether or not the Company is buying at full rate at all times."); public static ConfigEntry<float> BellCooldown = UtilsMod.CompanyConfig.Bind("Company Settings", "BellCooldown", 1f, new ConfigDescription("How long the cooldown is for ringing the bell. (You should make it 0 and spam until you die, yes yes.)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f))); public static ConfigEntry<float> GrabObjectsWaitTime = UtilsMod.CompanyConfig.Bind("Company Settings", "GrabObjectsWaitTime", 10f, new ConfigDescription("How long until the Company takes your stuff.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f))); } internal class CompanyPatch { [HarmonyPatch(typeof(DepositItemsDesk), "Start")] [HarmonyPrefix] private static void PatchDepositDesk(ref float ___grabObjectsWaitTime) { if (CompanySettings.GrabObjectsWaitTime.Value != 10f) { ___grabObjectsWaitTime = CompanySettings.GrabObjectsWaitTime.Value; } } [HarmonyPatch(typeof(InteractTrigger), "Start")] [HarmonyPostfix] private static void PatchBellCooldown(InteractTrigger __instance, ref float ___cooldownTime, ref float ___currentCooldownValue) { if (CompanySettings.BellCooldown.Value != (float)CompanySettings.BellCooldown.DefaultValue && !((Object)(object)((Component)__instance).gameObject != (Object)(object)GameObject.Find("BellDinger/Trigger"))) { ___cooldownTime = CompanySettings.BellCooldown.Value; ___currentCooldownValue = ___cooldownTime; } } [HarmonyPatch(typeof(TimeOfDay), "SetBuyingRateForDay")] [HarmonyPostfix] private static void SetBuyingRateForDay() { if (CompanySettings.AlwaysFullBuyingRate.Value) { StartOfRound.Instance.companyBuyingRate = 1f; } } [HarmonyPatch(typeof(DepositItemsDesk), "Attack")] [HarmonyPrefix] private static bool PatchPreAttack(DepositItemsDesk __instance) { if (CompanySettings.SetMonsterAggression.Value == MonsterAggression.OnlyVerbal) { __instance.timeSinceAttacking = 0f; __instance.patienceLevel += 6f; if (!__instance.doorOpen) { __instance.OpenShutDoor(true); } __instance.MakeLoudNoise(2); return false; } return true; } [HarmonyPatch(typeof(DepositItemsDesk), "Update")] [HarmonyPostfix] private static void PatchDepositItems(ref float ___patienceLevel) { if (CompanySettings.SetMonsterAggression.Value == MonsterAggression.NonHostile) { ___patienceLevel = 3f; } } } internal static class CharacterSettings { public static ConfigEntry<bool> ConfigEnabled = UtilsMod.CharacterConfig.Bind("Active Settings", "ConfigEnabled", defaultValue: false, "Whether or not the CharacterConfig executes."); public static ConfigEntry<bool> InfStamina = UtilsMod.CharacterConfig.Bind("Character Settings", "InfStamina", defaultValue: false, "Whether or not the player has infinite stamina."); public static ConfigEntry<bool> FallDamage = UtilsMod.CharacterConfig.Bind("Character Settings", "FallDamage", defaultValue: true, "Whether or not the player takes fall damage."); public static ConfigEntry<bool> ApplyMovementModifiers = UtilsMod.CharacterConfig.Bind("Movement Settings", "ApplyMovementModifiers", defaultValue: false, "Whether or not the Movement Settings apply."); public static ConfigEntry<float> WalkSpeed = UtilsMod.CharacterConfig.Bind("Movement Settings", "WalkSpeed", 4.6f, "Walking speed."); public static ConfigEntry<float> SprintTime = UtilsMod.CharacterConfig.Bind("Movement Settings", "SprintTime", 10f, "Sprint time."); public static ConfigEntry<float> SprintMultiplier = UtilsMod.CharacterConfig.Bind("Movement Settings", "SprintMultiplier", 2.25f, "Sprint walking speed multiplier."); public static ConfigEntry<float> ClimbSpeed = UtilsMod.CharacterConfig.Bind("Movement Settings", "ClimbSpeed", 4f, "Ladder climb speed."); public static ConfigEntry<float> FastClimbTime = UtilsMod.CharacterConfig.Bind("Movement Settings", "FastClimbTime", 10f, "Fast climbing time."); public static ConfigEntry<float> FastClimbMultiplier = UtilsMod.CharacterConfig.Bind("Movement Settings", "FastClimbMultiplier", 1f, "Fast climbing speed multiplier."); public static ConfigEntry<bool> NoJumpDelay = UtilsMod.CharacterConfig.Bind("Movement Settings", "NoJumpDelay", defaultValue: false, "Whether or not the vanilla jump delay is removed."); public static ConfigEntry<float> JumpForce = UtilsMod.CharacterConfig.Bind("Movement Settings", "JumpingForce", 13f, "Jumping force."); public static ConfigEntry<float> JumpStaminaUse = UtilsMod.CharacterConfig.Bind("Movement Settings", "JumpStaminaUse", 0.08f, "How much stamina jumping uses."); } internal class CharacterPatch { private static float PreviousSprintMeter = 1f; [HarmonyPatch(typeof(PlayerControllerB), "Jump_performed")] [HarmonyPrefix] public static void PreJump(PlayerControllerB __instance) { if (CharacterSettings.ApplyMovementModifiers.Value && ((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled) { PreviousSprintMeter = __instance.sprintMeter; __instance.jumpForce = CharacterSettings.JumpForce.Value; } } [HarmonyPatch(typeof(PlayerControllerB), "Jump_performed")] [HarmonyPostfix] public static void PostJump(PlayerControllerB __instance) { if (CharacterSettings.ApplyMovementModifiers.Value && ((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled) { float num = PreviousSprintMeter - __instance.sprintMeter; if (!(num < 0f)) { __instance.sprintMeter = Mathf.Clamp(PreviousSprintMeter + num - CharacterSettings.JumpStaminaUse.Value, 0f, 1f); } } } [HarmonyPatch(typeof(PlayerControllerB), "PlayerJump")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> NoJumpDelayTranspiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = instructions.ToList(); if (!CharacterSettings.ApplyMovementModifiers.Value || !CharacterSettings.NoJumpDelay.Value) { return list; } for (int i = 0; i < list.Count; i++) { if (!(list[i].opcode != OpCodes.Ldc_R4)) { list[i].operand = 0f; } } return list; } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPrefix] private static void PatchPlayerPreUpdate(PlayerControllerB __instance, ref Coroutine ___jumpCoroutine) { if (CharacterSettings.ApplyMovementModifiers.Value && ((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled) { PreviousSprintMeter = __instance.sprintMeter; __instance.sprintTime = CharacterSettings.SprintTime.Value; } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] private static void PatchPlayerUpdate(PlayerControllerB __instance, ref bool ___isWalking, ref float ___sprintMultiplier) { if (!((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled) { return; } if (CharacterSettings.ApplyMovementModifiers.Value) { float num = PreviousSprintMeter - __instance.sprintMeter; if (___isWalking) { float value = CharacterSettings.WalkSpeed.Value; float num2 = (___sprintMultiplier - 1f) / 1.25f; float value2 = CharacterSettings.SprintMultiplier.Value; __instance.movementSpeed = (value + (value2 * value - value) * num2) / ___sprintMultiplier; } if (__instance.isClimbingLadder) { float num3 = CharacterSettings.ClimbSpeed.Value; if (__instance.isSprinting) { __instance.sprintMeter = Mathf.Clamp(PreviousSprintMeter - num * __instance.sprintTime / CharacterSettings.FastClimbTime.Value, 0f, 1f); num3 *= CharacterSettings.FastClimbMultiplier.Value; } if (num3 != 4f) { __instance.climbSpeed = num3; } } } if (CharacterSettings.InfStamina.Value) { __instance.sprintMeter = 1f; } if (!CharacterSettings.FallDamage.Value) { __instance.takingFallDamage = false; } } } internal static class GeneralSettings { public static ConfigEntry<bool> ConfigEnabled = UtilsMod.GeneralConfig.Bind("Active Settings", "ConfigEnabled", defaultValue: false, "Whether or not the GeneralConfig executes."); public static ConfigEntry<int> SaveItemCount = UtilsMod.GeneralConfig.Bind("General Settings", "SaveItemCount", 45, "The amount of items that save."); public static ConfigEntry<bool> PlayBootAnimation = UtilsMod.GeneralConfig.Bind("Active Settings", "PlayBootAnimation", defaultValue: true, "Whether or not to play the booting animation."); } internal class GeneralPatch { [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPostfix] private static void PatchMaxItemCapacity(ref int ___maxShipItemCapacity) { if (GeneralSettings.SaveItemCount.Value != 45) { ___maxShipItemCapacity = GeneralSettings.SaveItemCount.Value; } } [HarmonyPatch(typeof(InitializeGame), "Awake")] [HarmonyPrefix] private static void SkipBoot(ref bool ___runBootUpScreen) { if (!GeneralSettings.PlayBootAnimation.Value) { ___runBootUpScreen = false; } } } internal static class HUDSettings { public static ConfigEntry<bool> ConfigEnabled = UtilsMod.HUDConfig.Bind("Active Settings", "ConfigEnabled", defaultValue: false, "Whether or not the HUDConfig executes."); public static ConfigEntry<bool> BlockPlayerModListLC_API = UtilsMod.HUDConfig.Bind("HUD Settings", "BlockPlayerModListLC_API", defaultValue: false, "Whether or not you want to hide the annoying LC_API mod list every time somebody joins. (Doesn't block the very first when loading a lobby, however.)"); public static ConfigEntry<bool> ViewClockInShip = UtilsMod.HUDConfig.Bind("Clock Settings", "ViewClockInShip", defaultValue: false, "Whether or not people can view the clock inside the ship."); public static ConfigEntry<bool> ViewClockOutside = UtilsMod.HUDConfig.Bind("Clock Settings", "ViewClockOutside", defaultValue: true, "Whether or not people can view the clock outside. (You should make it false and suffer.)"); public static ConfigEntry<bool> ViewClockInBuilding = UtilsMod.HUDConfig.Bind("Clock Settings", "ViewClockInBuilding", defaultValue: false, "Whether or not people can view the clock inside the building."); public static ConfigEntry<ClockType> TimeDisplay = UtilsMod.HUDConfig.Bind("Clock Settings", "TimeDisplay", ClockType.Display12Hour, "How the clock displays time."); } internal class HUDPatch { [HarmonyPatch(typeof(HUDManager), "SetClock")] [HarmonyPrefix] private static bool Patch24HourClock(ref TextMeshProUGUI ___clockNumber, ref float timeNormalized, ref float numberOfHours) { if (HUDSettings.TimeDisplay.Value == ClockType.Display12Hour) { return true; } int num = (int)(timeNormalized * (60f * numberOfHours)) + 360; int num2 = (int)Mathf.Floor((float)(num / 60)); int num3 = num % 60; ((TMP_Text)___clockNumber).text = string.Format("{0:00}{1}{2:00}", num2, (HUDSettings.TimeDisplay.Value == ClockType.Display24Hour) ? ":" : "", num3).TrimStart(new char[1] { '0' }); return false; } [HarmonyPatch(typeof(TimeOfDay), "SetInsideLightingDimness")] [HarmonyPostfix] public static void PatchClockVisibility() { if (HUDSettings.ViewClockInShip.Value || !HUDSettings.ViewClockOutside.Value || HUDSettings.ViewClockInBuilding.Value) { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (!localPlayerController.isPlayerDead) { bool isInsideFactory = localPlayerController.isInsideFactory; bool isInHangarShipRoom = localPlayerController.isInHangarShipRoom; bool clockVisible = (isInsideFactory && HUDSettings.ViewClockInBuilding.Value) || (isInHangarShipRoom && HUDSettings.ViewClockInShip.Value) || (!isInsideFactory && !isInHangarShipRoom && HUDSettings.ViewClockOutside.Value); HUDManager.Instance.SetClockVisible(clockVisible); } } } [HarmonyPatch(typeof(HUDManager), "CanTipDisplay")] [HarmonyPrefix] public static bool CanTipDisplay(string prefsKey, ref bool __result) { if (!HUDSettings.BlockPlayerModListLC_API.Value || !((TMP_Text)HUDManager.Instance.tipsPanelHeader).text.StartsWith("Mod List")) { return true; } __result = false; return false; } } internal static class MultipliersSettings { } internal class MultipliersPatch { [HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")] [HarmonyPrefix] private static void PatchMultiplierSettings(RoundManager __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) MapLevel levelID = (MapLevel)__instance.currentLevel.levelID; LevelWeatherType currentWeather = __instance.currentLevel.currentWeather; if (MapSettings.ConfigEnabled.Value && MapSettings.ScrapModifiersEnabled.Value && MapSettings.Settings.ContainsKey(levelID)) { Dictionary<string, ConfigEntryBase> dictionary = MapSettings.Settings[levelID]; __instance.currentLevel.minScrap = ((ConfigEntry<int>)dictionary["MinScrapAmount"]).Value; __instance.currentLevel.maxScrap = ((ConfigEntry<int>)dictionary["MaxScrapAmount"]).Value; } float num = 1f; float num2 = 0.4f; if (MapSettings.ConfigEnabled.Value && MapSettings.ScrapModifiersEnabled.Value) { num = MapSettings.ScrapAmountScalar.Value; num2 = MapSettings.ScrapValueScalar.Value; if (MapSettings.Settings.ContainsKey(levelID)) { Dictionary<string, ConfigEntryBase> dictionary2 = MapSettings.Settings[levelID]; num *= (dictionary2["ScrapAmountScalar"] as ConfigEntry<float>).Value; num2 *= (dictionary2["ScrapValueScalar"] as ConfigEntry<float>).Value; } } if (WeatherSettings.ConfigEnabled.Value && WeatherSettings.ScrapModifiersEnabled.Value && WeatherSettings.Settings.ContainsKey(currentWeather)) { Dictionary<string, ConfigEntryBase> dictionary3 = WeatherSettings.Settings[currentWeather]; num *= (dictionary3["ScrapAmountScalar"] as ConfigEntry<float>).Value; num2 *= (dictionary3["ScrapValueScalar"] as ConfigEntry<float>).Value; } __instance.scrapAmountMultiplier = num; __instance.scrapValueMultiplier = num2; } [HarmonyPatch(typeof(LungProp), "DisconnectFromMachinery")] [HarmonyPostfix] private static void FixApparatusScrapValMult(LungProp __instance) { ((GrabbableObject)__instance).SetScrapValue((int)((float)((GrabbableObject)__instance).scrapValue * RoundManager.Instance.scrapValueMultiplier / 0.4f)); } } internal static class GearSettings { public static ConfigEntry<bool> ConfigEnabled = UtilsMod.GearConfig.Bind("Active Settings", "ConfigEnabled", defaultValue: false, "Whether or not the GearConfig executes."); public static ConfigEntry<bool> InfFlashlight = UtilsMod.GearConfig.Bind("Flashlight Settings", "InfFlashlight", defaultValue: false, "Whether or not the flashlight has infinite energy."); public static ConfigEntry<bool> InfProFlashlight = UtilsMod.GearConfig.Bind("Flashlight Settings", "InfProFlashlight", defaultValue: false, "Whether or not the pro flashlight has infinite energy."); public static ConfigEntry<bool> InfWalkie = UtilsMod.GearConfig.Bind("Walkie Talkie Settings", "InfWalkie", defaultValue: false, "Whether or not the walkie has infinite energy."); public static ConfigEntry<bool> InfPaint = UtilsMod.GearConfig.Bind("Spray Paint Settings", "InfPaint", defaultValue: false, "Whether or not the spray paint is infinite."); public static ConfigEntry<bool> RequireShaking = UtilsMod.GearConfig.Bind("Spray Paint Settings", "RequireShaking", defaultValue: true, "Whether or not the spray paint needs to be shook."); public static ConfigEntry<float> SprayPaintVolume = UtilsMod.GearConfig.Bind("Spray Paint Settings", "SprayPaintVolume", 1f, "The general volume of the spray paint."); public static ConfigEntry<float> PaintSpeed = UtilsMod.GearConfig.Bind("Spray Paint Settings", "PaintSpeed", 0.2f, "Interval at which the paint decals apply."); public static ConfigEntry<int> MaxPaintDecals = UtilsMod.GearConfig.Bind("Spray Paint Settings", "MaxPaintDecals", 1000, "How many spray paint decals stay at once."); public static ConfigEntry<bool> InfBoombox = UtilsMod.GearConfig.Bind("Boombox Settings", "InfBoombox", defaultValue: false, "Whether or not the boombox has infinite energy."); public static ConfigEntry<bool> PocketBoombox = UtilsMod.GearConfig.Bind("Boombox Settings", "PocketBoombox", defaultValue: false, "Whether or not the boombox continues to play when put away."); public static ConfigEntry<bool> GroundBoombox = UtilsMod.GearConfig.Bind("Boombox Settings", "GroundBoombox", defaultValue: true, "Whether or not the boombox continues to play when thrown down."); public static ConfigEntry<bool> ReusableUnlockKeys = UtilsMod.GearConfig.Bind("Key Settings", "ReusableUnlockKeys", defaultValue: false, "Whether or not the key is reusable for unlocking."); public static ConfigEntry<bool> ReusableLockKeys = UtilsMod.GearConfig.Bind("Key Settings", "ReusableLockKeys", defaultValue: false, "Whether or not the key is reusable for locking."); public static ConfigEntry<bool> KeysCanLockDoors = UtilsMod.GearConfig.Bind("Key Settings", "KeysCanLockDoors", defaultValue: false, "Whether or not the key can lock doors."); } internal class GearPatch { public static bool BoomboxBeingPocketed; [HarmonyPatch(typeof(DoorLock), "UnlockDoor")] [HarmonyPrefix] private static bool PatchUnlockDoor(ref DoorLock __instance, ref bool ___isDoorOpened) { if (__instance.isLocked || !GearSettings.KeysCanLockDoors.Value) { return true; } if (___isDoorOpened) { return false; } __instance.doorLockSFX.PlayOneShot(__instance.unlockSFX); __instance.LockDoor(30f); return false; } [HarmonyPatch(typeof(DoorLock), "Update")] [HarmonyPrefix] private static void PreLockpickDoor(ref DoorLock __instance, ref InteractTrigger ___doorTrigger, out bool __state) { __state = false; if (__instance.isLocked && __instance.isPickingLock && GearSettings.KeysCanLockDoors.Value) { __state = true; __instance.isPickingLock = false; } } [HarmonyPatch(typeof(DoorLock), "Update")] [HarmonyPostfix] private static void PostLockpickDoor(ref DoorLock __instance, ref InteractTrigger ___doorTrigger, bool __state) { if (__state) { DoorLock obj = __instance; obj.lockPickTimeLeft -= Time.deltaTime; ___doorTrigger.disabledHoverTip = $"Picking lock: {(int)__instance.lockPickTimeLeft} sec."; if (((NetworkBehaviour)__instance).IsServer && __instance.lockPickTimeLeft < 0f) { __instance.UnlockDoorServerRpc(); } __instance.isPickingLock = true; } } [HarmonyPatch(typeof(DoorLock), "UnlockDoorSyncWithServer")] [HarmonyPrefix] private static bool UnlockDoorSyncWithServer(ref DoorLock __instance) { if (!GearSettings.KeysCanLockDoors.Value) { return true; } if (__instance.isLocked) { __instance.UnlockDoorServerRpc(); } return false; } [HarmonyPatch(typeof(KeyItem), "ItemActivate")] [HarmonyPrefix] private static bool ItemActivatePatch(ref KeyItem __instance) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (!GearSettings.KeysCanLockDoors.Value) { return true; } PlayerControllerB playerHeldBy = ((GrabbableObject)__instance).playerHeldBy; if (!Object.op_Implicit((Object)(object)playerHeldBy) || !((NetworkBehaviour)__instance).IsOwner) { return false; } RaycastHit val = default(RaycastHit); if (!Physics.Raycast(new Ray(((Component)playerHeldBy.gameplayCamera).transform.position, ((Component)playerHeldBy.gameplayCamera).transform.forward), ref val, 3f, 2816)) { return false; } DoorLock component = ((Component)((RaycastHit)(ref val)).transform).GetComponent<DoorLock>(); if (!Object.op_Implicit((Object)(object)component) || component.isPickingLock) { return false; } if (!component.isLocked && !GearSettings.KeysCanLockDoors.Value) { return false; } component.UnlockDoorServerRpc(); if ((component.isLocked && !GearSettings.ReusableUnlockKeys.Value) || !GearSettings.ReusableLockKeys.Value) { playerHeldBy.DespawnHeldObject(); } return false; } [HarmonyPatch(typeof(WalkieTalkie), "Start")] [HarmonyPostfix] private static void PatchInfWalkie(ref Item ___itemProperties) { if (GearSettings.InfWalkie.Value) { ___itemProperties.requiresBattery = false; } } [HarmonyPatch(typeof(FlashlightItem), "Start")] [HarmonyPostfix] private static void PatchInfFlashlight(ref Item ___itemProperties) { if (!((___itemProperties.itemId == 1) ? (!GearSettings.InfProFlashlight.Value) : (!GearSettings.InfFlashlight.Value))) { ___itemProperties.requiresBattery = false; } } [HarmonyPatch(typeof(SprayPaintItem), "Start")] [HarmonyPostfix] private static void PatchPaintStart(ref Item ___itemProperties, SprayPaintItem __instance) { if (GearSettings.PaintSpeed.Value != 0.2f) { __instance.sprayIntervalSpeed = GearSettings.PaintSpeed.Value; } if (GearSettings.MaxPaintDecals.Value != 1000) { __instance.maxSprayPaintDecals = GearSettings.MaxPaintDecals.Value; } __instance.sprayAudio.volume = GearSettings.SprayPaintVolume.Value; } [HarmonyPatch(typeof(SprayPaintItem), "LateUpdate")] [HarmonyPostfix] private static void PatchInfPaint(ref float ___sprayCanTank, ref float ___sprayCanShakeMeter) { if (GearSettings.InfPaint.Value) { ___sprayCanTank = 1f; } if (!GearSettings.RequireShaking.Value) { ___sprayCanShakeMeter = 1f; } } [HarmonyPatch(typeof(BoomboxItem), "Start")] [HarmonyPostfix] private static void PatchInfBoombox(ref Item ___itemProperties) { if (GearSettings.InfBoombox.Value) { ___itemProperties.requiresBattery = false; } } [HarmonyPatch(typeof(BoomboxItem), "PocketItem")] [HarmonyPrefix] private static void PatchPocketBoombox() { if (GearSettings.PocketBoombox.Value) { BoomboxBeingPocketed = true; } } [HarmonyPatch(typeof(BoomboxItem), "StartMusic")] [HarmonyPrefix] private static bool PatchStartMusic() { if (!GearSettings.PocketBoombox.Value || !BoomboxBeingPocketed) { return true; } BoomboxBeingPocketed = false; return false; } [HarmonyPatch(typeof(PlayerControllerB), "SetObjectAsNoLongerHeld")] [HarmonyPrefix] private static void PatchSetObjectAsNoLongerHeld(ref GrabbableObject dropObject) { if (!GearSettings.GroundBoombox.Value && dropObject is BoomboxItem) { dropObject.ItemActivate(false, true); } } } public enum ItemsOnTPOptions { Drop, DropExceptGear, DropExceptGearAndHeldItem, DropExceptHeldItem, DontDrop } internal static class TeleportSettings { public static ConfigEntry<bool> ConfigEnabled = UtilsMod.TeleportConfig.Bind("Active Settings", "ConfigEnabled", defaultValue: false, "Whether or not the TeleportConfig executes."); public static ConfigEntry<ItemsOnTPOptions> ItemsOnTP = UtilsMod.TeleportConfig.Bind("TP Settings", "ItemsOnTP", ItemsOnTPOptions.Drop, "Whether or not you keep your items upon teleportation."); public static ConfigEntry<int> CooldownTP = UtilsMod.TeleportConfig.Bind("TP Settings", "CooldownTP", 10, "How long until you can use the teleporter."); public static ConfigEntry<ItemsOnTPOptions> ItemsOnInverseTP = UtilsMod.TeleportConfig.Bind("TP Settings", "ItemsOnInverseTP", ItemsOnTPOptions.Drop, "Whether or not you keep your items upon inverse teleportation."); public static ConfigEntry<int> CooldownInverseTP = UtilsMod.TeleportConfig.Bind("TP Settings", "CooldownInverseTP", 210, "How long until you can use the inverse teleporter."); } internal class TeleportPatch { [HarmonyPatch(typeof(ShipTeleporter), "Awake")] [HarmonyPrefix] private static void PostShipTPAwake(ref float ___cooldownAmount, ref float ___cooldownTime, ref bool ___isInverseTeleporter) { int num = (___isInverseTeleporter ? TeleportSettings.CooldownInverseTP.Value : TeleportSettings.CooldownTP.Value); if (!(___isInverseTeleporter ? (num == 210) : (num == 10))) { ___cooldownAmount = num; ___cooldownTime = ___cooldownAmount; } } [HarmonyPatch(typeof(PlayerControllerB), "DropAllHeldItems")] [HarmonyPrefix] private static bool PreDropAllHeldItems(PlayerControllerB __instance, out object[] __state) { __state = new object[6]; GrabbableObject[] array = (GrabbableObject[])(object)new GrabbableObject[__instance.ItemSlots.Length]; __state[0] = array; __state[1] = __instance.isHoldingObject; __state[2] = __instance.activatingItem; __state[3] = __instance.twoHanded; __state[4] = __instance.currentlyHeldObjectServer; __state[5] = false; int shipTeleporterId = __instance.shipTeleporterId; bool flag = shipTeleporterId == 1; bool flag2 = shipTeleporterId == 2; if (!flag && !flag2) { return true; } ItemsOnTPOptions itemsOnTPOptions = (flag2 ? TeleportSettings.ItemsOnInverseTP.Value : TeleportSettings.ItemsOnTP.Value); int num; switch (itemsOnTPOptions) { case ItemsOnTPOptions.Drop: return true; case ItemsOnTPOptions.DontDrop: return false; default: num = ((itemsOnTPOptions == ItemsOnTPOptions.DropExceptGearAndHeldItem) ? 1 : 0); break; case ItemsOnTPOptions.DropExceptHeldItem: num = 1; break; } bool flag3 = (byte)num != 0; bool flag4 = itemsOnTPOptions == ItemsOnTPOptions.DropExceptGear || itemsOnTPOptions == ItemsOnTPOptions.DropExceptGearAndHeldItem; for (int i = 0; i < __instance.ItemSlots.Length; i++) { GrabbableObject val = __instance.ItemSlots[i]; if (Object.op_Implicit((Object)(object)val) && ((flag3 && !val.isPocketed) || (flag4 && (val is ExtensionLadderItem || val is JetpackItem || val is KeyItem || val is RadarBoosterItem || val is RemoteProp || val is BoomboxItem || val is ClipboardItem || val is FlashlightItem || val is LockPicker || val is MapDevice || val is Shovel || val is WalkieTalkie || val is StunGrenadeItem || val is TetraChemicalItem || val is ShotgunItem || val is HauntedMaskItem || val is GunAmmo || val is WhoopieCushionItem || val is SprayPaintItem)))) { if (!val.isPocketed) { flag3 = true; } array[i] = val; __instance.ItemSlots[i] = null; } } __state[5] = flag3; if (flag3) { __instance.isHoldingObject = false; } return true; } [HarmonyPatch(typeof(PlayerControllerB), "DropAllHeldItems")] [HarmonyPostfix] private static void PostDropAllHeldItems(PlayerControllerB __instance, object[] __state) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown GrabbableObject[] array = (GrabbableObject[])__state[0]; float num = 1f; for (int i = 0; i < array.Length; i++) { GrabbableObject val = array[i]; if (Object.op_Implicit((Object)(object)val)) { __instance.ItemSlots[i] = val; array[i] = null; num += Mathf.Clamp(val.itemProperties.weight - 1f, 0f, 10f); } } __instance.carryWeight = num; if ((bool)__state[5]) { __instance.isHoldingObject = (bool)__state[1]; __instance.activatingItem = (bool)__state[2]; __instance.twoHanded = (bool)__state[3]; __instance.currentlyHeldObjectServer = (GrabbableObject)__state[4]; } } [HarmonyPatch(typeof(ShipTeleporter), "TeleportPlayerOutWithInverseTeleporter")] [HarmonyPrefix] private static bool TeleportPlayerOutWithInverseTeleporter(ShipTeleporter __instance, ref int[] ___playersBeingTeleported, int playerObj, Vector3 teleportPos) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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) PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerObj]; if (val.isPlayerDead) { return true; } val.DropAllHeldItems(true, false); val.shipTeleporterId = -1; ___playersBeingTeleported[val.playerClientId] = (int)val.playerClientId; if (Object.op_Implicit((Object)(object)Object.FindObjectOfType<AudioReverbPresets>())) { Object.FindObjectOfType<AudioReverbPresets>().audioPresets[2].ChangeAudioReverbForPlayer(val); } val.isInElevator = false; val.isInHangarShipRoom = false; val.isInsideFactory = true; val.averageVelocity = 0f; val.velocityLastFrame = Vector3.zero; val.TeleportPlayer(teleportPos, false, 0f, false, true); val.beamOutParticle.Play(); __instance.shipTeleporterAudio.PlayOneShot(__instance.teleporterBeamUpSFX); val.movementAudio.PlayOneShot(__instance.teleporterBeamUpSFX); if ((Object)(object)val == (Object)(object)GameNetworkManager.Instance.localPlayerController) { Debug.Log((object)"Teleporter shaking camera"); HUDManager.Instance.ShakeCamera((ScreenShakeType)1); } return false; } } [BepInPlugin("Kyxino.LethalUtils", "LethalUtilities", "1.2.21")] public class UtilsMod : BaseUnityPlugin { public const bool DEBUGGINGMODE = false; private const string ModGUID = "Kyxino.LethalUtils"; private const string ModName = "LethalUtilities"; private const string ModVersion = "1.2.21"; private const string ModWebsite = "https://discord.gg/rzQcgRDQw3"; private const string ModDescription = "(Enemy Spawn Weights FULLY Fixed!) Customize all kinds of things like your gear, sprint, teleporters, map/weather multipliers for spawning and scrap value/amount, and even disable LC_API mod list!"; public static BepInPlugin Metadata = MetadataHelper.GetMetadata(typeof(UtilsMod)); private string[] Dependencies = new string[1] { "BepInEx-BepInExPack-5.4.2100" }; private readonly Harmony harmony = new Harmony("Kyxino.LethalUtils"); public static ManualLogSource MLS; public static ConfigFile GeneralConfig = new ConfigFile(Paths.ConfigPath + "\\LethalUtilities\\GeneralSettings.cfg", saveOnInit: true, Metadata); public static ConfigFile RoundConfig = new ConfigFile(Paths.ConfigPath + "\\LethalUtilities\\RoundSettings.cfg", saveOnInit: true, Metadata); public static ConfigFile CompanyConfig = new ConfigFile(Paths.ConfigPath + "\\LethalUtilities\\CompanySettings.cfg", saveOnInit: true, Metadata); public static ConfigFile HUDConfig = new ConfigFile(Paths.ConfigPath + "\\LethalUtilities\\HUDSettings.cfg", saveOnInit: true, Metadata); public static ConfigFile CharacterConfig = new ConfigFile(Paths.ConfigPath + "\\LethalUtilities\\CharacterSettings.cfg", saveOnInit: true, Metadata); public static ConfigFile TeleportConfig = new ConfigFile(Paths.ConfigPath + "\\LethalUtilities\\TeleportSettings.cfg", saveOnInit: true, Metadata); public static ConfigFile GearConfig = new ConfigFile(Paths.ConfigPath + "\\LethalUtilities\\GearSettings.cfg", saveOnInit: true, Metadata); public static ConfigFile MapConfig = new ConfigFile(Paths.ConfigPath + "\\LethalUtilities\\MapSettings.cfg", saveOnInit: true, Metadata); public static ConfigFile WeatherConfig = new ConfigFile(Paths.ConfigPath + "\\LethalUtilities\\WeatherSettings.cfg", saveOnInit: true, Metadata); public static ConfigFile ShipConfig = new ConfigFile(Paths.ConfigPath + "\\LethalUtilities\\ShipSettings.cfg", saveOnInit: true, Metadata); public static ConfigFile LobbyConfig = new ConfigFile(Paths.ConfigPath + "\\LethalUtilities\\LobbySettings.cfg", saveOnInit: true, Metadata); public static ConfigEntry<string> MODVERSION = GeneralConfig.Bind("Active Settings", "ModVersion", "1.2.21", "Version of the mod from which the configs were saved."); public static ConfigEntry<T> ConfigTransfer<T>(ConfigFile FromConfigFile, ConfigFile ToConfigFile, ConfigDefinition FromDefinition, ConfigDefinition ToDefinition, T DefaultValue, ConfigDescription Description) { ConfigEntry<T> configEntry = FromConfigFile.Bind(FromDefinition, DefaultValue); ConfigEntry<T> configEntry2 = ToConfigFile.Bind(ToDefinition, DefaultValue, Description); if (!configEntry.Value.Equals((T)configEntry.DefaultValue) && configEntry2.Value.Equals((T)configEntry2.DefaultValue)) { configEntry2.Value = configEntry.Value; if (FromConfigFile != ToConfigFile) { ToConfigFile.Save(); } } FromConfigFile.Remove(FromDefinition); FromConfigFile.Save(); return configEntry2; } public static ConfigEntry<T> ConfigTransfer<T>(ConfigFile FromConfigFile, ConfigFile ToConfigFile, string FromCategory, string FromVariable, string ToCategory, string ToVariable, T DefaultValue, string Description) { return ConfigTransfer(FromConfigFile, ToConfigFile, new ConfigDefinition(FromCategory, FromVariable), new ConfigDefinition(ToCategory, ToVariable), DefaultValue, new ConfigDescription(Description, null)); } public static ConfigEntry<T> ConfigTransfer<T>(ConfigFile ConfigFile, string FromCategory, string FromVariable, string ToCategory, string ToVariable, T DefaultValue, string Description) { return ConfigTransfer(ConfigFile, ConfigFile, new ConfigDefinition(FromCategory, FromVariable), new ConfigDefinition(ToCategory, ToVariable), DefaultValue, new ConfigDescription(Description, null)); } public static ConfigEntry<T> ConfigTransfer<T>(ConfigFile ConfigFile, ConfigDefinition FromDefinition, ConfigDefinition ToDefinition, T DefaultValue, string Description) { return ConfigTransfer(ConfigFile, ConfigFile, FromDefinition, ToDefinition, DefaultValue, new ConfigDescription(Description, null)); } public static ConfigEntry<T> ConfigTransfer<T>(ConfigFile ConfigFile, string Category, string FromVariable, string ToVariable, T DefaultValue, string Description) { return ConfigTransfer(ConfigFile, ConfigFile, new ConfigDefinition(Category, FromVariable), new ConfigDefinition(Category, ToVariable), DefaultValue, new ConfigDescription(Description, null)); } private void Awake() { MLS = Logger.CreateLogSource("Kyxino.LethalUtils"); bool flag = false; if (Directory.Exists(Paths.PluginPath + "\\kyxino-LethalUtilities\\config")) { Directory.Delete(Paths.PluginPath + "\\kyxino-LethalUtilities\\config", recursive: true); } MLS.LogInfo((object)"Loading all settings."); MLS.LogInfo((object)"YEEEEEEEET"); if (GeneralSettings.ConfigEnabled.Value) { harmony.PatchAll(typeof(GeneralPatch)); } if (RoundSettings.ConfigEnabled.Value) { harmony.PatchAll(typeof(RoundPatch)); } if (CompanySettings.ConfigEnabled.Value) { harmony.PatchAll(typeof(CompanyPatch)); } if (HUDSettings.ConfigEnabled.Value) { harmony.PatchAll(typeof(HUDPatch)); } if (CharacterSettings.ConfigEnabled.Value) { harmony.PatchAll(typeof(CharacterPatch)); } if (TeleportSettings.ConfigEnabled.Value) { harmony.PatchAll(typeof(TeleportPatch)); } if (GearSettings.ConfigEnabled.Value) { harmony.PatchAll(typeof(GearPatch)); } if (MapSettings.ConfigEnabled.Value || WeatherSettings.ConfigEnabled.Value) { if (MapSettings.ScrapModifiersEnabled.Value || WeatherSettings.ScrapModifiersEnabled.Value) { harmony.PatchAll(typeof(MultipliersPatch)); } if (MapSettings.MapModifiersEnabled.Value || WeatherSettings.MapModifiersEnabled.Value) { harmony.PatchAll(typeof(MapPatch)); } if (MapSettings.TimeModifiersEnabled.Value || WeatherSettings.TimeModifiersEnabled.Value) { harmony.PatchAll(typeof(TimePatch)); } if (MapSettings.SpawnModifiersEnabled.Value || WeatherSettings.SpawnModifiersEnabled.Value) { harmony.PatchAll(typeof(SpawnPatch)); } } if (ShipSettings.ConfigEnabled.Value) { harmony.PatchAll(typeof(ShipPatch)); } if (LobbySettings.ConfigEnabled.Value) { harmony.PatchAll(typeof(LobbyPatch)); } MLS.LogInfo((object)"All enabled patches have been executed."); GeneralConfig.Bind("Active Settings", "ModVersion", "1.2.21", "Version of the mod from which the configs were saved.").Value = "1.2.21"; GeneralConfig.Save(); MLS.LogInfo((object)"Saved mod version to GeneralConfig."); } } } namespace LethalUtilities.Configuration { public sealed class SettingChangedEventArgs : EventArgs { public ConfigEntryBase ChangedSetting { get; } public SettingChangedEventArgs(ConfigEntryBase cha