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 BepInEx;
using BepInEx.Logging;
using ElevatorMod.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using LethalNetworkAPI;
using Unity.Netcode;
using UnityEngine;
using ZeranosStore;
using ZeranosStore.Patches;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ZeranosStore")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ZeranosStore")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1303b33d-dd8e-46e8-8406-738b607eadc6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyVersion("1.0.0.0")]
public class PlayerRevivalClass
{
public static LNetworkMessage<ulong> RevivedPlayerMessage;
public static void Awake()
{
RevivedPlayerMessage = LNetworkMessage<ulong>.Connect("RevivedPlayerMessage", (Action<ulong, ulong>)null, (Action<ulong>)onPlayerRevived, (Action<ulong, ulong>)null);
ZeranosStoreModBase.mls.LogInfo((object)"Registered player revival message listener!");
}
private static void onPlayerRevived(ulong revivedClientId)
{
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Expected O, but got Unknown
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
ZeranosStoreModBase.mls.LogInfo((object)"Received player revival message!");
PlayerControllerB val = ((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB p) => p.actualClientId == revivedClientId));
if ((Object)(object)val == (Object)null)
{
ZeranosStoreModBase.mls.LogWarning((object)$"Player with clientId {revivedClientId} not found.");
return;
}
StartOfRound instance = StartOfRound.Instance;
instance.livingPlayers++;
val.isClimbingLadder = false;
((Collider)val.thisController).enabled = true;
val.health = 100;
val.carryWeight = 1f;
val.disableLookInput = false;
val.isPlayerDead = false;
val.isPlayerControlled = true;
val.isInElevator = true;
val.isInHangarShipRoom = true;
val.isInsideFactory = false;
val.parentedToElevatorLastFrame = false;
val.setPositionOfDeadPlayer = false;
val.criticallyInjured = false;
val.bleedingHeavily = false;
val.activatingItem = false;
val.twoHanded = false;
val.inSpecialInteractAnimation = false;
val.disableSyncInAnimation = false;
val.inAnimationWithEnemy = null;
val.holdingWalkieTalkie = false;
val.speakingToWalkieTalkie = false;
val.isSinking = false;
val.isUnderwater = false;
val.sinkingValue = 0f;
val.hasBegunSpectating = false;
val.hinderedMultiplier = 1f;
val.isMovementHindered = 0;
val.sourcesCausingSinking = 0;
val.spectatedPlayerScript = null;
((Behaviour)val.helmetLight).enabled = false;
val.ResetPlayerBloodObjects(val.isPlayerDead);
val.ResetZAndXRotation();
FieldInfo fieldInfo = AccessTools.Field(typeof(EndlessElevator), "playerPhysicsRegion_elevator");
PlayerPhysicsRegion val2 = (PlayerPhysicsRegion)fieldInfo.GetValue(EndlessElevator.Instance);
val.TeleportPlayer(((Component)val2).transform.position, false, 0f, false, true);
val.DisablePlayerModel(((Component)val).gameObject, true, true);
val.Crouch(false);
val.statusEffectAudio.Stop();
val.DisableJetpackControlsLocally();
if (revivedClientId == NetworkManager.Singleton.LocalClientId)
{
HUDManager.Instance.RemoveSpectateUI();
HUDManager.Instance.UpdateHealthUI(100, false);
StartOfRound.Instance.SetSpectateCameraToGameOverMode(false, val);
HUDManager.Instance.HideHUD(false);
StartOfRound.Instance.UpdatePlayerVoiceEffects();
StartOfRound.Instance.SetPlayerObjectExtrapolate(false);
if (Object.op_Implicit((Object)(object)val.playerBodyAnimator))
{
val.playerBodyAnimator.SetBool("Limp", false);
}
HUDManager.Instance.gasHelmetAnimator.SetBool("gasEmitting", false);
HUDManager.Instance.gameOverAnimator.SetTrigger("revive");
}
}
}
namespace ZeranosStore
{
[BepInPlugin("TimLiz.ZeranosAddonMod", "Zerasnos Addon", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class ZeranosStoreModBase : BaseUnityPlugin
{
private const string modGUID = "TimLiz.ZeranosAddonMod";
private const string modName = "Zerasnos Addon";
private const string modVersion = "1.0.1";
public static AssetBundle MyCustomAssets;
private readonly Harmony harmony = new Harmony("TimLiz.ZeranosAddonMod");
private static ZeranosStoreModBase Instance;
public static ManualLogSource mls;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("TimLiz.ZeranosAddonMod");
mls.LogWarning((object)"Hello world!");
PlayerRevivalClass.Awake();
harmony.PatchAll(typeof(ZeranosStoreModBase));
harmony.PatchAll(typeof(RoundManagerPatch));
harmony.PatchAll(typeof(ElevatorApparatusPatch));
harmony.PatchAll(typeof(EndlessElevatorPatch));
}
}
}
namespace ZeranosStore.Patches
{
[HarmonyPatch(typeof(EndlessElevator))]
internal class EndlessElevatorPatch
{
private static int POWER_PER_REVIVAL = 600;
private static float BODY_RECOVERED_DISCOUNT_REVIVAL = 0.08f;
private static int MINIMUM_POWER_AFTER_REVIVAL = 60;
private static void reviveOnePlayer(PlayerControllerB player)
{
PlayerRevivalClass.RevivedPlayerMessage.SendClients(player.actualClientId);
}
private static bool isObjectInElevator(GrabbableObject o)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//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_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: 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_008a: Unknown result type (might be due to invalid IL or missing references)
FieldInfo fieldInfo = AccessTools.Field(typeof(EndlessElevator), "playerPhysicsRegion_elevator");
PlayerPhysicsRegion val = (PlayerPhysicsRegion)fieldInfo.GetValue(EndlessElevator.Instance);
ManualLogSource mls = ZeranosStoreModBase.mls;
Vector3 val2 = ((Component)val).transform.position - ((Component)o).transform.position;
mls.LogMessage((object)("Dist: " + ((Vector3)(ref val2)).magnitude));
int result;
if (!o.isInElevator)
{
val2 = ((Component)val).transform.position - ((Component)o).transform.position;
result = ((((Vector3)(ref val2)).magnitude < 5f) ? 1 : 0);
}
else
{
result = 1;
}
return (byte)result != 0;
}
[HarmonyPatch("ElevatorMovement")]
[HarmonyPrefix]
private static void elevatorMovementPatch(EndlessElevator __instance)
{
ZeranosStoreModBase.mls.LogInfo((object)"Started elevator!");
if (!NetworkManager.Singleton.IsServer)
{
return;
}
NetworkManager singleton = NetworkManager.Singleton;
if ((Object)(object)singleton == (Object)null)
{
return;
}
StartOfRound instance = StartOfRound.Instance;
if ((Object)(object)instance == (Object)null)
{
return;
}
for (int i = 0; i < instance.allPlayerScripts.Length; i++)
{
PlayerControllerB val = instance.allPlayerScripts[i];
if (!val.isPlayerDead || val.disconnectedMidGame)
{
continue;
}
ZeranosStoreModBase.mls.LogInfo((object)"Reviving player...");
bool flag = false;
if ((Object)(object)val.deadBody != (Object)null && (Object)(object)val.deadBody.grabBodyObject != (Object)null)
{
flag = isObjectInElevator(val.deadBody.grabBodyObject) && !val.deadBody.grabBodyObject.isBeingUsed;
}
int num = POWER_PER_REVIVAL + MINIMUM_POWER_AFTER_REVIVAL;
if (flag)
{
num = (int)((float)num * BODY_RECOVERED_DISCOUNT_REVIVAL);
}
ZeranosStoreModBase.mls.LogInfo((object)("Do apply discount for revival: " + flag));
if (!(EndlessElevator.Instance.elevatorPower >= (float)(num + MINIMUM_POWER_AFTER_REVIVAL)))
{
continue;
}
EndlessElevator instance2 = EndlessElevator.Instance;
instance2.elevatorPower -= (float)num;
EndlessElevator.Instance.SetElevatorPower_ClientRpc(EndlessElevator.Instance.elevatorPower);
if ((Object)(object)val.deadBody != (Object)null && (Object)(object)val.deadBody.grabBodyObject != (Object)null)
{
NetworkObject component = ((Component)val.deadBody).gameObject.GetComponent<NetworkObject>();
if ((Object)(object)component != (Object)null && component.IsSpawned)
{
Debug.Log((object)"Despawning player body");
((Component)val.deadBody).gameObject.GetComponent<NetworkObject>().Despawn(true);
}
else
{
Debug.Log((object)"Player body had no network object, destroying it instead.");
Object.Destroy((Object)(object)((Component)val.deadBody).gameObject);
}
}
reviveOnePlayer(val);
}
ZeranosStoreModBase.mls.LogInfo((object)"All players are alive!");
}
[HarmonyPatch("InitializeElevator")]
[HarmonyPostfix]
private static void initializeElevatorPatch(EndlessElevator __instance)
{
__instance.maxElevatorPower = 9999999f;
}
[HarmonyPatch("TryAttachApparatus")]
[HarmonyPostfix]
private static void tryAttachApparatusPatch(EndlessElevator __instance)
{
__instance.maxElevatorPower = 9999999f;
}
[HarmonyPatch("UpdateApparatusCharge")]
[HarmonyPrefix]
private static void updateApparatusChargePatch(EndlessElevator __instance)
{
__instance.maxElevatorPower = 9999999f;
}
}
[HarmonyPatch(typeof(ElevatorApparatus))]
internal class ElevatorApparatusPatch
{
[HarmonyPatch("DockToElevator")]
[HarmonyPrefix]
private static void dockToElevatorPatch(ElevatorApparatus __instance)
{
EndlessElevator.Instance.maxElevatorPower = 9999999f;
}
}
[HarmonyPatch(typeof(RoundManager))]
internal class RoundManagerPatch
{
[HarmonyPatch("SpawnScrapInLevel")]
[HarmonyPrefix]
[HarmonyPriority(-100)]
private static void spawnScrapInLevelPatch(RoundManager __instance, ref float[] __state)
{
__state = new float[2];
__state[0] = __instance.scrapAmountMultiplier;
__state[1] = __instance.scrapValueMultiplier;
__instance.scrapAmountMultiplier += (float)Math.Abs(EndlessElevator.Instance.floorIndex) / 100f;
__instance.scrapValueMultiplier += (float)Math.Abs(EndlessElevator.Instance.floorIndex) / 300f;
ZeranosStoreModBase.mls.LogInfo((object)("Amount multiplier: " + __instance.scrapAmountMultiplier));
ZeranosStoreModBase.mls.LogInfo((object)("Value multiplier: " + __instance.scrapValueMultiplier));
}
[HarmonyPatch("SpawnScrapInLevel")]
[HarmonyPostfix]
private static void spawnScrapInLevelPatch_2(RoundManager __instance, ref float[] __state)
{
ZeranosStoreModBase.mls.LogInfo((object)("Amount multiplie2r: " + __instance.scrapAmountMultiplier));
ZeranosStoreModBase.mls.LogInfo((object)("Value multiplier2: " + __instance.scrapValueMultiplier));
ZeranosStoreModBase.mls.LogInfo((object)("Amount multiplie2r: " + RoundManager.Instance.scrapAmountMultiplier));
ZeranosStoreModBase.mls.LogInfo((object)("Value multiplier2: " + RoundManager.Instance.scrapValueMultiplier));
__instance.scrapAmountMultiplier = __state[0];
__instance.scrapValueMultiplier = __state[1];
}
}
}