Decompiled source of EasyREPO v1.1.1

EasyREPO.dll

Decompiled 21 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
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 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: AssemblyCompany("Laimu_Coffee")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EasyREPO")]
[assembly: AssemblyTitle("EasyREPO")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 EasyREPO
{
	[HarmonyPatch(typeof(HurtCollider))]
	internal class DeathPitFixed
	{
		private class WarpState
		{
			public float Teleport_CoolTime;
		}

		private static readonly ConditionalWeakTable<HurtCollider, WarpState> warpStates = new ConditionalWeakTable<HurtCollider, WarpState>();

		[HarmonyPrefix]
		[HarmonyPatch("PlayerHurt")]
		private static bool PlayerHurtFixed(HurtCollider __instance, PlayerAvatar _player)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.ignorePlayers.Contains(_player))
			{
				return true;
			}
			if (__instance.ignoreLocalPlayer && _player.isLocal)
			{
				__instance.ignoreLocalPlayer = false;
				return true;
			}
			if (__instance.detectionOnly)
			{
				__instance.CanHit(((Component)_player).gameObject, __instance.playerDamageCooldown, false, ((Component)_player).transform.position, (HitType)0);
				return true;
			}
			if (__instance.addRuckusOnVehicleImpactPlayerHit && SemiFunc.IsMasterClientOrSingleplayer() && Object.op_Implicit((Object)(object)__instance.playerCausingHurt) && (Object)(object)__instance.playerCausingHurt != (Object)(object)_player && __instance.VehicleImpactRuckusCanHit(_player))
			{
				SemiFunc.PlayerVehicleImpactHitPlayerHost(__instance.playerCausingHurt, _player);
			}
			if (GameManager.Multiplayer() && !_player.photonView.IsMine)
			{
				return true;
			}
			int num = SemiFunc.EnemyGetIndex(__instance.enemyHost);
			PlayerAvatar playerCausingHurt = __instance.playerCausingHurt;
			int health = _player.playerHealth.health;
			bool flag = health > 0 && !_player.deadSet;
			if (__instance.deathPit)
			{
				__instance.onImpactAny.Invoke();
				__instance.onImpactPlayer.Invoke();
				WarpState orCreateValue = warpStates.GetOrCreateValue(__instance);
				if (_player.isTumbling)
				{
					_player.tumble.TumbleRequest(false, false);
				}
				Vector3 val = _player.LastNavmeshPosition + Vector3.up * 2f;
				int num2 = 0;
				if (orCreateValue.Teleport_CoolTime <= Time.time)
				{
					num2 = RunManager.instance.levelsCompleted * 10;
					_player.playerHealth.Hurt(num2, true, num, false);
					Debug.Log((object)$"[EasyREPO-DEBUG] levelsCompleted: {RunManager.instance.levelsCompleted}, 計算された fall_damage: {num2}");
					Debug.Log((object)$"[EasyREPO-DEBUG] Hurt実行後のHP: {_player.playerHealth.health}");
					val = _player.LastNavmeshPosition + Vector3.up * 2f;
				}
				orCreateValue.Teleport_CoolTime = Time.time + 3.5f;
				PlayerController.instance.AntiGravity(1.5f);
				_player.rb.velocity = Vector3.zero;
				bool flag2 = num2 >= health;
				if (!flag2)
				{
					_player.playerTransform.position = val;
					_player.clientPosition = val;
					_player.clientPositionCurrent = val;
					SemiFunc.UIFocusText($"[EazyREPO] Oh no! You fell! Took {num2} damage and respawned.", Color.white, Color.yellow, 5f);
				}
				else
				{
					SemiFunc.UIFocusText("[EazyREPO] Don't give up! Shake it off and try again!", Color.white, Color.black, 5f);
				}
				Debug.Log((object)$"[EasyREPO-DEBUG] Hurt実行後のPOS: {val}");
				if (flag && Object.op_Implicit((Object)(object)playerCausingHurt) && (Object)(object)playerCausingHurt != (Object)(object)_player)
				{
					SemiFunc.PlayerDamagingPlayer(playerCausingHurt, _player, num2, false, flag2, __instance.playerHitFullRuckus);
				}
				return false;
			}
			return true;
		}
	}
	[BepInPlugin("Laimu_Coffee.EasyREPO", "EasyREPO", "1.0")]
	public class EasyREPO : BaseUnityPlugin
	{
		internal static EasyREPO Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	[HarmonyPatch(typeof(DebugCommandHandler))]
	internal class StackCommand
	{
		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		private static void NewRegister_Command(DebugCommandHandler __instance)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			ChatCommand val = new ChatCommand("stack", "Exiting the Stacked State.", (Action<bool, string[]>)delegate
			{
				((MonoBehaviour)__instance).StartCoroutine(StopTime());
			}, (Func<bool, string, string[], List<string>>)null, (Func<bool>)null, false);
			__instance.Register(val);
		}

		private static IEnumerator StopTime()
		{
			Vector3 pos = ((Component)PlayerAvatar.instance).transform.position;
			int wait_time = 5;
			while (true)
			{
				if (wait_time <= 0)
				{
					float num = 9999f;
					Vector3 tp_pos = Vector3.zero;
					foreach (LevelPoint level in LevelGenerator.Instance.LevelPathPoints)
					{
						foreach (LevelPoint item in level.AllLevelPoints)
						{
							float dis = Vector3.Distance(((Component)PlayerAvatar.instance).transform.position, ((Component)item).transform.position);
							if (dis < num)
							{
								num = dis;
								tp_pos = ((Component)item).transform.position;
							}
						}
					}
					PlayerAvatar.instance.playerTransform.position = tp_pos;
					PlayerAvatar.instance.clientPosition = tp_pos;
					PlayerAvatar.instance.clientPositionCurrent = tp_pos;
					SemiFunc.UIFocusText("[EazyREPO] Executed The Command!", Color.white, Color.black, 3f);
					yield break;
				}
				SemiFunc.UIFocusText($"[EazyREPO] Hold still for {wait_time} seconds!", Color.white, Color.green, 0.9f);
				yield return (object)new WaitForSeconds(1f);
				if (Vector3.Distance(pos, ((Component)PlayerAvatar.instance).transform.position) >= 1.5f)
				{
					break;
				}
				wait_time--;
			}
			SemiFunc.UIFocusText("[EazyREPO] Wait!? Don't move!", Color.white, Color.red, 3f);
		}
	}
}