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 TetoFumoMod v1.3.0
KasaneTetoMod.dll
Decompiled 9 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using LethalLib.Modules; using Microsoft.CodeAnalysis; using TetoMod; using UnityEngine; [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("KasaneTetoMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("KasaneTetoMod")] [assembly: AssemblyTitle("KasaneTetoMod")] [assembly: AssemblyVersion("1.0.0.0")] 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; } } } namespace TetoMod { [BepInPlugin("astrien.tetomod", "TetoFumoMod", "1.3.0")] public class TetoMod : BaseUnityPlugin { private const string GUID = "astrien.tetomod"; private const string NAME = "TetoFumoMod"; private const string VERSION = "1.3.0"; public static ManualLogSource Logger; public static ConfigFile config; private static List<NoisemakerProp> spawnedTetoFumos = new List<NoisemakerProp>(); private readonly Harmony harmony = new Harmony("astrien.tetomod"); public static ConfigEntry<int> tetoSpawnRarity { get; private set; } public static ConfigEntry<float> tetoMusicVolume { get; private set; } public static ConfigEntry<bool> tetoMute { get; private set; } private static void InitializeConfig() { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00bc: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown //IL_00ec: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown tetoSpawnRarity = config.Bind<int>("TetoFumo Spawn Rarity Settings", "TetoFumo Spawn Rarity", 20, "Sets TetoFumo spawn rarity in maps."); tetoMusicVolume = config.Bind<float>("TetoFumo Music Volume Settings", "TetoFumo Volume", 1f, "Sets TetoFumo Music Volume - Stop and play the music again to see effect of this slider"); tetoMute = config.Bind<bool>("TetoFumo Music Mute/Unmute Settings", "TetoFumo Mute/Unmute", false, "Sets TetoFumo Mute/Unmute"); tetoMusicVolume.SettingChanged += OnVolumeChanged; tetoMute.SettingChanged += OnVolumeChanged; ConfigEntry<int> obj = tetoSpawnRarity; IntSliderOptions val = new IntSliderOptions { RequiresRestart = true }; ((BaseRangeOptions<int>)val).Min = 0; ((BaseRangeOptions<int>)val).Max = 100; IntSliderConfigItem val2 = new IntSliderConfigItem(obj, val); ConfigEntry<float> obj2 = tetoMusicVolume; FloatSliderOptions val3 = new FloatSliderOptions { RequiresRestart = false }; ((BaseRangeOptions<float>)val3).Min = 0f; ((BaseRangeOptions<float>)val3).Max = 1f; FloatSliderConfigItem val4 = new FloatSliderConfigItem(obj2, val3); BoolCheckBoxConfigItem val5 = new BoolCheckBoxConfigItem(tetoMute, new BoolCheckBoxOptions { RequiresRestart = false, Section = "Audio", Name = "Enable Teto Music", Description = "If you hate headaches, tell Teto to shut the hell up." }); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val4); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val5); } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; config = ((BaseUnityPlugin)this).Config; InitializeConfig(); string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "tetofumo"); AssetBundle val = AssetBundle.LoadFromFile(text); Sprite modIcon = val.LoadAsset<Sprite>("Assets/KasaneTeto/icon.png"); LethalConfigManager.SetModIcon(modIcon); Item val2 = val.LoadAsset<Item>("Assets/KasaneTeto/KasaneTetoFumoItem.asset"); NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab); Utilities.FixMixerGroups(val2.spawnPrefab); Items.RegisterScrap(val2, tetoSpawnRarity.Value, (LevelTypes)(-1)); AudioSource component = val2.spawnPrefab.GetComponent<AudioSource>(); if (tetoMute.Value) { component.mute = true; } else { component.mute = false; } NoisemakerProp component2 = val2.spawnPrefab.GetComponent<NoisemakerProp>(); component2.maxLoudness = tetoMusicVolume.Value; component2.minLoudness = tetoMusicVolume.Value; harmony.PatchAll(); MethodInfo method = typeof(NoisemakerProp).GetMethod("ItemActivate"); if (method != null) { Patches patchInfo = Harmony.GetPatchInfo((MethodBase)method); if (patchInfo != null) { Logger.LogInfo((object)$"ItemActivate patches applied: {patchInfo.Prefixes.Count} prefixes"); } else { Logger.LogWarning((object)"No patches found on ItemActivate method!"); } } else { Logger.LogError((object)"ItemActivate method not found on NoisemakerProp!"); } Logger.LogInfo((object)"TetoMod loaded successfully!"); } private static void OnVolumeChanged(object sender, EventArgs e) { Logger.LogInfo((object)$"Volume changed to: {tetoMusicVolume.Value}"); spawnedTetoFumos.RemoveAll((NoisemakerProp x) => (Object)(object)x == (Object)null); Logger.LogInfo((object)$"Found {spawnedTetoFumos.Count} TetoFumos to update"); foreach (NoisemakerProp spawnedTetoFumo in spawnedTetoFumos) { if ((Object)(object)spawnedTetoFumo != (Object)null) { Logger.LogInfo((object)$"Updating TetoFumo: {((Object)spawnedTetoFumo).name} from {spawnedTetoFumo.maxLoudness} to {tetoMusicVolume.Value}"); spawnedTetoFumo.maxLoudness = tetoMusicVolume.Value; spawnedTetoFumo.minLoudness = tetoMusicVolume.Value; AudioSource component = ((Component)spawnedTetoFumo).GetComponent<AudioSource>(); if (tetoMute.Value) { component.mute = true; } else { component.mute = false; } Logger.LogInfo((object)$"Updated TetoFumo loudness values - min: {spawnedTetoFumo.minLoudness}, max: {spawnedTetoFumo.maxLoudness}, isMuted? {component.mute}"); } } Logger.LogInfo((object)"Volume update complete"); } public static void RegisterTetoFumo(NoisemakerProp tetoFumo) { spawnedTetoFumos.Add(tetoFumo); Logger.LogInfo((object)$"Registered TetoFumo: {((Object)tetoFumo).name}. Total count: {spawnedTetoFumos.Count}"); tetoFumo.maxLoudness = tetoMusicVolume.Value; tetoFumo.minLoudness = tetoMusicVolume.Value; AudioSource component = ((Component)tetoFumo).GetComponent<AudioSource>(); if (tetoMute.Value) { component.mute = true; } else { component.mute = false; } Logger.LogInfo((object)$"Set initial volume - min: {tetoFumo.minLoudness}, max: {tetoFumo.maxLoudness}"); } public static bool IsTetoFumo(NoisemakerProp prop) { return ((Object)((Component)prop).gameObject).name.Contains("KasaneTeto") || ((Object)((Component)prop).gameObject).name.Contains("TetoFumo") || ((Object)((Component)prop).gameObject).name.Contains("Teto"); } } [HarmonyPatch(typeof(GrabbableObject), "Start")] public class TetoFumoSpawnPatch { private static void Postfix(GrabbableObject __instance) { NoisemakerProp val = (NoisemakerProp)(object)((__instance is NoisemakerProp) ? __instance : null); if (val != null && TetoMod.IsTetoFumo(val)) { TetoMod.Logger.LogInfo((object)("Found TetoFumo spawning: " + ((Object)__instance).name)); TetoMod.RegisterTetoFumo(val); } } } } namespace KasaneTetoMod.Patches { [HarmonyPatch(typeof(NoisemakerProp))] internal class TetoMuteMusicPatch { private static ManualLogSource Logger => global::TetoMod.TetoMod.Logger; [HarmonyPatch("ItemActivate")] [HarmonyPrefix] private static bool muteMusicPatch(NoisemakerProp __instance) { int instanceID = ((Object)__instance).GetInstanceID(); if (__instance.noiseAudio.isPlaying) { Logger.LogInfo((object)$"STOPPING TETO MUSIC {instanceID}"); __instance.noiseAudio.Stop(); return false; } Logger.LogInfo((object)$"STARTING TETO MUSIC {instanceID}"); __instance.noiseAudio.Play(); return true; } } }