Decompiled source of JermaBrackenReplacementMod v1.0.1

snrk.JermaBracken.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Video;

[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("snrk.JermaBracken")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("JermaBracken")]
[assembly: AssemblyTitle("snrk.JermaBracken")]
[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.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;
		}
	}
}
namespace JermaBracken
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "snrk.JermaBracken";

		public const string PLUGIN_NAME = "JermaBracken";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace JermaBracken.Patches
{
	[HarmonyPatch(typeof(TVScript))]
	public class ExampleTVPatch
	{
		[HarmonyPatch("SwitchTVLocalClient")]
		[HarmonyPrefix]
		private static void SwitchTVPrefix(TVScript __instance)
		{
			StartOfRound.Instance.shipRoomLights.SetShipLightsBoolean(__instance.tvOn);
		}
	}
}
namespace CustomBrackenMod
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "snrk.JermaBracken";

		public const string PLUGIN_NAME = "Jerma Bracken Replacement Mod";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	[BepInPlugin("snrk.JermaBracken", "Jerma Bracken Replacement Mod", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static GameObject CustomBrackenModel;

		public static AudioClip NeckSnapAudio;

		public static AudioClip AngeredAudio;

		public static VideoClip jermaClip;

		public static Texture2D TerribleTex;

		public static ConfigEntry<bool> ApplyCustomTexture;

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Jerma Bracken Replacement Mod v1.0.0 loaded!");
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "jermbracken");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			CustomBrackenModel = val.LoadAsset<GameObject>("assets/jerma/jermbracken.prefab");
			NeckSnapAudio = val.LoadAsset<AudioClip>("assets/jerma/jermacrackneck.wav");
			AngeredAudio = val.LoadAsset<AudioClip>("assets/jerma/jermaangered.wav");
			TerribleTex = val.LoadAsset<Texture2D>("assets/jerma/terribletex.png");
			jermaClip = val.LoadAsset<VideoClip>("assets/jerma/jerma.mp4");
			SkinnedMeshRenderer[] componentsInChildren = CustomBrackenModel.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			SkinnedMeshRenderer[] array = componentsInChildren;
			foreach (SkinnedMeshRenderer val2 in array)
			{
				((Component)val2).gameObject.layer = LayerMask.NameToLayer("Enemies");
			}
		}
	}
}
namespace CustomBrackenMod.JermaBracken.Patches
{
	[HarmonyPatch(typeof(FlowermanAI), "Start")]
	internal class FlowermanPatch
	{
		[HarmonyPatch(typeof(Terminal))]
		internal class TerminalPatch
		{
			[HarmonyPatch("Awake")]
			[HarmonyPostfix]
			public static void TerminalFix(Terminal __instance)
			{
				for (int i = 0; i < __instance.enemyFiles.Count; i++)
				{
					if (__instance.enemyFiles[i].creatureName.Equals("Brackens"))
					{
						__instance.enemyFiles[i].creatureName = "Jerma985";
						__instance.enemyFiles[i].displayText = "Jerma985 - The Sus Guy\n\nSigurd's danger level: 1000%\n\nSpecies: Jerma985-plexus erraticus\n\nThe Sus Guy is a rogue physical manifestation of Jerma985, known for appearing suddenly and without warning. While it bears a striking resemblance to Jerma's natural form, this version of the streamer exhibits strange, erratic behavior that defies conventional understanding.\n\nThe Sus Guy is a lone entity with a disturbingly high intelligence. It often seems aloof, moving unpredictably through its environment. Despite appearing unprovoked, it exhibits bursts of aggression, especially when it perceives itself being observed. However, it will often back off or shift its focus if confronted directly. That said, its hostility increases dramatically when it feels cornered or if a viewer stares at it for too long—this triggers its infamous 'sus guy' expression, a sign of deep suspicion and hostility.";
						__instance.enemyFiles[i].displayVideo = Plugin.jermaClip;
						break;
					}
				}
				for (int j = 0; j < __instance.terminalNodes.allKeywords.Length; j++)
				{
					if (__instance.terminalNodes.allKeywords[j].word.Equals("brackens"))
					{
						__instance.terminalNodes.allKeywords[j].word = "jerma985";
						break;
					}
				}
			}
		}

		private static void Postfix(FlowermanAI __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Expected O, but got Unknown
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Expected O, but got Unknown
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Expected O, but got Unknown
			if ((Object)Plugin.CustomBrackenModel == (Object)null)
			{
				return;
			}
			Transform val = ((Component)__instance).transform.Find("FlowermanModel");
			object obj;
			if ((Object)(object)val == (Object)null)
			{
				obj = null;
			}
			else
			{
				Transform val2 = val.Find("LOD1");
				obj = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<SkinnedMeshRenderer>() : null);
			}
			SkinnedMeshRenderer val3 = (SkinnedMeshRenderer)obj;
			object obj2;
			if ((Object)(object)val == (Object)null)
			{
				obj2 = null;
			}
			else
			{
				Transform val4 = val.Find("AnimContainer");
				obj2 = (((Object)(object)val4 != (Object)null) ? val4.Find("metarig") : null);
			}
			Transform val5 = (Transform)obj2;
			if (!((Object)val3 == (Object)null) && ((Renderer)val3).enabled)
			{
				((Renderer)val3).enabled = false;
				Renderer[] componentsInChildren = ((Component)val5).gameObject.GetComponentsInChildren<Renderer>();
				Renderer[] array = componentsInChildren;
				foreach (Renderer val6 in array)
				{
					val6.enabled = false;
				}
				GameObject val7 = Object.Instantiate<GameObject>(Plugin.CustomBrackenModel);
				val7.transform.SetParent(val);
				val7.transform.localPosition = Vector3.zero;
				val7.transform.localRotation = Quaternion.identity;
				Vector3 val8 = default(Vector3);
				((Vector3)(ref val8))..ctor(1f, 1f, 1f);
				val7.transform.localScale = val8;
				Debug.Log((object)$"Custom model scale set to {val8}");
				Transform val9 = val7.transform.Find("jer_body");
				Transform val10 = val7.transform.Find("Flowerman/FlowermanModel/AnimContainer/metarig");
				val10.SetParent(val5.parent, true);
				((Component)val10).transform.localScale = ((Component)val5).transform.localScale;
				((Component)val10).transform.localRotation = ((Component)val5).transform.localRotation;
				((Component)val10).transform.localPosition = new Vector3(0f, 0f, 0f);
				SkinnedMeshRenderer component = ((Component)val9).GetComponent<SkinnedMeshRenderer>();
				component.rootBone = val10;
				Animator component2 = val7.GetComponent<Animator>();
				if ((Object)(object)component2 != (Object)null)
				{
					((Behaviour)component2).enabled = false;
				}
				MaterialPropertyBlock val11 = new MaterialPropertyBlock();
				((Renderer)component).GetPropertyBlock(val11, 0);
				val11.SetColor("_BaseColor", Color.white);
				val11.SetColor("_Color", Color.white);
				val11.SetTexture("_BaseColorMap", (Texture)Plugin.TerribleTex);
				val11.SetVector("_BaseColorMap_ST", new Vector4(1f, 1f, 0f, 0f));
				val11.SetFloat("_NormalMapSpace", 0f);
				val11.SetVector("_NormalMap_ST", new Vector4(1f, 1f, 0f, 0f));
				val11.SetFloat("_Metallic", 0f);
				((Renderer)component).SetPropertyBlock(val11, 0);
				MaterialPropertyBlock val12 = new MaterialPropertyBlock();
				((Renderer)component).GetPropertyBlock(val12, 1);
				((Renderer)component).SetPropertyBlock(val12, 1);
				((Object)val5).name = "old-metarig";
				__instance.crackNeckSFX = Plugin.NeckSnapAudio;
				__instance.creatureAngerVoice.clip = Plugin.AngeredAudio;
				__instance.rightHandGrip = val10.Find("Torso1").Find("Torso2").Find("Torso3")
					.Find("Arm1.R")
					.Find("Arm2.R")
					.Find("Arm3.R")
					.Find("Hand1.R")
					.Find("HandGripPosition");
				((Component)((Component)__instance).transform).GetComponentInChildren<ScanNodeProperties>().headerText = "Jerma985";
			}
		}
	}
}