Decompiled source of BeetleUtils v1.0.0

plugins/BeetleUtils.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using Il2Cpp;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppTMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BeetleUtils")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BeetleUtils")]
[assembly: AssemblyTitle("BeetleUtils")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Beetle_Utils;

public static class BeetleUtils
{
	public static string GetmapName()
	{
		MapInitializer val = Object.FindObjectsOfType<MapInitializer>()[0];
		return ((Object)val.mapData).ToString().Replace("MapData_", "").Replace(" (MapDataSO)", "");
	}

	public static bool Pressed(Key key)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		return ((ButtonControl)Keyboard.current[key]).wasPressedThisFrame;
	}

	public static string ModFolder()
	{
		string dataPath = Application.dataPath;
		string fullName = Directory.GetParent(dataPath).FullName;
		return Path.Combine(fullName, "Mods");
	}

	public static BeetleActor[] GetAllBeetles()
	{
		return Il2CppArrayBase<BeetleActor>.op_Implicit(Object.FindObjectsOfType<BeetleActor>());
	}

	public static BeetleActor GetLocalBeetle()
	{
		BeetleActor[] allBeetles = GetAllBeetles();
		if (allBeetles.Length == 0)
		{
			return null;
		}
		BeetleActor[] array = allBeetles;
		foreach (BeetleActor val in array)
		{
			if (((NetworkBehaviour)val).IsLocalPlayer)
			{
				return val;
			}
		}
		return null;
	}

	public static bool IsHost()
	{
		if (new Func<BeetleActor>(GetLocalBeetle) == null)
		{
			return false;
		}
		return ((NetworkBehaviour)GetLocalBeetle()).IsHost;
	}

	public static void ApplyModifer(ModifierType modifier, DungBall dungBall, float duration)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		dungBall.ModifiersController.AddModifierRpcDispatcher(modifier, duration);
	}

	public static List<(string player, string message)> GetChatHistory()
	{
		ChatLog val = Object.FindObjectOfType<ChatLog>();
		string text = ((TMP_Text)val.text).text;
		List<(string, string)> list = new List<(string, string)>();
		MatchCollection matchCollection = Regex.Matches(text, "<b><color=#A2CAFF>(.*?)</color></b>:\\s*<noparse>(.*?)</noparse>");
		foreach (Match item in matchCollection)
		{
			string value = item.Groups[1].Value;
			string value2 = item.Groups[2].Value;
			list.Add((value, value2));
		}
		return list;
	}

	public static void Score(TeamType team)
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		BeetleActor[] allBeetles = GetAllBeetles();
		Goal[] array = Il2CppArrayBase<Goal>.op_Implicit(Object.FindObjectsOfType<Goal>());
		Goal[] array2 = array;
		foreach (Goal val in array2)
		{
			if (!((Object)(object)val == (Object)null) && val.OwnerTeam != team)
			{
				val.BallEnteredGoal_ServerRpc(0uL);
			}
		}
	}

	public static string GetPlayerName(BeetleActor beetle)
	{
		if ((Object)(object)beetle == (Object)null)
		{
			return "Unknown";
		}
		try
		{
			PlayerNametagsController instance = PlayerNametagsController.Instance;
			TMP_Text val = default(TMP_Text);
			if ((Object)(object)instance != (Object)null && instance._activeNametags.TryGetValue(beetle, ref val) && (Object)(object)val != (Object)null)
			{
				string text = val.text;
				if (!string.IsNullOrEmpty(text))
				{
					return text;
				}
			}
		}
		catch
		{
			return "player_" + ((NetworkBehaviour)beetle).NetworkBehaviourId;
		}
		return "Unknown";
	}

	public static void SendChatMessage(string sender, string message)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		ChatPanel val = Object.FindObjectOfType<ChatPanel>();
		if ((Object)(object)val != (Object)null)
		{
			val.SendChatMessage_ServerRpc(FixedString32Bytes.op_Implicit(sender), FixedString128Bytes.op_Implicit(message), default(ServerRpcParams));
		}
	}
}