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 CleanerChef v1.1.0
CleanerChef.dll
Decompiled 4 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using On.RoR2.Items; using RiskOfOptions; using RiskOfOptions.Options; using RoR2; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CleanerChef")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+6ed9be97ee76b107423015e50ad61a37c911c646")] [assembly: AssemblyProduct("CleanerChef")] [assembly: AssemblyTitle("CleanerChef")] [assembly: AssemblyVersion("1.0.0.0")] namespace CleanerChef; [BepInPlugin("rainorshine.CleanChef", "CleanChef", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class CleanerChef : BaseUnityPlugin { public const string PluginGUID = "rainorshine.CleanChef"; public const string PluginName = "CleanChef"; public const string PluginVersion = "1.1.0"; public static ConfigEntry<bool> HaltCorruption; private static Dictionary<string, ConfigEntry<bool>> _stageBlacklistConfigs = new Dictionary<string, ConfigEntry<bool>>(); private static bool _chefFoundInCurrentStage = false; internal static ManualLogSource Log; public void Awake() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; HaltCorruption = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Halt Void Corruption", true, "Master toggle for the mod logic."); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(HaltCorruption)); CleanerChefAPI.RaiseHaltCorruptionChanged(HaltCorruption.Value); HaltCorruption.SettingChanged += OnHaltCorruptionChanged; Stage.onStageStartGlobal += OnStageStart; RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SetupStageConfig)); ContagiousItemManager.StepInventoryInfection += new hook_StepInventoryInfection(OnStepInventoryInfection); } public void OnDestroy() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown HaltCorruption.SettingChanged -= OnHaltCorruptionChanged; RoR2Application.onLoad = (Action)Delegate.Remove(RoR2Application.onLoad, new Action(SetupStageConfig)); Stage.onStageStartGlobal -= OnStageStart; ContagiousItemManager.StepInventoryInfection -= new hook_StepInventoryInfection(OnStepInventoryInfection); } private void OnStageStart(Stage stage) { _chefFoundInCurrentStage = false; } private void OnHaltCorruptionChanged(object sender, EventArgs e) { CleanerChefAPI.RaiseHaltCorruptionChanged(HaltCorruption.Value); } private bool OnStepInventoryInfection(orig_StepInventoryInfection orig, Inventory inventory, ItemIndex originalItem, int limit, bool isForced) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (HaltCorruption.Value && !IsCurrentStageBlacklisted() && CheckForChefPresenceCached()) { return false; } return orig.Invoke(inventory, originalItem, limit, isForced); } private void SetupStageConfig() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown string[] source = new string[5] { "moon2", "meridian", "voidstage", "limbo", "mysteryspace" }; foreach (SceneDef item in from s in (IEnumerable<SceneDef>)(object)SceneCatalog.allSceneDefs where ((int)s.sceneType == 1 || (int)s.sceneType == 2) && !string.IsNullOrEmpty(s.nameToken) group s by s.baseSceneName into g select g.First() into s orderby s.baseSceneName select s) { string baseSceneName = item.baseSceneName; if (!_stageBlacklistConfigs.ContainsKey(baseSceneName)) { bool flag = source.Contains(baseSceneName.ToLower()); string text = (Language.IsTokenInvalid(item.nameToken) ? baseSceneName : Language.GetString(item.nameToken)); ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>("Stage Blacklist", baseSceneName, flag, new ConfigDescription("Disable item protection on " + text + "?", (AcceptableValueBase)null, Array.Empty<object>())); _stageBlacklistConfigs[baseSceneName] = val; ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(val)); } } } private bool IsCurrentStageBlacklisted() { SceneDef sceneDefForCurrentScene = SceneCatalog.GetSceneDefForCurrentScene(); if ((Object)(object)sceneDefForCurrentScene != (Object)null && _stageBlacklistConfigs.TryGetValue(sceneDefForCurrentScene.baseSceneName, out var value)) { return value.Value; } return false; } internal static bool CheckForChefPresenceCached() { if (_chefFoundInCurrentStage) { return true; } _chefFoundInCurrentStage = PerformChefPresenceCheck(); return _chefFoundInCurrentStage; } private static bool PerformChefPresenceCheck() { if ((Object)(object)Object.FindObjectOfType<CraftingController>() != (Object)null) { return true; } GameObject[] array = Object.FindObjectsOfType<GameObject>(); for (int i = 0; i < array.Length; i++) { string name = ((Object)array[i]).name; if (name.Contains("CraftingController") || name.Contains("ChefStation")) { return true; } } return false; } } public static class CleanerChefAPI { public static bool HaltCorruptionEnabled { get; internal set; } public static event Action<bool> HaltCorruptionChanged; internal static void RaiseHaltCorruptionChanged(bool enabled) { HaltCorruptionEnabled = enabled; CleanerChefAPI.HaltCorruptionChanged?.Invoke(enabled); } }