using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using DamageNumbers;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Utilities;
using Il2CppTMPro;
using MelonLoader;
using RumbleModdingAPI;
using UnityEngine;
using UnityEngine.UI;
[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), "DamageNumbers", "2.1.0", "UlvakSkillz", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 195, 0, 255)]
[assembly: MelonAuthorColor(255, 195, 0, 255)]
[assembly: VerifyLoaderVersion(0, 6, 2, true)]
[assembly: AssemblyTitle("DamageNumbers")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DamageNumbers")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f6144130-bb99-4232-8aa6-d721c7b07821")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace DamageNumbers;
public class main : MelonMod
{
private string currentScene = "Loader";
private int sceneCount = 0;
private int[] healths;
private int playerCount = 0;
private bool waitForMatchStart = false;
public override void OnLateInitializeMelon()
{
Calls.onMapInitialized += SceneInit;
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
currentScene = sceneName;
sceneCount++;
}
private void SceneInit()
{
waitForMatchStart = false;
try
{
if (!(currentScene == "Loader"))
{
MelonCoroutines.Start(HealthWatcher(sceneCount));
}
}
catch (Exception ex)
{
MelonLogger.Error((object)ex);
}
}
private IEnumerator HealthWatcher(int sceneNumber)
{
yield return (object)new WaitForSeconds(3f);
playerCount = Singleton<PlayerManager>.instance.AllPlayers.Count;
healths = new int[playerCount];
for (int i = 0; i < playerCount; i++)
{
healths[i] = Singleton<PlayerManager>.instance.AllPlayers[i].Data.HealthPoints;
}
while (sceneNumber == sceneCount)
{
if (!waitForMatchStart)
{
try
{
if (playerCount != Singleton<PlayerManager>.instance.AllPlayers.Count)
{
healths = new int[playerCount];
for (int k = 0; k < playerCount; k++)
{
healths[k] = Singleton<PlayerManager>.instance.AllPlayers[k].Data.HealthPoints;
}
}
for (int j = 0; j < playerCount; j++)
{
if (healths[j] > Singleton<PlayerManager>.instance.AllPlayers[j].Data.HealthPoints)
{
string damage = "";
Color color = Color.black;
switch (healths[j] - Singleton<PlayerManager>.instance.AllPlayers[j].Data.HealthPoints)
{
case 1:
damage = "1";
color = new Color(83f / 85f, 50f / 51f, 0.64705884f, 1f);
break;
case 2:
damage = "2";
color = new Color(0.99607843f, 76f / 85f, 0.34901962f, 1f);
break;
case 3:
damage = "3";
color = new Color(0.99607843f, 56f / 85f, 0.015686275f, 1f);
break;
case 4:
damage = "4";
color = new Color(0.9843137f, 0.41960785f, 0.16862746f, 1f);
break;
case 5:
damage = "5";
color = new Color(50f / 51f, 21f / 85f, 0.29803923f, 1f);
break;
case 6:
damage = "6";
color = new Color(0.96862745f, 0f, 29f / 51f, 1f);
break;
case 7:
damage = "7";
color = new Color(0.3529412f, 37f / 85f, 1f, 1f);
break;
case 8:
damage = "8";
color = new Color(19f / 85f, 0.52156866f, 29f / 85f, 1f);
break;
case 9:
damage = "9";
color = new Color(1f, 0f, 1f, 1f);
break;
case 10:
damage = "10";
color = new Color(1f, 0f, 1f, 1f);
break;
case 11:
damage = "11";
color = new Color(1f, 0f, 1f, 1f);
break;
case 12:
damage = "12";
color = new Color(1f, 0f, 1f, 1f);
break;
case 13:
damage = "13";
color = new Color(1f, 0f, 1f, 1f);
break;
case 14:
damage = "14";
color = new Color(1f, 0f, 1f, 1f);
break;
case 15:
damage = "15";
color = new Color(1f, 0f, 1f, 1f);
break;
case 16:
damage = "16";
color = new Color(1f, 0f, 1f, 1f);
break;
case 17:
damage = "17";
color = new Color(1f, 0f, 1f, 1f);
break;
case 18:
damage = "18";
color = new Color(1f, 0f, 1f, 1f);
break;
case 19:
damage = "19";
color = new Color(1f, 0f, 1f, 1f);
break;
case 20:
damage = "20";
color = new Color(1f, 0f, 1f, 1f);
break;
}
if (damage != "")
{
int x = 5;
if (j > 0)
{
x++;
}
Transform playerTransform = ((Component)((Component)Singleton<PlayerManager>.instance.AllPlayers[j].Controller).gameObject.transform.GetChild(x).GetChild(5).GetChild(0)).gameObject.transform;
GameObject damageNumber = Create.NewText();
((Object)damageNumber).name = damage + " Damage";
damageNumber.transform.position = new Vector3(playerTransform.position.x, playerTransform.position.y + 1f, playerTransform.position.z);
damageNumber.transform.rotation = ((Component)((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.transform.GetChild(1).GetChild(0).GetChild(0)).gameObject.transform.localRotation;
if (x == 1)
{
damageNumber.transform.localScale = new Vector3(0.75f, 0.75f, 0.75f);
}
TextMeshPro damageNumberText = damageNumber.GetComponent<TextMeshPro>();
((TMP_Text)damageNumberText).fontSize = 12f;
((TMP_Text)damageNumberText).text = damage;
((Graphic)damageNumberText).color = color;
((TMP_Text)damageNumberText).SetOutlineColor(new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue));
((TMP_Text)damageNumberText).outlineWidth = 0.5f;
MelonCoroutines.Start(MoveNumber(damageNumber, sceneNumber, j));
if (healths[j] - Singleton<PlayerManager>.instance.AllPlayers[j].Data.HealthPoints > 8)
{
MelonCoroutines.Start(RainbowColor(damageNumberText, sceneNumber));
}
Object.Destroy((Object)(object)damageNumber, 4f);
}
}
if (healths[j] != Singleton<PlayerManager>.instance.AllPlayers[j].Data.HealthPoints)
{
healths[j] = Singleton<PlayerManager>.instance.AllPlayers[j].Data.HealthPoints;
if ((currentScene == "Map0" || currentScene == "Map1") && healths[j] <= 0 && !waitForMatchStart)
{
MelonCoroutines.Start(WaitForMatchStart(j, sceneNumber));
}
}
}
}
catch
{
}
}
yield return (object)new WaitForFixedUpdate();
}
}
private IEnumerator RainbowColor(TextMeshPro damageNumberText, int sceneNumber)
{
float r = 255f;
float g = 0f;
float b = 255f;
int colorToChange = 1;
DateTime timeToPlay = DateTime.Now.AddSeconds(3.9000000953674316);
yield return (object)new WaitForFixedUpdate();
while (DateTime.Now < timeToPlay && sceneNumber == sceneCount)
{
try
{
switch (colorToChange)
{
case 1:
g += 5f;
r -= 5f;
break;
case 2:
r += 5f;
b -= 5f;
break;
case 3:
b += 5f;
g -= 5f;
break;
}
if (r == 0f || g == 0f || b == 0f)
{
colorToChange++;
if (colorToChange == 4)
{
colorToChange = 1;
}
}
((Graphic)damageNumberText).color = new Color(r / 255f, g / 255f, b / 255f, ((Graphic)damageNumberText).color.a);
}
catch
{
}
yield return (object)new WaitForFixedUpdate();
}
}
private IEnumerator WaitForMatchStart(int playerNumber, int sceneNumber)
{
yield return (object)new WaitForSeconds(0.5f);
waitForMatchStart = true;
while (waitForMatchStart && sceneCount == sceneNumber)
{
try
{
if (Singleton<PlayerManager>.instance.AllPlayers[playerNumber].Data.HealthPoints == 20)
{
for (int i = 0; i < playerCount; i++)
{
healths[i] = Singleton<PlayerManager>.instance.AllPlayers[i].Data.HealthPoints;
}
waitForMatchStart = false;
}
}
catch
{
}
yield return (object)new WaitForFixedUpdate();
}
}
private IEnumerator MoveNumber(GameObject damageNumber, int sceneNumber, int playerNumber)
{
DateTime stopMovingTime = DateTime.Now.AddSeconds(3.9000000953674316);
DateTime startFadeTime = DateTime.Now.AddSeconds(2.0);
float moveAmount = 0.16f;
TextMeshPro damageNumberText = damageNumber.GetComponent<TextMeshPro>();
while (sceneNumber == sceneCount && DateTime.Now < stopMovingTime)
{
try
{
if (playerNumber != 0)
{
damageNumber.transform.rotation = GetAngleToFaceMe(damageNumber.transform.position, ((Component)((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.transform.GetChild(1).GetChild(0).GetChild(0)).gameObject.transform.position);
}
else
{
damageNumber.transform.rotation = ((Component)((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.transform.GetChild(1).GetChild(0).GetChild(0)).gameObject.transform.rotation;
}
if (moveAmount > 0f)
{
damageNumber.transform.position = new Vector3(damageNumber.transform.position.x, damageNumber.transform.position.y + moveAmount, damageNumber.transform.position.z);
moveAmount -= 0.0064f;
}
if (startFadeTime < DateTime.Now)
{
((Graphic)damageNumberText).color = new Color(((Graphic)damageNumberText).color.r, ((Graphic)damageNumberText).color.g, ((Graphic)damageNumberText).color.b, ((Graphic)damageNumberText).color.a - 0.05f);
}
}
catch
{
}
yield return (object)new WaitForFixedUpdate();
}
}
private 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);
}
}