Decompiled source of SilentHillTogether v1.0.1

SilentHillTogether.dll

Decompiled 2 months ago
using 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 System.Security;
using System.Security.Permissions;
using ATBTogether;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.Mono;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SilentHillTogether;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("SilentHillTogether")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+2ce543462ae84abe93a33645cdc7382fc533dbb8")]
[assembly: AssemblyProduct("SilentHillTogether")]
[assembly: AssemblyTitle("SilentHillTogether")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 SilentHillTogether
{
	[BepInPlugin("SilentHillTogether", "SilentHillTogether", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private static bool _initialized;

		private static AssetBundle _bundle;

		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			ManualLogSource logger = Logger;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("SilentHillTogether");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			logger.LogInfo(val);
			Harmony.CreateAndPatchAll(typeof(HeatherPatch), (string)null);
		}

		internal static AssetBundle getAssetBundle()
		{
			if (!_initialized)
			{
				Logger.LogInfo((object)"LOADED ASSETS");
				string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
				_bundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "heather"));
				if ((Object)(object)_bundle == (Object)null)
				{
					throw new SystemException("CAN'T LOAD BUNDLE " + directoryName);
				}
				_initialized = true;
			}
			return _bundle;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SilentHillTogether";

		public const string PLUGIN_NAME = "SilentHillTogether";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ATBTogether
{
	[HarmonyPatch]
	public class HeatherPatch
	{
		[HarmonyPatch(typeof(NPC_Info), "CreateNPCCharacter")]
		[HarmonyPostfix]
		private static void meme(NPC_Info __instance)
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			if (new Random().Next(0, 20) == 8 && !__instance.isEmployee)
			{
				Shader oldShader = ((Renderer)((Component)__instance).GetComponentInChildren<SkinnedMeshRenderer>()).material.shader;
				GameObject gameObject = ((Component)((Component)__instance).GetComponentInChildren<SkinnedMeshRenderer>()).gameObject;
				Plugin.getAssetBundle();
				GameObject val = Plugin.getAssetBundle().LoadAsset<GameObject>("assets/heather.prefab");
				Transform parent = gameObject.transform.parent;
				val.GetComponentsInChildren<SkinnedMeshRenderer>().SelectMany((SkinnedMeshRenderer renderer) => ((Renderer)renderer).materials).Distinct()
					.ToList()
					.ForEach(delegate(Material mat)
					{
						mat.shader = oldShader;
					});
				Object.Instantiate<GameObject>(val, parent);
				gameObject.SetActive(false);
				val.transform.localPosition = Vector3.zero;
			}
		}

		[HarmonyPatch(typeof(NPC_Info), "FixedUpdate")]
		[HarmonyPostfix]
		private static void Animate(NPC_Info __instance)
		{
			List<Animator> list = (from a in ((Component)__instance).GetComponentsInChildren<Animator>()
				where ((Object)((Component)a).gameObject.transform).name.Contains("HEATHER")
				select a).ToList();
			if (list.Count > 0)
			{
				list[0].SetFloat("MoveFactor", ((Component)__instance).GetComponent<NPC_Speed>().velocity);
			}
		}
	}
}