using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BoneLib;
using HarmonyLib;
using Il2CppSLZ.Marrow;
using LabFusion.Utilities;
using MelonLoader;
using Spawn_Protection;
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(SpawnProtection), "Spawn Protection", "1.0.0", "CooladTheGreat", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: AssemblyTitle("Spawn Protection")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Spawn Protection")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("46a7c25c-f7c1-4c83-8e3e-9274da00732b")]
[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 Spawn_Protection;
public class SpawnProtection : MelonMod
{
[HarmonyPatch(typeof(Player_Health), "Death")]
private static class PlayerDeathPatch
{
[HarmonyPostfix]
private static void Postfix()
{
SpawnProtection spawnProtection = new SpawnProtection();
spawnProtection.EnableProtection();
}
}
[HarmonyPatch(typeof(Player_Health), "TAKEDAMAGE")]
private static class TakeDamagePatch
{
private static bool Prefix(ref float damage)
{
if (IsProtected)
{
damage = 0f;
return false;
}
return true;
}
}
[CompilerGenerated]
private sealed class <ProtectionTimer>d__10 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public SpawnProtection <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ProtectionTimer>d__10(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSecondsRealtime(30f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
IsProtected = false;
FusionNotifier.Send(new FusionNotification
{
Title = NotificationText.op_Implicit("Spawn Protection"),
Message = NotificationText.op_Implicit("Spawn protection has ended!"),
ShowPopup = true,
Type = (NotificationType)1
});
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private Coroutine _protectionCoroutine;
public static bool IsProtected { get; private set; }
public override void OnInitializeMelon()
{
Hooking.OnLevelLoaded += Hooking_OnLevelLoaded;
}
private void Hooking_OnLevelLoaded(LevelInfo obj)
{
SpawnProtection spawnProtection = new SpawnProtection();
spawnProtection.EnableProtection();
}
private void EnableProtection()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
IsProtected = true;
FusionNotifier.Send(new FusionNotification
{
Title = NotificationText.op_Implicit("Spawn Protection"),
Message = NotificationText.op_Implicit("Spawn protection enabled for 30 seconds!"),
ShowPopup = true,
Type = (NotificationType)3
});
if (_protectionCoroutine != null)
{
MelonCoroutines.Stop((object)_protectionCoroutine);
}
_protectionCoroutine = (Coroutine)MelonCoroutines.Start(ProtectionTimer());
}
[IteratorStateMachine(typeof(<ProtectionTimer>d__10))]
private IEnumerator ProtectionTimer()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ProtectionTimer>d__10(0)
{
<>4__this = this
};
}
}