Decompiled source of RUMBLESpleef v1.0.0

Mods/RUMBLESpleef.dll

Decompiled 3 days 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 CustomMapLib;
using Il2CppExitGames.Client.Photon;
using Il2CppPhoton.Pun;
using Il2CppPhoton.Realtime;
using Il2CppSystem;
using MelonLoader;
using Microsoft.CodeAnalysis;
using RUMBLESpleef;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyDescription("is it spleef? is it tnt run? only one way to tell")]
[assembly: AssemblyCopyright("Created by elmish")]
[assembly: AssemblyTrademark(null)]
[assembly: MelonInfo(typeof(Class1), "RUMBLE Spleef", "1.0.0", "elmish", null)]
[assembly: MelonGame(null, null)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("RUMBLESpleef")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RUMBLESpleef")]
[assembly: AssemblyTitle("RUMBLESpleef")]
[assembly: AssemblyVersion("1.0.0.0")]
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 RUMBLESpleef
{
	public static class BuildInfo
	{
		public const string Name = "RUMBLE Spleef";

		public const string Description = "is it spleef? is it tnt run? only one way to tell";

		public const string Author = "elmish";

		public const string Company = null;

		public const string Version = "1.0.0";

		public const string DownloadLink = null;
	}
	public class Class1 : Map
	{
		public List<SpleefHandler> spleefObjects = new List<SpleefHandler>();

		public override void OnLateInitializeMelon()
		{
			((Map)this).Initialize("RUMBLE Spleef", "1.0.0", "elmish", (Map)(object)this);
		}

		public override void OnMapCreation()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_005a: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			CreateFloorLayer(33, 33, 0.9f, -0.5f);
			CreateFloorLayer(33, 33, 0.9f, -4.5f, 2000);
			GameObject val = ((Map)this).CreatePrimitiveObject((PrimitiveType)3, Vector3.zero, Quaternion.identity, Vector3.zero, (ObjectType)1, (PrimitivePhysicsMaterial)null);
			for (int i = 0; i < 71; i++)
			{
				GameObject val2 = ((Map)this).CreatePrimitiveObject((PrimitiveType)3, val.transform.forward * 14.5f, Quaternion.identity, new Vector3(10f, 25f, 1f), (ObjectType)1, (PrimitivePhysicsMaterial)null);
				val2.transform.rotation = GetAngleToFaceMe(val2.transform.position, val.transform.position);
				val.transform.Rotate(new Vector3(0f, 5f, 0f));
				val2.transform.position = val2.transform.position + new Vector3(0f, 6.5f, 0f);
			}
			base.HostPedestal.SetFirstSequence(new Vector3(0f, 0f, 10f));
			base.ClientPedestal.SetFirstSequence(new Vector3(0f, 0f, -10f));
			LoadBalancingClient networkingClient = PhotonNetwork.NetworkingClient;
			networkingClient.EventReceived += Action<EventData>.op_Implicit((Action<EventData>)OnEvent);
		}

		public override void OnMapDisabled()
		{
			ResetArena();
		}

		public override void OnMapMatchLoad(bool amHost)
		{
			ResetArena();
		}

		public override void OnRoundStarted()
		{
			((Map)this).OnRoundStarted();
			ResetArena();
		}

		public void ResetArena()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < base.mapParent.transform.childCount; i++)
			{
				((Component)base.mapParent.transform.GetChild(i)).gameObject.SetActive(true);
				((Renderer)((Component)base.mapParent.transform.GetChild(i)).GetComponent<MeshRenderer>()).material.color = Color.white;
			}
		}

		public void CreateFloorLayer(int length, int width, float sectionSize, float height, int UIDOffset = 0)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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)
			float num = 0f;
			float num2 = 0f;
			for (int i = 0; i < length; i++)
			{
				num2 = 0f;
				num += sectionSize;
				for (int j = 0; j < width; j++)
				{
					GameObject val = ((Map)this).CreatePrimitiveObject((PrimitiveType)3, new Vector3((float)width / 2.25f - num, height, (float)width / 2.25f - num2), Quaternion.identity, new Vector3(sectionSize, 1f, sectionSize), (ObjectType)9, (PrimitivePhysicsMaterial)null);
					SpleefHandler spleefHandler = val.AddComponent<SpleefHandler>();
					spleefHandler.objectUID = i * 40 + j + UIDOffset * 40;
					spleefObjects.Add(spleefHandler);
					num2 += sectionSize;
				}
			}
		}

		public Quaternion GetAngleToFaceMe(Vector3 objectPosition, Vector3 lookAtPosition)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = objectPosition - lookAtPosition;
			return Quaternion.LookRotation(val);
		}

		public void OnEvent(EventData data)
		{
			if (data.Code != 17)
			{
				return;
			}
			string[] array = data.CustomData.ToString().Split('|');
			if (!(array[0] == "Map_Spleef"))
			{
				return;
			}
			int num = int.Parse(array[1]);
			foreach (SpleefHandler spleefObject in spleefObjects)
			{
				if (spleefObject.objectUID == num)
				{
					spleefObject.StartSpleefSequence();
				}
			}
		}
	}
	[RegisterTypeInIl2Cpp]
	public class SpleefHandler : MonoBehaviour
	{
		private MeshRenderer renderer;

		private bool objectTouched;

		public int objectUID;

		public static RaiseEventOptions raiseEventOptions = new RaiseEventOptions
		{
			Receivers = (ReceiverGroup)1
		};

		public SpleefHandler(IntPtr ptr)
			: base(ptr)
		{
		}

		public void Start()
		{
			renderer = ((Component)this).GetComponent<MeshRenderer>();
		}

		public void OnCollisionEnter(Collision collision)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			if (!objectTouched && !PhotonNetwork.IsMasterClient)
			{
				PhotonNetwork.RaiseEvent((byte)17, Object.op_Implicit($"Map_Spleef|{objectUID}"), raiseEventOptions, SendOptions.SendReliable);
			}
		}

		public void StartSpleefSequence()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			objectTouched = true;
			((Renderer)renderer).material.color = Color32.op_Implicit(new Color32((byte)0, byte.MaxValue, (byte)0, byte.MaxValue));
			MelonCoroutines.Start(coroutine());
		}

		public IEnumerator coroutine()
		{
			while (((Renderer)renderer).material.color.g > 0f)
			{
				Color32 previousColor = Color32.op_Implicit(((Renderer)renderer).material.color);
				((Renderer)renderer).material.color = Color32.op_Implicit(new Color32((byte)(previousColor.r + 5), (byte)(previousColor.g - 5), previousColor.b, previousColor.a));
				yield return (object)new WaitForFixedUpdate();
				yield return (object)new WaitForFixedUpdate();
				yield return (object)new WaitForFixedUpdate();
				yield return (object)new WaitForFixedUpdate();
			}
			yield return (object)new WaitForFixedUpdate();
			objectTouched = false;
			((Component)this).gameObject.SetActive(false);
		}

		public void OnDisable()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			objectTouched = false;
			((Renderer)renderer).material.color = Color32.op_Implicit(new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue));
			((Component)this).gameObject.SetActive(true);
		}
	}
}