using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using HarmonyLib;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.MoveSystem;
using Il2CppRUMBLE.Players;
using Il2CppRUMBLE.Players.Subsystems;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using Park_dingdong;
using RumbleModUI;
using RumbleModdingAPI;
using RumbleSoundsOnSceneChange;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Class1), "QOL_improvements", "1.0.14", "Hasenparty", null)]
[assembly: VerifyLoaderVersion(0, 6, 6)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 49, 36, 1)]
[assembly: MelonAuthorColor(255, 49, 36, 1)]
[assembly: AssemblyTitle("QOL_improvements")]
[assembly: AssemblyDescription("Quality of life improvements")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("QOL_improvements")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8a963fb7-1e48-40b8-8a0c-a3a7d95dafd3")]
[assembly: AssemblyFileVersion("1.0.14")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.14.0")]
namespace Park_dingdong;
public static class BuildInfo
{
public const string ModName = "QOL_improvements";
public const string ModVersion = "1.0.14";
public const string Description = "Quality of life improvements";
public const string Author = "Hasenparty";
public const string Company = "";
}
public class Validation : ValidationParameters
{
private int Length;
public Validation(int i)
{
Length = i;
}
public override bool DoValidation(string Input)
{
if (Input.Length == Length)
{
return true;
}
return false;
}
}
public class Class1 : MelonMod
{
[HarmonyPatch(typeof(Structure), "OnFetchFromPool")]
public static class StructureRespawn
{
private static void Postfix(ref Structure __instance)
{
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
string name = ((Object)((Component)__instance.processableComponent).gameObject).name;
GameObject gameObject = ((Component)__instance.processableComponent).gameObject;
if ((!(scenename == "Map1") && !(scenename == "Map0")) || Players.GetEnemyPlayers().Count == 0)
{
return;
}
switch (name)
{
default:
if (!(name == "Ball"))
{
break;
}
goto case "Pillar";
case "Pillar":
case "Disc":
case "Wall":
case "RockCube":
local_player_pos = ((Component)((Component)Players.GetLocalPlayer().Controller).gameObject.transform.GetChild(1)).gameObject.transform.position;
opponent_player_pos = ((Component)((Component)Players.GetEnemyPlayers()[0].Controller).gameObject.transform.GetChild(1)).gameObject.transform.position;
if ((Object)(object)gameObject != (Object)null && (Object)(object)gameObject.transform != (Object)null)
{
float num = Vector3.Distance(local_player_pos, gameObject.transform.position);
float num2 = Vector3.Distance(opponent_player_pos, gameObject.transform.position);
if (num < 3f && num2 > 3f)
{
structures_lookup[gameObject] = Vector3.Distance(local_player_pos, opponent_player_pos);
time_lookup[gameObject] = 0f;
}
}
else
{
MelonLogger.Msg("Smh went wrong please talk to the developer, 2");
}
break;
}
}
}
public GameObject Name;
public static string scenename;
private Mod Mod = new Mod();
private ModSetting<bool> Sound;
private ModSetting<bool> Name_tag;
private ModSetting<int> NameTag_Mode;
private ModSetting<bool> Debug_test;
public static List<Player> Players;
public static int newint = 1;
public static int oldint = 1;
public int health = 0;
public int prevhealth = 0;
public Stopwatch stopwatch = new Stopwatch();
public GameObject Enemy_Name;
public static float range_dist;
public Stopwatch timer = new Stopwatch();
public static List<float> distance = new List<float>();
public static bool running = false;
public static Vector3 local_player_pos;
public static Vector3 opponent_player_pos;
public static float all;
public static Dictionary<GameObject, float> structures_lookup = new Dictionary<GameObject, float>();
public static Dictionary<GameObject, float> time_lookup = new Dictionary<GameObject, float>();
public override void OnLateInitializeMelon()
{
UI.instance.UI_Initialized += OnUIInit;
}
public static List<float> ReadFile(string filePath)
{
List<float> list = new List<float>();
try
{
string[] source = File.ReadAllLines(filePath);
return source.Where((string line) => !string.IsNullOrWhiteSpace(line)).Select(delegate(string line)
{
if (!float.TryParse(line.Replace(".", ","), out var result))
{
throw new FormatException("Unable to parse '" + line + "' as a Float.");
}
return result;
}).ToList();
}
catch (Exception ex)
{
MelonLogger.Error((object)ex);
MelonLogger.Msg("Please talk to the Developer. Something went wrong!");
return new List<float>();
}
}
public static float ReadAverage(string filePath)
{
List<float> list = ReadFile(filePath);
if (list.Count != 0)
{
all = 0f;
foreach (float item in list)
{
all += item;
}
all /= list.Count;
return all;
}
return 0f;
}
public void OnUIInit()
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Expected O, but got Unknown
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Expected O, but got Unknown
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Expected O, but got Unknown
try
{
Mod.ModName = "QOL_improvements";
Mod.ModVersion = "1.0.14";
Mod.SetFolder("QOL");
Mod.AddDescription("Description", "", "Quality of life improvements", new Tags
{
IsSummary = true
});
Sound = Mod.AddToList("Sound", true, 1, "Ring if player joins park and also give output if player leaves.", new Tags());
Name_tag = Mod.AddToList("Name Tag", true, 2, "Shows the nametag of the opponent in matches if the player got hit.", new Tags());
NameTag_Mode = Mod.AddToList("Name tag Setting", 3, "0 = Above Head\n1 = On Hand\n3 = Custom, ps it only works for above head will fix in future", new Tags());
Debug_test = Mod.AddToList("Debug test", true, 4, "A new Debug mode for generating a pie chart this is unfinished and may malfunction.", new Tags());
Mod.GetFromFile();
Mod.ModSaved += Save;
UI.instance.AddMod(Mod);
MelonLogger.Msg("Added Mod");
}
catch (Exception ex)
{
MelonLogger.Msg("Smh went wrong please talk to the developer, 2");
MelonLogger.Msg((object)ex);
}
}
private void Save()
{
MelonLogger.Msg("Succesfully Saved");
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
scenename = sceneName;
running = false;
stopwatch.Start();
if (scenename != "Loader")
{
if (File.Exists("UserData\\QOL\\spawn_dist.txt"))
{
range_dist = ReadAverage("UserData\\QOL\\spawn_dist.txt");
}
else
{
MelonLogger.Error("File not found: UserData\\QOL\\spawn_dist.txt");
range_dist = 0f;
}
float[] array = new float[6] { 0f, 2f, 6.1f, 8f, 15f, 11f };
float value = array.OrderBy((float n) => Math.Abs(n - range_dist)).First();
int num = Array.IndexOf(array, value);
MelonLogger.Msg(range_dist + " / " + value + " / " + num);
}
structures_lookup = new Dictionary<GameObject, float>();
time_lookup = new Dictionary<GameObject, float>();
}
public override void OnFixedUpdate()
{
if (!string.IsNullOrEmpty(scenename) && Calls.IsInitialized() && Calls.IsMapInitialized())
{
switch (scenename)
{
case "Map0":
case "Map1":
HandleDebugMode();
HandleNameTag_main();
break;
case "Park":
HandleSound();
break;
}
}
}
private void HandleDebugMode()
{
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: 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_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
if (!(bool)((ModSetting)Debug_test).SavedValue)
{
return;
}
List<Player> enemyPlayers = Players.GetEnemyPlayers();
if (enemyPlayers == null || enemyPlayers.Count <= 0)
{
return;
}
try
{
Player obj = Players.GetEnemyPlayers()[0];
Vector3? obj2;
if (obj == null)
{
obj2 = null;
}
else
{
PlayerController controller = obj.Controller;
if (controller == null)
{
obj2 = null;
}
else
{
GameObject gameObject = ((Component)controller).gameObject;
if (gameObject == null)
{
obj2 = null;
}
else
{
Transform child = gameObject.transform.GetChild(1);
obj2 = ((child != null) ? new Vector3?(child.position) : null);
}
}
}
opponent_player_pos = (Vector3)(((??)obj2) ?? Vector3.zero);
}
catch (Exception ex)
{
MelonLogger.Error("Failed to get opponent position: " + ex.Message);
opponent_player_pos = Vector3.zero;
}
foreach (KeyValuePair<GameObject, float> item in time_lookup.ToList())
{
time_lookup[item.Key] += 0.1f;
if (item.Value >= 70f)
{
structures_lookup.Remove(item.Key);
time_lookup.Remove(item.Key);
}
}
foreach (KeyValuePair<GameObject, float> item2 in structures_lookup.ToList())
{
if (Vector3.Distance(opponent_player_pos, item2.Key.transform.position) < 2f)
{
MelonLogger.Msg((object)item2.Value);
File.AppendAllText("UserData\\QOL\\spawn_dist.txt", $"{item2.Value}\n");
time_lookup.Remove(item2.Key);
structures_lookup.Remove(item2.Key);
}
}
}
public void HandleNameTag_main()
{
List<Player> enemyPlayers = Players.GetEnemyPlayers();
if (enemyPlayers != null && enemyPlayers.Count > 0 && (bool)((ModSetting)Name_tag).SavedValue)
{
switch ((int)((ModSetting)NameTag_Mode).SavedValue)
{
case 0:
HandleNameTag_head();
break;
case 1:
HandleNameTag_hand();
break;
case 3:
break;
default:
HandleNameTag_head();
break;
}
}
}
private void HandleNameTag_head()
{
Player val = Players.GetEnemyPlayers()[0];
PlayerData data = val.Data;
health = ((data != null) ? data.HealthPoints : 0);
if (health != prevhealth)
{
prevhealth = health;
stopwatch.Restart();
PlayerController controller = val.Controller;
if (controller != null)
{
GameObject gameObject = ((Component)controller).gameObject;
if (gameObject != null)
{
Transform child = gameObject.transform.GetChild(9);
if (child != null)
{
PlayerNameTag component = ((Component)child).GetComponent<PlayerNameTag>();
if (component != null)
{
component.FadePlayerNameTag(true);
}
}
}
}
}
if (!(stopwatch.Elapsed.TotalSeconds >= 2.0))
{
return;
}
prevhealth = health;
stopwatch.Reset();
PlayerController controller2 = val.Controller;
if (controller2 == null)
{
return;
}
GameObject gameObject2 = ((Component)controller2).gameObject;
if (gameObject2 == null)
{
return;
}
Transform child2 = gameObject2.transform.GetChild(9);
if (child2 != null)
{
PlayerNameTag component2 = ((Component)child2).GetComponent<PlayerNameTag>();
if (component2 != null)
{
component2.FadePlayerNameTag(false);
}
}
}
public void HandleNameTag_hand()
{
try
{
MelonLogger.Msg("Not working for f sake");
}
catch (Exception ex)
{
MelonLogger.Msg((object)ex);
}
}
private void HandleSound()
{
if ((bool)((ModSetting)Sound).SavedValue)
{
PlayerManager playerManager = Managers.GetPlayerManager();
Players = ((playerManager != null) ? playerManager.AllPlayers : null) ?? new List<Player>();
newint = Players.Count;
if (newint > oldint)
{
AdditionalSounds.PlaySound("\\QOL\\bell.mp3");
}
else if (newint < oldint)
{
AdditionalSounds.PlaySound("\\QOL\\end.mp3");
}
oldint = newint;
}
}
}