Decompiled source of DayZFusionSurvival v1.0.2

Mods/DayZFusionSurvival.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using DayZFusionSurvival;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Data;
using Il2CppSLZ.Marrow.Interaction;
using Il2CppSLZ.Marrow.Pool;
using Il2CppSLZ.Marrow.Warehouse;
using LabFusion.Data;
using LabFusion.Entities;
using LabFusion.Marrow;
using LabFusion.Menu.Data;
using LabFusion.Network;
using LabFusion.Player;
using LabFusion.RPC;
using LabFusion.SDK.Gamemodes;
using LabFusion.Scene;
using LabFusion.UI.Popups;
using LabFusion.Utilities;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(DayZFusionSurvivalMod), "DayZ Fusion Survival", "0.5.0", "Chappie Studios", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonPriority(0)]
[assembly: MelonAdditionalDependencies(new string[] { "LabFusion" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 DayZFusionSurvival
{
	public sealed class DayZFusionSurvivalMod : MelonMod
	{
		private static bool _registered;

		public override void OnInitializeMelon()
		{
			if (!_registered)
			{
				GamemodeRegistration.RegisterGamemode<DayZSurvivalGamemode>();
				_registered = true;
				((MelonBase)this).LoggerInstance.Msg("Registered DayZ Survival Fusion gamemode.");
			}
		}
	}
	public sealed class DayZSurvivalGamemode : Gamemode
	{
		private readonly record struct LootEntry(string Barcode, float Food, float Water, bool Heals, string Name);

		private readonly record struct HeldUsable(Hand Hand, Grip Grip, ushort EntityId, LootEntry Entry);

		private readonly record struct LevelPreset(string Name, SpawnProfile FallbackProfile);

		private readonly record struct SpawnProfile(string Name, float MinX, float MaxX, float MinZ, float MaxZ, float MinY, float MaxY, float RaycastTop, float RaycastDistance)
		{
			public SpawnProfile WithName(string name)
			{
				return this with
				{
					Name = name
				};
			}

			public Vector3 GetScatterCandidate(int salt, float channelOffset)
			{
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				float num = Frac((float)(salt + 1) * 0.6180339f + channelOffset + Random.Range(-0.025f, 0.025f));
				float num2 = Frac((float)(salt + 1) * 0.4142135f + channelOffset * 0.73f + Random.Range(-0.025f, 0.025f));
				return new Vector3(Mathf.Lerp(MinX, MaxX, num), RaycastTop, Mathf.Lerp(MinZ, MaxZ, num2));
			}
		}

		private const string SlenderLevelBarcode = "HombresGuapos.SlenderTheEightPages.Level.SlenderTheEightPages";

		private const string GmNightlightLevelBarcode = "jiggy.gmnightlight.Level.gmnightlight";

		private const string GmDaylightLevelBarcode = "jiggy.gmnightlight.Level.gmdaylight";

		private const string SkinnyZombie = "BlueScream.BeyondSandboxNPCs.Spawnable.BeyondZombieSkinny";

		private const string FatZombie = "BlueScream.BeyondSandboxNPCs.Spawnable.BeyondZombieFat";

		private const float HungerSeconds = 600f;

		private const float ThirstSeconds = 420f;

		private const float EmptyNeedDeathSeconds = 120f;

		private const string SevenRpBandage = "notnotnotswipez.SevenRP.Spawnable.Bandage";

		private const string SevenRpFirstAidKit = "notnotnotswipez.SevenRP.Spawnable.FirstAidKit";

		private static readonly string[] ZombieBarcodes = new string[4] { "BlueScream.BeyondSandboxNPCs.Spawnable.BeyondZombieSkinny", "BlueScream.BeyondSandboxNPCs.Spawnable.BeyondZombieSkinny", "BlueScream.BeyondSandboxNPCs.Spawnable.BeyondZombieSkinny", "BlueScream.BeyondSandboxNPCs.Spawnable.BeyondZombieFat" };

		private static readonly Dictionary<string, LevelPreset> SupportedLevels = new Dictionary<string, LevelPreset>
		{
			["HombresGuapos.SlenderTheEightPages.Level.SlenderTheEightPages"] = new LevelPreset("Slender The Eight Pages", new SpawnProfile("Slender The Eight Pages", -380f, 380f, -380f, 380f, -40f, 140f, 260f, 400f)),
			["jiggy.gmnightlight.Level.gmnightlight"] = new LevelPreset("gm_nightlight", new SpawnProfile("gm_nightlight", -450f, 450f, -450f, 450f, -50f, 160f, 300f, 420f)),
			["jiggy.gmnightlight.Level.gmdaylight"] = new LevelPreset("gm_daylight", new SpawnProfile("gm_daylight", -450f, 450f, -450f, 450f, -50f, 160f, 300f, 420f))
		};

		private static readonly LootEntry[] FoodLoot = new LootEntry[22]
		{
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.PotatoChips", 0.3f, 0f, Heals: true, "Potato Chips"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.WeirdChips", 0.25f, 0f, Heals: true, "Weird Chips"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.DomoCoffee", 0.05f, 0.4f, Heals: true, "Domo Coffee"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.CandyDweebs", 0.18f, 0f, Heals: true, "Dweebs"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.CandyFredTedFlamin", 0.16f, -0.05f, Heals: true, "Flamin Fred Ted"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.CandyFredTedFruit", 0.18f, 0f, Heals: true, "Fruit Fred Ted"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.CandyFredTedGreender", 0.18f, 0f, Heals: true, "Greender Fred Ted"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.CandyGenericMints", 0.12f, 0f, Heals: true, "Mints"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.CandyJGs", 0.14f, 0f, Heals: true, "JGs"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.CandyBaBasBits", 0.16f, 0f, Heals: true, "BaBa's Bits"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.PeepawsOintment", 0f, 0f, Heals: true, "Peepaw's Ointment"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.SodaCola", 0.04f, 0.38f, Heals: true, "Cola"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.SodaLime", 0.04f, 0.4f, Heals: true, "Lime Soda"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.SodaMint", 0.03f, 0.42f, Heals: true, "Mint Soda"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.SodaRootBeer", 0.04f, 0.38f, Heals: true, "Root Beer"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.NicksPizza", 0.45f, 0.02f, Heals: true, "Nick's Pizza"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.ChocolateChipCookies", 0.22f, 0f, Heals: true, "Chocolate Chip Cookies"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.DoubleChocolateCookies", 0.24f, 0f, Heals: true, "Double Chocolate Cookies"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.LemonCookies", 0.22f, 0f, Heals: true, "Lemon Cookies"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.RedVelvetCookies", 0.24f, 0f, Heals: true, "Red Velvet Cookies"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.GingerSnaps", 0.22f, 0f, Heals: true, "Ginger Snaps"),
			new LootEntry("BaBaCorp.711ExtraContent.Spawnable.RamenPackage", 0.35f, -0.03f, Heals: true, "Ramen")
		};

		private static readonly LootEntry[] MedicalLoot = new LootEntry[2]
		{
			new LootEntry("notnotnotswipez.SevenRP.Spawnable.Bandage", 0f, 0f, Heals: true, "Bandage"),
			new LootEntry("notnotnotswipez.SevenRP.Spawnable.FirstAidKit", 0f, 0f, Heals: true, "First Aid Kit")
		};

		private static readonly Dictionary<string, LootEntry> Consumables = FoodLoot.Concat(MedicalLoot).ToDictionary((LootEntry entry) => entry.Barcode);

		private static readonly LootEntry[] MeleeLoot = new LootEntry[15]
		{
			new LootEntry("c1534c5a-4774-460f-a814-149541786546", 0f, 0f, Heals: false, "Fire Axe"),
			new LootEntry("c1534c5a-0ba6-4876-be9c-216741786548", 0f, 0f, Heals: false, "Horror Axe"),
			new LootEntry("c1534c5a-e962-46dd-b1ef-f39542617262", 0f, 0f, Heals: false, "Barbed Bat"),
			new LootEntry("c1534c5a-6441-40aa-a070-909542617365", 0f, 0f, Heals: false, "Baseball Bat"),
			new LootEntry("fa534c5a868247138f50c62e424c4144.Spawnable.Baton", 0f, 0f, Heals: false, "Baton"),
			new LootEntry("c1534c5a-8036-440a-8830-b99543686566", 0f, 0f, Heals: false, "Chef Knife"),
			new LootEntry("c1534c5a-1fb8-477c-afbe-2a95436f6d62", 0f, 0f, Heals: false, "Combat Knife"),
			new LootEntry("c1534c5a-0c8a-4b82-9f8b-7a9543726f77", 0f, 0f, Heals: false, "Crowbar"),
			new LootEntry("c1534c5a-d0e9-4d53-9218-e76446727969", 0f, 0f, Heals: false, "Frying Pan"),
			new LootEntry("c1534c5a-11d0-4632-b36e-fa9548616d6d", 0f, 0f, Heals: false, "Hammer"),
			new LootEntry("SLZ.BONELAB.Content.Spawnable.MeleeIceAxe", 0f, 0f, Heals: false, "Ice Axe"),
			new LootEntry("c1534c5a-f6f9-4c96-b88e-91d74c656164", 0f, 0f, Heals: false, "Lead Pipe"),
			new LootEntry("c1534c5a-a767-4a58-b3ef-26064d616368", 0f, 0f, Heals: false, "Machete"),
			new LootEntry("c1534c5a-5d31-488d-b5b3-aa1c53686f76", 0f, 0f, Heals: false, "Shovel"),
			new LootEntry("c1534c5a-02e7-43cf-bc8d-26955772656e", 0f, 0f, Heals: false, "Wrench")
		};

		private static readonly LootEntry[] GunLoot = new LootEntry[6]
		{
			new LootEntry("c1534c5a-2a4f-481f-8542-cc9545646572", 0f, 0f, Heals: false, "Eder22"),
			new LootEntry("SLZ.BONELAB.Content.Spawnable.HandgunEder22training", 0f, 0f, Heals: false, "Eder22 Training"),
			new LootEntry("SLZ.BONELAB.Content.Spawnable.RifleM1Garand", 0f, 0f, Heals: false, "M1 Garand"),
			new LootEntry("c1534c5a-9112-49e5-b022-9c955269666c", 0f, 0f, Heals: false, "M16 Ironsights"),
			new LootEntry("c1534c5a-f3b6-4161-a525-a8955269666c", 0f, 0f, Heals: false, "MK18 Ironsights"),
			new LootEntry("SLZ.BONELAB.Content.Spawnable.RifleMK18HoloForegrip", 0f, 0f, Heals: false, "MK18 Holo Foregrip")
		};

		private static readonly LootEntry[] AmmoLoot = new LootEntry[6]
		{
			new LootEntry("c1534c5a-9e31-482a-b426-43764d616761", 0f, 0f, Heals: false, "M1 Garand Mag"),
			new LootEntry("c1534c5a-8bb2-47cc-977a-46954d616761", 0f, 0f, Heals: false, "M16 Mag"),
			new LootEntry("SLZ.BONELAB.CORE.Spawnable.MagazineeMag", 0f, 0f, Heals: false, "eMag"),
			new LootEntry("c1534c5a-683b-4c01-b378-6795416d6d6f", 0f, 0f, Heals: false, "Light Ammo Box"),
			new LootEntry("c1534c5a-57d4-4468-b5f0-c795416d6d6f", 0f, 0f, Heals: false, "Medium Ammo Box"),
			new LootEntry("c1534c5a-97a9-43f7-be30-6095416d6d6f", 0f, 0f, Heals: false, "Heavy Ammo Box")
		};

		private readonly HashSet<ushort> _zombieEntities = new HashSet<ushort>();

		private readonly HashSet<ushort> _lootEntities = new HashSet<ushort>();

		private readonly HashSet<ushort> _consumedEntities = new HashSet<ushort>();

		private readonly List<Vector3> _groundSpawnPoints = new List<Vector3>();

		private readonly List<HeldUsable> _heldUsables = new List<HeldUsable>();

		private SpawnProfile _spawnProfile = SupportedLevels["HombresGuapos.SlenderTheEightPages.Level.SlenderTheEightPages"].FallbackProfile;

		private float _hunger = 1f;

		private float _thirst = 1f;

		private float _zombieRespawnTimer;

		private float _lootThinkTimer;

		private float _needsNoticeTimer;

		private float _needsDamageTimer;

		private float _needsDamageNoticeTimer;

		private float _vitalityTimer;

		private bool _onExpectedMap;

		private int _zombieSpawnCursor;

		private int _lootSpawnCursor;

		private int _maxZombies = 14;

		private int _zombieRespawnSeconds = 45;

		private int _maxLoot = 30;

		private int _lootRespawnSeconds = 75;

		private bool _zombieRespawns = true;

		private bool _survivalDrain = true;

		private bool _requireSupportedMap = true;

		public override string Title => "DayZ Survival";

		public override string Author => "Chappie Studios";

		public override string Description => "Survive with Beyond Sandbox zombies, vanilla weapons, and 711 food/drink healing on Slender, gm_nightlight, or gm_daylight.";

		public override string Barcode => "Codex.DayZFusionSurvival";

		public override bool AutoStopOnSceneLoad => false;

		public override bool DisableDevTools => true;

		public override bool DisableSpawnGun => true;

		public override bool DisableManualUnragdoll => true;

		private bool ShouldRunOnCurrentLevel
		{
			get
			{
				if (_requireSupportedMap)
				{
					return SupportedLevels.ContainsKey(FusionSceneManager.Barcode);
				}
				return true;
			}
		}

		public override GroupElementData CreateSettingsGroup()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: 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)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: 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_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Expected O, but got Unknown
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Expected O, but got Unknown
			GroupElementData obj = ((Gamemode)this).CreateSettingsGroup();
			GroupElementData val = new GroupElementData("Survival");
			val.AddElement<IntElementData>(new IntElementData
			{
				Title = "Zombie Cap",
				Value = _maxZombies,
				MinValue = 4,
				MaxValue = 28,
				Increment = 1,
				OnValueChanged = delegate(int value)
				{
					_maxZombies = value;
				}
			});
			val.AddElement<BoolElementData>(new BoolElementData
			{
				Title = "Zombie Respawns",
				Value = _zombieRespawns,
				OnValueChanged = delegate(bool value)
				{
					_zombieRespawns = value;
				}
			});
			val.AddElement<IntElementData>(new IntElementData
			{
				Title = "Zombie Respawn Seconds",
				Value = _zombieRespawnSeconds,
				MinValue = 10,
				MaxValue = 240,
				Increment = 5,
				OnValueChanged = delegate(int value)
				{
					_zombieRespawnSeconds = value;
				}
			});
			val.AddElement<IntElementData>(new IntElementData
			{
				Title = "Loot Cap",
				Value = _maxLoot,
				MinValue = 10,
				MaxValue = 60,
				Increment = 1,
				OnValueChanged = delegate(int value)
				{
					_maxLoot = value;
				}
			});
			val.AddElement<IntElementData>(new IntElementData
			{
				Title = "Loot Respawn Seconds",
				Value = _lootRespawnSeconds,
				MinValue = 30,
				MaxValue = 240,
				Increment = 5,
				OnValueChanged = delegate(int value)
				{
					_lootRespawnSeconds = value;
				}
			});
			val.AddElement<BoolElementData>(new BoolElementData
			{
				Title = "Hunger and Thirst",
				Value = _survivalDrain,
				OnValueChanged = delegate(bool value)
				{
					_survivalDrain = value;
				}
			});
			val.AddElement<BoolElementData>(new BoolElementData
			{
				Title = "Require Supported Map",
				Value = _requireSupportedMap,
				OnValueChanged = delegate(bool value)
				{
					_requireSupportedMap = value;
				}
			});
			obj.AddElement<GroupElementData>(val);
			return obj;
		}

		public override void OnGamemodeStarted()
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			((Gamemode)this).OnGamemodeStarted();
			_hunger = 1f;
			_thirst = 1f;
			_zombieRespawnTimer = Mathf.Max(5f, (float)_zombieRespawnSeconds);
			_lootThinkTimer = 0f;
			_needsNoticeTimer = 0f;
			_needsDamageTimer = 0f;
			_needsDamageNoticeTimer = 0f;
			_vitalityTimer = 0f;
			_zombieSpawnCursor = 0;
			_lootSpawnCursor = 0;
			_consumedEntities.Clear();
			LocalHealth.MortalityOverride = true;
			LocalHealth.RegenerationOverride = false;
			LocalHealth.VitalityOverride = 1f;
			LocalHealth.SetFullHealth();
			LocalInventory.SetAmmo(0);
			LocalPlayer.OnGrab = (PlayerGrabDelegate)Delegate.Combine((Delegate?)(object)LocalPlayer.OnGrab, (Delegate?)new PlayerGrabDelegate(OnLocalPlayerGrab));
			LocalPlayer.OnRelease = (PlayerGrabDelegate)Delegate.Combine((Delegate?)(object)LocalPlayer.OnRelease, (Delegate?)new PlayerGrabDelegate(OnLocalPlayerRelease));
			LocalHealth.OnRespawn += OnLocalRespawn;
			_onExpectedMap = ConfigureCurrentLevelProfile();
			Notify("DayZ Survival", _onExpectedMap ? ("Scattering supplies across " + _spawnProfile.Name + ".") : "Load Slender, gm_nightlight, or gm_daylight to start the survival spawns.", (NotificationType)((!_onExpectedMap) ? 1 : 3));
			if (NetworkInfo.IsHost)
			{
				SpawnForHost();
			}
		}

		public override void OnGamemodeStopped()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			((Gamemode)this).OnGamemodeStopped();
			LocalPlayer.OnGrab = (PlayerGrabDelegate)Delegate.Remove((Delegate?)(object)LocalPlayer.OnGrab, (Delegate?)new PlayerGrabDelegate(OnLocalPlayerGrab));
			LocalPlayer.OnRelease = (PlayerGrabDelegate)Delegate.Remove((Delegate?)(object)LocalPlayer.OnRelease, (Delegate?)new PlayerGrabDelegate(OnLocalPlayerRelease));
			LocalHealth.OnRespawn -= OnLocalRespawn;
			LocalHealth.MortalityOverride = null;
			LocalHealth.RegenerationOverride = null;
			LocalHealth.VitalityOverride = null;
			if (NetworkInfo.IsHost)
			{
				DespawnTracked(_zombieEntities);
				DespawnTracked(_lootEntities);
			}
			_zombieEntities.Clear();
			_lootEntities.Clear();
			_consumedEntities.Clear();
			_heldUsables.Clear();
			Notify("DayZ Survival", "Survival mode stopped.", (NotificationType)0);
		}

		public override void OnLevelReady()
		{
			((Gamemode)this).OnLevelReady();
			if (((Gamemode)this).IsStarted)
			{
				_onExpectedMap = ConfigureCurrentLevelProfile();
				if (!_onExpectedMap)
				{
					Notify("Wrong Map", "This mode is tuned for Slender, gm_nightlight, and gm_daylight.", (NotificationType)1);
				}
				else if (NetworkInfo.IsHost)
				{
					_zombieEntities.Clear();
					_lootEntities.Clear();
					_zombieSpawnCursor = 0;
					_lootSpawnCursor = 0;
					_zombieRespawnTimer = Mathf.Max(5f, (float)_zombieRespawnSeconds);
					SpawnForHost();
				}
			}
		}

		protected override void OnUpdate()
		{
			((Gamemode)this).OnUpdate();
			if (!((Gamemode)this).IsStarted)
			{
				return;
			}
			float num = Mathf.Clamp(TimeReferences.DeltaTime, 0f, 0.25f);
			UpdateNeeds(num);
			UpdateHeldUsableInput();
			if (!NetworkInfo.IsHost || !_onExpectedMap)
			{
				return;
			}
			if (_zombieRespawns)
			{
				_zombieRespawnTimer -= num;
				if (_zombieRespawnTimer <= 0f)
				{
					_zombieRespawnTimer = Mathf.Max(5f, (float)_zombieRespawnSeconds);
					SpawnMissingZombies();
				}
			}
			else
			{
				_zombieRespawnTimer = Mathf.Max(5f, (float)_zombieRespawnSeconds);
				PruneMissing(_zombieEntities);
			}
			_lootThinkTimer -= num;
			if (_lootThinkTimer <= 0f)
			{
				_lootThinkTimer = Mathf.Max(15f, (float)_lootRespawnSeconds);
				SpawnMissingLoot();
			}
		}

		private void UpdateNeeds(float dt)
		{
			if (_survivalDrain)
			{
				_hunger = Mathf.Clamp01(_hunger - dt / 600f);
				_thirst = Mathf.Clamp01(_thirst - dt / 420f);
			}
			_vitalityTimer -= dt;
			if (_vitalityTimer <= 0f)
			{
				_vitalityTimer = 1f;
				float num = Mathf.Min(_hunger, _thirst);
				LocalHealth.VitalityOverride = Mathf.Lerp(0.35f, 1f, num);
			}
			UpdateEmptyNeedDamage(dt);
			if (!(_hunger > 0.2f) || !(_thirst > 0.2f))
			{
				_needsNoticeTimer -= dt;
				if (_needsNoticeTimer <= 0f)
				{
					_needsNoticeTimer = 30f;
					Notify("Low Supplies", "Food " + Percent(_hunger) + "  Water " + Percent(_thirst), (NotificationType)1, 2f);
				}
			}
		}

		private void UpdateEmptyNeedDamage(float dt)
		{
			if (!_survivalDrain || (_hunger > 0f && _thirst > 0f))
			{
				_needsDamageTimer = 0f;
			}
			else if (RigData.HasPlayer)
			{
				_needsDamageTimer += dt;
				if (_needsDamageTimer >= 1f)
				{
					float num = ((((_hunger <= 0f) ? 1f : 0f) + ((_thirst <= 0f) ? 1f : 0f) > 1f) ? 1.4f : 1f);
					Player_Health health = RigData.Refs.Health;
					DamageLocalPlayer(Mathf.Max(0.15f, ((Health)health).max_Health / 120f * _needsDamageTimer * num));
					_needsDamageTimer = 0f;
				}
				_needsDamageNoticeTimer -= dt;
				if (_needsDamageNoticeTimer <= 0f)
				{
					_needsDamageNoticeTimer = 18f;
					Notify((_hunger <= 0f && _thirst <= 0f) ? "Starving and dehydrated" : ((_hunger <= 0f) ? "Starving" : "Dehydrated"), "Use food, drink, or medical supplies.", (NotificationType)1, 2f);
				}
			}
		}

		private void OnLocalRespawn()
		{
			_hunger = Mathf.Max(_hunger, 0.65f);
			_thirst = Mathf.Max(_thirst, 0.65f);
			LocalHealth.SetFullHealth();
		}

		private void SpawnForHost()
		{
			if (_onExpectedMap)
			{
				SpawnMissingZombies();
				SpawnMissingLoot();
			}
		}

		private bool ConfigureCurrentLevelProfile()
		{
			if (!ShouldRunOnCurrentLevel)
			{
				return false;
			}
			if (!SupportedLevels.TryGetValue(FusionSceneManager.Barcode, out var value))
			{
				_spawnProfile = BuildColliderProfile("Current Map", new SpawnProfile("Current Map", -160f, 160f, -160f, 160f, -30f, 85f, 180f, 260f));
				RefreshGroundSpawnPoints();
				return true;
			}
			_spawnProfile = BuildColliderProfile(value.Name, value.FallbackProfile);
			RefreshGroundSpawnPoints();
			return true;
		}

		private void SpawnMissingZombies()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			PruneMissing(_zombieEntities);
			int num = 0;
			while (_zombieEntities.Count < _maxZombies && num < _maxZombies * 4)
			{
				num++;
				if (TryFindZombiePoint(++_zombieSpawnCursor, out var point))
				{
					SpawnNetworked(ZombieBarcodes[Random.Range(0, ZombieBarcodes.Length)], rotation: Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), position: point, onEntity: delegate(NetworkEntity entity)
					{
						TrackEntity(entity, _zombieEntities);
					});
				}
			}
		}

		private void SpawnMissingLoot()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			PruneMissing(_lootEntities);
			int num = 0;
			while (_lootEntities.Count < _maxLoot && num < _maxLoot * 5)
			{
				num++;
				if (TryFindLootPoint(++_lootSpawnCursor, out var point))
				{
					LootEntry lootEntry = PickLoot();
					Quaternion rotation = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f);
					SpawnNetworked(lootEntry.Barcode, point, rotation, delegate(NetworkEntity entity)
					{
						TrackEntity(entity, _lootEntities);
					});
				}
			}
		}

		private static LootEntry PickLoot()
		{
			float value = Random.value;
			if (value < 0.45f)
			{
				return FoodLoot[Random.Range(0, FoodLoot.Length)];
			}
			if (value < 0.55f)
			{
				return MedicalLoot[Random.Range(0, MedicalLoot.Length)];
			}
			if (value < 0.82f)
			{
				return MeleeLoot[Random.Range(0, MeleeLoot.Length)];
			}
			if (value < 0.94f)
			{
				return AmmoLoot[Random.Range(0, AmmoLoot.Length)];
			}
			return GunLoot[Random.Range(0, GunLoot.Length)];
		}

		private bool TryFindLootPoint(int salt, out Vector3 point)
		{
			return TryFindScatterPoint(salt, 0.17f, out point);
		}

		private bool TryFindZombiePoint(int salt, out Vector3 point)
		{
			return TryFindScatterPoint(salt, 0.63f, out point);
		}

		private bool TryFindScatterPoint(int salt, float channelOffset, out Vector3 point)
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			if (_groundSpawnPoints.Count > 0)
			{
				int num = Mathf.Abs(salt * 37 + Mathf.RoundToInt(channelOffset * 997f)) % _groundSpawnPoints.Count;
				for (int i = 0; i < 8; i++)
				{
					int index = (num + i * 17) % _groundSpawnPoints.Count;
					if (TryGroundPoint(_groundSpawnPoints[index] + new Vector3(Random.Range(-4f, 4f), 0f, Random.Range(-4f, 4f)), _spawnProfile, out point))
					{
						return true;
					}
				}
				point = _groundSpawnPoints[num];
				return true;
			}
			for (int j = 0; j < 12; j++)
			{
				if (TryGroundPoint(_spawnProfile.GetScatterCandidate(salt + j * 19, channelOffset), _spawnProfile, out point))
				{
					return true;
				}
			}
			point = Vector3.zero;
			return false;
		}

		private void RefreshGroundSpawnPoints()
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			_groundSpawnPoints.Clear();
			float num = (_spawnProfile.MaxX - _spawnProfile.MinX) / 18f;
			float num2 = (_spawnProfile.MaxZ - _spawnProfile.MinZ) / 18f;
			for (int i = 0; i < 18; i++)
			{
				for (int j = 0; j < 18; j++)
				{
					float num3 = ((float)i + 0.5f) / 18f;
					float num4 = ((float)j + 0.5f) / 18f;
					if (TryGroundPoint(new Vector3(Mathf.Lerp(_spawnProfile.MinX, _spawnProfile.MaxX, num3) + Random.Range((0f - num) * 0.22f, num * 0.22f), _spawnProfile.RaycastTop, Mathf.Lerp(_spawnProfile.MinZ, _spawnProfile.MaxZ, num4) + Random.Range((0f - num2) * 0.22f, num2 * 0.22f)), _spawnProfile, out var point))
					{
						_groundSpawnPoints.Add(point);
					}
				}
			}
		}

		private static bool TryGroundPoint(Vector3 rough, SpawnProfile profile, out Vector3 point)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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)
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(new Vector3(rough.x, profile.RaycastTop, rough.z), Vector3.down, ref val, profile.RaycastDistance, -5, (QueryTriggerInteraction)1))
			{
				if (((RaycastHit)(ref val)).normal.y < 0.45f || ((RaycastHit)(ref val)).point.y < profile.MinY - 6f || ((RaycastHit)(ref val)).point.y > profile.MaxY + 8f)
				{
					point = Vector3.zero;
					return false;
				}
				point = ((RaycastHit)(ref val)).point + Vector3.up * 0.1f;
				return true;
			}
			point = Vector3.zero;
			return false;
		}

		private static SpawnProfile BuildColliderProfile(string levelName, SpawnProfile fallback)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Il2CppArrayBase<Collider> obj = Object.FindObjectsOfType<Collider>();
				bool flag = false;
				float num = float.MaxValue;
				float num2 = float.MinValue;
				float num3 = float.MaxValue;
				float num4 = float.MinValue;
				float num5 = float.MaxValue;
				float num6 = float.MinValue;
				foreach (Collider item in obj)
				{
					if (!((Object)(object)item == (Object)null) && item.enabled && !item.isTrigger)
					{
						Bounds bounds = item.bounds;
						if (LooksLikeMapGeometry(bounds))
						{
							num = Mathf.Min(num, ((Bounds)(ref bounds)).min.x);
							num2 = Mathf.Max(num2, ((Bounds)(ref bounds)).max.x);
							num3 = Mathf.Min(num3, ((Bounds)(ref bounds)).min.z);
							num4 = Mathf.Max(num4, ((Bounds)(ref bounds)).max.z);
							num5 = Mathf.Min(num5, ((Bounds)(ref bounds)).min.y);
							num6 = Mathf.Max(num6, ((Bounds)(ref bounds)).max.y);
							flag = true;
						}
					}
				}
				if (!flag)
				{
					return fallback.WithName(levelName);
				}
				float num7 = num2 - num;
				float num8 = num4 - num3;
				float num9 = fallback.MaxX - fallback.MinX;
				float num10 = fallback.MaxZ - fallback.MinZ;
				if (num7 < 45f || num8 < 45f || num7 > 2500f || num8 > 2500f)
				{
					return fallback.WithName(levelName);
				}
				if (num7 < num9 * 0.45f || num8 < num10 * 0.45f)
				{
					return fallback.WithName(levelName);
				}
				float num11 = Mathf.Clamp(num7 * 0.035f, 4f, 18f);
				float num12 = Mathf.Clamp(num8 * 0.035f, 4f, 18f);
				float num13 = Mathf.Max(num6 + 35f, fallback.RaycastTop);
				float raycastDistance = Mathf.Clamp(num13 - num5 + 35f, 90f, 1800f);
				return new SpawnProfile(levelName, num + num11, num2 - num11, num3 + num12, num4 - num12, num5, num6, num13, raycastDistance);
			}
			catch
			{
				return fallback.WithName(levelName);
			}
		}

		private static bool LooksLikeMapGeometry(Bounds bounds)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			Vector3 size = ((Bounds)(ref bounds)).size;
			if (((Bounds)(ref bounds)).center.y < -120f || ((Bounds)(ref bounds)).center.y > 240f)
			{
				return false;
			}
			if (size.x > 2200f || size.z > 2200f || size.y > 260f)
			{
				return false;
			}
			if (!(size.x >= 3f))
			{
				return size.z >= 3f;
			}
			return true;
		}

		private static void SpawnNetworked(string barcode, Vector3 position, Quaternion rotation, Action<NetworkEntity> onEntity)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (!HasSpawnable(barcode))
			{
				return;
			}
			Spawnable spawnable = new Spawnable
			{
				crateRef = new SpawnableCrateReference(new Barcode(barcode)),
				policyData = null
			};
			NetworkAssetSpawner.Spawn(new SpawnRequestInfo
			{
				Spawnable = spawnable,
				Position = position,
				Rotation = rotation,
				SpawnEffect = true,
				SpawnSource = (EntitySource)1,
				SpawnCallback = delegate(SpawnCallbackInfo info)
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					if (info.Entity != null)
					{
						onEntity(info.Entity);
					}
				}
			});
		}

		private static bool HasSpawnable(string barcode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			try
			{
				return CrateFilterer.HasCrate<SpawnableCrate>(new Barcode(barcode));
			}
			catch
			{
				return false;
			}
		}

		private void TrackEntity(NetworkEntity entity, HashSet<ushort> targetSet)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			if (entity != null && entity.ID != 0)
			{
				targetSet.Add(entity.ID);
				entity.OnEntityUnregistered += new NetworkEntityDelegate(OnTrackedEntityUnregistered);
			}
		}

		private void OnTrackedEntityUnregistered(NetworkEntity entity)
		{
			if (entity != null)
			{
				_zombieEntities.Remove(entity.ID);
				_lootEntities.Remove(entity.ID);
				_consumedEntities.Remove(entity.ID);
			}
		}

		private static void PruneMissing(HashSet<ushort> ids)
		{
			ids.RemoveWhere((ushort id) => id == 0 || !NetworkEntityManager.IDManager.RegisteredEntities.HasEntity(id));
		}

		private static void DespawnTracked(HashSet<ushort> ids)
		{
			//IL_0011: 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)
			ushort[] array = ids.ToArray();
			foreach (ushort entityID in array)
			{
				NetworkAssetSpawner.Despawn(new DespawnRequestInfo
				{
					EntityID = entityID,
					DespawnEffect = true
				});
			}
		}

		private void OnLocalPlayerGrab(Hand hand, Grip grip)
		{
			if (((Gamemode)this).IsStarted && !((Object)(object)grip == (Object)null) && TryGetGrabbedSpawnable(grip, out var barcode, out var entityId) && Consumables.TryGetValue(barcode, out var value))
			{
				TrackHeldUsable(hand, grip, entityId, value);
				Notify(value.Name, "Hold it and tap the menu button to use.", (NotificationType)0, 1.6f);
			}
		}

		private void OnLocalPlayerRelease(Hand hand, Grip grip)
		{
			if (!((Object)(object)grip == (Object)null))
			{
				_heldUsables.RemoveAll((HeldUsable held) => (Object)(object)held.Grip == (Object)(object)grip || (Object)(object)held.Hand == (Object)(object)hand);
			}
		}

		private void TrackHeldUsable(Hand hand, Grip grip, ushort entityId, LootEntry entry)
		{
			_heldUsables.RemoveAll((HeldUsable held) => (Object)(object)held.Grip == (Object)(object)grip || (Object)(object)held.Hand == (Object)(object)hand || (entityId != 0 && held.EntityId == entityId));
			_heldUsables.Add(new HeldUsable(hand, grip, entityId, entry));
		}

		private void UpdateHeldUsableInput()
		{
			for (int num = _heldUsables.Count - 1; num >= 0; num--)
			{
				HeldUsable heldUsable = _heldUsables[num];
				if ((Object)(object)heldUsable.Hand == (Object)null || (Object)(object)heldUsable.Grip == (Object)null)
				{
					_heldUsables.RemoveAt(num);
				}
				else if ((Object)(object)heldUsable.Hand.Controller != (Object)null && heldUsable.Hand.Controller.GetMenuTap())
				{
					UseHeldItem(num);
				}
			}
		}

		private void UseHeldItem(int heldIndex)
		{
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			if (heldIndex < 0 || heldIndex >= _heldUsables.Count)
			{
				return;
			}
			HeldUsable held = _heldUsables[heldIndex];
			LootEntry entry = held.Entry;
			if (held.EntityId != 0 && !_consumedEntities.Add(held.EntityId))
			{
				_heldUsables.RemoveAt(heldIndex);
				return;
			}
			_hunger = Mathf.Clamp01(_hunger + entry.Food);
			_thirst = Mathf.Clamp01(_thirst + entry.Water);
			ApplyUseHealing(entry);
			_needsDamageTimer = 0f;
			Notify(entry.Name, "Food " + Percent(_hunger) + "  Water " + Percent(_thirst), (NotificationType)3, 1.75f);
			if (held.EntityId != 0)
			{
				NetworkAssetSpawner.Despawn(new DespawnRequestInfo
				{
					EntityID = held.EntityId,
					DespawnEffect = true
				});
			}
			_heldUsables.RemoveAll((HeldUsable other) => (Object)(object)other.Grip == (Object)(object)held.Grip || (Object)(object)other.Hand == (Object)(object)held.Hand || (held.EntityId != 0 && other.EntityId == held.EntityId));
		}

		private static void ApplyUseHealing(LootEntry entry)
		{
			if (entry.Heals)
			{
				if (entry.Barcode == "notnotnotswipez.SevenRP.Spawnable.Bandage")
				{
					HealLocalPlayer(0.35f);
				}
				else
				{
					LocalHealth.SetFullHealth();
				}
			}
		}

		private static void HealLocalPlayer(float maxHealthPercent)
		{
			if (RigData.HasPlayer)
			{
				Player_Health health = RigData.Refs.Health;
				((Health)health).curr_Health = Mathf.Min(((Health)health).max_Health, ((Health)health).curr_Health + ((Health)health).max_Health * maxHealthPercent);
				health.isInstaDying = false;
				((Health)health).deathIsImminent = false;
			}
		}

		private static void DamageLocalPlayer(float damage)
		{
			if (!RigData.HasPlayer)
			{
				return;
			}
			Player_Health health = RigData.Refs.Health;
			if (!((Object)(object)health == (Object)null) && ((Health)health).alive)
			{
				((Health)health).curr_Health = Mathf.Max(0f, ((Health)health).curr_Health - damage);
				if (((Health)health).curr_Health <= 0f)
				{
					health.ApplyKillDamage();
				}
			}
		}

		private static bool TryGetGrabbedSpawnable(Grip grip, out string barcode, out ushort entityId)
		{
			barcode = null;
			entityId = 0;
			MarrowEntity marrowEntity = grip._marrowEntity;
			if ((Object)(object)marrowEntity == (Object)null)
			{
				return false;
			}
			NetworkEntity val = default(NetworkEntity);
			if (IMarrowEntityExtender.Cache.TryGet(marrowEntity, ref val))
			{
				entityId = val.ID;
			}
			Poolee poolee = marrowEntity._poolee;
			if ((Object)(object)poolee == (Object)null || (Object)(object)poolee.SpawnableCrate == (Object)null || ((Scannable)poolee.SpawnableCrate).Barcode == (Barcode)null)
			{
				return false;
			}
			barcode = ((Scannable)poolee.SpawnableCrate).Barcode.ID;
			return !string.IsNullOrWhiteSpace(barcode);
		}

		private static void Notify(string title, string message, NotificationType type, float length = 2.5f)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			Notifier.Send(new Notification
			{
				Title = NotificationText.op_Implicit(title),
				Message = NotificationText.op_Implicit(message),
				Tag = "DayZSurvival",
				SaveToMenu = false,
				ShowPopup = true,
				PopupLength = length,
				Type = type
			});
		}

		private static string Percent(float value)
		{
			return $"{Mathf.RoundToInt(Mathf.Clamp01(value) * 100f)}%";
		}

		private static float Frac(float value)
		{
			return value - Mathf.Floor(value);
		}
	}
}