Decompiled source of Puppeteer v1.0.0

VeryVeryValet-Puppeteer.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Cinemachine;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Toyful;
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.6", FrameworkDisplayName = "")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("VeryVeryValet-Puppeteer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+80d81ea01171cb0552c7f94b524800a01f794726")]
[assembly: AssemblyProduct("VeryVeryValet-Puppeteer")]
[assembly: AssemblyTitle("VeryVeryValet-Puppeteer")]
[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 TemplatePlugin
{
	internal static class TemplatePluginInfo
	{
		public const string PLUGIN_GUID = "very_very_valet_puppeteer";

		public const string PLUGIN_NAME = "Puppeteer";

		public const string GAME_NAME = "Very Very Valet";
	}
}
namespace VeryVeryValet_Puppeteer
{
	[BepInPlugin("very_very_valet_puppeteer", "Puppeteer", "1.0.0")]
	public class PluginMain : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ActiveSceneManager))]
		private class ActiveSceneManager_Patch
		{
			[HarmonyPatch("GoToLevel")]
			[HarmonyPostfix]
			public static void GoToLevel(LevelData data, bool instant = false, bool isRetry = false)
			{
				if ((Object)(object)_vcam != (Object)null)
				{
					((Component)_vcam).gameObject.SetActive(true);
				}
			}

			[HarmonyPatch("ExitGame")]
			[HarmonyPostfix]
			public static void ExitGame()
			{
				if ((Object)(object)_vcam != (Object)null)
				{
					((Component)_vcam).gameObject.SetActive(false);
				}
			}
		}

		[HarmonyPatch(typeof(CharacterState_RunJump), "UpdateState")]
		private class CharacterState_RunJump_Patch
		{
			private static void Postfix(CharacterState_RunJump __instance)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: 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_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_009f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0107: Unknown result type (might be due to invalid IL or missing references)
				//IL_0110: Unknown result type (might be due to invalid IL or missing references)
				//IL_0115: Unknown result type (might be due to invalid IL or missing references)
				//IL_0125: Unknown result type (might be due to invalid IL or missing references)
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				Vector3 unitGoal = __instance.m_UnitGoal;
				if (((Vector3)(ref unitGoal)).sqrMagnitude < 0.01f)
				{
					return;
				}
				Vector3 position = ((Component)Camera.main).transform.position;
				Vector3 position2 = ((Component)__instance).transform.position;
				Vector3 val = position2 - position;
				val.y = 0f;
				((Vector3)(ref val)).Normalize();
				Vector3 val2 = Vector3.Cross(Vector3.up, val);
				Vector3 val3 = val * unitGoal.z + val2 * unitGoal.x;
				Vector3 normalized = ((Vector3)(ref val3)).normalized;
				Vector3 velocity = __instance._setup.rider.rigidbody.velocity;
				velocity.y = 0f;
				if (((Vector3)(ref velocity)).sqrMagnitude > 0.1f)
				{
					Vector3 normalized2 = ((Vector3)(ref velocity)).normalized;
					float num = Vector3.Dot(normalized, normalized2);
					if (num < -0.4f)
					{
						val3 = Vector3.Slerp(normalized2, normalized, 0.5f);
						normalized = ((Vector3)(ref val3)).normalized;
					}
				}
				__instance.m_UnitGoal = normalized * ((Vector3)(ref unitGoal)).magnitude;
				__instance._setup.rider.uprightJointTargetRot = Quaternion.LookRotation(normalized);
			}
		}

		public const string GameName = "Very Very Valet";

		private const string Version = "1.0.0";

		private readonly Harmony _harmony = new Harmony("very_very_valet_puppeteer");

		public static ManualLogSource? logger;

		public static Transform TargetPlayer;

		private static CinemachineVirtualCamera _vcam;

		private void Awake()
		{
			_harmony.PatchAll();
			PlayerMgr.OnPlayerSpawned = (Action<CharacterStateController_Valet>)Delegate.Combine(PlayerMgr.OnPlayerSpawned, (Action<CharacterStateController_Valet>)delegate(CharacterStateController_Valet player)
			{
				if (!((Object)(object)Object.FindObjectOfType<LevelBasics>() == (Object)null) && (Object)(object)_vcam == (Object)null)
				{
					TargetPlayer = ((Component)player).transform;
					SetupVcam();
				}
			});
		}

		private static void SetupVcam()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0038: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_vcam != (Object)null))
			{
				GameObject val = new GameObject("Puppeteer_VCam");
				_vcam = val.AddComponent<CinemachineVirtualCamera>();
				CinemachineTransposer val2 = _vcam.AddCinemachineComponent<CinemachineTransposer>();
				val2.m_BindingMode = (BindingMode)1;
				val2.m_FollowOffset = new Vector3(0f, 6f, -10f);
				val2.m_YawDamping = 2f;
				val2.m_ZDamping = 1f;
				CinemachineComposer val3 = _vcam.AddCinemachineComponent<CinemachineComposer>();
				val3.m_TrackedObjectOffset = new Vector3(0f, 1.5f, 0f);
				((CinemachineVirtualCameraBase)_vcam).Follow = TargetPlayer;
				((CinemachineVirtualCameraBase)_vcam).LookAt = TargetPlayer;
				((CinemachineVirtualCameraBase)_vcam).Priority = 999;
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}