using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using TMPro;
using UnboundLib;
using UnboundLib.Networking;
using UnboundLib.Utils.UI;
using UnityEngine;
using UnityEngine.Events;
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: AssemblyTitle("ClassLibrary1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Scan")]
[assembly: AssemblyProduct("ClassLibrary1")]
[assembly: AssemblyCopyright("Copyright © Scan 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0b9752fd-25ba-4282-99b3-b431a8bca89f")]
[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 BorderPercentageDamage;
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.edenfails.percentagedamage", "Border Percentage Damage", "1.0.8")]
[BepInProcess("ROUNDS.exe")]
public class BorderPD : BaseUnityPlugin
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UnityAction <>9__11_0;
public static Func<Player, bool> <>9__14_0;
public static Func<Player, bool> <>9__14_1;
public static UnityAction<float> <>9__15_1;
public static UnityAction<float> <>9__15_2;
public static UnityAction<float> <>9__15_3;
public static UnityAction<bool> <>9__15_0;
internal void <Start>b__11_0()
{
}
internal bool <Update>b__14_0(Player p)
{
return p.data.view.IsMine;
}
internal bool <Update>b__14_1(Player p)
{
return p.data.view.IsMine;
}
internal void <NewGUI>b__15_1(float val)
{
DamagePercentageConfig.Value = val;
OnHandShakeCompleted();
}
internal void <NewGUI>b__15_2(float val)
{
StaticDamageConfig.Value = val;
OnHandShakeCompleted();
}
internal void <NewGUI>b__15_3(float val)
{
DamageFrequencySeconds.Value = val;
OnHandShakeCompleted();
}
internal void <NewGUI>b__15_0(bool val)
{
CheckWeirdHealthConfig.Value = val;
OnHandShakeCompleted();
}
}
private const string ModId = "com.edenfails.percentagedamage";
internal static ManualLogSource Log;
public static ConfigEntry<float> DamagePercentageConfig;
public static ConfigEntry<float> StaticDamageConfig;
public static ConfigEntry<float> DamageFrequencySeconds;
public static ConfigEntry<bool> CheckWeirdHealthConfig;
private static Player _localPlayer;
private static float GetPlayerTimer = 1f;
public static BorderPD Instance { get; private set; }
private void Awake()
{
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Instance = this;
DamagePercentageConfig = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DamagePercentage", 0.1f, "Percentage of max health (0.1 = 10%)");
StaticDamageConfig = ((BaseUnityPlugin)this).Config.Bind<float>("General", "StaticDamage", 0.7f, "Flat damage added on top");
DamageFrequencySeconds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DamageFrequencySeconds", 0.25f, "Frequency of damage ticks");
CheckWeirdHealthConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "CheckWeirdHealth", true, "Enable/Disable the force-kill fix for NaN or Infinite health");
Harmony val = new Harmony("com.edenfails.percentagedamage");
val.PatchAll(Assembly.GetExecutingAssembly());
}
private void Start()
{
//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)
//IL_003c: Expected O, but got Unknown
Unbound.RegisterHandshake("com.edenfails.percentagedamage", (Action)OnHandShakeCompleted);
object obj = <>c.<>9__11_0;
if (obj == null)
{
UnityAction val = delegate
{
};
<>c.<>9__11_0 = val;
obj = (object)val;
}
Unbound.RegisterMenu("Border Percentage", (UnityAction)obj, (Action<GameObject>)NewGUI, (GameObject)null, false);
}
private void Update()
{
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: 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_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
if (!CheckWeirdHealthConfig.Value || !((Object)(object)_localPlayer != (Object)null))
{
return;
}
if ((Object)(object)_localPlayer.data != (Object)null)
{
if (!_localPlayer.data.view.IsMine)
{
return;
}
if (!_localPlayer.data.dead)
{
if (float.IsNaN(_localPlayer.data.health) || float.IsInfinity(_localPlayer.data.health) || _localPlayer.data.health < 0f)
{
_localPlayer.data.health = 1f;
if (_localPlayer.data.stats.remainingRespawns > 0)
{
_localPlayer.data.health = 1f;
((Damagable)_localPlayer.data.healthHandler).CallTakeDamage(Vector2.up * 2f, Vector2.op_Implicit(((Component)_localPlayer).transform.position), (GameObject)null, (Player)null, true);
_localPlayer.data.view.RPC("RPCA_Die_Phoenix", (RpcTarget)0, new object[1] { Vector2.up });
}
else
{
_localPlayer.data.health = 1f;
((Damagable)_localPlayer.data.healthHandler).CallTakeDamage(Vector2.up * 2f, Vector2.op_Implicit(((Component)_localPlayer).transform.position), (GameObject)null, (Player)null, true);
_localPlayer.data.view.RPC("RPCA_Die", (RpcTarget)0, new object[1] { Vector2.up });
}
}
else
{
_localPlayer.data.health = 1f;
((Damagable)_localPlayer.data.healthHandler).CallTakeDamage(Vector2.up * 2f, Vector2.op_Implicit(((Component)_localPlayer).transform.position), (GameObject)null, (Player)null, true);
}
}
else if (Time.time - GetPlayerTimer > 1f)
{
GetPlayerTimer = Time.time;
Log.LogInfo((object)"Attempting to get local player...");
_localPlayer = ((IEnumerable<Player>)PlayerManager.instance.players).FirstOrDefault((Func<Player, bool>)((Player p) => p.data.view.IsMine));
}
}
else if (Time.time - GetPlayerTimer > 1f)
{
GetPlayerTimer = Time.time;
Log.LogInfo((object)"Attempting to get local player...");
_localPlayer = ((IEnumerable<Player>)PlayerManager.instance.players).FirstOrDefault((Func<Player, bool>)((Player p) => p.data.view.IsMine));
}
}
private void NewGUI(GameObject menu)
{
TextMeshProUGUI val2 = default(TextMeshProUGUI);
MenuHandler.CreateText("Border Damage Settings", menu, ref val2, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
Slider val3 = default(Slider);
MenuHandler.CreateSlider("Percent Damage", menu, 30, 0f, 1f, DamagePercentageConfig.Value, (UnityAction<float>)delegate(float val)
{
DamagePercentageConfig.Value = val;
OnHandShakeCompleted();
}, ref val3, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
MenuHandler.CreateSlider("Static Extra Damage", menu, 30, 0f, 10f, StaticDamageConfig.Value, (UnityAction<float>)delegate(float val)
{
StaticDamageConfig.Value = val;
OnHandShakeCompleted();
}, ref val3, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
MenuHandler.CreateSlider("Damage Frequency Seconds", menu, 30, 0f, 3f, DamageFrequencySeconds.Value, (UnityAction<float>)delegate(float val)
{
DamageFrequencySeconds.Value = val;
OnHandShakeCompleted();
}, ref val3, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
MenuHandler.CreateToggle(CheckWeirdHealthConfig.Value, "Check for Weird Health fix", menu, (UnityAction<bool>)delegate(bool val)
{
CheckWeirdHealthConfig.Value = val;
OnHandShakeCompleted();
}, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
}
private static void OnHandShakeCompleted()
{
if (PhotonNetwork.IsMasterClient)
{
NetworkingManager.RPC(typeof(BorderPD), "SyncSettings", new object[4] { DamagePercentageConfig.Value, StaticDamageConfig.Value, DamageFrequencySeconds.Value, CheckWeirdHealthConfig.Value });
}
}
[UnboundRPC]
private static void SyncSettings(float pct, float stat, float freq, bool checkHealth)
{
if (PhotonNetwork.IsMasterClient || PhotonNetwork.InRoom)
{
DamagePercentageConfig.Value = pct;
StaticDamageConfig.Value = stat;
DamageFrequencySeconds.Value = freq;
CheckWeirdHealthConfig.Value = checkHealth;
Log.LogInfo((object)$"Settings Synced: Pct {pct}, Stat {stat}, Freq {freq}");
}
}
}
[HarmonyPatch(typeof(ChildRPC), "CallFunction", new Type[] { typeof(string) })]
public class RPCCallPatch
{
private static float timer;
[HarmonyPrefix]
private static void Prefix(ChildRPC __instance, string key)
{
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: 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_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
if (!(key == "OutOfBounds"))
{
return;
}
CharacterData component = ((Component)__instance).GetComponent<CharacterData>();
if ((Object)(object)component != (Object)null && component.view.IsMine && !component.dead)
{
float value = BorderPD.DamageFrequencySeconds.Value;
if (Time.time - timer > value)
{
timer = Time.time;
Vector3 position = ((Component)MainCam.instance).transform.position;
position.z = 0f;
Vector3 val = position - ((Component)component).transform.position;
Vector2 val2 = Vector2.op_Implicit(((Vector3)(ref val)).normalized);
float num = component.maxHealth * BorderPD.DamagePercentageConfig.Value + BorderPD.StaticDamageConfig.Value;
((Damagable)component.healthHandler).CallTakeDamage(val2 * num, Vector2.op_Implicit(((Component)component).transform.position), (GameObject)null, (Player)null, true);
}
}
}
}