Decompiled source of RealScenery v1.0.2

Mods/RealScenery.dll

Decompiled 3 days ago
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Il2CppExitGames.Client.Photon;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppPhoton.Realtime;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Players.Subsystems;
using Il2CppRUMBLE.Utilities;
using Il2CppSystem;
using MelonLoader;
using RealScenery;
using RumbleModdingAPI.RMAPI;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Main), "RealScenery", "1.0.2", "GreyBeetle", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 0, 255, 255)]
[assembly: MelonAuthorColor(255, 0, 255, 255)]
[assembly: VerifyLoaderVersion(0, 6, 2, true)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace RealScenery;

public class Main : RumbleMod
{
	public static bool alreadyEnabled = false;

	private static bool alreadyLoadedScenery = false;

	private static bool loadingSceneryIntoDDOL = false;

	private static GameObject gymCollision;

	private static GameObject gym;

	private static GameObject gymMoss;

	private static GameObject ring;

	private static GameObject ringCollision;

	private static GameObject ringLeaves;

	private static GameObject pit;

	private static GameObject pitCollision;

	private static GameObject park;

	private static GameObject parkCollision;

	private static GameObject loadingBox;

	private static string lastMap = "";

	public override void OnLateInitializeMelon()
	{
		Actions.onMapInitialized += delegate(string map)
		{
			if (!(map == lastMap))
			{
				lastMap = map;
				alreadyEnabled = false;
				if (!loadingSceneryIntoDDOL && alreadyLoadedScenery)
				{
					DissableAllScenery();
				}
				if (map == "Gym")
				{
					((RumbleMod)this).RegisterEvents();
					if (loadingSceneryIntoDDOL)
					{
						loadingSceneryIntoDDOL = false;
						NotificationSlabOther.GetGameObject().SetActive(false);
					}
					if (!alreadyLoadedScenery)
					{
						alreadyLoadedScenery = true;
						loadingSceneryIntoDDOL = true;
						MelonCoroutines.Start(GetSceneryFromAllScenes());
					}
					else
					{
						AddCollider(GYMVista.GetGameObject());
						ChangeCameraClipPlane();
						RemoveGymKillBox();
						PlaceRingInGym();
						PlacePitInGym();
						PlaceParkInGym();
					}
				}
				else if (map == "Park" && !loadingSceneryIntoDDOL)
				{
					PlayerManager instance = Singleton<PlayerManager>.instance;
					if (Players.IsHost())
					{
						MelonCoroutines.Start(DoPark());
						SendEnable();
						alreadyEnabled = true;
					}
				}
			}
		};
	}

	public override void OnEvent(List<Object> data)
	{
		if (!alreadyEnabled)
		{
			MelonCoroutines.Start(DoPark());
			alreadyEnabled = true;
		}
	}

	private void SendEnable()
	{
		//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_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Expected O, but got Unknown
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		List<Object> list = new List<Object>();
		string text = "true";
		list.Add((Object)(object)String.op_Implicit(text));
		RaiseEventOptions val = new RaiseEventOptions
		{
			Receivers = (ReceiverGroup)0,
			CachingOption = (EventCaching)4
		};
		((RumbleMod)this).RaiseEvent(list, val, SendOptions.SendReliable);
	}

	private IEnumerator DoPark()
	{
		yield return (object)new WaitForSeconds(3f);
		AddCollider(ParkVIsta.GetGameObject());
		RemoveParkKillBox();
		ChangeCameraClipPlane();
		PlaceGymInPark();
		PlacePitInPark();
		PlaceRingInPark();
	}

	private void RemoveGymKillBox()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		GameObject gameObject = SceneBoundaryPlayerGYM.GetGameObject();
		GameObject gameObject2 = SceneBoundaryStructuresGYM.GetGameObject();
		gameObject.transform.localScale = new Vector3(10000f, 10000f, 10000f);
		gameObject2.transform.localScale = new Vector3(10000f, 10000f, 10000f);
	}

	private void RemoveParkKillBox()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		GameObject gameObject = SceneBoundaryPlayerGYM.GetGameObject();
		GameObject gameObject2 = SceneBoundaryStructuresGYM.GetGameObject();
		gameObject.transform.localScale = new Vector3(10000f, 10000f, 10000f);
		gameObject2.transform.localScale = new Vector3(10000f, 10000f, 10000f);
	}

	private void ChangeCameraClipPlane()
	{
		foreach (Camera item in (Il2CppArrayBase<Camera>)(object)Camera.allCameras)
		{
			item.farClipPlane = 10000f;
		}
		PlayerLIV componentInChildren = ((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).GetComponentInChildren<PlayerLIV>();
		componentInChildren.LckTablet.selfieCamera._camera.farClipPlane = 10000f;
		componentInChildren.LckTablet.thirdPersonCamera._camera.farClipPlane = 10000f;
		componentInChildren.LckTablet.firstPersonCamera._camera.farClipPlane = 10000f;
	}

	private void AddCollider(GameObject scenery)
	{
		scenery.layer = 9;
		MeshFilter component = scenery.GetComponent<MeshFilter>();
		Mesh mesh = component.mesh;
		Mesh sharedMesh = MakeReadableMeshCopy(mesh);
		MeshCollider val = scenery.AddComponent<MeshCollider>();
		val.sharedMesh = sharedMesh;
	}

	private GameObject LoadingSide()
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
		val.GetComponent<Renderer>().material.shader = Shader.Find("Universal Render Pipeline/Unlit");
		val.GetComponent<Renderer>().material.color = new Color(0f, 0f, 0f);
		return val;
	}

	private void CreateLoadingBox()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_003d: 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_00b7: 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_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		loadingBox = new GameObject();
		GameObject val = LoadingSide();
		val.transform.parent = loadingBox.transform;
		val.transform.position = new Vector3(0f, 1f, 0f);
		GameObject val2 = LoadingSide();
		val2.transform.parent = loadingBox.transform;
		val2.transform.position = new Vector3(0f, -1f, 0f);
		GameObject val3 = LoadingSide();
		val3.transform.parent = loadingBox.transform;
		val3.transform.position = new Vector3(0f, 0f, 1f);
		GameObject val4 = LoadingSide();
		val4.transform.parent = loadingBox.transform;
		val4.transform.position = new Vector3(0f, 0f, -1f);
		GameObject val5 = LoadingSide();
		val5.transform.parent = loadingBox.transform;
		val5.transform.position = new Vector3(1f, 0f, 0f);
		GameObject val6 = LoadingSide();
		val6.transform.parent = loadingBox.transform;
		val6.transform.position = new Vector3(-1f, 0f, 0f);
		loadingBox.transform.localScale = new Vector3(1f, 2f, 1f);
		Object.DontDestroyOnLoad((Object)(object)loadingBox);
	}

	public static Mesh MakeReadableMeshCopy(Mesh nonReadableMesh)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		Mesh val = new Mesh();
		val.indexFormat = nonReadableMesh.indexFormat;
		GraphicsBuffer vertexBuffer = nonReadableMesh.GetVertexBuffer(0);
		int num = vertexBuffer.stride * vertexBuffer.count;
		Il2CppStructArray<byte> val2 = new Il2CppStructArray<byte>((long)num);
		vertexBuffer.GetData(((Il2CppObjectBase)val2).Cast<Array>());
		val.SetVertexBufferParams(nonReadableMesh.vertexCount, nonReadableMesh.GetVertexAttributes());
		val.SetVertexBufferData<byte>((Il2CppArrayBase<byte>)(object)val2, 0, 0, num, 0, (MeshUpdateFlags)0);
		vertexBuffer.Release();
		val.subMeshCount = nonReadableMesh.subMeshCount;
		GraphicsBuffer indexBuffer = nonReadableMesh.GetIndexBuffer();
		int num2 = indexBuffer.stride * indexBuffer.count;
		Il2CppStructArray<byte> val3 = new Il2CppStructArray<byte>((long)num2);
		indexBuffer.GetData(((Il2CppObjectBase)val3).Cast<Array>());
		val.SetIndexBufferParams(indexBuffer.count, nonReadableMesh.indexFormat);
		val.SetIndexBufferData<byte>((Il2CppArrayBase<byte>)(object)val3, 0, 0, num2, (MeshUpdateFlags)0);
		indexBuffer.Release();
		uint num3 = 0u;
		for (int i = 0; i < val.subMeshCount; i++)
		{
			uint indexCount = nonReadableMesh.GetIndexCount(i);
			val.SetSubMesh(i, new SubMeshDescriptor((int)num3, (int)indexCount, (MeshTopology)0), (MeshUpdateFlags)0);
			num3 += indexCount;
		}
		val.RecalculateNormals();
		val.RecalculateBounds();
		return val;
	}

	private IEnumerator GetSceneryFromAllScenes()
	{
		CreateLoadingBox();
		loadingBox.transform.position = new Vector3(0f, 2f, 0f);
		AsyncOperation ringLoad = SceneManager.LoadSceneAsync("Map0");
		while (!ringLoad.isDone)
		{
			yield return null;
		}
		ring = Object.Instantiate<GameObject>(Map0.GetGameObject());
		ring.SetActive(false);
		Object.DontDestroyOnLoad((Object)(object)ring);
		ringCollision = Object.Instantiate<GameObject>(Map0Collission.GetGameObject());
		ringCollision.SetActive(false);
		((Component)ringCollision.transform.GetChild(2)).gameObject.layer = 9;
		Object.DontDestroyOnLoad((Object)(object)ringCollision);
		ringLeaves = Object.Instantiate<GameObject>(Map0Leaves.GetGameObject());
		ringLeaves.SetActive(false);
		Object.DontDestroyOnLoad((Object)(object)ringLeaves);
		AsyncOperation pitLoad = SceneManager.LoadSceneAsync("Map1");
		while (!pitLoad.isDone)
		{
			yield return null;
		}
		pit = Object.Instantiate<GameObject>(MAP1.GetGameObject());
		pit.SetActive(false);
		Object.DontDestroyOnLoad((Object)(object)pit);
		pitCollision = Object.Instantiate<GameObject>(MAP1Collission.GetGameObject());
		pitCollision.SetActive(false);
		((Component)pitCollision.transform.GetChild(1)).gameObject.layer = 9;
		Object.DontDestroyOnLoad((Object)(object)pitCollision);
		AsyncOperation parkLoad = SceneManager.LoadSceneAsync("Park");
		while (!parkLoad.isDone)
		{
			yield return null;
		}
		park = Object.Instantiate<GameObject>(PARK.GetGameObject());
		park.SetActive(false);
		Object.DontDestroyOnLoad((Object)(object)park);
		parkCollision = Object.Instantiate<GameObject>(PARKCollission.GetGameObject());
		parkCollision.SetActive(false);
		Object.DontDestroyOnLoad((Object)(object)parkCollision);
		SceneManager.LoadScene("Gym");
		yield return (object)new WaitForSeconds(1f);
		gymCollision = Object.Instantiate<GameObject>(GYMCollission.GetGameObject());
		gymCollision.SetActive(false);
		Object.DontDestroyOnLoad((Object)(object)gymCollision);
		gym = Object.Instantiate<GameObject>(GYM.GetGameObject());
		gym.SetActive(false);
		Object.DontDestroyOnLoad((Object)(object)gym);
		gymMoss = Object.Instantiate<GameObject>(GYMMoss.GetGameObject());
		gymMoss.SetActive(false);
		Object.DontDestroyOnLoad((Object)(object)gymMoss);
		Object.Destroy((Object)(object)loadingBox);
	}

	private void PlaceRingInGym()
	{
		//IL_0026: 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_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: 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_00af: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = default(Vector3);
		((Vector3)(ref position))..ctor(-331.4998f, -187.7678f, -652.6992f);
		Quaternion rotation = Quaternion.Euler(0f, 0f, 0f);
		ring.SetActive(true);
		ring.transform.position = position;
		ring.transform.rotation = rotation;
		ringCollision.SetActive(true);
		ringCollision.transform.position = position;
		ringCollision.transform.rotation = rotation;
		ringLeaves.SetActive(true);
		ringLeaves.transform.position = position;
		ringLeaves.transform.rotation = rotation;
	}

	private void PlacePitInGym()
	{
		//IL_0026: 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_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: 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)
		Vector3 position = default(Vector3);
		((Vector3)(ref position))..ctor(465.6506f, 146.4798f, -707.935f);
		Quaternion rotation = Quaternion.Euler(0f, 99.9184f, 0f);
		pit.SetActive(true);
		pit.transform.position = position;
		pit.transform.rotation = rotation;
		pitCollision.SetActive(true);
		pitCollision.transform.position = position;
		pitCollision.transform.rotation = rotation;
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
		Object.Destroy((Object)(object)val.GetComponent<Renderer>());
		val.layer = 9;
		val.transform.position = new Vector3(451.4003f, 164.6153f, -663.3172f);
		val.transform.localScale = new Vector3(30.2875f, 0.5f, 34.442f);
		val.transform.rotation = Quaternion.Euler(353.3074f, 0f, 0f);
	}

	private void PlaceParkInGym()
	{
		//IL_0026: 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_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = default(Vector3);
		((Vector3)(ref position))..ctor(617.8049f, -605.7864f, -239.9187f);
		Quaternion rotation = Quaternion.Euler(-0f, 210.0365f, 0f);
		park.SetActive(true);
		park.transform.position = position;
		park.transform.rotation = rotation;
		parkCollision.SetActive(true);
		parkCollision.transform.position = position;
		parkCollision.transform.rotation = rotation;
	}

	private void PlaceRingInPark()
	{
		//IL_0026: 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_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = default(Vector3);
		((Vector3)(ref position))..ctor(598.605f, 435.6898f, 835.7606f);
		Quaternion rotation = Quaternion.Euler(-0f, 143.6651f, 0f);
		ring.SetActive(true);
		ring.transform.position = position;
		ring.transform.rotation = rotation;
		ringCollision.SetActive(true);
		ringCollision.transform.position = position;
		ringCollision.transform.rotation = rotation;
	}

	private void PlacePitInPark()
	{
		//IL_0026: 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_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: 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)
		Vector3 position = default(Vector3);
		((Vector3)(ref position))..ctor(-110.7695f, 763.5485f, 480.8831f);
		Quaternion rotation = Quaternion.Euler(-0f, 270.3223f, 0f);
		pit.SetActive(true);
		pit.transform.position = position;
		pit.transform.rotation = rotation;
		pitCollision.SetActive(true);
		pitCollision.transform.position = position;
		pitCollision.transform.rotation = rotation;
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
		Object.Destroy((Object)(object)val.GetComponent<Renderer>());
		val.layer = 9;
		val.transform.position = new Vector3(-87.9573f, 781.2126f, 445.5321f);
		val.transform.localScale = new Vector3(30.2875f, 0.5f, 34.442f);
		val.transform.rotation = Quaternion.Euler(353.3074f, 156.0481f, 0f);
	}

	private void PlaceGymInPark()
	{
		//IL_0026: 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_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: 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_00be: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = default(Vector3);
		((Vector3)(ref position))..ctor(636.7192f, 636.8054f, 102.7793f);
		Quaternion rotation = Quaternion.Euler(0f, 155.581f, 0f);
		gym.SetActive(true);
		gym.transform.position = position;
		gym.transform.rotation = rotation;
		gymCollision.SetActive(true);
		gymCollision.transform.position = position;
		gymCollision.transform.rotation = rotation;
		gymMoss.SetActive(true);
		gymMoss.transform.position = position;
		gymMoss.transform.rotation = Quaternion.Euler(270f, 155.581f, 0f);
	}

	private void DissableAllScenery()
	{
		ring.SetActive(false);
		ringCollision.SetActive(false);
		ringLeaves.SetActive(false);
		pit.SetActive(false);
		pitCollision.SetActive(false);
		park.SetActive(false);
		parkCollision.SetActive(false);
		gym.SetActive(false);
		gymCollision.SetActive(false);
		gymMoss.SetActive(false);
	}
}