Please disclose if your mod was created primarily 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 V70PoweredLights Fix v1.2.1
V72LightFix.dll
Decompiled 5 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using DunGen; using HarmonyLib; using Microsoft.CodeAnalysis; 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("V72LightFix")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("V72LightFix")] [assembly: AssemblyTitle("V72LightFix")] [assembly: AssemblyVersion("1.0.0.0")] [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; } } internal static class IsExternalInit { } } namespace V72LightFix { internal static class PoweredLightsAnimators { private delegate void ManualPatch(GameObject animatorContainer); private readonly record struct AnimatorPatch(string AnimatorContainerPath, RuntimeAnimatorController AnimatorController, bool AddTagAndAnimator, ManualPatch? ManualPatch); private readonly record struct TilePatch(string TileName, AnimatorPatch[] Patches) { public readonly string TileCloneName = TileName + "(Clone)"; } private readonly record struct AnimatorPatchDescriptor(string AnimatorContainerPath, string AnimatorControllerAssetPath, bool AddTagAndAnimator = false, ManualPatch? ManualPatch = null) { public AnimatorPatch Load(AssetBundle assetBundle) { RuntimeAnimatorController animatorController = assetBundle.LoadAsset<RuntimeAnimatorController>(AnimatorControllerAssetPath) ?? throw new FileNotFoundException("RuntimeAnimatorController not found: " + AnimatorControllerAssetPath, AnimatorControllerAssetPath); return new AnimatorPatch(AnimatorContainerPath, animatorController, AddTagAndAnimator, ManualPatch); } } private readonly record struct TilePatchDescriptor(string[] TileNames, AnimatorPatchDescriptor[] Descriptors) { public TilePatchDescriptor(string[] TileNames, AnimatorPatchDescriptor[] Descriptors) { this.TileNames = TileNames; this.Descriptors = Descriptors; } public TilePatchDescriptor(string TileName, AnimatorPatchDescriptor[] Descriptors) : this(new string[1] { TileName }, Descriptors) { } public TilePatch[] Load(AssetBundle assetBundle) { AnimatorPatch[] patches = Descriptors.Select((AnimatorPatchDescriptor d) => d.Load(assetBundle)).ToArray(); return TileNames.Select((string tileName) => new TilePatch(tileName, patches)).ToArray(); } } private const string PoweredLightTag = "PoweredLight"; private static IDictionary<string, TilePatch> Patches = new Dictionary<string, TilePatch>(); private static AudioClip AudioClipOn = null; private static AudioClip AudioClipOff = null; private static AudioClip AudioClipFlicker = null; public static void Load() { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "poweredlightsanimators"); AssetBundle assetBundle = AssetBundle.LoadFromFile(text) ?? throw new NullReferenceException("Failed to load bundle"); AudioClipOn = assetBundle.LoadAsset<AudioClip>("Assets/LethalCompany/Mods/MuzikaGromche/AudioClips/LightOn.ogg"); AudioClipOff = assetBundle.LoadAsset<AudioClip>("Assets/LethalCompany/Mods/MuzikaGromche/AudioClips/LightOff.ogg"); AudioClipFlicker = assetBundle.LoadAsset<AudioClip>("Assets/LethalCompany/Mods/MuzikaGromche/AudioClips/LightFlicker.ogg"); TilePatchDescriptor[] source = new TilePatchDescriptor[10] { new TilePatchDescriptor("KitchenTile", new AnimatorPatchDescriptor[2] { new AnimatorPatchDescriptor("PoweredLightTypeB", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/Point Light (4) (Patched).controller"), new AnimatorPatchDescriptor("PoweredLightTypeB (1)", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/Point Light (4) (Patched).controller") }), new TilePatchDescriptor("ManorStartRoom", new AnimatorPatchDescriptor[2] { new AnimatorPatchDescriptor("ManorStartRoom/Chandelier/PoweredLightTypeB (1)", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/Point Light (4) (Patched).controller"), new AnimatorPatchDescriptor("ManorStartRoom/Chandelier2/PoweredLightTypeB", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/Point Light (4) (Patched).controller") }), new TilePatchDescriptor("ManorStartRoomSmall", new AnimatorPatchDescriptor[2] { new AnimatorPatchDescriptor("ManorStartRoomMesh/Chandelier/PoweredLightTypeB (1)", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/Point Light (4) (Patched).controller"), new AnimatorPatchDescriptor("ManorStartRoomMesh/Chandelier2/PoweredLightTypeB", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/Point Light (4) (Patched).controller") }), new TilePatchDescriptor("NarrowHallwayTile2x2", new AnimatorPatchDescriptor[2] { new AnimatorPatchDescriptor("MineshaftSpotlight (1)", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/MineshaftSpotlight (Patched).controller"), new AnimatorPatchDescriptor("MineshaftSpotlight (2)", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/MineshaftSpotlight (Patched).controller") }), new TilePatchDescriptor("BirthdayRoomTile", new AnimatorPatchDescriptor[1] { new AnimatorPatchDescriptor("Lights/MineshaftSpotlight", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/MineshaftSpotlight (Patched).controller") }), new TilePatchDescriptor("BathroomTileContainer", new AnimatorPatchDescriptor[2] { new AnimatorPatchDescriptor("MineshaftSpotlight", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/MineshaftSpotlight (Patched).controller"), new AnimatorPatchDescriptor("LightbulbLine/lightbulbsLineMesh", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/lightbulbsLineMesh (Patched).controller") }), new TilePatchDescriptor(new string[2] { "BedroomTile", "BedroomTileB" }, new AnimatorPatchDescriptor[2] { new AnimatorPatchDescriptor("CeilingFanAnimContainer", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/CeilingFan (originally GameObject) (Patched).controller"), new AnimatorPatchDescriptor("MineshaftSpotlight (1)", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/MineshaftSpotlight (Patched).controller") }), new TilePatchDescriptor("GarageTile", new AnimatorPatchDescriptor[2] { new AnimatorPatchDescriptor("HangingLEDBarLight (3)", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/LEDHangingLight (Patched).controller"), new AnimatorPatchDescriptor("HangingLEDBarLight (4)", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/LEDHangingLight (Patched).controller") }), new TilePatchDescriptor("PoolTile", new AnimatorPatchDescriptor[3] { new AnimatorPatchDescriptor("PoolLights/HangingLEDBarLight", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/LEDHangingLight (Patched).controller"), new AnimatorPatchDescriptor("PoolLights/HangingLEDBarLight (4)", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/LEDHangingLight (Patched).controller"), new AnimatorPatchDescriptor("PoolLights/HangingLEDBarLight (5)", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/LEDHangingLight (Patched).controller") }), new TilePatchDescriptor("MineshaftStartTile", new AnimatorPatchDescriptor[2] { new AnimatorPatchDescriptor("Cylinder.001 (1)", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/MineshaftStartTileSpotlight (New).controller", AddTagAndAnimator: true), new AnimatorPatchDescriptor("Cylinder.001 (2)", "Assets/LethalCompany/Mods/MuzikaGromche/AnimatorControllers/MineshaftStartTileSpotlight (New).controller", AddTagAndAnimator: true) }) }; Patches = source.SelectMany((TilePatchDescriptor d) => d.Load(assetBundle)).ToDictionary((TilePatch d) => d.TileCloneName, (TilePatch d) => d); } public static void Patch(Tile tile) { //IL_019b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)tile == (Object)null) { throw new ArgumentNullException("tile"); } if (!Patches.TryGetValue(((Object)((Component)tile).gameObject).name, out var value)) { return; } AnimatorPatch[] patches = value.Patches; PlayAudioAnimationEvent val3 = default(PlayAudioAnimationEvent); AudioSource val4 = default(AudioSource); for (int i = 0; i < patches.Length; i++) { AnimatorPatch animatorPatch = patches[i]; Transform val = ((Component)tile).gameObject.transform.Find(animatorPatch.AnimatorContainerPath); if ((Object)(object)val == (Object)null) { throw new NullReferenceException(value.TileName + "/" + animatorPatch.AnimatorContainerPath + " Animation Container not found"); } GameObject gameObject = ((Component)val).gameObject; Animator val2 = gameObject.GetComponent<Animator>(); if (animatorPatch.AddTagAndAnimator) { gameObject.tag = "PoweredLight"; if ((Object)(object)val2 == (Object)null) { val2 = gameObject.AddComponent<Animator>(); } if (!gameObject.TryGetComponent<PlayAudioAnimationEvent>(ref val3)) { val3 = gameObject.AddComponent<PlayAudioAnimationEvent>(); val3.audioClip = AudioClipOn; val3.audioClip2 = AudioClipOff; val3.audioClip3 = AudioClipFlicker; } if (!gameObject.TryGetComponent<AudioSource>(ref val4)) { AudioSource componentInChildren = ((Component)tile).gameObject.GetComponentInChildren<AudioSource>(); if ((Object)(object)componentInChildren != (Object)null) { val4 = gameObject.AddComponent<AudioSource>(); val4.spatialBlend = 1f; val4.playOnAwake = false; val4.outputAudioMixerGroup = componentInChildren.outputAudioMixerGroup; val4.spread = componentInChildren.spread; val4.rolloffMode = componentInChildren.rolloffMode; val4.maxDistance = componentInChildren.maxDistance; val4.SetCustomCurve((AudioSourceCurveType)0, componentInChildren.GetCustomCurve((AudioSourceCurveType)0)); } } } if ((Object)(object)val2 == (Object)null) { throw new NullReferenceException(value.TileName + "/" + animatorPatch.AnimatorContainerPath + " Animation Component not found"); } animatorPatch.ManualPatch?.Invoke(gameObject); val2.runtimeAnimatorController = animatorPatch.AnimatorController; Debug.Log((object)("PoweredLightsAnimatorsPatch " + value.TileName + "/" + animatorPatch.AnimatorContainerPath + ": Replaced animator controller")); } } } [HarmonyPatch(typeof(Tile), "AddTriggerVolume")] internal static class PoweredLightsAnimatorsPatch { [HarmonyPostfix] public static void OnAddTriggerVolume(Tile __instance) { if (((Object)((Component)__instance).gameObject).name.Contains("BathroomTileContainer")) { Transform val = ((Component)__instance).gameObject.transform.Find("MineshaftSpotlight"); ((Component)val).tag = "PoweredLight"; Debug.Log((object)"Fixed Lights at BathRoom"); } if (((Object)((Component)__instance).gameObject).name.Contains("BirthdayRoomTile")) { Transform val2 = ((Component)__instance).gameObject.transform.Find("Lights/MineshaftSpotlight"); ((Component)val2).tag = "PoweredLight"; Debug.Log((object)"Fixed Lights at PartyRoom"); } if (((Object)((Component)__instance).gameObject).name.Contains("BedroomTile")) { Transform val3 = ((Component)__instance).gameObject.transform.Find("MineshaftSpotlight (1)"); ((Component)val3).tag = "PoweredLight"; Debug.Log((object)"Fixed Lights at Bedroom"); } if (((Object)((Component)__instance).gameObject).name.Contains("BedroomTileB")) { Transform val4 = ((Component)__instance).gameObject.transform.Find("MineshaftSpotlight (1)"); ((Component)val4).tag = "PoweredLight"; Debug.Log((object)"Fixed Lights at BedroomB"); } if (((Object)((Component)__instance).gameObject).name.Contains("PoolTile")) { Transform val5 = ((Component)__instance).gameObject.transform.Find("PoolLights/HangingLEDBarLight"); Transform val6 = ((Component)__instance).gameObject.transform.Find("PoolLights/HangingLEDBarLight (4)"); Transform val7 = ((Component)__instance).gameObject.transform.Find("PoolLights/HangingLEDBarLight (5)"); ((Component)val5).tag = "PoweredLight"; ((Component)val6).tag = "PoweredLight"; ((Component)val7).tag = "PoweredLight"; Debug.Log((object)"Fixed Lights at SwimingPool"); } if (((Object)((Component)__instance).gameObject).name.Contains("GarageTile")) { Transform val8 = ((Component)__instance).gameObject.transform.Find("HangingLEDBarLight (4)/IndirectLight (1)"); ((Object)((Component)val8).gameObject).name = "IndirectLight"; } PoweredLightsAnimators.Patch(__instance); } } [BepInPlugin("watergun.v72lightfix", "V72LightFix", "1.2.1")] public class Plugin : BaseUnityPlugin { private const string GUID = "watergun.v72lightfix"; private const string NAME = "V72LightFix"; private const string VER = "1.2.1"; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("watergun.v72lightfix"); val.PatchAll(); PoweredLightsAnimators.Load(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded!"); } } }