using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; 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.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.Modifiers; using StarLevelSystem.modules.NemesisSystem; using StarLevelSystem.modules.Raids; using StarLevelSystem.modules.Sizes; using StarLevelSystem.modules.UI; using TMPro; using UnityEngine; using UnityEngine.Events; 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("1.4.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.0.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"); if (!(APIReciever == null)) { 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 static 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 LogNemesis(string message) { if (ValConfig.EnableDebugNemesisDetails.Value) { StarLevelSystem.Log.LogInfo((object)("[Nemesis] " + message)); } } public static void LogRaid(string message) { if (ValConfig.EnableDebugRaidDetails.Value) { StarLevelSystem.Log.LogInfo((object)("[Raid] " + message)); } } public static void LogLoot(string message) { if (ValConfig.EnableDebugLootDetails.Value) { StarLevelSystem.Log.LogInfo((object)("[Loot] " + message)); } } 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", "1.4.0")] [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 = "1.4.0"; 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"); Compatibility.ApplyConditionalPatches(HarmonyInstance); Colorization.Init(); LevelSystemData.Init(); LootSystemData.Init(); CreatureModifiersData.Init(); RaidsData.Init(); NemesisSystemData.Init(); QuickConfigureTool.Init(); LocalizationLoader.AddLocalizations(); PrefabManager.OnVanillaPrefabsAvailable += CreatureModifiersData.LoadPrefabs; PrefabManager.OnVanillaPrefabsAvailable += UpdateLevelsOnChange.UpdateFishMaxLevel; PrefabManager.OnVanillaPrefabsAvailable += UIHudControl.SetDefaultStar; PrefabManager.OnVanillaPrefabsAvailable += NemesisRemoteSpawnControl.LoadAssets; PrefabManager.OnPrefabsRegistered += LootSystemData.AttachPrefabsWhenReady; MinimapManager.OnVanillaMapDataLoaded += DistanceScaleSystem.DelayedMinimapSetup; MinimapManager.OnVanillaMapDataLoaded += ZoneScaleSystem.Initialize; MinimapManager.OnVanillaMapDataLoaded += NemesisMinimap.OnMapReady; PrefabManager.OnPrefabsRegistered += SizeModifications.PrepareSizeRefCache; SynchronizationManager.OnConfigurationSynchronized += delegate { ValConfig.HasServerUpdates(); }; UIHudControl.LoadAssets(); RaidControl.LoadAssets(); TerminalCommands.AddCommands(); NemesisSystem.Initialize(); ConfigFileWatcher.Initialize(); } } } 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 List zoneOverlayColors = 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" }, { "LightYellow", "#ffff99" }, { "LightOrange", "#ffc266" }, { "DarkOrange", "#cc6600" }, { "LightRed", "#ff6666" }, { "DarkRed", "#b30000" }, { "LightPurple", "#e0b3ff" }, { "DarkPurple", "#8000b3" } }; 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 (!Enumerable.Contains(Colorization.creatureColorizationSettings.DefaultLevelColorization.Keys, 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> dictionary = (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() { ParseColorOptions(ValConfig.DistanceRingColorOptions.Value, mapRingColors, "distance ring"); } public static void UpdateZoneOverlayColorSelection() { ParseColorOptions(ValConfig.ZoneOverlayColorOptions.Value, zoneOverlayColors, "zone overlay"); } private static void ParseColorOptions(string optionsCsv, List target, string contextLabel) { //IL_004c: 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) target.Clear(); Color item = default(Color); Color item2 = default(Color); foreach (string item3 in optionsCsv.Split(new char[1] { ',' }).ToList()) { if (item3.StartsWith("#")) { if (ColorUtility.TryParseHtmlString(item3.Trim(), ref item)) { target.Add(item); continue; } Logger.LogWarning("Unable to parse color string " + item3 + " for " + contextLabel + " colors. It will be skipped"); } else { string key = StringExtensions.CapitalizeFirstLetter(item3.Trim()); if (defaultColors.TryGetValue(key, out var value) && ColorUtility.TryParseHtmlString(value, ref item2)) { target.Add(item2); } } } } } internal static class Compatibility { public static bool IsDropThatEnabled; public static bool IsExpandWorldEnabled; public static bool IsFGNEnabled; public static bool IsCustomRaidsEnabled; public static bool IsJewelcraftingEnabled; private static Type DropThatCharacterDropSessionManager; private static MethodInfo DropThatCharacterModifyDrop; private static MethodInfo JewelcraftingBossHudPostfix; public static bool CustomRaidsCompatActive { get { if (IsCustomRaidsEnabled) { return ValConfig.EnableCustomRaidsCompat.Value; } return false; } } public static bool DropThatCharacterModifyAvailable => DropThatCharacterModifyDrop != null; internal static void CheckModCompat() { try { Dictionary plugins = BepInExUtils.GetPlugins(false); if (plugins == null) { return; } if (Enumerable.Contains(plugins.Keys, "asharppen.valheim.drop_that")) { IsDropThatEnabled = true; DropThatCharacterDropSessionManager = Type.GetType("DropThat.Drop.CharacterDropSystem.Managers.CharacterDropSessionManager, DropThat"); if (DropThatCharacterDropSessionManager != null) { DropThatCharacterModifyDrop = DropThatCharacterDropSessionManager.GetMethod("ModifyDrop", BindingFlags.Static | BindingFlags.Public, null, new Type[3] { typeof(GameObject), typeof(List>), typeof(int) }, null); } if (!DropThatCharacterModifyAvailable) { Logger.LogWarning("Warning: DropThat compat method (CharacterDropSessionManager.ModifyDrop) not found; DropThat item modifiers will not be applied to creature loot."); } } if (Enumerable.Contains(plugins.Keys, "com.Fire.FiresGhettoNetworkMod")) { IsFGNEnabled = true; } if (Enumerable.Contains(plugins.Keys, "expand_world_size")) { IsExpandWorldEnabled = true; } if (Enumerable.Contains(plugins.Keys, "asharppen.valheim.custom_raids")) { IsCustomRaidsEnabled = true; Logger.LogInfo("Valheim.CustomRaids detected; CustomRaids raids will fire alongside SLS raids while EnableCustomRaidsCompat is enabled."); } if (Enumerable.Contains(plugins.Keys, "org.bepinex.plugins.jewelcrafting")) { IsJewelcraftingEnabled = true; JewelcraftingBossHudPostfix = AccessTools.Method("Jewelcrafting.WorldBosses.BossHud+DisplayMultipleBossHuds:Postfix", (Type[])null, (Type[])null); if (JewelcraftingBossHudPostfix == null) { Logger.LogWarning("Jewelcrafting detected but DisplayMultipleBossHuds.Postfix could not be found; boss-HUD compatibility patch will be skipped."); } } } catch { Logger.LogWarning("Unable to check mod compatibility. Ensure that Bepinex can load."); } } public static void DropThat_ModifyCharacterDrop(GameObject drop, List> drops, int index) { if (!DropThatCharacterModifyAvailable) { return; } try { DropThatCharacterModifyDrop.Invoke(null, new object[3] { drop, drops, index }); } catch (Exception ex) { Logger.LogWarning("DropThat ModifyDrop failed: " + ex.Message); } } internal static void ApplyConditionalPatches(Harmony harmony) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown if (IsJewelcraftingEnabled && JewelcraftingBossHudPostfix != null) { harmony.Patch((MethodBase)JewelcraftingBossHudPostfix, new HarmonyMethod(AccessTools.Method(typeof(Compatibility), "SkipJewelcraftingBossHud", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Logger.LogInfo("Jewelcrafting detected; suppressing its multi-boss HUD layout so SLS controls the boss healthbars."); } } private static bool SkipJewelcraftingBossHud() { return !ValConfig.EnableJewelCraftingBossHudCompat.Value; } } 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 = Mathf.Max(1f - (float)playerDifficulty * ValConfig.MultiplayerEnemyHealthModifier.Value, ValConfig.MultiplayerEnemyMinDamageTaken.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 { internal static bool CheckSetApplySpawnrate(Character chara, DataObjects.CharacterCacheEntry ccEntry) { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) if (ValConfig.BossCreaturesNeverSpawnMultiply.Value && chara.IsBoss()) { return false; } bool flag = chara.IsTamed(); if (flag && 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 (ValConfig.EnableNemesisSystem.Value && !flag) { NemesisActions.NemesisRandomSpawner(chara); } 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 (flag && (Object)(object)component != (Object)null) { component.SetTamed(true); } Logger.LogDebug($"Spawn Multiplier| {spawnRateModifier} 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; } internal static IEnumerator DestroyCoroutine(GameObject go) { yield return (object)new WaitForEndOfFrame(); if (!((Object)(object)go != (Object)null)) { yield break; } Character component = go.GetComponent(); if (!((Object)(object)component != (Object)null) || !component.m_tamed) { CharacterDrop component2 = go.GetComponent(); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); } ZNetScene.instance.Destroy(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 MinimapLevelIndicator { [HarmonyPatch(typeof(Minimap), "Awake")] public static class CreateIndicator { public static void Postfix(Minimap __instance) { //IL_0048: 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_0066: 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_0082: 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_00d3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.m_mapImageSmall == (Object)null || (Object)(object)indicatorText != (Object)null) { return; } try { Transform transform = ((Component)__instance.m_mapImageSmall).transform; indicatorText = GUIManager.Instance.CreateText("", transform, new Vector2(1f, 0f), new Vector2(1f, 0f), new Vector2(-8f, 8f), GUIManager.Instance.AveriaSerifBold, 14, GUIManager.Instance.ValheimYellow, true, Color.black, 200f, 44f, false).GetComponent(); ((Graphic)indicatorText).rectTransform.pivot = new Vector2(1f, 0f); ((Graphic)indicatorText).rectTransform.anchoredPosition = new Vector2(-8f, 8f); indicatorText.alignment = (TextAnchor)8; ((Component)indicatorText).gameObject.SetActive(false); } catch (Exception ex) { Logger.LogWarning("Failed to create minimap level indicator: " + ex.Message); } } } [HarmonyPatch(typeof(Minimap), "Update")] public static class RefreshIndicator { public static void Postfix() { MinimapOverlayFog.MaybeRefreshForExploration(); if (!((Object)(object)indicatorText == (Object)null) && !(Time.time < nextRefresh)) { nextRefresh = Time.time + 5f; Refresh(); } } } private static Text indicatorText; private static float nextRefresh; private const float RefreshInterval = 5f; private static void Refresh() { //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_0062: 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) Player localPlayer = Player.m_localPlayer; if (!ValConfig.ShowMinimapLevelIndicator.Value || (Object)(object)localPlayer == (Object)null) { if (((Component)indicatorText).gameObject.activeSelf) { ((Component)indicatorText).gameObject.SetActive(false); } return; } Vector3 position = ((Component)localPlayer).transform.position; List list = new List(2); if (ValConfig.EnableDistanceLevelScalingBonus.Value) { list.Add($"Ring {DistanceScaleSystem.GetCurrentRingLevel(position)}"); } if (ValConfig.EnableZoneScalingBonus.Value) { list.Add($"Zone {ZoneScaleSystemData.GetZoneForPosition(position)?.ZoneLevel ?? 0}"); } if (list.Count == 0) { if (((Component)indicatorText).gameObject.activeSelf) { ((Component)indicatorText).gameObject.SetActive(false); } return; } indicatorText.text = string.Join("\n", list); if (!((Component)indicatorText).gameObject.activeSelf) { ((Component)indicatorText).gameObject.SetActive(true); } } public static void OnShowIndicatorChanged(object s, EventArgs e) { if (!((Object)(object)indicatorText == (Object)null)) { if (!ValConfig.ShowMinimapLevelIndicator.Value) { ((Component)indicatorText).gameObject.SetActive(false); } else { nextRefresh = 0f; } } } } internal static class QuickConfigureTool { private class StagedConfig { public bool enableDistance; public bool enableDistanceOverlay; public bool enableZone; public bool enableZoneOverlay; public bool enableConditional; public float creatureHpPerLevel; public float creatureDmgPerLevel; public float bossHpPerLevel; public float bossDmgPerLevel; public int maxLevel; public int maxBossLevel; public bool mpHealth; public bool mpDamage; public float mpHealthMod; public float mpDamageMod; public int mpRequiredPlayers; public DataObjects.LevelGenerator generator; public int maxMajor; public int maxMinor; public int maxBossMods; public int prefixLimit; public float chanceMajor; public float chanceMinor; public float chanceBoss; public bool limitToStarLevel; public bool enableBossMods; public bool minorFirst; public DataObjects.ModifierDisplayStyle displayStyle; public DataObjects.CreatureModifierCollection modifierSource; public Dictionary> modifierOn; public bool enableSlsRaids; public float raidEventRate; public int raidCheckMinutes; public int maxRaidAttempts; public int maxActiveRaids; public DataObjects.RaidConfiguration raidSource; public HashSet raidsOn; public bool enableNemesis; public float nemCooldown; public float nemInfluence; public float nemMinSpawn; public float neutralScore; public float minScore; public float maxScore; public float decayPerUpdate; public float scoreInterval; public float bossKillBonus; public float deathReduction; public DataObjects.NemesisConfiguration nemesisSource; public static StagedConfig Snapshot() { StagedConfig stagedConfig = new StagedConfig { enableDistance = ValConfig.EnableDistanceLevelScalingBonus.Value, enableDistanceOverlay = ValConfig.EnableMapRingsForDistanceBonus.Value, enableZone = ValConfig.EnableZoneScalingBonus.Value, enableZoneOverlay = ValConfig.EnableZoneMapOverlay.Value, creatureHpPerLevel = ValConfig.EnemyHealthMultiplier.Value, creatureDmgPerLevel = ValConfig.EnemyDamageLevelMultiplier.Value, bossHpPerLevel = ValConfig.BossEnemyHealthMultiplier.Value, bossDmgPerLevel = ValConfig.BossEnemyDamageMultiplier.Value, maxLevel = ValConfig.MaxLevel.Value, maxBossLevel = ValConfig.MaxBossLevel.Value, mpHealth = ValConfig.EnableMultiplayerEnemyHealthScaling.Value, mpHealthMod = ValConfig.MultiplayerEnemyHealthModifier.Value, mpDamage = ValConfig.EnableMultiplayerEnemyDamageScaling.Value, mpDamageMod = ValConfig.MultiplayerEnemyDamageModifier.Value, mpRequiredPlayers = ValConfig.MultiplayerScalingRequiredPlayersNearby.Value, maxMajor = ValConfig.MaxMajorModifiersPerCreature.Value, maxMinor = ValConfig.MaxMinorModifiersPerCreature.Value, chanceMajor = ValConfig.ChanceMajorModifier.Value, chanceMinor = ValConfig.ChanceMinorModifier.Value, limitToStarLevel = ValConfig.LimitCreatureModifiersToCreatureStarLevel.Value, enableBossMods = ValConfig.EnableBossModifiers.Value, chanceBoss = ValConfig.ChanceOfBossModifier.Value, maxBossMods = ValConfig.MaxBossModifiersPerBoss.Value, prefixLimit = ValConfig.LimitCreatureModifierPrefixes.Value, minorFirst = ValConfig.MinorModifiersFirstInName.Value, enableSlsRaids = !ValConfig.UseVanillaRaidConfiguration.Value, raidEventRate = ValConfig.RaidEventRate.Value, raidCheckMinutes = ValConfig.ServerTimeBetweenRaidStartChecks.Value, maxRaidAttempts = ValConfig.MaxRaidAttemptsPerPlayer.Value, maxActiveRaids = ValConfig.MaxActiveRaids.Value, enableNemesis = ValConfig.EnableNemesisSystem.Value }; DataObjects.CreatureLevelSettings sLE_Level_Settings = LevelSystemData.SLE_Level_Settings; stagedConfig.enableConditional = sLE_Level_Settings?.EnableConditionalCreatureLevelupChance ?? false; stagedConfig.generator = CloneOrDefaultGenerator(sLE_Level_Settings, stagedConfig.maxLevel); if (!Enum.TryParse(ValConfig.ModifierIconDisplayStyle.Value, out var result)) { result = DataObjects.ModifierDisplayStyle.Stars; } stagedConfig.displayStyle = result; stagedConfig.modifierSource = CreatureModifiersData.ActiveCreatureModifiers; stagedConfig.modifierOn = new Dictionary> { { DataObjects.ModifierType.Boss, KeysOf(stagedConfig.modifierSource?.BossModifiers) }, { DataObjects.ModifierType.Major, KeysOf(stagedConfig.modifierSource?.MajorModifiers) }, { DataObjects.ModifierType.Minor, KeysOf(stagedConfig.modifierSource?.MinorModifiers) } }; DataObjects.NemesisConfiguration nemesisConfiguration = (stagedConfig.nemesisSource = NemesisSystemData.SLE_Nemesis_Settings); if (nemesisConfiguration != null) { stagedConfig.nemCooldown = nemesisConfiguration.NemesisActionCooldownSeconds; stagedConfig.nemInfluence = nemesisConfiguration.NemesisInfluenceRadius; stagedConfig.nemMinSpawn = nemesisConfiguration.NemesisMinSpawnDistance; DataObjects.NemesisScore nemesisScore = nemesisConfiguration.ScoreSystem ?? new DataObjects.NemesisScore(); stagedConfig.neutralScore = nemesisScore.NeutralScore; stagedConfig.minScore = nemesisScore.MinScore; stagedConfig.maxScore = nemesisScore.MaxScore; stagedConfig.decayPerUpdate = nemesisScore.DecayPerUpdate; stagedConfig.scoreInterval = nemesisScore.ScoreIntervalSeconds; stagedConfig.bossKillBonus = nemesisScore.BossKillBonus; stagedConfig.deathReduction = nemesisScore.DeathScoreReduction; } stagedConfig.raidSource = RaidsData.SLE_Raid_Settings; stagedConfig.raidsOn = new HashSet(); if (stagedConfig.raidSource?.Raids != null) { foreach (DataObjects.RaidDefinition raid in stagedConfig.raidSource.Raids) { if (raid.Enabled) { stagedConfig.raidsOn.Add(raid.Name); } } } return stagedConfig; } private static HashSet KeysOf(Dictionary dict) { HashSet hashSet = new HashSet(); if (dict == null) { return hashSet; } foreach (KeyValuePair item in dict) { if (item.Value.Enabled) { hashSet.Add(item.Key); } } return hashSet; } private static DataObjects.LevelGenerator CloneOrDefaultGenerator(DataObjects.CreatureLevelSettings settings, int maxLevel) { DataObjects.LevelGenerator levelGenerator = null; if (settings?.DefaultLevelupGenerators != null && settings.DefaultLevelupGenerators.Count > 0) { levelGenerator = settings.DefaultLevelupGenerators[0]; } if (levelGenerator == null) { return new DataObjects.LevelGenerator { MinLevel = 1, MaxLevel = Mathf.Max(1, maxLevel), LevelUpChance = 0.2f, LevelupCalculationStyle = DataObjects.LevelupCalculationStyle.Exponential, GaussianOffset = 0f, NightMultiplier = 1f }; } return new DataObjects.LevelGenerator { PrefabName = levelGenerator.PrefabName, MinLevel = levelGenerator.MinLevel, MaxLevel = levelGenerator.MaxLevel, LevelUpChance = levelGenerator.LevelUpChance, LevelupCalculationStyle = levelGenerator.LevelupCalculationStyle, GaussianOffset = levelGenerator.GaussianOffset, NightMultiplier = levelGenerator.NightMultiplier }; } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__38_0; public static UnityAction <>9__38_1; public static Action <>9__40_0; public static Action <>9__40_1; public static Action <>9__40_2; public static Action <>9__40_3; public static Action <>9__40_4; public static Action <>9__41_3; public static Action <>9__41_4; public static Action <>9__41_5; public static Action <>9__41_6; public static Action <>9__41_7; public static Action <>9__41_8; public static Action <>9__41_9; public static Action <>9__41_10; public static Action <>9__41_11; public static Action <>9__41_12; public static Action <>9__41_13; public static Action <>9__41_14; public static Action <>9__41_15; public static Action <>9__41_16; public static Action <>9__41_1; public static Action <>9__41_2; public static Action <>9__42_0; public static Action <>9__42_1; public static Action <>9__42_2; public static Action <>9__42_3; public static Action <>9__42_4; public static Func <>9__42_5; public static Func <>9__43_1; public static Action <>9__45_0; public static Action <>9__45_1; public static Action <>9__45_2; public static Action <>9__45_3; public static Action <>9__45_4; public static Action <>9__45_5; public static Action <>9__45_6; public static Action <>9__45_7; public static Action <>9__45_8; public static Action <>9__45_9; public static Action <>9__45_10; public static Action <>9__46_0; public static Action <>9__46_1; public static Action <>9__46_2; public static Action <>9__46_3; public static Action <>9__46_4; public static Action <>9__46_5; public static Action <>9__46_6; public static Action <>9__46_7; public static Action <>9__46_8; public static Action <>9__46_9; public static Action <>9__46_10; public static Func <>9__47_0; internal void b__38_0() { ShowPage(currentPage - 1); } internal void b__38_1() { ShowPage(currentPage + 1); } internal void b__40_0(bool v) { staged.enableDistance = v; } internal void b__40_1(bool v) { staged.enableDistanceOverlay = v; } internal void b__40_2(bool v) { staged.enableZone = v; } internal void b__40_3(bool v) { staged.enableZoneOverlay = v; } internal void b__40_4(bool v) { staged.enableConditional = v; } internal void b__41_3(float v) { staged.creatureHpPerLevel = v; UpdateExampleMath(); } internal void b__41_4(float v) { staged.creatureDmgPerLevel = v; UpdateExampleMath(); } internal void b__41_5(float v) { staged.maxLevel = (int)v; UpdateExampleMath(); } internal void b__41_6(float v) { staged.bossHpPerLevel = v; UpdateExampleMath(); } internal void b__41_7(float v) { staged.bossDmgPerLevel = v; UpdateExampleMath(); } internal void b__41_8(float v) { staged.maxBossLevel = (int)v; UpdateExampleMath(); } internal void b__41_9(bool v) { staged.mpHealth = v; } internal void b__41_10(float v) { staged.mpHealthMod = v; } internal void b__41_11(bool v) { staged.mpDamage = v; } internal void b__41_12(float v) { staged.mpDamageMod = v; } internal void b__41_13(float v) { staged.mpRequiredPlayers = (int)v; } internal void b__41_14(float v) { staged.generator.MinLevel = (int)v; } internal void b__41_15(float v) { staged.generator.MaxLevel = (int)v; } internal void b__41_16(float v) { staged.generator.LevelUpChance = v; } internal void b__41_1(float v) { staged.generator.GaussianOffset = v; } internal void b__41_2(float v) { staged.generator.NightMultiplier = v; } internal void b__42_0(bool v) { staged.enableSlsRaids = v; } internal void b__42_1(float v) { staged.raidEventRate = v; } internal void b__42_2(float v) { staged.raidCheckMinutes = (int)v; } internal void b__42_3(float v) { staged.maxRaidAttempts = (int)v; } internal void b__42_4(float v) { staged.maxActiveRaids = (int)v; } internal string b__42_5(DataObjects.RaidDefinition r) { return r.Name; } internal string b__43_1(DataObjects.RaidSpawnEntry sp) { return sp.PrefabName; } internal void b__45_0(bool v) { staged.enableNemesis = v; } internal void b__45_1(float v) { staged.nemCooldown = v; } internal void b__45_2(float v) { staged.nemInfluence = v; } internal void b__45_3(float v) { staged.nemMinSpawn = v; } internal void b__45_4(float v) { staged.neutralScore = v; } internal void b__45_5(float v) { staged.minScore = v; } internal void b__45_6(float v) { staged.maxScore = v; } internal void b__45_7(float v) { staged.decayPerUpdate = v; } internal void b__45_8(float v) { staged.scoreInterval = v; } internal void b__45_9(float v) { staged.bossKillBonus = v; } internal void b__45_10(float v) { staged.deathReduction = v; } internal void b__46_0(float v) { staged.maxMajor = (int)v; } internal void b__46_1(float v) { staged.maxMinor = (int)v; } internal void b__46_2(float v) { staged.chanceMajor = v; } internal void b__46_3(float v) { staged.chanceMinor = v; } internal void b__46_4(bool v) { staged.limitToStarLevel = v; } internal void b__46_5(bool v) { staged.enableBossMods = v; } internal void b__46_6(float v) { staged.chanceBoss = v; } internal void b__46_7(float v) { staged.maxBossMods = (int)v; } internal void b__46_8(float v) { staged.prefixLimit = (int)v; } internal void b__46_9(bool v) { staged.minorFirst = v; } internal void b__46_10(int i) { staged.displayStyle = (DataObjects.ModifierDisplayStyle)i; } internal string b__47_0(string n) { return n; } } private const float PanelW = 900f; private const float PanelH = 690f; private const float Margin = 26f; private const float ContentTop = 92f; private const float RowHeight = 34f; private const float SubRowHeight = 26f; private const float RowGap = 4f; private const int PageCount = 5; private const float TrollHp = 600f; private const float TrollDmg = 70f; private const float TheElderHP = 2500f; private const float TheElderDmg = 60f; private static readonly string[] CalcStyleOptions = Enum.GetNames(typeof(DataObjects.LevelupCalculationStyle)); private static readonly string[] DisplayStyleOptions = Enum.GetNames(typeof(DataObjects.ModifierDisplayStyle)); private static readonly Dictionary ModifierDescriptions = new Dictionary { { "BossSummoner", "Summons minion creatures at regular intervals." }, { "SoulEater", "Grows stronger as nearby creatures die; self-heals." }, { "LifeLink", "Redirects some damage taken to a nearby creature." }, { "Splitter", "Spawns replacement creatures when it dies." }, { "Lootbags", "Tankier and faster; drops extra loot." }, { "Fire", "Adds fire damage to its attacks." }, { "Frost", "Adds frost damage to its attacks." }, { "Poison", "Adds poison damage to its attacks." }, { "Lightning", "Adds lightning damage to its attacks." }, { "FireNova", "Explodes in fire on death, damaging nearby targets." }, { "FrostNova", "Explodes in frost on death, damaging nearby targets." }, { "PoisonNova", "Explodes in poison on death, damaging nearby targets." }, { "LightningNova", "Explodes in lightning on death, damaging nearby targets." }, { "Evolving", "Gains a level after enough kills." }, { "ResistSlash", "Reduces damage taken from slash." }, { "ResistBlunt", "Reduces damage taken from blunt." }, { "ResistPierce", "Reduces damage taken from pierce (e.g. arrows)." }, { "ResistFire", "Reduces damage taken from fire." }, { "ResistFrost", "Reduces damage taken from frost." }, { "ResistPoison", "Reduces damage taken from poison." }, { "ResistSpirit", "Reduces damage taken from spirit." }, { "Alert", "Increases the creature's hearing range." }, { "Big", "Increases the creature's size." }, { "Fast", "Increases the creature's movement speed." }, { "StaminaDrain", "Its attacks drain your stamina. Dodging avoids it; blocking or parrying lessens it." }, { "EitrDrain", "Its attacks drain your eitr. Dodging avoids it; blocking or parrying lessens it." }, { "Brutal", "Increases the creature's attack speed." }, { "ElementalChaos", "Adds random elemental damage on each hit." } }; private static Sprite DistanceExample; private static Sprite ZoneExample; private static GameObject panel; private static GameObject[] pageRoots; private static int currentPage; private static Text titleText; private static GameObject backBtn; private static GameObject cancelBtn; private static GameObject nextBtn; private static GameObject applyBtn; private static Text creatureExampleText; private static Text bossExampleText; private static StagedConfig staged; private static GameObject mainMenuButton; private static GameObject pauseMenuButton; internal static void Init() { GUIManager.OnCustomGUIAvailable += OnCustomGUIAvailable; DistanceExample = StarLevelSystem.EmbeddedResourceBundle.LoadAsset("distance_rings"); ZoneExample = StarLevelSystem.EmbeddedResourceBundle.LoadAsset("region_zones"); } private static void OnCustomGUIAvailable() { try { if (!GUIManager.IsHeadless() && GUIManager.Instance != null && (Object)(object)FejdStartup.instance != (Object)null) { CreateMainMenuButton(); } } catch (Exception ex) { Logger.LogWarning("QuickConfigureTool failed to set up main menu button: " + ex.Message); } } internal static void CreatePauseMenuButton(Menu menu) { try { if (!GUIManager.IsHeadless() && GUIManager.Instance != null && !((Object)(object)menu == (Object)null) && !((Object)(object)menu.m_root == (Object)null) && !((Object)(object)pauseMenuButton != (Object)null)) { pauseMenuButton = CreateCornerButton(menu.m_root); pauseMenuButton.SetActive(ValConfig.ShowQuickConfigureButton.Value && SynchronizationManager.Instance.PlayerIsAdmin); } } catch (Exception ex) { Logger.LogWarning("QuickConfigureTool failed to set up pause menu button: " + ex.Message); } } public static void OnShowButtonChanged(object s, EventArgs e) { bool value = ValConfig.ShowQuickConfigureButton.Value; if ((Object)(object)mainMenuButton != (Object)null) { mainMenuButton.SetActive(value); } if ((Object)(object)pauseMenuButton != (Object)null) { pauseMenuButton.SetActive(value && SynchronizationManager.Instance.PlayerIsAdmin); } } private static void CreateMainMenuButton() { if (!((Object)(object)mainMenuButton != (Object)null) && !((Object)(object)GUIManager.CustomGUIFront == (Object)null)) { mainMenuButton = CreateCornerButton(GUIManager.CustomGUIFront.transform); mainMenuButton.SetActive(ValConfig.ShowQuickConfigureButton.Value); } } private static GameObject CreateCornerButton(Transform parent) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_004d: 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) //IL_005d: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown GameObject obj = GUIManager.Instance.CreateButton("SLS Config", parent, new Vector2(1f, 0f), new Vector2(1f, 0f), new Vector2(-20f, 20f), 150f, 38f); RectTransform val = (RectTransform)obj.transform; val.pivot = new Vector2(1f, 0f); val.anchoredPosition = new Vector2(-20f, 20f); ((UnityEvent)obj.GetComponent