Decompiled source of StarLevelSystem v0.14.2
plugins/StarLevelSystem.dll
Decompiled 9 hours 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.ComponentModel; 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.Serialization; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Versioning; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using Jotunn; using Jotunn.Entities; using Jotunn.Extensions; using Jotunn.Managers; using Jotunn.Utils; using MonoMod.Utils; using SimpleJson; using StarLevelSystem.Data; using StarLevelSystem.common; using StarLevelSystem.modules; using TMPro; using UnityEngine; using UnityEngine.UI; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("StarLevelSystem")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("StarLevelSystem")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("0.14.1")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.14.1.0")] namespace StarLevelSystem { [PublicAPI] public static class API { private static readonly Type APIReciever; private static readonly MethodInfo UpdateCreatureLevel; private static readonly MethodInfo UpdateCreatureColorization; private static readonly MethodInfo GetBaseAttributeValue; private static readonly MethodInfo UpdateCreatureBaseAttributes; private static readonly MethodInfo GetAllBaseAttributeValues; private static readonly MethodInfo SetAllBaseAttributeValues; private static readonly MethodInfo GetPerLevelAttributeValue; private static readonly MethodInfo UpdateCreaturePerLevelAttributes; private static readonly MethodInfo GetAllPerLevelAttributeValues; private static readonly MethodInfo SetAllPerLevelAttributeValues; private static readonly MethodInfo GetCreatureDamageRecievedModifier; private static readonly MethodInfo UpdateCreatureDamageRecievedModifier; private static readonly MethodInfo GetAllDamageRecievedModifiers; private static readonly MethodInfo SetAllDamageRecievedModifiers; private static readonly MethodInfo GetCreatureDamageBonus; private static readonly MethodInfo UpdateCreatureDamageBonus; private static readonly MethodInfo GetAllDamageBonus; private static readonly MethodInfo SetAllDamageBonus; private static readonly MethodInfo ApplyUpdatesToCreature; private static readonly MethodInfo GetPossibleModifiersForType; private static readonly MethodInfo GetAllModifiersForCreature; private static readonly MethodInfo AddModifierToCreature; private static readonly MethodInfo AddNewModifierToSLS; public static bool IsAvailable => APIReciever != null; static API() { APIReciever = Type.GetType("StarLevelSystem.modules.APIReciever, StarLevelSystem"); UpdateCreatureLevel = APIReciever.GetMethod("UpdateCreatureLevel", BindingFlags.Static | BindingFlags.Public); UpdateCreatureColorization = APIReciever.GetMethod("UpdateCreatureColorization", BindingFlags.Static | BindingFlags.Public); GetBaseAttributeValue = APIReciever.GetMethod("GetBaseAttributeValue", BindingFlags.Static | BindingFlags.Public); UpdateCreatureBaseAttributes = APIReciever.GetMethod("UpdateCreatureBaseAttributes", BindingFlags.Static | BindingFlags.Public); GetAllBaseAttributeValues = APIReciever.GetMethod("GetAllBaseAttributeValues", BindingFlags.Static | BindingFlags.Public); SetAllBaseAttributeValues = APIReciever.GetMethod("SetAllBaseAttributeValues", BindingFlags.Static | BindingFlags.Public); GetPerLevelAttributeValue = APIReciever.GetMethod("GetPerLevelAttributeValue", BindingFlags.Static | BindingFlags.Public); UpdateCreaturePerLevelAttributes = APIReciever.GetMethod("UpdateCreaturePerLevelAttributes", BindingFlags.Static | BindingFlags.Public); GetAllPerLevelAttributeValues = APIReciever.GetMethod("GetAllPerLevelAttributeValues", BindingFlags.Static | BindingFlags.Public); SetAllPerLevelAttributeValues = APIReciever.GetMethod("SetAllPerLevelAttributeValues", BindingFlags.Static | BindingFlags.Public); GetCreatureDamageRecievedModifier = APIReciever.GetMethod("GetCreatureDamageRecievedModifier", BindingFlags.Static | BindingFlags.Public); UpdateCreatureDamageRecievedModifier = APIReciever.GetMethod("UpdateCreatureDamageRecievedModifier", BindingFlags.Static | BindingFlags.Public); GetAllDamageRecievedModifiers = APIReciever.GetMethod("GetAllDamageRecievedModifiers", BindingFlags.Static | BindingFlags.Public); SetAllDamageRecievedModifiers = APIReciever.GetMethod("SetAllDamageRecievedModifiers", BindingFlags.Static | BindingFlags.Public); GetCreatureDamageBonus = APIReciever.GetMethod("GetCreatureDamageBonus", BindingFlags.Static | BindingFlags.Public); UpdateCreatureDamageBonus = APIReciever.GetMethod("UpdateCreatureDamageBonus", BindingFlags.Static | BindingFlags.Public); GetAllDamageBonus = APIReciever.GetMethod("GetAllDamageBonus", BindingFlags.Static | BindingFlags.Public); SetAllDamageBonus = APIReciever.GetMethod("SetAllDamageBonus", BindingFlags.Static | BindingFlags.Public); ApplyUpdatesToCreature = APIReciever.GetMethod("ApplyUpdatesToCreature", BindingFlags.Static | BindingFlags.Public); GetPossibleModifiersForType = APIReciever.GetMethod("GetPossibleModifiersForType", BindingFlags.Static | BindingFlags.Public); GetAllModifiersForCreature = APIReciever.GetMethod("GetAllModifiersForCreature", BindingFlags.Static | BindingFlags.Public); AddModifierToCreature = APIReciever.GetMethod("AddModifierToCreature", BindingFlags.Static | BindingFlags.Public); AddNewModifierToSLS = APIReciever.GetMethod("AddNewModifierToSLS", BindingFlags.Static | BindingFlags.Public); } public static bool SetCreatureLevel(Character creatureId, int newLevel) { return (bool)UpdateCreatureLevel.Invoke(null, new object[2] { creatureId, newLevel }); } public static bool SetCreatureColorization(Character creatureId, float value, float hue, float sat, bool emission = false) { return (bool)UpdateCreatureColorization.Invoke(null, new object[5] { creatureId, value, hue, sat, emission }); } public static float GetCreatureBaseAttribute(Character creatureId, int attribute) { return (float)GetBaseAttributeValue.Invoke(null, new object[2] { creatureId, attribute }); } public static bool SetCreatureBaseAttribute(Character creatureId, int attribute, float value) { return (bool)UpdateCreatureBaseAttributes.Invoke(null, new object[3] { creatureId, attribute, value }); } public static Dictionary<int, float> GetAllCreatureBaseAttributes(Character creatureId) { return (Dictionary<int, float>)GetAllBaseAttributeValues.Invoke(null, new object[1] { creatureId }); } public static bool SetAllCreatureBaseAttributes(Character creatureId, Dictionary<int, float> attributes) { return (bool)SetAllBaseAttributeValues.Invoke(null, new object[2] { creatureId, attributes }); } public static float GetCreaturePerLevelAttribute(Character creatureId, int attribute) { return (float)GetPerLevelAttributeValue.Invoke(null, new object[2] { creatureId, attribute }); } public static bool SetCreaturePerLevelAttribute(Character creatureId, int attribute, float value) { return (bool)UpdateCreaturePerLevelAttributes.Invoke(null, new object[3] { creatureId, attribute, value }); } public static Dictionary<int, float> GetAllCreaturePerLevelAttributes(Character creatureId) { return (Dictionary<int, float>)GetAllPerLevelAttributeValues.Invoke(null, new object[1] { creatureId }); } public static bool SetAllCreaturePerLevelAttributes(Character creatureId, Dictionary<int, float> attributes) { return (bool)SetAllPerLevelAttributeValues.Invoke(null, new object[2] { creatureId, attributes }); } public static float GetCreatureDamageReceivedModifier(Character creatureId, int damageType) { return (float)GetCreatureDamageRecievedModifier.Invoke(null, new object[2] { creatureId, damageType }); } public static bool SetCreatureDamageReceivedModifier(Character creatureId, int damageType, float value) { return (bool)UpdateCreatureDamageRecievedModifier.Invoke(null, new object[3] { creatureId, damageType, value }); } public static Dictionary<int, float> GetAllCreatureDamageReceivedModifiers(Character creatureId) { return (Dictionary<int, float>)GetAllDamageRecievedModifiers.Invoke(null, new object[1] { creatureId }); } public static bool SetAllCreatureDamageReceivedModifiers(Character creatureId, Dictionary<int, float> attributes) { return (bool)SetAllDamageRecievedModifiers.Invoke(null, new object[2] { creatureId, attributes }); } public static float GetCreatureFlatDamageBonus(Character creatureId, int damageType) { return (float)GetCreatureDamageBonus.Invoke(null, new object[2] { creatureId, damageType }); } public static bool SetCreatureFlatDamageBonus(Character creatureId, int damageType, float value) { return (bool)UpdateCreatureDamageBonus.Invoke(null, new object[3] { creatureId, damageType, value }); } public static Dictionary<int, float> GetAllCreatureFlatDamageBonuses(Character creatureId) { return (Dictionary<int, float>)GetAllDamageBonus.Invoke(null, new object[1] { creatureId }); } public static bool SetAllCreatureFlatDamageBonuses(Character creatureId, Dictionary<int, float> attributes) { return (bool)SetAllDamageBonus.Invoke(null, new object[2] { creatureId, attributes }); } public static bool ApplyCreatureUpdates(Character creatureId) { return (bool)ApplyUpdatesToCreature.Invoke(null, new object[1] { creatureId }); } public static List<string> GetPossibleModifiers(int modType = 0) { return (List<string>)GetPossibleModifiersForType.Invoke(null, new object[1] { modType }); } public static Dictionary<string, int> GetCreaturesModifiers(Character creatureId) { return (Dictionary<string, int>)GetAllModifiersForCreature.Invoke(null, new object[1] { creatureId }); } public static bool AddModifierToTargetCreature(Character creatureId, string modifierName, int modifierType, bool update = true) { return (bool)AddModifierToCreature.Invoke(null, new object[4] { creatureId, modifierName, modifierType, update }); } public static bool AddNewModifier(int modifierID, string modifier_name, string setupMethod = null, float selectionWeight = 10f, float basepower = 0f, float perlevelpower = 0f, Dictionary<Biome, List<string>> biomeConfig = null, int namingStyle = 2, string name_suffixes = null, string name_prefixes = null, int visualStyle = 0, Sprite starIcon = null, GameObject visualEffect = null, List<string> allowed_creatures = null, List<string> unallowed_creatures = null, List<Biome> allowed_biomes = null) { return (bool)AddNewModifierToSLS.Invoke(null, new object[16] { modifierID, modifier_name, setupMethod, selectionWeight, basepower, perlevelpower, biomeConfig, namingStyle, name_suffixes, name_prefixes, visualStyle, starIcon, visualEffect, allowed_creatures, unallowed_creatures, allowed_biomes }); } } internal class ValConfig { [CompilerGenerated] private sealed class <OnClientReceiveColorConfigs>d__83 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ZPackage package; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <OnClientReceiveColorConfigs>d__83(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; Colorization.UpdateYamlConfig(package.ReadString()); <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <OnClientReceiveCreatureLootConfigs>d__84 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ZPackage package; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <OnClientReceiveCreatureLootConfigs>d__84(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; LootSystemData.UpdateYamlConfig(package.ReadString()); <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <OnClientReceiveLevelConfigs>d__82 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ZPackage package; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <OnClientReceiveLevelConfigs>d__82(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; LevelSystemData.UpdateYamlConfig(package.ReadString()); <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <OnClientReceiveModifiersConfigs>d__85 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ZPackage package; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <OnClientReceiveModifiersConfigs>d__85(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; CreatureModifiersData.UpdateModifierConfig(package.ReadString()); <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <OnServerRecieveConfigs>d__81 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <OnServerRecieveConfigs>d__81(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; Logger.LogDebug("Server recieved config from client, rejecting due to being the server."); <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static ConfigFile cfg; internal static string levelsFilePath = Path.Combine(Paths.ConfigPath, "StarLevelSystem", "LevelSettings.yaml"); internal static string colorsFilePath = Path.Combine(Paths.ConfigPath, "StarLevelSystem", "ColorSettings.yaml"); internal static string creatureLootFilePath = Path.Combine(Paths.ConfigPath, "StarLevelSystem", "CreatureLootSettings.yaml"); internal static string creatureModifierFilePath = Path.Combine(Paths.ConfigPath, "StarLevelSystem", "Modifiers.yaml"); private static CustomRPC LevelSettingsRPC; private static CustomRPC ColorSettingsRPC; private static CustomRPC CreatureLootSettingsRPC; private static CustomRPC ModifiersRPC; public static ConfigEntry<bool> EnableDebugMode; public static ConfigEntry<int> MaxLevel; public static ConfigEntry<bool> OverlevedCreaturesGetRerolledOnLoad; public static ConfigEntry<bool> EnableMapRingsForDistanceBonus; public static ConfigEntry<bool> DistanceBonusIsFromStarterTemple; public static ConfigEntry<int> MiniMapRingGeneratorUpdatesPerFrame; public static ConfigEntry<string> DistanceRingColorOptions; public static ConfigEntry<bool> ControlSpawnerLevels; public static ConfigEntry<bool> ForceControlAllSpawns; public static ConfigEntry<string> SpawnsAlwaysControlled; public static ConfigEntry<bool> ControlBossSpawns; public static ConfigEntry<bool> ControlAbilitySpawnedCreatures; public static ConfigEntry<bool> EnableCreatureScalingPerLevel; public static ConfigEntry<bool> EnableScalingInDungeons; public static ConfigEntry<float> PerLevelScaleBonus; public static ConfigEntry<float> PerLevelLootScale; public static ConfigEntry<int> LootDropsPerTick; public static ConfigEntry<string> LootDropCalculationType; public static ConfigEntry<float> EnemyHealthMultiplier; public static ConfigEntry<float> BossEnemyHealthMultiplier; public static ConfigEntry<float> EnemyHealthPerWorldLevel; public static ConfigEntry<float> EnemyDamageLevelMultiplier; public static ConfigEntry<float> BossEnemyDamageMultiplier; public static ConfigEntry<bool> EnableScalingBirds; public static ConfigEntry<float> BirdSizeScalePerLevel; public static ConfigEntry<bool> EnableScalingFish; public static ConfigEntry<float> FishSizeScalePerLevel; public static ConfigEntry<bool> EnableTreeScaling; public static ConfigEntry<float> TreeSizeScalePerLevel; public static ConfigEntry<bool> UseDeterministicTreeScaling; public static ConfigEntry<bool> RandomizeTameChildrenLevels; public static ConfigEntry<bool> RandomizeTameChildrenModifiers; public static ConfigEntry<bool> SpawnMultiplicationAppliesToTames; public static ConfigEntry<bool> BossCreaturesNeverSpawnMultiply; public static ConfigEntry<bool> EnableColorization; public static ConfigEntry<float> PerLevelTreeLootScale; public static ConfigEntry<float> PerLevelBirdLootScale; public static ConfigEntry<int> FishMaxLevel; public static ConfigEntry<int> BirdMaxLevel; public static ConfigEntry<int> TreeMaxLevel; public static ConfigEntry<int> MaxMajorModifiersPerCreature; public static ConfigEntry<int> MaxMinorModifiersPerCreature; public static ConfigEntry<bool> LimitCreatureModifiersToCreatureStarLevel; public static ConfigEntry<float> ChanceMajorModifier; public static ConfigEntry<float> ChanceMinorModifier; public static ConfigEntry<bool> EnableBossModifiers; public static ConfigEntry<float> ChanceOfBossModifier; public static ConfigEntry<int> MaxBossModifiersPerBoss; public static ConfigEntry<bool> SplittersInheritLevel; public static ConfigEntry<int> LimitCreatureModifierPrefixes; public static ConfigEntry<bool> EnableDistanceLevelScalingBonus; public static ConfigEntry<bool> EnableMultiplayerEnemyHealthScaling; public static ConfigEntry<bool> EnableMultiplayerEnemyDamageScaling; public static ConfigEntry<int> MultiplayerScalingRequiredPlayersNearby; public static ConfigEntry<float> MultiplayerEnemyDamageModifier; public static ConfigEntry<float> MultiplayerEnemyHealthModifier; public static ConfigEntry<int> NumberOfCacheUpdatesPerFrame; public static ConfigEntry<bool> OutputColorizationGeneratorsData; public static ConfigEntry<int> FallbackDelayBeforeCreatureSetup; public static ConfigEntry<float> InitialDelayBeforeSetup; public static ConfigEntry<bool> EnableDebugOutputForDamage; public ValConfig(ConfigFile cf) { cfg = cf; cfg.SaveOnConfigSet = true; CreateConfigValues(cf); } public void SetupConfigRPCs() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0027: Expected O, but got Unknown //IL_003d: 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_0053: Expected O, but got Unknown //IL_0053: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_007f: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00ab: Expected O, but got Unknown LevelSettingsRPC = NetworkManager.Instance.AddRPC("SLS_LevelsRPC", new CoroutineHandler(OnServerRecieveConfigs), new CoroutineHandler(OnClientReceiveLevelConfigs)); ColorSettingsRPC = NetworkManager.Instance.AddRPC("SLS_ColorsRPC", new CoroutineHandler(OnServerRecieveConfigs), new CoroutineHandler(OnClientReceiveColorConfigs)); CreatureLootSettingsRPC = NetworkManager.Instance.AddRPC("SLS_CreatureLootRPC", new CoroutineHandler(OnServerRecieveConfigs), new CoroutineHandler(OnClientReceiveCreatureLootConfigs)); ModifiersRPC = NetworkManager.Instance.AddRPC("SLS_ModifiersRPC", new CoroutineHandler(OnServerRecieveConfigs), new CoroutineHandler(OnClientReceiveModifiersConfigs)); SynchronizationManager.Instance.AddInitialSynchronization(LevelSettingsRPC, (Func<ZPackage>)SendLevelsConfigs); SynchronizationManager.Instance.AddInitialSynchronization(ColorSettingsRPC, (Func<ZPackage>)SendColorsConfigs); SynchronizationManager.Instance.AddInitialSynchronization(CreatureLootSettingsRPC, (Func<ZPackage>)SendCreatureLootConfigs); SynchronizationManager.Instance.AddInitialSynchronization(ModifiersRPC, (Func<ZPackage>)SendModifierConfigs); } private void CreateConfigValues(ConfigFile Config) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown EnableDebugMode = Config.Bind<bool>("Client config", "EnableDebugMode", false, new ConfigDescription("Enables Debug logging.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdvanced = true } })); EnableDebugMode.SettingChanged += Logger.enableDebugLogging; Logger.CheckEnableDebugLogging(); EnableDebugOutputForDamage = Config.Bind<bool>("Client config", "EnableDebugOutputForDamage", false, new ConfigDescription("Enables Detailed logging for damage calculations, warning, lots of logging.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdvanced = true } })); MaxLevel = BindServerConfig("LevelSystem", "MaxLevel", 20, "The Maximum number of stars that a creature can have", advanced: false, 1, 200); MaxLevel.SettingChanged += LevelSystem.ModifyLoadedCreatureLevels; OverlevedCreaturesGetRerolledOnLoad = BindServerConfig("LevelSystem", "OverlevedCreaturesGetRerolledOnLoad", value: true, "Rerolls creature levels which are above maximum defined level, when those creatures are loaded. This will automatically clean up overleveled creatures if you reduce the max level."); EnableCreatureScalingPerLevel = BindServerConfig("LevelSystem", "EnableCreatureScalingPerLevel", value: true, "Enables started creatures to get larger for each star"); EnableDistanceLevelScalingBonus = BindServerConfig("LevelSystem", "EnableDistanceLevelScalingBonus", value: true, "Creatures further away from the center of the world have a higher chance to levelup, this is a bonus applied to existing creature/biome configuration."); EnableMapRingsForDistanceBonus = BindServerConfig("LevelSystem", "EnableMapRingsForDistanceBonus", value: true, "Enables map rings to show distance levels, this is a visual aid to help you see how far away from the center of the world you are."); EnableMapRingsForDistanceBonus.SettingChanged += LevelSystem.UpdateMapRingEnableSettingOnChange; DistanceBonusIsFromStarterTemple = BindServerConfig("LevelSystem", "DistanceBonusIsFromStarterTemple", value: false, "When enabled the distance bonus is calculated from the starter temple instead of world center, typically this makes little difference. But can help ensure your starting area is more correctly calculated."); DistanceBonusIsFromStarterTemple.SettingChanged += LevelSystem.OnRingCenterChanged; DistanceRingColorOptions = BindServerConfig("LevelSystem", "DistanceRingColorOptions", "White,Blue,Teal,Green,Yellow,Purple,Orange,Pink,Purple,Red,Grey", "The colors that distance rings will use, if there are more rings than colors, the color pattern will be repeated. (Optional, use an HTML hex color starting with # to have a custom color.) Available options: Red, Orange, Yellow, Green, Teal, Blue, Purple, Pink, Gray, Brown, Black"); DistanceRingColorOptions.SettingChanged += LevelSystem.UpdateMapColorSettingsOnChange; MiniMapRingGeneratorUpdatesPerFrame = BindServerConfig("LevelSystem", "MiniMapRingGeneratorUpdatesPerFrame", 1000, "The number of ring points to calculate per frame when generating the minimap rings. Higher values make this go faster, but can get it killed or cause instability.", advanced: true); PerLevelScaleBonus = BindServerConfig("LevelSystem", "PerLevelScaleBonus", 0.1f, "The additional size that a creature grows each star level.", advanced: true, 0f, 2f); PerLevelScaleBonus.SettingChanged += Colorization.StarLevelScaleChanged; EnableScalingInDungeons = BindServerConfig("LevelSystem", "EnableScalingInDungeons", value: false, "Enables scaling in dungeons, this can cause creatures to become stuck."); EnableColorization = BindServerConfig("LevelSystem", "EnableColorization", value: true, "Enables this mods colorization of creatures based on their star level."); EnemyHealthMultiplier = BindServerConfig("LevelSystem", "EnemyHealthMultiplier", 1f, "The amount of health that each level gives a creature, vanilla is 1x.", advanced: false, 0f, 5f); EnemyHealthPerWorldLevel = BindServerConfig("LevelSystem", "EnemyHealthPerWorldLevel", 0.2f, "The percent amount of health that each world level gives a creature, vanilla is 2x (eg 200% more health each world level).", advanced: false, 0f, 2f); EnemyDamageLevelMultiplier = BindServerConfig("LevelSystem", "EnemyDamageLevelMultiplier", 0.1f, "The amount of damage that each level gives a creatures, vanilla is 0.5x (eg 50% more damage each level).", advanced: false, 0f, 2f); BossEnemyHealthMultiplier = BindServerConfig("LevelSystem", "BossEnemyHealthMultiplier", 0.3f, "The amount of health that each level gives a boss. 1 is 100% more health per level.", advanced: false, 0f, 5f); BossEnemyDamageMultiplier = BindServerConfig("LevelSystem", "BossEnemyDamageMultiplier", 0.02f, "The amount of damage that each level gives a boss. 1 is 100% more damage per level.", advanced: false, 0f, 5f); RandomizeTameChildrenLevels = BindServerConfig("LevelSystem", "RandomizeTameLevels", value: false, "Randomly rolls bred creature levels, instead of inheriting from parent."); RandomizeTameChildrenModifiers = BindServerConfig("LevelSystem", "RandomizeTameChildrenModifiers", value: true, "Randomly rolls bred creatures modifiers instead of inheriting from a parent"); SpawnMultiplicationAppliesToTames = BindServerConfig("LevelSystem", "SpawnMultiplicationAppliesToTames", value: false, "Spawn multipliers set on creature or biome will apply to produced tames when enabled."); BossCreaturesNeverSpawnMultiply = BindServerConfig("LevelSystem", "BossCreaturesNeverSpawnMultiply", value: true, "Boss creatures never have spawn multipliers applied to them."); EnableScalingBirds = BindServerConfig("ObjectLevels", "EnableScalingBirds", value: true, "Enables birds to scale with the level system. This will cause them to become larger and give more drops."); EnableScalingBirds.SettingChanged += LevelSystem.UpdateBirdSizeOnConfigChange; BirdSizeScalePerLevel = BindServerConfig("ObjectLevels", "BirdSizeScalePerLevel", 0.1f, "The amount of size that birds gain per level. 0.1 = 10% larger per level.", advanced: true, 0f, 2f); BirdSizeScalePerLevel.SettingChanged += LevelSystem.UpdateBirdSizeOnConfigChange; EnableScalingFish = BindServerConfig("ObjectLevels", "EnableScalingFish", value: true, "Enables star scaling for fish. This does potentially allow huge fish."); EnableScalingFish.SettingChanged += LevelSystem.UpdateFishSizeOnConfigChange; FishMaxLevel = BindServerConfig("ObjectLevels", "FishMaxLevel", 20, "Sets the max level that fish can scale up to.", advanced: true, 1); BirdMaxLevel = BindServerConfig("ObjectLevels", "BirdMaxLevel", 10, "Sets the max level that fish can scale up to.", advanced: true, 1); TreeMaxLevel = BindServerConfig("ObjectLevels", "TreeMaxLevel", 10, "Sets the max level that fish can scale up to.", advanced: true, 1); FishSizeScalePerLevel = BindServerConfig("ObjectLevels", "FishSizeScalePerLevel", 0.1f, "The amount of size that fish gain per level 0.1 = 10% larger per level."); FishSizeScalePerLevel.SettingChanged += LevelSystem.UpdateFishSizeOnConfigChange; EnableTreeScaling = BindServerConfig("ObjectLevels", "EnableTreeScaling", value: true, "Enables level scaling of trees. Make the trees bigger than reasonable? sure why not."); EnableTreeScaling.SettingChanged += LevelSystem.UpdateTreeSizeOnConfigChange; UseDeterministicTreeScaling = BindServerConfig("ObjectLevels", "UseDeterministicTreeScaling", value: true, "Scales the level of trees based on biome and distance from the center/spawn. This does not randomize tree levels, but reduces network usage."); TreeSizeScalePerLevel = BindServerConfig("ObjectLevels", "TreeSizeScalePerLevel", 0.1f, "The amount of size that trees gain per level 0.1 = 10% larger per level."); TreeSizeScalePerLevel.SettingChanged += LevelSystem.UpdateTreeSizeOnConfigChange; PerLevelTreeLootScale = BindServerConfig("ObjectLevels", "PerLevelTreeLootScale", 0.2f, "The amount of additional wood that each level grants for a tree.", advanced: true); PerLevelBirdLootScale = BindServerConfig("ObjectLevels", "PerLevelBirdLootScale", 0.3f, "Per level additional loot that birds gain.", advanced: true); MultiplayerEnemyDamageModifier = BindServerConfig("Multiplayer", "MultiplayerEnemyDamageModifier", 0.05f, "The additional amount of damage enemies will do to players, when there is a group of players together, per player. .2 = 20%. Vanilla gives creatures 4% more damage per player nearby.", advanced: true, 0f, 2f); MultiplayerEnemyHealthModifier = BindServerConfig("Multiplayer", "MultiplayerEnemyHealthModifier", 0.2f, "Enemies take reduced damage when there is a group of players, vanilla gives creatures 30% damage resistance per player nearby.", advanced: true, 0f, 0.99f); MultiplayerScalingRequiredPlayersNearby = BindServerConfig("Multiplayer", "MultiplayerScalingRequiredPlayersNearby", 3, "The number of players in a local area required to cause monsters to gain bonus health and/or damage.", advanced: true, 1, 20); EnableMultiplayerEnemyHealthScaling = BindServerConfig("Multiplayer", "EnableMultiplayerEnemyHealthScaling", value: true, "Wether or not creatures gain more health when players are grouped up."); EnableMultiplayerEnemyDamageScaling = BindServerConfig("Multiplayer", "EnableMultiplayerEnemyDamageScaling", value: false, "Wether or not creatures gain more damage when players are grouped up."); ControlSpawnerLevels = BindServerConfig("LevelSystem", "ControlSpawnerLevels", value: true, "Overrides spawner levels to be controlled by SLS (this impacts all naturally spawning creatures)"); ControlAbilitySpawnedCreatures = BindServerConfig("LevelSystem", "ControlAbilitySpawnedCreatures", value: true, "Forces creatures spawned from abilities to be controlled by SLS. This primarily impacts things such as the roots from Elder."); ControlBossSpawns = BindServerConfig("LevelSystem", "ControlBossSpawns", value: true, "Forces boss creatures to be controlled by SLS. Bosses will not get star levels if this is disabled."); ForceControlAllSpawns = BindServerConfig("LevelSystem", "ForceControlAllSpawns", value: false, "Forces all creatures to be controlled by SLS, this includes creatures spawned from player abilities and items. This will override creature levels, other mods must use the API to ensure their spawned creature levels are set."); SpawnsAlwaysControlled = BindServerConfig("LevelSystem", "SpawnsAlwaysControlled", "piece_TrainingDummy", "A list of creatures which always get their level set"); SpawnsAlwaysControlled.SettingChanged += ModificationExtensionSystem.LeveledCreatureListChanged; ModificationExtensionSystem.SetupForceLeveledCreatureList(); PerLevelLootScale = BindServerConfig("LootSystem", "PerLevelLootScale", 1f, "The amount of additional loot that a creature provides per each star level", advanced: false, 0f, 4f); LootDropCalculationType = BindServerConfig("LootSystem", "LootDropCaluationType", "PerLevel", "The type of loot calculation to use. Per Level ", LootLevelsExpanded.AllowedLootFactors); LootDropCalculationType.SettingChanged += LootLevelsExpanded.LootFactorChanged; LootDropsPerTick = BindServerConfig("LootSystem", "LootDropsPerTick", 20, "The number of loot drops that are generated per tick, reducing this will reduce lag when massive amounts of loot is generated at once.", advanced: true, 1, 100); MaxMajorModifiersPerCreature = BindServerConfig("Modifiers", "MaxMajorModifiersPerCreature", 1, "The default number of major modifiers that a creature can have."); MaxMinorModifiersPerCreature = BindServerConfig("Modifiers", "MaxMinorModifiersPerCreature", 1, "The default number of minor modifiers that a creature can have."); LimitCreatureModifiersToCreatureStarLevel = BindServerConfig("Modifiers", "LimitCreatureModifiersToCreatureStarLevel", value: true, "Limits the number of modifiers that a creature can have based on its level."); ChanceMajorModifier = BindServerConfig("Modifiers", "ChanceMajorModifier", 0.15f, "The chance that a creature will have a major modifier (creatures can have BOTH major and minor modifiers).", advanced: false, 0f, 1f); ChanceMajorModifier.SettingChanged += CreatureModifiersData.ClearProbabilityCaches; ChanceMinorModifier = BindServerConfig("Modifiers", "ChanceMinorModifier", 0.25f, "The chance that a creature will have a minor modifier (creatures can have BOTH major and minor modifiers).", advanced: false, 0f, 1f); ChanceMinorModifier.SettingChanged += CreatureModifiersData.ClearProbabilityCaches; EnableBossModifiers = BindServerConfig("Modifiers", "EnableBossModifiers", value: true, "Wether or not bosses can spawn with modifiers."); ChanceOfBossModifier = BindServerConfig("Modifiers", "ChanceOfBossModifier", 0.75f, "The chance that a boss will have a modifier.", advanced: false, 0f, 1f); ChanceOfBossModifier.SettingChanged += CreatureModifiersData.ClearProbabilityCaches; MaxBossModifiersPerBoss = BindServerConfig("Modifiers", "MaxBossModifiersPerBoss", 2, "The maximum number of modifiers that a boss can have."); SplittersInheritLevel = BindServerConfig("Modifiers", "SplittersInheritLevel", value: true, "Wether or not creatures spawned from the Splitter modifier inherit the level of the parent creature."); LimitCreatureModifierPrefixes = BindServerConfig("Modifiers", "LimitCreatureModifierPrefixes", 3, "Maximum number of prefix names to use when building a creatures name."); NumberOfCacheUpdatesPerFrame = BindServerConfig("Misc", "NumberOfCacheUpdatesPerFrame", 10, "Number of cache updates to process when performing live updates", advanced: true, 1); OutputColorizationGeneratorsData = BindServerConfig("Misc", "OutputColorizationGeneratorsData", value: false, "Writes out color generators to a debug file. This can be useful if you want to hand pick color settings from generated values."); InitialDelayBeforeSetup = BindServerConfig("Misc", "InitialDelayBeforeSetup", 0.5f, "The delay waited before a creature is setup, this is the delay that the person controlling the creature will wait before setup. Higher values will delay setup."); FallbackDelayBeforeCreatureSetup = BindServerConfig("Misc", "FallbackDelayBeforeCreatureSetup", 5, "The number of seconds non-owned creatures we will waited on before loading their modified attributes. This is a fallback setup."); } internal void LoadYamlConfigs() { string[] files = Directory.GetFiles(GetSecondaryConfigDirectoryPath()); bool flag = false; bool flag2 = false; bool flag3 = false; bool flag4 = false; string[] array = files; foreach (string text in array) { if (text.Contains("LevelSettings.yaml")) { Logger.LogDebug("Found level configuration: " + text); levelsFilePath = text; flag = true; } if (text.Contains("ColorSettings.yaml")) { Logger.LogDebug("Found color configuration: " + text); colorsFilePath = text; flag2 = true; } if (text.Contains("LootSettings.yaml")) { Logger.LogDebug("Found loot configuration: " + text); creatureLootFilePath = text; flag3 = true; } if (text.Contains("Modifiers.yaml")) { Logger.LogDebug("Found modifier configuration: " + text); creatureModifierFilePath = text; flag4 = true; } } if (!flag4) { Logger.LogDebug("Loot config missing, recreating."); using StreamWriter streamWriter = new StreamWriter(creatureModifierFilePath); string value = "#################################################\n# Star Level System Expanded - Creature Modifier Configuration\n#################################################\n"; streamWriter.WriteLine(value); streamWriter.WriteLine(CreatureModifiersData.GetModifierDefaultConfig()); } if (!flag3) { Logger.LogDebug("Loot config missing, recreating."); using StreamWriter streamWriter2 = new StreamWriter(creatureLootFilePath); string value2 = "#################################################\n# Star Level System Expanded - Creature loot configuration\n#################################################\n"; streamWriter2.WriteLine(value2); streamWriter2.WriteLine(LootSystemData.YamlDefaultConfig()); } if (!flag) { Logger.LogDebug("Level config file missing, recreating."); using StreamWriter streamWriter3 = new StreamWriter(levelsFilePath); string value3 = "#################################################\n# Star Level System Expanded - Level Settings\n#################################################\n"; streamWriter3.WriteLine(value3); streamWriter3.WriteLine(LevelSystemData.YamlDefaultConfig()); } if (!flag2) { Logger.LogDebug("Color config file missing, recreating."); using StreamWriter streamWriter4 = new StreamWriter(colorsFilePath); string value4 = "#################################################\n# Star Level System Expanded - Creature Level Color Settings\n#################################################\n"; streamWriter4.WriteLine(value4); streamWriter4.WriteLine(Colorization.YamlDefaultConfig()); } SetupFileWatcher("ColorSettings.yaml"); SetupFileWatcher("LevelSettings.yaml"); SetupFileWatcher("Modifiers.yaml"); SetupFileWatcher("CreatureLootSettings.yaml"); } private void SetupFileWatcher(string filtername) { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(); fileSystemWatcher.Path = GetSecondaryConfigDirectoryPath(); fileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite; fileSystemWatcher.Filter = filtername; fileSystemWatcher.Changed += UpdateConfigFileOnChange; fileSystemWatcher.Created += UpdateConfigFileOnChange; fileSystemWatcher.Renamed += UpdateConfigFileOnChange; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private static void UpdateConfigFileOnChange(object sender, FileSystemEventArgs e) { if (!SynchronizationManager.Instance.PlayerIsAdmin) { Logger.LogInfo("Player is not an admin, and not allowed to change local configuration. Ignoring."); } else if (File.Exists(e.FullPath)) { string yaml = File.ReadAllText(e.FullPath); FileInfo fileInfo = new FileInfo(e.FullPath); Logger.LogDebug("Filewatch changes from: (" + fileInfo.Name + ") " + fileInfo.FullName); switch (fileInfo.Name) { case "ColorSettings.yaml": Logger.LogDebug("Triggering Color Settings update."); Colorization.UpdateYamlConfig(yaml); ColorSettingsRPC.SendPackage(ZNet.instance.m_peers, SendFileAsZPackage(e.FullPath)); break; case "LevelSettings.yaml": Logger.LogDebug("Triggering Level Settings update."); LevelSystemData.UpdateYamlConfig(yaml); LevelSettingsRPC.SendPackage(ZNet.instance.m_peers, SendFileAsZPackage(e.FullPath)); break; case "CreatureLootSettings.yaml": Logger.LogDebug("Triggering Loot Settings update."); LootSystemData.UpdateYamlConfig(yaml); CreatureLootSettingsRPC.SendPackage(ZNet.instance.m_peers, SendFileAsZPackage(e.FullPath)); break; case "Modifiers.yaml": Logger.LogDebug("Triggering Modifiers Settings update."); CreatureModifiersData.UpdateModifierConfig(yaml); ModifiersRPC.SendPackage(ZNet.instance.m_peers, SendFileAsZPackage(e.FullPath)); break; } } } private static ZPackage SendFileAsZPackage(string filepath) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown string text = File.ReadAllText(filepath); ZPackage val = new ZPackage(); val.Write(text); return val; } private static ZPackage SendLevelsConfigs() { return SendFileAsZPackage(levelsFilePath); } private static ZPackage SendCreatureLootConfigs() { return SendFileAsZPackage(creatureLootFilePath); } private static ZPackage SendColorsConfigs() { return SendFileAsZPackage(colorsFilePath); } private static ZPackage SendModifierConfigs() { return SendFileAsZPackage(creatureModifierFilePath); } [IteratorStateMachine(typeof(<OnServerRecieveConfigs>d__81))] public static IEnumerator OnServerRecieveConfigs(long sender, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <OnServerRecieveConfigs>d__81(0); } [IteratorStateMachine(typeof(<OnClientReceiveLevelConfigs>d__82))] private static IEnumerator OnClientReceiveLevelConfigs(long sender, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <OnClientReceiveLevelConfigs>d__82(0) { package = package }; } [IteratorStateMachine(typeof(<OnClientReceiveColorConfigs>d__83))] private static IEnumerator OnClientReceiveColorConfigs(long sender, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <OnClientReceiveColorConfigs>d__83(0) { package = package }; } [IteratorStateMachine(typeof(<OnClientReceiveCreatureLootConfigs>d__84))] private static IEnumerator OnClientReceiveCreatureLootConfigs(long sender, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <OnClientReceiveCreatureLootConfigs>d__84(0) { package = package }; } [IteratorStateMachine(typeof(<OnClientReceiveModifiersConfigs>d__85))] private static IEnumerator OnClientReceiveModifiersConfigs(long sender, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <OnClientReceiveModifiersConfigs>d__85(0) { package = package }; } public static string GetSecondaryConfigDirectoryPath() { return Directory.CreateDirectory(Path.Combine(Paths.ConfigPath, "StarLevelSystem")).FullName; } public static ConfigEntry<bool> BindServerConfig(string catagory, string key, bool value, string description, AcceptableValueBase acceptableValues = null, bool advanced = false) { //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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown return cfg.Bind<bool>(catagory, key, value, new ConfigDescription(description, acceptableValues, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry<int> BindServerConfig(string catagory, string key, int value, string description, bool advanced = false, int valmin = 0, int valmax = 150) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown return cfg.Bind<int>(catagory, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<int>(valmin, valmax), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry<float> BindServerConfig(string catagory, string key, float value, string description, bool advanced = false, float valmin = 0f, float valmax = 150f) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown return cfg.Bind<float>(catagory, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(valmin, valmax), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry<string> BindServerConfig(string catagory, string key, string value, string description, AcceptableValueList<string> acceptableValues = null, bool advanced = false) { //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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown return cfg.Bind<string>(catagory, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)acceptableValues, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } } internal class Logger { public static LogLevel Level = (LogLevel)16; public static void enableDebugLogging(object sender, EventArgs e) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (ValConfig.EnableDebugMode.Value) { Level = (LogLevel)32; } else { Level = (LogLevel)16; } } public static void CheckEnableDebugLogging() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (ValConfig.EnableDebugMode.Value) { Level = (LogLevel)32; } else { Level = (LogLevel)16; } } public static void LogDebug(string message) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)Level >= 32) { StarLevelSystem.Log.LogInfo((object)message); } } public static void LogInfo(string message) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)Level >= 16) { StarLevelSystem.Log.LogInfo((object)message); } } public static void LogWarning(string message) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)Level >= 4) { StarLevelSystem.Log.LogWarning((object)message); } } public static void LogError(string message) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)Level >= 2) { StarLevelSystem.Log.LogError((object)message); } } } [BepInPlugin("MidnightsFX.StarLevelSystem", "StarLevelSystem", "0.14.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInIncompatibility("org.bepinex.plugins.creaturelevelcontrol")] internal class StarLevelSystem : BaseUnityPlugin { public const string PluginGUID = "MidnightsFX.StarLevelSystem"; public const string PluginName = "StarLevelSystem"; public const string PluginVersion = "0.14.1"; public ValConfig cfg; public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization(); public static AssetBundle EmbeddedResourceBundle; public static ManualLogSource Log; public static Harmony HarmonyInstance { get; private set; } public void Awake() { Log = ((BaseUnityPlugin)this).Logger; cfg = new ValConfig(((BaseUnityPlugin)this).Config); cfg.SetupConfigRPCs(); cfg.LoadYamlConfigs(); EmbeddedResourceBundle = AssetUtils.LoadAssetBundleFromResources("StarLevelSystem.assets.starlevelsystems", typeof(StarLevelSystem).Assembly); HarmonyInstance = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "MidnightsFX.StarLevelSystem"); Colorization.Init(); LevelSystemData.Init(); LootSystemData.Init(); CreatureModifiersData.Init(); LocalizationLoader.AddLocalizations(); PrefabManager.OnVanillaPrefabsAvailable += CreatureModifiersData.LoadPrefabs; PrefabManager.OnVanillaPrefabsAvailable += LevelSystem.UpdateMaxLevel; PrefabManager.OnPrefabsRegistered += LootSystemData.AttachPrefabsWhenReady; MinimapManager.OnVanillaMapAvailable += LevelSystem.CreateLevelBonusRingMapOverlays; ZoneManager.OnVanillaLocationsAvailable += LevelSystem.SetRingCenter; TerminalCommands.AddCommands(); } } } namespace StarLevelSystem.modules { public static class APIReciever { public static bool UpdateCreatureLevel(Character chara, int level) { LevelSystem.SetAndUpdateCharacterLevel(chara, level); return true; } public static bool UpdateCreatureColorization(Character chara, float value, float hue, float sat, bool emission = false) { DataObjects.CharacterCacheEntry cacheEntry = CompositeLazyCache.GetCacheEntry(chara); if (cacheEntry == null) { return false; } cacheEntry.Colorization = Colorization.DetermineCharacterColorization(chara, chara.m_level); CompositeLazyCache.UpdateCharacterCacheEntry(chara, cacheEntry); Colorization.ApplyColorizationWithoutLevelEffects(((Component)chara).gameObject, cacheEntry.Colorization); return true; } public static float GetBaseAttributeValue(Character chara, int attribute) { return CompositeLazyCache.GetAndSetLocalCache(chara)?.CreatureBaseValueModifiers[(DataObjects.CreatureBaseAttribute)attribute] ?? (-1f); } public static bool UpdateCreatureBaseAttributes(Character chara, int attribute, float value) { DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return false; } andSetLocalCache.CreatureBaseValueModifiers[(DataObjects.CreatureBaseAttribute)attribute] = value; return true; } public static Dictionary<int, float> GetAllBaseAttributes(Character chara) { DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return null; } Dictionary<int, float> dictionary = new Dictionary<int, float>(); foreach (KeyValuePair<DataObjects.CreatureBaseAttribute, float> creatureBaseValueModifier in andSetLocalCache.CreatureBaseValueModifiers) { dictionary[(int)creatureBaseValueModifier.Key] = creatureBaseValueModifier.Value; } return dictionary; } public static bool SetAllBaseAttributes(Character chara, Dictionary<int, float> attributes) { DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return false; } foreach (KeyValuePair<int, float> attribute in attributes) { andSetLocalCache.CreatureBaseValueModifiers[(DataObjects.CreatureBaseAttribute)attribute.Key] = attribute.Value; } CompositeLazyCache.UpdateCharacterCacheEntry(chara, andSetLocalCache); ModificationExtensionSystem.ApplySpeedModifications(chara, andSetLocalCache); ModificationExtensionSystem.ApplyDamageModification(chara, andSetLocalCache); ModificationExtensionSystem.LoadApplySizeModifications(((Component)chara).gameObject, chara.m_nview, andSetLocalCache, force_update: true); ModificationExtensionSystem.ApplyHealthModifications(chara, andSetLocalCache); return true; } public static float GetPerLevelAttributeValue(Character chara, int attribute) { return CompositeLazyCache.GetAndSetLocalCache(chara)?.CreaturePerLevelValueModifiers[(DataObjects.CreaturePerLevelAttribute)attribute] ?? (-1f); } public static bool UpdateCreaturePerLevelAttributes(Character chara, int attribute, float value) { DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return false; } andSetLocalCache.CreaturePerLevelValueModifiers[(DataObjects.CreaturePerLevelAttribute)attribute] = value; return true; } public static Dictionary<int, float> GetAllPerLevelAttributes(Character chara) { DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return null; } Dictionary<int, float> dictionary = new Dictionary<int, float>(); foreach (KeyValuePair<DataObjects.CreaturePerLevelAttribute, float> creaturePerLevelValueModifier in andSetLocalCache.CreaturePerLevelValueModifiers) { dictionary[(int)creaturePerLevelValueModifier.Key] = creaturePerLevelValueModifier.Value; } return dictionary; } public static bool SetAllPerLevelAttributes(Character chara, Dictionary<int, float> attributes) { DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return false; } foreach (KeyValuePair<int, float> attribute in attributes) { andSetLocalCache.CreaturePerLevelValueModifiers[(DataObjects.CreaturePerLevelAttribute)attribute.Key] = attribute.Value; } CompositeLazyCache.UpdateCharacterCacheEntry(chara, andSetLocalCache); ModificationExtensionSystem.ApplySpeedModifications(chara, andSetLocalCache); ModificationExtensionSystem.ApplyDamageModification(chara, andSetLocalCache); ModificationExtensionSystem.LoadApplySizeModifications(((Component)chara).gameObject, chara.m_nview, andSetLocalCache, force_update: true); ModificationExtensionSystem.ApplyHealthModifications(chara, andSetLocalCache); return true; } public static float GetCreatureDamageRecievedModifier(Character chara, int attribute) { return CompositeLazyCache.GetAndSetLocalCache(chara)?.DamageRecievedModifiers[(DataObjects.DamageType)attribute] ?? (-1f); } public static bool UpdateCreatureDamageRecievedModifier(Character chara, int attribute, float value) { DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return false; } andSetLocalCache.DamageRecievedModifiers[(DataObjects.DamageType)attribute] = value; return true; } public static Dictionary<int, float> GetAllDamageRecievedModifiers(Character chara) { DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return null; } Dictionary<int, float> dictionary = new Dictionary<int, float>(); foreach (KeyValuePair<DataObjects.DamageType, float> damageRecievedModifier in andSetLocalCache.DamageRecievedModifiers) { dictionary[(int)damageRecievedModifier.Key] = damageRecievedModifier.Value; } return dictionary; } public static bool SetAllDamageRecievedModifiers(Character chara, Dictionary<int, float> attributes) { DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return false; } foreach (KeyValuePair<int, float> attribute in attributes) { andSetLocalCache.DamageRecievedModifiers[(DataObjects.DamageType)attribute.Key] = attribute.Value; } CompositeLazyCache.UpdateCharacterCacheEntry(chara, andSetLocalCache); ModificationExtensionSystem.ApplyDamageModification(chara, andSetLocalCache); return true; } public static float GetCreatureDamageBonus(Character chara, int attribute) { DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return -1f; } if (andSetLocalCache.CreatureDamageBonus.ContainsKey((DataObjects.DamageType)attribute)) { return andSetLocalCache.CreatureDamageBonus[(DataObjects.DamageType)attribute]; } return 0f; } public static bool UpdateCreatureDamageBonus(Character chara, int attribute, float value) { DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return false; } if (!andSetLocalCache.CreatureDamageBonus.ContainsKey((DataObjects.DamageType)attribute)) { andSetLocalCache.CreatureDamageBonus[(DataObjects.DamageType)attribute] = value; } else { andSetLocalCache.CreatureDamageBonus.Add((DataObjects.DamageType)attribute, value); } return true; } public static Dictionary<int, float> GetAllDamageBonus(Character chara) { DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return null; } Dictionary<int, float> dictionary = new Dictionary<int, float>(); foreach (KeyValuePair<DataObjects.DamageType, float> creatureDamageBonu in andSetLocalCache.CreatureDamageBonus) { dictionary[(int)creatureDamageBonu.Key] = creatureDamageBonu.Value; } return dictionary; } public static bool SetAllDamageBonus(Character chara, Dictionary<int, float> attributes) { DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return false; } foreach (KeyValuePair<int, float> attribute in attributes) { andSetLocalCache.CreatureDamageBonus[(DataObjects.DamageType)attribute.Key] = attribute.Value; } CompositeLazyCache.UpdateCharacterCacheEntry(chara, andSetLocalCache); ModificationExtensionSystem.ApplyDamageModification(chara, andSetLocalCache); return true; } public static bool ApplyUpdatesToCreature(Character chara) { DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return false; } ModificationExtensionSystem.ApplySpeedModifications(chara, andSetLocalCache); ModificationExtensionSystem.ApplyDamageModification(chara, andSetLocalCache); ModificationExtensionSystem.LoadApplySizeModifications(((Component)chara).gameObject, chara.m_nview, andSetLocalCache, force_update: true); ModificationExtensionSystem.ApplyHealthModifications(chara, andSetLocalCache); return true; } public static List<string> GetPossibleModifiersForType(int modifierType) { List<string> list = new List<string>(); switch (modifierType) { case 0: foreach (string key in CreatureModifiersData.ActiveCreatureModifiers.MajorModifiers.Keys) { list.Add(key); } break; case 1: foreach (string key2 in CreatureModifiersData.ActiveCreatureModifiers.MinorModifiers.Keys) { list.Add(key2); } break; case 2: foreach (string key3 in CreatureModifiersData.ActiveCreatureModifiers.BossModifiers.Keys) { list.Add(key3); } break; default: Logger.LogWarning($"Invalid modifier type {modifierType} passed to GetAllPossibleModifiers. Valid types are 0 (Major), 1 (Minor), 2 (Boss)."); break; } return list; } public static Dictionary<string, int> GetAllModifiersForCreature(Character chara) { Dictionary<string, DataObjects.ModifierType> creatureModifiers = CompositeLazyCache.GetCreatureModifiers(chara); if (creatureModifiers == null) { return null; } Dictionary<string, int> dictionary = new Dictionary<string, int>(); foreach (KeyValuePair<string, DataObjects.ModifierType> item in creatureModifiers) { dictionary.Add(item.Key.ToString(), (int)item.Value); } return dictionary; } public static bool AddModifierToCreature(Character chara, string modifierName, int modifierType, bool update = true) { if (CompositeLazyCache.GetAndSetLocalCache(chara) == null) { return false; } return CreatureModifiers.AddCreatureModifier(chara, (DataObjects.ModifierType)modifierType, modifierName, update); } public static bool AddNewModifierToSLS(int modifierID, string modifier_name, string setupMethod = null, float selectionWeight = 10f, float basepower = 0f, float perlevelpower = 0f, Dictionary<Biome, List<string>> biomeConfig = null, int namingStyle = 2, string name_suffixes = null, string name_prefixes = null, int visualStyle = 0, Sprite starIcon = null, GameObject visualEffect = null, List<string> allowed_creatures = null, List<string> unallowed_creatures = null, List<Biome> allowed_biomes = null) { if (CreatureModifiersData.ModifierNamesLookupTable.ContainsID(modifierID)) { Logger.LogWarning($"Modifier ID {modifierID} already exists as {CreatureModifiersData.ModifierNamesLookupTable.GetValue(modifierID)}, please choose a different ID"); return false; } CreatureModifiersData.ModifierNamesLookupTable.AddValue(modifier_name, modifierID); DataObjects.CreatureModifierDefinition creatureModifierDefinition = new DataObjects.CreatureModifierDefinition(); if ((Object)(object)starIcon != (Object)null) { creatureModifierDefinition.StarVisualAPI = starIcon; creatureModifierDefinition.StarVisual = ((Object)starIcon).name; } if ((Object)(object)visualEffect != (Object)null) { creatureModifierDefinition.VisualEffectAPI = visualEffect; creatureModifierDefinition.VisualEffect = ((Object)visualEffect).name; } if (setupMethod != null) { creatureModifierDefinition.SetupMethodClass = setupMethod; } if (name_suffixes != null) { creatureModifierDefinition.NameSuffix = name_suffixes; } if (name_prefixes != null) { creatureModifierDefinition.NamePrefix = name_prefixes; } if (namingStyle > 2 || namingStyle < 0) { namingStyle = 2; } creatureModifierDefinition.namingConvention = (DataObjects.NameSelectionStyle)namingStyle; if (visualStyle > 3 || visualStyle < 0) { visualStyle = 0; } creatureModifierDefinition.VisualEffectStyle = (DataObjects.VisualEffectStyle)visualStyle; DataObjects.CreatureModifierConfiguration creatureModifierConfiguration = new DataObjects.CreatureModifierConfiguration(); creatureModifierConfiguration.Config = new DataObjects.CreatureModConfig { BasePower = basepower, PerlevelPower = perlevelpower, BiomeObjects = biomeConfig }; creatureModifierConfiguration.SelectionWeight = selectionWeight; if (allowed_creatures != null) { creatureModifierConfiguration.AllowedCreatures = allowed_creatures; } if (unallowed_creatures != null) { creatureModifierConfiguration.UnallowedCreatures = unallowed_creatures; } if (allowed_biomes != null) { creatureModifierConfiguration.AllowedBiomes = allowed_biomes; } CreatureModifiersData.ClearProbabilityCaches(); return true; } } public static class Colorization { [HarmonyPatch(typeof(LevelEffects), "SetupLevelVisualization")] public static class PreventDefaultLevelSetup { public static bool Prefix() { return false; } } public static DataObjects.CreatureColorizationSettings creatureColorizationSettings = defaultColorizationSettings; private static DataObjects.CreatureColorizationSettings defaultColorizationSettings = new DataObjects.CreatureColorizationSettings { characterSpecificColorization = ColorizationData.characterColorizationData, defaultLevelColorization = ColorizationData.defaultColorizationData, characterColorGenerators = ColorizationData.defaultColorGenerators }; public static List<Color> mapRingColors = new List<Color>(); public static readonly Dictionary<string, string> defaultColors = new Dictionary<string, string> { { "Red", "#ff1a1a" }, { "Orange", "#ff9933" }, { "Yellow", "#ffff1a" }, { "Green", "#50f83a" }, { "Teal", "#18e7a9" }, { "Blue", "#00abff" }, { "Purple", "#c966ff" }, { "Pink", "#ff4dcf" }, { "Gray", "#999999" }, { "Brown", "#b37700" }, { "Black", "#333333" }, { "White", "#f2f2f2" } }; public static DataObjects.ColorDef defaultColorization = new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = 0f, IsEmissive = false }; public static void Init() { creatureColorizationSettings = defaultColorizationSettings; try { UpdateYamlConfig(File.ReadAllText(ValConfig.colorsFilePath)); } catch (Exception arg) { Logger.LogWarning((object)$"There was an error updating the Color Level values, defaults will be used. Exception: {arg}"); } } public static string YamlDefaultConfig() { return DataObjects.yamlserializer.Serialize((object)defaultColorizationSettings); } public static bool UpdateYamlConfig(string yaml) { try { creatureColorizationSettings = DataObjects.yamldeserializer.Deserialize<DataObjects.CreatureColorizationSettings>(yaml); foreach (KeyValuePair<int, DataObjects.ColorDef> item in defaultColorizationSettings.defaultLevelColorization) { if (!creatureColorizationSettings.defaultLevelColorization.Keys.Contains(item.Key)) { creatureColorizationSettings.defaultLevelColorization.Add(item.Key, item.Value); } } if (creatureColorizationSettings.characterColorGenerators != null) { Logger.LogInfo("Running color generators"); foreach (KeyValuePair<string, List<DataObjects.ColorRangeDef>> characterColorGenerator in creatureColorizationSettings.characterColorGenerators) { Logger.LogInfo("Building color range for " + characterColorGenerator.Key); foreach (DataObjects.ColorRangeDef item2 in characterColorGenerator.Value) { BuildAddColorRange(characterColorGenerator.Key, item2); } } if (ValConfig.OutputColorizationGeneratorsData.Value) { File.WriteAllText(Path.Combine(Paths.ConfigPath, "StarLevelSystem", "DebugGeneratedColorValues.yaml"), DataObjects.yamlserializer.Serialize((object)creatureColorizationSettings)); } } Logger.LogInfo("Updated ColorizationSettings."); Character[] array = Resources.FindObjectsOfTypeAll<Character>(); foreach (Character val in array) { if (val.m_level > 1) { DataObjects.CharacterCacheEntry cacheEntry = CompositeLazyCache.GetCacheEntry(val); if (cacheEntry != null) { cacheEntry.Colorization = DetermineCharacterColorization(val, val.m_level); CompositeLazyCache.UpdateCharacterCacheEntry(val, cacheEntry); ApplyColorizationWithoutLevelEffects(((Component)val).gameObject, cacheEntry.Colorization); } } } } catch (Exception ex) { StarLevelSystem.Log.LogError((object)("Failed to parse ColorizationSettings YAML: " + ex.Message)); return false; } return true; } public static void ApplyLevelVisual(Character charc) { LevelEffects componentInChildren = ((Component)charc).gameObject.GetComponentInChildren<LevelEffects>(); if (!((Object)(object)componentInChildren == (Object)null) && componentInChildren.m_levelSetups != null && componentInChildren.m_levelSetups.Count > 0) { LevelSetup val = componentInChildren.m_levelSetups[Random.Range(0, componentInChildren.m_levelSetups.Count - 1)]; if ((Object)(object)val.m_enableObject != (Object)null) { val.m_enableObject.SetActive(true); } } } internal static DataObjects.ColorDef DetermineCharacterColorization(Character cgo, int level) { if ((Object)(object)cgo == (Object)null) { return null; } string prefabName = Utils.GetPrefabName(((Component)cgo).gameObject); if (creatureColorizationSettings.characterSpecificColorization.ContainsKey(prefabName) && creatureColorizationSettings.characterSpecificColorization[prefabName].ContainsKey(level - 1) && creatureColorizationSettings.characterSpecificColorization[prefabName].TryGetValue(level - 1, out var value)) { return value; } return GetDefaultColorization(level - 1); } internal static void ApplyColorizationWithoutLevelEffects(GameObject cgo, DataObjects.ColorDef colorization) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) if (!ValConfig.EnableColorization.Value || colorization == null) { return; } LevelSetup val = colorization.toLevelEffect(); try { SkinnedMeshRenderer[] componentsInChildren = cgo.gameObject.GetComponentsInChildren<SkinnedMeshRenderer>(); foreach (SkinnedMeshRenderer val2 in componentsInChildren) { Material[] sharedMaterials = ((Renderer)val2).sharedMaterials; if (sharedMaterials.Length != 0) { sharedMaterials[0] = new Material(sharedMaterials[0]); sharedMaterials[0].SetFloat("_Hue", val.m_hue); sharedMaterials[0].SetFloat("_Saturation", val.m_saturation); sharedMaterials[0].SetFloat("_Value", val.m_value); if (val.m_setEmissiveColor) { sharedMaterials[0].SetColor("_EmissionColor", val.m_emissiveColor); } ((Renderer)val2).sharedMaterials = sharedMaterials; } } } catch (Exception arg) { Logger.LogError($"Exception while colorizing {arg}"); } } internal static void BuildAddColorRange(string creatureKey, DataObjects.ColorRangeDef colorGen) { float num = Mathf.Abs(colorGen.EndColorDef.hue) + Mathf.Abs(colorGen.StartColorDef.hue); Mathf.Clamp(num, 0f, 2f); float num2 = Mathf.Abs(colorGen.EndColorDef.saturation) + Mathf.Abs(colorGen.StartColorDef.saturation); Mathf.Clamp(num2, 0f, 2f); float num3 = Mathf.Abs(colorGen.EndColorDef.value) + Mathf.Abs(colorGen.StartColorDef.value); Mathf.Clamp(num3, 0f, 2f); int num4 = colorGen.RangeEnd - colorGen.RangeStart; float num5 = num / (float)num4; float num6 = num2 / (float)num4; float num7 = num3 / (float)num4; int num8 = ((!(colorGen.StartColorDef.hue > colorGen.EndColorDef.hue)) ? 1 : (-1)); int num9 = ((!(colorGen.StartColorDef.saturation > colorGen.EndColorDef.saturation)) ? 1 : (-1)); int num10 = ((!(colorGen.StartColorDef.value > colorGen.EndColorDef.value)) ? 1 : (-1)); if (colorGen.CharacterSpecific && !creatureColorizationSettings.characterSpecificColorization.ContainsKey(creatureKey)) { creatureColorizationSettings.characterSpecificColorization.Add(creatureKey, new Dictionary<int, DataObjects.ColorDef>()); } int num11 = colorGen.RangeStart; int num12 = 0; while (num11 < colorGen.RangeEnd + 1) { DataObjects.ColorDef value = new DataObjects.ColorDef { hue = colorGen.StartColorDef.hue + num5 * (float)num12 * (float)num8, saturation = colorGen.StartColorDef.saturation + num6 * (float)num12 * (float)num9, value = colorGen.StartColorDef.value + num7 * (float)num12 * (float)num10, IsEmissive = false }; if (colorGen.CharacterSpecific) { if (!creatureColorizationSettings.characterSpecificColorization.ContainsKey(creatureKey)) { creatureColorizationSettings.characterSpecificColorization.Add(creatureKey, new Dictionary<int, DataObjects.ColorDef>()); } if (creatureColorizationSettings.characterSpecificColorization[creatureKey].ContainsKey(num11)) { if (colorGen.OverwriteExisting) { creatureColorizationSettings.characterSpecificColorization[creatureKey][num11] = value; } } else { creatureColorizationSettings.characterSpecificColorization[creatureKey].Add(num11, value); } } else if (creatureColorizationSettings.defaultLevelColorization.ContainsKey(num11)) { if (colorGen.OverwriteExisting) { creatureColorizationSettings.defaultLevelColorization[num11] = value; } } else { creatureColorizationSettings.defaultLevelColorization.Add(num11, value); } num11++; num12++; } } internal static void StarLevelScaleChanged(object s, EventArgs e) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) Character[] array = Resources.FindObjectsOfTypeAll<Character>(); foreach (Character val in array) { ((Component)val).transform.localScale = Vector3.one; float num = 1f + ValConfig.PerLevelScaleBonus.Value * (float)(val.m_level - 1); Logger.LogDebug($"Setting {((Object)val).name} size {num}."); Transform transform = ((Component)val).transform; transform.localScale *= num; } Physics.SyncTransforms(); } internal static DataObjects.ColorDef GetDefaultColorization(int level) { if (creatureColorizationSettings.defaultLevelColorization.ContainsKey(level)) { return creatureColorizationSettings.defaultLevelColorization[level]; } return defaultColorization; } public static void UpdateMapColorSelection() { //IL_005a: 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) mapRingColors.Clear(); Color item = default(Color); Color item2 = default(Color); foreach (string item3 in ValConfig.DistanceRingColorOptions.Value.Split(new char[1] { ',' }).ToList()) { if (item3.StartsWith("#")) { if (ColorUtility.TryParseHtmlString(item3.Trim(), ref item)) { mapRingColors.Add(item); } else { Logger.LogWarning("Unable to parse color string " + item3 + " for distance ring colors. It will be skipped"); } continue; } string key = StringExtensions.CapitalizeFirstLetter(item3.Trim()); if (defaultColors.TryGetValue(key, out var value) && ColorUtility.TryParseHtmlString(value, ref item2)) { mapRingColors.Add(item2); } } } } internal static class Compatibility { } public static class CreatureModifiers { internal static readonly string NoMods = "None"; private static readonly List<DataObjects.NameSelectionStyle> prefixSelectors = new List<DataObjects.NameSelectionStyle> { DataObjects.NameSelectionStyle.RandomFirst, DataObjects.NameSelectionStyle.RandomBoth }; private static readonly List<DataObjects.NameSelectionStyle> suffixSelectors = new List<DataObjects.NameSelectionStyle> { DataObjects.NameSelectionStyle.RandomLast, DataObjects.NameSelectionStyle.RandomBoth }; public static void RunOnceModifierSetup(Character character, DataObjects.CharacterCacheEntry cacheEntry) { if (cacheEntry.CreatureModifiers == null || cacheEntry.runOnceDone) { return; } int num = 0; foreach (KeyValuePair<string, DataObjects.ModifierType> creatureModifier in cacheEntry.CreatureModifiers) { if (ValConfig.LimitCreatureModifiersToCreatureStarLevel.Value && num >= character.m_level - 1) { break; } if (!(creatureModifier.Key == NoMods) && !(creatureModifier.Key == string.Empty)) { switch (creatureModifier.Value) { case DataObjects.ModifierType.Boss: RunOnceModifier(creatureModifier.Key, character, cacheEntry, CreatureModifiersData.ActiveCreatureModifiers.BossModifiers); break; case DataObjects.ModifierType.Major: RunOnceModifier(creatureModifier.Key, character, cacheEntry, CreatureModifiersData.ActiveCreatureModifiers.MajorModifiers); break; case DataObjects.ModifierType.Minor: RunOnceModifier(creatureModifier.Key, character, cacheEntry, CreatureModifiersData.ActiveCreatureModifiers.MinorModifiers); break; } num++; } } cacheEntry.runOnceDone = true; } public static void SetupModifiers(Character character, DataObjects.CharacterCacheEntry cacheEntry, Dictionary<string, DataObjects.ModifierType> selectedMods) { if (selectedMods == null) { return; } int num = 0; foreach (KeyValuePair<string, DataObjects.ModifierType> selectedMod in selectedMods) { if (ValConfig.LimitCreatureModifiersToCreatureStarLevel.Value && num >= character.m_level - 1) { break; } if (!(selectedMod.Key == NoMods) && !(selectedMod.Key == string.Empty)) { switch (selectedMod.Value) { case DataObjects.ModifierType.Boss: StartupModifier(selectedMod.Key, character, cacheEntry, CreatureModifiersData.ActiveCreatureModifiers.BossModifiers); break; case DataObjects.ModifierType.Major: StartupModifier(selectedMod.Key, character, cacheEntry, CreatureModifiersData.ActiveCreatureModifiers.MajorModifiers); break; case DataObjects.ModifierType.Minor: StartupModifier(selectedMod.Key, character, cacheEntry, CreatureModifiersData.ActiveCreatureModifiers.MinorModifiers); break; } num++; } } } private static void RunOnceModifier(string mod, Character character, DataObjects.CharacterCacheEntry cacheEntry, Dictionary<string, DataObjects.CreatureModifierConfiguration> availableMods) { if (!availableMods.ContainsKey(mod)) { if (!(mod == NoMods)) { Logger.LogWarning("Modifier " + mod + " not found in CreatureModifiersData, skipping runonce setup for " + ((Object)character).name); } } else { DataObjects.CreatureModifierConfiguration creatureModifierConfiguration = availableMods[mod]; CreatureModifiersData.ModifierDefinitions[mod].RunOnceMethodCall(character, creatureModifierConfiguration.Config, cacheEntry); } } private static void StartupModifier(string mod, Character character, DataObjects.CharacterCacheEntry cacheEntry, Dictionary<string, DataObjects.CreatureModifierConfiguration> availableMods) { if (!availableMods.ContainsKey(mod)) { if (!(mod == NoMods)) { Logger.LogWarning("Modifier " + mod + " not found in CreatureModifiersData, skipping setup for " + ((Object)character).name); } } else { DataObjects.CreatureModifierConfiguration creatureModifierConfiguration = availableMods[mod]; CreatureModifiersData.ModifierDefinitions[mod].SetupMethodCall(character, creatureModifierConfiguration.Config, cacheEntry); SetupCreatureVFX(character, CreatureModifiersData.ModifierDefinitions[mod]); } } internal static void SetupCreatureVFX(Character character, DataObjects.CreatureModifierDefinition cmodifier) { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) if (cmodifier.VisualEffect == null) { return; } GameObject val = CreatureModifiersData.LoadedModifierEffects[cmodifier.VisualEffect]; if (!Object.op_Implicit((Object)(object)((Component)character).transform.Find(((Object)val).name + "(Clone)"))) { GameObject val2 = Object.Instantiate<GameObject>(val, ((Component)character).transform); float height = character.GetHeight(); float num = height / 5f; float num2 = character.GetRadius() / 2f; switch (cmodifier.VisualEffectStyle) { case DataObjects.VisualEffectStyle.top: val2.transform.localPosition = new Vector3(0f, height, 0f); break; case DataObjects.VisualEffectStyle.bottom: val2.transform.localPosition = new Vector3(0f, 0f, 0f); break; case DataObjects.VisualEffectStyle.objectCenter: val2.transform.localPosition = new Vector3(0f, height / 2f, 0f); break; } val2.transform.localScale = new Vector3(val2.transform.localScale.x * num, val2.transform.localScale.y * num2, val2.transform.localScale.z * num); } } internal static string BuildCreatureLocalizableName(Character chara, Dictionary<string, DataObjects.ModifierType> modifiers) { if (modifiers == null) { modifiers = new Dictionary<string, DataObjects.ModifierType>(); } List<string> list = new List<string>(); List<string> list2 = new List<string>(); int num = 0; int num2 = 0; List<string> list3 = modifiers.Keys.ToList(); foreach (string item in list3) { if ((ValConfig.LimitCreatureModifiersToCreatureStarLevel.Value && num >= chara.m_level - 1) || list3.Count <= 0 || num >= list3.Count) { break; } num++; if (item == NoMods) { continue; } if (modifiers.ContainsKey(item)) { _ = modifiers[item]; } DataObjects.CreatureModifierDefinition creatureModifierDefinition = CreatureModifiersData.ModifierDefinitions[item]; if (creatureModifierDefinition != null) { if (num2 <= ValConfig.LimitCreatureModifierPrefixes.Value && prefixSelectors.Contains(creatureModifierDefinition.namingConvention) && creatureModifierDefinition.NamePrefix != null && creatureModifierDefinition.NamePrefix.Length > 0) { list.Add(creatureModifierDefinition.NamePrefix); } else if (suffixSelectors.Contains(creatureModifierDefinition.namingConvention) && creatureModifierDefinition.NameSuffix != null && creatureModifierDefinition.NameSuffix.Length > 0) { list2.Add(creatureModifierDefinition.NameSuffix); } } } string name = chara.m_name; if (list.Count == 0 && list2.Count == 0) { return name; } string text = string.Join(" ", list) + " " + name; if (list2.Count > 0) { text = text + " $suffix_moniker " + string.Join(" ", list2); } return text; } public static Dictionary<string, DataObjects.ModifierType> SelectModifiersForCreature(Character character, string creatureName, DataObjects.CreatureSpecificSetting creature_settings, Biome biome, int level, Dictionary<string, DataObjects.ModifierType> requiredModifiers = null, List<string> notAllowedModifiers = null) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, DataObjects.ModifierType> result = new Dictionary<string, DataObjects.ModifierType>(); if (!character.IsPlayer()) { if (character.IsBoss() && ValConfig.EnableBossModifiers.Value) { int maxBossMods = ValConfig.MaxMajorModifiersPerCreature.Value; if (creature_settings != null && creature_settings.MaxBossModifiers > -1) { maxBossMods = creature_settings.MaxBossModifiers; } float chanceBossMods = ValConfig.ChanceOfBossModifier.Value; if (creature_settings != null && creature_settings.ChanceForBossModifier > -1f) { chanceBossMods = creature_settings.ChanceForBossModifier; } result = SelectModifiers(character, creatureName, biome, level, 0, 1f, 0, 1f, isBoss: true, maxBossMods, chanceBossMods, requiredModifiers, notAllowedModifiers); } else { int num = ValConfig.MaxMajorModifiersPerCreature.Value; if (creature_settings != null && creature_settings.MaxMajorModifiers > -1) { num = creature_settings.MaxMajorModifiers; } int num2 = ValConfig.MaxMinorModifiersPerCreature.Value; if (creature_settings != null && creature_settings.MaxMinorModifiers > -1) { num2 = creature_settings.MaxMinorModifiers; } float chanceMajorMods = ValConfig.ChanceMajorModifier.Value; if (creature_settings != null && creature_settings.ChanceForMajorModifier > -1f) { chanceMajorMods = creature_settings.ChanceForMajorModifier; } float chanceMinorMods = ValConfig.ChanceMinorModifier.Value; if (creature_settings != null && creature_settings.ChanceForMinorModifier > -1f) { chanceMinorMods = creature_settings.ChanceForMinorModifier; } int maxMajorMods = num; int maxMinorMods = num2; result = SelectModifiers(character, creatureName, biome, level, maxMajorMods, chanceMajorMods, maxMinorMods, chanceMinorMods, isBoss: false, 0, 1f, null, notAllowedModifiers); } } return result; } public static Dictionary<string, DataObjects.ModifierType> SelectModifiers(Character character, string creatureName, Biome biome, int level, int maxMajorMods = 0, float chanceMajorMods = 1f, int maxMinorMods = 0, float chanceMinorMods = 1f, bool isBoss = false, int maxBossMods = 0, float chanceBossMods = 1f, Dictionary<string, DataObjects.ModifierType> requiredModifiers = null, List<string> notAllowedModifiers = null) { //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, DataObjects.ModifierType> dictionary = new Dictionary<string, DataObjects.ModifierType>(); if (creatureName != null && CreatureModifiersData.ActiveCreatureModifiers.ModifierGlobalSettings != null && CreatureModifiersData.ActiveCreatureModifiers.ModifierGlobalSettings.GlobalIgnorePrefabList != null && CreatureModifiersData.ActiveCreatureModifiers.ModifierGlobalSettings.GlobalIgnorePrefabList.Contains(((Object)character).name)) { Logger.LogDebug("Creature " + creatureName + " is in the global ignore prefab list, skipping modifier assignment."); if (!dictionary.ContainsKey(NoMods)) { dictionary.Add(NoMods, DataObjects.ModifierType.Minor); } return dictionary; } if (requiredModifiers == null) { requiredModifiers = new Dictionary<string, DataObjects.ModifierType>(); } List<string> list = new List<string>(); List<string> list2 = new List<string>(); List<string> list3 = new List<string>(); foreach (KeyValuePair<string, DataObjects.ModifierType> requiredModifier in requiredModifiers) { switch (requiredModifier.Value) { case DataObjects.ModifierType.Minor: list3.Add(requiredModifier.Key); break; case DataObjects.ModifierType.Major: list2.Add(requiredModifier.Key); break; case DataObjects.ModifierType.Boss: list.Add(requiredModifier.Key); break; } } if (isBoss) { foreach (string item in SelectCreatureModifiers(creatureName, biome, chanceBossMods, maxBossMods, level, 0, DataObjects.ModifierType.Boss, list, notAllowedModifiers)) { if (!dictionary.ContainsKey(item)) { dictionary.Add(item.ToString(), DataObjects.ModifierType.Boss); } } return dictionary; } List<string> list4 = SelectCreatureModifiers(creatureName, biome, chanceMajorMods, maxMajorMods, level, 0, DataObjects.ModifierType.Major, list2, notAllowedModifiers); foreach (string item2 in list4) { if (!dictionary.ContainsKey(item2)) { dictionary.Add(item2.ToString(), DataObjects.ModifierType.Major); } } foreach (string item3 in SelectCreatureModifiers(creatureName, biome, chanceMinorMods, maxMinorMods, level, list4.Count, DataObjects.ModifierType.Minor, list3, notAllowedModifiers)) { if (!dictionary.ContainsKey(item3)) { dictionary.Add(item3.ToString(), DataObjects.ModifierType.Minor); } } return dictionary; } public static List<string> SelectCreatureModifiers(string creature, Biome biome, float chance, int num_mods, int level, int existingMods = 0, DataObjects.ModifierType type = DataObjects.ModifierType.Major, List<string> requiredMods = null, List<string> notAllowedModifiers = null) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) List<string> list = new List<string>(); List<string> list2 = new List<string>(); if (requiredMods != null) { list.AddRange(requiredMods); } List<DataObjects.ProbabilityEntry> list3 = CreatureModifiersData.LazyCacheCreatureModifierSelect(creature, biome, type); if (list3.Count == 0) { return list; } if (notAllowedModifiers != null) { list2.AddRange(notAllowedModifiers); } int i = 0; if (requiredMods != null) { i += requiredMods.Count; } for (; num_mods > i && (!ValConfig.LimitCreatureModifiersToCreatureStarLevel.Value || i + 1 + existingMods < level); i++) { if (chance < 1f) { if (Random.value < chance) { string item = RandomSelect.RandomSelectFromWeightedListWithExclusions(list3, list2); list.Add(item); list2.Add(item); } } else { string item2 = RandomSelect.RandomSelectFromWeightedListWithExclusions(list3, list2); list.Add(item2); list2.Add(item2); } } if (list.Count == 0) { list.Add(NoMods); } return list; } public static void RemoveCreatureModifier(Character character, string modifier) { Dictionary<string, DataObjects.ModifierType> creatureModifiers = CompositeLazyCache.GetCreatureModifiers(character); if (creatureModifiers.Keys.Contains(modifier)) { Logger.LogDebug(((Object)character).name + " has " + modifier + ", removing."); if (creatureModifiers.Remove(modifier)) { CompositeLazyCache.SetCreatureModifiers(character, creatureModifiers); } LevelUI.InvalidateCacheEntry(character); } } public static bool AddCreatureModifier(Character character, DataObjects.ModifierType modType, string newModifier, bool applyChanges = true) { if (newModifier == NoMods || newModifier == string.Empty) { Logger.LogDebug("No modifier specified to add to " + ((Object)character).name + ", skipping."); return false; } Dictionary<string, DataObjects.ModifierType> creatureModifiers = CompositeLazyCache.GetCreatureModifiers(character); if (creatureModifiers.Count > 0 && creatureModifiers.ContainsKey(newModifier)) { Logger.LogDebug(((Object)character).name + " already has " + newModifier + ", skipping."); return false; } creatureModifiers.Add(newModifier, modType); CompositeLazyCache.SetCreatureModifiers(character, creatureModifiers); DataObjects.CharacterCacheEntry cacheEntry = CompositeLazyCache.GetCacheEntry(character); DataObjects.CreatureModifierConfiguration modifierDef = CreatureModifiersData.GetModifierDef(newModifier, modType); CreatureModifiersData.ModifierDefinitions[newModifier].SetupMethodCall(character, modifierDef.Config, cacheEntry); CreatureModifiersData.ModifierDefinitions[newModifier].RunOnceMethodCall(character, modifierDef.Config, cacheEntry); SetupCreatureVFX(character, CreatureModifiersData.ModifierDefinitions[newModifier]); LevelUI.InvalidateCacheEntry(character); if (!applyChanges) { ModificationExtensionSystem.ApplySpeedModifications(character, cacheEntry); ModificationExtensionSystem.ApplyDamageModification(character, cacheEntry); ModificationExtensionSystem.LoadApplySizeModifications(((Component)character).gameObject, character.m_nview, cacheEntry, force_update: true); ModificationExtensionSystem.ApplyHealthModifications(character, cacheEntry); return true; } return true; } } public static class LevelSystem { [HarmonyPatch(typeof(TreeBase), "Awake")] public static class RandomTreeLevelExtension { public static void Postfix(TreeBase __instance) { if (!ValConfig.EnableTreeScaling.Value) { return; } int num = 0; if (ValConfig.UseDeterministicTreeScaling.Value) { num = CompositeLazyCache.GetOrAddCachedTreeEntry(__instance.m_nview); } else { num = __instance.m_nview.GetZDO().GetInt(DataObjects.SLS_TREE, 0); if (num == 0) { SelectCreatureBiomeSettings(((Component)__instance).gameObject, out var creature_name, out var creature_settings, out var biome_settings, out var _); num = DetermineLevel(((Component)__instance).gameObject, creature_name, creature_settings, biome_settings, ValConfig.TreeMaxLevel.Value); __instance.m_nview.GetZDO().Set(DataObjects.SLS_TREE, num); } } if (num >= 1) { ((MonoBehaviour)__instance).StartCoroutine(ModifyTreeWithLevel(__instance, num)); } } } [HarmonyPatch(typeof(TreeLog))] public static class SetTreeLogPassLevel { [HarmonyTranspiler] [HarmonyPatch("Destroy")] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchStartForward((CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(ZNetScene), "Destroy", (Type[])null, (Type[])null), (string)null) }).RemoveInstructions(4).MatchStartForward((CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TreeLog), "m_subLogPrefab"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null) }) .Advance(1) .RemoveInstructions(10) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldloc_S, (object)(byte)10), new CodeInstruction(OpCodes.Ldloc_S, (object)(byte)11), Transpilers.EmitDelegate<Action<TreeLog, Transform, Quaternion>>((Action<TreeLog, Transform, Quaternion>)SetupTreeLog) }) .ThrowIfNotMatch("Unable to patch Tree Log Child Spawn Set Level.", Array.Empty<CodeMatch>()); return val.Instructions(); } [HarmonyPatch("Awake")] [HarmonyPostfix] private static void SetupAwakeLog(TreeLog __instance) { int num = 1; if (ValConfig.UseDeterministicTreeScaling.Value) { num = CompositeLazyCache.GetOrAddCachedTreeEntry(__instance.m_nview); } else if (__instance.m_nview.GetZDO() != null) { num = __instance.m_nview.GetZDO().GetInt(DataObjects.SLS_TREE, 1); } UpdateDrops(__instance, num); __instance.m_health += __instance.m_health * 0.1f * (float)num; ImpactEffect component = ((Component)__instance).GetComponent<ImpactEffect>(); if (component != null) { ((DamageTypes)(ref com