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 LofiCompany v1.1.1
BepInEx/plugins/inoyu.LofiCompany.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using CSync.Extensions; using CSync.Lib; using HarmonyLib; using LofiCompany.Configs; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.UIElements.Collections; [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("inoyu.LofiCompany")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.1.1.0")] [assembly: AssemblyInformationalVersion("1.1.1+7222105f85d3d9e93eca76505c9980a19cf203e9")] [assembly: AssemblyProduct("LofiCompany")] [assembly: AssemblyTitle("inoyu.LofiCompany")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 LofiCompany { internal class AudioUtils { private const float fadeAmount = 0.07f; private const float delayBetweenSteps = 0.2f; public static IEnumerator FadeOutMusicSource(AudioSource audioSource) { LofiCompany.Logger.LogInfo((object)("fading out: " + ((Object)audioSource).name)); float initialVolume = audioSource.volume; while (audioSource.volume > 0.1f) { audioSource.volume -= 0.07f; yield return (object)new WaitForSeconds(0.2f); } audioSource.Stop(); audioSource.volume = initialVolume; } public static IEnumerator FadeInMusicSource(AudioSource audioSource, float initialVolume) { LofiCompany.Logger.LogInfo((object)("fading in: " + ((Object)audioSource).name)); audioSource.volume = 0f; while (audioSource.volume < initialVolume) { audioSource.volume += 0.07f; yield return (object)new WaitForSeconds(0.2f); } audioSource.volume = initialVolume; } } [BepInPlugin("inoyu.LofiCompany", "LofiCompany", "1.1.1")] [BepInDependency("com.sigurd.csync", "5.0.1")] public class LofiCompany : BaseUnityPlugin { internal static string ASSET_BUNDLE_NAME = "lofiassetbundle"; internal static AssetBundle? lofiAssetBundle; internal static LofiConfigs lofiConfigs; internal static List<AudioClip> allLofiSongs = new List<AudioClip>(); internal static List<AudioClip> lofiSongsInQueue = new List<AudioClip>(); internal static List<AudioClip> playedLofiSongs = new List<AudioClip>(); internal static List<LevelWeatherType> lofiWeatherTypes = new List<LevelWeatherType>(); internal static List<DayMode> lofiDayModes = new List<DayMode>(); internal static bool wasLofiStopped = false; public static LofiCompany Instance { get; private set; } = null; internal static ManualLogSource Logger { get; private set; } = null; internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; lofiConfigs = new LofiConfigs(((BaseUnityPlugin)this).Config); LoadLofiMusic(); if (lofiSongsInQueue.Count > 0) { Patch(); Logger.LogInfo((object)"inoyu.LofiCompany v1.1.1 has loaded!"); } else { Logger.LogError((object)("ERROR_01: Couldn't load lofi songs. Make sure the assetbundle (" + ASSET_BUNDLE_NAME + ") is located next to this mod's assembly file.")); } } internal static void Patch() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("inoyu.LofiCompany"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } internal static void LoadLofiMusic() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string text = Path.Combine(directoryName, ASSET_BUNDLE_NAME); lofiAssetBundle = AssetBundle.LoadFromFile(text); AudioClip[] array = lofiAssetBundle.LoadAllAssets<AudioClip>(); List<AudioClip> list = new List<AudioClip>(array.Length); list.AddRange(array); allLofiSongs = list; lofiSongsInQueue.AddRange(allLofiSongs); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "inoyu.LofiCompany"; public const string PLUGIN_NAME = "LofiCompany"; public const string PLUGIN_VERSION = "1.1.1"; } } namespace LofiCompany.Patches { [HarmonyPatch(typeof(StartOfRound))] public class PlayLofiPatch { private static Random random = new Random(0); private static int[] hoursMinutes = new int[2]; private static int currentHours = 0; private static int currentMinutes = 0; private static int chancePerAttempt = 30; private static int attemptsPerHour = 1; private static float musicVolume = 0.2f; private static float playerShipLeaveTimer = 15f; private static int[] lofiTimestamps = new int[chancePerAttempt]; private static int lastCheckedTimestamp = -1; private static bool wasShipPowerSurged = false; private static bool isPlayingLofiSong = false; private static bool isPlayingMusicNextOpportunity = false; private static bool isShiproomEmpty = false; [HarmonyPatch("Update")] [HarmonyPostfix] public static void PlayLofiAtRandom(StartOfRound __instance) { //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) chancePerAttempt = LofiCompany.lofiConfigs.chancePerAttempt.Value; attemptsPerHour = LofiCompany.lofiConfigs.attemptsPerHour.Value; musicVolume = LofiCompany.lofiConfigs.musicVolume.Value; UpdateWasShipPowerSurged(); hoursMinutes = GetCurrentHoursAndMinutes(); if (currentMinutes != hoursMinutes[1]) { currentMinutes = hoursMinutes[1]; } if (currentHours != hoursMinutes[0]) { currentHours = hoursMinutes[0]; currentMinutes = 0; } if (IsAPlayerInShiproom()) { playerShipLeaveTimer = LofiCompany.lofiConfigs.playerLeaveShipTimer.Value; isShiproomEmpty = false; } else if (playerShipLeaveTimer > 0f) { playerShipLeaveTimer -= Time.deltaTime; } else { isShiproomEmpty = true; } bool flag = !__instance.speakerAudioSource.isPlaying && !__instance.shipIsLeaving && __instance.shipHasLanded && !__instance.inShipPhase && (!LofiCompany.wasLofiStopped || !SyncedEntry<bool>.op_Implicit(LofiCompany.lofiConfigs.isLofiStopActive)); if (!isPlayingLofiSong && flag && IsAPlayerInShiproom()) { LevelWeatherType currentLevelWeather = TimeOfDay.Instance.currentLevelWeather; DayMode dayMode = TimeOfDay.Instance.dayMode; bool flag2 = LofiCompany.lofiWeatherTypes.Contains(currentLevelWeather) || LofiConfigs.areAllWeatherTypesAccepted; bool flag3 = LofiCompany.lofiDayModes.Contains(dayMode) || LofiConfigs.areAllDayModesAccepted; if (flag2 && flag3) { if (lofiTimestamps.Contains(currentMinutes) && currentMinutes != lastCheckedTimestamp && !IsDiscoAudioPlaying()) { lastCheckedTimestamp = currentMinutes; isPlayingMusicNextOpportunity = IsPlayingOnNextOpportunity(); } if (isPlayingMusicNextOpportunity) { PlayRandomSong(__instance); } } } if (!isPlayingLofiSong) { return; } AudioSource speakerAudioSource = __instance.speakerAudioSource; speakerAudioSource.volume = musicVolume; bool flag4 = __instance.inShipPhase || __instance.shipIsLeaving || isShiproomEmpty; if (!speakerAudioSource.isPlaying || flag4) { LofiCompany.Logger.LogInfo((object)"stopping music"); isPlayingLofiSong = false; if (flag4) { ((MonoBehaviour)__instance).StartCoroutine(AudioUtils.FadeOutMusicSource(speakerAudioSource)); } isPlayingMusicNextOpportunity = false; } if (TimeOfDay.Instance.TimeOfDayMusic.isPlaying) { TimeOfDay.Instance.TimeOfDayMusic.Stop(); } } [HarmonyPatch("PowerSurgeShip")] [HarmonyPrefix] public static void ShipPowerSurgeListener() { wasShipPowerSurged = true; } [HarmonyPatch("OnShipLandedMiscEvents")] [HarmonyPrefix] public static void OnShipLanded(StartOfRound __instance) { //IL_0052: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) if (LofiCompany.lofiSongsInQueue.Count != LofiCompany.allLofiSongs.Count) { ResetMusicQueue(); } CalcAllLofiTimestamps(); LofiCompany.lofiConfigs.ParseLofiConditions(); LofiCompany.wasLofiStopped = false; for (int i = 0; i < LofiCompany.lofiWeatherTypes.Count; i++) { ManualLogSource logger = LofiCompany.Logger; LevelWeatherType val = LofiCompany.lofiWeatherTypes[i]; logger.LogDebug((object)("lofi weather selection includes: " + ((object)(LevelWeatherType)(ref val)).ToString())); } for (int j = 0; j < LofiCompany.lofiDayModes.Count; j++) { ManualLogSource logger2 = LofiCompany.Logger; DayMode val2 = LofiCompany.lofiDayModes[j]; logger2.LogDebug((object)("lofi daytime selection includes: " + ((object)(DayMode)(ref val2)).ToString())); } random = new Random(__instance.randomMapSeed); } [HarmonyPatch("DisableShipSpeaker")] [HarmonyPrefix] public static void DisablePlaybackForTheDay() { if (isPlayingLofiSong) { LofiCompany.wasLofiStopped = true; } } private static bool IsPlayingOnNextOpportunity() { int num = random.Next(0, 100); return num < chancePerAttempt; } private static void CalcAllLofiTimestamps() { int num = 60 / attemptsPerHour; lofiTimestamps = new int[attemptsPerHour]; for (int i = 0; i < attemptsPerHour; i++) { lofiTimestamps[i] = num * i; } } private static int[] GetCurrentHoursAndMinutes() { if ((Object)(object)TimeOfDay.Instance.currentLevel == (Object)null || (Object)(object)StartOfRound.Instance.currentLevel == (Object)null) { return new int[2] { 999, 999 }; } float num = TimeOfDay.Instance.CalculatePlanetTime(StartOfRound.Instance.currentLevel); float num2 = num / TimeOfDay.Instance.lengthOfHours; return new int[2] { (int)num2 + 6, (int)((num2 - (float)(int)num2) * 60f) }; } private static void PlayRandomSong(StartOfRound startOfRound) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if (TimeOfDay.Instance.TimeOfDayMusic.isPlaying) { ((MonoBehaviour)startOfRound).StartCoroutine(AudioUtils.FadeOutMusicSource(TimeOfDay.Instance.TimeOfDayMusic)); } if (LofiCompany.lofiSongsInQueue.Count <= 0) { ResetMusicQueue(); } AudioSource speakerAudioSource = startOfRound.speakerAudioSource; AudioClip val = LofiCompany.lofiSongsInQueue[random.Next(0, LofiCompany.lofiSongsInQueue.Count - 1)]; LofiCompany.lofiSongsInQueue.Remove(val); ((MonoBehaviour)startOfRound).StartCoroutine(AudioUtils.FadeInMusicSource(speakerAudioSource, musicVolume)); speakerAudioSource.volume = 0f; speakerAudioSource.PlayOneShot(val); isPlayingLofiSong = true; LofiCompany.Logger.LogInfo((object)$"Hello and good {TimeOfDay.Instance.dayMode}! It is {GetTimeAsString()} and the company wants to play some music."); LofiCompany.Logger.LogInfo((object)("The ship's speakers are now playing: \n " + ((Object)val).name)); } private static string GetTimeAsString() { StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = new StringBuilder(); stringBuilder.Append(currentHours); stringBuilder2.Append(currentMinutes); if (stringBuilder.Length == 1) { stringBuilder.Insert(0, 0); } if (stringBuilder2.Length == 1) { stringBuilder2.Insert(0, 0); } return stringBuilder.Append(':').Append(stringBuilder2).ToString(); } private static void UpdateWasShipPowerSurged() { if (wasShipPowerSurged && StartOfRound.Instance.shipRoomLights.areLightsOn) { wasShipPowerSurged = false; } } private static void ResetMusicQueue() { LofiCompany.lofiSongsInQueue.Clear(); LofiCompany.lofiSongsInQueue.AddRange(LofiCompany.allLofiSongs); } private static bool IsAPlayerInShiproom() { for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { if (StartOfRound.Instance.allPlayerScripts[i].isInHangarShipRoom) { return true; } } return false; } private static bool IsDiscoAudioPlaying() { GameObject val = GameObject.Find("DiscoBallContainer(Clone)/AnimContainer/Audio") ?? GameObject.Find("DiscoBallContainer/AnimContainer/Audio"); if ((Object)(object)val != (Object)null) { AudioSource component = val.GetComponent<AudioSource>(); return (Object)(object)component != (Object)null && component.isPlaying; } return false; } } } namespace LofiCompany.Configs { [DataContract] public class LofiConfigs : SyncedConfig2<LofiConfigs> { private const string CONDITIONS_SEPARATOR = ", "; private const string CONDITIONS_KEYWORD_ALL = "ALL"; private const string CONDITIONS_KEYWORD_DEFAULT = "DEFAULT"; private const int MIN_ATTEMPTS_PER_HOUR = 1; private const int MAX_ATTEMPTS_PER_HOUR = 30; private const int MIN_CHANCE = 0; private const int MAX_CHANCE = 100; private const float MIN_VOLUME = 0.01f; private const float MAX_VOLUME = 1f; private const float MIN_LEAVE_TIMER = 1f; private const float MAX_LEAVE_TIMER = 3000f; private static Dictionary<string, LevelWeatherType> weatherKeywords = new Dictionary<string, LevelWeatherType>(); private static Dictionary<string, DayMode> dayModeKeywords = new Dictionary<string, DayMode>(); internal static bool areAllWeatherTypesAccepted = false; internal static bool areAllDayModesAccepted = false; internal const string defaultLofiWeatherTypes = "RAINY, STORMY, FLOODED"; internal const string defaultLofiDaytimes = "NOON, SUNDOWN"; internal const int attemptsPerHourBaseValue = 1; internal const int defaultChancePerAttempt = 30; internal const float defaultMusicVolume = 0.2f; internal const float defaultPlayerLeaveShipTimer = 15f; [SyncedEntryField] public SyncedEntry<string> dayModes; [SyncedEntryField] public SyncedEntry<string> weatherTypes; [SyncedEntryField] public SyncedEntry<float> playerLeaveShipTimer; [SyncedEntryField] public SyncedEntry<int> attemptsPerHour; [SyncedEntryField] public SyncedEntry<int> chancePerAttempt; [SyncedEntryField] public SyncedEntry<float> musicVolume; [SyncedEntryField] public SyncedEntry<bool> isLofiStopActive; public LofiConfigs(ConfigFile cfg) : base("LofiCompany") { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown InitWeatherKeywords(); InitDayModeKeywords(); weatherTypes = SyncedBindingExtensions.BindSyncedEntry<string>(cfg, "LofiConditions", "weatherTypes", "RAINY, STORMY, FLOODED", "Lofi music will only be played under these weather conditions. \nPlease write the weather types in caps and separated by a comma and a whitespace (eg. 'RAINY, FOGGY'). \nFollowing input will be accepted: RAINY, STORMY, FLOODED, ECLIPSED, FOGGY, DUSTCLOUDS, NORMAL, ALL, DEFAULT (with 'NORMAL' being the standard sunny day)"); dayModes = SyncedBindingExtensions.BindSyncedEntry<string>(cfg, "LofiConditions", "dayModes", "NOON, SUNDOWN", "Lofi music will only be played at these times of the day. \nPlease write the day types in caps and separated by a comma and a whitespace (eg. 'NOONE, SUNRISE'). \nFollowing input will be accepted: SUNRISE, NOON, SUNDOWN, MIDNIGHT, ALL, DEFAULT"); playerLeaveShipTimer = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "LofiConditions", "playerLeaveShipTimer", 15f, new ConfigDescription("If all players leave the shiproom, after this amount of seconds lofi will stop playing.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 3000f), Array.Empty<object>())); attemptsPerHour = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "LofiMusicChance", "attemptsPerHour", 1, new ConfigDescription("This determines how often the company will try to put on some lofi music per hour (if LofiConditions are met). \nOne try per hour is the minimum.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 30), Array.Empty<object>())); chancePerAttempt = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "LofiMusicChance", "chancePerAttempt", 30, new ConfigDescription("This determines how likely it is that lofi will be played (per attempt). \nThis Value is a percentage, so 100 is the max value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); musicVolume = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "LofiMusic", "musicVolume", 0.2f, new ConfigDescription("This is the music volume. \nMax volume is at 1, min is 0.1.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f), Array.Empty<object>())); isLofiStopActive = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "LofiConditions", "dontPlayLofiAfterStop", false, "If enabled, LofiMusic will stop and not play for the rest of the day after turning off the speaker."); ConfigManager.Register<LofiConfigs>((SyncedConfig2<LofiConfigs>)(object)this); } private void InitWeatherKeywords() { if (weatherKeywords == null) { weatherKeywords = new Dictionary<string, LevelWeatherType>(); } weatherKeywords.Clear(); weatherKeywords.Add("RAINY", (LevelWeatherType)1); weatherKeywords.Add("STORMY", (LevelWeatherType)2); weatherKeywords.Add("FLOODED", (LevelWeatherType)4); weatherKeywords.Add("ECLIPSED", (LevelWeatherType)5); weatherKeywords.Add("FOGGY", (LevelWeatherType)3); weatherKeywords.Add("DUSTCLOUDS", (LevelWeatherType)0); weatherKeywords.Add("NORMAL", (LevelWeatherType)(-1)); } private void InitDayModeKeywords() { if (dayModeKeywords == null) { dayModeKeywords = new Dictionary<string, DayMode>(); } dayModeKeywords.Clear(); dayModeKeywords.Add("SUNRISE", (DayMode)0); dayModeKeywords.Add("NOON", (DayMode)1); dayModeKeywords.Add("SUNDOWN", (DayMode)2); dayModeKeywords.Add("MIDNIGHT", (DayMode)3); } internal void ParseLofiConditions() { InitWeatherKeywords(); InitDayModeKeywords(); ParseWeatherConditions(); ParseDayModeConditions(); } private void ParseWeatherConditions() { //IL_00be: Unknown result type (might be due to invalid IL or missing references) List<LevelWeatherType> list = new List<LevelWeatherType>(); string[] array = weatherTypes.Value.Split(", "); List<string> list2 = new List<string>(array.Length); list2.AddRange(array); List<string> list3 = list2; areAllWeatherTypesAccepted = false; if (list3.Contains("ALL")) { areAllWeatherTypesAccepted = true; list.AddRange(weatherKeywords.Values); } else if (list3.Contains("DEFAULT")) { list.Add((LevelWeatherType)1); list.Add((LevelWeatherType)2); list.Add((LevelWeatherType)4); } else { for (int i = 0; i < list3.Count; i++) { if (weatherKeywords.ContainsKey(list3[i])) { list.Add(DictionaryExtensions.Get<string, LevelWeatherType>((IDictionary<string, LevelWeatherType>)weatherKeywords, list3[i], (LevelWeatherType)0)); } else { LofiCompany.Logger.LogError((object)("ERROR_02: There was an error with parsing a weather type: \"" + list3[i] + "\". Make sure the weather was typed in correctly!")); } } } if (list.Count == 0) { LofiCompany.Logger.LogError((object)"ERROR_03: No weather types were found, will reset to standard ones."); list.Add((LevelWeatherType)1); list.Add((LevelWeatherType)2); list.Add((LevelWeatherType)4); } LofiCompany.lofiWeatherTypes.Clear(); LofiCompany.lofiWeatherTypes.AddRange(list); } private void ParseDayModeConditions() { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) List<DayMode> list = new List<DayMode>(); string[] array = dayModes.Value.Split(", "); List<string> list2 = new List<string>(array.Length); list2.AddRange(array); List<string> list3 = list2; areAllDayModesAccepted = false; if (list3.Contains("ALL")) { areAllDayModesAccepted = true; list.AddRange(dayModeKeywords.Values); } else if (list3.Contains("DEFAULT")) { list.Add((DayMode)1); list.Add((DayMode)2); } else { for (int i = 0; i < list3.Count; i++) { if (dayModeKeywords.ContainsKey(list3[i])) { list.Add(DictionaryExtensions.Get<string, DayMode>((IDictionary<string, DayMode>)dayModeKeywords, list3[i], (DayMode)0)); } else { LofiCompany.Logger.LogError((object)("ERROR_04: There was an error with parsing a day mode: \"" + list3[i] + "\". Make sure the time of day was typed in correctly!")); } } } if (list.Count == 0) { LofiCompany.Logger.LogError((object)"ERROR_05: No day modes were found, will reset to standard ones."); list.Add((DayMode)1); list.Add((DayMode)2); } LofiCompany.lofiDayModes.Clear(); LofiCompany.lofiDayModes.AddRange(list); } } }