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 System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Animations.Rigging;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("StaminAndGrabbin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StaminAndGrabbin")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7d22372b-e41e-4090-b0b6-931d22879b31")]
[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 StaminAndGrabbin
{
[BepInPlugin("StaminAndGrabbin", "StaminAndGrabbin", "1.0.0.4")]
public class modBase : BaseUnityPlugin
{
private const string modGUID = "StaminAndGrabbin";
private const string modName = "StaminAndGrabbin";
private const string modVersion = "1.0.0.4";
private readonly Harmony harmony = new Harmony("StaminAndGrabbin");
private static modBase Instance;
internal ManualLogSource mls;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("StaminAndGrabbin");
mls.LogInfo((object)"Mods loaded: Stamina, FOV and Quota Patch, MetalRecharging");
harmony.PatchAll(Assembly.GetExecutingAssembly());
}
}
}
namespace StaminAndGrabbin.Patches
{
[HarmonyPatch(typeof(PlayerControllerB))]
internal class FOVPatches
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void doFOV(ref bool ___inTerminalMenu, ref float ___targetFOV, ref bool ___IsInspectingItem, ref ChainIKConstraint ___rightArmProceduralRig, ref bool ___isSprinting)
{
if (___inTerminalMenu)
{
___targetFOV = 60f;
return;
}
if (___IsInspectingItem)
{
((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)___rightArmProceduralRig).weight = Mathf.Lerp(((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)___rightArmProceduralRig).weight, 1f, 25f * Time.deltaTime);
___targetFOV = 46f;
return;
}
((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)___rightArmProceduralRig).weight = Mathf.Lerp(((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)___rightArmProceduralRig).weight, 0f, 25f * Time.deltaTime);
if (___isSprinting)
{
___targetFOV = 95f;
}
else
{
___targetFOV = 90f;
}
}
}
[HarmonyPatch(typeof(TimeOfDay))]
internal class QuotaPatches
{
[HarmonyPatch("Awake")]
[HarmonyPrefix]
private static void patchQuota(ref TimeOfDay __instance)
{
QuotaSettings quotaVariables = __instance.quotaVariables;
quotaVariables.startingQuota = 300;
quotaVariables.baseIncrease = 200f;
quotaVariables.increaseSteepness = 4f;
quotaVariables.randomizerMultiplier = 1f;
quotaVariables.startingCredits = 200;
quotaVariables.deadlineDaysAmount = 4;
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
internal class StaminaPatch
{
[HarmonyPatch("Update")]
[HarmonyPrefix]
private static void betterSprint(ref float ___sprintMultiplier, ref bool ___isSprinting)
{
if (___isSprinting)
{
___sprintMultiplier = 3f;
}
else
{
___sprintMultiplier = 1.5f;
}
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void betterStamina(ref float ___sprintMeter, ref float ___sprintTime, ref bool ___isSprinting)
{
___sprintTime = 25f;
if (___isSprinting)
{
___sprintMeter = Mathf.Clamp(___sprintMeter - Time.deltaTime / ___sprintTime, 0f, 1f);
}
else
{
___sprintMeter = Mathf.Clamp(___sprintMeter + Time.deltaTime * 0.2f, 0f, 1f);
}
}
}
}
namespace StaminAndGrabbin.MetalRecharge
{
[HarmonyPatch(typeof(HUDManager))]
internal class ChatPatch
{
private static bool _justExploded;
private static SpawnableMapObject _landmine;
[HarmonyPatch("AddPlayerChatMessageServerRpc")]
[HarmonyPatch("AddChatMessage")]
[HarmonyPostfix]
private static void onServerMessageAdded(HUDManager __instance, ref string chatMessage)
{
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
if (_justExploded || (Object)(object)((NetworkBehaviour)__instance).NetworkManager == (Object)null || !chatMessage.Contains("iexplode"))
{
return;
}
string[] array = chatMessage.Split(new char[1] { '-' });
if (array.Length != 3)
{
return;
}
ulong playerID = ulong.Parse(array[1]);
PlayerControllerB val = ((IEnumerable<PlayerControllerB>)__instance.playersManager.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB x) => x.playerClientId == playerID));
if (_landmine == null)
{
_landmine = __instance.playersManager.levels.SelectMany((SelectableLevel x) => x.spawnableMapObjects).FirstOrDefault((Func<SpawnableMapObject, bool>)((SpawnableMapObject x) => ((Object)x.prefabToSpawn).name == "Landmine"));
}
if (!((Object)(object)val == (Object)null) && _landmine != null)
{
if (!((NetworkBehaviour)__instance).NetworkManager.IsHost && !((NetworkBehaviour)__instance).NetworkManager.IsServer)
{
LandminePatch.LastExplosionWasCharger = true;
return;
}
LandminePatch.LastExplosionWasCharger = true;
Debug.Log((object)"GO BOOM!");
_justExploded = true;
Vector3 val2 = ((Component)val).transform.position - new Vector3(0f, 0.25f, 0f);
GameObject val3 = Object.Instantiate<GameObject>(_landmine.prefabToSpawn, val2, Quaternion.identity, RoundManager.Instance.mapPropsContainer.transform);
Landmine componentInChildren = val3.GetComponentInChildren<Landmine>();
val3.GetComponent<NetworkObject>().Spawn(true);
componentInChildren.ExplodeMineServerRpc();
Unexplode();
}
}
private static async Task Unexplode()
{
await Task.Delay(200);
_justExploded = false;
}
public static void sendExplosionChat()
{
if (!((Object)(object)GameNetworkManager.Instance == (Object)null) && !((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null))
{
int num = (int)GameNetworkManager.Instance.localPlayerController.playerClientId;
HUDManager.Instance.AddTextToChatOnServer("<size=0>-" + num + "-iexplode</size>", num);
}
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
internal class InteractPerformedPatch
{
private static bool _swappingTwoHandedValue;
[HarmonyPatch("Interact_performed")]
[HarmonyPrefix]
internal static void interactPerformedPrefix(PlayerControllerB __instance)
{
if (!((Object)(object)__instance.hoveringOverTrigger == (Object)null) && __instance.twoHanded)
{
Transform parent = ((Component)__instance.hoveringOverTrigger).transform.parent;
if (!((Object)(object)parent == (Object)null) && !(((Object)((Component)parent).gameObject).name != "ChargeStationTrigger"))
{
_swappingTwoHandedValue = true;
__instance.twoHanded = false;
}
}
}
[HarmonyPatch("Interact_performed")]
[HarmonyPostfix]
internal static void interactPerformedPostFix(PlayerControllerB __instance)
{
if (_swappingTwoHandedValue)
{
_swappingTwoHandedValue = false;
__instance.twoHanded = true;
}
}
}
[HarmonyPatch(typeof(ItemCharger))]
internal class ItemChargerPatch
{
[HarmonyPatch("Update")]
[HarmonyPrefix]
private static bool itemChargerUpdate(ItemCharger __instance, ref float ___updateInterval, ref InteractTrigger ___triggerScript)
{
if ((Object)(object)NetworkManager.Singleton == (Object)null)
{
return false;
}
if (___updateInterval > 1f)
{
___updateInterval = 0f;
if ((Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
{
GrabbableObject currentlyHeldObjectServer = GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer;
if ((Object)(object)currentlyHeldObjectServer == (Object)null || (!currentlyHeldObjectServer.itemProperties.isConductiveMetal && !currentlyHeldObjectServer.itemProperties.requiresBattery))
{
___triggerScript.interactable = false;
___triggerScript.disabledHoverTip = "(Requires battery-powered or metal item)";
}
else
{
___triggerScript.interactable = true;
}
___triggerScript.twoHandedItemAllowed = true;
return false;
}
}
___updateInterval += Time.deltaTime;
return false;
}
[HarmonyPatch("ChargeItem")]
[HarmonyPrefix]
private static void itemChargerCharge(ItemCharger __instance)
{
GrabbableObject currentlyHeldObjectServer = GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer;
if ((Object)(object)currentlyHeldObjectServer != (Object)null && !currentlyHeldObjectServer.itemProperties.requiresBattery && currentlyHeldObjectServer.itemProperties.isConductiveMetal)
{
LandminePatch.LastExplosionWasLocalPlayer = true;
ChatPatch.sendExplosionChat();
}
}
}
[HarmonyPatch(typeof(Landmine))]
internal class LandminePatch
{
public static bool LastExplosionWasLocalPlayer;
public static bool LastExplosionWasCharger;
[HarmonyPatch("SpawnExplosion")]
[HarmonyPrefix]
private static bool SpawnExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false, float killRange = 1f, float damageRange = 1f)
{
//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_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: 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_0089: 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_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)"Spawning Explosion");
Debug.Log((object)"Charger:");
Debug.Log((object)LastExplosionWasCharger);
Debug.Log((object)LastExplosionWasLocalPlayer);
if (!LastExplosionWasLocalPlayer)
{
return true;
}
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
Vector3 val = (((Component)localPlayerController.gameplayCamera).transform.position - explosionPosition) * 80f / Vector3.Distance(((Component)localPlayerController.gameplayCamera).transform.position, explosionPosition);
if (LastExplosionWasLocalPlayer)
{
localPlayerController.KillPlayer(val, true, (CauseOfDeath)3, 0, default(Vector3));
}
LastExplosionWasCharger = false;
LastExplosionWasLocalPlayer = false;
int num = ~LayerMask.GetMask(new string[1] { "Room" });
num = ~LayerMask.GetMask(new string[1] { "Colliders" });
Collider[] array = Physics.OverlapSphere(explosionPosition, 10f, num);
for (int i = 0; i < array.Length; i++)
{
Rigidbody component = ((Component)array[i]).GetComponent<Rigidbody>();
if ((Object)(object)component != (Object)null)
{
component.AddExplosionForce(70f, explosionPosition, 10f);
}
}
return false;
}
}
}
namespace StaminAndGrabbin.LandMineUponDeath
{
internal class LandMineUponDeath : WhoopieCushionItem
{
}
}