Decompiled source of JakeyFloofleScavenger v1.0.4

BepInEx/plugins/LethalCompany-Jakey.dll

Decompiled 5 months ago
using System;
using System.Collections;
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;

[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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("LethalCompany-Jakey")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalCompany-Jakey")]
[assembly: AssemblyTitle("LethalCompany-Jakey")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
		}
	}
}
namespace ModelReplacement
{
	public class JakeyReplacement : BodyReplacementBase
	{
		private enum Blendshape
		{
			DEAD,
			POINT,
			DANCE,
			BLINK,
			FROWN,
			LOOK_UP,
			LOOK_DOWN,
			LOOK_LEFT,
			LOOK_RIGHT
		}

		private SkinnedMeshRenderer meshRenderer;

		private bool preventAnim = false;

		private readonly float blinkInterval = 5f;

		private readonly float blinkLength = 0.05f;

		private float blinkLast = 0f;

		private float blinkVal = 0f;

		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "Jakey";
			return Assets.MainAssetBundle.LoadAsset<GameObject>(text);
		}

		protected override void Awake()
		{
			((BodyReplacementBase)this).Awake();
			meshRenderer = base.replacementModel.GetComponentInChildren<SkinnedMeshRenderer>();
		}

		protected override void OnEmoteStart(int emoteId)
		{
			preventAnim = true;
			switch (emoteId)
			{
			case 1:
				meshRenderer.SetBlendShapeWeight(2, 100f);
				break;
			case 2:
				meshRenderer.SetBlendShapeWeight(1, 100f);
				break;
			}
		}

		protected override void OnEmoteEnd()
		{
			preventAnim = false;
			meshRenderer.SetBlendShapeWeight(2, 0f);
			meshRenderer.SetBlendShapeWeight(1, 0f);
		}

		protected override void OnDeath()
		{
			((BodyReplacementBase)this).OnDeath();
			SkinnedMeshRenderer componentInChildren = base.replacementDeadBody.GetComponentInChildren<SkinnedMeshRenderer>();
			componentInChildren.SetBlendShapeWeight(0, 100f);
		}

		private IEnumerator DoBlink()
		{
			meshRenderer.SetBlendShapeWeight(3, 0f);
			while (blinkVal < 100f)
			{
				blinkVal = Mathf.Lerp(blinkVal, 250f, Time.fixedDeltaTime);
				meshRenderer.SetBlendShapeWeight(3, Mathf.Min(blinkVal, 100f));
				yield return (object)new WaitForEndOfFrame();
			}
			yield return (object)new WaitForSeconds(blinkLength);
			while (blinkVal > 0f)
			{
				blinkVal = Mathf.Lerp(blinkVal, -5f, Time.fixedDeltaTime);
				meshRenderer.SetBlendShapeWeight(3, Mathf.Max(blinkVal, 0f));
				yield return (object)new WaitForEndOfFrame();
			}
		}

		public override void LateUpdate()
		{
			((BodyReplacementBase)this).LateUpdate();
			if (preventAnim)
			{
				return;
			}
			if ((Object)(object)meshRenderer == (Object)null)
			{
				Debug.Log((object)"No MeshRenderer Found");
				return;
			}
			float time = Time.time;
			if (time > blinkLast + blinkInterval)
			{
				blinkLast = time;
				((MonoBehaviour)this).StartCoroutine(DoBlink());
			}
		}
	}
	[BepInPlugin("com.jakeyfloofle.jakeymodel", "Jakey Floofle Scavenger", "1.0.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static ConfigFile config;

		private static void InitConfig()
		{
		}

		private void Awake()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			config = ((BaseUnityPlugin)this).Config;
			InitConfig();
			Assets.PopulateAssets();
			ModelReplacementAPI.RegisterSuitModelReplacement("Jakey", typeof(JakeyReplacement));
			Harmony val = new Harmony("com.jakeyfloofle.jakeymodel");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.jakeyfloofle.jakeymodel is loaded!");
		}
	}
	public static class Assets
	{
		public static string mainAssetBundleName = "jakeyfloofle";

		public static AssetBundle MainAssetBundle = null;

		private static string GetAssemblyName()
		{
			return Assembly.GetExecutingAssembly().GetName().Name.Replace(" ", "_");
		}

		public static void PopulateAssets()
		{
			if ((Object)(object)MainAssetBundle == (Object)null)
			{
				Console.WriteLine(GetAssemblyName() + "." + mainAssetBundleName);
				using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + "." + mainAssetBundleName);
				MainAssetBundle = AssetBundle.LoadFromStream(stream);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}