using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using HarmonyLib;
using Il2CppFemur;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MelonLoader;
using Microsoft.CodeAnalysis;
using OnePunchGB;
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(global::OnePunchGB.OnePunchGB), "OnePunchGB", "1.0.0", "Zooks", null)]
[assembly: MelonGame("Boneloaf", "Gang Beasts")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("FastPunchGB")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FastPunchGB")]
[assembly: AssemblyTitle("FastPunchGB")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
}
}
}
namespace OnePunchGB
{
public class PlayerBases
{
public float force;
public float damage;
public float lift;
public float animSpeed;
public float groundSpeed;
public float upwardForce;
}
public class OnePunchGB : MelonMod
{
public const float ForceMult = 2.5f;
public const float DamageMult = 66f;
public const float LiftMult = 5f;
public const float AnimSpeedMult = 1.5f;
public const float SpeedMult = 1.4f;
public const float UpwardLiftMult = 2.8f;
public static Dictionary<int, PlayerBases> BaseStats = new Dictionary<int, PlayerBases>();
private object? _pollCoroutine = null;
public override void OnInitializeMelon()
{
MelonLogger.Msg("OnePunchGB loaded.");
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
BaseStats.Clear();
if (_pollCoroutine != null)
{
MelonCoroutines.Stop(_pollCoroutine);
}
_pollCoroutine = MelonCoroutines.Start(PollForPlayer());
}
private IEnumerator PollForPlayer()
{
yield return (object)new WaitForSeconds(3f);
while (true)
{
yield return (object)new WaitForSeconds(1f);
Actor[] allActors = Il2CppArrayBase<Actor>.op_Implicit(Object.FindObjectsOfType<Actor>());
if (allActors == null || allActors.Length == 0)
{
continue;
}
Actor[] array = allActors;
foreach (Actor actor in array)
{
if (!((Object)(object)actor == (Object)null))
{
Traverse trv = Traverse.Create((object)actor);
if (IsStrictlyLocalPlayer(trv))
{
RefreshBuffs(actor, trv);
}
}
}
}
}
private bool IsStrictlyLocalPlayer(Traverse trv)
{
Traverse obj = trv.Property("IsAI", (object[])null);
if (obj != null && obj.GetValue<bool>())
{
return false;
}
Traverse obj2 = trv.Property("_aiMember", (object[])null);
if (obj2 != null && obj2.GetValue<bool>())
{
return false;
}
Traverse obj3 = trv.Property("isAI", (object[])null);
if (obj3 != null && obj3.GetValue<bool>())
{
return false;
}
Traverse obj4 = trv.Property("_controlledBy", (object[])null);
string text = ((obj4 == null) ? null : obj4.GetValue<object>()?.ToString()?.ToLower()) ?? "";
switch (text)
{
default:
if (!(text == "wave"))
{
Traverse obj5 = trv.Property("isLocalPlayer", (object[])null);
if (obj5 != null && obj5.GetValue<bool>())
{
return true;
}
if (text == "human" || text == "player" || text == "local")
{
return true;
}
Traverse obj6 = trv.Property("InputPlayer", (object[])null);
object obj7 = ((obj6 != null) ? obj6.GetValue() : null);
if (obj7 != null)
{
Traverse val = Traverse.Create(obj7).Property("valid", (object[])null);
if (val.PropertyExists() && val.GetValue<bool>())
{
return true;
}
}
return false;
}
goto case "ai";
case "ai":
case "cpu":
case "bot":
case "npc":
return false;
}
}
private void RefreshBuffs(Actor actor, Traverse trv)
{
int instanceID = ((Object)actor).GetInstanceID();
if (!BaseStats.TryGetValue(instanceID, out PlayerBases value))
{
value = new PlayerBases();
BaseStats[instanceID] = value;
}
Traverse obj = trv.Property("_punchForceModifer", (object[])null);
float num = ((obj != null) ? obj.GetValue<float>() : 0f);
if (num > value.force && num <= 10f)
{
value.force = num;
}
if (value.force > 0f)
{
Traverse obj2 = trv.Property("_punchForceModifer", (object[])null);
if (obj2 != null)
{
obj2.SetValue((object)(value.force * 2.5f));
}
}
Traverse obj3 = trv.Property("_punchDamageModifer", (object[])null);
float num2 = ((obj3 != null) ? obj3.GetValue<float>() : 0f);
if (num2 > value.damage && num2 <= 10f)
{
value.damage = num2;
}
if (value.damage > 0f)
{
Traverse obj4 = trv.Property("_punchDamageModifer", (object[])null);
if (obj4 != null)
{
obj4.SetValue((object)(value.damage * 66f));
}
}
Traverse obj5 = trv.Property("liftStrength", (object[])null);
float num3 = ((obj5 != null) ? obj5.GetValue<float>() : 0f);
if (num3 > value.lift && num3 <= 10f)
{
value.lift = num3;
}
if (value.lift > 0f)
{
Traverse obj6 = trv.Property("liftStrength", (object[])null);
if (obj6 != null)
{
obj6.SetValue((object)(value.lift * 5f));
}
}
Traverse obj7 = trv.Property("groundSpeed", (object[])null);
float num4 = ((obj7 != null) ? obj7.GetValue<float>() : 0f);
if (num4 > value.groundSpeed && num4 <= 20f)
{
value.groundSpeed = num4;
}
if (value.groundSpeed > 0f)
{
Traverse obj8 = trv.Property("groundSpeed", (object[])null);
if (obj8 != null)
{
obj8.SetValue((object)(value.groundSpeed * 1.4f));
}
}
Traverse obj9 = trv.Property("applyedForce", (object[])null);
float num5 = ((obj9 != null) ? obj9.GetValue<float>() : 0f);
if (num5 > value.upwardForce && num5 <= 10f)
{
value.upwardForce = num5;
}
if (value.upwardForce > 0f)
{
Traverse obj10 = trv.Property("applyedForce", (object[])null);
if (obj10 != null)
{
obj10.SetValue((object)(value.upwardForce * 2.8f));
}
}
Animator component = ((Component)actor).GetComponent<Animator>();
if ((Object)(object)component != (Object)null)
{
if (value.animSpeed == 0f)
{
value.animSpeed = component.speed;
}
if (value.animSpeed > 0f && value.animSpeed <= 5f)
{
component.speed = value.animSpeed * 1.5f;
}
}
}
}
}