using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Kai")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VoidFall")]
[assembly: AssemblyTitle("VoidFall")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace VoidFall
{
[HarmonyPatch(typeof(HurtCollider))]
public static class PlayerDeathPitPatch
{
[HarmonyPrefix]
[HarmonyPatch("PlayerHurt")]
private static bool Prefix(HurtCollider __instance, PlayerAvatar _player)
{
if (!VoidFall.EnableMod.Value)
{
return true;
}
if (!__instance.playerKill)
{
return true;
}
VoidFallLogic.OnPlayerFallIntoPit(_player, __instance);
return false;
}
}
[BepInPlugin("Kai.VoidFall", "VoidFall", "3.1")]
public class VoidFall : BaseUnityPlugin
{
internal static ConfigEntry<bool> EnableMod;
internal static ConfigEntry<int> DeathPitDamage;
internal static ConfigEntry<float> KnockbackForce;
internal static ConfigEntry<float> UpBoost;
internal static ConfigEntry<float> HitSpread;
internal static ConfigEntry<float> TumbleTime;
internal static ConfigEntry<float> CooldownSeconds;
internal static ConfigEntry<bool> TeleportToTruckOnDeathPit;
internal static ConfigEntry<float> TruckTeleportOffsetY;
internal static VoidFall Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; private set; }
private void Awake()
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Expected O, but got Unknown
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Expected O, but got Unknown
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Expected O, but got Unknown
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Expected O, but got Unknown
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Expected O, but got Unknown
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Expected O, but got Unknown
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Expected O, but got Unknown
//IL_0221: Expected O, but got Unknown
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableMod", true, "Enables or disables this mod entirely.");
DeathPitDamage = ((BaseUnityPlugin)this).Config.Bind<int>("DeathPit", "Damage", 0, new ConfigDescription("Flat damage dealt when falling into a Death Pit. Set to 0 for no damage.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 999), Array.Empty<object>()));
KnockbackForce = ((BaseUnityPlugin)this).Config.Bind<float>("DeathPit", "KnockbackForce", 45f, new ConfigDescription("Base horizontal knockback force applied on Death Pit impact.\nFunctions similarly to the original 'playerHitForce' from vanilla logic.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
UpBoost = ((BaseUnityPlugin)this).Config.Bind<float>("DeathPit", "UpBoost", 0.75f, new ConfigDescription("Vertical boost multiplier added on top of the knockback.\nVanilla-like bounce used a value around 1.0; this version is slightly reduced for balance.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
HitSpread = ((BaseUnityPlugin)this).Config.Bind<float>("DeathPit", "HitSpread", 0.35f, new ConfigDescription("Directional spread applied when calculating the knockback angle.\nMatches the default 'hitSpread' used in the old enemy Death Pit logic.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
TumbleTime = ((BaseUnityPlugin)this).Config.Bind<float>("DeathPit", "TumbleTime", 0.5f, new ConfigDescription("Duration (in seconds) of forced tumble state after being launched.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
CooldownSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("DeathPit", "CooldownSeconds", 1.5f, new ConfigDescription("Cooldown window preventing repeated triggers when staying inside or near a Death Pit.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
TeleportToTruckOnDeathPit = ((BaseUnityPlugin)this).Config.Bind<bool>("Teleport", "TeleportToTruckOnDeathPit", false, "If enabled, falling into a Death Pit will teleport the player back to the truck instead of launching them.");
TruckTeleportOffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("Teleport", "TruckTeleportOffsetY", 1.2f, new ConfigDescription("Vertical offset applied to the teleport destination to avoid spawning inside the ground.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
if (Harmony == null)
{
Harmony val = new Harmony("Kai.VoidFall");
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
Logger.LogInfo((object)"VoidFall 3.1 (Modern+OldBlend) loaded.");
}
}
internal static class VoidFallLogic
{
[CompilerGenerated]
private sealed class <ApplyForceNextFixed>d__5 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Rigidbody rb;
public Vector3 force;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ApplyForceNextFixed>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForFixedUpdate();
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
rb.AddForce(force, (ForceMode)2);
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 static readonly Dictionary<int, float> cooldown = new Dictionary<int, float>();
private static bool InCooldown(PlayerAvatar p)
{
if (!cooldown.TryGetValue(p.photonView.ViewID, out var value))
{
return false;
}
return Time.time < value;
}
private static void SetCooldown(PlayerAvatar p, float sec)
{
cooldown[p.photonView.ViewID] = Time.time + sec;
}
internal static void OnPlayerFallIntoPit(PlayerAvatar p, HurtCollider col)
{
if (VoidFall.EnableMod.Value && !InCooldown(p))
{
SetCooldown(p, VoidFall.CooldownSeconds.Value);
int value = VoidFall.DeathPitDamage.Value;
if (value > 0)
{
p.playerHealth.Hurt(value, false, -1);
}
if (VoidFall.TeleportToTruckOnDeathPit.Value)
{
TeleportToTruck(p);
}
else
{
BouncePlayer_ModernOldBlend(p, col);
}
}
}
internal static void BouncePlayer_ModernOldBlend(PlayerAvatar p, HurtCollider col)
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: 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_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
PhysGrabObject physGrabObject = p.tumble.physGrabObject;
if (!Object.op_Implicit((Object)(object)physGrabObject))
{
return;
}
Rigidbody rb = physGrabObject.rb;
if (Object.op_Implicit((Object)(object)rb))
{
if (!p.isTumbling)
{
p.tumble.TumbleSet(Object.op_Implicit((Object)(object)p.tumble), false);
}
if (rb.isKinematic)
{
rb.isKinematic = false;
}
rb.velocity = Vector3.zero;
Vector3 position = ((Component)col).transform.position;
Vector3 val = ((Component)p).transform.position - position;
Vector3 normalized = ((Vector3)(ref val)).normalized;
normalized = SemiFunc.ClampDirection(normalized, ((Component)col).transform.forward, VoidFall.HitSpread.Value);
val = new Vector3(normalized.x, 0f, normalized.z);
Vector3 normalized2 = ((Vector3)(ref val)).normalized;
float num = Mathf.Max(col.playerHitForce, VoidFall.KnockbackForce.Value);
Vector3 val2 = normalized2 * num;
Vector3 val3 = Vector3.up * (num * VoidFall.UpBoost.Value);
Vector3 force = val2 + val3;
((MonoBehaviour)p).StartCoroutine(ApplyForceNextFixed(rb, force));
p.tumble.TumbleOverrideTime(VoidFall.TumbleTime.Value);
}
}
[IteratorStateMachine(typeof(<ApplyForceNextFixed>d__5))]
private static IEnumerator ApplyForceNextFixed(Rigidbody rb, Vector3 force)
{
//IL_000e: 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)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ApplyForceNextFixed>d__5(0)
{
rb = rb,
force = force
};
}
internal static void TeleportToTruck(PlayerAvatar p)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: 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_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
Transform transform = ((Component)TruckSafetySpawnPoint.instance).transform;
float value = VoidFall.TruckTeleportOffsetY.Value;
Vector3 val = transform.position + Vector3.up * value;
p.tumble.physGrabObject.Teleport(val, transform.rotation);
p.tumble.TumbleOverrideTime(VoidFall.TumbleTime.Value);
}
}
}