Decompiled source of OhShitbutton v1.0.4

NitoOverhaul.dll

Decompiled 4 days ago
using System;
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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.Events;

[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("NitoOverhaul")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BepInEx")]
[assembly: AssemblyTitle("NitoOverhaul")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace NitoOverhaul
{
	[BepInPlugin("NitoOverhaul", "BepInEx", "1.0.0")]
	[BepInProcess("REPO.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class NitoOverhaul : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private readonly Harmony harmony = new Harmony("NitoOverhaul");

		private static NitoOverhaul instance;

		internal static AssetBundle Bundle;

		public static ConfigEntry<int> cubeValuableMap;

		private void Awake()
		{
			instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin NitoOverhaul is loaded!");
			string location = ((BaseUnityPlugin)instance).Info.Location;
			location = location.TrimEnd("NitoOverhaul.dll".ToCharArray());
			Bundle = AssetBundle.LoadFromFile(location + "nitooverhaul");
			if ((Object)(object)Bundle != (Object)null)
			{
				GameObject val = Bundle.LoadAsset<GameObject>("Item TeleportationCube.prefab");
				if ((Object)(object)val == (Object)null)
				{
					Logger.LogError((object)"Failed to load cubeVal");
				}
				val.AddComponent<CubeItem>();
				Item val2 = Bundle.LoadAsset<Item>("Item TeleportationCube.asset");
				val2.prefab = val;
				if ((Object)(object)val2 == (Object)null)
				{
					Logger.LogError((object)"Failed to load cubeVal3");
				}
				Items.RegisterItem(val2);
			}
			else
			{
				Logger.LogError((object)"Failed to load asset bundle");
			}
		}

		private void loadValuables()
		{
			GameObject val = Bundle.LoadAsset<GameObject>("Valuable TestCube.prefab");
			CubeValuable cubeValuable = val.AddComponent<CubeValuable>();
			cubeValuableMap = ((BaseUnityPlugin)this).Config.Bind<int>("AssetBundleCube", "Map", 0, "The map the teleportation cube can spawn on\n0 = All\n1 = Wizard\n2 = Manor\n3 = Arctic");
			Valuables.RegisterValuable(val, GetMap(cubeValuableMap.Value));
		}

		private List<string> GetMap(int map)
		{
			if (1 == 0)
			{
			}
			List<string> result = map switch
			{
				1 => new List<string> { "Valuables - Wizard" }, 
				2 => new List<string> { "Valuables - Manor" }, 
				3 => new List<string> { "Valuables - Arctic" }, 
				_ => new List<string> { "Valuables - Generic" }, 
			};
			if (1 == 0)
			{
			}
			return result;
		}
	}
	internal class CubeValuable : MonoBehaviour
	{
		internal static int itteration = 0;

		internal static Vector3 playerSpawnPosition = new Vector3(0f, 0f, -22f);

		private void Start()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			((Component)this).GetComponent<PhysGrabObjectImpactDetector>().onDestroy.AddListener(new UnityAction(teleportPlayer));
		}

		private void teleportPlayer()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_0031: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			bool flag = SemiFunc.LocalPlayerOverlapCheck(10f, ((Component)this).transform.position, false);
			List<PlayerAvatar> list = SemiFunc.PlayerGetAllPlayerAvatarWithinRange(6f, ((Component)this).transform.position, false, default(LayerMask));
			Enemy val = SemiFunc.EnemyGetNearest(((Component)this).transform.position, 10f, false);
			if (list.Count == 0)
			{
				NitoOverhaul.Logger.LogError((object)"No players were detected in the range of the object when broken");
			}
			else
			{
				if (!flag)
				{
					return;
				}
				foreach (PlayerAvatar item in list)
				{
					playerSpawnPosition.z += itteration * 4;
					item.playerTransform.position = playerSpawnPosition;
				}
				if ((Object)(object)val != (Object)null)
				{
					playerSpawnPosition.z += itteration * 4;
					((Component)val).transform.position = playerSpawnPosition;
					if (val.HasNavMeshAgent)
					{
						val.NavMeshAgent.Warp(playerSpawnPosition);
					}
					if (val.HasRigidbody)
					{
						val.Rigidbody.Teleport();
					}
				}
				playerSpawnPosition.z = -22f;
			}
		}
	}
	internal class CubeItem : MonoBehaviour
	{
		private ItemToggle itemToggle;

		private bool activated = false;

		private bool prevToggleState = false;

		private Vector3 startPos;

		internal static int itteration = 0;

		internal static Vector3 playerSpawnPosition = new Vector3(0f, 0f, -22f);

		internal static Vector3 playerShopSpawnPosition = new Vector3(0f, 0f, -12f);

		private void Start()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
			startPos = ((Component)this).transform.position;
		}

		private void Update()
		{
			if (itemToggle.toggleState != prevToggleState)
			{
				Activate();
			}
			prevToggleState = itemToggle.toggleState;
		}

		private void Activate()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			if (activated)
			{
				return;
			}
			activated = true;
			if (SemiFunc.RunIsShop())
			{
				List<PlayerAvatar> list = SemiFunc.PlayerGetAllPlayerAvatarWithinRange(20f, ((Component)this).transform.position, false, default(LayerMask));
				foreach (PlayerAvatar item in list)
				{
					NitoOverhaul.Logger.LogInfo((object)$"X: {item.playerTransform.position.x}, Y: {item.playerTransform.position.y}, Z: {item.playerTransform.position.z}");
					activated = false;
				}
				teleportPlayer();
				((Component)this).transform.position = startPos;
				activated = false;
			}
			else
			{
				teleportPlayer();
				((Component)this).GetComponent<PhysGrabObjectImpactDetector>().DestroyObject(false);
			}
		}

		private void teleportPlayer()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_0031: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			bool flag = SemiFunc.LocalPlayerOverlapCheck(20f, ((Component)this).transform.position, false);
			List<PlayerAvatar> list = SemiFunc.PlayerGetAllPlayerAvatarWithinRange(20f, ((Component)this).transform.position, false, default(LayerMask));
			Enemy val = SemiFunc.EnemyGetNearest(((Component)this).transform.position, 6f, false);
			if (list.Count == 0)
			{
				NitoOverhaul.Logger.LogError((object)"No players were detected in the range of the object when broken");
			}
			else
			{
				if (!flag)
				{
					return;
				}
				foreach (PlayerAvatar item in list)
				{
					if (SemiFunc.RunIsShop())
					{
						playerShopSpawnPosition.z += itteration * 4;
						item.playerTransform.position = playerShopSpawnPosition;
					}
					else
					{
						playerSpawnPosition.z += itteration * 4;
						item.playerTransform.position = playerSpawnPosition;
					}
				}
				if ((Object)(object)val != (Object)null)
				{
					playerSpawnPosition.z += itteration * 4;
					((Component)val).transform.position = playerSpawnPosition;
					if (val.HasNavMeshAgent)
					{
						val.NavMeshAgent.Warp(playerSpawnPosition);
					}
					if (val.HasRigidbody)
					{
						val.Rigidbody.Teleport();
					}
				}
				playerSpawnPosition.z = -22f;
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "NitoOverhaul";

		public const string PLUGIN_NAME = "BepInEx";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}