Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ShyGuySettings v1.0.0
com.github.zehsteam.ShyGuySettings.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using Microsoft.CodeAnalysis; using Scopophobia; using Unity.Netcode; using UnityEngine; using com.github.zehsteam.ShyGuySettings.Data; using com.github.zehsteam.ShyGuySettings.Dependencies; using com.github.zehsteam.ShyGuySettings.Patches; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("com.github.zehsteam.ShyGuySettings")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("This mod lets you configure the Shy Guy (SCP-096) enemy from the Scopophobia mod. Probability Curve, Spawn Weight, Max Spawn Count, SpawnInside, and SpawnOutside.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5d2b0bf6281dfbe256443252e2598bfd1b1e0f89")] [assembly: AssemblyProduct("ShyGuySettings")] [assembly: AssemblyTitle("com.github.zehsteam.ShyGuySettings")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace com.github.zehsteam.ShyGuySettings { internal static class ConfigHelper { public static void SetModIcon(Sprite sprite) { if (LethalConfigProxy.Enabled) { LethalConfigProxy.SetModIcon(sprite); } } public static void SetModDescription(string description) { if (LethalConfigProxy.Enabled) { LethalConfigProxy.SetModDescription(description); } } public static void SkipAutoGen() { if (LethalConfigProxy.Enabled) { LethalConfigProxy.SkipAutoGen(); } } public static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, bool requiresRestart, string description, AcceptableValueBase acceptableValues = null, Action<T> settingChanged = null, ConfigFile configFile = null) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown if (configFile == null) { configFile = ((BaseUnityPlugin)Plugin.Instance).Config; } ConfigEntry<T> configEntry = ((acceptableValues == null) ? configFile.Bind<T>(section, key, defaultValue, description) : configFile.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, Array.Empty<object>()))); if (settingChanged != null) { configEntry.SettingChanged += delegate { settingChanged?.Invoke(configEntry.Value); }; } if (LethalConfigProxy.Enabled) { if (acceptableValues == null) { LethalConfigProxy.AddConfig<T>(configEntry, requiresRestart); } else { LethalConfigProxy.AddConfigSlider<T>(configEntry, requiresRestart); } } return configEntry; } public static void AddButton(string section, string name, string description, string buttonText, Action callback) { if (LethalConfigProxy.Enabled) { LethalConfigProxy.AddButton(section, name, description, buttonText, callback); } } } internal class ConfigManager { public ConfigEntry<bool> ExtendedLogging { get; private set; } public ConfigEntry<string> SpawnProbabilityCurve { get; private set; } public ConfigManager() { BindConfigs(); SetupChangedEvents(); } private void BindConfigs() { ConfigHelper.SkipAutoGen(); ExtendedLogging = ConfigHelper.Bind("General Settings", "ExtendedLogging", defaultValue: false, requiresRestart: false, "Enable extended logging."); SpawnProbabilityCurve = ConfigHelper.Bind("Spawn Settings", "ProbabilityCurve", "1.0, 1.0, 1.0", requiresRestart: false, "Determines how likely Shy guy is to spawn throughout the day. Accepts an array of floats with each entry separated by a comma."); } private void SetupChangedEvents() { SpawnProbabilityCurve.SettingChanged += SpawnProbabilityCurve_SettingChanged; } private void SpawnProbabilityCurve_SettingChanged(object sender, EventArgs e) { EnemyHelper.SetProbabilityCurve("Shy guy", Utils.ToFloatsArray(SpawnProbabilityCurve.Value)); } private void ClearUnusedEntries() { ConfigFile config = ((BaseUnityPlugin)Plugin.Instance).Config; PropertyInfo property = ((object)config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic); Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(config, null); dictionary.Clear(); config.Save(); } } internal static class EnemyDataManager { public const string EnemyName = "Shy guy"; private static bool _initialized; public static List<EnemyData> EnemyDataList { get; private set; } = new List<EnemyData>(); public static void Initialize() { if (!_initialized) { _initialized = true; InitializeEnemyDataList(); } } private static void InitializeEnemyDataList() { if ((Object)(object)StartOfRound.Instance == (Object)null) { Plugin.logger.LogError((object)"Failed to initialize enemy data list. StartOfRound Instance is null. (EnemyName: Shy guy)"); return; } EnemyType enemyType = EnemyHelper.GetEnemyType("Shy guy"); if ((Object)(object)enemyType == (Object)null) { Plugin.logger.LogError((object)"Failed to initialize enemy data list. EnemyType is null. (EnemyName: Shy guy)"); return; } EnemyHelper.SetProbabilityCurve("Shy guy", Utils.ToFloatsArray(Plugin.ConfigManager.SpawnProbabilityCurve.Value)); SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel val in levels) { if (val.spawnEnemiesAndScrap) { AddEnemyData(val); } } foreach (EnemyData enemyData in EnemyDataList) { int value = enemyData.ConfigData.SpawnWeight.Value; if (enemyData.ConfigData.SpawnInside.Value) { LevelHelper.AddEnemyToLevel(enemyData.PlanetName, "Shy guy", value, EnemyListType.Inside); } else { LevelHelper.RemoveEnemyFromLevel(enemyData.PlanetName, "Shy guy", EnemyListType.Inside); } if (enemyData.ConfigData.SpawnOutside.Value) { LevelHelper.AddEnemyToLevel(enemyData.PlanetName, "Shy guy", value, EnemyListType.Outside); } else { LevelHelper.RemoveEnemyFromLevel(enemyData.PlanetName, "Shy guy", EnemyListType.Outside); } } } public static void AddEnemyData(SelectableLevel level) { if (HasEnemyData(level.PlanetName)) { Plugin.logger.LogWarning((object)("Failed to add enemy data for level \"" + level.PlanetName + "\". Enemy data already exists for SelectableLevel.")); return; } EnemyType enemyType = EnemyHelper.GetEnemyType("Shy guy"); if ((Object)(object)enemyType == (Object)null) { Plugin.logger.LogError((object)("Failed to add enemy data for level \"" + level.PlanetName + "\". EnemyType is null")); return; } int spawnWeight; bool flag = LevelHelper.LevelHasEnemy(level.PlanetName, "Shy guy", EnemyListType.Inside, out spawnWeight); int spawnWeight2; bool flag2 = LevelHelper.LevelHasEnemy(level.PlanetName, "Shy guy", EnemyListType.Outside, out spawnWeight2); int spawnWeight3 = 0; if (flag && flag2) { spawnWeight3 = Mathf.Max(spawnWeight, spawnWeight2); } else if (flag) { spawnWeight3 = spawnWeight; } else if (flag2) { spawnWeight3 = spawnWeight2; } EnemyConfigDataDefault defaultConfigValues = new EnemyConfigDataDefault(spawnWeight3, enemyType.MaxCount, flag, flag2); EnemyData enemyData = new EnemyData(level.PlanetName, defaultConfigValues); enemyData.BindConfigs(); EnemyDataList.Add(enemyData); } public static EnemyData GetEnemyData(string planetName) { foreach (EnemyData enemyData in EnemyDataList) { if (enemyData.PlanetName == planetName) { return enemyData; } } return null; } public static bool HasEnemyData(string planetName) { return GetEnemyData(planetName) != null; } public static void SetEnemyDataForCurrentLevel() { EnemyData enemyData = GetEnemyData(LevelHelper.CurrentPlanetName); if (enemyData == null) { Plugin.logger.LogError((object)("Failed to set enemy data for current level. EnemyData is null. (PlanetName: " + LevelHelper.CurrentPlanetName + ")")); } else { EnemyHelper.SetMaxSpawnCount("Shy guy", enemyData.ConfigData.MaxSpawnCount.Value, LevelHelper.CurrentPlanetName); } } } public enum EnemyListType { Inside, Outside, Daytime } internal static class EnemyHelper { public static void SetSpawnWeight(string enemyName, int spawnWeight, EnemyListType enemyListType, string planetName) { if ((Object)(object)StartOfRound.Instance == (Object)null) { Plugin.logger.LogError((object)$"Failed to set enemy spawn weight. StartOfRound Instance is null. (EnemyName: {enemyName}, SpawnWeight: {spawnWeight}, EnemyListType: {Utils.GetEnumName(enemyListType)}, PlanetName: {planetName})"); return; } EnemyType enemyType = GetEnemyType(enemyName); if ((Object)(object)enemyType == (Object)null) { Plugin.logger.LogError((object)$"Failed to set enemy spawn weight. EnemyType is null. (EnemyName: {enemyName}, SpawnWeight: {spawnWeight}, EnemyListType: {Utils.GetEnumName(enemyListType)}, PlanetName: {planetName})"); return; } SelectableLevel levelByName = LevelHelper.GetLevelByName(planetName); if ((Object)(object)levelByName == (Object)null) { Plugin.logger.LogError((object)$"Failed to set enemy spawn weight. SelectableLevel is null. (EnemyName: {enemyName}, SpawnWeight: {spawnWeight}, EnemyListType: {Utils.GetEnumName(enemyListType)}, PlanetName: {planetName})"); return; } if (!LevelHelper.LevelHasEnemy(planetName, enemyName, enemyListType)) { Plugin.logger.LogError((object)$"Failed to set enemy spawn weight. SelectableLevel does not contain enemy. (EnemyName: {enemyName}, SpawnWeight: {spawnWeight}, EnemyListType: {Utils.GetEnumName(enemyListType)}, PlanetName: {planetName})"); return; } List<SpawnableEnemyWithRarity> enemyList = LevelHelper.GetEnemyList(levelByName, enemyListType); foreach (SpawnableEnemyWithRarity item in enemyList) { if ((Object)(object)item.enemyType == (Object)(object)enemyType) { item.rarity = spawnWeight; break; } } Plugin.Instance.LogInfoExtended($"Set enemy spawn weight. (EnemyName: {enemyName}, SpawnWeight: {spawnWeight}, EnemyListType: {Utils.GetEnumName(enemyListType)}, PlanetName: {planetName})"); } public static void SetMaxSpawnCount(string enemyName, int maxSpawnCount, string planetName) { if ((Object)(object)StartOfRound.Instance == (Object)null) { Plugin.logger.LogError((object)$"Failed to set enemy max spawn count. StartOfRound Instance is null. (EnemyName: {enemyName}, MaxSpawnCount: {maxSpawnCount}, PlanetName: {planetName})"); return; } if (!LevelHelper.IsCurrentLevel(planetName)) { Plugin.logger.LogError((object)$"Failed to set enemy max spawn count. Planet name is not the current planet name. (EnemyName: {enemyName}, MaxSpawnCount: {maxSpawnCount}, PlanetName: {planetName})"); return; } EnemyType enemyType = GetEnemyType(enemyName); if ((Object)(object)enemyType == (Object)null) { Plugin.logger.LogError((object)$"Failed to set enemy max spawn count. EnemyType is null. (EnemyName: {enemyName}, MaxSpawnCount: {maxSpawnCount}, PlanetName: {planetName})"); return; } enemyType.MaxCount = maxSpawnCount; Plugin.Instance.LogInfoExtended($"Set enemy max spawn count. (EnemyName: {enemyName}, MaxSpawnCount: {maxSpawnCount}, PlanetName: {planetName})"); } public static void SetProbabilityCurve(string enemyName, float[] values) { if (values == null) { Plugin.logger.LogError((object)("Failed to set enemy probability curve. Values are null. (EnemyName: " + enemyName + ")")); return; } if (values.Length == 0) { Plugin.logger.LogError((object)("Failed to set enemy probability curve. Values are empty. (EnemyName: " + enemyName + ")")); return; } if ((Object)(object)StartOfRound.Instance == (Object)null) { Plugin.logger.LogError((object)("Failed to set enemy probability curve. StartOfRound Instance is null. (EnemyName: " + enemyName + ", Values: " + string.Join(", ", values) + ")")); return; } EnemyType enemyType = GetEnemyType(enemyName); if ((Object)(object)enemyType == (Object)null) { Plugin.logger.LogError((object)("Failed to set enemy probability curve. EnemyType is null. (EnemyName: " + enemyName + ", Values: " + string.Join(", ", values) + ")")); return; } AnimationCurve val = Utils.CreateAnimationCurve(values); if (val == null) { Plugin.logger.LogError((object)("Failed to set enemy probability curve. AnimationCurve is invalid. (EnemyName: " + enemyName + ", Values: " + string.Join(", ", values) + ")")); } else { enemyType.probabilityCurve = val; Plugin.Instance.LogInfoExtended("Set enemy probability curve. (EnemyName: " + enemyName + ", Values: " + string.Join(", ", values) + ")"); } } public static EnemyType GetEnemyType(string enemyName) { foreach (EnemyType enemyType in GetEnemyTypes()) { if (enemyType.enemyName == enemyName) { return enemyType; } } try { EnemyType val = Resources.FindObjectsOfTypeAll<EnemyType>().Single((EnemyType x) => x.enemyName == enemyName); if (IsValidEnemyType(val) && NetworkUtils.IsNetworkPrefab(val.enemyPrefab)) { Plugin.Instance.LogInfoExtended("Found EnemyType \"" + val.enemyName + "\" from Resources."); return val; } } catch { } return null; } public static List<EnemyType> GetEnemyTypes() { if ((Object)(object)StartOfRound.Instance == (Object)null) { return new List<EnemyType>(); } HashSet<EnemyType> hashSet = new HashSet<EnemyType>(new EnemyTypeComparer()); SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel val in levels) { IEnumerable<EnemyType> enumerable = (from e in val.Enemies.Concat(val.DaytimeEnemies).Concat(val.OutsideEnemies) select e.enemyType).Where(IsValidEnemyType); foreach (EnemyType item in enumerable) { hashSet.Add(item); } } return hashSet.ToList(); } public static bool IsValidEnemyType(EnemyType enemyType) { if ((Object)(object)enemyType == (Object)null) { return false; } if (string.IsNullOrWhiteSpace(enemyType.enemyName)) { return false; } if ((Object)(object)enemyType.enemyPrefab == (Object)null) { return false; } return true; } } public class EnemyTypeComparer : IEqualityComparer<EnemyType> { public bool Equals(EnemyType x, EnemyType y) { if ((Object)(object)x == (Object)null || (Object)(object)y == (Object)null) { return false; } return x.enemyName == y.enemyName; } public int GetHashCode(EnemyType obj) { return obj.enemyName?.GetHashCode() ?? 0; } } internal static class LevelHelper { public static string CurrentPlanetName { get { if ((Object)(object)StartOfRound.Instance == (Object)null) { Plugin.logger.LogError((object)"Failed to get current planet name. StartOfRound Instance is null."); return string.Empty; } return StartOfRound.Instance.currentLevel.PlanetName; } } public static SelectableLevel GetLevelByName(string planetName) { if ((Object)(object)StartOfRound.Instance == (Object)null) { return null; } SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel val in levels) { if (val.PlanetName == planetName) { return val; } } return null; } public static bool IsCurrentLevel(string planetName) { if ((Object)(object)StartOfRound.Instance == (Object)null) { Plugin.logger.LogError((object)("Failed to check is current level. StartOfRound Instance is null. (PlanetName: " + planetName + ")")); return false; } return StartOfRound.Instance.currentLevel.PlanetName == planetName; } public static List<SpawnableEnemyWithRarity> GetEnemyList(SelectableLevel level, EnemyListType enemyListType) { if ((Object)(object)level == (Object)null) { Plugin.logger.LogError((object)("Failed to get enemy list. SelectableLevel is null. (EnemyListType: " + Utils.GetEnumName(enemyListType) + ")")); return new List<SpawnableEnemyWithRarity>(); } if (1 == 0) { } List<SpawnableEnemyWithRarity> result = enemyListType switch { EnemyListType.Inside => level.Enemies, EnemyListType.Outside => level.OutsideEnemies, EnemyListType.Daytime => level.DaytimeEnemies, _ => new List<SpawnableEnemyWithRarity>(), }; if (1 == 0) { } return result; } public static bool LevelHasEnemy(string planetName, string enemyName, EnemyListType enemyListType) { int spawnWeight; return LevelHasEnemy(planetName, enemyName, enemyListType, out spawnWeight); } public static bool LevelHasEnemy(string planetName, string enemyName, EnemyListType enemyListType, out int spawnWeight) { spawnWeight = 0; SelectableLevel levelByName = GetLevelByName(planetName); if ((Object)(object)levelByName == (Object)null) { Plugin.logger.LogError((object)("Failed to check if level has enemy. SelectableLevel is null. (PlanetName: " + planetName + ", EnemyName: " + enemyName + ", EnemyListType: " + Utils.GetEnumName(enemyListType) + ")")); return false; } EnemyType enemyType = EnemyHelper.GetEnemyType(enemyName); if ((Object)(object)enemyType == (Object)null) { Plugin.logger.LogError((object)("Failed to check if level has enemy. EnemyType is null. (PlanetName: " + planetName + ", EnemyName: " + enemyName + ", EnemyListType: " + Utils.GetEnumName(enemyListType) + ")")); return false; } List<SpawnableEnemyWithRarity> enemyList = GetEnemyList(levelByName, enemyListType); foreach (SpawnableEnemyWithRarity item in enemyList) { if ((Object)(object)item.enemyType == (Object)(object)enemyType) { spawnWeight = item.rarity; return true; } } return false; } public static void AddEnemyToLevel(string planetName, string enemyName, int spawnWeight, EnemyListType enemyListType) { //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_0110: Expected O, but got Unknown if (LevelHasEnemy(planetName, enemyName, enemyListType)) { Plugin.Instance.LogWarningExtended($"Failed to add enemy to level. SelectableLevel already contains enemy. (PlanetName: {planetName}, EnemyName: {enemyName}, SpawnWeight: {spawnWeight}, EnemyListType: {Utils.GetEnumName(enemyListType)})"); return; } SelectableLevel levelByName = GetLevelByName(planetName); if ((Object)(object)levelByName == (Object)null) { Plugin.logger.LogError((object)$"Failed to add enemy to level. SelectableLevel is null. (PlanetName: {planetName}, EnemyName: {enemyName}, SpawnWeight: {spawnWeight}, EnemyListType: {Utils.GetEnumName(enemyListType)})"); return; } EnemyType enemyType = EnemyHelper.GetEnemyType(enemyName); if ((Object)(object)enemyType == (Object)null) { Plugin.logger.LogError((object)$"Failed to add enemy to level. EnemyType is null. (PlanetName: {planetName}, EnemyName: {enemyName}, SpawnWeight: {spawnWeight}, EnemyListType: {Utils.GetEnumName(enemyListType)})"); return; } List<SpawnableEnemyWithRarity> enemyList = GetEnemyList(levelByName, enemyListType); SpawnableEnemyWithRarity item = new SpawnableEnemyWithRarity { enemyType = enemyType, rarity = spawnWeight }; enemyList.Add(item); Plugin.Instance.LogInfoExtended($"Added enemy to level. (PlanetName: {planetName}, EnemyName: {enemyName}, SpawnWeight: {spawnWeight}, EnemyListType: {Utils.GetEnumName(enemyListType)})"); } public static void RemoveEnemyFromLevel(string planetName, string enemyName, EnemyListType enemyListType) { if (!LevelHasEnemy(planetName, enemyName, enemyListType)) { Plugin.Instance.LogWarningExtended("Failed to remove enemy from level. SelectableLevel does not contain enemy. (PlanetName: " + planetName + ", EnemyName: " + enemyName + ", EnemyListType: " + Utils.GetEnumName(enemyListType) + ")"); return; } SelectableLevel levelByName = GetLevelByName(planetName); if ((Object)(object)levelByName == (Object)null) { Plugin.logger.LogError((object)("Failed to remove enemy from level. SelectableLevel is null. (PlanetName: " + planetName + ", EnemyName: " + enemyName + ", EnemyListType: " + Utils.GetEnumName(enemyListType) + ")")); return; } EnemyType enemyType = EnemyHelper.GetEnemyType(enemyName); if ((Object)(object)enemyType == (Object)null) { Plugin.logger.LogError((object)("Failed to remove enemy from level. EnemyType is null. (PlanetName: " + planetName + ", EnemyName: " + enemyName + ", EnemyListType: " + Utils.GetEnumName(enemyListType) + ")")); return; } List<SpawnableEnemyWithRarity> enemyList = GetEnemyList(levelByName, enemyListType); int num = -1; for (int i = 0; i < enemyList.Count; i++) { if ((Object)(object)enemyList[i].enemyType == (Object)(object)enemyType) { num = i; break; } } if (num <= -1) { Plugin.Instance.LogWarningExtended("Failed to remove enemy from level. Could not find EnemyType in SelectableLevel. (PlanetName: " + planetName + ", EnemyName: " + enemyName + ", EnemyListType: " + Utils.GetEnumName(enemyListType) + ")"); } else { enemyList.RemoveAt(num); Plugin.Instance.LogInfoExtended("Removed enemy from level. (PlanetName: " + planetName + ", EnemyName: " + enemyName + ", EnemyListType: " + Utils.GetEnumName(enemyListType) + ")"); } } } internal static class NetworkUtils { public static bool IsServer { get { if ((Object)(object)NetworkManager.Singleton == (Object)null) { return false; } return NetworkManager.Singleton.IsServer; } } public static bool IsHost { get { if ((Object)(object)NetworkManager.Singleton == (Object)null) { return false; } return NetworkManager.Singleton.IsHost; } } public static ulong GetLocalClientId() { return NetworkManager.Singleton.LocalClientId; } public static bool IsLocalClientId(ulong clientId) { return clientId == GetLocalClientId(); } public static bool IsNetworkPrefab(GameObject prefab) { foreach (NetworkPrefab prefab2 in NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs) { if ((Object)(object)prefab2.Prefab == (Object)(object)prefab) { return true; } } return false; } } [BepInPlugin("com.github.zehsteam.ShyGuySettings", "ShyGuySettings", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("com.github.zehsteam.ShyGuySettings"); internal static Plugin Instance; internal static ManualLogSource logger; internal static ConfigManager ConfigManager; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } logger = Logger.CreateLogSource("com.github.zehsteam.ShyGuySettings"); logger.LogInfo((object)"ShyGuySettings has awoken!"); harmony.PatchAll(typeof(StartOfRoundPatch)); harmony.PatchAll(typeof(RoundManagerPatch)); ConfigManager = new ConfigManager(); ScopophobiaProxy.DisableSpawnPatches(); } public void LogInfoExtended(object data) { if (ConfigManager.ExtendedLogging.Value) { logger.LogInfo(data); } } public void LogWarningExtended(object data) { if (ConfigManager.ExtendedLogging.Value) { logger.LogWarning(data); } } } internal static class Utils { public static string GetEnumName(object e) { try { return Enum.GetName(e.GetType(), e); } catch { return string.Empty; } } public static AnimationCurve CreateAnimationCurve(float[] values) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0034: 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) if (values == null || values.Length == 0) { return null; } AnimationCurve val = new AnimationCurve(); if (values.Length == 1) { val.AddKey(new Keyframe(0f, values[0])); val.AddKey(new Keyframe(1f, values[0])); return val; } float num = 1f / (float)values.Length - 1f; for (int i = 0; i < values.Length; i++) { float num2 = Mathf.Clamp(num * (float)i, 0f, 1f); val.AddKey(num2, values[i]); } return val; } public static float[] ToFloatsArray(string text) { if (string.IsNullOrWhiteSpace(text)) { return Array.Empty<float>(); } List<float> list = new List<float>(); string[] array = (from x in text.Split(',') select x.Trim()).ToArray(); string[] array2 = array; foreach (string s in array2) { if (float.TryParse(s, out var result)) { list.Add(result); } } return list.ToArray(); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.github.zehsteam.ShyGuySettings"; public const string PLUGIN_NAME = "ShyGuySettings"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace com.github.zehsteam.ShyGuySettings.Patches { [HarmonyPatch(typeof(RoundManager))] internal static class RoundManagerPatch { [HarmonyPatch("LoadNewLevel")] [HarmonyPostfix] private static void LoadNewLevelPatch() { EnemyDataManager.SetEnemyDataForCurrentLevel(); } } [HarmonyPatch(typeof(StartOfRound))] internal static class StartOfRoundPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPatch() { EnemyDataManager.Initialize(); } } } namespace com.github.zehsteam.ShyGuySettings.Dependencies { internal static class LethalConfigProxy { public const string PLUGIN_GUID = "ainavt.lc.lethalconfig"; public static bool Enabled => Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"); [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void SetModIcon(Sprite sprite) { LethalConfigManager.SetModIcon(sprite); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void SetModDescription(string description) { LethalConfigManager.SetModDescription(description); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void SkipAutoGen() { LethalConfigManager.SkipAutoGen(); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfig<T>(ConfigEntry<T> configEntry, bool requiresRestart = false) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown if (!(configEntry is ConfigEntry<string> val)) { if (!(configEntry is ConfigEntry<bool> val2)) { if (!(configEntry is ConfigEntry<float> val3)) { if (!(configEntry is ConfigEntry<int> val4)) { throw new NotSupportedException($"Unsupported type: {typeof(T)}"); } LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(val4, requiresRestart)); } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(val3, requiresRestart)); } } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(val2, requiresRestart)); } } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(val, requiresRestart)); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfigSlider<T>(ConfigEntry<T> configEntry, bool requiresRestart = false) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown if (!(configEntry is ConfigEntry<float> val)) { if (!(configEntry is ConfigEntry<int> val2)) { throw new NotSupportedException($"Slider not supported for type: {typeof(T)}"); } LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(val2, requiresRestart)); } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(val, requiresRestart)); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddButton(string section, string name, string description, string buttonText, Action callback) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)new GenericButtonConfigItem(section, name, description, buttonText, (GenericButtonHandler)delegate { callback?.Invoke(); })); } } internal static class ScopophobiaProxy { public const string PLUGIN_GUID = "Scopophobia"; public static bool Enabled => Chainloader.PluginInfos.ContainsKey("Scopophobia"); public static void DisableSpawnPatches() { Config.DisableSpawnRatesConfig.Value = true; Plugin.logger.LogMessage((object)"Disabled Scopophobia spawn patches."); } } } namespace com.github.zehsteam.ShyGuySettings.Data { public class EnemyConfigData { private string _planetName; public EnemyConfigDataDefault DefaultValues { get; private set; } public ConfigEntry<int> SpawnWeight { get; private set; } public ConfigEntry<int> MaxSpawnCount { get; private set; } public ConfigEntry<bool> SpawnInside { get; private set; } public ConfigEntry<bool> SpawnOutside { get; private set; } public EnemyConfigData() { DefaultValues = new EnemyConfigDataDefault(); } public EnemyConfigData(EnemyConfigDataDefault defaultValues) { DefaultValues = defaultValues; } public void BindConfigs(string planetName) { if (DefaultValues == null) { EnemyConfigDataDefault enemyConfigDataDefault2 = (DefaultValues = new EnemyConfigDataDefault()); } _planetName = planetName; string section = planetName + " Spawn Settings"; SpawnWeight = ConfigHelper.Bind(section, "SpawnWeight", DefaultValues.SpawnWeight, requiresRestart: false, "The spawn weight of Shy guy."); MaxSpawnCount = ConfigHelper.Bind(section, "MaxSpawnCount", DefaultValues.MaxSpawnCount, requiresRestart: false, "The max amount of Shy guy that can spawn."); SpawnInside = ConfigHelper.Bind(section, "SpawnInside", DefaultValues.SpawnInside, requiresRestart: false, "If enabled, Shy guy will be able to spawn inside."); SpawnOutside = ConfigHelper.Bind(section, "SpawnOutside", DefaultValues.SpawnOutside, requiresRestart: false, "If enabled, Shy guy will be able to spawn outside."); SpawnWeight.SettingChanged += SpawnWeight_SettingChanged; MaxSpawnCount.SettingChanged += MaxSpawnCount_SettingChanged; SpawnInside.SettingChanged += SpawnInside_SettingChanged; SpawnOutside.SettingChanged += SpawnOutside_SettingChanged; } private void SpawnWeight_SettingChanged(object sender, EventArgs e) { if (SpawnInside.Value) { EnemyHelper.SetSpawnWeight("Shy guy", SpawnWeight.Value, EnemyListType.Inside, _planetName); } if (SpawnOutside.Value) { EnemyHelper.SetSpawnWeight("Shy guy", SpawnWeight.Value, EnemyListType.Outside, _planetName); } } private void MaxSpawnCount_SettingChanged(object sender, EventArgs e) { EnemyHelper.SetMaxSpawnCount("Shy guy", MaxSpawnCount.Value, _planetName); } private void SpawnInside_SettingChanged(object sender, EventArgs e) { if (SpawnInside.Value) { LevelHelper.AddEnemyToLevel(_planetName, "Shy guy", SpawnWeight.Value, EnemyListType.Inside); } else { LevelHelper.RemoveEnemyFromLevel(_planetName, "Shy guy", EnemyListType.Inside); } } private void SpawnOutside_SettingChanged(object sender, EventArgs e) { if (SpawnOutside.Value) { LevelHelper.AddEnemyToLevel(_planetName, "Shy guy", SpawnWeight.Value, EnemyListType.Outside); } else { LevelHelper.RemoveEnemyFromLevel(_planetName, "Shy guy", EnemyListType.Outside); } } } public class EnemyConfigDataDefault { public int SpawnWeight = 1; public int MaxSpawnCount = 1; public bool SpawnInside = true; public bool SpawnOutside = true; public EnemyConfigDataDefault() { } public EnemyConfigDataDefault(int spawnWeight, int maxSpawnCount, bool spawnInside, bool spawnOutside) { SpawnWeight = spawnWeight; MaxSpawnCount = maxSpawnCount; SpawnInside = spawnInside; SpawnOutside = spawnOutside; } } public class EnemyData { public string PlanetName { get; private set; } public EnemyConfigData ConfigData { get; private set; } public EnemyData(string planetName, EnemyConfigDataDefault defaultConfigValues = null) { PlanetName = planetName; ConfigData = new EnemyConfigData(defaultConfigValues); } public void BindConfigs() { if (ConfigData == null) { ConfigData = new EnemyConfigData(); } ConfigData.BindConfigs(PlanetName); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }