Decompiled source of InveiCompany v1.0.3

BepInEx/plugins/InveiCompany.dll

Decompiled 5 months 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.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Video;

[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("InveiCompany")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Adds Invei's horns to the Hygrodere")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+43206f0475d7dae18e393eaa115cfd192399712f")]
[assembly: AssemblyProduct("InveiCompany")]
[assembly: AssemblyTitle("InveiCompany")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.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;
		}
	}
}
public class Patcher
{
	public static void DoPatching()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		new Harmony("com.invei.patch").PatchAll();
	}
}
namespace InveiCompany
{
	[BepInPlugin("InveiCompany", "InveiCompany", "1.0.3")]
	public class Plugin : BaseUnityPlugin
	{
		public static ManualLogSource PluginLogger;

		public static GameObject model;

		public static VideoClip video;

		private void Awake()
		{
			Patcher.DoPatching();
			PluginLogger = ((BaseUnityPlugin)this).Logger;
			PluginLogger.LogInfo((object)"Plugin InveiCompany is loaded!");
			AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "invei.bundle"));
			model = obj.LoadAsset<GameObject>("assets/model/Horns.prefab");
			video = obj.LoadAsset<VideoClip>("assets/swag.jpg.mp4.webm");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "InveiCompany";

		public const string PLUGIN_NAME = "InveiCompany";

		public const string PLUGIN_VERSION = "1.0.3";
	}
}
namespace InveiCompany.patch
{
	public class HornsComponent : MonoBehaviour
	{
		public GameObject horns;

		public Transform horn1;

		public Transform horn2;

		private float animProgress = 1f;

		private readonly float animOffset = Random.Range(10, 50);

		private readonly float jiggleOffset = Random.Range(0, 3);

		public void initialize(Transform center)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			horns = Object.Instantiate<GameObject>(Plugin.model);
			horns.transform.SetParent(center);
			horns.transform.localPosition = new Vector3(0f, 0.9f, 0f);
			horn1 = horns.transform.Find("RightHorn");
			horn2 = horns.transform.Find("LeftHorn");
		}

		private float CalculateAnimation(float x, float offset)
		{
			float num = x + animOffset * offset;
			return Mathf.Sin(num * 2f) + Mathf.Sin(MathF.PI + num);
		}

		public void UpdateHorns(PlayerControllerB target, float tamedTimer)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			animProgress = Time.time / 3f;
			if ((Object)(object)target != (Object)null)
			{
				Vector3 val = target.thisPlayerBody.position - horns.transform.position;
				val.y = 0f;
				Quaternion val2 = Quaternion.LookRotation(val);
				Vector3 eulerAngles = ((Quaternion)(ref val2)).eulerAngles;
				eulerAngles.y += 90f;
				((Quaternion)(ref val2)).eulerAngles = eulerAngles;
				horns.transform.rotation = Quaternion.RotateTowards(horns.transform.rotation, val2, 45f * Time.deltaTime);
			}
			float num = 0f;
			if (tamedTimer > 0f)
			{
				num = Mathf.Sin(Time.time * (5f + jiggleOffset)) * 10f;
			}
			float num2 = CalculateAnimation(animProgress, 0f) * 4f;
			float num3 = CalculateAnimation(animProgress, 1f) * 4f;
			float num4 = CalculateAnimation(animProgress, 2f) / 5f;
			float num5 = CalculateAnimation(animProgress, 3f) / 5f;
			horn1.localRotation = Quaternion.Euler(num2 + num, 0f, num3);
			horn1.localPosition = new Vector3(num4, 0f, num5 - 0.8f);
			float num6 = CalculateAnimation(animProgress, 4f) * 4f;
			float num7 = CalculateAnimation(animProgress, 5f) * 4f;
			float num8 = CalculateAnimation(animProgress, 6f) / 5f;
			float num9 = CalculateAnimation(animProgress, 7f) / 5f;
			horn2.localRotation = Quaternion.Euler(num6 + num, 0f, num7);
			horn2.localPosition = new Vector3(num8, 0f, num9 + 0.8f);
		}
	}
	[HarmonyPatch(typeof(BlobAI))]
	internal class BlobPatches
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void SpawnHorns(BlobAI __instance)
		{
			((Component)__instance).gameObject.AddComponent<HornsComponent>();
			((Component)__instance).GetComponent<HornsComponent>().initialize(__instance.centerPoint);
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdateHorns(BlobAI __instance)
		{
			((Component)__instance).GetComponent<HornsComponent>().UpdateHorns(tamedTimer: Traverse.Create((object)__instance).Field("tamedTimer").GetValue<float>(), target: ((EnemyAI)__instance).targetPlayer);
		}
	}
	[HarmonyPatch]
	internal class TerminalPatch
	{
		[HarmonyPatch(typeof(Terminal), "Awake")]
		[HarmonyPostfix]
		public static void InveiTerminal(Terminal __instance)
		{
			__instance.enemyFiles[5].creatureName = "Invei (slimegirl)";
			__instance.enemyFiles[5].displayVideo = Plugin.video;
			__instance.enemyFiles[5].displayText = "INVEI\n\nSigurd's danger level: 0%, if you're faster than a snail!\n\nScientific name: Invei\nA eukaryotic organism classified within the paraphyletic group Prostita. With the incredible speed of reproduction, her cores can multiply to hundreds. Invei rarely splits apart, instead choosing to form large, viscous masses which can take up large amounts of space and become a danger to deal with, requiring large tools or lures to relocate.\n\nInvei is drawn to heat and oxygen and can detect it from seemingly anywhere. There's almost nothing organic she can't convert to her own body mass. Nothing has been found to poison her. Constantly replacing herself, she can persist for hundreds of thousands of years. If you ever find yourself cornered, find a tall object to stand on top of; Invei has trouble climbing. she has great taste! cause I made a friend with her somehow,, and we think it was my music because she started wiggling her horns when I played some..";
			__instance.terminalNodes.allKeywords[45].word = "slimegirl";
		}
	}
}