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 Beetle_ball_commands;
using Il2Cpp;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppTMPro;
using MelonLoader;
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: MelonInfo(typeof(ExampleMod), "One Gold", "1.0.0", "Spike", null)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Beetle ball commands")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Beetle ball commands")]
[assembly: AssemblyTitle("Beetle ball commands")]
[assembly: AssemblyVersion("1.0.0.0")]
public class ExampleMod : MelonMod
{
private DungBall oldestGold = null;
public override void OnUpdate()
{
if (!BeetleUtils.IsHost())
{
return;
}
List<(string, string)> chatHistory = BeetleUtils.GetChatHistory();
if (chatHistory.Count > 0 && chatHistory[chatHistory.Count - 1].Item2.ToLower() == "destroy")
{
oldestGold.Despawn_ServerRpc();
oldestGold = null;
}
Il2CppArrayBase<DungBall> val = Object.FindObjectsOfType<DungBall>();
if ((Object)(object)oldestGold == (Object)null)
{
foreach (DungBall item in val)
{
if (item.Size >= 5)
{
BeetleUtils.SendChatMessage("<color=yellow>MOD</color>", "A Gold has formed");
oldestGold = item;
break;
}
}
}
foreach (DungBall item2 in val)
{
if (item2.Size >= 5 && (Object)(object)item2 != (Object)(object)oldestGold)
{
item2.Despawn_ServerRpc();
}
}
}
}
public class Test : MelonMod
{
public override void OnUpdate()
{
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
if (BeetleUtils.Pressed((Key)51) && BeetleUtils.Pressed((Key)10))
{
DungBall[] array = Il2CppArrayBase<DungBall>.op_Implicit(Object.FindObjectsOfType<DungBall>());
DungBall[] array2 = array;
foreach (DungBall val in array2)
{
val.Despawn_ServerRpc();
}
}
SpectatorActor[] array3 = Il2CppArrayBase<SpectatorActor>.op_Implicit(Object.FindObjectsOfType<SpectatorActor>());
SpectatorActor[] array4 = array3;
foreach (SpectatorActor val2 in array4)
{
if (!BeetleUtils.Pressed((Key)51))
{
val2.moveSpeed += ((InputControl<Vector2>)(object)Mouse.current.scroll).ReadValue().y * 100f * Time.deltaTime;
}
else
{
val2.moveSpeedFast += ((InputControl<Vector2>)(object)Mouse.current.scroll).ReadValue().y * 100f * Time.deltaTime;
}
}
if (!BeetleUtils.Pressed((Key)95))
{
return;
}
Il2CppArrayBase<JigglePhysics> val3 = Object.FindObjectsOfType<JigglePhysics>();
foreach (JigglePhysics item in val3)
{
item.damping = float.Parse(BeetleUtils.GetChatHistory()[BeetleUtils.GetChatHistory().Count - 1].message);
}
}
}
namespace Beetle_ball_commands;
public static class BeetleUtils
{
public static string GetmapName()
{
try
{
MapInitializer val = Object.FindObjectsOfType<MapInitializer>()[0];
return ((Object)val.mapData).ToString().Replace("MapData_", "").Replace(" (MapDataSO)", "");
}
catch
{
return null;
}
}
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));
}
}
}