using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using WildSkies.Puzzles;
[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("MemoryLeakFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Nines (Natives)")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("MemoryLeakFix")]
[assembly: AssemblyTitle("MemoryLeakFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace MemoryLeakFix
{
[BepInPlugin("MemoryLeakFix", "MemoryLeakFix", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
internal static Harmony harmonyInstance;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin MemoryLeakFix is loaded!");
harmonyInstance = Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
}
private void OnDestroy()
{
Harmony obj = harmonyInstance;
if (obj != null)
{
obj.UnpatchSelf();
}
}
[HarmonyPatch(typeof(Switch), "Start")]
[HarmonyPostfix]
public static void Switch_Start(Switch __instance, ref Material ____materialLocked, ref Material ____materialOff, ref Material ____materialOn)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
//IL_0043: 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)
//IL_0060: Expected O, but got Unknown
____materialLocked = new Material(____materialLocked)
{
name = ((Object)____materialLocked).name + "_SwitchClone"
};
____materialOff = new Material(____materialOff)
{
name = ((Object)____materialOff).name + "_SwitchClone"
};
____materialOn = new Material(____materialOn)
{
name = ((Object)____materialOn).name + "_SwitchClone"
};
}
[HarmonyPatch(typeof(Switch), "MaterialChange")]
[HarmonyPrefix]
public static bool Switch_MaterialChange(Switch __instance, EntityRendererController ____entityRendererController, Renderer[] ____materialSwitchRenderers, Material ____materialLocked, Material ____materialOff, Material ____materialOn)
{
if (____materialSwitchRenderers != null)
{
Material val = ((!((PuzzleModule)__instance).Active) ? ____materialOff : (__instance._isSwitched ? ____materialOn : ____materialLocked));
foreach (Renderer val2 in ____materialSwitchRenderers)
{
____entityRendererController.SetNewDefaultMaterialsOnRenderer(val2, (Material[])(object)new Material[1] { val });
}
}
return false;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "MemoryLeakFix";
public const string PLUGIN_NAME = "MemoryLeakFix";
public const string PLUGIN_VERSION = "1.0.1";
}
}