Decompiled source of IdleActorsShaderFix v0.2.0

plugins/Streamiapp-IdleActorsShaderFix/StreamiappIdleActorsShaderFix.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BalrondIdleActors;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[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("StreamiappIdleActorsShaderFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("StreamiappIdleActorsShaderFix")]
[assembly: AssemblyTitle("StreamiappIdleActorsShaderFix")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 StreamiappIdleActorsShaderFix
{
	[BepInPlugin("streamiapp.idleactors.shaderfix", "Streamiapp IdleActors Shader Fix", "0.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class IdleActorsShaderFixPlugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			_harmony = new Harmony("streamiapp.idleactors.shaderfix");
			PatchSkip(typeof(ShaderReplacment), "runMaterialFix", "shader material replacement");
			PatchSkip("BalrondIdleActors.BalrondActor", "Awake", "BalrondActor.Awake");
			PatchSkip("BalrondIdleActors.BalrondActor", "Start", "BalrondActor.Start");
			PatchSkip("BalrondIdleActors.BalrondActorTalker", "Start", "BalrondActorTalker.Start");
			PatchSkip("BalrondIdleActors.BalrondActorTalker", "Update", "BalrondActorTalker.Update");
			PatchSkip("BalrondIdleActors.BalrondActorNamePicker", "Start", "BalrondActorNamePicker.Start");
			((BaseUnityPlugin)this).Logger.LogWarning((object)"DIAGNOSTIC SAFE MODE active: IdleActors custom NPC lifecycle is disabled; prefabs should render only.");
		}

		private void PatchSkip(Type type, string methodName, string label)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			MethodInfo methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null);
			if (methodInfo == null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Could not find " + label));
				return;
			}
			_harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(IdleActorsShaderFixPlugin), "Skip", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Disabled for diagnostic test: " + label));
		}

		private void PatchSkip(string typeName, string methodName, string label)
		{
			Type type = AccessTools.TypeByName(typeName);
			if (type == null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Could not find type " + typeName));
			}
			else
			{
				PatchSkip(type, methodName, label);
			}
		}

		private static bool Skip()
		{
			return false;
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}