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 Splatform; using StarLevelSystem.Data; using StarLevelSystem.Modifiers; using StarLevelSystem.Modifiers.Control; using StarLevelSystem.common; using StarLevelSystem.modules; using StarLevelSystem.modules.AnimationAndSpeed; using StarLevelSystem.modules.CreatureSetup; using StarLevelSystem.modules.Damage; using StarLevelSystem.modules.Health; using StarLevelSystem.modules.LevelSystem; using StarLevelSystem.modules.Loot; using StarLevelSystem.modules.Raids; using StarLevelSystem.modules.Sizes; using StarLevelSystem.modules.UI; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; 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.19.1")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.19.1.0")] [CompilerGenerated] internal delegate void <>f__AnonymousDelegate0(T1 arg1 = default(T1), T2 arg2 = default(T2), T3 arg3 = default(T3)); 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 GetAllCreatureBaseAttributes(Character creatureId) { return (Dictionary)GetAllBaseAttributeValues.Invoke(null, new object[1] { creatureId }); } public static bool SetAllCreatureBaseAttributes(Character creatureId, Dictionary 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 GetAllCreaturePerLevelAttributes(Character creatureId) { return (Dictionary)GetAllPerLevelAttributeValues.Invoke(null, new object[1] { creatureId }); } public static bool SetAllCreaturePerLevelAttributes(Character creatureId, Dictionary 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 GetAllCreatureDamageReceivedModifiers(Character creatureId) { return (Dictionary)GetAllDamageRecievedModifiers.Invoke(null, new object[1] { creatureId }); } public static bool SetAllCreatureDamageReceivedModifiers(Character creatureId, Dictionary 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 GetAllCreatureFlatDamageBonuses(Character creatureId) { return (Dictionary)GetAllDamageBonus.Invoke(null, new object[1] { creatureId }); } public static bool SetAllCreatureFlatDamageBonuses(Character creatureId, Dictionary 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 GetPossibleModifiers(int modType = 0) { return (List)GetPossibleModifiersForType.Invoke(null, new object[1] { modType }); } public static Dictionary GetCreaturesModifiers(Character creatureId) { return (Dictionary)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, Delegate setupMethod = null, float selectionWeight = 10f, float basepower = 0f, float perlevelpower = 0f, Dictionary> biomeConfig = null, int namingStyle = 2, string name_suffixes = null, string name_prefixes = null, int visualStyle = 0, Sprite starIcon = null, GameObject visualEffect = null, List allowed_creatures = null, List unallowed_creatures = null, List 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 d__137 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ZPackage package; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__137(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 d__138 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ZPackage package; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__138(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 d__136 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ZPackage package; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__136(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 d__139 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ZPackage package; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__139(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 d__145 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ZPackage package; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__145(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; RaidsData.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 d__141 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ZPackage package; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__141(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; string text = package.ReadString(); DataObjects.Music music = DataObjects.yamldeserializer.Deserialize(text); MusicMan.instance.TriggerMusic(music.ToString()); <>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 d__142 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__142(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; RaidControl.RemoveNearbyRunningEvents(); <>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 d__140 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ZPackage package; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__140(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: { <>1__state = -1; string text = package.ReadString(); RaidControl.StartRaidRunner(DataObjects.yamldeserializer.Deserialize(text), ((Component)Player.m_localPlayer).transform.position); <>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 d__143 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__143(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown if (<>1__state != 0) { return false; } <>1__state = -1; if ((Object)(object)Player.m_localPlayer == (Object)null) { return false; } List privateKeysSanitize = Player.m_localPlayer.GetPrivateKeysSanitize(); string text = DataObjects.yamlserializerJsonCompat.Serialize((object)privateKeysSanitize); ZPackage val = new ZPackage(); val.Write(text); if (string.IsNullOrEmpty(text) || privateKeysSanitize.Count <= 0) { Logger.LogDebug("No private keys recieved from player: " + ((Character)Player.m_localPlayer).m_name + ", skipping update to the server."); return false; } if (ZNet.instance.GetServerPeer() != null && ZNet.instance.IsCurrentServerDedicated()) { Logger.LogDebug("Sending private keys to server: " + text); ClientSendPlayerPrivateKeysRPC.SendPackage(ZNet.instance.GetServerPeer().m_uid, val); } else { Logger.LogDebug("Updating server with private keys: " + text); string localUserPlatformAndID = SLSExtensions.GetLocalUserPlatformAndID(); if (string.IsNullOrEmpty(localUserPlatformAndID)) { Logger.LogWarning("Could not update player private keys. Players platform was not detected."); return false; } RaidControl.UpdateOrAddPlayerPrivateKeys(localUserPlatformAndID, privateKeysSanitize); } 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 d__135 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__135(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(); } } [CompilerGenerated] private sealed class d__144 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ZPackage package; public long sender; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__144(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; string text = package.ReadString(); List privatekeys = DataObjects.yamldeserializer.Deserialize>(text); RaidControl.UpdateOrAddPlayerPrivateKeys(sender, privatekeys); 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 const string LevelSettingsFileName = "LevelSettings.yaml"; internal const string ColorSettingsFileName = "ColorSettings.yaml"; internal const string LootSettingsFileName = "LootSettings.yaml"; internal const string ModifiersFileName = "Modifiers.yaml"; internal const string RaidSettingsFileName = "RaidSettings.yaml"; internal const string StarLevelSystem = "StarLevelSystem"; internal const string ServerRaidSavedData = "ServerRaidSavedData.yaml"; internal const string SavedData = "SavedData"; 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", "LootSettings.yaml"); internal static string creatureModifierFilePath = Path.Combine(Paths.ConfigPath, "StarLevelSystem", "Modifiers.yaml"); internal static string raidsFilePath = Path.Combine(Paths.ConfigPath, "StarLevelSystem", "RaidSettings.yaml"); internal static string raidsServerSavedData = Path.Combine(Paths.ConfigPath, "StarLevelSystem", "SavedData", "ServerRaidSavedData.yaml"); internal static bool RecievedConfigsFromServer = false; private static CustomRPC LevelSettingsRPC; private static CustomRPC ColorSettingsRPC; private static CustomRPC CreatureLootSettingsRPC; private static CustomRPC ModifiersRPC; private static CustomRPC RaidsRPC; internal static CustomRPC ClientSendPlayerPrivateKeysRPC; internal static CustomRPC ClientStartRaidRPC; internal static CustomRPC ClientForcePlayMusicRPC; internal static CustomRPC ClientClearNearbyEventsRPC; public static ConfigEntry EnableDebugMode; public static ConfigEntry MaxLevel; public static ConfigEntry OverlevedCreaturesGetRerolledOnLoad; public static ConfigEntry EnableMapRingsForDistanceBonus; public static ConfigEntry DistanceBonusIsFromStarterTemple; public static ConfigEntry MiniMapRingGeneratorUpdatesPerFrame; public static ConfigEntry DistanceRingColorOptions; public static ConfigEntry ControlSpawnerLevels; public static ConfigEntry ForceControlAllSpawns; public static ConfigEntry SpawnsAlwaysControlled; public static ConfigEntry ControlBossSpawns; public static ConfigEntry ControlAbilitySpawnedCreatures; public static ConfigEntry EnableCreatureScalingPerLevel; public static ConfigEntry EnableScalingInDungeons; public static ConfigEntry PerLevelScaleBonus; public static ConfigEntry PerLevelLootScale; public static ConfigEntry ScaleAllLootByLevel; public static ConfigEntry LootDropsPerTick; public static ConfigEntry LootDropCalculationType; public static ConfigEntry LootEggsDropIncreaseStacks; public static ConfigEntry EggLevelDeterminedByItemQuality; public static ConfigEntry OffspringCanBeStrongerThanParents; public static ConfigEntry OffspringGainExtraLevelChance; public static ConfigEntry OffspringCanBeInfertile; public static ConfigEntry OffspringChanceToBeInfertile; public static ConfigEntry EnemyHealthMultiplier; public static ConfigEntry BossEnemyHealthMultiplier; public static ConfigEntry EnemyHealthPerWorldLevel; public static ConfigEntry EnemyDamageLevelMultiplier; public static ConfigEntry BossEnemyDamageMultiplier; public static ConfigEntry EnableScalingBirds; public static ConfigEntry BirdSizeScalePerLevel; public static ConfigEntry EnableScalingFish; public static ConfigEntry FishSizeScalePerLevel; public static ConfigEntry EnableTreeScaling; public static ConfigEntry TreeSizeScalePerLevel; public static ConfigEntry UseDeterministicTreeScaling; public static ConfigEntry RandomizeTameChildrenLevels; public static ConfigEntry RandomizeTameChildrenModifiers; public static ConfigEntry SpawnMultiplicationAppliesToTames; public static ConfigEntry BossCreaturesNeverSpawnMultiply; public static ConfigEntry EnableColorization; public static ConfigEntry EnableRockLevels; public static ConfigEntry EnableRidableCreatureSizeFixes; public static ConfigEntry MultipliedNightSpawnsRemovedDuringDay; public static ConfigEntry PerLevelTreeLootScale; public static ConfigEntry PerLevelBirdLootScale; public static ConfigEntry PerLevelMineRockLootScale; public static ConfigEntry PerLevelDestructibleLootScale; public static ConfigEntry FishMaxLevel; public static ConfigEntry BirdMaxLevel; public static ConfigEntry TreeMaxLevel; public static ConfigEntry RockMaxLevel; public static ConfigEntry DestructibleMaxLevel; public static ConfigEntry MaxMajorModifiersPerCreature; public static ConfigEntry MaxMinorModifiersPerCreature; public static ConfigEntry LimitCreatureModifiersToCreatureStarLevel; public static ConfigEntry ChanceMajorModifier; public static ConfigEntry ChanceMinorModifier; public static ConfigEntry EnableBossModifiers; public static ConfigEntry ChanceOfBossModifier; public static ConfigEntry MaxBossModifiersPerBoss; public static ConfigEntry SplittersInheritLevel; public static ConfigEntry LimitCreatureModifierPrefixes; public static ConfigEntry MinorModifiersFirstInName; public static ConfigEntry EnableDistanceLevelScalingBonus; public static ConfigEntry EnableMultiplayerEnemyHealthScaling; public static ConfigEntry EnableMultiplayerEnemyDamageScaling; public static ConfigEntry MultiplayerScalingRequiredPlayersNearby; public static ConfigEntry MultiplayerEnemyDamageModifier; public static ConfigEntry MultiplayerEnemyHealthModifier; public static ConfigEntry NumberOfCacheUpdatesPerFrame; public static ConfigEntry OutputColorizationGeneratorsData; public static ConfigEntry FallbackDelayBeforeCreatureSetup; public static ConfigEntry InitialDelayBeforeSetup; public static ConfigEntry EnableDebugOutputForDamage; public static ConfigEntry EnableDebugOutputLevelRolls; public static ConfigEntry EnableDebugLootDetails; public static ConfigEntry UseStarShapedModifierIcons; public static ConfigEntry EnemyHealthbarScalarX; public static ConfigEntry EnemyHealthbarScalarY; public static ConfigEntry EnableEnemyHeathbarNumberDisplay; public static ConfigEntry HealthDisplayFontSizeAdjustment; public static ConfigEntry OnlyControlVanillaAreaSpawners; public static ConfigEntry OverrideCreatureModifiedHealth; public static ConfigEntry UseVanillaRaidConfiguration; public static ConfigEntry RaidEventRate; public static ConfigEntry MaxActiveRaids; public static ConfigEntry MaxRaidAttemptsPerPlayer; public static ConfigEntry RaidPerPlayerUpdateCheck; public static ConfigEntry ServerTimeBetweenRaidStartChecks; public static ConfigEntry ConfigPollIntervalSeconds; public ValConfig(ConfigFile cf) { cfg = cf; cfg.SaveOnConfigSet = true; CreateConfigValues(cf); ConfigFileWatcher.Register(cfg.ConfigFilePath, OnMainConfigFileChanged); } 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 //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00d7: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0103: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown //IL_012f: Expected O, but got Unknown //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_015b: Expected O, but got Unknown //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_0187: 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)); RaidsRPC = NetworkManager.Instance.AddRPC("SLS_RaidsRPC", new CoroutineHandler(OnServerRecieveConfigs), new CoroutineHandler(OnClientReceiveRaidConfigs)); ClientSendPlayerPrivateKeysRPC = NetworkManager.Instance.AddRPC("SLS_SendPlayerKeysRPC", new CoroutineHandler(OnServerRecievePlayerPrivateKeys), new CoroutineHandler(OnClientRecieveRequestForPrivatekeys)); ClientStartRaidRPC = NetworkManager.Instance.AddRPC("SLS_ClientStartRaidRPC", new CoroutineHandler(OnServerRecieveConfigs), new CoroutineHandler(OnClientRecieveRaidStart)); ClientForcePlayMusicRPC = NetworkManager.Instance.AddRPC("SLS_ClientForcePlayMusicRPC", new CoroutineHandler(OnServerRecieveConfigs), new CoroutineHandler(OnClientRecieveForcePlayMusic)); ClientClearNearbyEventsRPC = NetworkManager.Instance.AddRPC("SLS_ClientForceRemoveNearbyEventsRPC", new CoroutineHandler(OnServerRecieveConfigs), new CoroutineHandler(OnClientRecieveForceRemoveNearbyEvents)); SynchronizationManager.Instance.AddInitialSynchronization(ClientSendPlayerPrivateKeysRPC, (Func)SendRequestForPrivateKeys); SynchronizationManager.Instance.AddInitialSynchronization(LevelSettingsRPC, (Func)SendLevelsConfigs); SynchronizationManager.Instance.AddInitialSynchronization(ColorSettingsRPC, (Func)SendColorsConfigs); SynchronizationManager.Instance.AddInitialSynchronization(CreatureLootSettingsRPC, (Func)SendCreatureLootConfigs); SynchronizationManager.Instance.AddInitialSynchronization(ModifiersRPC, (Func)SendModifierConfigs); SynchronizationManager.Instance.AddInitialSynchronization(RaidsRPC, (Func)SendRaidConfigs); } 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 //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown EnableDebugMode = Config.Bind("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("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 } })); EnableDebugOutputLevelRolls = Config.Bind("Client config", "EnableDebugOutputLevelRolls", false, new ConfigDescription("Enables Detailed logging for creature levelup rolls.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdvanced = true } })); EnableDebugLootDetails = Config.Bind("Client config", "EnableDebugLootDetails", false, new ConfigDescription("Enables Detailed logging for loot generation.", (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 += UpdateLevelsOnChange.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 += DistanceScaleSystem.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 += DistanceScaleSystem.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 += DistanceScaleSystem.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 += SizeModifications.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."); EnableRidableCreatureSizeFixes = BindServerConfig("LevelSystem", "EnableRidableCreatureSizeFixes", value: true, "Enables collider fixes for ridable creatures (lox and Askavin)."); MultipliedNightSpawnsRemovedDuringDay = BindServerConfig("LevelSystem", "MultipliedNightSpawnsRemovedDuringDay", value: true, "When true, night spawns will be flagged to despawn during the day, which will result in them running away and despawning. This can be disabled if desired."); 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 += UpdateLevelsOnChange.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 += UpdateLevelsOnChange.UpdateBirdSizeOnConfigChange; EnableScalingFish = BindServerConfig("ObjectLevels", "EnableScalingFish", value: true, "Enables star scaling for fish. This does potentially allow huge fish."); EnableScalingFish.SettingChanged += UpdateLevelsOnChange.UpdateFishSizeOnConfigChange; EnableRockLevels = BindServerConfig("ObjectLevels", "EnableRockLevels", value: false, "Enables level scaling for rocks."); 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 birds can scale up to.", advanced: true, 1); TreeMaxLevel = BindServerConfig("ObjectLevels", "TreeMaxLevel", 10, "Sets the max level that trees can scale up to.", advanced: true, 1); RockMaxLevel = BindServerConfig("ObjectLevels", "RockMaxLevel", 10, "Sets the max level that rocks can scale up to.", advanced: true, 1); DestructibleMaxLevel = BindServerConfig("ObjectLevels", "DestructibleMaxLevel", 1, "Sets the max level that generic destructibles can be leveled 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 += UpdateLevelsOnChange.UpdateFishSizeOnConfigChange; EnableTreeScaling = BindServerConfig("ObjectLevels", "EnableTreeScaling", value: true, "Enables level scaling of trees. Make the trees bigger than reasonable? sure why not."); EnableTreeScaling.SettingChanged += UpdateLevelsOnChange.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 += UpdateLevelsOnChange.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); PerLevelMineRockLootScale = BindServerConfig("ObjectLevels", "PerLevelMineRockLootScale", 0.2f, "The amount of additional stones and ores that each level grants for a rock", advanced: true); PerLevelDestructibleLootScale = BindServerConfig("ObjectLevels", "PerLevelDestructibleLootScale", 0.2f, "The amount of additional loot that destructible items grant for each level", 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 += LevelSelection.LeveledCreatureListChanged; LevelSelection.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 ", LootStyles.AllowedLootFactors); LootDropCalculationType.SettingChanged += LootStyles.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); ScaleAllLootByLevel = BindServerConfig("LootSystem", "ScaleAllLootByLevel", value: false, "Enables scaling of all loot which does not normally scale per level. Typically this is just trophies."); LootEggsDropIncreaseStacks = BindServerConfig("LootSystem", "LootEggsDropIncreaseStacks", value: true, "This causes higher level chickens (and other egg producers) to drop MORE eggs instead of higher leveled ones."); EggLevelDeterminedByItemQuality = BindServerConfig("LootSystem", "EggLevelDeterminedByItemQuality", value: false, "When enabled, the level of egg grown creatures is determined by the eggs quality level. Otherwise the grown creature uses its default level configuration."); OffspringCanBeStrongerThanParents = BindServerConfig("LevelSystem", "OffspringCanBeStrongerThanParents", value: false, "When enabled, creatures that are bred can have higher levels than their parents. Otherwise, they will be capped at the highest parent level."); OffspringGainExtraLevelChance = BindServerConfig("LevelSystem", "OffspringGainExtraLevelChance", 0.05f, "When enabled, creatures that are bred have a chance to gain an extra level above their parents. Chance is based on this value, 0.1 = 10% chance.", advanced: false, 0f, 1f); OffspringCanBeInfertile = BindServerConfig("LevelSystem", "OffspringCanBeInfertile", value: false, "When enabled, creatures produced from breeding have a chance to be infertile."); OffspringChanceToBeInfertile = BindServerConfig("LevelSystem", "OffspringChanceToBeInfertile", 0.5f, "When enabled, the chance that a creature produced from breeding will be infertile.", advanced: true, 0f, 1f); UseVanillaRaidConfiguration = BindServerConfig("Raids", "UseVanillaRaidConfiguration", value: false, "Reverts to use vanilla raid configuration when enabled."); RaidEventRate = BindServerConfig("Raids", "RaidEventRate", 1f, "The rate at which raid events occur (Vanilla is 1.0), higher values result in less frequent raids, lower values results in more frequent raids. This modifies the raid timing settings which are set per-raid.", advanced: false, 0.001f, 10f); MaxRaidAttemptsPerPlayer = BindServerConfig("Raids", "MaxRaidAttemptsPerPlayer", 5, "The Maximum number of times to try to activate a raid for a given player. The available raids will be shuffled each time before rolling their activation chance. With 10 raids defined the randomly selected first X will get a chance to spawn.", advanced: true, 0, 50); RaidPerPlayerUpdateCheck = BindServerConfig("Raids", "RaidPerPlayerUpdateCheck", 10f, "The Interval in minutes between updating the valid raids for each player. Reduce if you want new raids to become available faster for players, increase to reduce pressure on server.", advanced: true, 1f, 120f); ServerTimeBetweenRaidStartChecks = BindServerConfig("Raids", "ServerTimeBetweenRaidStartChecks", 25, "Number of minutes between when the server whill check to start raids (raids can still be on cooldown and will not be started).", advanced: true, 1, 120); MaxActiveRaids = BindServerConfig("Raids", "MaxActiveRaids", 10, "The maximum number of concurrent raids, automatically limited to 1 per player."); 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."); MinorModifiersFirstInName = BindServerConfig("Modifiers", "MinorModifiersFirstInName", value: false, "Enables or disables ordering of modifiers for naming. If enabled, minor modifiers will be sorted first eg: Fast Poisonous"); UseStarShapedModifierIcons = BindServerConfig("Modifiers", "UseStarShapedModifierIcons", value: true, "When enabled, uses modifier icons that are star shaped. When disabled, uses non-star shaped modifier icons. Requires a restart.", null, advanced: true); EnemyHealthbarScalarX = BindServerConfig("UI", "EnemyHealthbarScalarX", 1f, "The scale of the health bar for typical enemies. This does not impact bosses or players.", advanced: false, 0f, 4f); EnemyHealthbarScalarY = BindServerConfig("UI", "EnemyHealthbarScalarY", 1.75f, "The scale of the health bar for typical enemies. This does not impact bosses or players.", advanced: false, 0f, 4f); HealthDisplayFontSizeAdjustment = BindServerConfig("UI", "HealthDisplayFontSizeAdjustment", 0.8f, "Percentage modification for the font size on creature health."); EnableEnemyHeathbarNumberDisplay = BindServerConfig("UI", "EnableEnemyHeathbarNumberDisplay", value: false, "Enables a numerical display for enemy creatures health"); 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."); ConfigPollIntervalSeconds = BindServerConfig("Misc", "ConfigPollIntervalSeconds", 30f, "The number of seconds between checks for changes in the yaml config files.", advanced: true, 1f, 300f); OnlyControlVanillaAreaSpawners = BindServerConfig("ModCompat", "OnlyControlVanillaAreaSpawners", value: true, "When enabled, will only control the spawned level from an AreaSpawner if it is a vanilla one."); OverrideCreatureModifiedHealth = BindServerConfig("ModCompat", "OverrideCreatureModifiedHealth", value: false, "When enabled, will always set creatures health based on the SLS settings for the creature. This overrides other mods changes to creatures."); } internal static void RecievedServerUpdates() { RecievedConfigsFromServer = true; } internal void LoadYamlConfigs() { string[] files = Directory.GetFiles(GetSecondaryConfigDirectoryPath()); bool flag = false; bool flag2 = false; bool flag3 = false; bool flag4 = false; bool flag5 = 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 (text.Contains("RaidSettings.yaml")) { Logger.LogDebug("Found raid configuration: " + text); raidsFilePath = text; flag5 = 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()); } if (!flag5) { Logger.LogDebug("Raid config file missing, recreating."); using StreamWriter streamWriter5 = new StreamWriter(raidsFilePath); string value5 = "#################################################\n# Star Level System Expanded - Raid Settings\n#################################################\n"; streamWriter5.WriteLine(value5); streamWriter5.WriteLine(RaidsData.YamlDefaultConfig()); } ConfigFileWatcher.Register(colorsFilePath, UpdateColorSettings); ConfigFileWatcher.Register("LevelSettings.yaml", UpdateLevelSettings); ConfigFileWatcher.Register(creatureModifierFilePath, UpdateModifierSettings); ConfigFileWatcher.Register(creatureLootFilePath, UpdateLootSettings); ConfigFileWatcher.Register(raidsFilePath, UpdateRaidSettings); } private static void UpdateColorSettings(string fullFileName) { Logger.LogDebug("Triggering Color Settings update."); Colorization.UpdateYamlConfig(File.ReadAllText(fullFileName)); ColorSettingsRPC.SendPackage(ZNet.instance.m_peers, SendFileAsZPackage(fullFileName)); } private static void UpdateLevelSettings(string fullFileName) { Logger.LogDebug("Triggering Level Settings update."); LevelSystemData.UpdateYamlConfig(File.ReadAllText(fullFileName)); LevelSettingsRPC.SendPackage(ZNet.instance.m_peers, SendFileAsZPackage(fullFileName)); } private static void UpdateLootSettings(string fullFileName) { Logger.LogDebug("Triggering Loot Settings update."); LootSystemData.UpdateYamlConfig(File.ReadAllText(fullFileName)); CreatureLootSettingsRPC.SendPackage(ZNet.instance.m_peers, SendFileAsZPackage(fullFileName)); } private static void UpdateModifierSettings(string fullFileName) { Logger.LogDebug("Triggering Modifiers Settings update."); CreatureModifiersData.UpdateModifierConfig(File.ReadAllText(fullFileName)); ModifiersRPC.SendPackage(ZNet.instance.m_peers, SendFileAsZPackage(fullFileName)); } private static void UpdateRaidSettings(string fullFileName) { Logger.LogDebug("Triggering Raid Settings update."); RaidsData.UpdateYamlConfig(File.ReadAllText(fullFileName)); RaidsRPC.SendPackage(ZNet.instance.m_peers, SendFileAsZPackage(fullFileName)); } private static void OnMainConfigFileChanged(string _) { if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer()) { Logger.LogInfo("Configuration file has been changed, reloading settings."); cfg.Reload(); } } 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); } private static ZPackage SendRaidConfigs() { return SendFileAsZPackage(raidsFilePath); } private static ZPackage SendRequestForPrivateKeys() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown return new ZPackage(); } [IteratorStateMachine(typeof(d__135))] public static IEnumerator OnServerRecieveConfigs(long sender, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__135(0); } [IteratorStateMachine(typeof(d__136))] private static IEnumerator OnClientReceiveLevelConfigs(long sender, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__136(0) { package = package }; } [IteratorStateMachine(typeof(d__137))] private static IEnumerator OnClientReceiveColorConfigs(long sender, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__137(0) { package = package }; } [IteratorStateMachine(typeof(d__138))] private static IEnumerator OnClientReceiveCreatureLootConfigs(long sender, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__138(0) { package = package }; } [IteratorStateMachine(typeof(d__139))] private static IEnumerator OnClientReceiveModifiersConfigs(long sender, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__139(0) { package = package }; } [IteratorStateMachine(typeof(d__140))] private static IEnumerator OnClientRecieveRaidStart(long sender, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__140(0) { package = package }; } [IteratorStateMachine(typeof(d__141))] private static IEnumerator OnClientRecieveForcePlayMusic(long sender, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__141(0) { package = package }; } [IteratorStateMachine(typeof(d__142))] private static IEnumerator OnClientRecieveForceRemoveNearbyEvents(long sender, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__142(0); } [IteratorStateMachine(typeof(d__143))] internal static IEnumerator OnClientRecieveRequestForPrivatekeys(long sender, ZPackage _) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__143(0); } [IteratorStateMachine(typeof(d__144))] private static IEnumerator OnServerRecievePlayerPrivateKeys(long sender, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__144(0) { sender = sender, package = package }; } [IteratorStateMachine(typeof(d__145))] private static IEnumerator OnClientReceiveRaidConfigs(long sender, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__145(0) { package = package }; } public static string GetSecondaryConfigDirectoryPath() { return Directory.CreateDirectory(Path.Combine(Paths.ConfigPath, "StarLevelSystem")).FullName; } public static string GetSavedDataSecondaryConfigDirectoryPath() { return Directory.CreateDirectory(Path.Combine(Paths.ConfigPath, "StarLevelSystem", "SavedData")).FullName; } public static ConfigEntry 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(catagory, key, value, new ConfigDescription(description, acceptableValues, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry 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(catagory, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange(valmin, valmax), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry 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(catagory, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange(valmin, valmax), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry BindServerConfig(string catagory, string key, string value, string description, AcceptableValueList 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(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.19.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInIncompatibility("org.bepinex.plugins.creaturelevelcontrol")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class StarLevelSystem : BaseUnityPlugin { public const string PluginGUID = "MidnightsFX.StarLevelSystem"; public const string PluginName = "StarLevelSystem"; public const string PluginVersion = "0.19.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(); TaskRunner.Setup(); Compatibility.CheckModCompat(); EmbeddedResourceBundle = AssetUtils.LoadAssetBundleFromResources("StarLevelSystem.assets.starlevelsystems", typeof(StarLevelSystem).Assembly); HarmonyInstance = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "MidnightsFX.StarLevelSystem"); Colorization.Init(); LevelSystemData.Init(); LootSystemData.Init(); CreatureModifiersData.Init(); RaidsData.Init(); LocalizationLoader.AddLocalizations(); PrefabManager.OnVanillaPrefabsAvailable += CreatureModifiersData.LoadPrefabs; PrefabManager.OnVanillaPrefabsAvailable += UpdateLevelsOnChange.UpdateFishmaxLevel; PrefabManager.OnVanillaPrefabsAvailable += UIHudControl.SetDefaultStar; PrefabManager.OnPrefabsRegistered += LootSystemData.AttachPrefabsWhenReady; MinimapManager.OnVanillaMapDataLoaded += DistanceScaleSystem.DelayedMinimapSetup; PrefabManager.OnPrefabsRegistered += SizeModifications.PrepareSizeRefCache; SynchronizationManager.OnConfigurationSynchronized += delegate { ValConfig.RecievedServerUpdates(); }; UIHudControl.LoadAssets(); RaidControl.LoadAssets(); TerminalCommands.AddCommands(); } } } namespace StarLevelSystem.modules { public static class APIReciever { public static bool UpdateCreatureLevel(Character chara, int level) { if ((Object)(object)chara == (Object)null) { return false; } Logger.LogDebug($"SLS-API: Update Creature level {chara} - {level}"); LevelSelection.SetAndUpdateCharacterLevel(chara, level); return true; } public static bool UpdateCreatureColorization(Character chara, float value, float hue, float sat, bool emission = false) { if ((Object)(object)chara == (Object)null) { return 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) { if ((Object)(object)chara == (Object)null) { return -1f; } return CompositeLazyCache.GetAndSetLocalCache(chara)?.CreatureBaseValueModifiers[(DataObjects.CreatureBaseAttribute)attribute] ?? (-1f); } public static bool UpdateCreatureBaseAttributes(Character chara, int attribute, float value) { if ((Object)(object)chara == (Object)null) { return false; } DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return false; } andSetLocalCache.CreatureBaseValueModifiers[(DataObjects.CreatureBaseAttribute)attribute] = value; if (attribute == 4) { SizeModifications.SetSizeModification(((Component)chara).gameObject, chara.m_nview, andSetLocalCache, update: true); } return true; } public static Dictionary GetAllBaseAttributes(Character chara) { if ((Object)(object)chara == (Object)null) { return null; } DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return null; } Dictionary dictionary = new Dictionary(); foreach (KeyValuePair creatureBaseValueModifier in andSetLocalCache.CreatureBaseValueModifiers) { dictionary[(int)creatureBaseValueModifier.Key] = creatureBaseValueModifier.Value; } return dictionary; } public static bool SetAllBaseAttributes(Character chara, Dictionary attributes) { if ((Object)(object)chara == (Object)null) { return false; } DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return false; } foreach (KeyValuePair attribute in attributes) { andSetLocalCache.CreatureBaseValueModifiers[(DataObjects.CreatureBaseAttribute)attribute.Key] = attribute.Value; } CompositeLazyCache.UpdateCharacterCacheEntry(chara, andSetLocalCache); SpeedModifications.ApplySpeedModifications(chara, andSetLocalCache); DamageModifications.ApplyDamageModification(chara, andSetLocalCache); SizeModifications.SetSizeModification(((Component)chara).gameObject, chara.m_nview, andSetLocalCache, update: true); HealthModifications.ForceApplyHealthModifications(chara, andSetLocalCache); return true; } public static float GetPerLevelAttributeValue(Character chara, int attribute) { if ((Object)(object)chara == (Object)null) { return -1f; } return CompositeLazyCache.GetAndSetLocalCache(chara)?.CreaturePerLevelValueModifiers[(DataObjects.CreaturePerLevelAttribute)attribute] ?? (-1f); } public static bool UpdateCreaturePerLevelAttributes(Character chara, int attribute, float value) { if ((Object)(object)chara == (Object)null) { return false; } DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return false; } andSetLocalCache.CreaturePerLevelValueModifiers[(DataObjects.CreaturePerLevelAttribute)attribute] = value; if (attribute == 4) { SizeModifications.SetSizeModification(((Component)chara).gameObject, chara.m_nview, andSetLocalCache, update: true); } return true; } public static Dictionary GetAllPerLevelAttributes(Character chara) { if ((Object)(object)chara == (Object)null) { return null; } DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return null; } Dictionary dictionary = new Dictionary(); foreach (KeyValuePair creaturePerLevelValueModifier in andSetLocalCache.CreaturePerLevelValueModifiers) { dictionary[(int)creaturePerLevelValueModifier.Key] = creaturePerLevelValueModifier.Value; } return dictionary; } public static bool SetAllPerLevelAttributes(Character chara, Dictionary attributes) { if ((Object)(object)chara == (Object)null) { return false; } DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return false; } foreach (KeyValuePair attribute in attributes) { andSetLocalCache.CreaturePerLevelValueModifiers[(DataObjects.CreaturePerLevelAttribute)attribute.Key] = attribute.Value; } CompositeLazyCache.UpdateCharacterCacheEntry(chara, andSetLocalCache); SpeedModifications.ApplySpeedModifications(chara, andSetLocalCache); DamageModifications.ApplyDamageModification(chara, andSetLocalCache); SizeModifications.SetSizeModification(((Component)chara).gameObject, chara.m_nview, andSetLocalCache, update: true); HealthModifications.ForceApplyHealthModifications(chara, andSetLocalCache); return true; } public static float GetCreatureDamageRecievedModifier(Character chara, int attribute) { if ((Object)(object)chara == (Object)null) { return -1f; } return CompositeLazyCache.GetAndSetLocalCache(chara)?.DamageRecievedModifiers[(DataObjects.DamageType)attribute] ?? (-1f); } public static bool UpdateCreatureDamageRecievedModifier(Character chara, int attribute, float value) { if ((Object)(object)chara == (Object)null) { return false; } DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return false; } andSetLocalCache.DamageRecievedModifiers[(DataObjects.DamageType)attribute] = value; return true; } public static Dictionary GetAllDamageRecievedModifiers(Character chara) { if ((Object)(object)chara == (Object)null) { return null; } DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return null; } Dictionary dictionary = new Dictionary(); foreach (KeyValuePair damageRecievedModifier in andSetLocalCache.DamageRecievedModifiers) { dictionary[(int)damageRecievedModifier.Key] = damageRecievedModifier.Value; } return dictionary; } public static bool SetAllDamageRecievedModifiers(Character chara, Dictionary attributes) { if ((Object)(object)chara == (Object)null) { return false; } DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return false; } foreach (KeyValuePair attribute in attributes) { andSetLocalCache.DamageRecievedModifiers[(DataObjects.DamageType)attribute.Key] = attribute.Value; } CompositeLazyCache.UpdateCharacterCacheEntry(chara, andSetLocalCache); DamageModifications.ApplyDamageModification(chara, andSetLocalCache); return true; } public static float GetCreatureDamageBonus(Character chara, int attribute) { if ((Object)(object)chara == (Object)null) { return -1f; } 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) { if ((Object)(object)chara == (Object)null) { return false; } 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 GetAllDamageBonus(Character chara) { if ((Object)(object)chara == (Object)null) { return null; } DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return null; } Dictionary dictionary = new Dictionary(); foreach (KeyValuePair creatureDamageBonu in andSetLocalCache.CreatureDamageBonus) { dictionary[(int)creatureDamageBonu.Key] = creatureDamageBonu.Value; } return dictionary; } public static bool SetAllDamageBonus(Character chara, Dictionary attributes) { if ((Object)(object)chara == (Object)null) { return false; } DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return false; } foreach (KeyValuePair attribute in attributes) { andSetLocalCache.CreatureDamageBonus[(DataObjects.DamageType)attribute.Key] = attribute.Value; } CompositeLazyCache.UpdateCharacterCacheEntry(chara, andSetLocalCache); DamageModifications.ApplyDamageModification(chara, andSetLocalCache); return true; } public static bool ApplyUpdatesToCreature(Character chara) { if ((Object)(object)chara == (Object)null) { return false; } DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara); if (andSetLocalCache == null) { return false; } SpeedModifications.ApplySpeedModifications(chara, andSetLocalCache); DamageModifications.ApplyDamageModification(chara, andSetLocalCache); SizeModifications.SetSizeModification(((Component)chara).gameObject, chara.m_nview, andSetLocalCache, update: true); HealthModifications.ForceApplyHealthModifications(chara, andSetLocalCache); return true; } public static List GetPossibleModifiersForType(int modifierType) { List list = new List(); 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 GetAllModifiersForCreature(Character chara) { Dictionary creatureModifiers = CompositeLazyCache.GetCreatureModifiers(chara); if (creatureModifiers == null) { return null; } Dictionary dictionary = new Dictionary(); foreach (KeyValuePair 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, Delegate setupMethod = null, float selectionWeight = 10f, float basepower = 0f, float perlevelpower = 0f, Dictionary> biomeConfig = null, int namingStyle = 2, string name_suffixes = null, string name_prefixes = null, int visualStyle = 0, Sprite starIcon = null, GameObject visualEffect = null, List allowed_creatures = null, List unallowed_creatures = null, List 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 ((object)setupMethod != null) { creatureModifierDefinition.SetupEvent = 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 mapRingColors = new List(); public static readonly Dictionary defaultColors = new Dictionary { { "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 { Colorization.creatureColorizationSettings = DataObjects.yamldeserializer.Deserialize(yaml); foreach (KeyValuePair item in defaultColorizationSettings.defaultLevelColorization) { if (!Colorization.creatureColorizationSettings.defaultLevelColorization.Keys.Contains(item.Key)) { Colorization.creatureColorizationSettings.defaultLevelColorization.Add(item.Key, item.Value); } } if (Colorization.creatureColorizationSettings.characterColorGenerators != null) { Logger.LogInfo("Running color generators"); DataObjects.CreatureColorizationSettings creatureColorizationSettings = Colorization.creatureColorizationSettings; if (creatureColorizationSettings.characterSpecificColorization == null) { Dictionary> dictionary2 = (creatureColorizationSettings.characterSpecificColorization = new Dictionary>()); } foreach (KeyValuePair> characterColorGenerator in Colorization.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)Colorization.creatureColorizationSettings)); } } Logger.LogInfo("Updated ColorizationSettings."); Character[] array = Resources.FindObjectsOfTypeAll(); 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)); StarLevelSystem.Log.LogError((object)"Colorization will use internal defaults."); Colorization.creatureColorizationSettings = defaultColorizationSettings; return false; } return true; } public static void ApplyLevelVisual(Character charc) { LevelEffects componentInChildren = ((Component)charc).gameObject.GetComponentInChildren(); 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 != null && 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(); 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 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()); } 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 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 bool IsDropThatEnabled; public static bool IsExpandWorldEnabled; private static Type DropThatDropTableSessionManager; private static Type DropThatCharacterDropSessionManager; private static MethodInfo DropThatModifyDrop; private static MethodInfo DropThatModifyInstantiatedObjectDrop; public static bool DropThatMethodsAvailable { get { if (DropThatDropTableSessionManager != null) { return DropThatCharacterDropSessionManager != null; } return false; } } internal static void CheckModCompat() { try { Dictionary plugins = BepInExUtils.GetPlugins(false); if (plugins == null) { return; } if (plugins.Keys.Contains("asharppen.valheim.drop_that")) { IsDropThatEnabled = true; DropThatCharacterDropSessionManager = Type.GetType("DropThat.Drop.DropTableSystem.Managers.DropTableSessionManager, DropThat"); DropThatDropTableSessionManager = Type.GetType("DropThat.Drop.CharacterDropSystem.Managers.CharacterDropSessionManager, DropThat"); if (DropThatMethodsAvailable) { DropThatModifyInstantiatedObjectDrop = DropThatDropTableSessionManager.GetMethod("ModifyDrop", BindingFlags.Static | BindingFlags.Public); DropThatModifyDrop = DropThatCharacterDropSessionManager.GetMethod("ModifyDrop", BindingFlags.Static | BindingFlags.Public); } else { Logger.LogWarning("Warning: Compat methods for DropThat not found, strict compatibility patches will be used."); } } if (plugins.Keys.Contains("expand_world_size")) { IsExpandWorldEnabled = true; } } catch { Logger.LogWarning("Unable to check mod compatibility. Ensure that Bepinex can load."); } } public static bool DropThat_ModifyDrop(GameObject drop, List> drops, int index) { if (!DropThatMethodsAvailable) { return false; } return (bool)DropThatModifyDrop.Invoke(null, new object[2] { drop, index }); } public static bool DropThat_ModifyInstantiatedObjectDrop(GameObject drop, int index) { if (!DropThatMethodsAvailable) { return false; } return (bool)DropThatModifyInstantiatedObjectDrop.Invoke(null, new object[2] { drop, index }); } } public static class MultiplayerDamageMod { [HarmonyPatch(typeof(Game), "GetDifficultyDamageScalePlayer")] public static class PatchPerPlayerDamageScaling { public static bool Prefix(Game __instance, Vector3 pos, ref float __result) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!ValConfig.EnableMultiplayerEnemyDamageScaling.Value) { __result = 1f; return false; } int playerDifficulty = __instance.GetPlayerDifficulty(pos); if (playerDifficulty >= ValConfig.MultiplayerScalingRequiredPlayersNearby.Value) { float num = (1f + (float)playerDifficulty) * ValConfig.MultiplayerEnemyDamageModifier.Value; __result = 1f + num; } else { __result = 1f; } return false; } } } public static class MultiplayerHealthMod { [HarmonyPatch(typeof(Game), "GetDifficultyDamageScaleEnemy")] public static class PatchPerPlayerDamageScaling { public static bool Prefix(Game __instance, Vector3 pos, ref float __result) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!ValConfig.EnableMultiplayerEnemyHealthScaling.Value) { __result = 1f; return false; } int playerDifficulty = __instance.GetPlayerDifficulty(pos); if (playerDifficulty >= ValConfig.MultiplayerScalingRequiredPlayersNearby.Value) { __result = 1f - (float)playerDifficulty * ValConfig.MultiplayerEnemyHealthModifier.Value; } else { __result = 1f; } return false; } } } internal class SpawnLevelExtension { [HarmonyPatch] internal static class SpawnCommandDelegate { [HarmonyTargetMethod] internal static MethodBase FindSpawnCommandDelegateMethod() { return (from method in AccessTools.GetDeclaredMethods(typeof(Terminal)) where method.Name.IndexOf("__spawn|", StringComparison.Ordinal) >= 0 select method).FirstOrDefault(); } [HarmonyTranspiler] internal static IEnumerable SpawnCommandDelegateTranspiler(IEnumerable instructions, ILGenerator generator) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Expected O, but got Unknown //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Expected O, but got Unknown //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Expected O, but got Unknown //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Expected O, but got Unknown //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Expected O, but got Unknown //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Expected O, but got Unknown //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Expected O, but got Unknown //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Expected O, but got Unknown Type[] array = new Type[2] { typeof(int), typeof(int) }; return new CodeMatcher(instructions, generator).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(ItemDrop), "OnCreateNew", new Type[1] { typeof(GameObject) }, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null) }).ThrowIfInvalid("Could not patch Terminal.SpawnCommandDelegate()! (level-compare)") .Advance(3) .RemoveInstruction() .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_I4_0, (object)null) }) .MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Mathf), "Min", array, (Type[])null), (string)null) }) .ThrowIfInvalid("Could not patch Terminal.SpawnCommandDelegate()! (mathf-min-4)") .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(SpawnCommandDelegate), "MathfMinDelegate", (Type[])null, (Type[])null))) .MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Mathf), "Min", array, (Type[])null), (string)null) }) .ThrowIfInvalid("Could not patch Terminal.SpawnCommandDelegate()! (mathf-min-9)") .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(SpawnCommandDelegate), "MathfMinDelegate", (Type[])null, (Type[])null))) .MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Character), "SetLevel", (Type[])null, (Type[])null), (string)null) }) .RemoveInstructions(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(SpawnCommandDelegate), "SetCreatureSpawnLevel", (Type[])null, (Type[])null)) }) .ThrowIfInvalid("Could not patch terminal.SpawnCommandDelegate()! (SetCreatureSpawnLevel)") .MatchStartForward((CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_4, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stfld, (object)null, (string)null) }) .ThrowIfInvalid("Could not patch Terminal.SpawnCommandDelegate()! (set-level-4)") .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .InstructionEnumeration(); } private static int MathfMinDelegate(int level, int value) { return level; } private static void SetCreatureSpawnLevel(Character chara, int level) { CompositeLazyCache.GetAndSetLocalCache(chara, level, null, null, updateCache: true); chara.m_nview.GetZDO().Set(ZDOVars.s_level, level, false); CreatureSetupControl.CreatureSetup(chara, level, multiply: false, 0.01f); } } } internal class Spawnrate { [CompilerGenerated] private sealed class d__1 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public GameObject go; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)go != (Object)null) { Character component = go.GetComponent(); if ((Object)(object)component != (Object)null && component.m_tamed) { return false; } CharacterDrop component2 = go.GetComponent(); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); } ZNetScene.instance.Destroy(go); } 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(); } } internal static bool CheckSetApplySpawnrate(Character chara, DataObjects.CharacterCacheEntry ccEntry) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) if (ValConfig.BossCreaturesNeverSpawnMultiply.Value && chara.IsBoss()) { return false; } if (chara.IsTamed() && ValConfig.SpawnMultiplicationAppliesToTames.Value) { return false; } if (chara.m_nview.GetZDO().GetBool(DataObjects.SLS_SPAWN_MULT, false)) { return false; } chara.m_nview.GetZDO().Set(DataObjects.SLS_SPAWN_MULT, true); float spawnRateModifier = ccEntry.SpawnRateModifier; if (spawnRateModifier > 1f) { for (spawnRateModifier -= 1f; spawnRateModifier > 0f; spawnRateModifier -= 1f) { if (Random.value <= spawnRateModifier) { Vector3 val = ((Component)chara).transform.position; if (((Component)chara).transform.position.y < 3000f) { val = DetermineOffsetPosition(val, 15f); } Quaternion val2 = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f); GameObject val3 = Object.Instantiate(PrefabManager.Instance.GetPrefab(ccEntry.RefCreatureName), val, val2); Character component = val3.GetComponent(); if (chara.IsTamed() && (Object)(object)component != (Object)null) { component.SetTamed(true); } Logger.LogDebug($"Spawn Multiplier| Spawned {val3.gameObject} at {val}"); CreatureSetupControl.CreatureSetup(component, 0, multiply: false); component.m_nview.GetZDO().Set(DataObjects.SLS_SPAWN_MULT, true); if (ValConfig.MultipliedNightSpawnsRemovedDuringDay.Value && EnvMan.IsNight()) { MonsterAI component2 = ((Component)component).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.SetDespawnInDay(true); } } } } } else if (spawnRateModifier < 1f && Random.value >= spawnRateModifier) { Logger.LogDebug("Spawn Reducer| Selecting " + ccEntry.RefCreatureName + " for deletion."); ZNetScene.instance.Destroy(((Component)chara).gameObject); return true; } return false; } [IteratorStateMachine(typeof(d__1))] internal static IEnumerator DestroyCoroutine(GameObject go) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { go = go }; } internal static Vector3 DetermineOffsetPosition(Vector3 sourcePosition, float radius) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) float num = default(float); ZoneSystem.instance.GetGroundHeight(sourcePosition, ref num); float num2 = 0f; if (num > sourcePosition.y + 2f) { num2 = Mathf.Abs(sourcePosition.y - num); if (num2 < 0f) { num2 = 0f; } } int num3 = 0; if (num3 < 10) { Vector2 val = Random.insideUnitCircle * (radius * 0.8f); Vector3 val2 = sourcePosition + new Vector3(val.x, 0f, val.y); num3++; float num4 = default(float); ZoneSystem.instance.GetGroundHeight(new Vector3(val2.x, val2.y + 100f, val2.z), ref num4); val2.y = num4 + num2; return val2; } return sourcePosition; } } internal static class TaskRunner { internal static GameObject RunnerGO; internal static Orchestrator Instance; internal static void Setup() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0020: Expected O, but got Unknown GameObject val = new GameObject("StarLevelSystem_TaskRunner"); Instance = val.AddComponent(); RunnerGO = val; Object.DontDestroyOnLoad((Object)val); } internal static Orchestrator Run() { if ((Object)(object)Instance != (Object)null) { return Instance; } Setup(); return Instance; } } internal class Orchestrator : MonoBehaviour { } } namespace StarLevelSystem.modules.UI { internal static class UIHudControl { public class StarLevelHud { public Dictionary Starlevel = new Dictionary(); public Dictionary StarLevelFront = new Dictionary(); public Dictionary StarLevelBack = new Dictionary(); public bool IsBoss { get; set; } public string CreatureNameLocalized { get; set; } public int Level { get; set; } = 1; public List DisplayedMods { get; set; } = new List(); public GameObject StarLevelN { get; set; } public Image StarLevelNFrontImage { get; set; } public Image StarLevelNBackImage { get; set; } public Text StarLevelNText { get; set; } public HudData Hudlink { get; set; } public TextMeshProUGUI HealthText { get; set; } } public static Dictionary characterExtendedHuds = new Dictionary(); private static GameObject HealthText; private static Sprite defaultStar; internal static void SetDefaultStar() { defaultStar = Cache.GetPrefab("craft_icon"); } internal static void RemoveExtendedHudFromCache(uint id) { if (characterExtendedHuds.ContainsKey(id)) { if ((Object)(object)characterExtendedHuds[id].HealthText != (Object)null) { Object.Destroy((Object)(object)((Component)characterExtendedHuds[id].HealthText).gameObject); } characterExtendedHuds.Remove(id); } } public static void InvalidateCacheEntry(Character chara) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) ZDOID zDOID = chara.GetZDOID(); uint iD = ((ZDOID)(ref zDOID)).ID; CompositeLazyCache.GetAndSetLocalCache(chara); if (characterExtendedHuds.ContainsKey(iD)) { DataObjects.CharacterCacheEntry cacheEntry = CompositeLazyCache.GetCacheEntry(iD); StarLevelHud starLevelHud = characterExtendedHuds[iD]; cacheEntry.CreatureModifiers = CompositeLazyCache.GetCreatureModifiers(starLevelHud.Hudlink.m_character); Dictionary creatureModifiers = CompositeLazyCache.GetCreatureModifiers(starLevelHud.Hudlink.m_character); cacheEntry.CreatureNameLocalizable = CreatureModifiers.BuildCreatureLocalizableName(starLevelHud.Hudlink.m_character, creatureModifiers); cacheEntry.CreatureModifiers = creatureModifiers; starLevelHud.Level = cacheEntry.Level; UpdateHudModifiers(iD, starLevelHud, creatureModifiers); _ = cacheEntry?.CreatureNameLocalizable; } } internal static void StarLevelHudDisplay(GameObject star, Transform basehud, Transform bosshud) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Expected O, but got Unknown //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) SetupStar(star, 2, basehud); SetupStar(star, 3, basehud); SetupStar(star, 4, basehud); SetupStar(star, 5, basehud); SetupStar(star, 6, basehud); GameObject val = new GameObject("SLS_level_n"); val.transform.SetParent(basehud); GameObject obj = Object.Instantiate(star, val.transform); val.transform.localPosition = new Vector3(-42f, 19f, 0f); obj.transform.localPosition = new Vector3(0f, 0f, 0f); GameObject val2 = Object.Instantiate(new GameObject("level_n_name"), val.transform); val2.transform.SetParent(val.transform); val2.transform.localPosition = new Vector3(0f, 0f, 0f); GUIManager.Instance.CreateText("999", val2.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(185f, -13f), GUIManager.Instance.AveriaSerifBold, 14, GUIManager.Instance.ValheimYellow, true, Color.black, 350f, 40f, false); val.SetActive(false); SetupStar(star, 2, bosshud, boss: true); SetupStar(star, 3, bosshud, boss: true); SetupStar(star, 4, bosshud, boss: true); SetupStar(star, 5, bosshud, boss: true); SetupStar(star, 6, bosshud, boss: true); GameObject val3 = new GameObject("SLS_level_n"); val3.transform.SetParent(bosshud); GameObject obj2 = Object.Instantiate(star, val3.transform); obj2.GetComponent().sizeDelta = new Vector2(20f, 20f); ((Component)obj2.transform.Find("star (1)")).gameObject.GetComponent().sizeDelta = new Vector2(16f, 16f); val3.transform.localPosition = new Vector3(-17f, -6f, 0f); obj2.transform.localPosition = new Vector3(0f, 0f, 0f); GameObject val4 = Object.Instantiate(new GameObject("level_n_name"), val3.transform); val4.transform.SetParent(val3.transform); val4.transform.localPosition = new Vector3(0f, 0f, 0f); GUIManager.Instance.CreateText("999", val4.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(185f, -7f), GUIManager.Instance.AveriaSerifBold, 23, GUIManager.Instance.ValheimYellow, true, Color.black, 350f, 40f, false); val3.SetActive(false); } private static void SetupStar(GameObject star, int level, Transform parent_t, bool boss = false) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject($"SLS_level_{level}"); val.transform.SetParent(parent_t); GameObject val2 = Object.Instantiate(star, val.transform); if (boss) { RectTransform component = ((Component)val2.transform.Find("star (1)")).gameObject.GetComponent(); RectTransform component2 = val2.GetComponent(); component.sizeDelta = new Vector2(16f, 16f); component2.sizeDelta = new Vector2(20f, 20f); } val.SetActive(false); switch (level) { case 2: if (boss) { val.transform.localPosition = new Vector3(0f, -6f, 0f); break; } val.transform.localPosition = new Vector3(-41f, 19f, 0f); val2.transform.localPosition = new Vector3(0f, 0f, 0f); break; case 3: if (boss) { val.transform.localPosition = new Vector3(-20f, -6f, 0f); break; } val.transform.localPosition = new Vector3(-25f, 19f, 0f); val2.transform.localPosition = new Vector3(0f, 0f, 0f); break; case 4: if (boss) { val.transform.localPosition = new Vector3(20f, -6f, 0f); val2.transform.localPosition = new Vector3(0f, 0f, 0f); } else { val.transform.localPosition = new Vector3(-9f, 19f, 0f); val2.transform.localPosition = new Vector3(0f, 0f, 0f); } break; case 5: if (boss) { val.transform.localPosition = new Vector3(-40f, -6f, 0f); val2.transform.localPosition = new Vector3(0f, 0f, 0f); } else { val.transform.localPosition = new Vector3(7f, 19f, 0f); val2.transform.localPosition = new Vector3(0f, 0f, 0f); } break; case 6: if (boss) { val.transform.localPosition = new Vector3(40f, -6f, 0f); val2.transform.localPosition = new Vector3(0f, 0f, 0f); } else { val.transform.localPosition = new Vector3(23f, 19f, 0f); val2.transform.localPosition = new Vector3(0f, 0f, 0f); } break; } } public static void UpdateHudforAllLevels(HudData ehud) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) if (ehud == null || (Object)(object)ehud.m_character == (Object)null || ehud.m_character.IsPlayer()) { return; } int level = ehud.m_character.GetLevel(); ZDOID zDOID = ehud.m_character.GetZDOID(); uint iD = ((ZDOID)(ref zDOID)).ID; if ((long)iD == 0L) { return; } StarLevelHud starLevelHud = new StarLevelHud(); starLevelHud.Level = level; Dictionary creatureModifiers = CompositeLazyCache.GetCreatureModifiers(ehud.m_character); if (characterExtendedHuds.ContainsKey(iD)) { starLevelHud = characterExtendedHuds[iD]; if (starLevelHud == null || (starLevelHud.Starlevel.ContainsKey(3) && (Object)(object)starLevelHud.Starlevel[3] == (Object)null)) { Logger.LogDebug($"UI Cache Invalid for {iD}, removing."); RemoveExtendedHudFromCache(iD); return; } List listA = creatureModifiers.Keys.ToList(); DataObjects.CharacterCacheEntry cacheEntry = CompositeLazyCache.GetCacheEntry(iD); int level2 = ehud.m_character.GetLevel(); if (!listA.CompareListContents(starLevelHud.DisplayedMods) || cacheEntry == null || level2 != starLevelHud.Level) { Logger.LogDebug($"UI Cache for {iD} outdated (level {ehud.m_character.GetLevel()}-{starLevelHud.Level} or mods {starLevelHud.DisplayedMods.Count}-{creatureModifiers.Count} or name {((TMP_Text)starLevelHud.Hudlink.m_name).text}-{starLevelHud.CreatureNameLocalized}), updating cache."); CompositeLazyCache.ClearCachedCreature(ehud.m_character); InvalidateCacheEntry(ehud.m_character); return; } ((TMP_Text)starLevelHud.Hudlink.m_name).text = starLevelHud.CreatureNameLocalized; if (ValConfig.EnableEnemyHeathbarNumberDisplay.Value && (Object)(object)starLevelHud.HealthText != (Object)null) { ((TMP_Text)starLevelHud.HealthText).text = $"{ehud.m_character.GetHealth():N0}/{ehud.m_character.GetMaxHealth():N0}"; } } else { starLevelHud.Hudlink = ehud; Logger.LogDebug($"Creating new hud for {ehud.m_character} with level {level}"); starLevelHud.IsBoss = ehud.m_character.IsBoss(); if ((ValConfig.EnemyHealthbarScalarX.Value != 1f || ValConfig.EnemyHealthbarScalarY.Value != 1f) && !starLevelHud.IsBoss) { RectTransform component = ((Component)ehud.m_gui.transform.Find("Health")).GetComponent(); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(100f * ValConfig.EnemyHealthbarScalarX.Value, 5f * ValConfig.EnemyHealthbarScalarY.Value); component.sizeDelta = val; RectTransform component2 = ((Component)((Transform)component).Find("health_slow")).GetComponent(); ((Component)component2).GetComponent().m_width = val.x; ((Component)((Transform)component2).Find("bar")).GetComponent().sizeDelta = val; RectTransform component3 = ((Component)((Transform)component).Find("health_fast")).GetComponent(); RectTransform component4 = ((Component)((Transform)component3).Find("bar")).GetComponent(); ((Component)component3).GetComponent().m_width = val.x; component4.sizeDelta = val; } if (ValConfig.EnableEnemyHeathbarNumberDisplay.Value && (Object)(object)starLevelHud.HealthText == (Object)null) { if ((Object)(object)HealthText == (Object)null) { LoadAssets(); } GameObject val2 = Object.Instantiate(HealthText, ehud.m_gui.transform.Find("Health")); starLevelHud.HealthText = val2.GetComponent(); ((TMP_Text)starLevelHud.HealthText).fontSize = 10f * (ValConfig.EnemyHealthbarScalarY.Value * ValConfig.HealthDisplayFontSizeAdjustment.Value); } UpdateHudModifiers(iD, starLevelHud, creatureModifiers); characterExtendedHuds.Add(iD, starLevelHud); } if (level <= 6) { switch (level) { case 2: starLevelHud.Starlevel[2].SetActive(true); starLevelHud.Starlevel[3].SetActive(false); starLevelHud.Starlevel[4].SetActive(false); starLevelHud.Starlevel[5].SetActive(false); starLevelHud.Starlevel[6].SetActive(false); break; case 3: starLevelHud.Starlevel[2].SetActive(true); starLevelHud.Starlevel[3].SetActive(true); starLevelHud.Starlevel[4].SetActive(false); starLevelHud.Starlevel[5].SetActive(false); starLevelHud.Starlevel[6].SetActive(false); break; case 4: starLevelHud.Starlevel[2].SetActive(true); starLevelHud.Starlevel[3].SetActive(true); starLevelHud.Starlevel[4].SetActive(true); starLevelHud.Starlevel[5].SetActive(false); starLevelHud.Starlevel[6].SetActive(false); break; case 5: starLevelHud.Starlevel[2].SetActive(true); starLevelHud.Starlevel[3].SetActive(true); starLevelHud.Starlevel[4].SetActive(true); starLevelHud.Starlevel[5].SetActive(true); starLevelHud.Starlevel[6].SetActive(false); break; case 6: starLevelHud.Starlevel[2].SetActive(true); starLevelHud.Starlevel[3].SetActive(true); starLevelHud.Starlevel[4].SetActive(true); starLevelHud.Starlevel[5].SetActive(true); starLevelHud.Starlevel[6].SetActive(true); break; } } else { starLevelHud.Starlevel[2].SetActive(false); starLevelHud.Starlevel[3].SetActive(false); starLevelHud.Starlevel[4].SetActive(false); starLevelHud.Starlevel[5].SetActive(false); starLevelHud.Starlevel[6].SetActive(false); } if (level > 6) { starLevelHud.StarLevelN.SetActive(true); starLevelHud.StarLevelNText.text = (level - 1).ToString(); } else { starLevelHud.StarLevelN.SetActive(false); } } public static void UpdateHudModifiers(uint zdid, StarLevelHud extended_hud, Dictionary mods) { //IL_051a: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) if (extended_hud.Hudlink == null || (Object)(object)extended_hud.Hudlink.m_gui == (Object)null) { RemoveExtendedHudFromCache(zdid); return; } DataObjects.CharacterCacheEntry characterCacheEntry = CompositeLazyCache.GetCacheEntry(extended_hud.Hudlink.m_character); if (characterCacheEntry != null) { if (characterCacheEntry.CreatureModifiers == null || !characterCacheEntry.CreatureModifiers.Keys.ToList().CompareListContents(mods.Keys.ToList())) { CompositeLazyCache.ClearCachedCreature(extended_hud.Hudlink.m_character); characterCacheEntry = CompositeLazyCache.GetAndSetLocalCache(extended_hud.Hudlink.m_character); } extended_hud.CreatureNameLocalized = extended_hud.Hudlink.m_character.m_nview.GetZDO().GetString(ZDOVars.s_tamedName, Localization.instance.Localize(characterCacheEntry.CreatureNameLocalizable)); ((TMP_Text)extended_hud.Hudlink.m_name).text = extended_hud.CreatureNameLocalized; } Dictionary dictionary = new Dictionary(); int num = 2; if (mods == null) { mods = new Dictionary(); } extended_hud.DisplayedMods = mods.Keys.ToList(); foreach (KeyValuePair mod in mods) { if (!(mod.Key == CreatureModifiers.NoMods)) { DataObjects.CreatureModifierDefinition creatureModifierDefinition = CreatureModifiersData.ModifierDefinitions[mod.Key]; if (creatureModifierDefinition.StarVisual != null && CreatureModifiersData.LoadedModifierSprites.ContainsKey(creatureModifierDefinition.StarVisual)) { Sprite value = CreatureModifiersData.LoadedModifierSprites[creatureModifierDefinition.StarVisual]; dictionary.Add(num, value); } num++; } } for (int i = 2; i < 7; i++) { if (!extended_hud.Starlevel.ContainsKey(i)) { extended_hud.Starlevel.Add(i, ((Component)extended_hud.Hudlink.m_gui.transform.Find($"SLS_level_{i}")).gameObject); } if (!extended_hud.StarLevelBack.ContainsKey(i)) { extended_hud.StarLevelBack.Add(i, ((Component)extended_hud.Hudlink.m_gui.transform.Find($"SLS_level_{i}/star(Clone)")).gameObject.GetComponent()); } if (!extended_hud.StarLevelFront.ContainsKey(i)) { extended_hud.StarLevelFront.Add(i, ((Component)extended_hud.Hudlink.m_gui.transform.Find($"SLS_level_{i}/star(Clone)/star (1)")).gameObject.GetComponent()); } if (dictionary.ContainsKey(i)) { if ((Object)(object)extended_hud.StarLevelFront[i] != (Object)null) { extended_hud.StarLevelFront[i].sprite = dictionary[i]; ((Graphic)extended_hud.StarLevelFront[i]).rectTransform.sizeDelta = new Vector2(17f, 17f); ((Graphic)extended_hud.StarLevelFront[i]).color = Color.white; } if ((Object)(object)extended_hud.StarLevelBack[i] != (Object)null) { extended_hud.StarLevelBack[i].sprite = dictionary[i]; ((Graphic)extended_hud.StarLevelBack[i]).rectTransform.sizeDelta = new Vector2(21f, 21f); } } else { if ((Object)(object)extended_hud.StarLevelFront[i] != (Object)null) { extended_hud.StarLevelFront[i].sprite = defaultStar; ((Graphic)extended_hud.StarLevelFront[i]).rectTransform.sizeDelta = new Vector2(14f, 14f); } if ((Object)(object)extended_hud.StarLevelBack[i] != (Object)null) { extended_hud.StarLevelBack[i].sprite = defaultStar; ((Graphic)extended_hud.StarLevelBack[i]).rectTransform.sizeDelta = new Vector2(16f, 16f); } } } extended_hud.StarLevelN = ((Component)extended_hud.Hudlink.m_gui.transform.Find("SLS_level_n")).gameObject; extended_hud.StarLevelNBackImage = ((Component)extended_hud.Hudlink.m_gui.transform.Find("SLS_level_n/star(Clone)")).gameObject.GetComponent(); extended_hud.StarLevelNFrontImage = ((Component)extended_hud.Hudlink.m_gui.transform.Find("SLS_level_n/star(Clone)/star (1)")).gameObject.GetComponent(); extended_hud.StarLevelNText = ((Component)extended_hud.Hudlink.m_gui.transform.Find("SLS_level_n/level_n_name(Clone)/Text")).gameObject.GetComponent(); if (dictionary.Count > 0) { extended_hud.StarLevelNFrontImage.sprite = dictionary.First().Value; ((Graphic)extended_hud.StarLevelNFrontImage).rectTransform.sizeDelta = new Vector2(17f, 17f); extended_hud.StarLevelNBackImage.sprite = dictionary.First().Value; ((Graphic)extended_hud.StarLevelNBackImage).rectTransform.sizeDelta = new Vector2(21f, 21f); } else { extended_hud.StarLevelNFrontImage.sprite = defaultStar; ((Graphic)extended_hud.StarLevelNFrontImage).rectTransform.sizeDelta = new Vector2(17f, 17f); extended_hud.StarLevelNBackImage.sprite = defaultStar; ((Graphic)extended_hud.StarLevelNBackImage).rectTransform.sizeDelta = new Vector2(21f, 21f); } } internal static void LoadAssets() { HealthText = StarLevelSystem.EmbeddedResourceBundle.LoadAsset("HealthText.prefab"); } } internal static class UIPatches { [HarmonyPatch(typeof(EnemyHud), "Awake")] public static class EnableLevelDisplay { public static void Postfix(EnemyHud __instance) { GameObject gameObject = ((Component)__instance.m_baseHud.transform.Find("level_2/star")).gameObject; ((Component)__instance.m_baseHud.transform.Find("level_3/star")).gameObject.SetActive(false); UIHudControl.StarLevelHudDisplay(gameObject, __instance.m_baseHud.transform, __instance.m_baseHudBoss.transform); } } [HarmonyPatch(typeof(Tameable), "SetName")] public static class UpdateTamedName { public static void Postfix(Tameable __instance) { UIHudControl.InvalidateCacheEntry(__instance.m_character); } } [HarmonyPatch(typeof(EnemyHud), "ShowHud")] public static class DisableVanillaStarsByDefault { public static void Postfix(EnemyHud __instance, Character c) { if ((Object)(object)__instance == (Object)null || (Object)(object)c == (Object)null || c.IsBoss()) { return; } __instance.m_huds.TryGetValue(c, out var value); if (value == null || (Object)(object)value.m_level2 == (Object)null || (Object)(object)value.m_level3 == (Object)null) { return; } RectTransform level = value.m_level2; if (level != null) { GameObject gameObject = ((Component)level).gameObject; if (gameObject != null) { gameObject.SetActive(false); } } RectTransform level2 = value.m_level3; if (level2 != null) { GameObject gameObject2 = ((Component)level2).gameObject; if (gameObject2 != null) { gameObject2.SetActive(false); } } } } [HarmonyPatch(typeof(EnemyHud))] public static class SetupCreatureLevelDisplay { [HarmonyTranspiler] [HarmonyPatch("UpdateHuds")] private static IEnumerable Transpiler(IEnumerable instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[8] { new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldloc_S, (object)(byte)6), Transpilers.EmitDelegate>((Action)UIHudControl.UpdateHudforAllLevels) }).RemoveInstructions(23) .ThrowIfNotMatch("Unable to patch Enemy Hud update, levels will not be displayed properly.", Array.Empty()); return val.Instructions(); } } [HarmonyPatch(typeof(Character), "GetHoverName")] public static class DisplayCreatureNameChanges { public static bool Prefix(Character __instance, ref string __result) { DataObjects.CharacterCacheEntry cacheEntry = CompositeLazyCache.GetCacheEntry(__instance); if (cacheEntry == null || cacheEntry.CreatureNameLocalizable == null) { return true; } __result = Localization.instance.Localize(cacheEntry.CreatureNameLocalizable); Tameable component = ((Component)__instance).gameObject.GetComponent(); if (Object.op_Implicit((Object)(object)component) && __instance.IsTamed()) { __result = component.m_nview.GetZDO().GetString(ZDOVars.s_tamedName, __result); } return false; } } } } namespace StarLevelSystem.modules.Sizes { internal static class SizeModifications { private static Dictionary SizeEstimateCache = new Dictionary(); internal static void SetSizeModification(GameObject obj, ZNetView zview, DataObjects.CharacterCacheEntry cdetails, bool update = false, float bonus = 0f) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //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_0088: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) Vector3 vec = zview.m_zdo.GetVec3(DataObjects.SLS_SIZE, Vector3.zero); if (!update && vec != Vector3.zero) { obj.transform.localScale = vec; UpdateRidingCreaturesForSizeScaling(obj, cdetails); Physics.SyncTransforms(); return; } float num = bonus + cdetails.CreatureBaseValueModifiers[DataObjects.CreatureBaseAttribute.Size] + cdetails.CreaturePerLevelValueModifiers[DataObjects.CreaturePerLevelAttribute.SizePerLevel] * (float)cdetails.Level; Vector3 val = GetSizeReferenceForObject(((Object)obj).name) * num; UpdateRidingCreaturesForSizeScaling(obj, cdetails); zview.m_zdo.Set(DataObjects.SLS_SIZE, val); Logger.LogDebug($"Setting size of {cdetails.RefCreatureName} to {val}"); Physics.SyncTransforms(); } internal static Vector3 GetSizeReferenceForObject(string name) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //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_0044: Unknown result type (might be due to invalid IL or missing references) string prefabName = Utils.GetPrefabName(name); Vector3 val; if (SizeEstimateCache.ContainsKey(prefabName)) { val = SizeEstimateCache[prefabName]; } else { val = PrefabManager.Instance.GetPrefab(prefabName).transform.localScale; SizeEstimateCache.Add(prefabName, val); } return val; } internal static void PrepareSizeRefCache() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) string clone = "(Clone)"; foreach (Character item in (from obj in Resources.FindObjectsOfTypeAll() where !((Object)obj).name.EndsWith(clone) select obj).ToList()) { if (!SizeEstimateCache.ContainsKey(((Object)item).name)) { SizeEstimateCache.Add(((Object)item).name, ((Component)item).transform.localScale); } } foreach (Humanoid item2 in (from obj in Resources.FindObjectsOfTypeAll() where !((Object)obj).name.EndsWith(clone) select obj).ToList()) { if (!SizeEstimateCache.ContainsKey(((Object)item2).name)) { SizeEstimateCache.Add(((Object)item2).name, ((Component)item2).transform.localScale); } } foreach (GameObject item3 in ObjectDB.m_instance.m_items) { if (!SizeEstimateCache.ContainsKey(((Object)item3).name)) { SizeEstimateCache.Add(((Object)item3).name, item3.transform.localScale); } } } internal static void UpdateRidingCreaturesForSizeScaling(GameObject creature, DataObjects.CharacterCacheEntry cDetails) { if (!ValConfig.EnableRidableCreatureSizeFixes.Value) { return; } Tameable component = creature.GetComponent(); if ((Object)(object)component != (Object)null && component.IsTamed()) { string prefabName = Utils.GetPrefabName(creature.gameObject); if (prefabName == "Lox") { UpdateLoxCollider(creature.gameObject, cDetails); } if (prefabName == "Askvin") { UpdateAskavinCollider(creature.gameObject); } } } private static void UpdateLoxCollider(GameObject go, DataObjects.CharacterCacheEntry cDetails) { CapsuleCollider component = go.GetComponent(); float num = (cDetails.CreaturePerLevelValueModifiers[DataObjects.CreaturePerLevelAttribute.SizePerLevel] * (float)cDetails.Level + cDetails.CreatureBaseValueModifiers[DataObjects.CreatureBaseAttribute.Size] - 1f) * 0.1555f; component.height = 3f + num; component.radius = 0.5f; } private static void UpdateAskavinCollider(GameObject go) { go.GetComponent().radius = 0.842f; } internal static void StarLevelScaleChanged(object s, EventArgs e) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) Logger.LogInfo($"Updating size scale: {ValConfig.PerLevelScaleBonus.Value}"); Character[] array = Resources.FindObjectsOfTypeAll(); foreach (Character val in array) { ((Component)val).transform.localScale = Vector3.one; float num = 1f + ValConfig.PerLevelScaleBonus.Value * (float)(val.m_level - 1); Transform transform = ((Component)val).transform; transform.localScale *= num; } Physics.SyncTransforms(); } } internal static class SizePatches { [HarmonyPatch(typeof(Humanoid), "OnRagdollCreated")] public static class ModifyRagdollHumanoid { public static void Postfix(Character __instance, Ragdoll ragdoll) { if ((Object)(object)__instance == (Object)null || __instance.IsPlayer() || (Object)(object)__instance.m_nview == (Object)null) { return; } DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(__instance); if (__instance.m_level > 1 && andSetLocalCache != null) { SizeModifications.SetSizeModification(((Component)ragdoll).gameObject, __instance.m_nview, andSetLocalCache); if (andSetLocalCache.Colorization != null) { Colorization.ApplyColorizationWithoutLevelEffects(((Component)ragdoll).gameObject, andSetLocalCache.Colorization); } } CompositeLazyCache.ClearCachedCreature(__instance); } } } } namespace StarLevelSystem.modules.Raids { internal static class RaidControl { [CompilerGenerated] private sealed class d__15 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Vector3 origin; public float maxDistance; public Biome targetBiome; public int numTargets; public DataObjects.ListVectorZNetProperty resultset; public DataObjects.BoolZNetProperty pointsReady; private List 5__2; private int 5__3; private Vector3 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__15(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Invalid comparison between Unknown and I4 //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Invalid comparison between Unknown and I4 //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; goto IL_00af; } <>1__state = -1; 5__2 = new List(); 5__3 = 0; 5__4 = origin; goto IL_02c6; IL_00af: Vector3 val = default(Vector3); Biome val2 = default(Biome); BiomeArea val3 = default(BiomeArea); Heightmap val4 = default(Heightmap); ZoneSystem.instance.GetGroundData(ref 5__4, ref val, ref val2, ref val3, ref val4); if ((int)targetBiome != 0 && ((Object)(object)val4 == (Object)null || val2 != targetBiome)) { 5__3++; Logger.LogDebug($"Spawn location in the wrong biome, skipping. {val2} | {5__4}"); } else { float y = 5__4.y; float num2 = 1000f; if (ZoneSystem.instance.FindFloor(new Vector3(5__4.x, 5__4.y + 100f, 5__4.z), ref num2)) { float num3 = num2 - y; if (num3 > 1f) { Logger.LogDebug($"Spawn location blocked by an existing object skipping. {num3} | {5__4}"); 5__3++; } else { if (num3 > 0f) { 5__4.y = num2; } if ((int)val2 != 32 && Object.op_Implicit((Object)(object)EffectArea.IsPointInsideArea(5__4, (Type)4, 0f))) { Logger.LogDebug($"Spawn location in a players base zone, skipping. | {5__4}"); 5__3++; } else if (5__4.y < 27f) { Logger.LogDebug($"Spawn location below water level, skipping. | {5__4}"); 5__3++; } else if ((int)val2 == 32 && val4.GetVegetationMask(5__4) > 0.45f) { 5__3++; Logger.LogDebug($"Spawn location is in lava, skipping. | {5__4}"); } else { Logger.LogDebug($"Determined valid spawn target: {5__4}"); 5__2.Add(5__4); } } } else { 5__3++; } } goto IL_02c6; IL_02c6: if (5__2.Count < numTargets || 5__3 > 200) { Vector2 val5 = Random.insideUnitCircle * (maxDistance * 0.8f); 5__4 = origin + new Vector3(val5.x, 0f, val5.y); if (5__3 > 1 && 5__3 % 10 == 0) { <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; } goto IL_00af; } if (5__2.Count < numTargets) { Logger.LogWarning("Unable to find the requested number of spawn points."); } resultset.ForceSet(5__2); pointsReady.ForceSet(value: true); 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(); } } internal static Dictionary ServerPlayerRaidData = new Dictionary(); internal static RaidManager RaidMan; internal static GameObject RaidRunnerGO; internal static void LoadAssets() { RaidRunnerGO = StarLevelSystem.EmbeddedResourceBundle.LoadAsset("RaidRunner.prefab"); } internal static void StartRaidRunner(DataObjects.RaidDefinition targetRaid, Vector3 pos) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) Object.Instantiate(RaidRunnerGO, pos, Quaternion.identity).GetComponent().StartRaid(targetRaid, Player.m_localPlayer); } public static DataObjects.RaidDefinition RandomSelectValidRaidForPlayer(string playerPlatformID) { if (RaidsData.SLE_Raid_Settings.Raids.Count == 0) { Logger.LogWarning("No Raids were defined."); return new DataObjects.RaidDefinition(); } Logger.LogDebug("Checking for raids for " + playerPlatformID); if (!ServerPlayerRaidData.ContainsKey(playerPlatformID)) { Logger.LogWarning("Player " + playerPlatformID + " was not found and an appropriate raid can't be determined, a random one will be selected. \n Currently tracked: " + string.Join(",", ServerPlayerRaidData.Keys.ToList())); return RaidsData.SLE_Raid_Settings.Raids.ElementAt(Random.Range(0, RaidsData.SLE_Raid_Settings.Raids.Count - 1)); } return ServerPlayerRaidData[playerPlatformID].PlayerAvailableRaids.ElementAt(Random.Range(0, ServerPlayerRaidData[playerPlatformID].PlayerAvailableRaids.Count - 1)); } internal static void UpdateOrAddPlayerPrivateKeys(string playerPlatformID, List privatekeys) { if (!string.IsNullOrEmpty(playerPlatformID)) { UpdateOrAddPlayerPrivateKeysToRegistry(playerPlatformID, privatekeys); } } internal static void UpdateOrAddPlayerPrivateKeys(long playerID, List privatekeys) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) PlatformUserID platformUserID = SLSExtensions.GetPlatformUserID(playerID); string text = ((object)(PlatformUserID)(ref platformUserID)).ToString(); if (!string.IsNullOrEmpty(text)) { UpdateOrAddPlayerPrivateKeysToRegistry(text, privatekeys); } } private static void UpdateOrAddPlayerPrivateKeysToRegistry(string playerPlatformID, List privatekeys) { if (ServerPlayerRaidData.ContainsKey(playerPlatformID)) { ServerPlayerRaidData[playerPlatformID].PlayerPrivatekeys = privatekeys; } else { ServerPlayerRaidData.Add(playerPlatformID, new DataObjects.PlayerRaidData { PlayerPrivatekeys = privatekeys }); } RaidsData.SaveServerRaidData(DataObjects.yamlserializer.Serialize((object)ServerPlayerRaidData)); } internal static void UpdatePlayerRaidHistory(DataObjects.PlayerRaidData playerRaidData, DataObjects.RaidDefinition raidDef, string key) { if (playerRaidData.LastRaidByName.ContainsKey(key)) { playerRaidData.LastRaidByName[key] = ZNet.instance.GetTimeSeconds(); } else { playerRaidData.LastRaidByName.Add(key, ZNet.instance.GetTimeSeconds()); } playerRaidData.NextRaidableTime = ZNet.instance.GetTimeSeconds() + (double)(raidDef.RaidCoolDownMinutes * 60f * RaidsData.SLE_Raid_Settings.GlobalSettings.GlobalRaidIntervalScalar); } internal static void ApplyRaidConfiguration(RandEventSystem res) { if ((Object)(object)res == (Object)null) { return; } DataObjects.RaidConfiguration raidConfiguration = RaidsData.SLE_Raid_Settings ?? RaidsData.DefaultConfiguration; if (raidConfiguration.GlobalSettings != null) { if (raidConfiguration.GlobalSettings.GlobalRaidIntervalScalar > 0f) { res.m_eventIntervalMin *= raidConfiguration.GlobalSettings.GlobalRaidIntervalScalar; } if (raidConfiguration.GlobalSettings.DisableAllRaids) { res.m_events.Clear(); Logger.LogInfo("SLS raid system: DisableAllRaids set, cleared all random events."); return; } } Logger.LogInfo($"SLS raid system: applied {raidConfiguration.Raids.Count} raid definitions."); } internal static void UpdateAvailableRaidsPerPlayer() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { if (peer.IsReady()) { PlatformUserID platformUserID = SLSExtensions.GetPlatformUserID(peer.m_uid); string text = ((object)(PlatformUserID)(ref platformUserID)).ToString(); List validRaidsForPlayer = GetValidRaidsForPlayer(peer.GetRefPos(), text); if (ServerPlayerRaidData.ContainsKey(text)) { ServerPlayerRaidData[text].PlayerAvailableRaids = validRaidsForPlayer; continue; } ServerPlayerRaidData.Add(text, new DataObjects.PlayerRaidData { PlayerAvailableRaids = validRaidsForPlayer }); } } } internal static List GetValidRaidsForPlayer(Vector3 position, string playerPlatformID) { //IL_0006: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) List list = new List(); bool flag = Object.op_Implicit((Object)(object)EffectArea.IsPointInsideArea(position, (Type)4, 30f)); Biome biome = WorldGenerator.instance.GetBiome(position); foreach (DataObjects.RaidDefinition raid in RaidsData.SLE_Raid_Settings.Raids) { if (raid.Activation == null || !raid.Enabled) { continue; } if (raid.Activation.Biomes != null && !raid.Activation.Biomes.Contains(biome)) { Logger.LogDebug("Player is not in a target biome, skipping selection of Raid: " + raid.Name); continue; } if (raid.Activation.NearBaseOnly && !flag) { Logger.LogDebug("Player is not in base, skipping selection of Raid: " + raid.Name); continue; } if (raid.Activation.RequiredGlobalKeys != null) { bool flag2 = true; List globalKeys = ZoneSystem.instance.GetGlobalKeys(); foreach (string requiredGlobalKey in raid.Activation.RequiredGlobalKeys) { if (!globalKeys.Contains(requiredGlobalKey)) { flag2 = false; break; } } if (!flag2) { Logger.LogDebug("Server does not have a required global key, skipping Raid: " + raid.Name); continue; } } if (raid.Activation.NotRequiredGlobalKeys != null) { bool flag3 = false; List globalKeys2 = ZoneSystem.instance.GetGlobalKeys(); foreach (string notRequiredGlobalKey in raid.Activation.NotRequiredGlobalKeys) { if (!globalKeys2.Contains(notRequiredGlobalKey)) { flag3 = true; break; } } if (flag3) { Logger.LogDebug("Server has a key that must be missing, skipping Raid: " + raid.Name); continue; } } DataObjects.PlayerRaidData playerRaidData = new DataObjects.PlayerRaidData(); if (ServerPlayerRaidData.ContainsKey(playerPlatformID)) { playerRaidData = ServerPlayerRaidData[playerPlatformID]; } List playerPrivatekeys = playerRaidData.PlayerPrivatekeys; if (raid.Activation.RequiredPlayerKeys != null) { bool flag4 = true; foreach (string requiredPlayerKey in raid.Activation.RequiredPlayerKeys) { if (!playerPrivatekeys.Contains(requiredPlayerKey)) { flag4 = false; break; } } if (!flag4) { Logger.LogDebug("Player " + playerPlatformID + " does not have a required private key, skipping Raid: " + raid.Name); continue; } } if (raid.Activation.AnyRequiredPlayerKeys != null) { bool flag5 = false; foreach (string requiredPlayerKey2 in raid.Activation.RequiredPlayerKeys) { if (playerPrivatekeys.Contains(requiredPlayerKey2)) { flag5 = true; break; } } if (!flag5) { Logger.LogDebug("Player " + playerPlatformID + " does not have any of the required private keys, skipping Raid: " + raid.Name); continue; } } if (raid.Activation.NotRequiredPlayerKeys != null) { bool flag6 = false; foreach (string notRequiredPlayerKey in raid.Activation.NotRequiredPlayerKeys) { if (!playerPrivatekeys.Contains(notRequiredPlayerKey)) { flag6 = true; break; } } if (flag6) { Logger.LogDebug("Player " + playerPlatformID + " has a private key which must be avoided, skipping Raid: " + raid.Name); continue; } } if (playerRaidData.LastRaidByName.Count > 0) { if (playerRaidData.NextRaidableTime > ZNet.instance.GetTimeSeconds()) { Logger.LogDebug($"Player {playerPlatformID} has a NextRaidableTime of {playerRaidData.NextRaidableTime} which is in the future, skipping Raid: {raid.Name}"); continue; } if (playerRaidData.LastRaidByName != null && playerRaidData.LastRaidByName.ContainsKey(raid.Name) && playerRaidData.LastRaidByName[raid.Name] + (double)raid.RaidCoolDownMinutes > ZNet.instance.GetTimeSeconds()) { Logger.LogDebug($"Player {playerPlatformID} has activated Raid {raid.Name} too recently, skipping. Next possible activation time: {playerRaidData.LastRaidByName[raid.Name] + (double)raid.RaidCoolDownMinutes}"); continue; } } Logger.LogDebug("Raid " + raid.Name + " valid for player " + playerPlatformID); list.Add(raid); } return list; } public static void ForceMusicForClientsInArea(DataObjects.Music music, Vector3 position, float range) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown List list = SLSExtensions.ServerGetPeersInArea(position, range); ZPackage val = new ZPackage(); val.Write(music.ToString()); foreach (ZNetPeer item in list) { ValConfig.ClientForcePlayMusicRPC.SendPackage(item.m_uid, val); } } public static void RemoveNearbyRunningEvents() { Logger.LogDebug("Client recieved remove nearby event command."); foreach (RaidRunner item in (IEnumerable)Resources.FindObjectsOfTypeAll()) { if (!(((Object)item).name == "RaidRunner")) { Logger.LogDebug("Removing " + ((Object)item).name); ZNetScene.instance.Destroy(((Component)item).gameObject); } } } [IteratorStateMachine(typeof(d__15))] public static IEnumerator DetermineRemoteSpawnLocations(Vector3 origin, DataObjects.ListVectorZNetProperty resultset, int numTargets, DataObjects.BoolZNetProperty pointsReady, float maxDistance = 300f, Biome targetBiome = 0) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__15(0) { origin = origin, resultset = resultset, numTargets = numTargets, pointsReady = pointsReady, maxDistance = maxDistance, targetBiome = targetBiome }; } } public class RaidManager : MonoBehaviour { private bool setup; private double nextCheckForRaidsTime; private bool forceRaidStart; public void FixedUpdate() { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_0644: Unknown result type (might be due to invalid IL or missing references) //IL_06b9: Unknown result type (might be due to invalid IL or missing references) //IL_06c0: Expected O, but got Unknown //IL_06fb: Unknown result type (might be due to invalid IL or missing references) //IL_0686: Unknown result type (might be due to invalid IL or missing references) if (!setup || ValConfig.UseVanillaRaidConfiguration.Value || (Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer() || (!forceRaidStart && !(ZNet.instance.GetTimeSeconds() >= nextCheckForRaidsTime))) { return; } nextCheckForRaidsTime = ZNet.instance.GetTimeSeconds() + (double)(ValConfig.ServerTimeBetweenRaidStartChecks.Value * 60); Logger.LogDebug($"Raid check happening. Next check will be at: {nextCheckForRaidsTime} currentTime: {ZNet.instance.GetTimeSeconds()}"); int nrOfPlayers = ZNet.instance.GetNrOfPlayers(); if (nrOfPlayers <= 0) { Logger.LogDebug("No Players online, skipping raids."); return; } bool flag = false; foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { PlatformUserID platformUserID = SLSExtensions.GetPlatformUserID(peer.m_uid); string value = ((object)(PlatformUserID)(ref platformUserID)).ToString(); if (!RaidControl.ServerPlayerRaidData.Keys.Contains(value)) { ZPackage val = new ZPackage(); ValConfig.ClientSendPlayerPrivateKeysRPC.SendPackage(peer.m_uid, val); flag = true; } } if (flag) { Logger.LogInfo("Networked players data is needed to ensure accurate raids, delaying raid initilaization and awaiting updated client data."); nextCheckForRaidsTime = ZNet.instance.GetTimeSeconds() + 60.0; return; } bool flag2 = false; string text = null; if (ZNet.instance.IsServer() && !ZNet.instance.IsDedicated() && (Object)(object)Player.m_localPlayer != (Object)null) { Logger.LogDebug("Integrated server mode enabled, local player will be checked for configuration data. Networked players already validated."); text = SLSExtensions.GetLocalUserPlatformAndID(); RaidControl.UpdateOrAddPlayerPrivateKeys(text, Player.m_localPlayer.GetPrivateKeysSanitize()); flag2 = true; } int num = Random.Range(1, Mathf.Min(ValConfig.MaxActiveRaids.Value, nrOfPlayers)); int num2 = 0; int num3 = 0; double timeSeconds = ZNet.instance.GetTimeSeconds(); Logger.LogDebug($"Starting raid init check potential num raids: {num} start-time: {timeSeconds} checking {RaidControl.ServerPlayerRaidData.Count} players for raid availability."); List list = new List(); foreach (PlayerInfo player in ZNet.instance.GetPlayerList()) { list.Add($"{player.m_userInfo.m_id.m_platform}_{player.m_userInfo.m_id.m_userID}"); } Logger.LogDebug("Available players for raids:\n" + string.Join("\n", list) + "\nAvailable Player data:\n" + string.Join("\n", RaidControl.ServerPlayerRaidData.Keys)); PlayerInfo val2 = default(PlayerInfo); foreach (KeyValuePair serverPlayerRaidDatum in RaidControl.ServerPlayerRaidData) { Logger.LogDebug("Checking raids for " + serverPlayerRaidDatum.Key); if (!SLSExtensions.PlatformAndIDIsPlayerOnline(serverPlayerRaidDatum.Key)) { Logger.LogDebug("Client " + serverPlayerRaidDatum.Key + " was not online, skipping raid checks for them."); continue; } if (!forceRaidStart && serverPlayerRaidDatum.Value.NextRaidableTime >= timeSeconds) { Logger.LogDebug($"{serverPlayerRaidDatum.Key} is not currently raidable, still on cooldown: {serverPlayerRaidDatum.Value.NextRaidableTime} >= {timeSeconds}"); continue; } if (num2 >= num) { Logger.LogDebug($"Number of raids activating now matches: activating {num2} == target {num}"); break; } if (!ZNet.TryGetPlayerByPlatformUserID(new PlatformUserID(serverPlayerRaidDatum.Key), ref val2)) { Logger.LogInfo("Could not find player by platform ID " + serverPlayerRaidDatum.Key + ", this player will be skipped."); continue; } Vector3 playerPosition = SLSExtensions.GetPlayerPosition(val2.m_characterID); if (playerPosition == Vector3.zero) { Logger.LogDebug("Player " + serverPlayerRaidDatum.Key + " position was not found, they will not get raided."); continue; } bool flag3 = false; foreach (KeyValuePair serverPlayerRaidDatum2 in RaidControl.ServerPlayerRaidData) { if (!(serverPlayerRaidDatum2.Value.NextRaidableTime < timeSeconds) && serverPlayerRaidDatum2.Value.LastRaidByName.ContainsKey(serverPlayerRaidDatum2.Key) && serverPlayerRaidDatum2.Value.LastRaidByName[serverPlayerRaidDatum2.Key] + (double)serverPlayerRaidDatum2.Value.ActiveRaid.Duration > timeSeconds && Vector3.Distance(serverPlayerRaidDatum2.Value.CurrentRaidPosition, playerPosition) < serverPlayerRaidDatum2.Value.ActiveRaid.EventRange * 3f) { flag3 = true; break; } } if (flag3) { Logger.LogDebug("Potential raid would be too close to an existing raid, skipping."); break; } Logger.LogDebug("Updating available raids for " + serverPlayerRaidDatum.Key); serverPlayerRaidDatum.Value.PlayerAvailableRaids = RaidControl.GetValidRaidsForPlayer(playerPosition, serverPlayerRaidDatum.Key); Logger.LogDebug($"Shuffling {serverPlayerRaidDatum.Value.PlayerAvailableRaids.Count} potential raids for player..."); foreach (DataObjects.RaidDefinition item in serverPlayerRaidDatum.Value.PlayerAvailableRaids.ShuffleList()) { if (num3 >= ValConfig.MaxRaidAttemptsPerPlayer.Value) { Logger.LogDebug($"Reached max raid attempts per player ({ValConfig.MaxRaidAttemptsPerPlayer.Value}), stopping checks for player {serverPlayerRaidDatum.Key}"); break; } num3++; float num4 = Random.Range(0f, 100f); Logger.LogDebug($"Raid {item} checking activation chance: {num4} <= {item.Activation.Chance * RaidsData.SLE_Raid_Settings.GlobalSettings.GlobalRaidChanceScalar} | Forced? {forceRaidStart}"); if (forceRaidStart || num4 <= item.Activation.Chance * RaidsData.SLE_Raid_Settings.GlobalSettings.GlobalRaidChanceScalar) { Logger.LogDebug("Activating Raid " + item.Name + " for player " + serverPlayerRaidDatum.Key); RaidControl.UpdatePlayerRaidHistory(serverPlayerRaidDatum.Value, item, item.Name); serverPlayerRaidDatum.Value.CurrentRaidPosition = playerPosition; Logger.LogDebug($"Determining raid init style: integrated? {flag2} && {text} == {serverPlayerRaidDatum.Key}"); if (flag2 && text == serverPlayerRaidDatum.Key) { Logger.LogDebug("Starting integrated raid runner."); RaidControl.StartRaidRunner(item, playerPosition); MusicMan.instance.TriggerMusic(item.ForceMusic.ToString()); } else { Logger.LogDebug("Starting networked raid runner."); ZPackage val3 = new ZPackage(); val3.Write(DataObjects.yamlserializer.Serialize((object)item)); ZNetPeer peerByPlatformID = SLSExtensions.GetPeerByPlatformID(serverPlayerRaidDatum.Key); ValConfig.ClientStartRaidRPC.SendPackage(peerByPlatformID.m_uid, val3); } RaidControl.ForceMusicForClientsInArea(item.ForceMusic, playerPosition, item.EventRange * 1.5f); num2++; break; } } } forceRaidStart = false; RaidsData.SaveServerRaidData(DataObjects.yamlserializer.Serialize((object)RaidControl.ServerPlayerRaidData)); } public void Setup() { Logger.LogDebug("Starting setup for RaidManager."); try { RaidControl.ServerPlayerRaidData = DataObjects.yamldeserializer.Deserialize>(RaidsData.LoadServerRaidData()); } catch (Exception arg) { Logger.LogWarning($"There was an error loading saved player raid data. New data will be requested from players. Exception: {arg}"); } setup = true; } public void ForceRaidStart() { forceRaidStart = true; } public void OnDestroy() { RaidsData.SaveServerRaidData(DataObjects.yamlserializer.Serialize((object)RaidControl.ServerPlayerRaidData)); } } internal static class RaidPatches { [HarmonyPatch(typeof(Player), "AddUniqueKey")] internal static class UpdatePlayerPrivateKeys { public static void Postfix() { if (ZNet.instance.IsServer() && !((Object)(object)Player.m_localPlayer == (Object)null)) { ((MonoBehaviour)TaskRunner.Instance).StartCoroutine(ValConfig.OnClientRecieveRequestForPrivatekeys(1L, null)); } } } [HarmonyPatch(typeof(Player), "RemoveUniqueKey")] internal static class RemovePlayerPrivateKey { public static void Postfix() { if (ZNet.instance.IsServer() && !((Object)(object)Player.m_localPlayer == (Object)null)) { ((MonoBehaviour)TaskRunner.Instance).StartCoroutine(ValConfig.OnClientRecieveRequestForPrivatekeys(1L, null)); } } } [HarmonyPatch(typeof(Player), "Load")] internal static class SyncPlayerPrivateKeysOnLoad { public static void Postfix() { if (ZNet.instance.IsServer() && !((Object)(object)Player.m_localPlayer == (Object)null)) { ((MonoBehaviour)TaskRunner.Instance).StartCoroutine(ValConfig.OnClientRecieveRequestForPrivatekeys(1L, null)); } } } [HarmonyPatch(typeof(RandEventSystem), "Awake")] public static class RandEventSystemAwakePatch { public static void Postfix(RandEventSystem __instance) { Logger.LogDebug("Adding custom raid manager"); RaidControl.RaidMan = ((Component)__instance).gameObject.AddComponent(); RaidControl.RaidMan.Setup(); } } [HarmonyPatch(typeof(RandEventSystem), "FixedUpdate")] public static class ToggleCustomRaids { public static bool Prefix() { if (ValConfig.UseVanillaRaidConfiguration.Value) { return true; } return false; } } [HarmonyPatch(typeof(RandEventSystem), "SetRandomEvent")] public static class SetRandomCustomEvent { public static bool Prefix(RandEventSystem __instance, RandomEvent ev, Vector3 pos) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) Logger.LogDebug("Checking for random Raid " + ev.m_name); RaidsData.RaidsByName.TryGetValue(ev.m_name, out var value); if (value == null) { return false; } RaidControl.StartRaidRunner(value, pos); if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { Player.m_localPlayer.ShowTutorial("randomevent", false); } return false; } } [HarmonyPatch(typeof(RandEventSystem), "StartRandomEvent")] public static class RandEventSystemStartEvent { public static bool Prefix(RandEventSystem __instance) { if (ValConfig.UseVanillaRaidConfiguration.Value) { return true; } if ((Object)(object)RaidControl.RaidMan != (Object)null) { RaidControl.RaidMan.ForceRaidStart(); } else { RaidManager component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { RaidControl.RaidMan = component; RaidControl.RaidMan.ForceRaidStart(); return false; } RaidControl.RaidMan = ((Component)__instance).gameObject.AddComponent(); RaidControl.RaidMan.Setup(); RaidControl.RaidMan.ForceRaidStart(); } return false; } } [HarmonyPatch(typeof(RandEventSystem), "ResetRandomEvent")] public static class ResetRandomEvents { public static bool Prefix() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown if (ValConfig.UseVanillaRaidConfiguration.Value) { return true; } foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { if (peer != null && peer.IsReady()) { ZPackage val = new ZPackage(); Logger.LogDebug("Sending reset event RPC to " + peer.m_playerName); ValConfig.ClientClearNearbyEventsRPC.SendPackage(peer.m_uid, val); } } if (!ZNet.instance.IsDedicated()) { Logger.LogDebug("Running integrated server removal"); RaidControl.RemoveNearbyRunningEvents(); } return false; } } [HarmonyPatch(typeof(RandEventSystem), "UpdateRandomEvent")] public static class OverrideRaidSelectionSystem { public static bool Prefix() { if (ValConfig.UseVanillaRaidConfiguration.Value) { return true; } return false; } } internal static List ActiveRaids = new List(); } public class RaidRunner : MonoBehaviour { internal ZNetView Znet; internal DataObjects.RaidZNetProperty RunningRaid; internal DataObjects.DoubleZNetProperty RaitStartTime; internal DataObjects.ListVectorZNetProperty RaidSpawnPoints; internal DataObjects.BoolZNetProperty RaidSpawnPointsReady; internal DataObjects.BoolZNetProperty RaidSpawnPointsGenerating; internal DataObjects.RaidMonitorListZNetProperty ActiveRaidSpawns; private bool networkReady; private double Endtime; private List RaidSpawners = new List(); private PinData AreaPin; private PinData IconPin; public void Awake() { Znet = ((Component)this).GetComponent(); if (Object.op_Implicit((Object)(object)Znet)) { ConnectZData(); } } public void Update() { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_054c: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Invalid comparison between Unknown and I4 //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) if (RunningRaid == null || !Znet.IsValid()) { return; } DataObjects.RaidDefinition raidDefinition = RunningRaid.Get(); EnvMan.instance.m_forceEnv = raidDefinition.ForceEnvironment.ToString(); if (!Znet.IsOwner()) { return; } if (!networkReady) { ConnectZData(); } if (!RaidSpawnPointsReady.Get() && !RaidSpawnPointsGenerating.Get()) { ((MonoBehaviour)TaskRunner.Run()).StartCoroutine(RaidControl.DetermineRemoteSpawnLocations(((Component)this).transform.position, RaidSpawnPoints, RunningRaid.Get().SpawnPoints, RaidSpawnPointsReady, RunningRaid.Get().EventRange, (Biome)0)); RaidSpawnPointsGenerating.Set(value: true); } else { if (!RaidSpawnPointsReady.Get() && RaidSpawnPointsGenerating.Get()) { return; } if (ActiveRaidSpawns.Get().Count <= 0) { RaitStartTime.Set(ZNet.instance.GetTimeSeconds()); Endtime = RaitStartTime.Get() + (double)raidDefinition.Duration; AddMapPins(((Component)this).transform.position, raidDefinition); Player.MessageAllInRange(((Component)this).transform.position, raidDefinition.EventRange * 1.5f, (MessageType)2, raidDefinition.StartMessage, (Sprite)null); RaidSpawners.Clear(); foreach (DataObjects.RaidSpawnEntry spawn in raidDefinition.Spawns) { RaidSpawners.Add(new DataObjects.RaidMonitor { RaidSpawnDef = spawn, NextSpawn = ZNet.instance.GetTimeSeconds() + (double)spawn.InitalSpawnDelay }); } ActiveRaidSpawns.Set(RaidSpawners); { foreach (Player item in SLSExtensions.GetPlayersInRange(((Component)this).transform.position, raidDefinition.EventRange * 1.5f)) { item.ShowTutorial("randomevent", false); } return; } } if (Endtime == 0.0) { Endtime = RaitStartTime.Get() + (double)RunningRaid.Get().Duration; } if (RaidSpawners.Count != ActiveRaidSpawns.Get().Count) { RaidSpawners = ActiveRaidSpawns.Get(); } foreach (DataObjects.RaidMonitor raidSpawner in RaidSpawners) { if (raidSpawner.NextSpawn > ZNet.instance.GetTimeSeconds()) { continue; } Logger.LogDebug($"Checking {raidSpawner.RaidSpawnDef.PrefabName} spawn timer: {raidSpawner.NextSpawn} < {ZNet.instance.GetTimeSeconds()}"); raidSpawner.NextSpawn = ZNet.instance.GetTimeSeconds() + (double)raidSpawner.RaidSpawnDef.SpawnInterval; List list = (from x in raidSpawner.GetSpawnedZDOIDs() where ZDOMan.instance.GetZDO(x) != null select x).ToList(); Logger.LogDebug($"Found {list.Count} alive creatures"); if (list.Count > raidSpawner.RaidSpawnDef.MaxSpawned) { continue; } List list2 = RaidSpawnPoints.Get(); GameObject prefab = PrefabManager.Instance.GetPrefab(raidSpawner.RaidSpawnDef.PrefabName); if ((Object)(object)prefab == (Object)null) { Logger.LogWarning("The creature defined for this wave is invalid and will be skipped. |" + raidSpawner.RaidSpawnDef.PrefabName + "|"); } float num = Random.Range(0f, 100f); if (raidSpawner.RaidSpawnDef.SpawnChance < num) { Logger.LogDebug($"{raidSpawner.RaidSpawnDef.PrefabName} Failed spawn chance roll {raidSpawner.RaidSpawnDef.SpawnChance} < {num}"); continue; } Vector3 val = list2[Random.Range(0, list2.Count - 1)]; SortedDictionary creature_levelup_chance = LevelSelection.DetermineLevelupChance(null, null, raidSpawner.RaidSpawnDef.CustomCreatureLevelUpChance); SortedDictionary levelup_bonus = LevelSelection.DetermineDistanceBonus(val); int num2 = 0; while (num2 < raidSpawner.RaidSpawnDef.SpawnGroupSize) { int num3 = 0; if (raidSpawner.RaidSpawnDef.UseRaidLevelSystem) { num3 = LevelSelection.DetermineLevelRollResult(Random.Range(0f, 100f), raidSpawner.RaidSpawnDef.LevelMax, creature_levelup_chance, levelup_bonus, 1f); Logger.LogDebug($"Spawning {raidSpawner.RaidSpawnDef.PrefabName} at {val} level {num3}"); } else { Logger.LogDebug($"Spawning {raidSpawner.RaidSpawnDef.PrefabName} at {val}"); } GameObject val2 = Object.Instantiate(prefab, val, Random.rotation); num2++; MonsterAI component = val2.GetComponent(); switch (raidSpawner.RaidSpawnDef.CreatureAI) { case DataObjects.AI.HuntPlayer: ((BaseAI)component).SetHuntPlayer(true); break; case DataObjects.AI.Alerted: ((BaseAI)component).SetAlerted(true); break; case DataObjects.AI.AgitatedByBuild: ((BaseAI)component).SetAggravated(true, (AggravatedReason)1); break; default: ((BaseAI)component).SetAlerted(true); break; } Character component2 = val2.GetComponent(); if ((int)raidSpawner.RaidSpawnDef.Faction != 12) { component2.m_faction = raidSpawner.RaidSpawnDef.Faction; } CreatureSetupControl.CreatureSpawnerSetup(component2, num3, multiply: false, 0.1f, raidSpawner.RaidSpawnDef.RequiredModifiers, raidSpawner.RaidSpawnDef.ModifiersNotAllowed); list.Add(val2.GetComponent().GetZDO().m_uid); raidSpawner.StoreZDOIDS(list); } } if (Endtime < ZNet.instance.GetTimeSeconds()) { RemoveExistingMapPins(); Player.MessageAllInRange(((Component)this).transform.position, RunningRaid.Get().EventRange * 1.5f, (MessageType)2, RunningRaid.Get().EndMessage, (Sprite)null); Object.Destroy((Object)(object)this); } } } public void OnDestroy() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) RemoveExistingMapPins(); MusicMan.instance.StopMusic(); EnvMan.instance.m_forceEnv = DataObjects.Environment.Clear.ToString(); if (RaidSpawners == null) { return; } foreach (DataObjects.RaidMonitor raidSpawner in RaidSpawners) { foreach (ZDOID spawnedZDOID in raidSpawner.GetSpawnedZDOIDs()) { ZDO zDO = ZDOMan.instance.GetZDO(spawnedZDOID); if (zDO != null) { ZNetView val = ZNetScene.instance.FindInstance(zDO); if (!((Object)(object)val == (Object)null) && (Object)(object)val != (Object)null) { val.ClaimOwnership(); ZNetScene.instance.Destroy(((Component)val).gameObject); } } } } } private void ConnectZData() { RunningRaid = new DataObjects.RaidZNetProperty("SLS_RAID", Znet, null); RaitStartTime = new DataObjects.DoubleZNetProperty("SLS_RAID_START", Znet, 0.0); RaidSpawnPoints = new DataObjects.ListVectorZNetProperty("SLS_RAID_SPAWN_POINTS", Znet, null); RaidSpawnPointsReady = new DataObjects.BoolZNetProperty("SLS_RAID_SPAWN_READY", Znet, defaultValue: false); RaidSpawnPointsGenerating = new DataObjects.BoolZNetProperty("SLS_RAID_SPAWN_GEN", Znet, defaultValue: false); ActiveRaidSpawns = new DataObjects.RaidMonitorListZNetProperty("SLS_RAID_SPAWNS_ACTIVE", Znet, new List()); networkReady = true; } public void StartRaid(DataObjects.RaidDefinition raid, Player player) { Znet.ClaimOwnership(); RunningRaid.ForceSet(raid); RaitStartTime.ForceSet(ZNet.instance.GetTimeSeconds()); } public void AddMapPins(Vector3 pos, DataObjects.RaidDefinition raid) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) RemoveExistingMapPins(); AreaPin = Minimap.instance.AddPin(pos, (PinType)13, "", false, false, 0L, default(PlatformUserID)); AreaPin.m_worldSize = raid.EventRange * 2f; IconPin = Minimap.instance.AddPin(pos, (PinType)11, "", false, false, 0L, default(PlatformUserID)); IconPin.m_animate = true; IconPin.m_doubleSize = true; } public void RemoveExistingMapPins() { if (AreaPin != null) { Minimap.instance.RemovePin(AreaPin); AreaPin = null; } if (IconPin != null) { Minimap.instance.RemovePin(IconPin); IconPin = null; } } } } namespace StarLevelSystem.modules.Loot { internal static class LootPatches { [HarmonyPatch(typeof(CharacterDrop))] public static class DropItemsPerformancePatch { [HarmonyPatch("DropItems")] public static bool Prefix(CharacterDrop __instance, List> drops, Vector3 centerPos, float dropArea) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) LootPerformanceChanges.DropItemsPreferAsync(centerPos, drops, immediate: false, dropThatCharacterDrop: true); return false; } } [HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")] [HarmonyPriority(0)] public static class ModifyLootPerLevelEffect { public static bool Prefix(ref List> __result, CharacterDrop __instance) { if ((Object)(object)__instance.m_character == (Object)null) { return true; } string prefabName = Utils.GetPrefabName(((Component)__instance.m_character).gameObject); if (LootSystemData.SLS_Drop_Settings == null || LootSystemData.SLS_Drop_Settings.characterSpecificLoot == null) { return true; } if (LootSystemData.SLS_Drop_Settings.characterSpecificLoot != null && !LootSystemData.SLS_Drop_Settings.characterSpecificLoot.ContainsKey(prefabName)) { return true; } __result = LootStyles.ModifyCharacterDrops(__instance, prefabName); return false; } } [HarmonyPatch(typeof(CharacterDrop))] public static class CalculateLootPerLevelStyle { [HarmonyTranspiler] [HarmonyPatch("GenerateDropList")] private static IEnumerable Transpiler(IEnumerable 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchStartForward((CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(CharacterDrop), "m_character"), (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null) }).Advance(2).RemoveInstructions(15) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Func)DetermineLootScale) }) .ThrowIfNotMatch("Unable to patch Character drop generator, level scaling.", Array.Empty()) .MatchForward(false, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldloc_3, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Drop), "m_levelMultiplier"), (string)null) }) .Advance(1) .MatchForward(false, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldloc_3, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Drop), "m_levelMultiplier"), (string)null) }) .Advance(2) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Func)OverrideLootScalingEnabler) }) .MatchStartForward((CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ble, (object)null, (string)null) }) .Advance(3) .RemoveInstructions(2) .ThrowIfNotMatch("Unable to patch Character drop limit removal.", Array.Empty()); return val.Instructions(); } private static bool OverrideLootScalingEnabler(bool defaultlootLevelMultiplier) { if (ValConfig.ScaleAllLootByLevel.Value) { return true; } return defaultlootLevelMultiplier; } private static int DetermineLootScale(Character character) { int num = 1; if ((Object)(object)character != (Object)null) { num = character.GetLevel(); } LootStyles.SelectCharacterLootSettings(character, out var distance_bonus); float num2; float num3; if (LootStyles.SelectedLootFactor == DataObjects.LootFactorType.PerLevel) { num2 = (float)num * (distance_bonus.MinAmountScaleFactorBonus + ValConfig.PerLevelLootScale.Value); num3 = (float)num * (distance_bonus.MaxAmountScaleFactorBonus + ValConfig.PerLevelLootScale.Value); } else if (LootStyles.SelectedLootFactor == DataObjects.LootFactorType.Exponential) { num2 = Mathf.Pow(ValConfig.PerLevelLootScale.Value + distance_bonus.MinAmountScaleFactorBonus, (float)num); num3 = Mathf.Pow(ValConfig.PerLevelLootScale.Value + distance_bonus.MaxAmountScaleFactorBonus, (float)num); } else { num2 = (float)num * ValConfig.PerLevelLootScale.Value; num3 = (float)num * ValConfig.PerLevelLootScale.Value; } int num4 = Mathf.RoundToInt(Random.Range(num2, num3)); if (num4 < 1) { num4 = 1; } if (ValConfig.EnableDebugLootDetails.Value) { Logger.LogDebug($"Loot Scale {LootStyles.SelectedLootFactor} select {num2} <-> {num3} selected {num4}."); } return num4; } } [HarmonyPatch] public static class MineRockPerformancePatch { [HarmonyTranspiler] [HarmonyPatch(typeof(MineRock), "RPC_Hit")] private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(MineRock), "m_dropItems"), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(DropTable), "GetDropList", (Type[])null, (Type[])null), (string)null) }).RemoveInstructions(6).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_2, (object)null), Transpilers.EmitDelegate>((Action)ModifyMinerockDrops) }) .RemoveInstructions(30) .ThrowIfNotMatch("Unable to patch Minerock performance increase.", Array.Empty()); return val.Instructions(); } internal static void ModifyMinerockDrops(MineRock instance, HitData hit) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) List> optimizeDrops = LootStyles.ModifyRockDropsOrDefault(((Component)instance).transform, instance.m_dropItems, Utils.GetPrefabName(((Component)instance).gameObject), LevelSelection.DeterministicDetermineRockLevel(((Component)instance).gameObject.transform.position)); LootPerformanceChanges.DropItemsPreferAsync(hit.m_point - hit.m_dir * 0.2f + Random.insideUnitSphere * 0.3f, optimizeDrops, immediate: false, dropThatCharacterDrop: false, dropThatNonCharacterDrop: true); } } [HarmonyPatch(typeof(MineRock5))] public static class MineRock5performancePatch { [HarmonyTranspiler] [HarmonyPatch("DamageArea")] private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); if (Compatibility.IsDropThatEnabled && !Compatibility.DropThatMethodsAvailable) { Logger.LogDebug("DropThat detected, using non-performance based Minerock5 patch for compat."); val.MatchStartForward((CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(DropTable), "GetDropList", (Type[])null, (Type[])null), (string)null) }).Advance(1).RemoveInstructions(2) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>>((Func>)NonPerformanceBasedMineDrop) }) .ThrowIfNotMatch("Unable to patch MineRock5 to provide loot modifications.", Array.Empty()); } else { val.MatchStartForward((CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(DropTable), "GetDropList", (Type[])null, (Type[])null), (string)null) }).Advance(1).RemoveInstructions(27) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldloc_3, (object)null), Transpilers.EmitDelegate>((Action)MineDrop) }) .ThrowIfNotMatch("Unable to patch MineRock5 to handle large drops.", Array.Empty()); } return val.Instructions(); } internal static void MineDrop(MineRock5 instance, Vector3 vector) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) int level = LevelSelection.DeterministicDetermineRockLevel(vector); List> optimizeDrops = LootStyles.ModifyRockDropsOrDefault(((Component)instance).transform, instance.m_dropItems, Utils.GetPrefabName(((Component)instance).gameObject), level); LootPerformanceChanges.DropItemsPreferAsync(((Component)instance).transform.position, optimizeDrops, immediate: false, dropThatCharacterDrop: false, dropThatNonCharacterDrop: true); } internal static List NonPerformanceBasedMineDrop(MineRock5 instance) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) List drops = new List(); foreach (KeyValuePair drop in LootStyles.ModifyRockDropsOrDefault(((Component)instance).transform, instance.m_dropItems, Utils.GetPrefabName(((Component)instance).gameObject), LevelSelection.DeterministicDetermineRockLevel(((Component)instance).transform.position))) { drop.Value.Times(delegate { drops.Add(drop.Key); }); } return drops; } } [HarmonyPatch(typeof(DropOnDestroyed))] public static class DropItemsNonCharacterPerformancePatch { [HarmonyTranspiler] [HarmonyPatch("OnDestroyed")] private static IEnumerable Transpiler(IEnumerable 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchStartForward((CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(DropTable), "GetDropList", (Type[])null, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_2, (object)null, (string)null) }).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { Transpilers.EmitDelegate>((Action)DropItemsOnDestroy), new CodeInstruction(OpCodes.Ret, (object)null) }) .ThrowIfNotMatch("Unable to patch DropOnDestroy to handle large drops.", Array.Empty()); return val.Instructions(); } private static void DropItemsOnDestroy(DropOnDestroyed instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) int level = LevelSelection.DetermineisticDetermineObjectLevel(((Component)instance).transform.position); LootStyles.SelectObjectDistanceBonus(((Component)instance).transform, out var distance_bonus); List> optimizeDrops = LootStyles.ModifyObjectDropsOrDefault(instance.m_dropWhenDestroyed, Utils.GetPrefabName(((Component)instance).gameObject), level, distance_bonus, DataObjects.DropType.Destructible); LootPerformanceChanges.DropItemsPreferAsync(((Component)instance).transform.position, optimizeDrops, immediate: false, dropThatCharacterDrop: false, dropThatNonCharacterDrop: true); } } [HarmonyPatch(typeof(TreeBase))] public static class DropItemsTreeBasePerformancePatch { [HarmonyTranspiler] [HarmonyPatch("RPC_Damage")] private static IEnumerable Transpiler(IEnumerable instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); if (Compatibility.IsDropThatEnabled && !Compatibility.DropThatMethodsAvailable) { Logger.LogDebug("DropThat detected, using non-performance based TreeBase patch for compat."); val.MatchStartForward((CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(DropTable), "GetDropList", (Type[])null, (Type[])null), (string)null) }).Advance(1).RemoveInstructions(2) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>>((Func>)NonPerformanceBasedTreeBaseDrop) }) .ThrowIfNotMatch("Unable to patch TreeBase to provide loot modifications.", Array.Empty()); } else { val.MatchStartForward((CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(DropTable), "GetDropList", (Type[])null, (Type[])null), (string)null) }).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Action)TreebaseDropDestroyedItems) }) .RemoveInstructions(54) .Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldarg_0, (object)null) }) .ThrowIfNotMatch("Unable to patch Treebase to handle large drops.", Array.Empty()); } return val.Instructions(); } private static void TreebaseDropDestroyedItems(TreeBase instance) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) List> optimizeDrops = LootStyles.ModifyTreeDropsOrDefault(instance); LootPerformanceChanges.DropItemsPreferAsync(((Component)instance).transform.position, optimizeDrops, immediate: false, dropThatCharacterDrop: false, dropThatNonCharacterDrop: true); } internal static List NonPerformanceBasedTreeBaseDrop(TreeBase instance) { List drops = new List(); foreach (KeyValuePair drop in LootStyles.ModifyTreeDropsOrDefault(instance)) { drop.Value.Times(delegate { drops.Add(drop.Key); }); } return drops; } } } internal class LootPerformanceChanges { [CompilerGenerated] private sealed class d__2 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public List> drops; public Vector3 centerPos; public bool dropThatCharacterDrop; public bool dropThatNonCharacterDrop; public float dropArea; private int 5__2; private int 5__3; private List>.Enumerator <>7__wrap3; private bool 5__5; private int 5__6; private GameObject 5__7; private int 5__8; private int 5__9; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap3 = default(List>.Enumerator); 5__7 = null; <>1__state = -2; } private bool MoveNext() { //IL_0105: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) try { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -3; goto IL_00fe; } <>1__state = -1; 5__2 = 0; 5__3 = 0; <>7__wrap3 = drops.GetEnumerator(); <>1__state = -3; goto IL_02f1; IL_02f1: if (<>7__wrap3.MoveNext()) { KeyValuePair current = <>7__wrap3.Current; 5__5 = false; 5__6 = 0; 5__7 = current.Key; 5__8 = current.Value; if (ValConfig.EnableDebugLootDetails.Value) { Logger.LogDebug($"Dropping async {((Object)5__7).name} {5__8}"); } 5__9 = 0; goto IL_02c7; } <>m__Finally1(); <>7__wrap3 = default(List>.Enumerator); return false; IL_00fe: GameObject val = Object.Instantiate(5__7, centerPos, Quaternion.identity); 5__2++; ItemDrop component = val.GetComponent(); if (!5__5) { 5__5 = true; if (Object.op_Implicit((Object)(object)component)) { 5__6 = component.m_itemData.m_shared.m_maxStackSize; } } if (component != null) { int num2 = 5__8 - 5__9; if (num2 > 0) { if (5__8 > 5__6) { component.m_itemData.m_stack = 5__6; 5__9 += 5__6; } else { component.m_itemData.m_stack = num2; 5__9 += num2; } } component.m_itemData.m_worldLevel = (byte)Game.m_worldLevel; } else { Character component2 = val.GetComponent(); if ((Object)(object)component2 == (Object)null) { component2 = (Character)(object)val.GetComponent(); } if ((Object)(object)component2 != (Object)null) { CreatureSetupControl.CreatureSetup(component2, 0, multiply: true, 0.5f); } } if (dropThatCharacterDrop && Compatibility.IsDropThatEnabled && Compatibility.DropThatMethodsAvailable) { Compatibility.DropThat_ModifyDrop(val, drops, 5__3); } if (dropThatNonCharacterDrop && Compatibility.IsDropThatEnabled && Compatibility.DropThatMethodsAvailable) { Compatibility.DropThat_ModifyInstantiatedObjectDrop(val, 5__3); } Rigidbody component3 = val.GetComponent(); if (Object.op_Implicit((Object)(object)component3)) { Vector3 val2 = Random.insideUnitSphere * dropArea; if (val2.y < 0f) { val2.y = 0f - val2.y; } component3.AddForce(val2 * 5f, (ForceMode)2); } 5__9++; goto IL_02c7; IL_02c7: if (5__9 < 5__8) { if (5__2 > 0 && 5__2 % ValConfig.LootDropsPerTick.Value == 0) { <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } goto IL_00fe; } 5__3++; 5__7 = null; goto IL_02f1; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap3).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static void DropItemsPreferAsync(Vector3 position, List> optimizeDrops, bool immediate = false, bool dropThatCharacterDrop = false, bool dropThatNonCharacterDrop = false) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!immediate) { ((MonoBehaviour)TaskRunner.Run()).StartCoroutine(DropItemsAsync(optimizeDrops, position, 0.5f, dropThatCharacterDrop)); } else { DropItemsImmediate(optimizeDrops, position, 0.5f, dropThatCharacterDrop, dropThatNonCharacterDrop); } } private static void DropItemsImmediate(List> drops, Vector3 centerPos, float dropArea, bool dropThatCharacterDrop = false, bool dropThatNonCharacterDrop = false) { //IL_0060: 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) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) int num = 0; foreach (KeyValuePair drop in drops) { bool flag = false; int num2 = 0; GameObject key = drop.Key; int value = drop.Value; if (ValConfig.EnableDebugLootDetails.Value) { Logger.LogDebug($"Dropping {((Object)key).name} {value}"); } for (int i = 0; i < value; i++) { GameObject val = Object.Instantiate(key, centerPos, Quaternion.identity); ItemDrop component = val.GetComponent(); if (!flag) { flag = true; if (Object.op_Implicit((Object)(object)component)) { num2 = component.m_itemData.m_shared.m_maxStackSize; } } if (component != null) { int num3 = value - i; if (num3 > 0) { if (value > num2) { component.m_itemData.m_stack = num2; i += num2; } else { component.m_itemData.m_stack = num3; i += num3; } } component.m_itemData.m_worldLevel = (byte)Game.m_worldLevel; } else { Character component2 = val.GetComponent(); if ((Object)(object)component2 == (Object)null) { component2 = (Character)(object)val.GetComponent(); } if ((Object)(object)component2 != (Object)null) { CompositeLazyCache.GetAndSetLocalCache(component2); CreatureSetupControl.CreatureSetup(component2, 0, multiply: false); } } if (dropThatCharacterDrop && Compatibility.IsDropThatEnabled && Compatibility.DropThatMethodsAvailable) { Compatibility.DropThat_ModifyDrop(val, drops, num); } if (dropThatNonCharacterDrop && Compatibility.IsDropThatEnabled && Compatibility.DropThatMethodsAvailable) { Compatibility.DropThat_ModifyInstantiatedObjectDrop(val, num); } Rigidbody component3 = val.GetComponent(); if (Object.op_Implicit((Object)(object)component3)) { Vector3 val2 = Random.insideUnitSphere * dropArea; if (val2.y < 0f) { val2.y = 0f - val2.y; } component3.AddForce(val2 * 5f, (ForceMode)2); } } num++; } } [IteratorStateMachine(typeof(d__2))] private static IEnumerator DropItemsAsync(List> drops, Vector3 centerPos, float dropArea, bool dropThatCharacterDrop = false, bool dropThatNonCharacterDrop = false) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0) { drops = drops, centerPos = centerPos, dropArea = dropArea, dropThatCharacterDrop = dropThatCharacterDrop, dropThatNonCharacterDrop = dropThatNonCharacterDrop }; } } internal static class LootStyles { public static DataObjects.LootFactorType SelectedLootFactor = DataObjects.LootFactorType.PerLevel; internal static readonly AcceptableValueList AllowedLootFactors = new AcceptableValueList(new string[2] { DataObjects.LootFactorType.PerLevel.ToString(), DataObjects.LootFactorType.Exponential.ToString() }); internal static void LootFactorChanged(object s, EventArgs e) { SelectedLootFactor = (DataObjects.LootFactorType)Enum.Parse(typeof(DataObjects.LootFactorType), ValConfig.LootDropCalculationType.Value); } internal static List> ModifyTreeDropsOrDefault(TreeBase treeInstance) { int orAddCachedTreeEntry = CompositeLazyCache.GetOrAddCachedTreeEntry(treeInstance.m_nview); SelectObjectDistanceBonus(((Component)treeInstance).transform, out var distance_bonus); return ModifyObjectDropsOrDefault(treeInstance.m_dropWhenDestroyed, Utils.GetPrefabName(((Component)treeInstance).gameObject), orAddCachedTreeEntry, distance_bonus); } internal static List> ModifyTreeDropsOrDefault(TreeLog treeInstance) { int orAddCachedTreeEntry = CompositeLazyCache.GetOrAddCachedTreeEntry(treeInstance.m_nview); SelectObjectDistanceBonus(((Component)treeInstance).transform, out var distance_bonus); return ModifyObjectDropsOrDefault(treeInstance.m_dropWhenDestroyed, Utils.GetPrefabName(((Component)treeInstance).gameObject), orAddCachedTreeEntry, distance_bonus); } internal static List> ModifyRockDropsOrDefault(Transform tform, DropTable droptable, string name, int level) { SelectObjectDistanceBonus(tform, out var distance_bonus); return ModifyObjectDropsOrDefault(droptable, name, level, distance_bonus, DataObjects.DropType.Rock); } internal static List> ModifyObjectDropsOrDefault(DropTable defaultDrops, string lookupkey, int level, DataObjects.DistanceLootModifier distance_bonus, DataObjects.DropType type = DataObjects.DropType.Tree) { //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Expected O, but got Unknown List> list = new List>(); Logger.LogDebug("Checking for custom drop configuration for " + lookupkey); if (LootSystemData.SLS_Drop_Settings != null && LootSystemData.SLS_Drop_Settings.nonCharacterSpecificLoot != null && LootSystemData.SLS_Drop_Settings.nonCharacterSpecificLoot.ContainsKey(lookupkey)) { Logger.LogDebug("Custom loot drops configured for:" + lookupkey); foreach (DataObjects.ExtendedObjectDrop item in LootSystemData.SLS_Drop_Settings.nonCharacterSpecificLoot[lookupkey]) { if (item.Drop.Chance < 1f) { float value = Random.value; float num = item.Drop.Chance; if (item.ChanceScaleFactor > 0f) { num *= 1f + item.ChanceScaleFactor * (float)level; } if (value > num) { Logger.LogDebug($"Drop {item.Drop.Prefab} failed random drop chance ({value} < {num})."); continue; } } if ((Object)(object)item.DropGo == (Object)null) { item.ResolveDropPrefab(); if ((Object)(object)item.DropGo == (Object)null) { Logger.LogWarning("Prefab " + item.Drop.Prefab + " was not found, ensure it is spelled correctly and available in the game. This lootdrop will be skipped."); continue; } } if (item.Drop.DontScale) { list.Add(new KeyValuePair(item.DropGo, Random.Range(item.Drop.Min, item.Drop.Max))); continue; } float num2 = 1f; int min = item.Drop.Min; int max = item.Drop.Max; int num3 = min; if (min != max) { num3 = Random.Range(min, max); } if (item.UseChanceAsMultiplier) { num2 = item.Drop.Chance * (float)level; } int num4 = num3; float num5 = item.AmountScaleFactor * num2; if (num5 <= 0f) { num5 = 1f; } switch (SelectedLootFactor) { case DataObjects.LootFactorType.PerLevel: num4 = MultiplyLootPerLevel(num4, level, distance_bonus, num5); break; case DataObjects.LootFactorType.Exponential: num4 = ExponentLootPerLevel(num4, level, distance_bonus, num5); break; case DataObjects.LootFactorType.ChancePerLevel: { float value2 = Random.value; float num6 = item.Drop.Chance; if (item.ChanceScaleFactor > 0f) { num6 *= 1f + item.ChanceScaleFactor * (float)level; } if (value2 > num6) { Logger.LogDebug($"Drop {item.Drop.Prefab} failed random drop chance ({value2} < {num6})."); continue; } break; } } if (item.MaxScaledAmount > 0 && num4 > item.MaxScaledAmount) { num4 = item.MaxScaledAmount; Logger.LogDebug($"Drop {item.Drop.Prefab} capped to {num4}"); } list.Add(new KeyValuePair(item.DropGo, num4)); } } else { if (defaultDrops == null) { return list; } DropTable val = new DropTable(); switch (type) { case DataObjects.DropType.Tree: Logger.LogDebug($"Updating Tree drops with: level-{level}"); val = UpdateDroptableByLevel(defaultDrops, level, ValConfig.PerLevelTreeLootScale.Value); break; case DataObjects.DropType.Rock: Logger.LogDebug($"Updating Rock drops with: level-{level}"); val = UpdateDroptableByLevel(defaultDrops, level, ValConfig.PerLevelMineRockLootScale.Value); break; case DataObjects.DropType.Destructible: Logger.LogDebug($"Updating Destructible drops with: level-{level}"); val = UpdateDroptableByLevel(defaultDrops, level, ValConfig.PerLevelDestructibleLootScale.Value); break; } list = OptimizeToDropStacks(val.GetDropList()); } return list; } internal static List> ModifyCharacterDrops(CharacterDrop cdrop, string name) { //IL_0391: Unknown result type (might be due to invalid IL or missing references) List> list = new List>(); int num = 1; if ((Object)(object)cdrop.m_character != (Object)null) { num = cdrop.m_character.m_level; } SelectCharacterLootSettings(cdrop.m_character, out var distance_bonus); StringBuilder stringBuilder = new StringBuilder(); foreach (DataObjects.ExtendedCharacterDrop item in LootSystemData.SLS_Drop_Settings.characterSpecificLoot[name]) { if ((Object)(object)cdrop.m_character != (Object)null) { if (ValConfig.EnableDebugLootDetails.Value) { stringBuilder.AppendLine("Skipping " + item.Drop.Prefab + " for tamed creature."); } if ((item.UntamedOnlyDrop && cdrop.m_character.IsTamed()) || (item.TamedOnlyDrop && !cdrop.m_character.IsTamed())) { continue; } } float num2 = 1f; if (item.Drop.Chance < 1f) { float value = Random.value; float num3 = item.Drop.Chance; if (item.ChanceScaleFactor > 0f) { num3 *= 1f + item.ChanceScaleFactor * (float)num; } if (value > num3) { if (ValConfig.EnableDebugLootDetails.Value) { stringBuilder.AppendLine($"Drop {item.Drop.Prefab} failed random drop chance ({value} < {num3})."); } continue; } } if (item.UseChanceAsMultiplier) { num2 = item.Drop.Chance * (float)num; if (ValConfig.EnableDebugLootDetails.Value) { stringBuilder.AppendLine($"Drop {item.Drop.Prefab} modified by chance and creature level (scale multiplier now: {num2})."); } } int min = item.Drop.Min; int max = item.Drop.Max; int num4 = min; if (min != max) { num4 = ((!item.ScalebyMaxLevel) ? Random.Range(min, max) : ((max - min) / ValConfig.MaxLevel.Value * num)); if (ValConfig.EnableDebugLootDetails.Value) { stringBuilder.AppendLine($"Drop {item.Drop.Prefab} determined base drop amount: {num4})."); } } if (item.DoesNotScale) { if (ValConfig.EnableDebugLootDetails.Value) { stringBuilder.AppendLine($"Drop {item.Drop.Prefab} does not scale and will drop {num4}"); } list.Add(new KeyValuePair(item.GameDrop.m_prefab, num4)); continue; } int num5 = num4; if (!item.DoesNotScale && !item.Drop.DontScale) { float num6 = item.AmountScaleFactor * num2; if (num6 <= 0f) { num6 = 1f; } num5 = ((SelectedLootFactor != 0) ? ExponentLootPerLevel(num5, num, distance_bonus, num6) : MultiplyLootPerLevel(num5, num, distance_bonus, num6)); if (ValConfig.EnableDebugLootDetails.Value) { stringBuilder.AppendLine($"Drop {item.Drop.Prefab} Using {SelectedLootFactor} factor {num6} base {num4} = {num5}"); } if (item.MaxScaledAmount > 0 && num5 > item.MaxScaledAmount) { num5 = item.MaxScaledAmount; Logger.LogDebug($"Drop {item.Drop.Prefab} capped to {num5}"); } } if (item.Drop.OnePerPlayer) { int playersInRangeXZ = Player.GetPlayersInRangeXZ(((Component)cdrop).transform.position, 500f); num5 *= Mathf.Max(1, playersInRangeXZ); } if (item.GameDrop == null || (Object)(object)item.GameDrop.m_prefab == (Object)null) { item.ToCharacterDrop(); } list.Add(new KeyValuePair(item.GameDrop.m_prefab, num5)); } if (ValConfig.EnableDebugLootDetails.Value) { Logger.LogDebug("Generated drops for " + name + ":\n" + stringBuilder.ToString()); } return list; } private static int MultiplyLootPerLevel(int lootdrop_amount, int level, DataObjects.DistanceLootModifier dmod, float scale_factor = 1f) { if (level == 1) { return lootdrop_amount; } float num = (float)level * ValConfig.PerLevelLootScale.Value * (scale_factor + dmod.MinAmountScaleFactorBonus); float num2 = (float)level * ValConfig.PerLevelLootScale.Value * (scale_factor + dmod.MaxAmountScaleFactorBonus); if (num == num2) { int num3 = Mathf.RoundToInt(num * (float)lootdrop_amount); if (ValConfig.EnableDebugLootDetails.Value) { Logger.LogDebug($"MultiplyLootPerLevel {num3} = drop_base: {lootdrop_amount} * {num} scale from (lvl:{level} * PerLevelLootScale:{ValConfig.PerLevelLootScale.Value}) * (factor:{scale_factor} + scaleFactorBonus:{dmod.MinAmountScaleFactorBonus})"); } return num3; } int num4 = Mathf.RoundToInt(num * (float)lootdrop_amount); int num5 = Mathf.RoundToInt(num2 * (float)lootdrop_amount); int num6 = Random.Range(num4, num5); if (ValConfig.EnableDebugLootDetails.Value) { Logger.LogDebug($"MultiplyLootPerLevel {num6} from range: ({num4} <-> {num5}) = drop_base: {lootdrop_amount} * min:{num}/max:{num2} scale from (lvl:{level} * PerLevelLootScale:{ValConfig.PerLevelLootScale.Value}) * (factor:{scale_factor} + scaleFactorBonus: min{dmod.MinAmountScaleFactorBonus}/max:{dmod.MaxAmountScaleFactorBonus})"); } return num6; } private static int ExponentLootPerLevel(int lootdrop_amount, int level, DataObjects.DistanceLootModifier dmod, float scale_factor = 1f) { if (level == 1) { return lootdrop_amount; } float num = ValConfig.PerLevelLootScale.Value + dmod.MinAmountScaleFactorBonus + scale_factor; float num2 = ValConfig.PerLevelLootScale.Value + dmod.MaxAmountScaleFactorBonus + scale_factor; int num3 = Mathf.RoundToInt(Mathf.Pow(Random.Range(num, num2), (float)level) * (float)lootdrop_amount); Logger.LogDebug($"ExponentLootPerLevel {num3} from range ({num} <-> {num2}) = drop_base: {lootdrop_amount} * min:{num}/max:{num2} scale from (factor:{scale_factor} + distance:(min){dmod.MinAmountScaleFactorBonus}/(max){dmod.MaxAmountScaleFactorBonus} perlevelscale:{dmod.MinAmountScaleFactorBonus})"); return num3; } private static int ChancePerLevel(int lootdrop_amount, int level, DataObjects.DistanceLootModifier dmod, float scale_factor = 1f) { float num = ValConfig.PerLevelLootScale.Value + dmod.MinAmountScaleFactorBonus + scale_factor; float num2 = ValConfig.PerLevelLootScale.Value + dmod.MaxAmountScaleFactorBonus + scale_factor; float num3 = Mathf.Pow(Random.Range(num, num2), (float)level); float value = Random.value; Logger.LogDebug($"ChancePerLevel roll {value} vs chance {num3} from range ({num} <-> {num2}) = drop_base: {lootdrop_amount} * min:{num}/max:{num2} scale from (factor:{scale_factor} + distance:(min){dmod.MinAmountScaleFactorBonus}/(max){dmod.MaxAmountScaleFactorBonus} perlevelscale:{dmod.MinAmountScaleFactorBonus})"); if (value < num3) { return lootdrop_amount; } return 0; } internal static DropTable UpdateDroptableByLevel(DropTable droptable, int level, float mod) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) if (level > 1) { DropTable val = droptable.Clone(); List list = new List(); foreach (DropData drop in droptable.m_drops) { DropData val2 = drop; val2.m_stackMin = Mathf.RoundToInt((float)drop.m_stackMin * (1f + mod * (float)level)); val2.m_stackMax = Mathf.RoundToInt((float)drop.m_stackMax * (1f + mod * (float)level)); Logger.LogDebug($"Scaling drop {drop.m_item} from {drop.m_stackMin}-{drop.m_stackMax} to {val2.m_stackMin}-{val2.m_stackMax} for level {level}."); list.Add(val2); } val.m_drops = list; return val; } return droptable; } internal static List> OptimizeToDropStacks(List drops, float lootmult = 1f) { List> list = new List>(); Dictionary dictionary = new Dictionary(); foreach (GameObject drop in drops) { if (dictionary.ContainsKey(drop)) { dictionary[drop]++; } else { dictionary.Add(drop, 1); } } if (lootmult != 1f) { foreach (KeyValuePair item in dictionary) { int num = Mathf.RoundToInt((float)item.Value * lootmult); Logger.LogDebug($"{item.Key} loot modified: {item.Value} * {lootmult} = {num}"); list.Add(new KeyValuePair(item.Key, num)); } } else { foreach (KeyValuePair item2 in dictionary) { list.Add(new KeyValuePair(item2.Key, item2.Value)); } } return list; } public static void SelectCharacterLootSettings(Character creature, out DataObjects.DistanceLootModifier distance_bonus) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) float distance_from_center = Vector2.Distance(Vector2.op_Implicit(((Component)creature).gameObject.transform.position), Vector2.op_Implicit(DistanceScaleSystem.center)); distance_bonus = SelectDistanceFromCenterLootBonus(distance_from_center); } public static void SelectObjectDistanceBonus(Transform tform, out DataObjects.DistanceLootModifier distance_bonus) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) float distance_from_center = Vector2.Distance(Vector2.op_Implicit(tform.position), Vector2.op_Implicit(DistanceScaleSystem.center)); distance_bonus = SelectDistanceFromCenterLootBonus(distance_from_center); } private static DataObjects.DistanceLootModifier SelectDistanceFromCenterLootBonus(float distance_from_center) { DataObjects.DistanceLootModifier result = new DataObjects.DistanceLootModifier(); if (ValConfig.EnableDistanceLevelScalingBonus.Value && LootSystemData.SLS_Drop_Settings != null && LootSystemData.SLS_Drop_Settings.DistanceLootModifier != null) { foreach (KeyValuePair item in LootSystemData.SLS_Drop_Settings.DistanceLootModifier) { if (distance_from_center <= (float)item.Key) { result = item.Value; break; } } } return result; } } } namespace StarLevelSystem.modules.LevelSystem { internal static class DistanceScaleSystem { [CompilerGenerated] private sealed class d__11 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private MapOverlay 5__2; private Color[] 5__3; private int 5__4; private int 5__5; private int 5__6; private int 5__7; private SortedDictionary>.KeyCollection.Enumerator <>7__wrap7; private Color 5__9; private int 5__10; private int 5__11; private float 5__12; private int 5__13; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__11(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__2 = null; 5__3 = null; <>7__wrap7 = default(SortedDictionary>.KeyCollection.Enumerator); <>1__state = -2; } private bool MoveNext() { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Expected O, but got Unknown //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) bool result; try { int num = <>1__state; if (num != 0) { if (num == 1) { <>1__state = -3; goto IL_0289; } result = false; } else { <>1__state = -1; if (LevelSystemData.SLE_Level_Settings.DistanceLevelBonus == null || LevelSystemData.SLE_Level_Settings.DistanceLevelBonus.Keys.Count <= 0) { result = false; } else if (ZNet.instance.IsDedicated()) { Logger.LogDebug("Server is headless, skipping minimap generation"); result = false; } else { 5__2 = MinimapManager.Instance.GetMapOverlay("SLS-LevelBonus", false); 5__2.Enabled = true; int num2 = ((MapOverlayBase)5__2).TextureSize * ((MapOverlayBase)5__2).TextureSize; 5__3 = (Color[])(object)new Color[num2]; 5__2.OverlayTex.SetPixels(5__3); Minimap.instance.WorldToPixel(center, ref 5__4, ref 5__5); Logger.LogDebug($"Map centered: x:{5__4} y:{5__5}"); if (LevelSystemData.SLE_Level_Settings != null && LevelSystemData.SLE_Level_Settings.DistanceLevelBonus != null && Colorization.mapRingColors != null && Colorization.mapRingColors.Count != 0) { 5__6 = 0; 5__7 = 0; <>7__wrap7 = LevelSystemData.SLE_Level_Settings.DistanceLevelBonus.Keys.GetEnumerator(); <>1__state = -3; goto IL_033b; } result = false; } } goto end_IL_0000; IL_0289: float num3 = 5__12 * (float)5__13; int num4 = Mathf.RoundToInt((float)5__4 + Mathf.Cos(num3) * (float)5__11); int num5 = Mathf.RoundToInt((float)5__5 + Mathf.Sin(num3) * (float)5__11); if (5__2 != null) { int num6 = num5 * ((MapOverlayBase)5__2).TextureSize + num4; if (num6 < 5__3.Length && num6 >= 0) { 5__3[num6] = 5__9; } 5__13++; goto IL_032a; } result = false; <>m__Finally1(); goto end_IL_0000; IL_032a: if (5__13 >= 5__10) { goto IL_033b; } 5__6++; if (5__6 % 3000 != 0) { goto IL_0289; } <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 1; result = true; goto end_IL_0000; IL_033b: if (<>7__wrap7.MoveNext()) { int current = <>7__wrap7.Current; if (5__7 >= Colorization.mapRingColors.Count) { 5__7 = 0; } 5__9 = Colorization.mapRingColors[5__7]; 5__7++; 5__10 = current * 10; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(center.x + (float)current, center.y, center.z); int num7 = default(int); int num8 = default(int); Minimap.instance.WorldToPixel(val, ref num7, ref num8); 5__11 = num7 - 5__4; Logger.LogDebug($"Set Ringsize: {current} -PixelMap-> {num7} | {5__11}"); 5__12 = (float)Math.PI * 2f / (float)5__10; 5__13 = 0; goto IL_032a; } <>m__Finally1(); <>7__wrap7 = default(SortedDictionary>.KeyCollection.Enumerator); if (5__2 == null) { result = false; } else { 5__2.OverlayTex.SetPixels(5__3); 5__2.OverlayTex.Apply(); Logger.LogDebug("Finished Creating Level Bonus Rings on Minimap"); buildingMapRings = false; ringAvailable = true; result = false; } end_IL_0000:; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap7).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__4 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private int 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; Logger.LogDebug("Waiting to draw map"); <>2__current = (object)new WaitForSeconds(10f); <>1__state = 1; return true; case 1: <>1__state = -1; if (!ZNet.instance.IsCurrentServerDedicated()) { break; } 5__2 = 0; goto IL_00b1; case 2: { <>1__state = -1; 5__2++; if (5__2 >= 25) { Logger.LogWarning("Config sync not detected. Waiting timeframe expired."); break; } goto IL_00b1; } IL_00b1: if (!ValConfig.RecievedConfigsFromServer) { Logger.LogDebug("Waiting for config sync to complete before drawing map rings on dedicated server."); <>2__current = (object)new WaitForSeconds(5f); <>1__state = 2; return true; } break; } CreateLevelBonusRingMapOverlays(); 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 Vector3 center = new Vector3(0f, 0f, 0f); private static bool buildingMapRings = false; private static bool ringAvailable = false; public static void DelayedMinimapSetup() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); if (!(((Scene)(ref activeScene)).name != "main")) { ((MonoBehaviour)TaskRunner.Run()).StartCoroutine(CheckAndDrawMapRings()); } } [IteratorStateMachine(typeof(d__4))] private static IEnumerator CheckAndDrawMapRings() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0); } internal static SortedDictionary SelectDistanceFromCenterLevelBonus(float distance_from_center) { SortedDictionary sortedDictionary = new SortedDictionary(); if (ValConfig.EnableDistanceLevelScalingBonus.Value && LevelSystemData.SLE_Level_Settings.DistanceLevelBonus != null) { foreach (KeyValuePair> distanceLevelBonu in LevelSystemData.SLE_Level_Settings.DistanceLevelBonus) { if (distance_from_center >= (float)distanceLevelBonu.Key) { sortedDictionary = distanceLevelBonu.Value; } if (distance_from_center < (float)distanceLevelBonu.Key) { return sortedDictionary; } } if (sortedDictionary.Count > 0) { return sortedDictionary; } } return new SortedDictionary(); } private static void CreateLevelBonusRingMapOverlays() { if (ValConfig.EnableMapRingsForDistanceBonus.Value) { SetRingCenter(); Logger.LogDebug("Creating Level Bonus Rings on Map"); if (!buildingMapRings) { buildingMapRings = true; ((MonoBehaviour)TaskRunner.Run()).StartCoroutine(BuildMapRingOverlay()); } } } public static void OnRingCenterChanged(object s, EventArgs e) { if (!ZNet.instance.IsCurrentServerDedicated()) { SetRingCenter(); DelayedMinimapSetup(); } } public static void SetRingCenter() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (ValConfig.DistanceBonusIsFromStarterTemple.Value) { GameObject val = (from obj in Resources.FindObjectsOfTypeAll() where ((Object)obj).name == "StartTemple" select obj).FirstOrDefault(); if ((Object)(object)val != (Object)null) { center = val.transform.position; return; } Logger.LogWarning("Unable to find starter temple, bonus rings will use world center. (0,0,0)"); center = new Vector3(0f, 0f, 0f); } else { center = new Vector3(0f, 0f, 0f); } } public static void UpdateMapColorSettingsOnChange(object s, EventArgs e) { Colorization.UpdateMapColorSelection(); DelayedMinimapSetup(); } public static void UpdateMapRingEnableSettingOnChange(object s, EventArgs e) { if (ValConfig.EnableMapRingsForDistanceBonus.Value) { DelayedMinimapSetup(); } else if (ringAvailable) { MapOverlay mapOverlay = MinimapManager.Instance.GetMapOverlay("SLS-LevelBonus", false); if (mapOverlay != null) { mapOverlay.Enabled = false; } } } [IteratorStateMachine(typeof(d__11))] private static IEnumerator BuildMapRingOverlay() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__11(0); } } internal static class LevelPatches { [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) { LevelSelection.SelectCreatureBiomeSettings(((Component)__instance).gameObject, out var creature_name, out var creature_settings, out var biome_settings, out var _); num = LevelSelection.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(LevelSelection.ModifyTreeWithLevel(__instance, num)); } } } [HarmonyPatch(typeof(TreeLog))] public static class SetTreeLogPassLevel { [HarmonyPatch("Destroy")] [HarmonyPrefix] private static bool DropAndSpawnTreeLogs(TreeLog __instance) { //IL_000d: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) List> optimizeDrops = LootStyles.ModifyTreeDropsOrDefault(__instance); Vector3 val = ((Component)__instance).transform.position + ((Component)__instance).transform.up * Random.Range(0f - __instance.m_spawnDistance, __instance.m_spawnDistance) + Vector3.up * 0.3f; __instance.m_destroyedEffect.Create(val, ((Component)__instance).transform.rotation, (Transform)null, 1f, -1); LootPerformanceChanges.DropItemsPreferAsync(val, optimizeDrops, immediate: false, dropThatCharacterDrop: false, dropThatNonCharacterDrop: true); if ((Object)(object)__instance.m_subLogPrefab != (Object)null) { Transform[] subLogPoints = __instance.m_subLogPoints; foreach (Transform val2 in subLogPoints) { Quaternion val3 = (__instance.m_useSubLogPointRotation ? ((Component)__instance).transform.rotation : ((Component)__instance).transform.rotation); Logger.LogDebug($"Spawning Treelog at point {val2.position} rot:{val3}"); SetupTreeLog(__instance, val2, val3); } } if (ValConfig.EnableTreeScaling.Value && (Object)(object)__instance.m_nview != (Object)null && __instance.m_nview.GetZDO() != null) { CompositeLazyCache.RemoveTreeCacheEntry(((ZDOID)(ref __instance.m_nview.GetZDO().m_uid)).ID); } ZNetScene.instance.Destroy(((Component)__instance).gameObject); return false; } [HarmonyPatch("Awake")] [HarmonyPostfix] private static void SetupAwakeLog(TreeLog __instance) { if (ValConfig.EnableTreeScaling.Value) { 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); } __instance.m_health += __instance.m_health * 0.1f * (float)num; ImpactEffect component = ((Component)__instance).GetComponent(); if (component != null) { ((DamageTypes)(ref component.m_damages)).Modify(1f + 0.1f * (float)num); } } } internal static void SetupTreeLog(TreeLog instance, Transform tform, Quaternion qt) { //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_0027: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Object.Instantiate(instance.m_subLogPrefab, tform.position, qt); ZNetView component = obj.GetComponent(); TreeLog component2 = obj.GetComponent(); component.SetLocalScale(((Component)instance).transform.localScale); int num = 1; if (ValConfig.EnableTreeScaling.Value) { 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); } } component2.m_health += component2.m_health * 0.1f * (float)num; ImpactEffect component3 = obj.GetComponent(); if (component3 != null) { ((DamageTypes)(ref component3.m_damages)).Modify(1f + 0.1f * (float)num); } if (!ValConfig.UseDeterministicTreeScaling.Value) { component.GetZDO().Set(DataObjects.SLS_TREE, num); } } } [HarmonyPatch(typeof(RandomFlyingBird), "Awake")] public static class RandomFlyingBirdExtension { public static void Postfix(RandomFlyingBird __instance) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) if (!ValConfig.EnableScalingBirds.Value) { return; } int num = __instance.m_nview.GetZDO().GetInt(DataObjects.SLS_BIRD, 0); if (num == 0) { LevelSelection.SelectCreatureBiomeSettings(((Component)__instance).gameObject, out var creature_name, out var creature_settings, out var biome_settings, out var _); num = LevelSelection.DetermineLevel(((Component)__instance).gameObject, creature_name, creature_settings, biome_settings, ValConfig.BirdMaxLevel.Value); __instance.m_nview.GetZDO().Set(DataObjects.SLS_BIRD, num); } if (num <= 1) { return; } float num2 = 1f + ValConfig.BirdSizeScalePerLevel.Value * (float)num; Transform transform = ((Component)__instance).transform; transform.localScale *= num2; Physics.SyncTransforms(); DropOnDestroyed component = ((Component)__instance).gameObject.GetComponent(); List list = new List(); foreach (DropData drop in component.m_dropWhenDestroyed.m_drops) { DropData item = default(DropData); item.m_stackMin = Mathf.RoundToInt((float)drop.m_stackMin * (1f + ValConfig.PerLevelBirdLootScale.Value * (float)num)); item.m_stackMax = Mathf.RoundToInt((float)drop.m_stackMax * (1f + ValConfig.PerLevelBirdLootScale.Value * (float)num)); item.m_item = drop.m_item; list.Add(item); } component.m_dropWhenDestroyed.m_drops = list; } } [HarmonyPatch(typeof(Growup))] public static class SetGrowUpLevel { [HarmonyTranspiler] [HarmonyPatch("GrowUpdate")] private static IEnumerable Transpiler(IEnumerable instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Character), "GetLevel", (Type[])null, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Character), "SetLevel", (Type[])null, (Type[])null), (string)null) }).RemoveInstructions(2).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Action)SetupGrownUp) }) .ThrowIfNotMatch("Unable to patch child grow up level set.", Array.Empty()); return val.Instructions(); } internal static void SetupGrownUp(Character grownup, Character childChar) { DataObjects.CharacterCacheEntry cacheEntry = CompositeLazyCache.GetCacheEntry(childChar); int leveloverride = 0; if (cacheEntry == null) { leveloverride = childChar.m_level; grownup.SetLevel(childChar.m_level); } DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(grownup); andSetLocalCache.CreatureModifiers = cacheEntry.CreatureModifiers; andSetLocalCache.Level = cacheEntry.Level; CompositeLazyCache.SetCreatureModifiers(grownup, cacheEntry.CreatureModifiers); CreatureSetupControl.CreatureSpawnerSetup(grownup, leveloverride, multiply: false); } } [HarmonyPatch] public static class SetChildLevel { [HarmonyTranspiler] [HarmonyPatch(typeof(Procreation), "Procreate")] private static IEnumerable SetChildLevelProcreateTranspiler(IEnumerable instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Tameable), "IsTamed", (Type[])null, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Character), "SetTamed", (Type[])null, (Type[])null), (string)null) }).RemoveInstructions(15).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldloc, (object)(byte)6), new CodeInstruction(OpCodes.Ldarg_0, (object)null), Transpilers.EmitDelegate>((Action)SetupChildCharacter) }) .MatchStartForward((CodeMatch[])(object)new CodeMatch[5] { new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Procreation), "m_minOffspringLevel"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Procreation), "m_character"), (string)null) }) .Advance(2) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Action)SetupEggItem) }) .RemoveInstructions(13) .ThrowIfNotMatch("Unable to patch child spawn level set.", Array.Empty()); return val.Instructions(); } [HarmonyTranspiler] [HarmonyPatch(typeof(EggGrow), "GrowUpdate")] private static IEnumerable EggSetChildLevelTranspiler(IEnumerable instructions, ILGenerator generator) { //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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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 CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchStartForward((CodeMatch[])(object)new CodeMatch[5] { new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(EggGrow), "m_item"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ItemData), "m_quality"), (string)null) }).Advance(2).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Action)ControlEggSpawnLevelInheritance) }) .RemoveInstructions(4) .ThrowIfNotMatch("Unable to patch Egg.GrowUpdate", Array.Empty()); return val.Instructions(); } private static void ControlEggSpawnLevelInheritance(Character spawnedChar, EggGrow egg) { if (ValConfig.EggLevelDeterminedByItemQuality.Value) { int quality = egg.m_item.m_itemData.m_quality; Logger.LogDebug($"Setting egg spawn level based on item quality {quality}."); CreatureSetupControl.CreatureSetup(spawnedChar, quality); } else { CreatureSetupControl.CreatureSetup(spawnedChar); } CheckToMakeOffspringInfertile(spawnedChar); } private static void CheckToMakeOffspringInfertile(Character chara) { if (ValConfig.OffspringCanBeInfertile.Value && Random.value <= ValConfig.OffspringChanceToBeInfertile.Value) { chara.m_nview.GetZDO().Set(DataObjects.SLS_INFERTILE, true); Logger.LogDebug("Child is infertile."); } } internal static void SetupEggItem(ItemDrop item, Procreation proclass) { if (ValConfig.LootEggsDropIncreaseStacks.Value) { int num = Mathf.RoundToInt(1f * (1f + ValConfig.PerLevelLootScale.Value * (float)proclass.m_character.m_level)); if (num > item.m_itemData.m_shared.m_maxStackSize) { num = item.m_itemData.m_shared.m_maxStackSize; } item.m_itemData.m_stack = num; return; } int num2 = Mathf.Max(proclass.m_minOffspringLevel, Object.op_Implicit((Object)(object)proclass.m_character) ? proclass.m_character.GetLevel() : proclass.m_minOffspringLevel); if (ValConfig.OffspringCanBeStrongerThanParents.Value && Random.value <= ValConfig.OffspringGainExtraLevelChance.Value) { num2++; Logger.LogDebug("Child egg is stronger than parents and has a higher max level."); } item.SetQuality(num2); } internal static void SetupChildCharacter(Character chara, Procreation proc) { Logger.LogDebug("Setting child level for " + chara.m_name); chara.SetTamed(true); DataObjects.CharacterCacheEntry cacheEntry = CompositeLazyCache.GetCacheEntry(proc.m_character); if (!ValConfig.RandomizeTameChildrenModifiers.Value && (Object)(object)proc.m_character != (Object)null && cacheEntry != null) { CompositeLazyCache.SetCreatureModifiers(chara, cacheEntry.CreatureModifiers); } if (!ValConfig.SpawnMultiplicationAppliesToTames.Value && chara.m_nview.GetZDO() != null) { Logger.LogDebug("Disabling spawn multiplier for tamed child."); chara.m_nview.GetZDO().Set(DataObjects.SLS_SPAWN_MULT, true); } int num = proc.m_character.m_level; if (cacheEntry != null && cacheEntry.Level != 0) { num = cacheEntry.Level; } if (ValConfig.RandomizeTameChildrenLevels.Value) { int num2 = Random.Range(1, num); if (ValConfig.OffspringCanBeStrongerThanParents.Value && Random.value <= ValConfig.OffspringGainExtraLevelChance.Value) { num2++; Logger.LogDebug("Child is strong, but still random."); } Logger.LogDebug($"Character randomized level {num2} (1-{num}) being used for child."); CreatureSetupControl.CreatureSetup(chara, num2, multiply: true, 0.1f); } else { if (ValConfig.OffspringCanBeStrongerThanParents.Value && Random.value <= ValConfig.OffspringGainExtraLevelChance.Value) { num++; Logger.LogDebug("Child is stronger than parents and has a higher max level."); } Logger.LogDebug($"Parent level {num} being used for child from: proc-{proc.m_character.m_level} cdc-{cacheEntry.Level}."); CreatureSetupControl.CreatureSetup(chara, num, multiply: true, 0.1f); } CheckToMakeOffspringInfertile(chara); } } [HarmonyPatch(typeof(Procreation), "ReadyForProcreation")] public static class ProcreationPrevention { public static void Postfix(Procreation __instance, ref bool __result) { if (((Object)(object)__instance.m_character != (Object)null || (Object)(object)__instance.m_character.m_nview != (Object)null || (__instance.m_character.m_nview.GetZDO() != null && __result)) && __instance.m_nview.GetZDO().GetBool(DataObjects.SLS_INFERTILE, false)) { __result = false; Logger.LogDebug("Preventing procreation because child is infertile."); } } } [HarmonyPatch(typeof(Tameable), "GetHoverText")] public static class ProcreationPreventionDisplay { public static void Postfix(Tameable __instance, ref string __result) { if ((Object)(object)__instance.m_character != (Object)null && (Object)(object)__instance.m_character.m_nview != (Object)null && __instance.m_character.m_nview.GetZDO() != null && __instance.m_nview.GetZDO().GetBool(DataObjects.SLS_INFERTILE, false)) { __result += Localization.instance.Localize("\n$SLS_infertile"); } } } [HarmonyPatch(typeof(CreatureSpawner))] public static class CreatureSpawnerSpawn { [HarmonyTranspiler] [HarmonyPatch("Spawn")] private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Character), "SetLevel", (Type[])null, (Type[])null), (string)null) }).RemoveInstructions(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Action)CreatureSpawnerCharacterLevelControl) }) .MatchStartBackwards((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null) }) .Advance(1) .RemoveInstructions(1) .Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_I4, (object)0) }) .MatchStartBackwards((CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null) }) .Advance(2) .RemoveInstructions(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_I4, (object)0) }) .ThrowIfNotMatch("Unable to patch CreatureSpawner.Spawn.", Array.Empty()); return val.Instructions(); } private static void CreatureSpawnerCharacterLevelControl(Character chara, int providedLevel) { LevelSelection.SetCharacterLevelControl(chara, providedLevel); } [HarmonyPatch("Awake")] [HarmonyPostfix] public static void Postfix(CreatureSpawner __instance) { __instance.m_minLevel = 1; } } [HarmonyPatch(typeof(SpawnArea))] public static class SpawnAreaSpawnOnePatch { private static readonly List VanillaSpawnAreaControllers = new List { "EvilHeart_Forest", "Spawner_GreydwarfNest", "Spawner_DraugrPile", "BonePileSpawner", "Spawner_CharredCross", "Spawner_CharredStone_Elite", "Spawner_Kvastur", "Spawner_CharredStone", "Spawner_CharredStone_event", "EvilHeart_Swamp" }; [HarmonyTranspiler] [HarmonyPatch("SpawnOne")] private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(GameObject), "GetComponent", (Type[])null, new Type[1] { typeof(Character) }), (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null) }).Advance(2).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[4] { new CodeInstruction(OpCodes.Ldloc_S, (object)5), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldloc_2, (object)null), Transpilers.EmitDelegate>((Action)SpawnAreaSetCharacterLevelControl) }) .CreateLabelOffset(out var label, 28) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Br, (object)label) }) .ThrowIfNotMatch("Unable to patch SpawnArea.SpawnOne.", Array.Empty()); return val.Instructions(); } private static void SpawnAreaSetCharacterLevelControl(Character chara, SpawnArea spawnArea, SpawnData spawndata) { if (ValConfig.ControlSpawnerLevels.Value) { if (ValConfig.OnlyControlVanillaAreaSpawners.Value) { VanillaSpawnAreaControllers.Contains(Utils.GetPrefabName(((Component)spawnArea).gameObject)); CreatureSetupControl.CreatureSpawnerSetup(chara); } else { CreatureSetupControl.CreatureSpawnerSetup(chara); } } else { int num = new DataObjects.LevelGenerator { LevelUpChance = spawnArea.GetLevelUpChance(), MaxLevel = spawndata.m_maxLevel, MinLevel = spawndata.m_minLevel, PrefabName = ((Object)spawndata.m_prefab).name }.RollAndDetermineLevel(); Logger.LogDebug($"SpawnArea.SpawnOne using provided {chara.m_name} level {num}"); CreatureSetupControl.CreatureSpawnerSetup(chara, num); } } [HarmonyPatch("SelectWeightedPrefab")] [HarmonyPostfix] public static void Prefix(ref SpawnData __result) { if (__result != null) { __result.m_minLevel = 1; } } } [HarmonyPatch(typeof(SpawnSystem))] public static class SpawnSystemSpawnPatch { [HarmonyTranspiler] [HarmonyPatch("Spawn")] private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchStartForward((CodeMatch[])(object)new CodeMatch[5] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(SpawnData), "m_prefab"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_2, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null) }).Advance(5).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldloc_0, (object)null), Transpilers.EmitDelegate>((Action)SpawnSystemSetCharacterWithoutZoneLimits) }) .MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Character), "SetLevel", (Type[])null, (Type[])null), (string)null) }) .RemoveInstructions(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Action)SpawnSystemSetCharacterLevelControl) }) .MatchStartBackwards((CodeMatch[])(object)new CodeMatch[2] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldloc_S, (object)null)), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null) }) .Advance(1) .RemoveInstructions(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_I4, (object)0) }) .MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(ItemDrop), "SetQuality", (Type[])null, (Type[])null), (string)null) }) .RemoveInstructions(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Action)SetItemLevelFish) }) .ThrowIfNotMatch("Unable to patch SpawnSystem Spawn set level.", Array.Empty()); return val.Instructions(); } private static void SpawnSystemSetCharacterWithoutZoneLimits(GameObject go) { Character component = go.GetComponent(); if (!((Object)(object)component == (Object)null)) { LevelSelection.SetCharacterLevelControl(component, 1); } } private static void SetItemLevelFish(ItemDrop item, int _providedLevel) { LevelSelection.SelectCreatureBiomeSettings(((Component)item).gameObject, out var creature_name, out var creature_settings, out var biome_settings, out var _); int quality = LevelSelection.DetermineLevel(((Component)item).gameObject, creature_name, creature_settings, biome_settings, ValConfig.FishMaxLevel.Value); item.m_itemData.m_shared.m_maxQuality = ValConfig.FishMaxLevel.Value + 1; item.SetQuality(quality); item.m_itemData.m_shared.m_scaleByQuality = ValConfig.FishSizeScalePerLevel.Value; item.Save(); } private static void SpawnSystemSetCharacterLevelControl(Character chara, int providedLevel) { LevelSelection.SetCharacterLevelControl(chara, providedLevel); } [HarmonyPatch("Spawn")] [HarmonyPrefix] public static void Prefix(ref SpawnData critter) { critter.m_minLevel = 1; } } [HarmonyPatch(typeof(TriggerSpawner))] public static class TriggerSpawnerSpawnPatch { [HarmonyTranspiler] [HarmonyPatch("Spawn")] private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Character), "SetLevel", (Type[])null, (Type[])null), (string)null) }).RemoveInstructions(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Action)TriggerSpawnerSetCharacterLevelControl) }) .MatchStartBackwards((CodeMatch[])(object)new CodeMatch[2] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldloc_S, (object)null)), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null) }) .Advance(1) .RemoveInstructions(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_I4, (object)0) }) .MatchStartBackwards((CodeMatch[])(object)new CodeMatch[3] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldarg_0, (object)null)), CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(TriggerSpawner), "m_maxLevel"))), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null) }) .Advance(2) .RemoveInstructions(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_I4, (object)0) }) .ThrowIfNotMatch("Unable to patch TriggerSpawner.Spawn.", Array.Empty()); return val.Instructions(); } private static void TriggerSpawnerSetCharacterLevelControl(Character chara, int providedLevel) { LevelSelection.SetCharacterLevelControl(chara, providedLevel); } [HarmonyPatch("Awake")] [HarmonyPostfix] public static void Postfix(TriggerSpawner __instance) { __instance.m_minLevel = 1; } } [HarmonyPatch(typeof(SpawnAbility))] public static class SpawnAbilitySpawnPatch { [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable TranspileMoveNext(IEnumerable instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Character), "SetLevel", (Type[])null, (Type[])null), (string)null) }).RemoveInstructions(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Action)SetSpawnAbilityLevelControl) }) .ThrowIfNotMatch("Unable to patch TriggerSpawner Spawn set level.", Array.Empty()); return val.Instructions(); } public static void SetSpawnAbilityLevelControl(Character chara, int providedLevel) { if (ValConfig.ControlAbilitySpawnedCreatures.Value) { CreatureSetupControl.CreatureSpawnerSetup(chara); } else { chara.SetLevel(providedLevel); } } } [HarmonyPatch(typeof(EggHatch))] public static class EggHatchSpawnPatch { [HarmonyPatch("Hatch")] private static bool Prefix(EggHatch __instance) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) __instance.m_hatchEffect.Create(((Component)__instance).transform.position, ((Component)__instance).transform.rotation, (Transform)null, 1f, -1); Character component = Object.Instantiate(__instance.m_spawnPrefab, ((Component)__instance).transform.TransformPoint(__instance.m_spawnOffset), Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f)).GetComponent(); if ((Object)(object)component != (Object)null) { CreatureSetupControl.CreatureSetup(component); } __instance.m_nview.Destroy(); return false; } } [HarmonyPatch(typeof(ItemDrop))] public static class DropOnDestroyedSpawnPatch { [HarmonyPostfix] [HarmonyPatch("OnCreateNew", new Type[] { typeof(GameObject) })] private static void Postfix(GameObject go) { Character component = go.GetComponent(); if ((Object)(object)component != (Object)null) { CreatureSetupControl.CreatureSetup(component); } } } } internal static class LevelSelection { [CompilerGenerated] private sealed class d__12 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public TreeBase tree; public int level; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; case 1: { <>1__state = -1; if ((Object)(object)tree == (Object)null) { return false; } float num = 1f + ValConfig.TreeSizeScalePerLevel.Value * (float)level; TreeBase obj = tree; obj.m_health += tree.m_health * 0.1f * (float)level; Transform transform = ((Component)tree).transform; transform.localScale *= num; List list = new List(); foreach (DropData drop in tree.m_dropWhenDestroyed.m_drops) { DropData item = default(DropData); item.m_stackMin = Mathf.RoundToInt((float)drop.m_stackMin * (1f + ValConfig.PerLevelTreeLootScale.Value * (float)level)); item.m_stackMax = Mathf.RoundToInt((float)drop.m_stackMax * (1f + ValConfig.PerLevelTreeLootScale.Value * (float)level)); item.m_item = drop.m_item; list.Add(item); } Physics.SyncTransforms(); 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 List ForceLeveledCreatures = new List(); public static int DetermineLevel(Character character, ZDO cZDO, DataObjects.CreatureSpecificSetting creature_settings, DataObjects.BiomeSpecificSetting biome_settings, int leveloverride = 0) { //IL_00e1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || cZDO == null) { Logger.LogWarning("Creature null or nview null, cannot set level."); return 1; } if (leveloverride > 0) { Logger.LogDebug($"Level override provided, setting level to {leveloverride}"); return leveloverride; } int @int = cZDO.GetInt(ZDOVars.s_level, 0); if (@int <= 0 || (ValConfig.OverlevedCreaturesGetRerolledOnLoad.Value && @int > ValConfig.MaxLevel.Value)) { int num = ValConfig.MaxLevel.Value; int num2 = 0; if (biome_settings != null && biome_settings.BiomeMaxLevelOverride != 0) { num = biome_settings.BiomeMaxLevelOverride; } if (creature_settings != null && creature_settings.CreatureMaxLevelOverride > -1) { num = creature_settings.CreatureMaxLevelOverride; } if (biome_settings != null && biome_settings.BiomeMinLevelOverride > 0) { num2 = biome_settings.BiomeMinLevelOverride; } if (creature_settings != null && creature_settings.CreatureMinLevelOverride > -1) { num2 = creature_settings.CreatureMinLevelOverride; } num2++; num++; float roll = Random.Range(0f, 100f); float distance_influence = 1f; SortedDictionary levelup_bonus = DetermineDistanceBonus(((Component)character).transform.position); SortedDictionary creature_levelup_chance = DetermineLevelupChance(creature_settings, biome_settings); if (biome_settings != null) { distance_influence = biome_settings.DistanceScaleModifier; } if (creature_settings != null && creature_settings.DistanceScaleModifier != 1f) { distance_influence = creature_settings.DistanceScaleModifier; } float nightBonus = 1f; if (biome_settings != null && biome_settings.NightSettings != null && biome_settings.NightSettings.NightLevelUpChanceScaler != 1f) { nightBonus = biome_settings.NightSettings.NightLevelUpChanceScaler; } if (creature_settings != null && creature_settings.NightSettings != null && creature_settings.NightSettings.NightLevelUpChanceScaler != 1f) { nightBonus = creature_settings.NightSettings.NightLevelUpChanceScaler; } int num3 = DetermineLevelRollResult(roll, num, creature_levelup_chance, levelup_bonus, distance_influence, nightBonus); if (num2 > 0 && num3 < num2) { num3 = num2; } return num3; } return @int; } public static int DetermineLevel(GameObject creature, string creature_name, DataObjects.CreatureSpecificSetting creature_settings, DataObjects.BiomeSpecificSetting biome_settings, int maxLevel) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)creature == (Object)null) { Logger.LogWarning("Creature is null, cannot determine level, set 1."); return 1; } float roll = Random.Range(0f, 100f); maxLevel++; Vector3 position = creature.transform.position; float distance_from_center = Vector2.Distance(new Vector2(position.x, position.y), new Vector2(DistanceScaleSystem.center.x, DistanceScaleSystem.center.z)); SortedDictionary levelup_bonus = new SortedDictionary(); SortedDictionary sortedDictionary = LevelSystemData.SLE_Level_Settings.DefaultCreatureLevelUpChance; if (sortedDictionary == null) { sortedDictionary = LevelSystemData.DefaultConfiguration.DefaultCreatureLevelUpChance; } if (ValConfig.EnableDistanceLevelScalingBonus.Value && LevelSystemData.SLE_Level_Settings.DistanceLevelBonus != null) { levelup_bonus = DistanceScaleSystem.SelectDistanceFromCenterLevelBonus(distance_from_center); } float distance_influence = 1f; if (biome_settings != null) { distance_influence = biome_settings.DistanceScaleModifier; } if (creature_settings != null && creature_settings.DistanceScaleModifier != 1f) { distance_influence = creature_settings.DistanceScaleModifier; } if (LevelSystemData.SLE_Level_Settings.CreatureConfiguration != null && LevelSystemData.SLE_Level_Settings.CreatureConfiguration.ContainsKey(creature_name) && creature_settings.CustomCreatureLevelUpChance != null) { if (creature_settings.CreatureMaxLevelOverride > -1) { maxLevel = creature_settings.CreatureMaxLevelOverride; } if (creature_settings.CustomCreatureLevelUpChance != null) { sortedDictionary = creature_settings.CustomCreatureLevelUpChance; } return DetermineLevelRollResult(roll, maxLevel, sortedDictionary, levelup_bonus, distance_influence); } if (biome_settings != null) { if (biome_settings.BiomeMaxLevelOverride > 0) { maxLevel = biome_settings.BiomeMaxLevelOverride; } if (biome_settings.CustomCreatureLevelUpChance != null) { sortedDictionary = biome_settings.CustomCreatureLevelUpChance; } return DetermineLevelRollResult(roll, maxLevel, sortedDictionary, levelup_bonus, distance_influence); } return DetermineLevelRollResult(roll, maxLevel, sortedDictionary, levelup_bonus, distance_influence); } public static SortedDictionary DetermineLevelupChance(DataObjects.CreatureSpecificSetting creature_settings = null, DataObjects.BiomeSpecificSetting biome_settings = null, SortedDictionary customLevelup = null) { SortedDictionary result = LevelSystemData.DefaultConfiguration.DefaultCreatureLevelUpChance; if (customLevelup != null) { result = customLevelup; } if (biome_settings != null && biome_settings.CustomCreatureLevelUpChance != null) { result = biome_settings.CustomCreatureLevelUpChance; } if (creature_settings != null && creature_settings.CustomCreatureLevelUpChance != null) { result = creature_settings.CustomCreatureLevelUpChance; } return result; } public static SortedDictionary DetermineDistanceBonus(Vector3 pos) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) SortedDictionary result = new SortedDictionary(); if (!ValConfig.EnableDistanceLevelScalingBonus.Value) { return result; } float distance_from_center = Vector2.Distance(new Vector2(pos.x, pos.z), new Vector2(DistanceScaleSystem.center.x, DistanceScaleSystem.center.z)); if (LevelSystemData.SLE_Level_Settings.DistanceLevelBonus != null) { result = DistanceScaleSystem.SelectDistanceFromCenterLevelBonus(distance_from_center); } return result; } public static void SetAndUpdateCharacterLevel(Character character, int level) { if (!((Object)(object)character == (Object)null)) { character.m_level = level; character.SetupMaxHealth(); if ((Object)(object)character.m_nview != (Object)null && character.m_nview.GetZDO() != null) { character.m_nview.GetZDO().Set(ZDOVars.s_level, level, false); } } } public static int DetermineLevelRollResult(float roll, int maxLevel, SortedDictionary creature_levelup_chance, SortedDictionary levelup_bonus, float distance_influence, float nightBonus = 1f) { int num = 0; SortedDictionary sortedDictionary = new SortedDictionary(); Extensions.AddRange((IDictionary)sortedDictionary, (IDictionary)creature_levelup_chance); if (levelup_bonus != null) { foreach (KeyValuePair levelup_bonu in levelup_bonus) { if (sortedDictionary.ContainsKey(levelup_bonu.Key)) { sortedDictionary[levelup_bonu.Key] += levelup_bonu.Value * distance_influence; } else { sortedDictionary[levelup_bonu.Key] = levelup_bonu.Value * distance_influence; } } } int num2 = 0; foreach (KeyValuePair item in sortedDictionary) { float num3 = item.Value * nightBonus; num2++; if (!(roll >= num3) && item.Key < maxLevel && num2 != sortedDictionary.Count()) { continue; } num = item.Key; if (ValConfig.EnableDebugOutputLevelRolls.Value) { if (num2 == sortedDictionary.Count()) { num++; } float num4 = 0f; if (levelup_bonus != null && levelup_bonus.ContainsKey(item.Key)) { num4 = levelup_bonus[item.Key]; } float num5 = 0f; if (creature_levelup_chance.ContainsKey(item.Key)) { num5 = creature_levelup_chance[item.Key]; } Logger.LogDebug($"Level Roll: {roll} >= {num3} = [ {num5}(base) + {num4}(distanceBonus) * {distance_influence}(DistanceInfluence)] * {nightBonus}(Night) | max-level used: {maxLevel} Selected Level: {num}"); } break; } return num; } public static int DeterministicDetermineTreeLevel(GameObject go) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_003f: Unknown result type (might be due to invalid IL or missing references) if (!ValConfig.EnableTreeScaling.Value) { return 1; } Vector3 position = go.transform.position; int num = Mathf.RoundToInt(Vector2.Distance(new Vector2(position.x, position.y), new Vector2(DistanceScaleSystem.center.x, DistanceScaleSystem.center.z)) / (10000f / (float)ValConfig.TreeMaxLevel.Value)); if (num < 1) { num = 1; } return num; } public static int DeterministicDetermineRockLevel(Vector3 pos) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!ValConfig.EnableRockLevels.Value) { return 1; } int num = Mathf.RoundToInt(Vector2.Distance(new Vector2(pos.x, pos.y), new Vector2(DistanceScaleSystem.center.x, DistanceScaleSystem.center.z)) / (10000f / (float)ValConfig.RockMaxLevel.Value)); if (num < 1) { num = 1; } return num; } public static int DetermineisticDetermineObjectLevel(Vector3 pos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0025: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.RoundToInt(Vector2.Distance(new Vector2(pos.x, pos.y), new Vector2(DistanceScaleSystem.center.x, DistanceScaleSystem.center.z)) / (10000f / (float)ValConfig.DestructibleMaxLevel.Value)); if (num < 1) { num = 1; } return num; } internal static void SetCharacterLevelControl(Character chara, int fallbackLevel) { if (!((Object)(object)chara == (Object)null)) { if (ValConfig.ControlSpawnerLevels.Value) { CreatureSetupControl.CreatureSpawnerSetup(chara, 0, multiply: true, 1f); return; } Logger.LogDebug($"Setting creature level from fallback provided {fallbackLevel}"); chara.SetLevel(fallbackLevel); } } public static void SelectCreatureBiomeSettings(GameObject creature, out string creature_name, out DataObjects.CreatureSpecificSetting creature_settings, out DataObjects.BiomeSpecificSetting biome_settings, out Biome creature_biome) { //IL_0006: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected I4, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) Vector3 position = creature.transform.position; creature_name = Utils.GetPrefabName(creature.gameObject); Biome val = Heightmap.FindBiome(position); creature_biome = (Biome)(int)val; biome_settings = null; creature_settings = null; if (LevelSystemData.SLE_Level_Settings == null) { return; } if (LevelSystemData.SLE_Level_Settings.BiomeConfiguration != null) { DataObjects.BiomeSpecificSetting value; bool flag = LevelSystemData.SLE_Level_Settings.BiomeConfiguration.TryGetValue((Biome)895, out value); if (flag) { biome_settings = value; } DataObjects.BiomeSpecificSetting value2; bool flag2 = LevelSystemData.SLE_Level_Settings.BiomeConfiguration.TryGetValue(val, out value2); if (flag2 && flag) { biome_settings = SLSExtensions.MutatingMergeBiomeConfigs(value2, value); } else if (flag2) { biome_settings = value2; } } if (LevelSystemData.SLE_Level_Settings.CreatureConfiguration != null && LevelSystemData.SLE_Level_Settings.CreatureConfiguration.TryGetValue(creature_name, out var value3)) { creature_settings = value3; } } [IteratorStateMachine(typeof(d__12))] public static IEnumerator ModifyTreeWithLevel(TreeBase tree, int level) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__12(0) { tree = tree, level = level }; } internal static void LeveledCreatureListChanged(object s, EventArgs e) { SetupForceLeveledCreatureList(); } internal static void SetupForceLeveledCreatureList() { ForceLeveledCreatures.Clear(); string[] array = ValConfig.SpawnsAlwaysControlled.Value.Split(new char[1] { ',' }); foreach (string item in array) { ForceLeveledCreatures.Add(item); } } } internal static class UpdateLevelsOnChange { [CompilerGenerated] private sealed class d__2 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private int 5__2; private IEnumerator <>7__wrap2; private GameObject 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap2 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown try { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -3; Physics.SyncTransforms(); goto IL_00c5; } <>1__state = -1; 5__2 = 0; IEnumerable enumerable = from obj in Resources.FindObjectsOfTypeAll() where (Object)(object)obj.GetComponent() != (Object)null || Object.op_Implicit((Object)(object)obj.GetComponent()) select obj; <>7__wrap2 = enumerable.GetEnumerator(); <>1__state = -3; goto IL_016e; IL_016e: if (<>7__wrap2.MoveNext()) { 5__4 = <>7__wrap2.Current; 5__2++; if (5__2 % ValConfig.NumberOfCacheUpdatesPerFrame.Value == 0) { <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 1; return true; } goto IL_00c5; } <>m__Finally1(); <>7__wrap2 = null; return false; IL_00c5: if (!((Object)(object)5__4 == (Object)null)) { Character component = 5__4.GetComponent(); if ((Object)(object)component == (Object)null) { component = (Character)(object)5__4.GetComponent(); } if (!((Object)(object)component == (Object)null) && !((Object)(object)component.m_nview == (Object)null) && component.m_nview.GetZDO() != null && component.GetLevel() > ValConfig.MaxLevel.Value) { DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(component, 0, null, null, updateCache: true); SizeModifications.SetSizeModification(((Component)component).gameObject, component.m_nview, andSetLocalCache, update: true); CreatureSetupControl.CreatureSetup(component, andSetLocalCache.Level); 5__4 = null; } } goto IL_016e; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap2 != null) { <>7__wrap2.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__7 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private int 5__2; private Dictionary 5__3; private IEnumerator <>7__wrap3; private GameObject 5__5; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__3 = null; <>7__wrap3 = null; 5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) try { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -3; Physics.SyncTransforms(); goto IL_00d0; } <>1__state = -1; 5__2 = 0; 5__3 = new Dictionary(); IEnumerable enumerable = from obj in Resources.FindObjectsOfTypeAll() where (Object)(object)obj.GetComponent() != (Object)null select obj; <>7__wrap3 = enumerable.GetEnumerator(); <>1__state = -3; goto IL_01d1; IL_01d1: if (<>7__wrap3.MoveNext()) { 5__5 = <>7__wrap3.Current; 5__2++; if (5__2 % ValConfig.NumberOfCacheUpdatesPerFrame.Value == 0) { <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 1; return true; } goto IL_00d0; } <>m__Finally1(); <>7__wrap3 = null; return false; IL_00d0: RandomFlyingBird component = 5__5.GetComponent(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.m_nview == (Object)null) && component.m_nview.GetZDO() != null) { string prefabName = Utils.GetPrefabName(5__5.gameObject); if (!5__3.ContainsKey(prefabName)) { 5__3.Add(prefabName, PrefabManager.Instance.GetPrefab(prefabName).gameObject.transform.localScale); } if (!ValConfig.EnableScalingBirds.Value) { ((Component)component).transform.localScale = 5__3[prefabName]; } else { int @int = component.m_nview.GetZDO().GetInt(DataObjects.SLS_BIRD, 0); if (@int > 1) { float num2 = 1f + ValConfig.BirdSizeScalePerLevel.Value * (float)@int; ((Component)component).transform.localScale = 5__3[prefabName] * num2; } 5__5 = null; } } goto IL_01d1; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap3 != null) { <>7__wrap3.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__8 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private int 5__2; private Dictionary 5__3; private IEnumerator <>7__wrap3; private GameObject 5__5; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__3 = null; <>7__wrap3 = null; 5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) try { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -3; Physics.SyncTransforms(); goto IL_00d0; } <>1__state = -1; 5__2 = 0; 5__3 = new Dictionary(); IEnumerable enumerable = from obj in Resources.FindObjectsOfTypeAll() where (Object)(object)obj.GetComponent() != (Object)null select obj; <>7__wrap3 = enumerable.GetEnumerator(); <>1__state = -3; goto IL_0256; IL_0256: if (<>7__wrap3.MoveNext()) { 5__5 = <>7__wrap3.Current; 5__2++; if (5__2 % ValConfig.NumberOfCacheUpdatesPerFrame.Value == 0) { <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 1; return true; } goto IL_00d0; } <>m__Finally1(); <>7__wrap3 = null; return false; IL_00d0: Fish component = 5__5.GetComponent(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.m_nview == (Object)null) && component.m_nview.GetZDO() != null) { string prefabName = Utils.GetPrefabName(5__5.gameObject); if (!5__3.ContainsKey(prefabName)) { 5__3.Add(prefabName, PrefabManager.Instance.GetPrefab(prefabName).gameObject.transform.localScale); } if (!ValConfig.EnableScalingFish.Value) { ((Component)component).transform.localScale = 5__3[prefabName]; } else { int @int = component.m_nview.GetZDO().GetInt(DataObjects.SLS_FISH, 0); if (@int > 1) { float num2 = 1f + ValConfig.FishSizeScalePerLevel.Value * (float)@int; ((Component)component).transform.localScale = 5__3[prefabName] * num2; } else { ItemDrop component2 = 5__5.GetComponent(); if (component2.m_itemData.m_quality > 1) { float num3 = 1f + ValConfig.FishSizeScalePerLevel.Value * (float)component2.m_itemData.m_quality; ((Component)component).transform.localScale = 5__3[prefabName] * num3; component2.m_itemData.m_shared.m_scaleByQuality = ValConfig.FishSizeScalePerLevel.Value; component2.Save(); } 5__5 = null; } } } goto IL_0256; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap3 != null) { <>7__wrap3.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__6 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private int 5__2; private IEnumerator <>7__wrap2; private GameObject 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap2 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) try { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -3; Physics.SyncTransforms(); goto IL_00c5; } <>1__state = -1; 5__2 = 0; IEnumerable enumerable = from obj in Resources.FindObjectsOfTypeAll() where (Object)(object)obj.GetComponent() != (Object)null select obj; <>7__wrap2 = enumerable.GetEnumerator(); <>1__state = -3; goto IL_023b; IL_023b: if (<>7__wrap2.MoveNext()) { 5__4 = <>7__wrap2.Current; 5__2++; if (5__2 % ValConfig.NumberOfCacheUpdatesPerFrame.Value == 0) { <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 1; return true; } goto IL_00c5; } <>m__Finally1(); <>7__wrap2 = null; return false; IL_00c5: TreeBase component = 5__4.GetComponent(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.m_nview == (Object)null) && component.m_nview.GetZDO() != null) { string prefabName = Utils.GetPrefabName(5__4.gameObject); Vector3 val = component.m_nview.GetZDO().GetVec3(ZDOVars.s_scaleHash, Vector3.zero); if (val == Vector3.zero) { float @float = component.m_nview.GetZDO().GetFloat(ZDOVars.s_scaleScalarHash, 0f); ((Vector3)(ref val))..ctor(@float, @float, @float); } if (val == Vector3.zero) { val = PrefabManager.Instance.GetPrefab(prefabName).gameObject.transform.localScale; } if (!ValConfig.EnableTreeScaling.Value) { ((Component)component).transform.localScale = val; } else { if (ValConfig.UseDeterministicTreeScaling.Value) { float num2 = 1f + ValConfig.TreeSizeScalePerLevel.Value * (float)CompositeLazyCache.GetOrAddCachedTreeEntry(component.m_nview); ((Component)component).transform.localScale = val * num2; } else { int @int = component.m_nview.GetZDO().GetInt(DataObjects.SLS_TREE, 0); if (@int > 1) { float num3 = 1f + ValConfig.TreeSizeScalePerLevel.Value * (float)@int; ((Component)component).transform.localScale = val * num3; } } 5__4 = null; } } goto IL_023b; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap2 != null) { <>7__wrap2.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static void ModifyLoadedCreatureLevels(object s, EventArgs e) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Player.m_localPlayer == (Object)null) && ZNetScene.instance.IsAreaReady(((Component)Player.m_localPlayer).gameObject.transform.position)) { ((MonoBehaviour)TaskRunner.Run()).StartCoroutine(ModifyLoadedCreaturesLevels()); } } public static void UpdateFishmaxLevel() { if (!ValConfig.EnableScalingFish.Value) { return; } foreach (GameObject item in from obj in Resources.FindObjectsOfTypeAll() where ((Object)obj).name.StartsWith("Fish") select obj) { if ((Object)(object)item.GetComponent() != (Object)null) { item.GetComponent().m_itemData.m_shared.m_maxQuality = ValConfig.FishMaxLevel.Value + 1; } } } [IteratorStateMachine(typeof(d__2))] public static IEnumerator ModifyLoadedCreaturesLevels() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0); } public static void UpdateTreeSizeOnConfigChange(object s, EventArgs e) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Player.m_localPlayer == (Object)null) && ZNetScene.instance.IsAreaReady(((Component)Player.m_localPlayer).gameObject.transform.position)) { ((MonoBehaviour)TaskRunner.Run()).StartCoroutine(UpdateAllTreeSizesOnConfigChangeCoroutine()); } } public static void UpdateBirdSizeOnConfigChange(object s, EventArgs e) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Player.m_localPlayer == (Object)null) && ZNetScene.instance.IsAreaReady(((Component)Player.m_localPlayer).gameObject.transform.position)) { ((MonoBehaviour)TaskRunner.Run()).StartCoroutine(UpdateAllBirdSizesOnConfigChangeCoroutine()); } } public static void UpdateFishSizeOnConfigChange(object s, EventArgs e) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Player.m_localPlayer == (Object)null) && ZNetScene.instance.IsAreaReady(((Component)Player.m_localPlayer).gameObject.transform.position)) { ((MonoBehaviour)TaskRunner.Run()).StartCoroutine(UpdateAllFishOnConfigChangeCoroutine()); } } [IteratorStateMachine(typeof(d__6))] public static IEnumerator UpdateAllTreeSizesOnConfigChangeCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(0); } [IteratorStateMachine(typeof(d__7))] public static IEnumerator UpdateAllBirdSizesOnConfigChangeCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__7(0); } [IteratorStateMachine(typeof(d__8))] public static IEnumerator UpdateAllFishOnConfigChangeCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__8(0); } } } namespace StarLevelSystem.modules.Health { internal static class HealthModifications { internal static bool ForceUpdateHealth; internal static void ForceApplyHealthModifications(Character chara, DataObjects.CharacterCacheEntry cDetails) { ForceUpdateHealth = true; ApplyHealthModifications(chara, cDetails); ForceUpdateHealth = false; } internal static void ApplyHealthModifications(Character chara, DataObjects.CharacterCacheEntry cDetails) { float num = chara.m_health; if (!chara.IsPlayer() && Game.m_worldLevel > 0) { num *= (float)Game.m_worldLevel * Game.instance.m_worldLevelEnemyHPMultiplier; } float maxHealth = chara.GetMaxHealth(); float maxHealthBase = chara.GetMaxHealthBase(); float num2 = num; if (cDetails.CreatureBaseValueModifiers[DataObjects.CreatureBaseAttribute.BaseHealth] != 1f || cDetails.CreaturePerLevelValueModifiers[DataObjects.CreaturePerLevelAttribute.HealthPerLevel] > 0f) { float num3 = num * cDetails.CreatureBaseValueModifiers[DataObjects.CreatureBaseAttribute.BaseHealth]; float num4 = num * cDetails.CreaturePerLevelValueModifiers[DataObjects.CreaturePerLevelAttribute.HealthPerLevel] * (float)(chara.GetLevel() - 1); num2 = num3 + num4; } else { num = ((!chara.IsBoss()) ? (num * ValConfig.EnemyHealthMultiplier.Value) : (num * ValConfig.BossEnemyHealthMultiplier.Value)); num2 = num; } if (!ForceUpdateHealth && maxHealth == num2) { return; } float num5 = maxHealthBase * (float)chara.GetLevel(); if (ForceUpdateHealth || ValConfig.OverrideCreatureModifiedHealth.Value || maxHealth == maxHealthBase) { if (ValConfig.EnableDebugMode.Value) { Logger.LogDebug($"Creature {Localization.instance.Localize(cDetails.CreatureNameLocalizable)} HP does not match target: current:{maxHealth} (base {maxHealthBase}) != {num2} | vanilla {num5} | Set to {num2}"); } chara.SetMaxHealth(num2); } } } internal static class HealthPatches { [HarmonyPatch(typeof(Character), "Awake")] public static class CharacterHealthFix { private static void Postfix(Character __instance) { if (float.IsNaN(__instance.GetHealth())) { Logger.LogWarning("NaN health detected on " + ((Object)__instance).name + ", resetting to max health."); __instance.SetHealth(__instance.GetMaxHealth()); } } } [HarmonyPatch(typeof(Character), "SetHealth")] public static class CharacterSetHealthPreventNaN { private static bool Prefix(Character __instance, float health) { if (float.IsNaN(health)) { Logger.LogWarning("Preventing NaN health on " + ((Object)__instance).name); return false; } return true; } } } } namespace StarLevelSystem.modules.Damage { internal static class DamageModifications { public static void ForceUpdateDamageMod(Character creature, float increase_dmg_by) { float @float = creature.m_nview.GetZDO().GetFloat(DataObjects.SLS_DAMAGE_MODIFIER, 0f); creature.m_nview.GetZDO().Set(DataObjects.SLS_DAMAGE_MODIFIER, @float + increase_dmg_by); } internal static void ApplyDamageModification(Character creature, DataObjects.CharacterCacheEntry cDetails, bool updateCache = false) { if ((Object)(object)creature.m_nview == (Object)null || cDetails == null) { return; } float num = cDetails.CreatureBaseValueModifiers[DataObjects.CreatureBaseAttribute.BaseDamage]; if (num != 1f) { DataObjects.DictionaryDmgNetProperty dictionaryDmgNetProperty = new DataObjects.DictionaryDmgNetProperty(DataObjects.SLS_DAMAGE_BONUSES, creature.m_nview, new Dictionary()); if ((dictionaryDmgNetProperty.Get().Count == 0 && cDetails.CreatureDamageBonus.Count > 0) || updateCache) { dictionaryDmgNetProperty.Set(cDetails.CreatureDamageBonus); } creature.m_nview.GetZDO().Set(DataObjects.SLS_DAMAGE_MODIFIER, num); Logger.LogDebug(string.Format("Built damage buffs for {0} +{1} *{2}", ((Object)creature).name, string.Join(",", cDetails.CreatureDamageBonus), num)); } } internal static void ApplyDamageModifiers(HitData hit, Character chara, Dictionary damageMods) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Applying damage recieved mods for " + chara.m_name); if (hit.m_damage.m_blunt > 0f && damageMods.ContainsKey(DataObjects.DamageType.Blunt)) { stringBuilder.Append($" {DataObjects.DamageType.Blunt}: {hit.m_damage.m_blunt} * {damageMods[DataObjects.DamageType.Blunt]}"); hit.m_damage.m_blunt *= damageMods[DataObjects.DamageType.Blunt]; stringBuilder.Append($" = {hit.m_damage.m_blunt}\n"); } if (hit.m_damage.m_pierce > 0f && damageMods.ContainsKey(DataObjects.DamageType.Pierce)) { stringBuilder.Append($" {DataObjects.DamageType.Pierce}: {hit.m_damage.m_pierce} * {damageMods[DataObjects.DamageType.Pierce]}"); hit.m_damage.m_pierce *= damageMods[DataObjects.DamageType.Pierce]; stringBuilder.Append($" = {hit.m_damage.m_pierce}\n"); } if (hit.m_damage.m_slash > 0f && damageMods.ContainsKey(DataObjects.DamageType.Slash)) { stringBuilder.Append($" {DataObjects.DamageType.Slash}: {hit.m_damage.m_slash} * {damageMods[DataObjects.DamageType.Slash]}"); hit.m_damage.m_slash *= damageMods[DataObjects.DamageType.Slash]; stringBuilder.Append($" = {hit.m_damage.m_slash}\n"); } if (hit.m_damage.m_fire > 0f && damageMods.ContainsKey(DataObjects.DamageType.Fire)) { stringBuilder.Append($" {DataObjects.DamageType.Fire}: {hit.m_damage.m_fire} * {damageMods[DataObjects.DamageType.Fire]}"); hit.m_damage.m_fire *= damageMods[DataObjects.DamageType.Fire]; stringBuilder.Append($" = {hit.m_damage.m_fire}\n"); } if (hit.m_damage.m_frost > 0f && damageMods.ContainsKey(DataObjects.DamageType.Frost)) { stringBuilder.Append($" {DataObjects.DamageType.Fire}: {hit.m_damage.m_frost} * {damageMods[DataObjects.DamageType.Frost]}"); hit.m_damage.m_frost *= damageMods[DataObjects.DamageType.Frost]; stringBuilder.Append($" = {hit.m_damage.m_frost}\n"); } if (hit.m_damage.m_lightning > 0f && damageMods.ContainsKey(DataObjects.DamageType.Lightning)) { stringBuilder.Append($" {DataObjects.DamageType.Lightning}: {hit.m_damage.m_lightning} * {damageMods[DataObjects.DamageType.Lightning]}"); hit.m_damage.m_lightning *= damageMods[DataObjects.DamageType.Lightning]; stringBuilder.Append($" = {hit.m_damage.m_lightning}\n"); } if (hit.m_damage.m_poison > 0f && damageMods.ContainsKey(DataObjects.DamageType.Poison)) { stringBuilder.Append($" {DataObjects.DamageType.Poison}: {hit.m_damage.m_poison} * {damageMods[DataObjects.DamageType.Poison]}"); hit.m_damage.m_poison *= damageMods[DataObjects.DamageType.Poison]; stringBuilder.Append($" = {hit.m_damage.m_poison}\n"); } if (hit.m_damage.m_spirit > 0f && damageMods.ContainsKey(DataObjects.DamageType.Spirit)) { stringBuilder.Append($" {DataObjects.DamageType.Spirit}: {hit.m_damage.m_spirit} * {damageMods[DataObjects.DamageType.Spirit]}"); hit.m_damage.m_spirit *= damageMods[DataObjects.DamageType.Spirit]; stringBuilder.Append($" = {hit.m_damage.m_spirit}\n"); } if (hit.m_damage.m_chop > 0f && damageMods.ContainsKey(DataObjects.DamageType.Chop)) { stringBuilder.Append($" {DataObjects.DamageType.Spirit}: {hit.m_damage.m_chop} * {damageMods[DataObjects.DamageType.Chop]}"); hit.m_damage.m_chop *= damageMods[DataObjects.DamageType.Chop]; stringBuilder.Append($" = {hit.m_damage.m_chop}\n"); } if (hit.m_damage.m_pickaxe > 0f && damageMods.ContainsKey(DataObjects.DamageType.Pickaxe)) { stringBuilder.Append($" {DataObjects.DamageType.Pickaxe}: {hit.m_damage.m_pickaxe} * {damageMods[DataObjects.DamageType.Pickaxe]}"); hit.m_damage.m_pickaxe *= damageMods[DataObjects.DamageType.Pickaxe]; stringBuilder.Append($" = {hit.m_damage.m_pickaxe}\n"); } if (ValConfig.EnableDebugOutputForDamage.Value) { Logger.LogInfo(stringBuilder.ToString()); } } internal static float GetTotalDamageOptions(this HitData hit, bool include_poison = false, bool include_spirit = false, bool include_pickaxe_and_chop = false) { float num = hit.m_damage.m_damage + hit.m_damage.m_blunt + hit.m_damage.m_slash + hit.m_damage.m_pierce + hit.m_damage.m_fire + hit.m_damage.m_frost + hit.m_damage.m_lightning; if (include_poison) { num += hit.m_damage.m_poison; } if (include_spirit) { num += hit.m_damage.m_spirit; } if (include_pickaxe_and_chop) { num += hit.m_damage.m_pickaxe + hit.m_damage.m_chop; } return num; } internal static void AddDamagesToHit(HitData hit, Dictionary damageBonuses) { float totalDamageOptions = hit.GetTotalDamageOptions(); foreach (KeyValuePair damageBonuse in damageBonuses) { switch (damageBonuse.Key) { case DataObjects.DamageType.Blunt: hit.m_damage.m_blunt += totalDamageOptions * damageBonuse.Value; break; case DataObjects.DamageType.Slash: hit.m_damage.m_slash += totalDamageOptions * damageBonuse.Value; break; case DataObjects.DamageType.Pierce: hit.m_damage.m_pierce += totalDamageOptions * damageBonuse.Value; break; case DataObjects.DamageType.Fire: hit.m_damage.m_fire += totalDamageOptions * damageBonuse.Value; break; case DataObjects.DamageType.Frost: hit.m_damage.m_frost += totalDamageOptions * damageBonuse.Value; break; case DataObjects.DamageType.Lightning: hit.m_damage.m_lightning += totalDamageOptions * damageBonuse.Value; break; case DataObjects.DamageType.Poison: hit.m_damage.m_poison += totalDamageOptions * damageBonuse.Value; break; case DataObjects.DamageType.Spirit: hit.m_damage.m_spirit += totalDamageOptions * damageBonuse.Value; break; case DataObjects.DamageType.Chop: hit.m_damage.m_chop += totalDamageOptions * damageBonuse.Value; break; case DataObjects.DamageType.Pickaxe: hit.m_damage.m_pickaxe += totalDamageOptions * damageBonuse.Value; break; } } } internal static Dictionary DetermineCreatureDamageRecievedModifiers(DataObjects.BiomeSpecificSetting biome_settings, DataObjects.CreatureSpecificSetting creature_settings) { Dictionary dictionary = new Dictionary { { DataObjects.DamageType.Blunt, 1f }, { DataObjects.DamageType.Pierce, 1f }, { DataObjects.DamageType.Slash, 1f }, { DataObjects.DamageType.Fire, 1f }, { DataObjects.DamageType.Frost, 1f }, { DataObjects.DamageType.Lightning, 1f }, { DataObjects.DamageType.Poison, 1f }, { DataObjects.DamageType.Spirit, 1f } }; if (biome_settings != null && biome_settings.DamageRecievedModifiers != null) { foreach (KeyValuePair damageRecievedModifier in biome_settings.DamageRecievedModifiers) { dictionary[damageRecievedModifier.Key] = damageRecievedModifier.Value; } } if (creature_settings != null && creature_settings.DamageRecievedModifiers != null) { foreach (KeyValuePair damageRecievedModifier2 in creature_settings.DamageRecievedModifiers) { dictionary[damageRecievedModifier2.Key] = damageRecievedModifier2.Value; } } return dictionary; } internal static Dictionary DetermineCharacterPerLevelStats(DataObjects.BiomeSpecificSetting biome_settings, DataObjects.CreatureSpecificSetting creature_settings) { Dictionary dictionary = new Dictionary { { DataObjects.CreaturePerLevelAttribute.DamagePerLevel, 0f }, { DataObjects.CreaturePerLevelAttribute.HealthPerLevel, ValConfig.EnemyHealthMultiplier.Value }, { DataObjects.CreaturePerLevelAttribute.SizePerLevel, ValConfig.PerLevelScaleBonus.Value }, { DataObjects.CreaturePerLevelAttribute.SpeedPerLevel, 0f }, { DataObjects.CreaturePerLevelAttribute.AttackSpeedPerLevel, 0f } }; if (biome_settings != null && biome_settings.CreaturePerLevelValueModifiers != null) { foreach (KeyValuePair creaturePerLevelValueModifier in biome_settings.CreaturePerLevelValueModifiers) { dictionary[creaturePerLevelValueModifier.Key] = creaturePerLevelValueModifier.Value; } } if (creature_settings != null && creature_settings.CreaturePerLevelValueModifiers != null) { foreach (KeyValuePair creaturePerLevelValueModifier2 in creature_settings.CreaturePerLevelValueModifiers) { dictionary[creaturePerLevelValueModifier2.Key] = creaturePerLevelValueModifier2.Value; } } return dictionary; } internal static Dictionary DetermineCreatureBaseStats(DataObjects.BiomeSpecificSetting biome_settings, DataObjects.CreatureSpecificSetting creature_settings) { Dictionary dictionary = new Dictionary { { DataObjects.CreatureBaseAttribute.BaseDamage, 1f }, { DataObjects.CreatureBaseAttribute.BaseHealth, 1f }, { DataObjects.CreatureBaseAttribute.Size, 1f }, { DataObjects.CreatureBaseAttribute.Speed, 1f }, { DataObjects.CreatureBaseAttribute.AttackSpeed, 1f } }; if (biome_settings != null && biome_settings.CreatureBaseValueModifiers != null) { foreach (KeyValuePair creatureBaseValueModifier in biome_settings.CreatureBaseValueModifiers) { dictionary[creatureBaseValueModifier.Key] = creatureBaseValueModifier.Value; } } if (creature_settings != null && creature_settings.CreatureBaseValueModifiers != null) { foreach (KeyValuePair creatureBaseValueModifier2 in creature_settings.CreatureBaseValueModifiers) { dictionary[creatureBaseValueModifier2.Key] = creatureBaseValueModifier2.Value; } } return dictionary; } } internal static class DamagePatches { [HarmonyPatch(typeof(Attack), "GetLevelDamageFactor")] public static class ModifyDamagePerLevel { public static bool Prefix(Attack __instance, ref float __result) { __result = DetermineDamageFactor((Character)(object)__instance.m_character); return false; } private static float DetermineDamageFactor(Character character) { if (character.IsPlayer()) { return 1f; } DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(character); int num = Mathf.Max(0, character.GetLevel() - 1); float num2 = 1f; num2 = (character.IsBoss() ? ((andSetLocalCache == null || andSetLocalCache.CreaturePerLevelValueModifiers[DataObjects.CreaturePerLevelAttribute.DamagePerLevel] == 0f) ? (num2 + (float)num * ValConfig.BossEnemyDamageMultiplier.Value) : (num2 + (float)num * andSetLocalCache.CreaturePerLevelValueModifiers[DataObjects.CreaturePerLevelAttribute.DamagePerLevel])) : ((andSetLocalCache == null || andSetLocalCache.CreaturePerLevelValueModifiers[DataObjects.CreaturePerLevelAttribute.DamagePerLevel] == 0f) ? (num2 + (float)num * ValConfig.EnemyDamageLevelMultiplier.Value) : (num2 + (float)num * andSetLocalCache.CreaturePerLevelValueModifiers[DataObjects.CreaturePerLevelAttribute.DamagePerLevel]))); float @float = character.m_nview.GetZDO().GetFloat(DataObjects.SLS_DAMAGE_MODIFIER, 1f); if (ValConfig.EnableDebugOutputForDamage.Value) { Logger.LogDebug($"Setting {((Object)character).name} lvl {num} dmg factor to {num2} * {@float} = {num2 * @float}"); } return num2 * @float; } } [HarmonyPatch(typeof(Character), "ApplyDamage")] public static class CharacterApplyDamage { private static void Prefix(HitData hit) { if (ValConfig.EnableDebugOutputForDamage.Value) { Logger.LogDebug($"Applying Damage: D:{hit.m_damage.m_damage} fi:{hit.m_damage.m_fire} fr:{hit.m_damage.m_frost} s:{hit.m_damage.m_spirit} po:{hit.m_damage.m_poison} b:{hit.m_damage.m_blunt} p:{hit.m_damage.m_pierce} s:{hit.m_damage.m_slash}"); } } } [HarmonyPatch(typeof(HitData), "ApplyResistance")] public static class ApplyResistance { private static void Postfix(HitData __instance, DamageModifiers modifiers) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (ValConfig.EnableDebugOutputForDamage.Value) { Logger.LogDebug($"Applying Damage Modifiers {modifiers}, result after modifiers: D:{__instance.m_damage.m_damage} fi:{__instance.m_damage.m_fire} fr:{__instance.m_damage.m_frost} s:{__instance.m_damage.m_spirit} po:{__instance.m_damage.m_poison} b:{__instance.m_damage.m_blunt} p:{__instance.m_damage.m_pierce} s:{__instance.m_damage.m_slash}"); } } } [HarmonyPatch(typeof(Character), "Damage")] public static class CharacterDamageModificationApply { private static void Prefix(HitData hit, Character __instance) { DataObjects.CharacterCacheEntry cacheEntry = CompositeLazyCache.GetCacheEntry(hit.GetAttacker()); DataObjects.CharacterCacheEntry cacheEntry2 = CompositeLazyCache.GetCacheEntry(__instance); if (cacheEntry != null && cacheEntry.CreatureDamageBonus != null && cacheEntry.CreatureDamageBonus.Count > 0) { if (ValConfig.EnableDebugOutputForDamage.Value) { Logger.LogDebug($"{((Object)__instance).name} Hit:{hit.GetTotalDamageOptions()} Adding {cacheEntry.GetDamageBonusDescription()}"); } DamageModifications.AddDamagesToHit(hit, cacheEntry.CreatureDamageBonus); } if (cacheEntry2 != null) { DamageModifications.ApplyDamageModifiers(hit, __instance, cacheEntry2.DamageRecievedModifiers); } } } } } namespace StarLevelSystem.modules.CreatureSetup { internal static class CreatureSetupControl { [CompilerGenerated] private sealed class d__0 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public float delay; public Character __instance; public int level_override; public Dictionary requiredModifiers; public bool spawnMultiply; private int 5__2; private bool 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; if (!((Object)(object)__instance.m_nview == (Object)null) && __instance.m_nview.IsValid()) { if (!__instance.m_nview.m_zdo.Owned) { __instance.m_nview.ClaimOwnership(); } DataObjects.CharacterCacheEntry andSetLocalCache; if (__instance.m_nview.IsOwner() || delay == 0f) { if ((Object)(object)__instance.m_nview == (Object)null || !__instance.m_nview.IsValid()) { goto IL_01b3; } andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(__instance, level_override, requiredModifiers); CompositeLazyCache.StartZOwnerCreatureRoutines(__instance, andSetLocalCache, spawnMultiply); } andSetLocalCache = CompositeLazyCache.GetCacheEntry(__instance); 5__3 = CharacterSetup(__instance, andSetLocalCache); 5__2++; if (5__2 >= ValConfig.FallbackDelayBeforeCreatureSetup.Value - 1) { DataObjects.CharacterCacheEntry andSetLocalCache2 = CompositeLazyCache.GetAndSetLocalCache(__instance, level_override, requiredModifiers); CompositeLazyCache.StartZOwnerCreatureRoutines(__instance, andSetLocalCache2, spawnMultiply); CharacterSetup(__instance, andSetLocalCache2); Logger.LogDebug(andSetLocalCache2.RefCreatureName + " running delayed setup."); } if (5__2 >= ValConfig.FallbackDelayBeforeCreatureSetup.Value) { goto IL_01be; } } } else { <>1__state = -1; 5__2 = 0; 5__3 = false; } goto IL_01b3; IL_01b3: if (!5__3) { <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; } goto IL_01be; IL_01be: 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(); } } [IteratorStateMachine(typeof(d__0))] public static IEnumerator DelayedSetupValidateZnet(Character __instance, int level_override = 0, float delay = 1f, bool spawnMultiply = true, Dictionary requiredModifiers = null, List notAllowedModifiers = null) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0) { __instance = __instance, level_override = level_override, delay = delay, spawnMultiply = spawnMultiply, requiredModifiers = requiredModifiers }; } private static bool CharacterSetup(Character __instance, DataObjects.CharacterCacheEntry cDetails) { if ((Object)(object)__instance == (Object)null || cDetails == null || cDetails.Level == 0) { return false; } if (ValConfig.ForceControlAllSpawns.Value) { CompositeLazyCache.StartZOwnerCreatureRoutines(__instance, cDetails); cDetails = CompositeLazyCache.GetCacheEntry(__instance); } cDetails.CreatureNameLocalizable = CreatureModifiers.BuildCreatureLocalizableName(__instance, cDetails.CreatureModifiers); CreatureModifiers.RunOnceModifierSetup(__instance, cDetails); CreatureModifiers.SetupModifiers(__instance, cDetails, CompositeLazyCache.GetCreatureModifiers(__instance)); SpeedModifications.ApplySpeedModifications(__instance, cDetails); DamageModifications.ApplyDamageModification(__instance, cDetails); SizeModifications.SetSizeModification(((Component)__instance).gameObject, __instance.m_nview, cDetails); HealthModifications.ApplyHealthModifications(__instance, cDetails); UIHudControl.InvalidateCacheEntry(__instance); if (__instance.m_level <= 1) { return true; } Colorization.ApplyColorizationWithoutLevelEffects(((Component)__instance).gameObject, cDetails.Colorization); Colorization.ApplyLevelVisual(__instance); return true; } internal static void CreatureSpawnerSetup(Character chara, int leveloverride = 0, bool multiply = true, float delay = 0.1f, Dictionary requiredModifiers = null, List notAllowedModifiers = null) { DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(chara, leveloverride, requiredModifiers, notAllowedModifiers); CompositeLazyCache.StartZOwnerCreatureRoutines(chara, andSetLocalCache, multiply); CreatureSetup(chara, 0, multiply: true, delay); } internal static void CreatureSetupNoDelay(Character __instance) { if (!((Object)(object)__instance == (Object)null)) { DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(__instance); CompositeLazyCache.StartZOwnerCreatureRoutines(__instance, andSetLocalCache); andSetLocalCache = CompositeLazyCache.GetCacheEntry(__instance); CharacterSetup(__instance, andSetLocalCache); } } internal static void CreatureSetup(Character __instance, int leveloverride = 0, bool multiply = true, float delay = 1f, Dictionary requiredModifiers = null, List notAllowedModifiers = null) { if (!__instance.IsPlayer()) { if (delay == 0f) { delay = 0.1f; } ((MonoBehaviour)TaskRunner.Run()).StartCoroutine(DelayedSetupValidateZnet(__instance, leveloverride, delay, multiply, requiredModifiers)); } } } internal static class CreatureSetupPatches { [HarmonyPatch(typeof(Character), "Awake")] public static class CreatureCharacterExtension { public static void Postfix(Character __instance) { CreatureSetupControl.CreatureSetup(__instance, 0, multiply: true, ValConfig.InitialDelayBeforeSetup.Value); } } [HarmonyPatch(typeof(Character), "SetLevel")] public static class ModifyCharacterVisualsToLevel { public static void Prefix(Character __instance, ref int level) { if (level <= 1) { level = 1; } } } } } namespace StarLevelSystem.modules.AnimationAndSpeed { internal static class AnimationSpeedPatches { [HarmonyPatch(typeof(CharacterAnimEvent), "CustomFixedUpdate")] public static class ModifyCharacterAnimationSpeed { public static void Postfix(CharacterAnimEvent __instance) { if ((Object)(object)__instance.m_character != (Object)null && __instance.m_character.InAttack()) { DataObjects.CharacterCacheEntry cacheEntry = CompositeLazyCache.GetCacheEntry(__instance.m_character); if ((cacheEntry != null && cacheEntry.CreatureBaseValueModifiers[DataObjects.CreatureBaseAttribute.AttackSpeed] != 1f) || (cacheEntry != null && cacheEntry.CreaturePerLevelValueModifiers[DataObjects.CreaturePerLevelAttribute.SpeedPerLevel] != 0f)) { __instance.m_animator.speed = cacheEntry.CreatureBaseValueModifiers[DataObjects.CreatureBaseAttribute.AttackSpeed] + cacheEntry.CreaturePerLevelValueModifiers[DataObjects.CreaturePerLevelAttribute.SpeedPerLevel] * (float)__instance.m_character.m_level; } } } } } internal static class SpeedModifications { internal static void ApplySpeedModifications(Character creature, DataObjects.CharacterCacheEntry cDetails) { float num = cDetails.CreaturePerLevelValueModifiers[DataObjects.CreaturePerLevelAttribute.SpeedPerLevel]; float num2 = cDetails.CreatureBaseValueModifiers[DataObjects.CreatureBaseAttribute.Speed]; float num3 = num * (float)(creature.m_level - 1); float num4 = num2 + num3; string text = cDetails.RefCreatureName; if (text == null) { text = Utils.GetPrefabName(((Component)creature).gameObject); } GameObject prefab = PrefabManager.Instance.GetPrefab(text); if ((Object)(object)prefab == (Object)null) { Logger.LogWarning("Unable to find reference object for " + ((Object)creature).name + ", not applying speed modifications"); return; } Character component = prefab.GetComponent(); if ((Object)(object)component == (Object)null) { Logger.LogWarning("Unable to find reference character for " + ((Object)creature).name + ", not applying speed modifications"); return; } creature.m_speed = component.m_speed * num4; creature.m_walkSpeed = component.m_walkSpeed * num4; creature.m_runSpeed = component.m_runSpeed * num4; creature.m_turnSpeed = component.m_turnSpeed * num4; creature.m_flyFastSpeed = component.m_flyFastSpeed * num4; creature.m_flySlowSpeed = component.m_flySlowSpeed * num4; creature.m_flyTurnSpeed = component.m_flyTurnSpeed * num4; creature.m_swimSpeed = component.m_swimSpeed * num4; creature.m_crouchSpeed = component.m_crouchSpeed * num4; } } } namespace StarLevelSystem.Modifiers { internal static class Alert { [UsedImplicitly] public static void Setup(Character creature, DataObjects.CreatureModConfig config, DataObjects.CharacterCacheEntry ccache) { BaseAI baseAI = creature.m_baseAI; baseAI.m_hearRange *= config.BasePower + config.PerlevelPower * (float)creature.m_level; } } internal class Big { [UsedImplicitly] public static void RunOnce(Character creature, DataObjects.CreatureModConfig config, DataObjects.CharacterCacheEntry ccache) { if (ccache != null) { ccache.CreatureBaseValueModifiers[DataObjects.CreatureBaseAttribute.Size] += config.BasePower + config.PerlevelPower * (float)creature.m_level; ccache.CreatureBaseValueModifiers[DataObjects.CreatureBaseAttribute.BaseHealth] += config.BasePower + config.PerlevelPower * (float)creature.m_level; } } } internal static class Brutal { [UsedImplicitly] public static void RunOnce(Character creature, DataObjects.CreatureModConfig config, DataObjects.CharacterCacheEntry ccache) { if (ccache != null) { ccache.CreatureBaseValueModifiers[DataObjects.CreatureBaseAttribute.AttackSpeed] += config.BasePower; ccache.CreaturePerLevelValueModifiers[DataObjects.CreaturePerLevelAttribute.AttackSpeedPerLevel] += config.PerlevelPower * (float)creature.m_level; } } } internal static class DeathNova { [HarmonyPatch(typeof(Character), "OnDeath")] public static class DeathNovaOnDeathPatch { private static void Prefix(Character __instance) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || __instance.IsPlayer() || !__instance.m_nview.IsOwner()) { return; } Dictionary creatureModifiers = CompositeLazyCache.GetCreatureModifiers(__instance); if (creatureModifiers == null) { return; } if (creatureModifiers.Keys.Contains(CreatureModifiersData.ModifierNames.FireNova.ToString())) { DataObjects.CreatureModifierConfiguration modifierDef = CreatureModifiersData.GetModifierDef(CreatureModifiersData.ModifierNames.FireNova.ToString(), creatureModifiers[CreatureModifiersData.ModifierNames.FireNova.ToString()]); if (modifierDef == null) { return; } GameObject val = CreatureModifiers.ApplySecondaryVFX(CreatureModifiersData.ModifierDefinitions[CreatureModifiersData.ModifierNames.FireNova.ToString()].SecondaryEffect, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation); if ((Object)(object)val == (Object)null) { return; } val.SetActive(false); Aoe component = val.GetComponent(); float num = modifierDef.Config.BasePower + modifierDef.Config.PerlevelPower * (float)__instance.m_level; if (Object.op_Implicit((Object)(object)component)) { float num2 = SLSExtensions.EstimateCharacterDamage(__instance, DataObjects.DamageEstimateType.Average); if (num2 <= 0f) { num2 = 10 * __instance.m_level; } component.m_damage.m_blunt = Mathf.Clamp(num2 * num * 0.25f, 0f, 5000f); component.m_damage.m_fire = Mathf.Clamp(num2 * num * 0.5f, 0f, 5000f); Logger.LogDebug($"Activating FireNova m:{num} x c:{num2} = {num2 * num} | blunt: {component.m_damage.m_blunt} fire: {component.m_damage.m_fire}"); } val.SetActive(true); } if (!creatureModifiers.Keys.Contains(CreatureModifiersData.ModifierNames.PoisonNova.ToString())) { return; } DataObjects.CreatureModifierConfiguration modifierDef2 = CreatureModifiersData.GetModifierDef(CreatureModifiersData.ModifierNames.PoisonNova.ToString(), creatureModifiers[CreatureModifiersData.ModifierNames.PoisonNova.ToString()]); if (modifierDef2 == null) { return; } GameObject val2 = CreatureModifiers.ApplySecondaryVFX(CreatureModifiersData.ModifierDefinitions[CreatureModifiersData.ModifierNames.PoisonNova.ToString()].SecondaryEffect, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation); if ((Object)(object)val2 == (Object)null) { return; } val2.SetActive(false); Aoe component2 = val2.GetComponent(); float num3 = modifierDef2.Config.BasePower + modifierDef2.Config.PerlevelPower * (float)__instance.m_level; if (Object.op_Implicit((Object)(object)component2)) { float num4 = SLSExtensions.EstimateCharacterDamage(__instance, DataObjects.DamageEstimateType.Average); if (num4 <= 0f) { num4 = 10 * __instance.m_level; } component2.m_damage.m_blunt = Mathf.Clamp(num4 * num3 * 0.16f, 0f, 5000f); component2.m_damage.m_poison = Mathf.Clamp(num4 * num3, 0f, 5000f); Logger.LogDebug($"Activating Poison Nova m:{num3} x c:{num4} = {num4 * num3}"); } val2.SetActive(true); } } } internal static class Drainers { [HarmonyPatch(typeof(Character), "Damage")] public static class ModifierDrain { private static void Postfix(HitData hit, Character __instance) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) if (hit == null) { return; } _ = hit.m_attacker; if ((Object)(object)__instance == (Object)null) { return; } Character attacker = hit.GetAttacker(); if ((Object)(object)attacker == (Object)null || attacker.IsPlayer()) { return; } Dictionary creatureModifiers = CompositeLazyCache.GetCreatureModifiers(attacker); if (creatureModifiers != null) { if (creatureModifiers.Keys.Contains(CreatureModifiersData.ModifierNames.StaminaDrain.ToString())) { DataObjects.CreatureModConfig config = CreatureModifiersData.GetConfig(CreatureModifiersData.ModifierNames.StaminaDrain.ToString(), creatureModifiers[CreatureModifiersData.ModifierNames.StaminaDrain.ToString()]); __instance.UseStamina(config.BasePower + config.PerlevelPower * (float)attacker.m_level); } if (creatureModifiers.Keys.Contains(CreatureModifiersData.ModifierNames.EitrDrain.ToString())) { DataObjects.CreatureModConfig config2 = CreatureModifiersData.GetConfig(CreatureModifiersData.ModifierNames.EitrDrain.ToString(), creatureModifiers[CreatureModifiersData.ModifierNames.EitrDrain.ToString()]); __instance.UseEitr(config2.BasePower + config2.PerlevelPower * (float)attacker.m_level); } } } } } internal static class ElementalChaos { [HarmonyPriority(700)] [HarmonyPatch(typeof(Character), "Damage")] public static class ElementalChaosRandomDamageSelectionBonus { private static readonly List ElementalDamages = new List { DataObjects.DamageType.Fire, DataObjects.DamageType.Frost, DataObjects.DamageType.Lightning, DataObjects.DamageType.Spirit, DataObjects.DamageType.Poison }; private static void Prefix(HitData hit, Character __instance) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) if (hit == null) { return; } _ = hit.m_attacker; if ((Object)(object)__instance == (Object)null) { return; } Character attacker = hit.GetAttacker(); if (!((Object)(object)attacker == (Object)null) && !attacker.IsPlayer()) { Dictionary creatureModifiers = CompositeLazyCache.GetCreatureModifiers(attacker); if (creatureModifiers != null && creatureModifiers.Keys.Contains(CreatureModifiersData.ModifierNames.ElementalChaos.ToString())) { DataObjects.CreatureModConfig config = CreatureModifiersData.GetConfig(CreatureModifiersData.ModifierNames.ElementalChaos.ToString(), creatureModifiers[CreatureModifiersData.ModifierNames.ElementalChaos.ToString()]); float num = Mathf.Clamp(config.BasePower + config.PerlevelPower * (float)attacker.m_level, 0f, 500f); DataObjects.DamageType damageType = RandomSelectDamageType(); Logger.LogDebug($"Elemental Chaos adding {damageType} modifier {num}"); DamageModifications.AddDamagesToHit(hit, new Dictionary { { damageType, num } }); } } } private static DataObjects.DamageType RandomSelectDamageType() { int index = Random.Range(0, 4); return ElementalDamages[index]; } } } internal static class Evolve { [HarmonyPatch(typeof(Character), "OnDeath")] public static class SoulEaterAndEvolveOnDeath { private static void Prefix(Character __instance) { if ((Object)(object)__instance == (Object)null || __instance.IsPlayer() || __instance.m_lastHit == null) { return; } Character attacker = __instance.m_lastHit.GetAttacker(); Dictionary creatureModifiers = CompositeLazyCache.GetCreatureModifiers(attacker); if (creatureModifiers != null && creatureModifiers.Keys.Contains(CreatureModifiersData.ModifierNames.Evolving.ToString())) { DataObjects.CreatureModConfig config = CreatureModifiersData.GetConfig(CreatureModifiersData.ModifierNames.Evolving.ToString(), creatureModifiers[CreatureModifiersData.ModifierNames.Evolving.ToString()]); int @int = attacker.m_nview.GetZDO().GetInt(DataObjects.SLS_EVOLVE, 0); @int++; int level = attacker.m_level; int num = Mathf.RoundToInt(config.BasePower + config.PerlevelPower * (float)level); Logger.LogDebug($"Evolve check: {@int} >= {num}"); if (@int >= num) { attacker.m_nview.GetZDO().Set(ZDOVars.s_level, level + 1, false); @int = 1; DataObjects.CharacterCacheEntry andSetLocalCache = CompositeLazyCache.GetAndSetLocalCache(attacker, 0, null, null, updateCache: true); SpeedModifications.ApplySpeedModifications(attacker, andSetLocalCache); DamageModifications.ApplyDamageModification(attacker, andSetLocalCache); SizeModifications.SetSizeModification(((Component)attacker).gameObject, attacker.m_nview, andSetLocalCache, update: true); HealthModifications.ForceApplyHealthModifications(attacker, andSetLocalCache); attacker.Heal(attacker.GetMaxHealth() * 5f, true); Logger.LogDebug($"Evolve: {attacker} level: {level} -> {level + 1}"); } attacker.m_nview.GetZDO().Set(DataObjects.SLS_EVOLVE, @int); } } } } internal class Fast { [UsedImplicitly] public static void RunOnce(Character creature, DataObjects.CreatureModConfig config, DataObjects.CharacterCacheEntry ccache) { if (ccache != null) { ccache.CreatureBaseValueModifiers[DataObjects.CreatureBaseAttribute.Speed] += config.BasePower + config.PerlevelPower * (float)creature.m_level; } } } internal static class Flame { [UsedImplicitly] public static void RunOnce(Character creature, DataObjects.CreatureModConfig config, DataObjects.CharacterCacheEntry ccache) { if (ccache != null) { if (ccache.CreatureDamageBonus.ContainsKey(DataObjects.DamageType.Fire)) { ccache.CreatureDamageBonus[DataObjects.DamageType.Fire] += config.BasePower + config.PerlevelPower * (float)creature.m_level; } else { ccache.CreatureDamageBonus[DataObjects.DamageType.Fire] = config.BasePower + config.PerlevelPower * (float)creature.m_level; } } } } internal static class Frost { [UsedImplicitly] public static void RunOnce(Character creature, DataObjects.CreatureModConfig config, DataObjects.CharacterCacheEntry ccache) { if (ccache != null) { if (ccache.CreatureDamageBonus.ContainsKey(DataObjects.DamageType.Frost)) { ccache.CreatureDamageBonus[DataObjects.DamageType.Frost] += config.BasePower + config.PerlevelPower * (float)creature.m_level; } else { ccache.CreatureDamageBonus[DataObjects.DamageType.Frost] = config.BasePower + config.PerlevelPower * (float)creature.m_level; } } } } public static class LifeLink { [HarmonyPatch(typeof(Character), "RPC_Damage")] public static class LifeLinkDamageDistributionPatch { private static float NextAllowedRedirection; public static void Prefix(Character __instance, HitData hit) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) Dictionary creatureModifiers = CompositeLazyCache.GetCreatureModifiers(__instance); if (creatureModifiers == null || !creatureModifiers.ContainsKey(CreatureModifiersData.ModifierNames.LifeLink.ToString())) { return; } DataObjects.CreatureModifierConfiguration modifierDef = CreatureModifiersData.GetModifierDef(CreatureModifiersData.ModifierNames.LifeLink.ToString(), creatureModifiers[CreatureModifiersData.ModifierNames.LifeLink.ToString()]); float num = 1f - (modifierDef.Config.BasePower + modifierDef.Config.PerlevelPower * (float)__instance.m_level); num = Mathf.Clamp(num, 0.1f, 1f); HitData val = new HitData { m_attacker = hit.m_attacker, m_damage = hit.m_damage }; if (val.GetTotalDamageOptions() < 20f || Time.realtimeSinceStartup < NextAllowedRedirection) { return; } ((DamageTypes)(ref val.m_damage)).Modify(num); NextAllowedRedirection = Time.realtimeSinceStartup + 1f; List charactersInRange = SLSExtensions.GetCharactersInRange(((Component)__instance).transform.position, 15f); bool flag = false; foreach (Character item in charactersInRange) { if (!item.IsPlayer() && !((Object)(object)item == (Object)(object)__instance)) { Logger.LogDebug("Distributing Damage to " + item.m_name); item.Damage(val); flag = true; break; } } if (flag) { ((DamageTypes)(ref hit.m_damage)).Modify(num); } } } } internal static class Lightning { [UsedImplicitly] public static void RunOnce(Character creature, DataObjects.CreatureModConfig config, DataObjects.CharacterCacheEntry ccache) { if (ccache != null) { if (ccache.CreatureDamageBonus.ContainsKey(DataObjects.DamageType.Lightning)) { ccache.CreatureDamageBonus[DataObjects.DamageType.Lightning] += config.BasePower + config.PerlevelPower * (float)creature.m_level; } else { ccache.CreatureDamageBonus[DataObjects.DamageType.Lightning] = config.BasePower + config.PerlevelPower * (float)creature.m_level; } } } } internal static class Lootbags { [HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")] public static class CreatureLootMultiplied { public static void Postfix(CharacterDrop __instance, List> __result) { //IL_0109: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.m_character == (Object)null || __instance.m_character.IsPlayer()) { return; } Dictionary creatureModifiers = CompositeLazyCache.GetCreatureModifiers(__instance.m_character); if (creatureModifiers == null || !creatureModifiers.ContainsKey(CreatureModifiersData.ModifierNames.Lootbags.ToString())) { return; } DataObjects.CreatureModConfig config = CreatureModifiersData.GetConfig(CreatureModifiersData.ModifierNames.Lootbags.ToString(), creatureModifiers[CreatureModifiersData.ModifierNames.Lootbags.ToString()]); List> list = new List>(); float num = config.BasePower + config.PerlevelPower * (float)__instance.m_character.m_level; foreach (KeyValuePair item in __result) { list.Add(new KeyValuePair(item.Key, Mathf.RoundToInt((float)item.Value * Random.Range(0.5f, 1f) * num))); } LootPerformanceChanges.DropItemsPreferAsync(((Component)__instance).gameObject.transform.position, list, immediate: true); } } [UsedImplicitly] public static void RunOnce(Character creature, DataObjects.CreatureModConfig config, DataObjects.CharacterCacheEntry ccache) { if (ccache != null) { ccache.CreatureBaseValueModifiers[DataObjects.CreatureBaseAttribute.Speed] += 0.15f; ccache.CreatureBaseValueModifiers[DataObjects.CreatureBaseAttribute.BaseHealth] += 0.3f; } } } internal static class Poison { [UsedImplicitly] public static void RunOnce(Character creature, DataObjects.CreatureModConfig config, DataObjects.CharacterCacheEntry ccache) { if (ccache != null) { if (ccache.CreatureDamageBonus.ContainsKey(DataObjects.DamageType.Poison)) { ccache.CreatureDamageBonus[DataObjects.DamageType.Poison] += config.BasePower + config.PerlevelPower * (float)creature.m_level; } else { ccache.CreatureDamageBonus[DataObjects.DamageType.Poison] = config.BasePower + config.PerlevelPower * (float)creature.m_level; } } } } internal static class ResistBlunt { [UsedImplicitly] public static void RunOnce(Character creature, DataObjects.CreatureModConfig config, DataObjects.CharacterCacheEntry ccache) { if (ccache != null) { ccache.DamageRecievedModifiers[DataObjects.DamageType.Blunt] -= config.BasePower + config.PerlevelPower * (float)creature.m_level; if (ccache.DamageRecievedModifiers[DataObjects.DamageType.Blunt] < 0.2f) { ccache.DamageRecievedModifiers[DataObjects.DamageType.Blunt] = 0.2f; } } } } internal class ResistFire { [UsedImplicitly] public static void RunOnce(Character creature, DataObjects.CreatureModConfig config, DataObjects.CharacterCacheEntry ccache) { if (ccache != null) { ccache.DamageRecievedModifiers[DataObjects.DamageType.Fire] -= config.BasePower + config.PerlevelPower * (float)creature.m_level; if (ccache.DamageRecievedModifiers[DataObjects.DamageType.Fire] < 0.2f) { ccache.DamageRecievedModifiers[DataObjects.DamageType.Fire] = 0.2f; } } } } internal class ResistFrost { [UsedImplicitly] public static void RunOnce(Character creature, DataObjects.CreatureModConfig config, DataObjects.CharacterCacheEntry ccache) { if (ccache != null) { ccache.DamageRecievedModifiers[DataObjects.DamageType.Frost] -= config.BasePower + config.PerlevelPower * (float)creature.m_level; if (ccache.DamageRecievedModifiers[DataObjects.DamageType.Frost] < 0.2f) { ccache.DamageRecievedModifiers[DataObjects.DamageType.Frost] = 0.2f; } } } } internal static class ResistPierce { [UsedImplicitly] public static void RunOnce(Character creature, DataObjects.CreatureModConfig config, DataObjects.CharacterCacheEntry ccache) { if (ccache != null) { ccache.DamageRecievedModifiers[DataObjects.DamageType.Pierce] -= config.BasePower + config.PerlevelPower * (float)creature.m_level; if (ccache.DamageRecievedModifiers[DataObjects.DamageType.Pierce] < 0.2f) { ccache.DamageRecievedModifiers[DataObjects.DamageType.Pierce] = 0.2f; } } } } internal class ResistPoison { [UsedImplicitly] public static void RunOnce(Character creature, DataObjects.CreatureModConfig config, DataObjects.CharacterCacheEntry ccache) { if (ccache != null) { ccache.DamageRecievedModifiers[DataObjects.DamageType.Poison] -= config.BasePower + config.PerlevelPower * (float)creature.m_level; if (ccache.DamageRecievedModifiers[DataObjects.DamageType.Poison] < 0.2f) { ccache.DamageRecievedModifiers[DataObjects.DamageType.Poison] = 0.2f; } } } } internal static class ResistSlash { [UsedImplicitly] public static void RunOnce(Character creature, DataObjects.CreatureModConfig config, DataObjects.CharacterCacheEntry ccache) { if (ccache != null) { ccache.DamageRecievedModifiers[DataObjects.DamageType.Slash] -= config.BasePower + config.PerlevelPower * (float)creature.m_level; if (ccache.DamageRecievedModifiers[DataObjects.DamageType.Slash] < 0.2f) { ccache.DamageRecievedModifiers[DataObjects.DamageType.Slash] = 0.2f; } } } } internal class ResistSpirit { [UsedImplicitly] public static void RunOnce(Character creature, DataObjects.CreatureModConfig config, DataObjects.CharacterCacheEntry ccache) { if (ccache != null) { ccache.DamageRecievedModifiers[DataObjects.DamageType.Spirit] -= config.BasePower + config.PerlevelPower * (float)creature.m_level; if (ccache.DamageRecievedModifiers[DataObjects.DamageType.Spirit] < 0.2f) { ccache.DamageRecievedModifiers[DataObjects.DamageType.Spirit] = 0.2f; } } } } internal static class SoulEater { [HarmonyPatch(typeof(Character), "OnDeath")] public static class SoulEaterAndEvolveOnDeath { private static void Prefix(Character __instance) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || __instance.IsPlayer()) { return; } foreach (Character item in SLSExtensions.GetCharactersInRange(((Component)__instance).transform.position, 5f)) { if (!((Object)(object)item == (Object)null) && !item.IsPlayer()) { DataObjects.CharacterCacheEntry cacheEntry = CompositeLazyCache.GetCacheEntry(item); Dictionary creatureModifiers = CompositeLazyCache.GetCreatureModifiers(__instance); if (cacheEntry != null && creatureModifiers != null && creatureModifiers.Keys.Contains(CreatureModifiersData.ModifierNames.SoulEater.ToString())) { DataObjects.CreatureModConfig config = CreatureModifiersData.GetConfig(CreatureModifiersData.ModifierNames.SoulEater.ToString(), creatureModifiers[CreatureModifiersData.ModifierNames.SoulEater.ToString()]); float num = config.PerlevelPower * (float)item.m_level; Logger.LogDebug($"SoulEater Increased on {((Object)item).name} by {config.PerlevelPower} * {item.m_level} = {num}"); DamageModifications.ForceUpdateDamageMod(item, num); int @int = item.m_nview.GetZDO().GetInt(DataObjects.SLS_SOULEATER, 0); @int++; item.m_nview.GetZDO().Set(DataObjects.SLS_SOULEATER, @int); SizeModifications.SetSizeModification(((Component)item).gameObject, item.m_nview, cacheEntry, update: true, 0.01f * (float)@int); item.Heal(item.GetMaxHealth() * config.PerlevelPower, true); } } } } } } public static class Splitter { [HarmonyPatch(typeof(Character), "OnDeath")] public static class CharacterOnDeath { public static void Prefix(Character __instance) { //IL_0105: 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) if ((Object)(object)__instance == (Object)null || __instance.IsPlayer()) { return; } Dictionary creatureModifiers = CompositeLazyCache.GetCreatureModifiers(__instance); if (creatureModifiers == null || !creatureModifiers.ContainsKey(CreatureModifiersData.ModifierNames.Splitter.ToString())) { return; } DataObjects.CreatureModConfig config = CreatureModifiersData.GetConfig(CreatureModifiersData.ModifierNames.Splitter.ToString(), creatureModifiers[CreatureModifiersData.ModifierNames.Splitter.ToString()]); float num = config.BasePower + (float)__instance.m_level * config.PerlevelPower; bool flag = __instance.IsTamed(); int num2 = Mathf.RoundToInt((float)__instance.m_level / num); if (num2 <= 0) { num2 = 1; } if (!ValConfig.SplittersInheritLevel.Value) { num2 = Random.Range(1, num2); } Logger.LogDebug($"Splitter on {((Object)__instance).name} total split potential:{num} split creature level: {num2}"); while (num >= 1f) { GameObject prefab = PrefabManager.Instance.GetPrefab(Utils.GetPrefabName(((Component)__instance).gameObject)); if (!((Object)(object)prefab == (Object)null)) { GameObject val = Object.Instantiate(prefab, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation); num -= 1f; if (flag) { val.GetComponent().SetTamed(true); } Character component = val.GetComponent(); if ((Object)(object)component != (Object)null) { CompositeLazyCache.GetAndSetLocalCache(component, num2, null, new List { CreatureModifiersData.ModifierNames.Splitter.ToString() }, updateCache: true); CreatureSetupControl.CreatureSetup(component, num2, multiply: false, 0.1f); CreatureModifiers.RemoveCreatureModifier(component, CreatureModifiersData.ModifierNames.Splitter.ToString()); } continue; } break; } } } } internal class Summoner { public class SLSSummoner : MonoBehaviour { private List summonableCreatures = new List(); private ZNetView creature_znet; private static List spawned = new List(); private static int maxSummoned = 10; private static int summonBatchSize = 2; private static float timeBetweenSummons = 30f; private static Character bossCharacter; private static bool started = false; public void SpawnCreaturesBatch() { summonBatchSize.Times(delegate { SpawnCreatureRandomly(); }); } public void SpawnCreatureRandomly() { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) if (summonableCreatures.Count == 0) { return; } if (spawned.Count >= maxSummoned) { spawned.RemoveAll((ZDOID x) => ZDOMan.instance.GetZDO(x) == null); if (spawned.Count >= maxSummoned) { return; } } if (summonableCreatures.Count != 0 && !((Object)(object)bossCharacter == (Object)null)) { GameObject obj = summonableCreatures[Random.Range(0, summonableCreatures.Count)]; Vector3 val = ((Component)bossCharacter).transform.position + new Vector3((float)Random.Range(-10, 10), 0f, (float)Random.Range(-10, 10)); val.y = ZoneSystem.instance.GetGroundHeight(val) + 0.5f; Character component = Object.Instantiate(obj, val, Quaternion.identity).GetComponent(); if ((Object)(object)component != (Object)null) { spawned.Add(component.GetZDOID()); } } } public void SetupSummoner(Character character, List summonPrefabs, int max_summoned = 10, float time_between_summons = 60f) { bossCharacter = character; timeBetweenSummons = time_between_summons; maxSummoned = max_summoned; creature_znet = character.m_nview; foreach (string summonPrefab in summonPrefabs) { GameObject prefab = PrefabManager.Instance.GetPrefab(summonPrefab); if ((Object)(object)prefab != (Object)null) { summonableCreatures.Add(prefab); } } if ((Object)(object)creature_znet == (Object)null) { creature_znet = ((Component)this).gameObject.GetComponent(); } if (!started) { ((MonoBehaviour)this).InvokeRepeating("SpawnCreaturesBatch", timeBetweenSummons, timeBetweenSummons); started = true; } } } public static void Setup(Character creature = null, DataObjects.CreatureModConfig config = null, DataObjects.CharacterCacheEntry ccache = null) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (ccache == null) { return; } SLSSummoner component = ((Component)creature).GetComponent(); Logger.LogDebug($"Setting up Summoner for {((Object)creature).name} summon script {component}"); if ((Object)(object)component == (Object)null) { SLSSummoner sLSSummoner = ((Component)creature).gameObject.AddComponent(); if (config.BiomeObjects.ContainsKey(ccache.Biome)) { sLSSummoner.SetupSummoner(creature, config.BiomeObjects[ccache.Biome], Mathf.RoundToInt(config.BasePower), config.PerlevelPower); } } } } } namespace StarLevelSystem.Modifiers.Control { public static class CreatureModifiers { internal static readonly string NoMods = "None"; internal static GameObject VisualEffectHolder = new GameObject("SLS_Visuals"); private static readonly List prefixSelectors = new List { DataObjects.NameSelectionStyle.RandomFirst, DataObjects.NameSelectionStyle.RandomBoth }; private static readonly List suffixSelectors = new List { 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 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 selectedMods) { if (selectedMods == null) { return; } int num = 0; foreach (KeyValuePair 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 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 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || cmodifier == null || cmodifier.VisualEffect == null) { return; } GameObject val = CreatureModifiersData.LoadedModifierEffects[cmodifier.VisualEffect]; if ((Object)(object)val == (Object)null || Object.op_Implicit((Object)(object)((Component)character).transform.Find("SLS_Visuals(Clone)/" + ((Object)val).name + "(Clone)"))) { return; } Transform val2 = ((Component)character).transform.Find("SLS_Visuals(Clone)"); if ((Object)(object)val2 == (Object)null) { if ((Object)(object)VisualEffectHolder == (Object)null || (Object)(object)((Component)character).gameObject == (Object)null) { return; } val2 = Object.Instantiate(VisualEffectHolder, ((Component)character).transform).transform; } GameObject val3 = Object.Instantiate(val, val2); if (!((Object)(object)val3 == (Object)null)) { float height = character.GetHeight(); float num = height / 5f; float num2 = character.GetRadius() / 2f; switch (cmodifier.VisualEffectStyle) { case DataObjects.VisualEffectStyle.top: val3.transform.localPosition = new Vector3(0f, height, 0f); break; case DataObjects.VisualEffectStyle.bottom: val3.transform.localPosition = new Vector3(0f, 0f, 0f); break; case DataObjects.VisualEffectStyle.objectCenter: val3.transform.localPosition = new Vector3(0f, height / 2f, 0f); break; } val3.transform.localScale = new Vector3(val3.transform.localScale.x * num, val3.transform.localScale.y * num2, val3.transform.localScale.z * num); } } internal static GameObject ApplySecondaryVFX(string effectName, Vector3 position, Quaternion rotation) { //IL_0025: 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) if (CreatureModifiersData.LoadedSecondaryEffects.ContainsKey(effectName)) { GameObject val = CreatureModifiersData.LoadedSecondaryEffects[effectName]; if ((Object)(object)val == (Object)null) { return null; } return Object.Instantiate(val, position, rotation); } return null; } internal static string BuildCreatureLocalizableName(Character chara, Dictionary modifiers) { if (modifiers == null) { modifiers = new Dictionary(); } List list = new List(); List list2 = new List(); int num = 0; int num2 = 1; List list3 = modifiers.Keys.ToList(); if (ValConfig.MinorModifiersFirstInName.Value) { list3 = (from kvp in modifiers orderby kvp.Value select kvp.Key).Reverse().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) { num2++; 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 SelectModifiersForCreature(Character character, string creatureName, DataObjects.CreatureSpecificSetting creature_settings, Biome biome, int level, Dictionary requiredModifiers = null, List 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 result = new Dictionary(); if (!character.IsPlayer()) { if (character.IsBoss() && ValConfig.EnableBossModifiers.Value) { int maxBossMods = ValConfig.MaxBossModifiersPerBoss.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, requiredModifiers, notAllowedModifiers); } } return result; } public static Dictionary 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 requiredModifiers = null, List 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 dictionary = new Dictionary(); 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(); } List list = new List(); List list2 = new List(); List list3 = new List(); foreach (KeyValuePair 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 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 SelectCreatureModifiers(string creature, Biome biome, float chance, int num_mods, int level, int existingMods = 0, DataObjects.ModifierType type = DataObjects.ModifierType.Major, List requiredMods = null, List notAllowedModifiers = null) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = new List(); if (requiredMods != null) { list.AddRange(requiredMods); } List 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 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); } UIHudControl.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 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]); UIHudControl.InvalidateCacheEntry(character); if (!applyChanges) { SpeedModifications.ApplySpeedModifications(character, cacheEntry); DamageModifications.ApplyDamageModification(character, cacheEntry); SizeModifications.SetSizeModification(((Component)character).gameObject, character.m_nview, cacheEntry, update: true); HealthModifications.ForceApplyHealthModifications(character, cacheEntry); return true; } return true; } } internal class Visible_Toggle { [HarmonyPatch(typeof(Character), "SetVisible")] private static class Patch_Character_SetVisible { internal static readonly string SLSVISUALS = "SLS_Visuals(Clone)"; private static void Postfix(Character __instance, bool visible) { Transform val = ((Component)__instance).transform.Find(SLSVISUALS); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(visible); } } } } } namespace StarLevelSystem.Data { public static class ColorizationData { internal static readonly Dictionary> characterColorizationData = new Dictionary> { { "Deer", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.05f, saturation = -0.1f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = 0.09f, saturation = -0.5f, value = -0.05f } }, { 3, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = -0.07f } }, { 4, new DataObjects.ColorDef { hue = 0.09f, saturation = 0f, value = -0.09f } }, { 5, new DataObjects.ColorDef { hue = -0.11f, saturation = 0f, value = -0.11f } }, { 6, new DataObjects.ColorDef { hue = 0f, saturation = 0.5f, value = -0.15f } }, { 7, new DataObjects.ColorDef { hue = 0f, saturation = 0.5f, value = 0f } }, { 8, new DataObjects.ColorDef { hue = 0f, saturation = 0.5f, value = -0.08f } }, { 9, new DataObjects.ColorDef { hue = 0f, saturation = -0.3f, value = 0f } }, { 10, new DataObjects.ColorDef { hue = 0f, saturation = -0.5f, value = 0f } } } }, { "Boar", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = -0.05f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = -0.07f } }, { 3, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = -0.09f } }, { 4, new DataObjects.ColorDef { hue = 0.1f, saturation = 0f, value = -0.05f } }, { 5, new DataObjects.ColorDef { hue = 0.15f, saturation = 0f, value = -0.05f } }, { 6, new DataObjects.ColorDef { hue = 0.05f, saturation = 0f, value = 0.05f } }, { 7, new DataObjects.ColorDef { hue = -0.05f, saturation = 0.1f, value = 0.05f } }, { 8, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.1f, value = -0.05f } }, { 9, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.02f } }, { 10, new DataObjects.ColorDef { hue = 0f, saturation = -0.05f, value = -0.1f } } } }, { "Neck", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = -0.07f } }, { 2, new DataObjects.ColorDef { hue = 0.05f, saturation = 0f, value = -0.1f } }, { 3, new DataObjects.ColorDef { hue = -0.1f, saturation = 0f, value = -0.05f } }, { 4, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = -0.4f, saturation = 0f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.4f, saturation = 0f, value = -0.05f } }, { 7, new DataObjects.ColorDef { hue = 0.25f, saturation = 0f, value = -0.05f } }, { 8, new DataObjects.ColorDef { hue = 0.35f, saturation = 0f, value = -0.1f } }, { 9, new DataObjects.ColorDef { hue = 0.1f, saturation = 0f, value = -0.15f } }, { 10, new DataObjects.ColorDef { hue = 0.1f, saturation = 0f, value = -0.2f } } } }, { "Greyling", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.06f, saturation = 0.1f, value = 0.05f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = 0.2f, value = -0.01f } }, { 3, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.2f, value = -0.01f } }, { 4, new DataObjects.ColorDef { hue = -0.2f, saturation = 0.2f, value = -0.01f } }, { 5, new DataObjects.ColorDef { hue = -0.4f, saturation = 0f, value = -0.01f } }, { 6, new DataObjects.ColorDef { hue = -0.5f, saturation = 0f, value = -0.01f } }, { 7, new DataObjects.ColorDef { hue = -0.7f, saturation = 0f, value = -0.01f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0f, value = -0.01f } }, { 9, new DataObjects.ColorDef { hue = -1f, saturation = 0f, value = -0.01f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.2f, value = -0.07f } } } }, { "Eikthyr", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.1f, saturation = 0f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.5f, saturation = 0f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.1f, saturation = 0f, value = 0f } }, { 5, new DataObjects.ColorDef { hue = 0.1f, saturation = 0f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.8f, saturation = 0f, value = -0.01f } }, { 7, new DataObjects.ColorDef { hue = 0.5f, saturation = 0f, value = -0.05f } }, { 8, new DataObjects.ColorDef { hue = -0.75f, saturation = 0f, value = -0.15f } }, { 9, new DataObjects.ColorDef { hue = 0.15f, saturation = 0f, value = 0.05f } }, { 10, new DataObjects.ColorDef { hue = 0.2f, saturation = 0f, value = 0.5f } } } }, { "Greydwarf", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.06f, saturation = 0.1f, value = 0.05f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = 0.2f, value = -0.01f } }, { 3, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.2f, value = -0.01f } }, { 4, new DataObjects.ColorDef { hue = -0.2f, saturation = 0.2f, value = -0.01f } }, { 5, new DataObjects.ColorDef { hue = -0.4f, saturation = 0f, value = -0.01f } }, { 6, new DataObjects.ColorDef { hue = -0.5f, saturation = 0f, value = -0.01f } }, { 7, new DataObjects.ColorDef { hue = -0.7f, saturation = 0f, value = -0.01f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0f, value = -0.01f } }, { 9, new DataObjects.ColorDef { hue = -1f, saturation = 0f, value = -0.01f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.2f, value = -0.07f } } } }, { "Greydwarf_Shaman", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.1f, saturation = 0f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = 0.3f, saturation = 0f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = -0.01f } }, { 4, new DataObjects.ColorDef { hue = -0.4f, saturation = 0f, value = -0.01f } }, { 5, new DataObjects.ColorDef { hue = -0.5f, saturation = 0f, value = -0.01f } }, { 6, new DataObjects.ColorDef { hue = 0.3f, saturation = 0f, value = -0.01f } }, { 7, new DataObjects.ColorDef { hue = -0.8f, saturation = 0f, value = -0.01f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0f, value = -0.01f } }, { 9, new DataObjects.ColorDef { hue = -1f, saturation = 0f, value = -0.01f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.2f, value = -0.07f } } } }, { "Greydwarf_Elite", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.046f, saturation = 0f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.108f, saturation = 0f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = -0.01f } }, { 4, new DataObjects.ColorDef { hue = -0.4f, saturation = 0f, value = -0.01f } }, { 5, new DataObjects.ColorDef { hue = -0.5f, saturation = 0f, value = -0.01f } }, { 6, new DataObjects.ColorDef { hue = 0.3f, saturation = 0f, value = -0.01f } }, { 7, new DataObjects.ColorDef { hue = -0.8f, saturation = 0f, value = -0.01f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0f, value = -0.01f } }, { 9, new DataObjects.ColorDef { hue = -1f, saturation = 0f, value = -0.01f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.2f, value = -0.07f } } } }, { "Skeleton", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.03f, saturation = 0.3f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.3f, value = -0.1f } }, { 3, new DataObjects.ColorDef { hue = -0.12f, saturation = 0.3f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.01f, saturation = 0.3f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.15f, saturation = 0.3f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.2f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0.3f, value = -0.2f } }, { 9, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.2f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "Skeleton_NoArcher", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.03f, saturation = 0.3f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.3f, value = -0.1f } }, { 3, new DataObjects.ColorDef { hue = -0.12f, saturation = 0.3f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.01f, saturation = 0.3f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.15f, saturation = 0.3f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.2f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0.3f, value = -0.2f } }, { 9, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.2f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "Skeleton_Poison", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.16f, saturation = 0f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.12f, saturation = 0.3f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.01f, saturation = 0.3f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.15f, saturation = 0.3f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.2f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0.3f, value = -0.2f } }, { 9, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.2f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "Troll", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.1f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.12f, saturation = 0.2f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.15f, saturation = 0.3f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = -0.2f, saturation = 0.3f, value = -0.05f } }, { 5, new DataObjects.ColorDef { hue = 0.4f, saturation = 0.3f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.45f, saturation = 0.3f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = 0.5f, saturation = 0.3f, value = 0f } }, { 8, new DataObjects.ColorDef { hue = 0.85f, saturation = 0.3f, value = 0f } }, { 9, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = 0f } }, { 10, new DataObjects.ColorDef { hue = 1f, saturation = 0.5f, value = 0f } } } }, { "Bjorn", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = 0.3f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = 5f, saturation = 0.3f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.12f, saturation = 0.3f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = 0.18f, saturation = 0.3f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.2f, saturation = 0.3f, value = -0.12f } }, { 7, new DataObjects.ColorDef { hue = -0.08f, saturation = 0.3f, value = -0.1f } }, { 8, new DataObjects.ColorDef { hue = 0.05f, saturation = 0.3f, value = -0.12f } }, { 9, new DataObjects.ColorDef { hue = 0.15f, saturation = 0.3f, value = -0.1f } }, { 10, new DataObjects.ColorDef { hue = 1f, saturation = 0.5f, value = -0.05f } } } }, { "Serpent", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.05f, saturation = 0f, value = -0.01f } }, { 2, new DataObjects.ColorDef { hue = -0.1f, saturation = 0f, value = -0.01f } }, { 3, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = -0.01f } }, { 4, new DataObjects.ColorDef { hue = -0.4f, saturation = 0f, value = -0.01f } }, { 5, new DataObjects.ColorDef { hue = -0.5f, saturation = 0f, value = -0.01f } }, { 6, new DataObjects.ColorDef { hue = 0.3f, saturation = 0f, value = -0.01f } }, { 7, new DataObjects.ColorDef { hue = -0.8f, saturation = 0f, value = -0.01f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0f, value = -0.01f } }, { 9, new DataObjects.ColorDef { hue = -1f, saturation = 0f, value = -0.01f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.2f, value = -0.07f } } } }, { "Skeleton_Hildir", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.16f, saturation = 0f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.12f, saturation = 0.3f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.01f, saturation = 0.3f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.15f, saturation = 0.3f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.2f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0.3f, value = -0.2f } }, { 9, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.2f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "Skeleton_Hildir_nochest", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.16f, saturation = 0f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.12f, saturation = 0.3f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.01f, saturation = 0.3f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.15f, saturation = 0.3f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.2f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0.3f, value = -0.2f } }, { 9, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.2f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "gd_king", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.12f, saturation = 0f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.22f, saturation = 0f, value = -0.1f } }, { 3, new DataObjects.ColorDef { hue = -0.33f, saturation = 0f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = -0.44f, saturation = 0.3f, value = 0f } }, { 5, new DataObjects.ColorDef { hue = -0.55f, saturation = 0.3f, value = 0.05f } }, { 6, new DataObjects.ColorDef { hue = -0.66f, saturation = 0f, value = 0.07f } }, { 7, new DataObjects.ColorDef { hue = -0.66f, saturation = -0.15f, value = 0.1f } }, { 8, new DataObjects.ColorDef { hue = -0.66f, saturation = -0.45f, value = 0.1f } }, { 9, new DataObjects.ColorDef { hue = -0.88f, saturation = 0f, value = 0.2f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "Draugr", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.27f, saturation = 0f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.25f, saturation = 0.04f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = 0.32f, saturation = 0.3f, value = 0.01f } }, { 4, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.5f, value = 0.01f } }, { 5, new DataObjects.ColorDef { hue = -0.2f, saturation = -0.2f, value = 0.01f } }, { 6, new DataObjects.ColorDef { hue = -0.4f, saturation = -0.2f, value = 0.01f } }, { 7, new DataObjects.ColorDef { hue = -0.6f, saturation = -0.2f, value = 0.01f } }, { 8, new DataObjects.ColorDef { hue = -0.9f, saturation = -0.2f, value = 0.01f } }, { 9, new DataObjects.ColorDef { hue = 1f, saturation = 0.2f, value = 0.01f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.5f, value = 0.01f } } } }, { "Draugr_Ranged", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.27f, saturation = 0f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.25f, saturation = 0.04f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = 0.32f, saturation = 0.3f, value = 0.01f } }, { 4, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.5f, value = 0.01f } }, { 5, new DataObjects.ColorDef { hue = -0.2f, saturation = -0.2f, value = 0.01f } }, { 6, new DataObjects.ColorDef { hue = -0.4f, saturation = -0.2f, value = 0.01f } }, { 7, new DataObjects.ColorDef { hue = -0.6f, saturation = -0.2f, value = 0.01f } }, { 8, new DataObjects.ColorDef { hue = -0.9f, saturation = -0.2f, value = 0.01f } }, { 9, new DataObjects.ColorDef { hue = 1f, saturation = 0.2f, value = 0.01f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.5f, value = 0.01f } } } }, { "Draugr_Elite", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.1f, saturation = 0f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = 0.32f, saturation = 0.3f, value = 0.01f } }, { 4, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.5f, value = 0.01f } }, { 5, new DataObjects.ColorDef { hue = -0.2f, saturation = -0.2f, value = 0.01f } }, { 6, new DataObjects.ColorDef { hue = -0.4f, saturation = -0.2f, value = 0.01f } }, { 7, new DataObjects.ColorDef { hue = -0.6f, saturation = -0.2f, value = 0.01f } }, { 8, new DataObjects.ColorDef { hue = -0.9f, saturation = -0.2f, value = 0.01f } }, { 9, new DataObjects.ColorDef { hue = 1f, saturation = 0.2f, value = 0.01f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.5f, value = 0.01f } } } }, { "Abomination", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.1f, saturation = 0f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = 0.32f, saturation = 0.3f, value = 0.01f } }, { 4, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.5f, value = 0.01f } }, { 5, new DataObjects.ColorDef { hue = -0.2f, saturation = -0.2f, value = 0.01f } }, { 6, new DataObjects.ColorDef { hue = -0.4f, saturation = -0.2f, value = 0.01f } }, { 7, new DataObjects.ColorDef { hue = -0.6f, saturation = -0.2f, value = 0.01f } }, { 8, new DataObjects.ColorDef { hue = -0.9f, saturation = -0.2f, value = 0.01f } }, { 9, new DataObjects.ColorDef { hue = 1f, saturation = 0.2f, value = 0.01f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.5f, value = 0.01f } } } }, { "Surtling", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.16f, saturation = 0f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.5f, saturation = 0.5f, value = -1f } }, { 3, new DataObjects.ColorDef { hue = -0.12f, saturation = 0.3f, value = -2f } }, { 4, new DataObjects.ColorDef { hue = 0.01f, saturation = 0.3f, value = -3f } }, { 5, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -4f } }, { 6, new DataObjects.ColorDef { hue = 0.15f, saturation = 0.3f, value = -5f } }, { 7, new DataObjects.ColorDef { hue = 1f, saturation = 0.5f, value = -5f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0.5f, value = -5f } }, { 9, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.8f, value = -5f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 1f, value = -5f } } } }, { "Leech", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.23f, saturation = 0.26f, value = 0.04f } }, { 2, new DataObjects.ColorDef { hue = -0.139f, saturation = 0.47f, value = 0.06f } }, { 3, new DataObjects.ColorDef { hue = 0.32f, saturation = 0.3f, value = 0.01f } }, { 4, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.5f, value = 0.01f } }, { 5, new DataObjects.ColorDef { hue = -0.2f, saturation = -0.2f, value = 0.01f } }, { 6, new DataObjects.ColorDef { hue = -0.4f, saturation = -0.2f, value = 0.01f } }, { 7, new DataObjects.ColorDef { hue = -0.6f, saturation = -0.2f, value = 0.01f } }, { 8, new DataObjects.ColorDef { hue = -0.9f, saturation = -0.2f, value = 0.01f } }, { 9, new DataObjects.ColorDef { hue = 1f, saturation = 0.2f, value = 0.01f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.5f, value = 0.01f } } } }, { "Blob", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.23f, saturation = 0.26f, value = 0.04f } }, { 2, new DataObjects.ColorDef { hue = -0.139f, saturation = 0.47f, value = 0.06f } } } }, { "BlobElite", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.23f, saturation = 0.26f, value = 0.04f } }, { 2, new DataObjects.ColorDef { hue = -0.139f, saturation = 0.47f, value = 0.06f } } } }, { "Bonemass", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = 0f } } } }, { "Wolf", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.2f, value = -0.05f } }, { 3, new DataObjects.ColorDef { hue = -0.4f, saturation = 0.2f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.2f, saturation = 0.1f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = 0.4f, saturation = 0.2f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.2f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = 0.4f, saturation = 0.3f, value = -0.05f } }, { 8, new DataObjects.ColorDef { hue = 0.1f, saturation = -0.5f, value = -0.2f } }, { 9, new DataObjects.ColorDef { hue = -0.9f, saturation = 0.2f, value = -0.3f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.4f } } } }, { "Ulv", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.2f, value = -0.05f } }, { 3, new DataObjects.ColorDef { hue = -0.4f, saturation = 0.2f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.2f, saturation = 0.1f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = 0.4f, saturation = 0.2f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.2f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = 0.4f, saturation = 0.3f, value = -0.05f } }, { 8, new DataObjects.ColorDef { hue = 0.1f, saturation = -0.5f, value = -0.2f } }, { 9, new DataObjects.ColorDef { hue = -0.9f, saturation = 0.2f, value = -0.3f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.4f } } } }, { "Fenring", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.2f, value = -0.05f } }, { 3, new DataObjects.ColorDef { hue = -0.4f, saturation = 0.2f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.2f, saturation = 0.1f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = 0.4f, saturation = 0.2f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.2f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = 0.4f, saturation = 0.3f, value = -0.05f } }, { 8, new DataObjects.ColorDef { hue = 0.1f, saturation = -0.5f, value = -0.2f } }, { 9, new DataObjects.ColorDef { hue = -0.9f, saturation = 0.2f, value = -0.3f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.4f } } } }, { "Fenring_Cultist", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.2f, value = -0.05f } }, { 3, new DataObjects.ColorDef { hue = 0.32f, saturation = 0.3f, value = 0.01f } }, { 4, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.5f, value = 0.01f } }, { 5, new DataObjects.ColorDef { hue = -0.2f, saturation = -0.2f, value = 0.01f } }, { 6, new DataObjects.ColorDef { hue = -0.4f, saturation = -0.2f, value = 0.01f } }, { 7, new DataObjects.ColorDef { hue = -0.6f, saturation = -0.2f, value = 0.01f } }, { 8, new DataObjects.ColorDef { hue = -0.9f, saturation = -0.2f, value = 0.01f } }, { 9, new DataObjects.ColorDef { hue = 1f, saturation = 0.2f, value = 0.01f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.5f, value = 0.01f } } } }, { "Hatchling", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.2f, value = -0.05f } }, { 3, new DataObjects.ColorDef { hue = -0.12f, saturation = 0.3f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.01f, saturation = 0.3f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.15f, saturation = 0.3f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.2f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0.3f, value = -0.2f } }, { 9, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.2f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "StoneGolem", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.2f, value = -0.05f } }, { 3, new DataObjects.ColorDef { hue = -0.12f, saturation = 0.3f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.01f, saturation = 0.3f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.15f, saturation = 0.3f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.2f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0.3f, value = -0.2f } }, { 9, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.2f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "Dragon", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.2f, value = -0.05f } }, { 3, new DataObjects.ColorDef { hue = -0.12f, saturation = 0.3f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.01f, saturation = 0.3f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.15f, saturation = 0.3f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.2f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0.3f, value = -0.2f } }, { 9, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.2f } }, { 10, new DataObjects.ColorDef { hue = 1f, saturation = 0.3f, value = 0.05f } } } }, { "Deathsquito", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.05f, saturation = 0f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.15f, saturation = 0f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.12f, saturation = 0.3f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.01f, saturation = 0.3f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.15f, saturation = 0.3f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.2f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0.3f, value = -0.2f } }, { 9, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.2f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "Lox", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.05f, saturation = 0f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.1f, saturation = 0f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.14f, saturation = 0f, value = 0f } }, { 4, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = 0f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.07f, saturation = 0f, value = 0f } }, { 7, new DataObjects.ColorDef { hue = 0.14f, saturation = 0f, value = 0f } }, { 8, new DataObjects.ColorDef { hue = 0.18f, saturation = 0f, value = 0f } }, { 9, new DataObjects.ColorDef { hue = 0.35f, saturation = 0f, value = 0f } }, { 10, new DataObjects.ColorDef { hue = 0f, saturation = -0.5f, value = 0f } } } }, { "GoblinArcher", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.05f, saturation = 0f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.08f, saturation = 0f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.12f, saturation = 0f, value = 0f } }, { 4, new DataObjects.ColorDef { hue = -0.15f, saturation = 0f, value = 0f } }, { 5, new DataObjects.ColorDef { hue = -0.18f, saturation = 0f, value = 0f } }, { 6, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = 0f } }, { 7, new DataObjects.ColorDef { hue = -0.22f, saturation = 0f, value = 0f } }, { 8, new DataObjects.ColorDef { hue = -0.24f, saturation = 0f, value = 0f } }, { 9, new DataObjects.ColorDef { hue = -0.26f, saturation = 0f, value = 0f } }, { 10, new DataObjects.ColorDef { hue = -0.28f, saturation = 0f, value = 0f } } } }, { "Goblin", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.05f, saturation = 0f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.08f, saturation = 0f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.12f, saturation = 0f, value = 0f } }, { 4, new DataObjects.ColorDef { hue = -0.15f, saturation = 0f, value = 0f } }, { 5, new DataObjects.ColorDef { hue = -0.18f, saturation = 0f, value = 0f } }, { 6, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = 0f } }, { 7, new DataObjects.ColorDef { hue = -0.22f, saturation = 0f, value = 0f } }, { 8, new DataObjects.ColorDef { hue = -0.24f, saturation = 0f, value = 0f } }, { 9, new DataObjects.ColorDef { hue = -0.26f, saturation = 0f, value = 0f } }, { 10, new DataObjects.ColorDef { hue = -0.28f, saturation = 0f, value = 0f } } } }, { "GoblinBrute", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.1f, saturation = -0.1f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.18f, saturation = 0f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.12f, saturation = 0.3f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.01f, saturation = 0.3f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.15f, saturation = 0.3f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.3f, value = -0.2f } }, { 8, new DataObjects.ColorDef { hue = -0.2f, saturation = 0.3f, value = -0.15f } }, { 9, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.2f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "GoblinShaman", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.1f, saturation = -0.1f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.18f, saturation = 0f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.12f, saturation = 0.3f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.01f, saturation = 0.3f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.15f, saturation = 0.3f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.3f, value = -0.2f } }, { 8, new DataObjects.ColorDef { hue = -0.2f, saturation = 0.3f, value = -0.15f } }, { 9, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.2f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "GoblinBrute_Hildir", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.1f, saturation = -0.1f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.18f, saturation = 0f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.12f, saturation = 0.3f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.01f, saturation = 0.3f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.15f, saturation = 0.3f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.3f, value = -0.2f } }, { 8, new DataObjects.ColorDef { hue = -0.2f, saturation = 0.3f, value = -0.15f } }, { 9, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.2f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "GoblinBruteBros", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.1f, saturation = -0.1f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.18f, saturation = 0f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.12f, saturation = 0.3f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.01f, saturation = 0.3f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.15f, saturation = 0.3f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.3f, value = -0.2f } }, { 8, new DataObjects.ColorDef { hue = -0.2f, saturation = 0.3f, value = -0.15f } }, { 9, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.2f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "GoblinKing", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = 0f } } } }, { "Hen", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.05f, saturation = -0.1f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = 0.09f, saturation = -0.5f, value = -0.05f } }, { 3, new DataObjects.ColorDef { hue = -0.14f, saturation = 0f, value = 0f } }, { 4, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = 0f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.07f, saturation = 0f, value = 0f } }, { 7, new DataObjects.ColorDef { hue = 0.14f, saturation = 0f, value = 0f } }, { 8, new DataObjects.ColorDef { hue = 0.18f, saturation = 0f, value = 0f } }, { 9, new DataObjects.ColorDef { hue = 0.35f, saturation = 0f, value = 0f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "Gjall", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.201f, saturation = 0.29f, value = -0.42f } }, { 2, new DataObjects.ColorDef { hue = -0.103f, saturation = -0.08f, value = -0.42f } }, { 3, new DataObjects.ColorDef { hue = -0.14f, saturation = 0f, value = 0f } }, { 4, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = 0f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.07f, saturation = 0f, value = 0f } }, { 7, new DataObjects.ColorDef { hue = 0.14f, saturation = 0f, value = 0f } }, { 8, new DataObjects.ColorDef { hue = 0.18f, saturation = 0f, value = 0f } }, { 9, new DataObjects.ColorDef { hue = 0.35f, saturation = 0f, value = 0f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "Tick", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.337f, saturation = -0.09f, value = -0.41f } }, { 2, new DataObjects.ColorDef { hue = -0.027f, saturation = 0.29f, value = -0.41f } }, { 3, new DataObjects.ColorDef { hue = -0.14f, saturation = 0f, value = 0f } }, { 4, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = 0f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.07f, saturation = 0f, value = 0f } }, { 7, new DataObjects.ColorDef { hue = 0.14f, saturation = 0f, value = 0f } }, { 8, new DataObjects.ColorDef { hue = 0.18f, saturation = 0f, value = 0f } }, { 9, new DataObjects.ColorDef { hue = 0.35f, saturation = 0f, value = 0f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "Seeker", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.28f, saturation = -0.3f, value = -0.1f } }, { 2, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.1f, value = -0.2f } }, { 3, new DataObjects.ColorDef { hue = -0.14f, saturation = 0f, value = 0f } }, { 4, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = 0f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.07f, saturation = 0f, value = 0f } }, { 7, new DataObjects.ColorDef { hue = 0.14f, saturation = 0f, value = 0f } }, { 8, new DataObjects.ColorDef { hue = 0.18f, saturation = 0f, value = 0f } }, { 9, new DataObjects.ColorDef { hue = 0.35f, saturation = 0f, value = 0f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "SeekerBrute", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.5f, saturation = 0.05f, value = -0.08f } }, { 2, new DataObjects.ColorDef { hue = -0.351f, saturation = -0.04f, value = -0.1f } }, { 3, new DataObjects.ColorDef { hue = -0.14f, saturation = 0f, value = 0f } }, { 4, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = 0f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.07f, saturation = 0f, value = 0f } }, { 7, new DataObjects.ColorDef { hue = 0.14f, saturation = 0f, value = 0f } }, { 8, new DataObjects.ColorDef { hue = 0.18f, saturation = 0f, value = 0f } }, { 9, new DataObjects.ColorDef { hue = 0.35f, saturation = 0f, value = 0f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "DvergerMageIce", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.2f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = -1f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.14f, saturation = 0f, value = 0f } }, { 4, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = 0f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.07f, saturation = 0f, value = 0f } }, { 7, new DataObjects.ColorDef { hue = 0.14f, saturation = 0f, value = 0f } }, { 8, new DataObjects.ColorDef { hue = 0.18f, saturation = 0f, value = 0f } }, { 9, new DataObjects.ColorDef { hue = 0.35f, saturation = 0f, value = 0f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "DvergerMageSupport", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.2f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = -1f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.14f, saturation = 0f, value = 0f } }, { 4, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = 0f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.07f, saturation = 0f, value = 0f } }, { 7, new DataObjects.ColorDef { hue = 0.14f, saturation = 0f, value = 0f } }, { 8, new DataObjects.ColorDef { hue = 0.18f, saturation = 0f, value = 0f } }, { 9, new DataObjects.ColorDef { hue = 0.35f, saturation = 0f, value = 0f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "DvergerMageFire", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.2f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = -1f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.14f, saturation = 0f, value = 0f } }, { 4, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = 0f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.07f, saturation = 0f, value = 0f } }, { 7, new DataObjects.ColorDef { hue = 0.14f, saturation = 0f, value = 0f } }, { 8, new DataObjects.ColorDef { hue = 0.18f, saturation = 0f, value = 0f } }, { 9, new DataObjects.ColorDef { hue = 0.35f, saturation = 0f, value = 0f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "DvergerMage", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.2f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = -1f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.14f, saturation = 0f, value = 0f } }, { 4, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = 0f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.07f, saturation = 0f, value = 0f } }, { 7, new DataObjects.ColorDef { hue = 0.14f, saturation = 0f, value = 0f } }, { 8, new DataObjects.ColorDef { hue = 0.18f, saturation = 0f, value = 0f } }, { 9, new DataObjects.ColorDef { hue = 0.35f, saturation = 0f, value = 0f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "Dverger", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.2f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = -1f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = -0.14f, saturation = 0f, value = 0f } }, { 4, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = 0f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = 0f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.07f, saturation = 0f, value = 0f } }, { 7, new DataObjects.ColorDef { hue = 0.14f, saturation = 0f, value = 0f } }, { 8, new DataObjects.ColorDef { hue = 0.18f, saturation = 0f, value = 0f } }, { 9, new DataObjects.ColorDef { hue = 0.35f, saturation = 0f, value = 0f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "Skeleton_Friendly", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.03f, saturation = 0.3f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.3f, value = -0.1f } }, { 3, new DataObjects.ColorDef { hue = -0.15f, saturation = 0.3f, value = -0.151f } }, { 4, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.3f, value = -0.18f } }, { 5, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.15f, saturation = 0.3f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.2f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0.3f, value = -0.2f } }, { 9, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.2f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "SeekerQueen", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.03f, saturation = 0.3f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.3f, value = -0.1f } }, { 3, new DataObjects.ColorDef { hue = -0.15f, saturation = 0.3f, value = -0.151f } }, { 4, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.3f, value = -0.18f } }, { 5, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.15f, saturation = 0.3f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.2f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0.3f, value = -0.2f } }, { 9, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.2f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "BonemawSerpent", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.05f, saturation = 0f, value = -0.01f } }, { 2, new DataObjects.ColorDef { hue = -0.1f, saturation = 0f, value = -0.01f } }, { 3, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = -0.01f } }, { 4, new DataObjects.ColorDef { hue = -0.4f, saturation = 0f, value = -0.01f } }, { 5, new DataObjects.ColorDef { hue = -0.5f, saturation = 0f, value = -0.01f } }, { 6, new DataObjects.ColorDef { hue = 0.3f, saturation = 0f, value = -0.01f } }, { 7, new DataObjects.ColorDef { hue = -0.8f, saturation = 0f, value = -0.01f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0f, value = -0.01f } }, { 9, new DataObjects.ColorDef { hue = -1f, saturation = 0f, value = -0.01f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.2f, value = -0.07f } } } }, { "Asksvin", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.477f, saturation = -1f, value = 0.02f } }, { 2, new DataObjects.ColorDef { hue = 0.5f, saturation = -0.08f, value = 0.08f } }, { 3, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = -0.01f } }, { 4, new DataObjects.ColorDef { hue = -0.4f, saturation = 0f, value = -0.01f } }, { 5, new DataObjects.ColorDef { hue = -0.5f, saturation = 0f, value = -0.01f } }, { 6, new DataObjects.ColorDef { hue = 0.3f, saturation = 0f, value = -0.01f } }, { 7, new DataObjects.ColorDef { hue = -0.8f, saturation = 0f, value = -0.01f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0f, value = -0.01f } }, { 9, new DataObjects.ColorDef { hue = -1f, saturation = 0f, value = -0.01f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.2f, value = -0.07f } } } }, { "Asksvin_hatchling", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.477f, saturation = -1f, value = 0.02f } }, { 2, new DataObjects.ColorDef { hue = 0.5f, saturation = -0.08f, value = 0.08f } }, { 3, new DataObjects.ColorDef { hue = -0.2f, saturation = 0.2f, value = -0.01f } }, { 4, new DataObjects.ColorDef { hue = -0.4f, saturation = 0.4f, value = -0.01f } }, { 5, new DataObjects.ColorDef { hue = -0.5f, saturation = 0.6f, value = -0.01f } }, { 6, new DataObjects.ColorDef { hue = 0.3f, saturation = 0.8f, value = -0.01f } }, { 7, new DataObjects.ColorDef { hue = -0.8f, saturation = -0.1f, value = -0.01f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = -0.3f, value = -0.01f } }, { 9, new DataObjects.ColorDef { hue = -1f, saturation = -0.4f, value = -0.01f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = -0.8f, value = -0.07f } } } }, { "Volture", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.477f, saturation = -1f, value = 0.02f } }, { 2, new DataObjects.ColorDef { hue = 0.5f, saturation = -0.08f, value = 0.08f } }, { 3, new DataObjects.ColorDef { hue = -0.2f, saturation = 0f, value = -0.01f } }, { 4, new DataObjects.ColorDef { hue = -0.4f, saturation = 0f, value = -0.01f } }, { 5, new DataObjects.ColorDef { hue = -0.5f, saturation = 0f, value = -0.01f } }, { 6, new DataObjects.ColorDef { hue = 0.3f, saturation = 0f, value = -0.01f } }, { 7, new DataObjects.ColorDef { hue = -0.8f, saturation = 0f, value = -0.01f } }, { 8, new DataObjects.ColorDef { hue = -0.8f, saturation = 0f, value = -0.01f } }, { 9, new DataObjects.ColorDef { hue = -1f, saturation = 0f, value = -0.01f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.2f, value = -0.07f } } } }, { "FallenValkyrie", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.05f } }, { 3, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.1f } }, { 4, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.15f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.25f } }, { 6, new DataObjects.ColorDef { hue = 0f, saturation = 0.2f, value = 0.25f } }, { 7, new DataObjects.ColorDef { hue = 0.5f, saturation = 0.2f, value = 0.1f } }, { 8, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.3f, value = 0f } }, { 9, new DataObjects.ColorDef { hue = 0.3f, saturation = 0.3f, value = -0.1f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.4f } } } }, { "Charred_Melee", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.05f } }, { 3, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.1f } }, { 4, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.15f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.25f } }, { 6, new DataObjects.ColorDef { hue = 0f, saturation = 0.2f, value = 0.25f } }, { 7, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.2f, value = 0.25f } }, { 8, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.5f, value = 0.25f } }, { 9, new DataObjects.ColorDef { hue = 0.45f, saturation = 0.5f, value = 0.3f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.4f } } } }, { "Charred_Twitcher", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.05f } }, { 3, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.1f } }, { 4, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.15f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.25f } }, { 6, new DataObjects.ColorDef { hue = 0f, saturation = 0.2f, value = 0.25f } }, { 7, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.2f, value = 0.25f } }, { 8, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.5f, value = 0.25f } }, { 9, new DataObjects.ColorDef { hue = 0.45f, saturation = 0.5f, value = 0.3f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.4f } } } }, { "Charred_Archer", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.05f } }, { 3, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.1f } }, { 4, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.15f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.25f } }, { 6, new DataObjects.ColorDef { hue = 0f, saturation = 0.2f, value = 0.25f } }, { 7, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.2f, value = 0.25f } }, { 8, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.5f, value = 0.25f } }, { 9, new DataObjects.ColorDef { hue = 0.45f, saturation = 0.5f, value = 0.3f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.4f } } } }, { "Charred_Mage", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.05f } }, { 3, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.1f } }, { 4, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.15f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.25f } }, { 6, new DataObjects.ColorDef { hue = 0f, saturation = 0.2f, value = 0.25f } }, { 7, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.2f, value = 0.25f } }, { 8, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.5f, value = 0.25f } }, { 9, new DataObjects.ColorDef { hue = 0.45f, saturation = 0.5f, value = 0.3f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.4f } } } }, { "DvergerAshlands", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.2f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = -1f, value = 0f } }, { 3, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.1f } }, { 4, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.15f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.25f } }, { 6, new DataObjects.ColorDef { hue = 0f, saturation = 0.2f, value = 0.25f } }, { 7, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.2f, value = 0.25f } }, { 8, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.5f, value = 0.25f } }, { 9, new DataObjects.ColorDef { hue = 0.45f, saturation = 0.5f, value = 0.3f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.4f } } } }, { "Morgen", new Dictionary { { 1, new DataObjects.ColorDef { hue = -0.03f, saturation = 0.3f, value = 0f } }, { 2, new DataObjects.ColorDef { hue = -0.1f, saturation = 0.3f, value = -0.1f } }, { 3, new DataObjects.ColorDef { hue = -0.12f, saturation = 0.3f, value = -0.1f } }, { 4, new DataObjects.ColorDef { hue = 0.01f, saturation = 0.3f, value = -0.1f } }, { 5, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.3f, value = -0.1f } }, { 6, new DataObjects.ColorDef { hue = 0.15f, saturation = 0.3f, value = -0.1f } }, { 7, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.5f, value = -0.1f } }, { 8, new DataObjects.ColorDef { hue = 0.05f, saturation = 0.5f, value = -0.1f } }, { 9, new DataObjects.ColorDef { hue = 0.1f, saturation = 0.1f, value = -0.09f } }, { 10, new DataObjects.ColorDef { hue = -1f, saturation = 0.4f, value = -0.25f } } } }, { "BlobLava", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.05f } }, { 3, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.1f } }, { 4, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.15f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.25f } }, { 6, new DataObjects.ColorDef { hue = 0f, saturation = 0.2f, value = 0.25f } }, { 7, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.2f, value = 0.25f } }, { 8, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.5f, value = 0.25f } }, { 9, new DataObjects.ColorDef { hue = 0.45f, saturation = 0.5f, value = 0.3f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.4f } } } }, { "Troll_Summoned", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.05f } }, { 3, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.1f } }, { 4, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.15f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.25f } }, { 6, new DataObjects.ColorDef { hue = 0f, saturation = 0.2f, value = 0.25f } }, { 7, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.2f, value = 0.25f } }, { 8, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.5f, value = 0.25f } }, { 9, new DataObjects.ColorDef { hue = 0.45f, saturation = 0.5f, value = 0.3f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.4f } } } }, { "Charred_Twitcher_Summoned", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.05f } }, { 3, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.1f } }, { 4, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.15f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.25f } }, { 6, new DataObjects.ColorDef { hue = 0f, saturation = 0.2f, value = 0.25f } }, { 7, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.2f, value = 0.25f } }, { 8, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.5f, value = 0.25f } }, { 9, new DataObjects.ColorDef { hue = 0.45f, saturation = 0.5f, value = 0.3f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.4f } } } }, { "Charred_Melee_Dyrnwyn", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.05f } }, { 3, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.1f } }, { 4, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.15f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.25f } }, { 6, new DataObjects.ColorDef { hue = 0f, saturation = 0.2f, value = 0.25f } }, { 7, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.2f, value = 0.25f } }, { 8, new DataObjects.ColorDef { hue = 0.6f, saturation = 0.5f, value = 0.25f } }, { 9, new DataObjects.ColorDef { hue = 0.45f, saturation = 0.5f, value = 0.3f } }, { 10, new DataObjects.ColorDef { hue = 0.9f, saturation = 0.3f, value = -0.4f } } } }, { "Charred_Melee_Fader", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.05f } }, { 3, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.1f } }, { 4, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.15f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.25f } }, { 6, new DataObjects.ColorDef { hue = 0f, saturation = 0.2f, value = 0.25f } }, { 7, new DataObjects.ColorDef { hue = 0.05f, saturation = 0.2f, value = 0.2f } }, { 8, new DataObjects.ColorDef { hue = 0f, saturation = 0.5f, value = 0.25f } }, { 9, new DataObjects.ColorDef { hue = 0f, saturation = 0.5f, value = 0.2f } }, { 10, new DataObjects.ColorDef { hue = 0.45f, saturation = 0.3f, value = -0.4f } } } }, { "Charred_Archer_Fader", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.05f } }, { 3, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.1f } }, { 4, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.15f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.25f } }, { 6, new DataObjects.ColorDef { hue = 0f, saturation = 0.2f, value = 0.25f } }, { 7, new DataObjects.ColorDef { hue = 0.05f, saturation = 0.2f, value = 0.2f } }, { 8, new DataObjects.ColorDef { hue = 0f, saturation = 0.5f, value = 0.25f } }, { 9, new DataObjects.ColorDef { hue = 0f, saturation = 0.5f, value = 0.2f } }, { 10, new DataObjects.ColorDef { hue = 0.45f, saturation = 0.3f, value = -0.4f } } } }, { "Fader", new Dictionary { { 1, new DataObjects.ColorDef { hue = 0f, saturation = 0.1f, value = -0.03f } }, { 2, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.05f } }, { 3, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.1f } }, { 4, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = 0.15f } }, { 5, new DataObjects.ColorDef { hue = 0f, saturation = -0.1f, value = -0.25f } }, { 6, new DataObjects.ColorDef { hue = 0f, saturation = 0.2f, value = -0.25f } }, { 7, new DataObjects.ColorDef { hue = 0.05f, saturation = 0.2f, value = -0.2f } }, { 8, new DataObjects.ColorDef { hue = 0f, saturation = 0.3f, value = -0.25f } }, { 9, new DataObjects.ColorDef { hue = 0f, saturation = 0.4f, value = -0.2f } }, { 10, new DataObjects.ColorDef { hue = 0.45f, saturation = 0.1f, value = -0.4f } } } } }; internal static readonly Dictionary defaultColorizationData = new Dictionary { { 1, new DataObjects.ColorDef { hue = 0.07130837f, saturation = 0.2f, value = 0.130073f } }, { 2, new DataObjects.ColorDef { hue = -0.07488244f, saturation = 0.4406867f, value = 0.01721987f } }, { 3, new DataObjects.ColorDef { hue = -0.04446793f, saturation = 0.05205864f, value = -0.191282f } }, { 4, new DataObjects.ColorDef { hue = 0.08774569f, saturation = -0.3959962f, value = 0.224104f } }, { 5, new DataObjects.ColorDef { hue = -0.05712423f, saturation = 0.09905273f, value = -0.1369882f } }, { 6, new DataObjects.ColorDef { hue = 0.08566696f, saturation = -0.3398137f, value = -0.2270744f } }, { 7, new DataObjects.ColorDef { hue = 0.03924248f, saturation = -0.04047304f, value = -0.1966226f } }, { 8, new DataObjects.ColorDef { hue = -0.3575756f, saturation = 0.09342755f, value = 0.3008582f } }, { 9, new DataObjects.ColorDef { hue = 0.3575756f, saturation = 0.09342755f, value = -0.1008582f } }, { 10, new DataObjects.ColorDef { hue = 0f, saturation = -0.25f, value = 0f } } }; internal static readonly Dictionary> defaultColorGenerators = new Dictionary> { { "DefaultGenerator", new List { new DataObjects.ColorRangeDef { CharacterSpecific = false, RangeStart = 1, RangeEnd = 15, StartColorDef = new DataObjects.ColorDef { hue = 0.07130837f, saturation = 0.05205864f, value = 0.01721987f }, EndColorDef = new DataObjects.ColorDef { hue = -0.07488244f, saturation = 0.09342755f, value = -0.1008582f } }, new DataObjects.ColorRangeDef { CharacterSpecific = false, RangeStart = 16, RangeEnd = 32, StartColorDef = new DataObjects.ColorDef { hue = 0f, saturation = -0.3959962f, value = 0f }, EndColorDef = new DataObjects.ColorDef { hue = -0.3575756f, saturation = 0.2f, value = -0.2270744f } } } } }; } internal static class CompositeLazyCache { [HarmonyPatch(typeof(ZNetScene), "Destroy")] public static class CleanupDeletedCreatures { private static void Prefix(ZNetScene __instance, GameObject go) { ZNetView component = go.GetComponent(); if (!((Object)(object)component == (Object)null) && !((Object)(object)__instance == (Object)null) && component.GetZDO() != null) { uint iD = ((ZDOID)(ref component.GetZDO().m_uid)).ID; if (SessionCache.ContainsKey(iD)) { SessionCache.Remove(iD); } } } } public static readonly Vector2 Center = new Vector2(0f, 0f); private static Dictionary SessionCache = new Dictionary(); private static Dictionary TreeSessionCache = new Dictionary(); public static int GetOrAddCachedTreeEntry(ZNetView zgo) { if ((Object)(object)zgo == (Object)null || !zgo.IsValid() || zgo.GetZDO() == null) { return 1; } uint iD = ((ZDOID)(ref zgo.GetZDO().m_uid)).ID; if (TreeSessionCache.ContainsKey(iD)) { return TreeSessionCache[iD]; } int num = LevelSelection.DeterministicDetermineTreeLevel(((Component)zgo).gameObject); TreeSessionCache.Add(iD, num); return num; } public static void RemoveTreeCacheEntry(uint id) { if (TreeSessionCache.ContainsKey(id)) { TreeSessionCache.Remove(id); } } internal static void FlushCache() { Logger.LogDebug("Flushing creature cache..."); SessionCache.Clear(); } public static DataObjects.CharacterCacheEntry GetCacheEntry(uint cid) { if (SessionCache.ContainsKey(cid)) { return SessionCache[cid]; } return null; } public static DataObjects.CharacterCacheEntry GetCacheEntry(Character character) { return RetrieveStoredCreatureFromCache(character); } public static void ClearCachedCreature(Character character) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)character == (Object)null) && !((Object)(object)character.m_nview == (Object)null) && !character.IsPlayer() && character.m_nview.GetZDO() != null) { ZDOID zDOID = character.GetZDOID(); uint iD = ((ZDOID)(ref zDOID)).ID; SessionCache.Remove(iD); } } public static DataObjects.CharacterCacheEntry GetAndSetLocalCache(Character character, int leveloverride = 0, Dictionary requiredModifiers = null, List notAllowedModifiers = null, bool updateCache = false) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) DataObjects.CharacterCacheEntry characterCacheEntry = RetrieveStoredCreatureFromCache(character); if (characterCacheEntry != null && !updateCache) { return characterCacheEntry; } DataObjects.CharacterCacheEntry characterCacheEntry2 = new DataObjects.CharacterCacheEntry(); characterCacheEntry2.ZDO = character.m_nview.GetZDO(); LevelSelection.SelectCreatureBiomeSettings(((Component)character).gameObject, out var creature_name, out var creature_settings, out var biome_settings, out var creature_biome); characterCacheEntry2.creatureSettings = creature_settings; characterCacheEntry2.Biome = creature_biome; characterCacheEntry2.RefCreatureName = creature_name; if (biome_settings != null && biome_settings.creatureSpawnsDisabled != null && biome_settings.creatureSpawnsDisabled.Contains(creature_name)) { characterCacheEntry2.ShouldDelete = true; } if (biome_settings != null) { characterCacheEntry2.SpawnRateModifier = biome_settings.SpawnRateModifier; } if (creature_settings != null) { characterCacheEntry2.SpawnRateModifier = creature_settings.SpawnRateModifier; } if (EnvMan.IsNight()) { if (biome_settings != null && biome_settings.NightSettings != null) { if (biome_settings.NightSettings.SpawnRateModifier != 1f) { biome_settings.SpawnRateModifier = biome_settings.NightSettings.SpawnRateModifier; } if (biome_settings.NightSettings.creatureSpawnsDisabled != null && biome_settings.NightSettings.creatureSpawnsDisabled.Contains(creature_name)) { characterCacheEntry2.ShouldDelete = true; } } if (creature_settings != null && creature_settings.NightSettings != null) { if (creature_settings.NightSettings.SpawnRateModifier != 1f) { creature_settings.SpawnRateModifier = creature_settings.NightSettings.SpawnRateModifier; } if (creature_settings.NightSettings.creatureSpawnsDisabled) { characterCacheEntry2.ShouldDelete = true; } } } if (requiredModifiers == null) { if (creature_settings != null && creature_settings.RequiredModifiers != null) { requiredModifiers = creature_settings.RequiredModifiers; } } else if (creature_settings != null && creature_settings.RequiredModifiers != null) { foreach (KeyValuePair requiredModifier in creature_settings.RequiredModifiers) { if (!requiredModifiers.ContainsKey(requiredModifier.Key)) { requiredModifiers.Add(requiredModifier.Key, requiredModifier.Value); } } } characterCacheEntry2.ModifiersNotAllowed = notAllowedModifiers; characterCacheEntry2.ModifiersRequired = requiredModifiers; characterCacheEntry2.CreatureModifiers = GetCreatureModifiers(character); characterCacheEntry2.Level = LevelSelection.DetermineLevel(character, characterCacheEntry2.ZDO, creature_settings, biome_settings, leveloverride); characterCacheEntry2.Colorization = Colorization.DetermineCharacterColorization(character, characterCacheEntry2.Level); characterCacheEntry2.DamageRecievedModifiers = DamageModifications.DetermineCreatureDamageRecievedModifiers(biome_settings, creature_settings); characterCacheEntry2.CreaturePerLevelValueModifiers = DamageModifications.DetermineCharacterPerLevelStats(biome_settings, creature_settings); characterCacheEntry2.CreatureBaseValueModifiers = DamageModifications.DetermineCreatureBaseStats(biome_settings, creature_settings); ZDOID zDOID = character.GetZDOID(); uint iD = ((ZDOID)(ref zDOID)).ID; if (SessionCache.ContainsKey(iD)) { if (updateCache) { SessionCache[iD] = characterCacheEntry2; } } else { SessionCache.Add(iD, characterCacheEntry2); } return characterCacheEntry2; } public static void StartZOwnerCreatureRoutines(Character chara, DataObjects.CharacterCacheEntry characterEntry, bool spawnratecheck = true) { //IL_018b: Unknown result type (might be due to invalid IL or missing references) if (characterEntry == null || (Object)(object)chara == (Object)null) { return; } if (characterEntry.Level == 0) { characterEntry.Level = 1; } if (characterEntry.ShouldDelete && !chara.m_tamed) { ((MonoBehaviour)TaskRunner.Run()).StartCoroutine(Spawnrate.DestroyCoroutine(((Component)chara).gameObject)); return; } int level = chara.GetLevel(); if (level <= 1 && characterEntry.Level != level) { chara.m_nview.GetZDO().Set(ZDOVars.s_level, characterEntry.Level, false); chara.m_level = characterEntry.Level; UIHudControl.InvalidateCacheEntry(chara); } if (ValConfig.OverlevedCreaturesGetRerolledOnLoad.Value && level > ValConfig.MaxLevel.Value + 1) { characterEntry = GetAndSetLocalCache(chara, 0, null, null, updateCache: true); int num = ValConfig.MaxLevel.Value + 1; Logger.LogDebug($"{characterEntry.RefCreatureName} level {level} over max {num}, resetting to {num}"); chara.SetLevel(num); chara.m_level = num; SizeModifications.SetSizeModification(((Component)chara).gameObject, chara.m_nview, characterEntry); Colorization.ApplyColorizationWithoutLevelEffects(((Component)chara).gameObject, characterEntry.Colorization); UIHudControl.InvalidateCacheEntry(chara); } if ((chara.IsBoss() && ValConfig.ControlBossSpawns.Value) || LevelSelection.ForceLeveledCreatures.Contains(characterEntry.RefCreatureName)) { chara.SetLevel(characterEntry.Level); } if (characterEntry.CreatureModifiers == null || characterEntry.CreatureModifiers.Count == 0) { characterEntry.CreatureModifiers = CreatureModifiers.SelectModifiersForCreature(chara, characterEntry.RefCreatureName, characterEntry.creatureSettings, characterEntry.Biome, characterEntry.Level, characterEntry.ModifiersRequired, characterEntry.ModifiersNotAllowed); SetCreatureModifiers(chara, characterEntry.CreatureModifiers); } if (!spawnratecheck) { characterEntry.ZDO.Set(DataObjects.SLS_SPAWN_MULT, true); } else { Spawnrate.CheckSetApplySpawnrate(chara, characterEntry); } } public static DataObjects.CharacterCacheEntry RetrieveStoredCreatureFromCache(Character character) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_002b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || character.GetZDOID() == ZDOID.None || character.IsPlayer()) { return null; } ZDOID zDOID = character.GetZDOID(); uint iD = ((ZDOID)(ref zDOID)).ID; if (SessionCache.ContainsKey(iD)) { return SessionCache[iD]; } return null; } public static void UpdateCharacterCacheEntry(Character character, DataObjects.CharacterCacheEntry scd) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) ZDOID zDOID = character.GetZDOID(); uint iD = ((ZDOID)(ref zDOID)).ID; if (SessionCache.ContainsKey(iD)) { SessionCache[iD] = scd; } else { SessionCache.Add(iD, scd); } } public static Dictionary GetCreatureModifiers(Character character) { if ((Object)(object)character == (Object)null || (Object)(object)character.m_nview == (Object)null) { return null; } string @string = character.m_nview.GetZDO().GetString(DataObjects.SLS_MODSV2, (string)null); if (@string != null) { try { return DataObjects.yamldeserializer.Deserialize>(@string); } catch { return null; } } return new DataObjects.CreatureModifiersZNetProperty(DataObjects.SLS_MODIFIERS, character.m_nview, null).Get(); } public static void SetCreatureModifiers(Character chara, Dictionary modifiers) { chara.m_nview.GetZDO().Set(DataObjects.SLS_MODSV2, DataObjects.yamlserializerJsonCompat.Serialize((object)modifiers)); DataObjects.CharacterCacheEntry cacheEntry = GetCacheEntry(chara); if (cacheEntry != null) { cacheEntry.CreatureModifiers = modifiers; UpdateCharacterCacheEntry(chara, cacheEntry); } } } public static class CreatureModifiersData { public enum ModifierNames { None = 0, BossSummoner = 1, SoulEater = 2, LifeLink = 3, Splitter = 9, Lootbags = 10, Fire = 11, Frost = 12, Poison = 13, Lightning = 14, FireNova = 15, FrostNova = 16, PoisonNova = 17, LightningNova = 18, Evolving = 19, ResistSlash = 21, ResistBlunt = 22, ResistPierce = 23, ResistFire = 24, ResistFrost = 25, ResistPoison = 26, ResistSpirit = 27, Alert = 51, Big = 52, Fast = 53, StaminaDrain = 54, EitrDrain = 55, Brutal = 56, ElementalChaos = 57 } public static DataObjects.CreatureModifierCollection ActiveCreatureModifiers = new DataObjects.CreatureModifierCollection { MajorModifiers = new Dictionary(), MinorModifiers = new Dictionary(), BossModifiers = new Dictionary(), ModifierGlobalSettings = new DataObjects.GlobalModifierSettings() }; public static Dictionary>> biomeMajorProbabilityList = new Dictionary>>(); public static Dictionary>> biomeMinorProbabilityList = new Dictionary>>(); public static Dictionary>> biomeBossProbabilityList = new Dictionary>>(); public static Dictionary LoadedModifierEffects = new Dictionary(); public static Dictionary LoadedSecondaryEffects = new Dictionary(); public static Dictionary LoadedModifierSprites = new Dictionary(); public static List NonCombatCreatures = new List { "Deer", "Hare", "Chicken", "Hen" }; public static Dictionary ModifierDefinitions = new Dictionary { { ModifierNames.BossSummoner.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$bossSummoner_prefix1", NameSuffix = "$bossSummoner_suffix1", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, StarVisual = "summoner", SetupEvent = new <>f__AnonymousDelegate0(Summoner.Setup) } }, { ModifierNames.SoulEater.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$SoulEater_prefix1", NameSuffix = "$SoulEater_suffix1", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, StarVisual = "vortex" } }, { ModifierNames.LifeLink.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$LifeLink_prefix1", NameSuffix = "$LifeLink_suffix1", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, StarVisual = "LifeLink2", SecondaryEffect = "LifelinkEffect" } }, { ModifierNames.Evolving.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$Evolve_prefix1", namingConvention = DataObjects.NameSelectionStyle.RandomFirst, StarVisual = "evolve" } }, { ModifierNames.Brutal.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$Brutal_prefix1", namingConvention = DataObjects.NameSelectionStyle.RandomFirst, VisualEffectStyle = DataObjects.VisualEffectStyle.bottom, StarVisual = "brutal", RunOnceEvent = new Action(Brutal.RunOnce) } }, { ModifierNames.Fire.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$fire_prefix1", NameSuffix = "$fire_suffix1", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, VisualEffectStyle = DataObjects.VisualEffectStyle.bottom, VisualEffect = "creatureFire", StarVisual = "flame", RunOnceEvent = new Action(Flame.RunOnce) } }, { ModifierNames.Frost.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$frost_prefix1", NameSuffix = "$frost_suffix1", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, VisualEffect = "creatureFrost", StarVisual = "snowflake", RunOnceEvent = new Action(Frost.RunOnce) } }, { ModifierNames.Poison.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$poison_prefix1", NameSuffix = "$poison_suffix1", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, VisualEffect = "creaturePoison", StarVisual = "poison", RunOnceEvent = new Action(Poison.RunOnce) } }, { ModifierNames.Lightning.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$lightning_prefix1", NameSuffix = "$lightning_suffix1", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, VisualEffectStyle = DataObjects.VisualEffectStyle.objectCenter, VisualEffect = "creatureLightning", StarVisual = "lightning", RunOnceEvent = new Action(Lightning.RunOnce) } }, { ModifierNames.ElementalChaos.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$ElementalChaos_prefix", NameSuffix = "$ElementalChaos_suffix", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, VisualEffectStyle = DataObjects.VisualEffectStyle.objectCenter, VisualEffect = "creatureLightning", StarVisual = "eleChaos" } }, { ModifierNames.Splitter.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$Splitter_prefix1", NameSuffix = "$Splitter_suffix1", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, StarVisual = "splitting" } }, { ModifierNames.ResistPierce.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$ResistPierce_prefix1", NameSuffix = "$ResistPierce_suffix1", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, StarVisual = "pierceresist", RunOnceEvent = new Action(ResistPierce.RunOnce) } }, { ModifierNames.ResistSlash.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$ResistSlash_prefix1", NameSuffix = "$ResistSlash_suffix1", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, StarVisual = "slashresist", RunOnceEvent = new Action(ResistSlash.RunOnce) } }, { ModifierNames.ResistBlunt.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$ResistBlunt_prefix1", NameSuffix = "$ResistBlunt_suffix1", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, StarVisual = "bluntresist", RunOnceEvent = new Action(ResistBlunt.RunOnce) } }, { ModifierNames.ResistFire.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$ResistFire_prefix1", NameSuffix = "$ResistFire_suffix1", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, StarVisual = "FireRes", RunOnceEvent = new Action(ResistFire.RunOnce) } }, { ModifierNames.ResistFrost.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$ResistFrost_prefix1", NameSuffix = "$ResistFrost_suffix1", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, StarVisual = "FrostRes", RunOnceEvent = new Action(ResistFrost.RunOnce) } }, { ModifierNames.ResistPoison.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$ResistPoison_prefix1", NameSuffix = "$ResistPoison_suffix1", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, StarVisual = "PoisonRes", RunOnceEvent = new Action(ResistPoison.RunOnce) } }, { ModifierNames.ResistSpirit.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$ResistSpirit_prefix1", NameSuffix = "$ResistSpirit_suffix1", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, StarVisual = "SpiritRes", RunOnceEvent = new Action(ResistSpirit.RunOnce) } }, { ModifierNames.FireNova.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$FireNova_prefix1", namingConvention = DataObjects.NameSelectionStyle.RandomFirst, StarVisual = "firenova", SecondaryEffect = "DeathFireNova" } }, { ModifierNames.PoisonNova.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$PoisonNova_prefix1", namingConvention = DataObjects.NameSelectionStyle.RandomFirst, StarVisual = "poisonnova", SecondaryEffect = "DeathPoisonNova" } }, { ModifierNames.Lootbags.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$Lootbags_prefix1", NameSuffix = "$Lootbags_suffix1", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, StarVisual = "lootbag", RunOnceEvent = new Action(Lootbags.RunOnce) } }, { ModifierNames.Alert.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$alert_prefix1", NameSuffix = "$alert_suffix1", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, SetupEvent = new Action(Alert.Setup) } }, { ModifierNames.Big.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$big_prefix1", NameSuffix = "$big_suffix1", namingConvention = DataObjects.NameSelectionStyle.RandomBoth, RunOnceEvent = new Action(Big.RunOnce) } }, { ModifierNames.Fast.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$fast_prefix1", namingConvention = DataObjects.NameSelectionStyle.RandomFirst, RunOnceEvent = new Action(Fast.RunOnce) } }, { ModifierNames.StaminaDrain.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$staminaDrain_prefix1", namingConvention = DataObjects.NameSelectionStyle.RandomFirst, StarVisual = "staminadrain" } }, { ModifierNames.EitrDrain.ToString(), new DataObjects.CreatureModifierDefinition { NamePrefix = "$staminaDrain_prefix1", namingConvention = DataObjects.NameSelectionStyle.RandomFirst, StarVisual = "staminadrain" } } }; public static DataObjects.DNum ModifierNamesLookupTable = new DataObjects.DNum(Enum.GetValues(typeof(ModifierNames))); private static DataObjects.CreatureModifierCollection CustomModifiers = new DataObjects.CreatureModifierCollection(); private static DataObjects.CreatureModifierCollection APIAdded = new DataObjects.CreatureModifierCollection(); private static DataObjects.CreatureModifierCollection DefaultModifiers = new DataObjects.CreatureModifierCollection { BossModifiers = new Dictionary { { ModifierNames.BossSummoner.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { BasePower = 10f, PerlevelPower = 120f, BiomeObjects = new Dictionary> { { (Biome)1, new List { "Greyling" } }, { (Biome)8, new List { "Greydwarf_Shaman" } }, { (Biome)2, new List { "BlobElite" } }, { (Biome)4, new List { "Hatchling" } }, { (Biome)16, new List { "Goblin", "GoblinShaman", "GoblinBrute" } }, { (Biome)512, new List { "SeekerBrute", "Seeker" } }, { (Biome)32, new List { "Charred_Archer", "Charred_Melee" } } } } } }, { ModifierNames.SoulEater.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 0.01f } } }, { ModifierNames.LifeLink.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { BasePower = 0.3f, PerlevelPower = 0.02f } } }, { ModifierNames.ResistPierce.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 0.02f, BasePower = 0.25f } } }, { ModifierNames.Brutal.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 0f, BasePower = 0.05f }, UnallowedCreatures = NonCombatCreatures } } }, MajorModifiers = new Dictionary { { ModifierNames.Brutal.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 0f, BasePower = 0.07f }, UnallowedCreatures = NonCombatCreatures } }, { ModifierNames.ElementalChaos.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 0.01f, BasePower = 0.3f }, UnallowedCreatures = NonCombatCreatures } }, { ModifierNames.Fire.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 0.01f, BasePower = 0.3f }, UnallowedCreatures = NonCombatCreatures } }, { ModifierNames.Frost.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 0.01f, BasePower = 0.3f }, UnallowedCreatures = NonCombatCreatures } }, { ModifierNames.Poison.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 0.05f, BasePower = 1f }, UnallowedCreatures = NonCombatCreatures } }, { ModifierNames.Lightning.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 0.05f, BasePower = 0.3f }, UnallowedCreatures = NonCombatCreatures } }, { ModifierNames.Splitter.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { BasePower = 2f, PerlevelPower = 0.1f } } }, { ModifierNames.SoulEater.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 0.05f }, UnallowedCreatures = NonCombatCreatures } }, { ModifierNames.ResistPierce.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 0.02f, BasePower = 0.5f } } }, { ModifierNames.ResistSlash.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 0.02f, BasePower = 0.5f } } }, { ModifierNames.ResistBlunt.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 0.02f, BasePower = 0.5f } } } }, MinorModifiers = new Dictionary { { ModifierNames.ResistFire.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 5f, Config = new DataObjects.CreatureModConfig { BasePower = 0.5f, PerlevelPower = 0.02f } } }, { ModifierNames.ResistFrost.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 4f, Config = new DataObjects.CreatureModConfig { BasePower = 0.5f, PerlevelPower = 0.02f } } }, { ModifierNames.ResistPoison.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 3f, Config = new DataObjects.CreatureModConfig { BasePower = 0.5f, PerlevelPower = 0.02f } } }, { ModifierNames.ResistSpirit.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 2f, Config = new DataObjects.CreatureModConfig { BasePower = 0.5f, PerlevelPower = 0.02f } } }, { ModifierNames.FireNova.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { BasePower = 2f, PerlevelPower = 0.1f }, UnallowedCreatures = NonCombatCreatures } }, { ModifierNames.PoisonNova.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { BasePower = 2f, PerlevelPower = 0.2f }, UnallowedCreatures = NonCombatCreatures } }, { ModifierNames.Lootbags.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { BasePower = 2f, PerlevelPower = 0.2f } } }, { ModifierNames.Alert.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 0.05f, BasePower = 2f } } }, { ModifierNames.Big.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 0f, BasePower = 0.3f } } }, { ModifierNames.Fast.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 0f, BasePower = 0.2f } } }, { ModifierNames.StaminaDrain.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 2f, BasePower = 3f }, UnallowedCreatures = NonCombatCreatures } }, { ModifierNames.Evolving.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 5f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 1f, BasePower = 10f }, UnallowedCreatures = NonCombatCreatures } }, { ModifierNames.EitrDrain.ToString(), new DataObjects.CreatureModifierConfiguration { SelectionWeight = 10f, Config = new DataObjects.CreatureModConfig { PerlevelPower = 4f, BasePower = 10f }, UnallowedCreatures = NonCombatCreatures, AllowedBiomes = new List { (Biome)512, (Biome)32 } } } }, ModifierGlobalSettings = new DataObjects.GlobalModifierSettings { GlobalIgnorePrefabList = new List { "piece_TrainingDummy" } } }; public static Dictionary GetModifiersOfType(DataObjects.ModifierType type) { return type switch { DataObjects.ModifierType.Minor => ActiveCreatureModifiers.MinorModifiers, DataObjects.ModifierType.Boss => ActiveCreatureModifiers.BossModifiers, _ => ActiveCreatureModifiers.MajorModifiers, }; } public static DataObjects.CreatureModConfig GetConfig(string name, DataObjects.ModifierType type = DataObjects.ModifierType.Major) { switch (type) { case DataObjects.ModifierType.Minor: if (!ActiveCreatureModifiers.MinorModifiers.ContainsKey(name)) { return new DataObjects.CreatureModConfig(); } return ActiveCreatureModifiers.MinorModifiers[name].Config; case DataObjects.ModifierType.Boss: if (!ActiveCreatureModifiers.BossModifiers.ContainsKey(name)) { return new DataObjects.CreatureModConfig(); } return ActiveCreatureModifiers.BossModifiers[name].Config; default: if (!ActiveCreatureModifiers.MajorModifiers.ContainsKey(name)) { return new DataObjects.CreatureModConfig(); } return ActiveCreatureModifiers.MajorModifiers[name].Config; } } public static DataObjects.CreatureModifierConfiguration GetModifierDef(string name, DataObjects.ModifierType type = DataObjects.ModifierType.Major) { switch (type) { case DataObjects.ModifierType.Minor: if (!ActiveCreatureModifiers.MinorModifiers.ContainsKey(name)) { return new DataObjects.CreatureModifierConfiguration(); } return ActiveCreatureModifiers.MinorModifiers[name]; case DataObjects.ModifierType.Boss: if (!ActiveCreatureModifiers.BossModifiers.ContainsKey(name)) { return new DataObjects.CreatureModifierConfiguration(); } return ActiveCreatureModifiers.BossModifiers[name]; default: if (!ActiveCreatureModifiers.MajorModifiers.ContainsKey(name)) { return new DataObjects.CreatureModifierConfiguration(); } return ActiveCreatureModifiers.MajorModifiers[name]; } } public static List LazyCacheCreatureModifierSelect(string creature, Biome biome, DataObjects.ModifierType type = DataObjects.ModifierType.Major) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) switch (type) { case DataObjects.ModifierType.Major: if (biomeMajorProbabilityList.ContainsKey(biome) && biomeMajorProbabilityList[biome].ContainsKey(creature)) { return biomeMajorProbabilityList[biome][creature]; } break; case DataObjects.ModifierType.Minor: if (biomeMinorProbabilityList.ContainsKey(biome) && biomeMinorProbabilityList[biome].ContainsKey(creature)) { return biomeMinorProbabilityList[biome][creature]; } break; case DataObjects.ModifierType.Boss: if (biomeBossProbabilityList.ContainsKey(biome) && biomeBossProbabilityList[biome].ContainsKey(creature)) { return biomeBossProbabilityList[biome][creature]; } break; } return type switch { DataObjects.ModifierType.Boss => BuildCacheProbabilities(creature, biome, ActiveCreatureModifiers.BossModifiers, biomeBossProbabilityList), DataObjects.ModifierType.Major => BuildCacheProbabilities(creature, biome, ActiveCreatureModifiers.MajorModifiers, biomeMajorProbabilityList), _ => BuildCacheProbabilities(creature, biome, ActiveCreatureModifiers.MinorModifiers, biomeMinorProbabilityList), }; } private static List BuildCacheProbabilities(string creature, Biome biome, Dictionary activeMods, Dictionary>> probabilitiesCache) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (probabilitiesCache.ContainsKey(biome) && probabilitiesCache[biome].ContainsKey(creature)) { return probabilitiesCache[biome][creature]; } List list = BuildProbabilityEntries(creature, biome, activeMods); if (!probabilitiesCache.ContainsKey(biome)) { probabilitiesCache.Add(biome, new Dictionary> { { creature, list } }); } else { probabilitiesCache[biome].Add(creature, list); } return list; } private static List BuildProbabilityEntries(string creature, Biome biome, Dictionary modifiers) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (KeyValuePair modifier in modifiers) { if ((modifier.Value.UnallowedCreatures != null && modifier.Value.UnallowedCreatures.Contains(creature)) || (modifier.Value.AllowedBiomes != null && !modifier.Value.AllowedBiomes.Contains(biome))) { continue; } if (modifier.Value.AllowedCreatures != null && modifier.Value.AllowedCreatures.Count > 0) { if (!modifier.Value.AllowedCreatures.Contains(creature)) { continue; } list.Add(new DataObjects.ProbabilityEntry { Name = modifier.Key, SelectionWeight = modifier.Value.SelectionWeight }); } list.Add(new DataObjects.ProbabilityEntry { Name = modifier.Key, SelectionWeight = modifier.Value.SelectionWeight }); } return list; } private static void UpdateModifiers(DataObjects.CreatureModifierCollection creatureMods = null, DataObjects.CreatureModifierCollection APIcreatureMods = null) { ActiveCreatureModifiers.MajorModifiers.Clear(); ActiveCreatureModifiers.MinorModifiers.Clear(); ActiveCreatureModifiers.BossModifiers.Clear(); Logger.LogDebug("Setting config definitions"); if (creatureMods != null) { CustomModifiers = creatureMods; } if (APIcreatureMods != null) { APIAdded = APIcreatureMods; } if (CustomModifiers.ModifierGlobalSettings != null) { ActiveCreatureModifiers.ModifierGlobalSettings = CustomModifiers.ModifierGlobalSettings; } else { ActiveCreatureModifiers.ModifierGlobalSettings = DefaultModifiers.ModifierGlobalSettings; } Logger.LogDebug("Merging config Major mod definitions"); if (CustomModifiers.MajorModifiers != null && CustomModifiers.MajorModifiers.Count > 0) { Extensions.AddRange(ActiveCreatureModifiers.MajorModifiers, CustomModifiers.MajorModifiers); } if (APIAdded.MajorModifiers != null && APIAdded.MajorModifiers.Count > 0) { Extensions.AddRange(ActiveCreatureModifiers.MajorModifiers, APIAdded.MajorModifiers); } if (APIAdded.MajorModifiers == null && CustomModifiers.MajorModifiers == null) { Extensions.AddRange(ActiveCreatureModifiers.MajorModifiers, DefaultModifiers.MajorModifiers); } Logger.LogDebug("Merging config Minor mod definitions"); if (CustomModifiers.MinorModifiers != null && CustomModifiers.MinorModifiers.Count > 0) { Extensions.AddRange(ActiveCreatureModifiers.MinorModifiers, CustomModifiers.MinorModifiers); } if (APIAdded.MinorModifiers != null && APIAdded.MinorModifiers.Count > 0) { Extensions.AddRange(ActiveCreatureModifiers.MinorModifiers, APIAdded.MinorModifiers); } if (APIAdded.MinorModifiers == null && CustomModifiers.MinorModifiers == null) { Extensions.AddRange(ActiveCreatureModifiers.MinorModifiers, DefaultModifiers.MinorModifiers); } Logger.LogDebug("Merging config Boss mod definitions"); if (CustomModifiers.BossModifiers != null && CustomModifiers.BossModifiers.Count > 0) { Extensions.AddRange(ActiveCreatureModifiers.BossModifiers, CustomModifiers.BossModifiers); } if (APIAdded.BossModifiers != null && APIAdded.BossModifiers.Count > 0) { Extensions.AddRange(ActiveCreatureModifiers.BossModifiers, APIAdded.BossModifiers); } if (APIAdded.BossModifiers == null && CustomModifiers.BossModifiers == null) { Extensions.AddRange(ActiveCreatureModifiers.BossModifiers, DefaultModifiers.BossModifiers); } } internal static string GetModifierDefaultConfig() { return DataObjects.yamlserializer.Serialize((object)DefaultModifiers); } internal static void ClearProbabilityCaches(object s, EventArgs e) { ClearProbabilityCaches(); } internal static void ClearProbabilityCaches() { biomeMajorProbabilityList.Clear(); biomeMinorProbabilityList.Clear(); biomeBossProbabilityList.Clear(); } internal static bool UpdateModifierConfig(string yaml) { try { UpdateModifiers(DataObjects.yamldeserializer.Deserialize(yaml)); LoadPrefabs(); Logger.LogDebug("Loading Modifier Configuration."); } catch (Exception ex) { UpdateModifiers(DefaultModifiers); LoadPrefabs(); StarLevelSystem.Log.LogError((object)("Failed to parse Modifier YAML, reverting to defaults error: " + ex.Message)); return false; } return true; } internal static void LoadPrefabs() { if (ActiveCreatureModifiers.MinorModifiers != null) { foreach (KeyValuePair minorModifier in ActiveCreatureModifiers.MinorModifiers) { ModifierDefinitions[minorModifier.Key].LoadAndSetGameObjects(); } } if (ActiveCreatureModifiers.MajorModifiers != null) { foreach (KeyValuePair majorModifier in ActiveCreatureModifiers.MajorModifiers) { ModifierDefinitions[majorModifier.Key].LoadAndSetGameObjects(); } } if (ActiveCreatureModifiers.BossModifiers == null) { return; } foreach (KeyValuePair bossModifier in ActiveCreatureModifiers.BossModifiers) { ModifierDefinitions[bossModifier.Key].LoadAndSetGameObjects(); } } internal static void Init() { UpdateModifierConfig(File.ReadAllText(ValConfig.creatureModifierFilePath)); } } public static class LevelSystemData { [CompilerGenerated] private sealed class d__5 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public List characters; private WaitForSeconds 5__2; private List.Enumerator <>7__wrap2; private Character 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__2 = null; <>7__wrap2 = default(List.Enumerator); 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown try { int num = <>1__state; int num2; if (num != 0) { if (num != 1) { return false; } <>1__state = -3; num2 = 0; goto IL_0094; } <>1__state = -1; num2 = 0; 5__2 = new WaitForSeconds(0.1f); HealthModifications.ForceUpdateHealth = true; <>7__wrap2 = characters.GetEnumerator(); <>1__state = -3; goto IL_00dd; IL_0094: if (!((Object)(object)5__4 == (Object)null) && !((Object)(object)5__4.m_nview == (Object)null) && 5__4.m_nview.IsValid()) { CreatureSetupControl.CreatureSetupNoDelay(5__4); num2++; 5__4 = null; } goto IL_00dd; IL_00dd: if (<>7__wrap2.MoveNext()) { 5__4 = <>7__wrap2.Current; if (num2 >= ValConfig.NumberOfCacheUpdatesPerFrame.Value) { <>2__current = 5__2; <>1__state = 1; return true; } goto IL_0094; } <>m__Finally1(); <>7__wrap2 = default(List.Enumerator); HealthModifications.ForceUpdateHealth = false; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap2).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static DataObjects.CreatureLevelSettings SLE_Level_Settings = DefaultConfiguration; public static readonly DataObjects.CreatureLevelSettings DefaultConfiguration = new DataObjects.CreatureLevelSettings { DefaultCreatureLevelUpChance = new SortedDictionary { { 1, 20f }, { 2, 10f }, { 3, 5f }, { 4, 2f }, { 5, 1f }, { 6, 0.5f }, { 7, 0.25f }, { 8, 0.125f }, { 9, 0.0625f }, { 10, 0.0312f }, { 11, 0.0156f }, { 12, 0.0078f }, { 13, 0.0039f }, { 14, 0.0019f }, { 15, 0.0015f }, { 16, 0.001f }, { 17, 0.0009f }, { 18, 0.0008f }, { 19, 0.0007f }, { 20, 0.0006f }, { 21, 0.0005f }, { 22, 0.0004f }, { 23, 0.0003f }, { 24, 0.0002f }, { 25, 0.0001f } }, BiomeConfiguration = new Dictionary { { (Biome)895, new DataObjects.BiomeSpecificSetting { SpawnRateModifier = 1.1f, DistanceScaleModifier = 1.5f, DamageRecievedModifiers = new Dictionary { { DataObjects.DamageType.Poison, 1.5f } }, NightSettings = new DataObjects.BiomeNightSettings { NightLevelUpChanceScaler = 1.5f } } }, { (Biome)1, new DataObjects.BiomeSpecificSetting { BiomeMaxLevelOverride = 4 } }, { (Biome)8, new DataObjects.BiomeSpecificSetting { BiomeMaxLevelOverride = 6 } }, { (Biome)2, new DataObjects.BiomeSpecificSetting { BiomeMaxLevelOverride = 10 } }, { (Biome)4, new DataObjects.BiomeSpecificSetting { BiomeMaxLevelOverride = 14 } }, { (Biome)16, new DataObjects.BiomeSpecificSetting { BiomeMaxLevelOverride = 18 } }, { (Biome)512, new DataObjects.BiomeSpecificSetting { BiomeMaxLevelOverride = 22 } }, { (Biome)32, new DataObjects.BiomeSpecificSetting { DistanceScaleModifier = 0.5f, BiomeMaxLevelOverride = 26 } }, { (Biome)64, new DataObjects.BiomeSpecificSetting { DistanceScaleModifier = 0.5f, BiomeMaxLevelOverride = 26 } } }, CreatureConfiguration = new Dictionary { { "piece_TrainingDummy", new DataObjects.CreatureSpecificSetting { CreatureMaxLevelOverride = 11, SpawnRateModifier = 1f, CreatureBaseValueModifiers = new Dictionary { { DataObjects.CreatureBaseAttribute.BaseHealth, 1.05f }, { DataObjects.CreatureBaseAttribute.BaseDamage, 0.95f }, { DataObjects.CreatureBaseAttribute.Speed, 1.05f }, { DataObjects.CreatureBaseAttribute.Size, 1.05f }, { DataObjects.CreatureBaseAttribute.AttackSpeed, 1.05f } }, CreaturePerLevelValueModifiers = new Dictionary { { DataObjects.CreaturePerLevelAttribute.HealthPerLevel, 0.3f }, { DataObjects.CreaturePerLevelAttribute.DamagePerLevel, 0.05f }, { DataObjects.CreaturePerLevelAttribute.SizePerLevel, 0.005f } }, CustomCreatureLevelUpChance = new SortedDictionary { { 1, 100f }, { 2, 100f }, { 3, 0f } } } }, { "Lox", new DataObjects.CreatureSpecificSetting { CreaturePerLevelValueModifiers = new Dictionary { { DataObjects.CreaturePerLevelAttribute.SpeedPerLevel, -0.01f } } } }, { "Troll", new DataObjects.CreatureSpecificSetting { SpawnRateModifier = 1f, CreaturePerLevelValueModifiers = new Dictionary { { DataObjects.CreaturePerLevelAttribute.SizePerLevel, 0.05f } } } }, { "Bjorn", new DataObjects.CreatureSpecificSetting { SpawnRateModifier = 1f, CreaturePerLevelValueModifiers = new Dictionary { { DataObjects.CreaturePerLevelAttribute.SizePerLevel, 0.05f } } } }, { "GoblinBruteBros", new DataObjects.CreatureSpecificSetting { SpawnRateModifier = 1f } }, { "GoblinShaman_Hildir", new DataObjects.CreatureSpecificSetting { SpawnRateModifier = 1f } }, { "GoblinBrute_Hildir", new DataObjects.CreatureSpecificSetting { SpawnRateModifier = 1f } }, { "Skeleton_Hildir", new DataObjects.CreatureSpecificSetting { SpawnRateModifier = 1f } }, { "Fenring_Cultist_Hildir", new DataObjects.CreatureSpecificSetting { SpawnRateModifier = 1f } }, { "Charred_Melee_Dyrnwyn", new DataObjects.CreatureSpecificSetting { SpawnRateModifier = 1f } } }, EnableDistanceLevelBonus = true, DistanceLevelBonus = new SortedDictionary> { { 750, new SortedDictionary { { 1, 15f }, { 2, 5f }, { 3, 1f } } }, { 1200, new SortedDictionary { { 1, 18f }, { 2, 7f }, { 3, 1.5f }, { 4, 0.5f } } }, { 2000, new SortedDictionary { { 1, 24f }, { 2, 10f }, { 3, 3f }, { 4, 1f }, { 5, 0.5f } } }, { 3000, new SortedDictionary { { 1, 32f }, { 2, 16f }, { 3, 8f }, { 4, 4f }, { 5, 2f }, { 6, 1f } } }, { 4000, new SortedDictionary { { 1, 40f }, { 2, 25f }, { 3, 12f }, { 4, 6f }, { 5, 3f }, { 6, 2f }, { 7, 1f }, { 8, 0.5f } } }, { 5000, new SortedDictionary { { 1, 50f }, { 2, 35f }, { 3, 18f }, { 4, 9f }, { 5, 6f }, { 6, 3f }, { 7, 2f }, { 8, 1f }, { 9, 0.5f }, { 10, 0.25f } } }, { 6000, new SortedDictionary { { 1, 60f }, { 2, 40f }, { 3, 20f }, { 4, 10f }, { 5, 8f }, { 6, 6f }, { 7, 4f }, { 8, 2f }, { 9, 1f }, { 10, 0.5f }, { 11, 0.25f }, { 12, 0.12f } } }, { 7000, new SortedDictionary { { 1, 70f }, { 2, 50f }, { 3, 25f }, { 4, 12f }, { 5, 10f }, { 6, 8f }, { 7, 6f }, { 8, 4f }, { 9, 2f }, { 10, 1f }, { 11, 0.5f }, { 12, 0.25f }, { 13, 0.12f }, { 14, 0.06f } } }, { 8000, new SortedDictionary { { 1, 80f }, { 2, 60f }, { 3, 40f }, { 4, 20f }, { 5, 15f }, { 6, 12f }, { 7, 10f }, { 8, 8f }, { 9, 6f }, { 10, 4f }, { 11, 2f }, { 12, 1f }, { 13, 0.5f }, { 14, 0.25f }, { 15, 0.12f }, { 16, 0.06f } } }, { 9100, new SortedDictionary { { 1, 100f }, { 2, 80f }, { 3, 60f }, { 4, 40f }, { 5, 30f }, { 6, 20f }, { 7, 16f }, { 8, 14f }, { 9, 12f }, { 10, 10f }, { 11, 8f }, { 12, 4f }, { 13, 2f }, { 14, 1f }, { 15, 0.5f }, { 16, 0.25f }, { 17, 0.12f }, { 18, 0.06f } } } } }; internal static void Init() { SLE_Level_Settings = DefaultConfiguration; Colorization.UpdateMapColorSelection(); try { UpdateYamlConfig(File.ReadAllText(ValConfig.levelsFilePath)); } catch (Exception arg) { Logger.LogWarning((object)$"There was an error updating the Creature Level values, defaults will be used. Exception: {arg}"); } } public static string YamlDefaultConfig() { return DataObjects.yamlserializer.Serialize((object)DefaultConfiguration); } public static bool UpdateYamlConfig(string yaml) { try { SLE_Level_Settings = DataObjects.yamldeserializer.Deserialize(yaml); Logger.LogDebug("Loaded new Star Level Creature settings, updating loaded creatures..."); DistanceScaleSystem.DelayedMinimapSetup(); CompositeLazyCache.FlushCache(); ((MonoBehaviour)TaskRunner.Run()).StartCoroutine(UpdateCreatureAttributes(new List(Resources.FindObjectsOfTypeAll()))); } catch (Exception ex) { StarLevelSystem.Log.LogError((object)("Failed to parse CreatureLevelSettings YAML: " + ex.Message)); return false; } return true; } [IteratorStateMachine(typeof(d__5))] internal static IEnumerator UpdateCreatureAttributes(List characters) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { characters = characters }; } } public static class LootSystemData { public static DataObjects.LootSettings DefaultDropConfiguration = new DataObjects.LootSettings { characterSpecificLoot = new Dictionary> { { "BlobElite", new List { new DataObjects.ExtendedCharacterDrop { Drop = new DataObjects.Drop { Prefab = "Ooze", Min = 2, Max = 3 }, AmountScaleFactor = 0.5f }, new DataObjects.ExtendedCharacterDrop { Drop = new DataObjects.Drop { Prefab = "IronScrap", Min = 1, Max = 1, Chance = 0.33f }, AmountScaleFactor = 0.2f }, new DataObjects.ExtendedCharacterDrop { Drop = new DataObjects.Drop { Prefab = "TrophyBlob", Min = 1, Max = 1, Chance = 0.1f }, ChanceScaleFactor = 0.01f, MaxScaledAmount = 1 }, new DataObjects.ExtendedCharacterDrop { Drop = new DataObjects.Drop { Prefab = "Blob", Min = 2, Max = 2 }, AmountScaleFactor = 0.5f, MaxScaledAmount = 6 } } }, { "GoblinBruteBros", new List { new DataObjects.ExtendedCharacterDrop { Drop = new DataObjects.Drop { Prefab = "GoblinShaman_Hildir", Min = 1, Max = 1, Chance = 1f, DontScale = true }, DoesNotScale = true }, new DataObjects.ExtendedCharacterDrop { Drop = new DataObjects.Drop { Prefab = "TrophyGoblinBruteBrosBrute", Min = 1, Max = 1, Chance = 1f, DontScale = true }, DoesNotScale = true } } }, { "Tick", new List { new DataObjects.ExtendedCharacterDrop { Drop = new DataObjects.Drop { Prefab = "GiantBloodSack", Min = 1, Max = 1, Chance = 1f }, AmountScaleFactor = 0.5f }, new DataObjects.ExtendedCharacterDrop { Drop = new DataObjects.Drop { Prefab = "TrophyTick", Min = 1, Max = 1, Chance = 0.05f }, ChanceScaleFactor = 0.01f, MaxScaledAmount = 1 } } } }, nonCharacterSpecificLoot = new Dictionary> { { "caverock_ice_stalagtite_falling", new List { new DataObjects.ExtendedObjectDrop { Drop = new DataObjects.Drop { Prefab = "Crystal", Min = 1, Max = 3, Chance = 0.3f, DontScale = true } } } }, { "EvilHeart_Forest", new List { new DataObjects.ExtendedObjectDrop { Drop = new DataObjects.Drop { Prefab = "AncientSeed", Min = 1, Max = 1, OnePerPlayer = true }, MaxScaledAmount = 3 } } } }, EnableDistanceLootModifier = true, DistanceLootModifier = new SortedDictionary { { 1250, new DataObjects.DistanceLootModifier { ChanceScaleFactorBonus = 0f, MinAmountScaleFactorBonus = 0.02f, MaxAmountScaleFactorBonus = 0.02f } }, { 2500, new DataObjects.DistanceLootModifier { ChanceScaleFactorBonus = 0f, MinAmountScaleFactorBonus = 0.05f, MaxAmountScaleFactorBonus = 0.05f } }, { 3750, new DataObjects.DistanceLootModifier { ChanceScaleFactorBonus = 0f, MinAmountScaleFactorBonus = 0.08f, MaxAmountScaleFactorBonus = 0.08f } }, { 5000, new DataObjects.DistanceLootModifier { ChanceScaleFactorBonus = 0f, MinAmountScaleFactorBonus = 0.12f, MaxAmountScaleFactorBonus = 0.12f } }, { 6250, new DataObjects.DistanceLootModifier { ChanceScaleFactorBonus = 0f, MinAmountScaleFactorBonus = 0.15f, MaxAmountScaleFactorBonus = 0.15f } }, { 7500, new DataObjects.DistanceLootModifier { ChanceScaleFactorBonus = 0f, MinAmountScaleFactorBonus = 0.2f, MaxAmountScaleFactorBonus = 0.2f } }, { 8750, new DataObjects.DistanceLootModifier { ChanceScaleFactorBonus = 0f, MinAmountScaleFactorBonus = 0.35f, MaxAmountScaleFactorBonus = 0.35f } } } }; public static DataObjects.LootSettings SLS_Drop_Settings { get; set; } internal static void Init() { SLS_Drop_Settings = DefaultDropConfiguration; try { UpdateYamlConfig(File.ReadAllText(ValConfig.creatureLootFilePath)); } catch (Exception arg) { SLS_Drop_Settings = DefaultDropConfiguration; Logger.LogWarning((object)$"There was an error updating the Loot Level values, defaults will be used. Exception: {arg}"); } } public static string YamlDefaultConfig() { return DataObjects.yamlserializer.Serialize((object)DefaultDropConfiguration); } internal static void AttachPrefabsWhenReady() { AttachLootPrefabs(SLS_Drop_Settings); } public static void AttachLootPrefabs(DataObjects.LootSettings lootconfig) { if (lootconfig == null) { return; } if (lootconfig.characterSpecificLoot != null) { foreach (KeyValuePair> item in lootconfig.characterSpecificLoot) { foreach (DataObjects.ExtendedCharacterDrop item2 in item.Value) { item2.ToCharacterDrop(); } } } if (lootconfig.nonCharacterSpecificLoot == null) { return; } foreach (KeyValuePair> item3 in lootconfig.nonCharacterSpecificLoot) { foreach (DataObjects.ExtendedObjectDrop item4 in item3.Value) { item4.ResolveDropPrefab(); } } } public static bool UpdateYamlConfig(string yaml) { try { SLS_Drop_Settings = DataObjects.yamldeserializer.Deserialize(yaml); AttachLootPrefabs(SLS_Drop_Settings); Logger.LogDebug("Loaded new Creature loot configuration."); } catch (Exception ex) { StarLevelSystem.Log.LogError((object)("Failed to parse LootLevelSettings YAML: " + ex.Message)); return false; } return true; } } public static class RaidsData { public static DataObjects.RaidConfiguration SLE_Raid_Settings = DefaultConfiguration; internal static Dictionary RaidsByName = new Dictionary(); public static readonly DataObjects.RaidConfiguration DefaultConfiguration = new DataObjects.RaidConfiguration { GlobalSettings = new DataObjects.GlobalRaidSettings { DisableAllRaids = false, GlobalRaidIntervalScalar = 1f, GlobalRaidChanceScalar = 1f }, Raids = new List { new DataObjects.RaidDefinition { Name = "army_eikthyr", Duration = 180f, StartMessage = "$event_eikthyrarmy_start", EndMessage = "$event_eikthyrarmy_end", ForceMusic = DataObjects.Music.Zcombat, ForceEnvironment = DataObjects.Environment.Misty, Activation = new DataObjects.RaidActivation { NearBaseOnly = true, Chance = 50f, RequiredGlobalKeys = new List { "defeated_eikthyr" }, NotRequiredGlobalKeys = new List { "defeated_gdking" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Greyling", MaxSpawned = 4, SpawnInterval = 4f, SpawnChance = 100f, LevelMin = 1, LevelMax = 5, CreatureAI = DataObjects.AI.HuntPlayer }, new DataObjects.RaidSpawnEntry { PrefabName = "Neck", MaxSpawned = 2, SpawnInterval = 6f, SpawnChance = 100f, LevelMin = 1, LevelMax = 5, CreatureAI = DataObjects.AI.Alerted }, new DataObjects.RaidSpawnEntry { PrefabName = "Boar", MaxSpawned = 2, SpawnInterval = 6f, SpawnChance = 100f, LevelMin = 1, LevelMax = 5, CreatureAI = DataObjects.AI.Alerted } } }, new DataObjects.RaidDefinition { Name = "foresttrolls", Duration = 180f, StartMessage = "$event_foresttrolls_start", EndMessage = "$event_foresttrolls_end", ForceMusic = DataObjects.Music.Zcombat, ForceEnvironment = DataObjects.Environment.DeepForest_Mist, Activation = new DataObjects.RaidActivation { NearBaseOnly = true, Chance = 50f, RequiredGlobalKeys = new List { "defeated_eikthyr" }, NotRequiredGlobalKeys = new List { "defeated_bonemass" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Troll", MaxSpawned = 3, SpawnInterval = 30f, SpawnChance = 100f, LevelMin = 1, LevelMax = 3, CreatureAI = DataObjects.AI.AgitatedByBuild, SpawnGroupSize = 2, CustomCreatureLevelUpChance = new SortedDictionary { { 1, 50f }, { 2, 25f }, { 3, 20f }, { 4, 15f }, { 5, 7f }, { 6, 3f }, { 7, 1f } } } } }, new DataObjects.RaidDefinition { Name = "army_theelder", Duration = 180f, StartMessage = "$event_gdkingarmy_start", EndMessage = "$event_gdkingarmy_end", ForceEnvironment = DataObjects.Environment.DeepForest_Mist, ForceMusic = DataObjects.Music.Zcombat, Activation = new DataObjects.RaidActivation { NearBaseOnly = true, Chance = 50f, RequiredGlobalKeys = new List { "defeated_gdking" }, NotRequiredGlobalKeys = new List { "defeated_bonemass" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Greydwarf", MaxSpawned = 6, SpawnInterval = 3f, SpawnChance = 100f, LevelMin = 1, LevelMax = 5, CreatureAI = DataObjects.AI.HuntPlayer, SpawnGroupSize = 3 }, new DataObjects.RaidSpawnEntry { PrefabName = "Greydwarf_Elite", MaxSpawned = 2, SpawnInterval = 8f, SpawnChance = 100f, LevelMin = 1, LevelMax = 5, CreatureAI = DataObjects.AI.AgitatedByBuild }, new DataObjects.RaidSpawnEntry { PrefabName = "Greydwarf_Shaman", MaxSpawned = 2, SpawnInterval = 8f, SpawnChance = 100f, LevelMin = 1, LevelMax = 5, CreatureAI = DataObjects.AI.Alerted } } }, new DataObjects.RaidDefinition { Name = "skeletons", Duration = 90f, StartMessage = "$event_skeletons_start", EndMessage = "$event_skeletons_end", ForceEnvironment = DataObjects.Environment.Crypt, ForceMusic = DataObjects.Music.Zcombat, Activation = new DataObjects.RaidActivation { Chance = 50f, RequiredGlobalKeys = new List { "defeated_gdking" }, NotRequiredGlobalKeys = new List { "defeated_bonemass" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Skeleton", MaxSpawned = 6, SpawnInterval = 4f, SpawnChance = 100f, UseRaidLevelSystem = false, CreatureAI = DataObjects.AI.Alerted, SpawnGroupSize = 3 }, new DataObjects.RaidSpawnEntry { PrefabName = "Skeleton_Poison", MaxSpawned = 2, SpawnInterval = 6f, SpawnChance = 100f, UseRaidLevelSystem = false, CreatureAI = DataObjects.AI.Alerted } } }, new DataObjects.RaidDefinition { Name = "blobs", Duration = 90f, StartMessage = "$event_blobs_start", EndMessage = "$event_blobs_over", ForceEnvironment = DataObjects.Environment.SwampRain, ForceMusic = DataObjects.Music.Zcombat, Activation = new DataObjects.RaidActivation { NearBaseOnly = true, Chance = 50f, RequiredGlobalKeys = new List { "defeated_gdking" }, NotRequiredGlobalKeys = new List { "defeated_bonemass" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Blob", MaxSpawned = 4, SpawnInterval = 4f, SpawnChance = 100f, LevelMin = 1, LevelMax = 12, CreatureAI = DataObjects.AI.HuntPlayer, SpawnGroupSize = 2 }, new DataObjects.RaidSpawnEntry { PrefabName = "BlobElite", MaxSpawned = 2, SpawnInterval = 8f, SpawnChance = 100f, LevelMin = 1, LevelMax = 12, CreatureAI = DataObjects.AI.HuntPlayer } } }, new DataObjects.RaidDefinition { Name = "ghosts", Duration = 180f, StartMessage = "$event_ghosts_start", EndMessage = "$event_ghosts_end", ForceEnvironment = DataObjects.Environment.Ghosts, ForceMusic = DataObjects.Music.Zcombat, Activation = new DataObjects.RaidActivation { Chance = 50f, RequiredGlobalKeys = new List { "defeated_bonemass" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Ghost", MaxSpawned = 3, SpawnInterval = 30f, SpawnChance = 100f, LevelMin = 1, LevelMax = 16, CreatureAI = DataObjects.AI.AgitatedByBuild }, new DataObjects.RaidSpawnEntry { PrefabName = "Wraith", MaxSpawned = 3, SpawnInterval = 30f, SpawnChance = 100f, LevelMin = 1, LevelMax = 16, CreatureAI = DataObjects.AI.AgitatedByBuild } } }, new DataObjects.RaidDefinition { Name = "surtlings", Duration = 60f, StartMessage = "$event_surtlings_start", EndMessage = "$event_surtlings_end", ForceEnvironment = DataObjects.Environment.Ashlands_CinderRain, ForceMusic = DataObjects.Music.Zcombat, Activation = new DataObjects.RaidActivation { Biomes = new List { (Biome)2, (Biome)1, (Biome)8 }, NearBaseOnly = true, RequiredGlobalKeys = new List { "defeated_gdking" }, NotRequiredGlobalKeys = new List { "defeated_bonemass" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Surtling", MaxSpawned = 4, SpawnInterval = 4f, SpawnChance = 100f, UseRaidLevelSystem = false, CreatureAI = DataObjects.AI.HuntPlayer, SpawnGroupSize = 2, RequiredModifiers = new Dictionary { { "Fire", DataObjects.ModifierType.Major } } } } }, new DataObjects.RaidDefinition { Name = "army_bonemass", Duration = 180f, StartMessage = "$event_bonemassarmy_start", EndMessage = "$event_bonemassarmy_end", ForceMusic = DataObjects.Music.Zcombat, ForceEnvironment = DataObjects.Environment.SwampRain, Activation = new DataObjects.RaidActivation { NearBaseOnly = true, Chance = 50f, RequiredGlobalKeys = new List { "defeated_bonemass" }, NotRequiredGlobalKeys = new List { "defeated_dragon" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Skeleton", MaxSpawned = 4, SpawnInterval = 4f, SpawnChance = 100f, LevelMin = 1, LevelMax = 12, CreatureAI = DataObjects.AI.Alerted, SpawnGroupSize = 2 }, new DataObjects.RaidSpawnEntry { PrefabName = "Blob", MaxSpawned = 2, SpawnInterval = 6f, SpawnChance = 100f, LevelMin = 1, LevelMax = 12, CreatureAI = DataObjects.AI.Alerted }, new DataObjects.RaidSpawnEntry { PrefabName = "Draugr", MaxSpawned = 3, SpawnInterval = 6f, SpawnChance = 100f, LevelMin = 1, LevelMax = 12, CreatureAI = DataObjects.AI.AgitatedByBuild, SpawnGroupSize = 2 }, new DataObjects.RaidSpawnEntry { PrefabName = "Draugr_Elite", MaxSpawned = 1, SpawnInterval = 10f, SpawnChance = 100f, LevelMin = 1, LevelMax = 12, CreatureAI = DataObjects.AI.HuntPlayer }, new DataObjects.RaidSpawnEntry { PrefabName = "Draugr_Ranged", MaxSpawned = 2, SpawnInterval = 8f, SpawnChance = 100f, LevelMin = 1, LevelMax = 12, CreatureAI = DataObjects.AI.HuntPlayer } } }, new DataObjects.RaidDefinition { Name = "wolves", Duration = 60f, StartMessage = "$event_wolves_start", EndMessage = "$event_wolves_end", ForceMusic = DataObjects.Music.Zcombat, ForceEnvironment = DataObjects.Environment.SnowStorm, Activation = new DataObjects.RaidActivation { Chance = 50f, RequiredGlobalKeys = new List { "defeated_bonemass" }, NotRequiredGlobalKeys = new List { "defeated_dragon" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Wolf", MaxSpawned = 5, SpawnInterval = 4f, SpawnChance = 100f, LevelMin = 1, LevelMax = 16, CreatureAI = DataObjects.AI.HuntPlayer, SpawnGroupSize = 3 }, new DataObjects.RaidSpawnEntry { PrefabName = "Fenring", MaxSpawned = 1, SpawnInterval = 12f, SpawnChance = 100f, LevelMin = 1, LevelMax = 16, CreatureAI = DataObjects.AI.HuntPlayer } } }, new DataObjects.RaidDefinition { Name = "cultists", Duration = 180f, StartMessage = "$event_caves_start", EndMessage = "$event_caves_end", ForceMusic = DataObjects.Music.Zcombat, ForceEnvironment = DataObjects.Environment.SnowStorm, Activation = new DataObjects.RaidActivation { NearBaseOnly = true, Chance = 50f, RequiredGlobalKeys = new List { "defeated_dragon" }, NotRequiredGlobalKeys = new List { "defeated_queen" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Ulv", MaxSpawned = 5, SpawnInterval = 4f, SpawnChance = 100f, LevelMin = 1, LevelMax = 20, CreatureAI = DataObjects.AI.HuntPlayer, SpawnGroupSize = 3 }, new DataObjects.RaidSpawnEntry { PrefabName = "Fenring_Cultist", MaxSpawned = 2, SpawnInterval = 12f, SpawnChance = 100f, LevelMin = 1, LevelMax = 20, CreatureAI = DataObjects.AI.HuntPlayer } } }, new DataObjects.RaidDefinition { Name = "army_moder", Duration = 180f, StartMessage = "$event_moderarmy_start", EndMessage = "$event_moderarmy_end", ForceMusic = DataObjects.Music.Zcombat, ForceEnvironment = DataObjects.Environment.Twilight_Snow, Activation = new DataObjects.RaidActivation { NearBaseOnly = true, Chance = 50f, RequiredGlobalKeys = new List { "defeated_dragon" }, NotRequiredGlobalKeys = new List { "defeated_goblinking" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Hatchling", MaxSpawned = 3, SpawnInterval = 6f, SpawnChance = 100f, LevelMin = 1, LevelMax = 16, CreatureAI = DataObjects.AI.HuntPlayer, SpawnGroupSize = 2 }, new DataObjects.RaidSpawnEntry { PrefabName = "Wolf", MaxSpawned = 3, SpawnInterval = 6f, SpawnChance = 100f, LevelMin = 1, LevelMax = 16, CreatureAI = DataObjects.AI.HuntPlayer, SpawnGroupSize = 3 }, new DataObjects.RaidSpawnEntry { PrefabName = "Fenring_Cultist", MaxSpawned = 1, SpawnInterval = 12f, SpawnChance = 100f, LevelMin = 1, LevelMax = 16, CreatureAI = DataObjects.AI.AgitatedByBuild } } }, new DataObjects.RaidDefinition { Name = "army_goblin", Duration = 180f, StartMessage = "$event_goblinarmy_start", EndMessage = "$event_goblinarmy_end", ForceEnvironment = DataObjects.Environment.GoblinKing, ForceMusic = DataObjects.Music.Zcombat, Activation = new DataObjects.RaidActivation { NearBaseOnly = true, Chance = 50f, RequiredGlobalKeys = new List { "defeated_goblinking" }, NotRequiredGlobalKeys = new List { "defeated_queen" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Goblin", MaxSpawned = 4, SpawnInterval = 4f, SpawnChance = 100f, LevelMin = 1, LevelMax = 20, CreatureAI = DataObjects.AI.HuntPlayer, SpawnGroupSize = 2 }, new DataObjects.RaidSpawnEntry { PrefabName = "GoblinArcher", MaxSpawned = 2, SpawnInterval = 6f, SpawnChance = 100f, LevelMin = 1, LevelMax = 20, CreatureAI = DataObjects.AI.HuntPlayer }, new DataObjects.RaidSpawnEntry { PrefabName = "GoblinShaman", MaxSpawned = 1, SpawnInterval = 10f, SpawnChance = 100f, LevelMin = 1, LevelMax = 20, CreatureAI = DataObjects.AI.Alerted }, new DataObjects.RaidSpawnEntry { PrefabName = "GoblinBrute", MaxSpawned = 1, SpawnInterval = 12f, SpawnChance = 100f, LevelMin = 1, LevelMax = 20, CreatureAI = DataObjects.AI.AgitatedByBuild } } }, new DataObjects.RaidDefinition { Name = "bats", Duration = 60f, StartMessage = "$event_bats_start", EndMessage = "$event_bats_end", ForceEnvironment = DataObjects.Environment.GoblinKing, ForceMusic = DataObjects.Music.Zcombat, Activation = new DataObjects.RaidActivation { Chance = 50f, RequiredGlobalKeys = new List { "defeated_goblinking" }, NotRequiredGlobalKeys = new List { "defeated_queen" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Bat", MaxSpawned = 12, SpawnInterval = 3f, SpawnChance = 100f, LevelMin = 1, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer, SpawnGroupSize = 3 } } }, new DataObjects.RaidDefinition { Name = "gjall_ambush", Duration = 90f, StartMessage = "$event_gjallarmy_start", EndMessage = "$event_gjallarmy_end", ForceMusic = DataObjects.Music.Zcombat, ForceEnvironment = DataObjects.Environment.Mistlands_thunder, Activation = new DataObjects.RaidActivation { NearBaseOnly = true, Chance = 50f, RequiredGlobalKeys = new List { "defeated_queen" }, NotRequiredGlobalKeys = new List { "defeated_fader" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Gjall", MaxSpawned = 2, SpawnInterval = 12f, SpawnChance = 100f, LevelMin = 1, LevelMax = 26, CreatureAI = DataObjects.AI.AgitatedByBuild }, new DataObjects.RaidSpawnEntry { PrefabName = "Tick", MaxSpawned = 8, SpawnInterval = 8f, SpawnChance = 100f, LevelMin = 1, LevelMax = 26, CreatureAI = DataObjects.AI.HuntPlayer, SpawnGroupSize = 2, ModifiersNotAllowed = new List { "FireNova" } } } }, new DataObjects.RaidDefinition { Name = "army_seekers", Duration = 180f, StartMessage = "$event_seekerarmy_start", EndMessage = "$event_seekerarmy_end", ForceEnvironment = DataObjects.Environment.Mistlands_thunder, ForceMusic = DataObjects.Music.Zcombat, Activation = new DataObjects.RaidActivation { NearBaseOnly = true, Chance = 50f, RequiredGlobalKeys = new List { "defeated_queen" }, NotRequiredGlobalKeys = new List { "defeated_fader" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Seeker", MaxSpawned = 4, SpawnInterval = 4f, SpawnChance = 100f, LevelMin = 1, LevelMax = 26, CreatureAI = DataObjects.AI.HuntPlayer }, new DataObjects.RaidSpawnEntry { PrefabName = "SeekerBrute", MaxSpawned = 1, SpawnInterval = 12f, SpawnChance = 100f, LevelMin = 1, LevelMax = 26, CreatureAI = DataObjects.AI.AgitatedByBuild }, new DataObjects.RaidSpawnEntry { PrefabName = "Tick", MaxSpawned = 2, SpawnInterval = 8f, SpawnChance = 100f, LevelMin = 1, LevelMax = 26, CreatureAI = DataObjects.AI.HuntPlayer } } }, new DataObjects.RaidDefinition { Name = "army_charred", Duration = 180f, StartMessage = "$event_charredarmy_start", EndMessage = "$event_charredarmy_end", ForceEnvironment = DataObjects.Environment.Ashlands_storm, ForceMusic = DataObjects.Music.Zcombat, Activation = new DataObjects.RaidActivation { NearBaseOnly = true, Chance = 50f, RequiredGlobalKeys = new List { "defeated_queen" }, NotRequiredGlobalKeys = new List { "defeated_fader" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Charred_Twitcher", MaxSpawned = 6, SpawnInterval = 4f, SpawnChance = 100f, LevelMin = 1, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer, SpawnGroupSize = 3 }, new DataObjects.RaidSpawnEntry { PrefabName = "Charred_Archer", MaxSpawned = 2, SpawnInterval = 12f, SpawnChance = 100f, LevelMin = 1, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer }, new DataObjects.RaidSpawnEntry { PrefabName = "Charred_Melee", MaxSpawned = 2, SpawnInterval = 8f, SpawnChance = 100f, LevelMin = 1, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer } } }, new DataObjects.RaidDefinition { Name = "army_charred_spawners", Duration = 90f, StartMessage = "event_charredspawnerarmy_start", EndMessage = "event_charrespawnerarmy_end", ForceEnvironment = DataObjects.Environment.Ashlands_ashrain, ForceMusic = DataObjects.Music.Zcombat, Activation = new DataObjects.RaidActivation { NearBaseOnly = true, Chance = 50f, RequiredGlobalKeys = new List { "defeated_queen" }, NotRequiredGlobalKeys = new List { "defeated_fader" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Spawner_CharredStone", MaxSpawned = 4, SpawnInterval = 4f, SpawnChance = 100f, LevelMin = 1, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer } } }, new DataObjects.RaidDefinition { Name = "hildir_boss_revenge1", Duration = 180f, StartMessage = "$event_hildirboss1_start", EndMessage = "$event_hildirboss1_end", ForceMusic = DataObjects.Music.ZCombatEventL2, ForceEnvironment = DataObjects.Environment.Ashlands_ashrain, Activation = new DataObjects.RaidActivation { Chance = 50f, RequiredGlobalKeys = new List { "hildir1" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Skeleton_Hildir", MaxSpawned = 1, SpawnInterval = 4f, SpawnChance = 100f, LevelMin = 1, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer }, new DataObjects.RaidSpawnEntry { PrefabName = "Skeleton", MaxSpawned = 8, SpawnInterval = 6f, SpawnChance = 100f, LevelMin = 1, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer, SpawnGroupSize = 3 }, new DataObjects.RaidSpawnEntry { PrefabName = "Skeleton_Poison", MaxSpawned = 4, SpawnInterval = 10f, SpawnChance = 100f, LevelMin = 1, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer } } }, new DataObjects.RaidDefinition { Name = "hildir_boss_revenge2", Duration = 180f, StartMessage = "$event_hildirboss2_start", EndMessage = "$event_hildirboss2_end", ForceMusic = DataObjects.Music.ZCombatEventL3, ForceEnvironment = DataObjects.Environment.Twilight_SnowStorm, Activation = new DataObjects.RaidActivation { Chance = 50f, RequiredGlobalKeys = new List { "hildir2" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "Fenring_Cultist_Hildir", MaxSpawned = 1, SpawnInterval = 4f, SpawnChance = 100f, LevelMin = 1, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer }, new DataObjects.RaidSpawnEntry { PrefabName = "Ulv", MaxSpawned = 6, SpawnInterval = 6f, SpawnChance = 100f, LevelMin = 1, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer, SpawnGroupSize = 3 }, new DataObjects.RaidSpawnEntry { PrefabName = "Fenring_Cultist", MaxSpawned = 2, SpawnInterval = 10f, SpawnChance = 100f, LevelMin = 1, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer } } }, new DataObjects.RaidDefinition { Name = "hildir_boss_revenge3", Duration = 180f, StartMessage = "$event_hildirboss3_start", EndMessage = "$event_hildirboss3_end", ForceMusic = DataObjects.Music.ZCombatEventL4, ForceEnvironment = DataObjects.Environment.GoblinKing, Activation = new DataObjects.RaidActivation { Chance = 50f, RequiredGlobalKeys = new List { "hildir3" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "GoblinBruteBros", MaxSpawned = 1, SpawnInterval = 4f, SpawnChance = 100f, LevelMin = 1, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer }, new DataObjects.RaidSpawnEntry { PrefabName = "Goblin", MaxSpawned = 8, SpawnInterval = 6f, SpawnChance = 100f, LevelMin = 1, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer, SpawnGroupSize = 3 }, new DataObjects.RaidSpawnEntry { PrefabName = "GoblinShaman", MaxSpawned = 2, SpawnInterval = 10f, SpawnChance = 100f, LevelMin = 1, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer } } }, new DataObjects.RaidDefinition { Name = "deathlink_surprise", Duration = 180f, StartMessage = "$SLS_Secret_event1_start", EndMessage = "$SLS_Secret_event1_end", ForceEnvironment = DataObjects.Environment.Mistlands_thunder, ForceMusic = DataObjects.Music.ZCombatEventL4, Activation = new DataObjects.RaidActivation { Chance = 25f, RequiredGlobalKeys = new List { "defeated_fader" }, RequiredPlayerKeys = new List { "Deathlink" } }, Spawns = new List { new DataObjects.RaidSpawnEntry { PrefabName = "GoblinBruteBros", MaxSpawned = 1, SpawnInterval = 180f, SpawnChance = 100f, LevelMin = 15, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer, Faction = (Faction)4 }, new DataObjects.RaidSpawnEntry { PrefabName = "Fenring_Cultist_Hildir", MaxSpawned = 1, SpawnInterval = 180f, SpawnChance = 100f, LevelMin = 20, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer, Faction = (Faction)4 }, new DataObjects.RaidSpawnEntry { PrefabName = "Skeleton_Hildir", MaxSpawned = 1, SpawnInterval = 180f, SpawnChance = 100f, LevelMin = 25, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer, Faction = (Faction)4 }, new DataObjects.RaidSpawnEntry { PrefabName = "Skeleton_Poison", MaxSpawned = 4, SpawnInterval = 10f, SpawnChance = 100f, LevelMin = 20, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer, Faction = (Faction)4 }, new DataObjects.RaidSpawnEntry { PrefabName = "GoblinShaman", MaxSpawned = 2, SpawnInterval = 10f, SpawnChance = 100f, LevelMin = 12, LevelMax = 30, CreatureAI = DataObjects.AI.HuntPlayer, Faction = (Faction)4 } } } } }; internal static void SaveServerRaidData(string data) { ValConfig.GetSavedDataSecondaryConfigDirectoryPath(); File.WriteAllText(ValConfig.raidsServerSavedData, data); } internal static string LoadServerRaidData() { ValConfig.GetSavedDataSecondaryConfigDirectoryPath(); if (File.Exists(ValConfig.raidsServerSavedData)) { return File.ReadAllText(ValConfig.raidsServerSavedData); } return ""; } internal static void Init() { SLE_Raid_Settings = DefaultConfiguration; try { if (File.Exists(ValConfig.raidsFilePath)) { UpdateYamlConfig(File.ReadAllText(ValConfig.raidsFilePath)); return; } SaveServerRaidData(DataObjects.yamlserializer.Serialize((object)RaidControl.ServerPlayerRaidData)); UpdateYamlConfig(File.ReadAllText(ValConfig.raidsFilePath)); } catch (Exception arg) { Logger.LogWarning((object)$"There was an error updating the Raid values, defaults will be used. Exception: {arg}"); } } public static string YamlDefaultConfig() { return DataObjects.yamlserializer.Serialize((object)DefaultConfiguration); } public static bool UpdateYamlConfig(string yaml) { try { Logger.LogDebug("Loaded new Raid settings..."); SLE_Raid_Settings = DataObjects.yamldeserializer.Deserialize(yaml); RaidsByName.Clear(); foreach (DataObjects.RaidDefinition raid in SLE_Raid_Settings.Raids) { if (RaidsByName.ContainsKey(raid.Name)) { Logger.LogWarning("Raid with duplicate name, will be skipped. (" + raid.Name + ")"); } RaidsByName.Add(raid.Name, raid); } RaidControl.ApplyRaidConfiguration(RandEventSystem.instance); } catch (Exception ex) { StarLevelSystem.Log.LogError((object)("Failed to parse RaidSettings YAML: " + ex.Message)); return false; } return true; } } } namespace StarLevelSystem.common { internal static class ConfigFileWatcher { private class WatchEntry { public Action Callback; public DateTime LastWriteUTC { get; set; } public long FileLength { get; set; } public void Update(DateTime lastwrite, long len) { LastWriteUTC = lastwrite; FileLength = len; } } internal class ConfigFileWatcherBehaviour : MonoBehaviour { private float nextPollTime; public void Update() { if (!(Time.unscaledTime < nextPollTime)) { nextPollTime = Time.unscaledTime + ValConfig.ConfigPollIntervalSeconds.Value; Poll(); } } private static void Poll() { if (WatchedFiles.Count == 0) { return; } foreach (string key in WatchedFiles.Keys) { if (!File.Exists(key)) { continue; } FileInfo fileInfo = new FileInfo(key); DateTime lastWriteTimeUtc = fileInfo.LastWriteTimeUtc; long length = fileInfo.Length; WatchEntry watchEntry = WatchedFiles[key]; if (lastWriteTimeUtc == watchEntry.LastWriteUTC && length == watchEntry.FileLength) { continue; } WatchedFiles[key].LastWriteUTC = lastWriteTimeUtc; WatchedFiles[key].FileLength = length; try { if (watchEntry.Callback != null) { watchEntry.Callback(key); } } catch (Exception ex) { Logger.LogWarning("ConfigFileWatcher callback for " + key + " threw: " + ex.Message); } } } } private static Dictionary WatchedFiles = new Dictionary(); private static ConfigFileWatcherBehaviour watchProcess; internal static void Initialize() { //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_001e: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)watchProcess != (Object)null)) { GameObject val = new GameObject("VE_ConfigFileWatcher"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; watchProcess = val.AddComponent(); Logger.LogDebug("ConfigFileWatcher initialized."); } } internal static void Register(string fullPath, Action onChanged) { if (File.Exists(fullPath)) { FileInfo fileInfo = new FileInfo(fullPath); DateTime lastWriteTimeUtc = fileInfo.LastWriteTimeUtc; long length = fileInfo.Length; WatchedFiles.Add(fullPath, new WatchEntry { LastWriteUTC = lastWriteTimeUtc, FileLength = length, Callback = onChanged }); } else { WatchedFiles.Add(fullPath, new WatchEntry { LastWriteUTC = DateTime.MinValue, FileLength = 0L, Callback = onChanged }); } Logger.LogDebug("ConfigFileWatcher watching " + fullPath); } } public class DataObjects { public enum CreatureBaseAttribute { BaseHealth, BaseDamage, AttackSpeed, Speed, Size } public enum CreaturePerLevelAttribute { HealthPerLevel, DamagePerLevel, SpeedPerLevel, AttackSpeedPerLevel, SizePerLevel } public enum DamageType { Blunt, Slash, Pierce, Fire, Frost, Lightning, Poison, Spirit, Chop, Pickaxe } public enum NameSelectionStyle { RandomFirst, RandomLast, RandomBoth } public enum VisualEffectStyle { objectCenter, top, bottom } public enum ModifierType { Major, Minor, Boss } public enum DropType { Tree, Rock, Destructible } public enum LootFactorType { PerLevel, Exponential, ChancePerLevel } public enum DamageEstimateType { Average, Highest, Lowest } public enum AI { HuntPlayer, Alerted, AgitatedByBuild } public enum Music { Zrespawn, Zintro, Zmenu, Zcombat, ZCombatEventL1, ZCombatEventL2, ZCombatEventL3, ZCombatEventL4, Zboss_eikthyr, Zboss_gdking, Zboss_bonemass, Zboss_moder, Zboss_goblinking, Zboss_queen, Zboss_queen_ambience, Zboss_fader, Zmorning, Zevening, Zsailing, Zsailing_ashlands, Zblackforest, Zmeadows, Zswamp, Zmountain, Zplains, Zplainstower, Zmistlands, Zashlands, Zforestcrypt, Zforestcrypthildir, Zfrostcaves, Zfrostcaveshildir, Zhome, Zlocation_forest, Zlocation_haldor, Zlocation_dvergrtower, Zlocation_dvergrexc, Zlocation_ashlands_ruins } public enum Environment { Clear, Misty, Darklands_dark, DeepForest_Mist, Heath_clear, InfectedMine, GDKing, Rain, LightRain, ThunderStorm, Eikthyr, Fader, GoblinKing, nofogts, SwampRain, Bonemass, Snow, SnowStorm, Twilight_Clear, Twilight_Snow, Twilight_SnowStorm, Moder, Crypt, CryptHildir, Ghosts, Queen, SunkenCrypt, Mistlands_clear, Mistlands_rain, Mistlands_thunder, Ashlands_ashrain, Ashlands_ashrain_clear, Ashlands_CinderRain, Ashlands_meteorshower, Ashlands_misty, Ashlands_SeaStorm, Ashlands_storm, Caves, CavesHildir } public class DNum { private static Dictionary _enumReverseLookup = new Dictionary(); private static Dictionary _enumData = new Dictionary(); public DNum() { } public DNum(Array modnames) { foreach (int modname in modnames) { string name = Enum.GetName(typeof(CreatureModifiersData.ModifierNames), modname); _enumData[name] = modname; _enumReverseLookup[modname] = name; } } public DNum(Dictionary initialValues) { Extensions.AddRange(_enumData, initialValues); foreach (KeyValuePair initialValue in initialValues) { _enumReverseLookup[initialValue.Value] = initialValue.Key; } } public void AddValue(string name, int id) { if (_enumData.ContainsKey(name)) { Logger.LogWarning("Tried to add duplicate enum name " + name + " to DNum, skipping."); } _enumData[name] = id; _enumReverseLookup[id] = name; } [CanBeNull] public string GetValue(int id) { if (!_enumReverseLookup.TryGetValue(id, out var value)) { return null; } return value; } public int GetValue(string name) { if (!_enumData.TryGetValue(name, out var value)) { return -1; } return value; } public bool ContainsName(string name) { return _enumData.ContainsKey(name); } public bool ContainsID(int id) { return _enumReverseLookup.ContainsKey(id); } } public class LevelGenerator { public string PrefabName { get; set; } [DefaultValue(1)] public int MaxLevel { get; set; } [DefaultValue(1)] public int MinLevel { get; set; } [DefaultValue(0f)] public float LevelUpChance { get; set; } [DefaultValue(1f)] public float NightMultiplier { get; set; } [DefaultValue(false)] public SortedDictionary GetLevelUpDefinition() { int num = MaxLevel - MinLevel; SortedDictionary sortedDictionary = new SortedDictionary(); if (num >= 0) { sortedDictionary.Add(MinLevel, LevelUpChance); return sortedDictionary; } num += MinLevel; float num2 = LevelUpChance; while (num <= MaxLevel) { sortedDictionary.Add(num, num2); num2 *= LevelUpChance; } return sortedDictionary; } public int RollAndDetermineLevel() { return LevelSelection.DetermineLevelRollResult(Random.Range(0f, 100f), MaxLevel, GetLevelUpDefinition(), new SortedDictionary(), 1f, NightMultiplier); } } public class CreatureLevelSettings { public Dictionary BiomeConfiguration { get; set; } public Dictionary CreatureConfiguration { get; set; } public SortedDictionary DefaultCreatureLevelUpChance { get; set; } public bool EnableDistanceLevelBonus { get; set; } public SortedDictionary> DistanceLevelBonus { get; set; } } public class NightSettings { [DefaultValue(1f)] public float SpawnRateModifier { get; set; } = 1f; [DefaultValue(1f)] public float NightLevelUpChanceScaler { get; set; } = 1f; [DefaultValue(false)] public bool creatureSpawnsDisabled { get; set; } } public class BiomeNightSettings { [DefaultValue(1f)] public float SpawnRateModifier { get; set; } = 1f; [DefaultValue(1f)] public float NightLevelUpChanceScaler { get; set; } = 1f; public List creatureSpawnsDisabled { get; set; } } public class BiomeSpecificSetting { public SortedDictionary CustomCreatureLevelUpChance { get; set; } [DefaultValue(0)] public int BiomeMinLevelOverride { get; set; } public int BiomeMaxLevelOverride { get; set; } [DefaultValue(1f)] public float DistanceScaleModifier { get; set; } = 1f; [DefaultValue(1f)] public float SpawnRateModifier { get; set; } = 1f; public Dictionary CreatureBaseValueModifiers { get; set; } public Dictionary CreaturePerLevelValueModifiers { get; set; } public Dictionary DamageRecievedModifiers { get; set; } public List creatureSpawnsDisabled { get; set; } public BiomeNightSettings NightSettings { get; set; } } public class CreatureSpecificSetting { [DefaultValue(1f)] public float DistanceScaleModifier { get; set; } = 1f; public SortedDictionary CustomCreatureLevelUpChance { get; set; } [DefaultValue(-1)] public int CreatureMinLevelOverride { get; set; } = -1; [DefaultValue(-1)] public int CreatureMaxLevelOverride { get; set; } = -1; [DefaultValue(-1)] public int MaxMajorModifiers { get; set; } = -1; [DefaultValue(-1f)] public float ChanceForMajorModifier { get; set; } = -1f; [DefaultValue(-1)] public int MaxMinorModifiers { get; set; } = -1; [DefaultValue(-1f)] public float ChanceForMinorModifier { get; set; } = -1f; [DefaultValue(-1)] public int MaxBossModifiers { get; set; } = -1; [DefaultValue(-1f)] public float ChanceForBossModifier { get; set; } = -1f; [DefaultValue(1f)] public Dictionary RequiredModifiers { get; set; } public float SpawnRateModifier { get; set; } = 1f; public NightSettings NightSettings { get; set; } public Dictionary CreatureBaseValueModifiers { get; set; } public Dictionary CreaturePerLevelValueModifiers { get; set; } public Dictionary DamageRecievedModifiers { get; set; } } [DataContract] public class CreatureColorizationSettings { public Dictionary> characterSpecificColorization { get; set; } public Dictionary defaultLevelColorization { get; set; } public Dictionary> characterColorGenerators { get; set; } } public class LootSettings { public Dictionary> characterSpecificLoot { get; set; } public Dictionary> nonCharacterSpecificLoot { get; set; } public bool EnableDistanceLootModifier { get; set; } public SortedDictionary DistanceLootModifier { get; set; } } public class DistanceLootModifier { [DefaultValue(0f)] public float MinAmountScaleFactorBonus { get; set; } [DefaultValue(0f)] public float MaxAmountScaleFactorBonus { get; set; } [DefaultValue(0f)] public float ChanceScaleFactorBonus { get; set; } } public class ProbabilityEntry { public string Name { get; set; } [DefaultValue(1f)] public float SelectionWeight { get; set; } = 1f; } public class CreatureModifierConfiguration { [DefaultValue(1f)] public float SelectionWeight { get; set; } = 1f; public CreatureModConfig Config { get; set; } = new CreatureModConfig(); public List AllowedCreatures { get; set; } public List UnallowedCreatures { get; set; } public List AllowedBiomes { get; set; } } public class CreatureModifierDefinition { public NameSelectionStyle namingConvention { get; set; } = NameSelectionStyle.RandomBoth; public string NamePrefix { get; set; } public string NameSuffix { get; set; } public string StarVisual { get; set; } public string VisualEffect { get; set; } public string SecondaryEffect { get; set; } public VisualEffectStyle VisualEffectStyle { get; set; } public Delegate SetupEvent { get; set; } public Delegate RunOnceEvent { get; set; } public bool FromAPI { get; set; } public Sprite StarVisualAPI { get; set; } public GameObject VisualEffectAPI { get; set; } public GameObject SecondaryEffectAPI { get; set; } public void LoadAndSetGameObjects() { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown if (FromAPI) { LoadAPIGameObjects(); return; } if (StarVisual != null && !CreatureModifiersData.LoadedModifierSprites.ContainsKey(StarVisual)) { string text = "assets/custom/starlevels/icons/" + StarVisual + ".png"; if (ValConfig.UseStarShapedModifierIcons.Value) { text = "assets/custom/starlevels/icons2/" + StarVisual + ".png"; } Sprite value = StarLevelSystem.EmbeddedResourceBundle.LoadAsset(text); CreatureModifiersData.LoadedModifierSprites.Add(StarVisual, value); } if (VisualEffect != null && !CreatureModifiersData.LoadedModifierEffects.ContainsKey(VisualEffect)) { CustomPrefab val = new CustomPrefab(StarLevelSystem.EmbeddedResourceBundle.LoadAsset(VisualEffect), true); PrefabManager.Instance.AddPrefab(val); GameObject prefab = PrefabManager.Instance.GetPrefab(VisualEffect); CreatureModifiersData.LoadedModifierEffects.Add(VisualEffect, prefab); } if (SecondaryEffect != null && !CreatureModifiersData.LoadedSecondaryEffects.ContainsKey(SecondaryEffect)) { CustomPrefab val2 = new CustomPrefab(StarLevelSystem.EmbeddedResourceBundle.LoadAsset(SecondaryEffect), true); PrefabManager.Instance.AddPrefab(val2); GameObject prefab2 = PrefabManager.Instance.GetPrefab(SecondaryEffect); CreatureModifiersData.LoadedSecondaryEffects.Add(SecondaryEffect, prefab2); } } public void LoadAPIGameObjects() { if ((Object)(object)StarVisualAPI != (Object)null && !CreatureModifiersData.LoadedModifierSprites.ContainsKey(StarVisual)) { CreatureModifiersData.LoadedModifierSprites.Add(StarVisual, StarVisualAPI); } if ((Object)(object)VisualEffectAPI != (Object)null && !CreatureModifiersData.LoadedModifierEffects.ContainsKey(VisualEffect)) { CreatureModifiersData.LoadedModifierEffects.Add(VisualEffect, VisualEffectAPI); } if ((Object)(object)SecondaryEffectAPI != (Object)null && !CreatureModifiersData.LoadedSecondaryEffects.ContainsKey(SecondaryEffect)) { CreatureModifiersData.LoadedSecondaryEffects.Add(SecondaryEffect, SecondaryEffectAPI); } } public void RunOnceMethodCall(Character chara, CreatureModConfig cfg, CharacterCacheEntry scd) { if ((object)RunOnceEvent != null) { RunOnceEvent.DynamicInvoke(chara, cfg, scd); } } public void SetupMethodCall(Character chara, CreatureModConfig cfg, CharacterCacheEntry scd) { if ((object)SetupEvent != null) { SetupEvent.DynamicInvoke(chara, cfg, scd); } } } public class CreatureModConfig { public float PerlevelPower { get; set; } public float BasePower { get; set; } public Dictionary> BiomeObjects { get; set; } public Dictionary Config { get; set; } } public class CreatureModifierCollection { public GlobalModifierSettings ModifierGlobalSettings { get; set; } = new GlobalModifierSettings(); public Dictionary MajorModifiers { get; set; } public Dictionary MinorModifiers { get; set; } public Dictionary BossModifiers { get; set; } } public class GlobalModifierSettings { public List GlobalIgnorePrefabList = new List(); } public class PlayerRaidData { public RaidDefinition ActiveRaid { get; set; } public List PlayerPrivatekeys { get; set; } = new List(); public List PlayerAvailableRaids { get; set; } = new List(); public double NextRaidableTime { get; set; } public Vector3 CurrentRaidPosition { get; set; } public Dictionary LastRaidByName { get; set; } = new Dictionary(); } public class PlayerPrivatekeys { public List PrivateKeys { get; set; } = new List(); public double LastUpdatedAt { get; set; } } public class PlayerRaidHistory { public double NextRaidableTime { get; set; } public Dictionary LastRaidByName { get; set; } } public class ActiveRaid { public Vector3 Position { get; set; } public RaidDefinition Definition { get; set; } public float StartTime { get; set; } public ZNetPeer TargetPlayer { get; set; } } public class RaidConfiguration { public GlobalRaidSettings GlobalSettings { get; set; } = new GlobalRaidSettings(); public List Raids { get; set; } = new List(); } public class GlobalRaidSettings { [DefaultValue(false)] public bool DisableAllRaids { get; set; } [DefaultValue(true)] public bool PlayerBasedRaids { get; set; } = true; [DefaultValue(1f)] public float GlobalRaidIntervalScalar { get; set; } = 1f; [DefaultValue(1f)] public float GlobalRaidChanceScalar { get; set; } = 1f; } [Serializable] public class RaidDefinition { public string Name { get; set; } [DefaultValue(true)] public bool Enabled { get; set; } = true; [DefaultValue(60f)] public float Duration { get; set; } = 60f; [DefaultValue(12)] public int SpawnPoints { get; set; } = 12; public float RaidCoolDownMinutes { get; set; } = 120f; public RaidActivation Activation { get; set; } = new RaidActivation(); public List Spawns { get; set; } = new List(); [DefaultValue(96f)] public float EventRange { get; set; } = 96f; [DefaultValue("")] public string StartMessage { get; set; } = ""; [DefaultValue("")] public string EndMessage { get; set; } = ""; [DefaultValue(Environment.Clear)] public Environment ForceEnvironment { get; set; } [DefaultValue(Music.Zcombat)] public Music ForceMusic { get; set; } = Music.Zcombat; public RandomEvent ToRaid(Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) RandomEvent val = new RandomEvent(); val.m_name = Name; val.m_duration = Duration; if (Activation != null) { if (Activation.RequiredGlobalKeys != null) { val.m_requiredGlobalKeys = Activation.RequiredGlobalKeys; } if (Activation.NotRequiredGlobalKeys != null) { val.m_notRequiredGlobalKeys = Activation.NotRequiredGlobalKeys; } if (Activation.RequiredPlayerKeys != null) { val.m_altRequiredPlayerKeysAll = Activation.RequiredPlayerKeys; } if (Activation.NotRequiredPlayerKeys != null) { val.m_altNotRequiredPlayerKeys = Activation.NotRequiredPlayerKeys; } if (Activation.AnyRequiredPlayerKeys != null) { val.m_altRequiredPlayerKeysAny = Activation.AnyRequiredPlayerKeys; } val.m_standaloneChance = Activation.Chance; val.m_standaloneInterval = 100f; val.m_pauseIfNoPlayerInArea = Activation.PauseIfNoPlayerInArea; val.m_nearBaseOnly = Activation.NearBaseOnly; } val.m_spawnerDelay = 0f; val.m_eventRange = EventRange; val.m_startMessage = Localization.instance.Localize(StartMessage); val.m_endMessage = Localization.instance.Localize(EndMessage); val.m_forceEnvironment = ForceEnvironment.ToString(); val.m_biome = Heightmap.FindBiome(position); val.m_forceMusic = ForceMusic.ToString(); val.m_random = true; val.m_time = 0f; val.m_pos = position; return val; } } [Serializable] public class RaidActivation { public List Biomes { get; set; } [DefaultValue(true)] public bool NearBaseOnly { get; set; } [DefaultValue(true)] public bool PauseIfNoPlayerInArea { get; set; } = true; [DefaultValue(100f)] public float Chance { get; set; } = 100f; public List RequiredGlobalKeys { get; set; } public List NotRequiredGlobalKeys { get; set; } public List RequiredPlayerKeys { get; set; } public List NotRequiredPlayerKeys { get; set; } public List AnyRequiredPlayerKeys { get; set; } } [Serializable] public class RaidSpawnEntry { public string PrefabName { get; set; } public AI CreatureAI { get; set; } = AI.Alerted; [DefaultValue(10f)] public float SpawnInterval { get; set; } = 10f; [DefaultValue(100f)] public float SpawnChance { get; set; } = 100f; [DefaultValue(0f)] public float InitalSpawnDelay { get; set; } [DefaultValue(0)] public int MaxSpawned { get; set; } [DefaultValue(1)] public int SpawnGroupSize { get; set; } = 1; [DefaultValue(/*Could not decode attribute arguments.*/)] public Faction Faction { get; set; } = (Faction)12; [DefaultValue(1)] public int LevelMin { get; set; } = 1; public int LevelMax { get; set; } = ValConfig.MaxLevel.Value; public bool UseRaidLevelSystem { get; set; } = true; public Dictionary RequiredModifiers { get; set; } public List ModifiersNotAllowed { get; set; } [DefaultValue(null)] public SortedDictionary CustomCreatureLevelUpChance { get; set; } } [Serializable] public class RaidMonitor { public RaidSpawnEntry RaidSpawnDef { get; set; } public double NextSpawn { get; set; } public List SpawnedCreatures { get; set; } = new List(); public List GetSpawnedZDOIDs() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (string spawnedCreature in SpawnedCreatures) { string[] array = spawnedCreature.Split(new char[1] { ':' }); list.Add(new ZDOID(long.Parse(array[0]), uint.Parse(array[1]))); } return list; } public void StoreZDOIDS(List connected) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) SpawnedCreatures.Clear(); foreach (ZDOID item in connected) { ZDOID current = item; SpawnedCreatures.Add(((object)(ZDOID)(ref current)).ToString()); } } } [Serializable] public class CharacterCacheEntry { public int Level { get; set; } public ZDO ZDO { get; set; } public bool ShouldDelete { get; set; } public string CreatureNameLocalizable { get; set; } public string RefCreatureName { get; set; } public ColorDef Colorization { get; set; } public Biome Biome { get; set; } public float SpawnRateModifier { get; set; } = 1f; public bool RunOnceDone { get; set; } public Dictionary CreatureModifiers { get; set; } = new Dictionary(); public Dictionary ModifiersRequired { get; set; } public List ModifiersNotAllowed { get; set; } public Dictionary DamageRecievedModifiers { get; set; } = new Dictionary { { DamageType.Blunt, 1f }, { DamageType.Pierce, 1f }, { DamageType.Slash, 1f }, { DamageType.Fire, 1f }, { DamageType.Frost, 1f }, { DamageType.Lightning, 1f }, { DamageType.Poison, 1f }, { DamageType.Spirit, 1f }, { DamageType.Chop, 1f }, { DamageType.Pickaxe, 1f } }; public Dictionary CreatureBaseValueModifiers { get; set; } = new Dictionary { { CreatureBaseAttribute.BaseDamage, 1f }, { CreatureBaseAttribute.BaseHealth, 1f }, { CreatureBaseAttribute.Size, 1f }, { CreatureBaseAttribute.Speed, 1f }, { CreatureBaseAttribute.AttackSpeed, 1f } }; public Dictionary CreaturePerLevelValueModifiers { get; set; } = new Dictionary { { CreaturePerLevelAttribute.DamagePerLevel, 0f }, { CreaturePerLevelAttribute.HealthPerLevel, 0f }, { CreaturePerLevelAttribute.SizePerLevel, 0f }, { CreaturePerLevelAttribute.SpeedPerLevel, 0f }, { CreaturePerLevelAttribute.AttackSpeedPerLevel, 0f } }; public CreatureSpecificSetting creatureSettings { get; set; } public Dictionary CreatureDamageBonus { get; set; } = new Dictionary(); public string GetDamageBonusDescription() { StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair creatureDamageBonu in CreatureDamageBonus) { if (creatureDamageBonu.Value > 0f) { stringBuilder.Append($"|{creatureDamageBonu.Key}-{creatureDamageBonu.Value}"); } } return stringBuilder.ToString(); } } [DataContract] public class ExtendedCharacterDrop { public Drop Drop { get; set; } public Drop GameDrop { get; private set; } [DefaultValue(0f)] public float AmountScaleFactor { get; set; } [DefaultValue(0f)] public float ChanceScaleFactor { get; set; } public bool UseChanceAsMultiplier { get; set; } public bool ScalebyMaxLevel { get; set; } public bool DoesNotScale { get; set; } [DefaultValue(0)] public int MaxScaledAmount { get; set; } public bool UntamedOnlyDrop { get; set; } public bool TamedOnlyDrop { get; set; } public void ToCharacterDrop() { GameDrop = Drop.ToCharDrop(); } } [DataContract] public class ExtendedObjectDrop { public Drop Drop { get; set; } public GameObject DropGo { get; private set; } public float AmountScaleFactor { get; set; } [DefaultValue(0f)] public float ChanceScaleFactor { get; set; } public bool UseChanceAsMultiplier { get; set; } [DefaultValue(0)] public int MaxScaledAmount { get; set; } public void ResolveDropPrefab() { DropGo = PrefabManager.Instance.GetPrefab(Drop.Prefab); } } [DataContract] public class Drop { public string Prefab { get; set; } [DefaultValue(1)] public int Min { get; set; } = 1; [DefaultValue(1)] public int Max { get; set; } = 1; [DefaultValue(1f)] public float Chance { get; set; } = 1f; [DefaultValue(false)] public bool OnePerPlayer { get; set; } [DefaultValue(true)] public bool LevelMultiplier { get; set; } = true; [DefaultValue(false)] public bool DontScale { get; set; } public Drop ToCharDrop() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown return new Drop { m_prefab = PrefabManager.Instance.GetPrefab(Prefab), m_amountMin = Min, m_amountMax = Max, m_chance = Chance, m_onePerPlayer = OnePerPlayer, m_levelMultiplier = LevelMultiplier, m_dontScale = DontScale }; } } [Serializable] [DataContract] public class ColorDef { public float hue { get; set; } public float saturation { get; set; } public float value { get; set; } public bool IsEmissive { get; set; } public ColorDef() { } public ColorDef(float hue = 0f, float saturation = 0f, float value = 0f, bool is_emissive = false) { this.hue = hue; this.saturation = saturation; this.value = value; IsEmissive = is_emissive; } public LevelSetup toLevelEffect() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown return new LevelSetup { m_scale = 1f, m_hue = hue, m_saturation = saturation, m_value = value, m_setEmissiveColor = IsEmissive, m_emissiveColor = new Color(hue, saturation, value) }; } } [DataContract] public class ColorRangeDef { [DefaultValue(true)] public bool CharacterSpecific { get; set; } = true; [DefaultValue(false)] public bool OverwriteExisting { get; set; } public ColorDef StartColorDef { get; set; } public ColorDef EndColorDef { get; set; } public int RangeStart { get; set; } public int RangeEnd { get; set; } } public abstract class ZNetProperty { protected readonly ZNetView zNetView; public string Key { get; private set; } public T DefaultValue { get; private set; } protected ZNetProperty(string key, ZNetView zNetView, T defaultValue) { Key = key; DefaultValue = defaultValue; this.zNetView = zNetView; } private void ClaimOwnership() { if (!zNetView.IsOwner()) { zNetView.ClaimOwnership(); } } public void Set(T value) { SetValue(value); } public void ForceSet(T value) { ClaimOwnership(); Set(value); } public abstract T Get(); protected abstract void SetValue(T value); } public class ListStringZNetProperty : ZNetProperty> { private BinaryFormatter binFormatter = new BinaryFormatter(); public ListStringZNetProperty(string key, ZNetView zNetView, List defaultValue) : base(key, zNetView, defaultValue) { } public override List Get() { byte[] byteArray = zNetView.GetZDO().GetByteArray(base.Key, (byte[])null); if (byteArray == null) { return new List(); } MemoryStream serializationStream = new MemoryStream(byteArray); return (List)binFormatter.Deserialize(serializationStream); } protected override void SetValue(List value) { MemoryStream memoryStream = new MemoryStream(); binFormatter.Serialize(memoryStream, value); zNetView.GetZDO().Set(base.Key, memoryStream.ToArray()); } } public class CreatureModifiersZNetProperty : ZNetProperty> { private BinaryFormatter binFormatter = new BinaryFormatter(); public CreatureModifiersZNetProperty(string key, ZNetView zNetView, Dictionary defaultValue) : base(key, zNetView, defaultValue) { } public override Dictionary Get() { byte[] byteArray = zNetView.GetZDO().GetByteArray(base.Key, (byte[])null); if (byteArray == null) { return new Dictionary(); } MemoryStream serializationStream = new MemoryStream(byteArray); Dictionary obj = (Dictionary)binFormatter.Deserialize(serializationStream); Dictionary dictionary = new Dictionary(); foreach (KeyValuePair item in obj) { string value = CreatureModifiersData.ModifierNamesLookupTable.GetValue(item.Key); if (value != null) { dictionary.Add(value, item.Value); } } return dictionary; } protected override void SetValue(Dictionary value) { Dictionary dictionary = new Dictionary(); foreach (KeyValuePair item in value) { int value2 = CreatureModifiersData.ModifierNamesLookupTable.GetValue(item.Key); if (value2 != -1) { dictionary.Add(value2, item.Value); } } MemoryStream memoryStream = new MemoryStream(); binFormatter.Serialize(memoryStream, dictionary); zNetView.GetZDO().Set(base.Key, memoryStream.ToArray()); } } public class ListIntZNetProperty : ZNetProperty> { private BinaryFormatter binFormatter = new BinaryFormatter(); public ListIntZNetProperty(string key, ZNetView zNetView, List defaultValue) : base(key, zNetView, defaultValue) { } public override List Get() { byte[] byteArray = zNetView.GetZDO().GetByteArray(base.Key, (byte[])null); if (byteArray == null) { return new List(); } MemoryStream serializationStream = new MemoryStream(byteArray); return (List)binFormatter.Deserialize(serializationStream); } protected override void SetValue(List value) { MemoryStream memoryStream = new MemoryStream(); binFormatter.Serialize(memoryStream, value); zNetView.GetZDO().Set(base.Key, memoryStream.ToArray()); } } public class ListModifierZNetProperty : ZNetProperty> { private BinaryFormatter binFormatter = new BinaryFormatter(); public ListModifierZNetProperty(string key, ZNetView zNetView, List defaultValue) : base(key, zNetView, defaultValue) { } public override List Get() { byte[] byteArray = zNetView.GetZDO().GetByteArray(base.Key, (byte[])null); if (byteArray == null) { return new List(); } MemoryStream serializationStream = new MemoryStream(byteArray); return (List)binFormatter.Deserialize(serializationStream); } protected override void SetValue(List value) { MemoryStream memoryStream = new MemoryStream(); binFormatter.Serialize(memoryStream, value); zNetView.GetZDO().Set(base.Key, memoryStream.ToArray()); } } public class DictionaryDmgNetProperty : ZNetProperty> { private BinaryFormatter binFormatter = new BinaryFormatter(); public DictionaryDmgNetProperty(string key, ZNetView zNetView, Dictionary defaultValue) : base(key, zNetView, defaultValue) { } public override Dictionary Get() { byte[] byteArray = zNetView.GetZDO().GetByteArray(base.Key, (byte[])null); if (byteArray == null) { return new Dictionary(); } MemoryStream serializationStream = new MemoryStream(byteArray); return (Dictionary)binFormatter.Deserialize(serializationStream); } protected override void SetValue(Dictionary value) { MemoryStream memoryStream = new MemoryStream(); binFormatter.Serialize(memoryStream, value); zNetView.GetZDO().Set(base.Key, memoryStream.ToArray()); } } public class CreatureDetailsZNetProperty : ZNetProperty { private BinaryFormatter binFormatter = new BinaryFormatter(); public CreatureDetailsZNetProperty(string key, ZNetView zNetView, CharacterCacheEntry defaultValue) : base(key, zNetView, defaultValue) { } public override CharacterCacheEntry Get() { byte[] byteArray = zNetView.GetZDO().GetByteArray(base.Key, (byte[])null); if (byteArray == null) { return new CharacterCacheEntry(); } MemoryStream serializationStream = new MemoryStream(byteArray); return (CharacterCacheEntry)binFormatter.Deserialize(serializationStream); } protected override void SetValue(CharacterCacheEntry value) { MemoryStream memoryStream = new MemoryStream(); binFormatter.Serialize(memoryStream, value); zNetView.GetZDO().Set(base.Key, memoryStream.ToArray()); } } public class RaidZNetProperty : ZNetProperty { public RaidZNetProperty(string key, ZNetView zNetView, RaidDefinition defaultValue) : base(key, zNetView, defaultValue) { } public override RaidDefinition Get() { byte[] byteArray = zNetView.GetZDO().GetByteArray(base.Key, (byte[])null); if (byteArray == null) { return null; } MemoryStream serializationStream = new MemoryStream(byteArray); return (RaidDefinition)binFormatter.Deserialize(serializationStream); } protected override void SetValue(RaidDefinition value) { MemoryStream memoryStream = new MemoryStream(); binFormatter.Serialize(memoryStream, value); zNetView.GetZDO().Set(base.Key, memoryStream.ToArray()); } } public class IntZNetProperty : ZNetProperty { public IntZNetProperty(string key, ZNetView zNetView, int defaultValue) : base(key, zNetView, defaultValue) { } public override int Get() { return zNetView.GetZDO().GetInt(base.Key, base.DefaultValue); } protected override void SetValue(int value) { zNetView.GetZDO().Set(base.Key, value); } } public class DoubleZNetProperty : ZNetProperty { public DoubleZNetProperty(string key, ZNetView zNetView, double defaultValue) : base(key, zNetView, defaultValue) { } public override double Get() { byte[] byteArray = zNetView.GetZDO().GetByteArray(base.Key, (byte[])null); if (byteArray == null) { return 0.0; } MemoryStream serializationStream = new MemoryStream(byteArray); return (double)binFormatter.Deserialize(serializationStream); } protected override void SetValue(double value) { MemoryStream memoryStream = new MemoryStream(); binFormatter.Serialize(memoryStream, value); zNetView.GetZDO().Set(base.Key, memoryStream.ToArray()); } } public class RaidMonitorListZNetProperty : ZNetProperty> { public RaidMonitorListZNetProperty(string key, ZNetView zNetView, List defaultValue) : base(key, zNetView, defaultValue) { } public override List Get() { byte[] byteArray = zNetView.GetZDO().GetByteArray(base.Key, (byte[])null); if (byteArray == null) { return new List(); } MemoryStream serializationStream = new MemoryStream(byteArray); return (List)binFormatter.Deserialize(serializationStream); } protected override void SetValue(List value) { MemoryStream memoryStream = new MemoryStream(); binFormatter.Serialize(memoryStream, value); zNetView.GetZDO().Set(base.Key, memoryStream.ToArray()); } } public class ListVectorZNetProperty : ZNetProperty> { public ListVectorZNetProperty(string key, ZNetView zNetView, List defaultValue) : base(key, zNetView, defaultValue) { } public override List Get() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) byte[] byteArray = zNetView.GetZDO().GetByteArray(base.Key, (byte[])null); if (byteArray == null) { return null; } List list = new List(); int num = byteArray.Length / 12; for (int i = 0; i < num; i++) { list.Add(new Vector3(BitConverter.ToSingle(byteArray, i * 12), BitConverter.ToSingle(byteArray, i * 12 + 4), BitConverter.ToSingle(byteArray, i * 12 + 8))); } return list; } protected override void SetValue(List value) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) byte[] array = new byte[value.Count * 12]; for (int i = 0; i < value.Count; i++) { BitConverter.GetBytes(value[i].x).CopyTo(array, i * 12); BitConverter.GetBytes(value[i].y).CopyTo(array, i * 12 + 4); BitConverter.GetBytes(value[i].z).CopyTo(array, i * 12 + 8); } zNetView.GetZDO().Set(base.Key, array); } } public class BoolZNetProperty : ZNetProperty { public BoolZNetProperty(string key, ZNetView zNetView, bool defaultValue) : base(key, zNetView, defaultValue) { } public override bool Get() { return zNetView.GetZDO().GetBool(base.Key, base.DefaultValue); } protected override void SetValue(bool value) { zNetView.GetZDO().Set(base.Key, value); } } public static IDeserializer yamldeserializer = new DeserializerBuilder().WithCaseInsensitivePropertyMatching().Build(); public static ISerializer yamlserializer = ((BuilderSkeleton)new SerializerBuilder()).WithNamingConvention(PascalCaseNamingConvention.Instance).ConfigureDefaultValuesHandling((DefaultValuesHandling)2).Build(); public static ISerializer yamlserializerJsonCompat = ((BuilderSkeleton)new SerializerBuilder()).WithNamingConvention(PascalCaseNamingConvention.Instance).JsonCompatible().Build(); public static BinaryFormatter binFormatter = new BinaryFormatter(); public static readonly string SLS_CREATURE = "SLS_CREATURE"; public static readonly string SLS_DAMAGE_MODIFIER = "SLS_DMOD"; public static readonly string SLS_DAMAGE_BONUSES = "SLS_DBON"; public static readonly string SLS_SPAWN_MULT = "SLS_MULT"; public static readonly string SLS_MODIFIERS = "SLS_MODS"; public static readonly string SLS_MODSV2 = "SLS_MODV2"; public static readonly string SLS_CHARNAME = "SLS_CHARNAME"; public static readonly string SLS_TREE = "SLE_Tree"; public static readonly string SLS_FISH = "SLE_Fish"; public static readonly string SLS_BIRD = "SLE_Bird"; public static readonly string SLS_INFERTILE = "SLS_Infertile"; public static readonly string SLS_SOULEATER = "SLS_SoulEater"; public static readonly string SLS_EVOLVE = "SLS_Evolve"; public static readonly string SLS_SIZE = "SLS_SIZE"; public static readonly string SLS_MOD_CAP = "EffectCap"; public static List CreatureBaseAttributes = new List { CreatureBaseAttribute.BaseHealth, CreatureBaseAttribute.BaseDamage, CreatureBaseAttribute.Speed, CreatureBaseAttribute.AttackSpeed, CreatureBaseAttribute.Size }; public static List CreaturePerLevelAttributes = new List { CreaturePerLevelAttribute.HealthPerLevel, CreaturePerLevelAttribute.DamagePerLevel, CreaturePerLevelAttribute.SpeedPerLevel, CreaturePerLevelAttribute.SizePerLevel }; } internal static class LocalizationLoader { private static CustomLocalization Localization; internal static void AddLocalizations() { Localization = LocalizationManager.Instance.GetLocalization(); string text = Path.Combine(Paths.ConfigPath, "StarLevelSystem", "localizations"); Directory.CreateDirectory(text); string[] manifestResourceNames = typeof(StarLevelSystem).Assembly.GetManifestResourceNames(); foreach (string text2 in manifestResourceNames) { if (!text2.Contains("Localization")) { continue; } string text3 = Regex.Replace(ReadEmbeddedResourceFile(text2), "\\/\\/.*", ""); Dictionary internal_localization = SimpleJson.DeserializeObject>(text3); string[] array = text2.Split(new char[1] { '.' }); if (File.Exists(text + "/" + array[2] + ".json")) { string text4 = File.ReadAllText(text + "/" + array[2] + ".json"); try { Dictionary dictionary = SimpleJson.DeserializeObject>(text4); UpdateLocalizationWithMissingKeys(internal_localization, dictionary); Logger.LogDebug("Reading " + text + "/" + array[2] + ".json"); File.WriteAllText(text + "/" + array[2] + ".json", SimpleJson.SerializeObject((object)dictionary)); string text5 = File.ReadAllText(text + "/" + array[2] + ".json"); Localization.AddJsonFile(array[2], text5); } catch { File.WriteAllText(text + "/" + array[2] + ".json", text3); Logger.LogDebug("Reading " + text2); Localization.AddJsonFile(array[2], text3); } } else { File.WriteAllText(text + "/" + array[2] + ".json", text3); Logger.LogDebug("Reading " + text2); Localization.AddJsonFile(array[2], text3); } Logger.LogDebug("Added localization: '" + array[2] + "'"); } } private static void UpdateLocalizationWithMissingKeys(Dictionary internal_localization, Dictionary cached_localization) { if (internal_localization.Keys.Count == cached_localization.Keys.Count) { return; } Logger.LogDebug("Cached localization was missing some entries. They will be added."); foreach (KeyValuePair item in internal_localization) { if (!cached_localization.ContainsKey(item.Key)) { cached_localization.Add(item.Key, item.Value); } } } private static string ReadEmbeddedResourceFile(string filename) { using Stream stream = typeof(StarLevelSystem).Assembly.GetManifestResourceStream(filename); using StreamReader streamReader = new StreamReader(stream); return streamReader.ReadToEnd(); } } internal static class RandomSelect { public static string RandomSelectFromWeightedListWithExclusions(List listOfWeights, List exclude) { List list = listOfWeights.Where((DataObjects.ProbabilityEntry x) => !exclude.Contains(x.Name)).ToList(); float num = list.Select((DataObjects.ProbabilityEntry x) => x.SelectionWeight).Sum(); if (num == 0f) { return CreatureModifiers.NoMods; } float num2 = Random.Range(0f, num); float num3 = 0f; foreach (DataObjects.ProbabilityEntry listOfWeight in listOfWeights) { num3 += listOfWeight.SelectionWeight; if (num3 >= num2) { return listOfWeight.Name; } } return list.ToArray()[Random.Range(0, listOfWeights.Count - 1)].Name; } } public static class SLSExtensions { public static List ShuffleList(this List inputList) { int i = 0; int count = inputList.Count; int num = 0; T val = default(T); List list = new List(); list.AddRange(inputList); for (; i < count; i++) { num = Random.Range(i, list.Count); val = list[i]; list[i] = list[num]; list[num] = val; } return list; } public static bool CompareListContents(this List listA, List listB) { if (listA == null && listB == null) { return true; } if (listA == null || listB == null) { return false; } if (listA.Count != listB.Count) { return false; } List source = listA.Except(listB).ToList(); List source2 = listB.Except(listA).ToList(); if (!source.Any()) { return !source2.Any(); } return false; } public static int GetLabelValue(Label label) { return (int)typeof(Label).GetMethod("GetLabelValue", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(label, null); } public static CodeMatcher CreateLabelOffset(this CodeMatcher matcher, out Label label, int offset = 0) { return matcher.CreateLabelAt(matcher.Pos + offset, ref label); } public static CodeMatcher ExtractLabel(this CodeMatcher matcher, out Label elabel, int searchrange = 1, int labelToSelect = 0) { elabel = default(Label); List list = matcher.Instructions(); int num = Math.Min(list.Count, matcher.Pos + 1 + searchrange); bool flag = false; List