using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using ForceKo;
using Il2CppFemur;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using MelonLoader.Preferences;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(ForceKoMod), "ForceKo", "1.0.0", "Zooks", null)]
[assembly: MelonGame("Boneloaf", "Gang Beasts")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ForceKO")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ForceKO")]
[assembly: AssemblyTitle("ForceKO")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ForceKo;
public class ForceKoMod : MelonMod
{
private MelonPreferences_Entry<Key> _koKey;
private MelonPreferences_Entry<float> _koDuration;
private List<Actor> _cachedActors = new List<Actor>();
private bool _isHoldingKey;
public override void OnInitializeMelon()
{
MelonPreferences_Category val = MelonPreferences.CreateCategory("ForceKo", "Force KO Settings");
_koKey = val.CreateEntry<Key>("Keybind", (Key)23, "KO Keybind", (string)null, false, false, (ValueValidator)null, (string)null);
_koDuration = val.CreateEntry<float>("UnconsciousTime", 6f, "KO Duration (Seconds)", (string)null, false, false, (ValueValidator)null, (string)null);
}
public override void OnUpdate()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
if (Keyboard.current == null)
{
return;
}
if (((ButtonControl)Keyboard.current[_koKey.Value]).isPressed)
{
if (!_isHoldingKey)
{
FindLocalActors();
_isHoldingKey = true;
}
for (int num = _cachedActors.Count - 1; num >= 0; num--)
{
Actor val = _cachedActors[num];
if ((Object)(object)val != (Object)null)
{
ApplyKo(val);
}
else
{
_cachedActors.RemoveAt(num);
}
}
}
else
{
if (!_isHoldingKey)
{
return;
}
for (int i = 0; i < _cachedActors.Count; i++)
{
Actor val2 = _cachedActors[i];
if ((Object)(object)val2 != (Object)null)
{
WakeUpActor(val2);
}
}
_isHoldingKey = false;
_cachedActors.Clear();
}
}
private void FindLocalActors()
{
_cachedActors.Clear();
List<Actor> localPlayers = Actor.LocalPlayers;
if (localPlayers != null && localPlayers.Count > 0)
{
for (int i = 0; i < localPlayers.Count; i++)
{
if ((Object)(object)localPlayers[i] != (Object)null)
{
_cachedActors.Add(localPlayers[i]);
}
}
}
if (_cachedActors.Count != 0)
{
return;
}
Il2CppArrayBase<Actor> val = Object.FindObjectsOfType<Actor>();
for (int j = 0; j < val.Length; j++)
{
Actor val2 = val[j];
if ((Object)(object)val2 != (Object)null && (val2.IsLocal || val.Length == 1))
{
_cachedActors.Add(val2);
}
}
}
private void ApplyKo(Actor actor)
{
if ((Object)(object)actor.statusHandeler != (Object)null)
{
StatusHandeler statusHandeler = actor.statusHandeler;
statusHandeler.staminaDamage = statusHandeler.maxStamina + 1000f;
statusHandeler.healthDamage = statusHandeler.knockoutThreshold + 1000f;
statusHandeler.unconsciousTime = _koDuration.Value;
statusHandeler.CheckConscious();
}
actor.actorState = (ActorState)2;
}
private void WakeUpActor(Actor actor)
{
if ((Object)(object)actor.statusHandeler != (Object)null)
{
StatusHandeler statusHandeler = actor.statusHandeler;
statusHandeler.staminaDamage = 0f;
statusHandeler.healthDamage = 0f;
statusHandeler.unconsciousTime = 0f;
statusHandeler.CheckConscious();
}
}
}