Decompiled source of FordRoyale v0.1.4

Mods/FordRoyale.dll

Decompiled 12 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using FordRoyale;
using Il2CppSLZ.Bonelab;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Data;
using Il2CppSLZ.Marrow.Warehouse;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LabFusion.Data;
using LabFusion.Marrow.Pool;
using LabFusion.Menu.Data;
using LabFusion.Network;
using LabFusion.Player;
using LabFusion.RPC;
using LabFusion.SDK.Gamemodes;
using LabFusion.SDK.Modules;
using LabFusion.SDK.Triggers;
using LabFusion.Scene;
using LabFusion.Senders;
using LabFusion.UI.Popups;
using LabFusion.Utilities;
using MelonLoader;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(FordRoyaleMod), "FordRoyale", "0.1.4", "JonLandonMods", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonAdditionalDependencies(new string[] { "LabFusion" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("FordRoyale")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("FordRoyale")]
[assembly: AssemblyTitle("FordRoyale")]
[assembly: AssemblyVersion("0.1.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 FordRoyale
{
	public static class FordRoyaleConfig
	{
		public const string MapLevelBarcode = "Schoold.TiltedTowersBONELAB.Level.TiltedTowers";

		public static readonly Vector3 MapCenter = new Vector3(0f, 0f, 0f);

		public const float LootScatterRadius = 80f;

		public static bool FortniteGunsRequired = true;

		public static bool FortnitePropsRequired = true;

		public static bool TiltedTowersMapRequired = false;

		public const float RareWeaponChance = 0.3f;

		public const float EpicWeaponChance = 0.1f;

		public static readonly string[] CommonWeapons = new string[10] { "Blurgert.FortniteGunPack.Spawnable.SemiAutoPistol", "Blurgert.FortniteGunPack.Spawnable.SidearmPistol", "Blurgert.FortniteGunPack.Spawnable.RangerPistol", "Blurgert.FortniteGunPack.Spawnable.CombatPistol", "Blurgert.FortniteGunPack.Spawnable.TacticalPistol", "Blurgert.FortniteGunPack.Spawnable.SubmachineGun", "Blurgert.FortniteGunPack.Spawnable.CompactSMG", "Blurgert.FortniteGunPack.Spawnable.MicroSMG", "Blurgert.FortniteGunPack.Spawnable.HuntingRifle", "Blurgert.FortniteGunPack.Spawnable.PumpShotgunRare" };

		public static readonly string[] RareWeapons = new string[15]
		{
			"Blurgert.FortniteGunPack.Spawnable.AssaultRifle", "Blurgert.FortniteGunPack.Spawnable.Scar", "Blurgert.FortniteGunPack.Spawnable.TacticalAssaultRifle", "Blurgert.FortniteGunPack.Spawnable.CombatAssaultRifle", "Blurgert.FortniteGunPack.Spawnable.RedeyeAssaultRifle", "Blurgert.FortniteGunPack.Spawnable.TwinMagAssaultRifle", "Blurgert.FortniteGunPack.Spawnable.HammerAssaultRifle", "Blurgert.FortniteGunPack.Spawnable.PumpShotgunEpic", "Blurgert.FortniteGunPack.Spawnable.TacticalShotgun", "Blurgert.FortniteGunPack.Spawnable.CombatShotgun",
			"Blurgert.FortniteGunPack.Spawnable.CombatSMG", "Blurgert.FortniteGunPack.Spawnable.DrumGun", "Blurgert.FortniteGunPack.Spawnable.SuppressedScar", "Blurgert.FortniteGunPack.Spawnable.FlapjackRifle", "Blurgert.FortniteGunPack.Spawnable.LeverActionRifle"
		};

		public static readonly string[] EpicWeapons = new string[9] { "Blurgert.FortniteGunPack.Spawnable.BoltActionSniperRifle", "Blurgert.FortniteGunPack.Spawnable.SemiAutoSniperRifle", "Blurgert.FortniteGunPack.Spawnable.HeavySniperRifle", "Blurgert.FortniteGunPack.Spawnable.DeadeyeDMR", "Blurgert.FortniteGunPack.Spawnable.HandCannon", "Blurgert.FortniteGunPack.Spawnable.MidasDrumGun", "Blurgert.FortniteGunPack.Spawnable.MysticsAssaultRifle", "Blurgert.FortniteGunPack.Spawnable.MysticsHandCannon", "Blurgert.FortniteGunPack.Spawnable.MysticsFrenzyAutoShotgun" };

		public static readonly string[] PropBarcodes = new string[6] { "Blurgert.FortnitePropPack.Spawnable.Chest", "Blurgert.FortnitePropPack.Spawnable.Chest", "Blurgert.FortnitePropPack.Spawnable.AmmoBox", "Blurgert.FortnitePropPack.Spawnable.AmmoBox", "Blurgert.FortnitePropPack.Spawnable.RareChest", "Blurgert.FortnitePropPack.Spawnable.LaunchPadStatic" };

		public static readonly string[] VanillaCommonWeapons = new string[8] { "c1534c5a-2a4f-481f-8542-cc9545646572", "c1534c5a-aade-4fa1-8f4b-d4c547756e4d", "c1534c5a-bcb7-4f02-a4f5-da9550333530", "c1534c5a-50cf-4500-83d5-c0b447756e50", "c1534c5a-fcfc-4f43-8fb0-d29531393131", "c1534c5a-9f55-4c56-ae23-d33b47727562", "c1534c5a-8d03-42de-93c7-f595534d4755", "c1534c5a-9f54-4f32-b8b9-f295534d474d" };

		public static readonly string[] VanillaRareWeapons = new string[9] { "c1534c5a-d00c-4aa8-adfd-3495534d474d", "c1534c5a-4c47-428d-b5a5-b05747756e56", "c1534c5a-04d7-41a0-b7b8-5a95534d4750", "c1534c5a-40e5-40e0-8139-194347756e55", "c1534c5a-a6b5-4177-beb8-04d947756e41", "c1534c5a-9112-49e5-b022-9c955269666c", "c1534c5a-2774-48db-84fd-778447756e46", "c1534c5a-7f05-402f-9320-609647756e35", "c1534c5a-e0b5-4d4b-9df3-567147756e4d" };

		public static readonly string[] VanillaEpicWeapons = new string[5] { "c1534c5a-ea97-495d-b0bf-ac955269666c", "c1534c5a-cc53-4aac-b842-46955269666c", "c1534c5a-c061-4c5c-a5e2-3d955269666c", "c1534c5a-ec8e-418a-a545-cf955269666c", "SLZ.BONELAB.Content.Spawnable.RifleM1Garand" };

		public static readonly string[] VanillaMeleeWeapons = new string[14]
		{
			"c1534c5a-6441-40aa-a070-909542617365", "c1534c5a-0c8a-4b82-9f8b-7a9543726f77", "c1534c5a-a767-4a58-b3ef-26064d616368", "c1534c5a-282b-4430-b009-58954b617461", "c1534c5a-d605-4f85-870d-f68848617463", "c1534c5a-d0e9-4d53-9218-e76446727969", "c1534c5a-8597-4ffe-892e-b995476f6c66", "c1534c5a-f6f9-4c96-b88e-91d74c656164", "c1534c5a-1f5a-4993-bbc1-03be4d656c65", "c1534c5a-1fb8-477c-afbe-2a95436f6d62",
			"c1534c5a-a97f-4bff-b512-e44d53706561", "c1534c5a-e75f-4ded-aa5a-a27b4178655f", "c1534c5a-d086-4e27-918d-ee9542617374", "fa534c5a868247138f50c62e424c4144.Spawnable.Baton"
		};

		public const int StartingAmmo = 150;

		public const float StormGraceTime = 90f;

		public const float StormStartRadius = 120f;

		public const float StormMinStartRadius = 40f;

		public const float StormMaxStartRadius = 250f;

		public static readonly float[] StormPhaseFractions = new float[4] { 0.6f, 0.35f, 0.18f, 0.08f };

		public const float StormHoldTime = 45f;

		public const float StormShrinkTime = 30f;

		public static readonly int[] StormCountdownWarnings = new int[3] { 30, 10, 5 };

		public const float StormDamagePerSecond = 0.25f;

		public const float StormTickInterval = 1f;

		public static bool IsQuest => (int)Application.platform == 11;

		public static int WeaponSpawnCount
		{
			get
			{
				if (!IsQuest)
				{
					return 30;
				}
				return 18;
			}
		}

		public static int PropSpawnCount
		{
			get
			{
				if (!IsQuest)
				{
					return 15;
				}
				return 8;
			}
		}

		public static int MeleeSpawnCount
		{
			get
			{
				if (!IsQuest)
				{
					return 10;
				}
				return 6;
			}
		}

		public static int AmmoBoxSpawnCount
		{
			get
			{
				if (!IsQuest)
				{
					return 12;
				}
				return 6;
			}
		}
	}
	public class FordRoyaleGamemode : Gamemode
	{
		private readonly TeamManager _teamManager = new TeamManager();

		private readonly Team _aliveTeam = new Team("Alive");

		private readonly Team _eliminatedTeam = new Team("Eliminated");

		private readonly Storm _storm = new Storm();

		public const string StormPhasesKey = "FordRoyale.StormPhases";

		public override string Title => "Ford Royale";

		public override string Author => "JonLandonMods";

		public override string Description => "A mini battle royale! Weapons and chests are scattered around the map. Stay inside the storm circle and be the last player standing to claim the Victory Royale! Requires the Fortnite weapon/prop mods and the map from mod.io.";

		public override bool DisableDevTools => true;

		public override bool DisableSpawnGun => true;

		public override bool DisableManualUnragdoll => true;

		public override bool AutoHolsterOnDeath => true;

		public static FordRoyaleGamemode Instance { get; private set; }

		public TeamManager TeamManager => _teamManager;

		public Team AliveTeam => _aliveTeam;

		public Team EliminatedTeam => _eliminatedTeam;

		public Storm Storm => _storm;

		public TriggerEvent VictoryEvent { get; set; }

		public TriggerEvent EliminationEvent { get; set; }

		public int MinimumPlayers { get; set; } = 2;

		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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_0075: 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_0085: 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_00ba: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			GroupElementData obj = ((Gamemode)this).CreateSettingsGroup();
			GroupElementData val = new GroupElementData("General");
			obj.AddElement<GroupElementData>(val);
			val.AddElement<IntElementData>(new IntElementData
			{
				Title = "Minimum Players",
				Value = MinimumPlayers,
				Increment = 1,
				MinValue = 2,
				MaxValue = 20,
				OnValueChanged = delegate(int v)
				{
					MinimumPlayers = v;
				}
			});
			GroupElementData val2 = new GroupElementData("Required Mods");
			obj.AddElement<GroupElementData>(val2);
			val2.AddElement<BoolElementData>(new BoolElementData
			{
				Title = "Fortnite Gun Mod Required",
				Value = FordRoyaleConfig.FortniteGunsRequired,
				OnValueChanged = delegate(bool v)
				{
					FordRoyaleConfig.FortniteGunsRequired = v;
				}
			});
			val2.AddElement<BoolElementData>(new BoolElementData
			{
				Title = "Fortnite Prop Mod Required",
				Value = FordRoyaleConfig.FortnitePropsRequired,
				OnValueChanged = delegate(bool v)
				{
					FordRoyaleConfig.FortnitePropsRequired = v;
				}
			});
			val2.AddElement<BoolElementData>(new BoolElementData
			{
				Title = "Tilted Towers Map Required",
				Value = FordRoyaleConfig.TiltedTowersMapRequired,
				OnValueChanged = delegate(bool v)
				{
					FordRoyaleConfig.TiltedTowersMapRequired = v;
				}
			});
			return obj;
		}

		public override bool CheckReadyConditions()
		{
			if (PlayerIDManager.PlayerCount < MinimumPlayers)
			{
				return false;
			}
			if (FordRoyaleConfig.TiltedTowersMapRequired && FusionSceneManager.Barcode != "Schoold.TiltedTowersBONELAB.Level.TiltedTowers")
			{
				return false;
			}
			return true;
		}

		public override void OnGamemodeRegistered()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			Instance = this;
			MultiplayerHooking.OnPlayerAction += new PlayerAction(OnPlayerAction);
			FusionOverrides.OnValidateNametag += new UserOverride(OnValidateNametag);
			TeamManager.Register((Gamemode)(object)this);
			TeamManager.AddTeam(AliveTeam);
			TeamManager.AddTeam(EliminatedTeam);
			VictoryEvent = new TriggerEvent("VictoryRoyale", ((Gamemode)this).Relay, false);
			VictoryEvent.OnTriggeredWithValue += OnVictory;
			EliminationEvent = new TriggerEvent("Elimination", ((Gamemode)this).Relay, false);
			EliminationEvent.OnTriggeredWithValue += OnElimination;
		}

		public override void OnGamemodeUnregistered()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			if (Instance == this)
			{
				Instance = null;
			}
			MultiplayerHooking.OnPlayerAction -= new PlayerAction(OnPlayerAction);
			FusionOverrides.OnValidateNametag -= new UserOverride(OnValidateNametag);
			TeamManager.Unregister();
			VictoryEvent.UnregisterEvent();
			VictoryEvent = null;
			EliminationEvent.UnregisterEvent();
			EliminationEvent = null;
		}

		public override void OnGamemodeStarted()
		{
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: 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_010c: 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)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			((Gamemode)this).OnGamemodeStarted();
			LocalHealth.MortalityOverride = true;
			LocalHealth.RegenerationOverride = false;
			LocalControls.DisableSlowMo = true;
			LocalHealth.SetFullHealth();
			LocalInventory.SetAmmo(150);
			Storm.Start();
			WristHealthDisplay.Show();
			MapDisplay.AddMenuItem();
			if (NetworkInfo.IsHost)
			{
				foreach (PlayerID playerID in PlayerIDManager.PlayerIDs)
				{
					TeamManager.TryAssignTeam(playerID, AliveTeam);
				}
				? val = ((??)GetLocalPlayerPosition()) ?? FordRoyaleConfig.MapCenter;
				float startRadius = MapBounds.GetStartRadius(MapBounds.Compute((Vector3)val));
				List<StormPhase> phases = Storm.GeneratePhases((Vector3)val, startRadius);
				((Gamemode)this).Metadata.TrySetMetadata("FordRoyale.StormPhases", Storm.SerializePhases(phases));
				Storm.ApplyPhases(phases);
				LootSpawner.SpawnAllLoot((Vector3)val);
			}
			FusionOverrides.ForceUpdateOverrides();
			Notifier.Send(new Notification
			{
				ShowPopup = true,
				Title = NotificationText.op_Implicit("Ford Royale"),
				Message = NotificationText.op_Implicit("The round has started! Find a weapon, stay out of the storm, and be the last one standing!"),
				PopupLength = 5f,
				Type = (NotificationType)0
			});
		}

		public override void OnGamemodeStopped()
		{
			((Gamemode)this).OnGamemodeStopped();
			Storm.Stop();
			WristHealthDisplay.Hide();
			MapDisplay.HideMap();
			MapDisplay.RemoveMenuItem();
			LocalHealth.MortalityOverride = null;
			LocalHealth.RegenerationOverride = null;
			LocalControls.DisableSlowMo = false;
			if (NetworkInfo.IsHost)
			{
				TeamManager.UnassignAllPlayers();
				LootSpawner.CleanupLoot();
			}
			FusionOverrides.ForceUpdateOverrides();
		}

		protected override void OnUpdate()
		{
			if (((Gamemode)this).IsStarted)
			{
				Storm.Update();
				WristHealthDisplay.Update();
				MapDisplay.Update(Storm);
			}
		}

		protected override void OnPlayerJoined(PlayerID playerId)
		{
			if (NetworkInfo.IsHost)
			{
				TeamManager.TryAssignTeam(playerId, EliminatedTeam);
			}
		}

		protected override void OnPlayerLeft(PlayerID playerId)
		{
			if (NetworkInfo.IsHost)
			{
				CheckForVictory(playerId.SmallID);
			}
		}

		protected bool OnValidateNametag(PlayerID id)
		{
			return !((Gamemode)this).IsStarted;
		}

		private void OnPlayerAction(PlayerID player, PlayerActionType type, PlayerID otherPlayer = null)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			if (((Gamemode)this).IsStarted && NetworkInfo.IsHost && (int)type == 2 && AliveTeam.HasPlayer(player))
			{
				TeamManager.TryAssignTeam(player, EliminatedTeam);
				string text = default(string);
				MetadataHelper.TryGetDisplayName(player, ref text);
				EliminationEvent.TryInvoke(text ?? "A player");
				CheckForVictory(player.SmallID);
			}
		}

		protected override void OnMetadataChanged(string key, string value)
		{
			if (key == "FordRoyale.StormPhases" && !NetworkInfo.IsHost)
			{
				List<StormPhase> list = Storm.ParsePhases(value);
				if (list.Count >= 2)
				{
					Storm.ApplyPhases(list);
				}
			}
		}

		private static Vector3? GetLocalPlayerPosition()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (!RigData.HasPlayer)
			{
				return null;
			}
			return RigData.Refs.RigManager.physicsRig.feet.transform.position;
		}

		private static string FormatVector(Vector3 v)
		{
			CultureInfo invariantCulture = CultureInfo.InvariantCulture;
			return $"{v.x.ToString(invariantCulture)};{v.y.ToString(invariantCulture)};{v.z.ToString(invariantCulture)}";
		}

		private static bool TryParseVector(string value, out Vector3 result)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//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)
			result = default(Vector3);
			string[] array = value.Split(';');
			if (array.Length != 3)
			{
				return false;
			}
			CultureInfo invariantCulture = CultureInfo.InvariantCulture;
			if (!float.TryParse(array[0], NumberStyles.Float, invariantCulture, out var result2) || !float.TryParse(array[1], NumberStyles.Float, invariantCulture, out var result3) || !float.TryParse(array[2], NumberStyles.Float, invariantCulture, out var result4))
			{
				return false;
			}
			result = new Vector3(result2, result3, result4);
			return true;
		}

		private void CheckForVictory(byte removedSmallId)
		{
			List<byte> list = AliveTeam.Players.Where((byte smallId) => smallId != removedSmallId).ToList();
			if (list.Count > 1)
			{
				return;
			}
			string text = "Nobody";
			if (list.Count == 1)
			{
				PlayerID playerID = PlayerIDManager.GetPlayerID(list[0]);
				if (playerID != null)
				{
					MetadataHelper.TryGetDisplayName(playerID, ref text);
				}
			}
			VictoryEvent.TryInvoke(text);
			GamemodeManager.StopGamemode();
		}

		private void OnElimination(string playerName)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_006a: 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_0081: Expected O, but got Unknown
			Notifier.Send(new Notification
			{
				ShowPopup = true,
				Title = NotificationText.op_Implicit("Elimination"),
				Message = NotificationText.op_Implicit($"{playerName} has been eliminated! {AliveTeam.PlayerCount} players remain."),
				PopupLength = 3f,
				Type = (NotificationType)0
			});
		}

		private void OnVictory(string winnerName)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0032: 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_0049: Expected O, but got Unknown
			Notifier.Send(new Notification
			{
				ShowPopup = true,
				Title = NotificationText.op_Implicit("VICTORY ROYALE"),
				Message = NotificationText.op_Implicit(winnerName + " wins the Ford Royale!"),
				PopupLength = 6f,
				Type = (NotificationType)3
			});
		}
	}
	public class FordRoyaleModule : Module
	{
		public override string Name => "FordRoyale";

		public override string Author => "JonLandonMods";

		public override Version Version => new Version(0, 1, 0);

		public override ConsoleColor Color => ConsoleColor.Cyan;

		protected override void OnModuleRegistered()
		{
			GamemodeRegistration.LoadGamemodes(Assembly.GetExecutingAssembly());
			((Module)this).LoggerInstance.Log("FordRoyale gamemode registered with Fusion!", ConsoleColor.White);
		}
	}
	public static class LootSpawner
	{
		private static readonly Random _random = new Random();

		private static readonly List<ushort> _spawnedEntities = new List<ushort>();

		private static Vector3 _center = FordRoyaleConfig.MapCenter;

		public static void SpawnAllLoot(Vector3 center)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			_center = center;
			for (int i = 0; i < FordRoyaleConfig.WeaponSpawnCount; i++)
			{
				SpawnOne(RollWeaponBarcode());
			}
			if (FordRoyaleConfig.FortnitePropsRequired)
			{
				for (int j = 0; j < FordRoyaleConfig.PropSpawnCount; j++)
				{
					string[] propBarcodes = FordRoyaleConfig.PropBarcodes;
					SpawnOne(propBarcodes[_random.Next(propBarcodes.Length)]);
				}
			}
			if (FordRoyaleConfig.FortniteGunsRequired)
			{
				return;
			}
			string[] vanillaMeleeWeapons = FordRoyaleConfig.VanillaMeleeWeapons;
			for (int k = 0; k < FordRoyaleConfig.MeleeSpawnCount; k++)
			{
				SpawnOne(vanillaMeleeWeapons[_random.Next(vanillaMeleeWeapons.Length)]);
			}
			string[] barcodes = VanillaAmmoCrates.GetBarcodes();
			if (barcodes.Length != 0)
			{
				for (int l = 0; l < FordRoyaleConfig.AmmoBoxSpawnCount; l++)
				{
					SpawnOne(barcodes[_random.Next(barcodes.Length)]);
				}
			}
		}

		private static string RollWeaponBarcode()
		{
			double num = _random.NextDouble();
			bool fortniteGunsRequired = FordRoyaleConfig.FortniteGunsRequired;
			string[] array = ((num < 0.10000000149011612) ? (fortniteGunsRequired ? FordRoyaleConfig.EpicWeapons : FordRoyaleConfig.VanillaEpicWeapons) : ((!(num < 0.4000000059604645)) ? (fortniteGunsRequired ? FordRoyaleConfig.CommonWeapons : FordRoyaleConfig.VanillaCommonWeapons) : (fortniteGunsRequired ? FordRoyaleConfig.RareWeapons : FordRoyaleConfig.VanillaRareWeapons)));
			return array[_random.Next(array.Length)];
		}

		private static void SpawnOne(string barcode)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_004a: 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)
			if (!TryGetGroundPoint(out var position))
			{
				return;
			}
			Spawnable spawnable = LocalAssetSpawner.CreateSpawnable(barcode);
			NetworkAssetSpawner.Spawn(new SpawnRequestInfo
			{
				Spawnable = spawnable,
				Position = position,
				Rotation = Quaternion.Euler(0f, (float)_random.Next(360), 0f),
				SpawnEffect = false,
				SpawnCallback = delegate(SpawnCallbackInfo info)
				{
					//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)
					if (info.Entity != null)
					{
						_spawnedEntities.Add(info.Entity.ID);
					}
				}
			});
		}

		public static void CleanupLoot()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			foreach (ushort spawnedEntity in _spawnedEntities)
			{
				NetworkAssetSpawner.Despawn(new DespawnRequestInfo
				{
					EntityID = spawnedEntity,
					DespawnEffect = false
				});
			}
			_spawnedEntities.Clear();
		}

		private static bool TryGetGroundPoint(out Vector3 position)
		{
			//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_005a: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: 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_00ff: 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_0099: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			Vector3 center = _center;
			RaycastHit val = default(RaycastHit);
			for (int i = 0; i < 16; i++)
			{
				float num = 1f - (float)i / 16f * 0.9f;
				float num2 = 80f * num;
				float num3 = (float)(_random.NextDouble() * 3.1415927410125732 * 2.0);
				float num4 = (float)_random.NextDouble() * num2;
				if (Physics.Raycast(center + new Vector3(Mathf.Cos(num3) * num4, 100f, Mathf.Sin(num3) * num4), Vector3.down, ref val, 400f))
				{
					position = ((RaycastHit)(ref val)).point + Vector3.up * 0.5f;
					return true;
				}
			}
			position = center + new Vector3(((float)_random.NextDouble() - 0.5f) * 4f, 0.5f, ((float)_random.NextDouble() - 0.5f) * 4f);
			return true;
		}
	}
	public class FordRoyaleMod : MelonMod
	{
		public override void OnInitializeMelon()
		{
			ModuleManager.LoadModules(Assembly.GetExecutingAssembly());
			StormAudio.OnInitializeMelon();
			((MelonBase)this).LoggerInstance.Msg("FordRoyale loaded! Drop in and win that Victory Royale.");
		}
	}
	public static class MapBounds
	{
		public static Bounds Compute(Vector3 focus)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_0043: 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_0056: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			Bounds bounds = default(Bounds);
			((Bounds)(ref bounds))..ctor(focus, Vector3.zero);
			bool flag = false;
			foreach (Renderer item in Object.FindObjectsOfType<Renderer>())
			{
				if ((Object)(object)item == (Object)null || !item.enabled)
				{
					continue;
				}
				Bounds bounds2 = item.bounds;
				Vector3 size = ((Bounds)(ref bounds2)).size;
				float num = Mathf.Max(new float[3] { size.x, size.y, size.z });
				if (num < 0.1f || num > 600f)
				{
					continue;
				}
				bounds2 = item.bounds;
				if (!(Vector3.Distance(((Bounds)(ref bounds2)).center, focus) > 500f))
				{
					if (!flag)
					{
						bounds = item.bounds;
						flag = true;
					}
					else
					{
						((Bounds)(ref bounds)).Encapsulate(item.bounds);
					}
				}
			}
			return bounds;
		}

		public static float GetStartRadius(Bounds bounds)
		{
			//IL_0002: 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)
			return Mathf.Clamp(Mathf.Max(((Bounds)(ref bounds)).extents.x, ((Bounds)(ref bounds)).extents.z) * 0.9f, 40f, 250f);
		}

		public static float GetWallHeight(Bounds bounds)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return Mathf.Clamp(((Bounds)(ref bounds)).size.y + 100f, 100f, 500f);
		}
	}
	public static class MapDisplay
	{
		private const string PageName = "Ford Royale Map";

		private static PageItem _mapPage;

		private static bool _visible;

		private static RenderTexture _renderTexture;

		private static GameObject _cameraObject;

		private static Camera _camera;

		private static GameObject _panel;

		private static GameObject _playerMarker;

		private static GameObject _nextCircleRing;

		private static GameObject _currentCircleRing;

		private static Material _ringMaterial;

		private static Material _currentRingMaterial;

		public static void AddMenuItem()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			RemoveMenuItem();
			PopUpMenuView popUpMenu = UIRig.Instance.popUpMenu;
			Page homePage = popUpMenu.radialPageView.m_HomePage;
			_mapPage = new PageItem("Ford Royale Map", (Directions)5, Action.op_Implicit((Action)delegate
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Expected O, but got Unknown
				popUpMenu.Deactivate();
				Toggle();
				Notifier.Send(new Notification
				{
					ShowPopup = true,
					SaveToMenu = false,
					Message = NotificationText.op_Implicit(_visible ? "Map Shown" : "Map Hidden"),
					PopupLength = 1f
				});
			}));
			homePage.items.Add(_mapPage);
		}

		public static void RemoveMenuItem()
		{
			if (_mapPage != null)
			{
				PopUpMenuView popUpMenu = UIRig.Instance.popUpMenu;
				Page homePage = popUpMenu.radialPageView.m_HomePage;
				homePage.items.RemoveAll(Predicate<PageItem>.op_Implicit((Func<PageItem, bool>)((PageItem i) => i.name == "Ford Royale Map")));
				popUpMenu.radialPageView.Render(homePage);
				_mapPage = null;
			}
		}

		public static void Toggle()
		{
			if (_visible)
			{
				HideMap();
			}
			else
			{
				ShowMap();
			}
		}

		public static void ShowMap()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0029: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Expected O, but got Unknown
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Expected O, but got Unknown
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Expected O, but got Unknown
			HideMap();
			_renderTexture = new RenderTexture(512, 512, 16)
			{
				antiAliasing = 2,
				filterMode = (FilterMode)1
			};
			_cameraObject = new GameObject("FordRoyale Map Camera");
			_camera = _cameraObject.AddComponent<Camera>();
			_camera.orthographic = true;
			_camera.farClipPlane = 500f;
			_camera.targetTexture = _renderTexture;
			_cameraObject.transform.rotation = Quaternion.Euler(90f, 0f, 0f);
			_panel = GameObject.CreatePrimitive((PrimitiveType)5);
			((Object)_panel).name = "FordRoyale Map Panel";
			Collider component = _panel.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			Material material = new Material(Shader.Find("Sprites/Default"))
			{
				mainTexture = (Texture)(object)_renderTexture,
				color = Color.white
			};
			((Renderer)_panel.GetComponent<MeshRenderer>()).material = material;
			_panel.transform.localScale = new Vector3(0.4f, 0.4f, 0.4f);
			_playerMarker = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)_playerMarker).name = "FordRoyale Map Player Marker";
			Collider component2 = _playerMarker.GetComponent<Collider>();
			if ((Object)(object)component2 != (Object)null)
			{
				Object.Destroy((Object)(object)component2);
			}
			((Renderer)_playerMarker.GetComponent<MeshRenderer>()).material = new Material(Shader.Find("Sprites/Default"))
			{
				color = Color.red
			};
			_nextCircleRing = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)_nextCircleRing).name = "FordRoyale Map Next Circle";
			Collider component3 = _nextCircleRing.GetComponent<Collider>();
			if ((Object)(object)component3 != (Object)null)
			{
				Object.Destroy((Object)(object)component3);
			}
			_ringMaterial = new Material(Shader.Find("Sprites/Default"))
			{
				color = new Color(1f, 1f, 1f, 0.35f)
			};
			((Renderer)_nextCircleRing.GetComponent<MeshRenderer>()).material = _ringMaterial;
			_currentCircleRing = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)_currentCircleRing).name = "FordRoyale Map Current Circle";
			Collider component4 = _currentCircleRing.GetComponent<Collider>();
			if ((Object)(object)component4 != (Object)null)
			{
				Object.Destroy((Object)(object)component4);
			}
			_currentRingMaterial = new Material(Shader.Find("Sprites/Default"))
			{
				color = new Color(0.55f, 0.2f, 0.85f, 0.4f)
			};
			((Renderer)_currentCircleRing.GetComponent<MeshRenderer>()).material = _currentRingMaterial;
			_visible = true;
		}

		public static void HideMap()
		{
			_visible = false;
			GameObject[] array = (GameObject[])(object)new GameObject[5] { _cameraObject, _panel, _playerMarker, _nextCircleRing, _currentCircleRing };
			foreach (GameObject val in array)
			{
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
			}
			_cameraObject = null;
			_camera = null;
			_panel = null;
			_playerMarker = null;
			_nextCircleRing = null;
			_currentCircleRing = null;
			_ringMaterial = null;
			_currentRingMaterial = null;
			if ((Object)(object)_renderTexture != (Object)null)
			{
				_renderTexture.Release();
				Object.Destroy((Object)(object)_renderTexture);
				_renderTexture = null;
			}
		}

		public static void Update(Storm storm)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0049: 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_0054: 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_0064: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			if (_visible && storm != null && RigData.HasPlayer)
			{
				RigManager rigManager = RigData.Refs.RigManager;
				Vector3 position = rigManager.physicsRig.feet.transform.position;
				Transform head = ((Rig)rigManager.physicsRig).m_head;
				float num = 150f;
				Vector3 val = storm.Center + Vector3.up * num;
				_cameraObject.transform.position = val;
				_camera.orthographicSize = Mathf.Max(storm.CurrentRadius * 1.5f, 40f);
				_playerMarker.transform.position = new Vector3(position.x, val.y - 30f, position.z);
				float num2 = _camera.orthographicSize * 0.05f;
				_playerMarker.transform.localScale = Vector3.one * num2;
				_currentCircleRing.transform.position = new Vector3(storm.Center.x, val.y - 45f, storm.Center.z);
				_currentCircleRing.transform.localScale = new Vector3(storm.CurrentRadius * 2f, 0.25f, storm.CurrentRadius * 2f);
				if (storm.NextPhase.HasValue)
				{
					StormPhase value = storm.NextPhase.Value;
					_nextCircleRing.SetActive(true);
					_nextCircleRing.transform.position = new Vector3(value.Center.x, val.y - 40f, value.Center.z);
					_nextCircleRing.transform.localScale = new Vector3(value.Radius * 2f, 0.25f, value.Radius * 2f);
				}
				else
				{
					_nextCircleRing.SetActive(false);
				}
				if ((Object)(object)head != (Object)null)
				{
					Vector3 forward = head.forward;
					forward.y = 0f;
					((Vector3)(ref forward)).Normalize();
					Vector3 val2 = head.position + forward * 0.6f;
					_panel.transform.position = val2;
					_panel.transform.rotation = Quaternion.LookRotation(val2 - head.position, Vector3.up);
				}
			}
		}
	}
	public struct StormPhase
	{
		public Vector3 Center;

		public float Radius;
	}
	public class Storm
	{
		private readonly List<StormPhase> _phases = new List<StormPhase>();

		private float _elapsed;

		private float _tickTimer;

		private bool _inStormLastTick;

		private bool _wasShrinking;

		private float _previousSecondsUntilShrink = float.MaxValue;

		private GameObject _wallVisual;

		private Material _wallMaterial;

		private float _wallHeight = 200f;

		public bool Active { get; private set; }

		public bool InGracePeriod => _elapsed < 90f;

		public Vector3 Center { get; private set; } = FordRoyaleConfig.MapCenter;

		public float CurrentRadius { get; private set; } = 120f;

		public StormPhase? NextPhase { get; private set; }

		public static List<StormPhase> GeneratePhases(Vector3 start, float startRadius)
		{
			//IL_0010: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			List<StormPhase> list = new List<StormPhase>
			{
				new StormPhase
				{
					Center = start,
					Radius = startRadius
				}
			};
			Random random = new Random();
			float[] stormPhaseFractions = FordRoyaleConfig.StormPhaseFractions;
			foreach (float num in stormPhaseFractions)
			{
				StormPhase stormPhase = list[list.Count - 1];
				float num2 = startRadius * num;
				float num3 = Mathf.Max(stormPhase.Radius - num2, 0f);
				float num4 = (float)random.NextDouble() * num3 * 0.85f;
				float num5 = (float)(random.NextDouble() * 3.1415927410125732 * 2.0);
				Vector3 center = stormPhase.Center + new Vector3(Mathf.Cos(num5) * num4, 0f, Mathf.Sin(num5) * num4);
				list.Add(new StormPhase
				{
					Center = center,
					Radius = num2
				});
			}
			return list;
		}

		public static string SerializePhases(List<StormPhase> phases)
		{
			CultureInfo inv = CultureInfo.InvariantCulture;
			IEnumerable<string> values = phases.Select((StormPhase p) => $"{p.Center.x.ToString(inv)};{p.Center.y.ToString(inv)};{p.Center.z.ToString(inv)};{p.Radius.ToString(inv)}");
			return string.Join("|", values);
		}

		public static List<StormPhase> ParsePhases(string value)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			CultureInfo invariantCulture = CultureInfo.InvariantCulture;
			List<StormPhase> list = new List<StormPhase>();
			string[] array = value.Split('|');
			for (int i = 0; i < array.Length; i++)
			{
				string[] array2 = array[i].Split(';');
				if (array2.Length == 4 && float.TryParse(array2[0], NumberStyles.Float, invariantCulture, out var result) && float.TryParse(array2[1], NumberStyles.Float, invariantCulture, out var result2) && float.TryParse(array2[2], NumberStyles.Float, invariantCulture, out var result3) && float.TryParse(array2[3], NumberStyles.Float, invariantCulture, out var result4))
				{
					list.Add(new StormPhase
					{
						Center = new Vector3(result, result2, result3),
						Radius = result4
					});
				}
			}
			return list;
		}

		public void ApplyPhases(List<StormPhase> phases)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			_phases.Clear();
			_phases.AddRange(phases);
			if (_phases.Count > 0)
			{
				Center = _phases[0].Center;
				CurrentRadius = _phases[0].Radius;
			}
		}

		public void Start()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			_elapsed = 0f;
			_tickTimer = 0f;
			_inStormLastTick = false;
			_wasShrinking = false;
			_previousSecondsUntilShrink = float.MaxValue;
			Active = true;
			Bounds bounds = MapBounds.Compute(Center);
			_wallHeight = MapBounds.GetWallHeight(bounds);
			CreateWallVisual();
		}

		public void Stop()
		{
			Active = false;
			_phases.Clear();
			NextPhase = null;
			DestroyWallVisual();
		}

		public void Update()
		{
			if (!Active)
			{
				return;
			}
			_elapsed += TimeReferences.DeltaTime;
			UpdateTimeline();
			UpdateWallVisual();
			if (!InGracePeriod)
			{
				_tickTimer += TimeReferences.DeltaTime;
				if (_tickTimer >= 1f)
				{
					_tickTimer -= 1f;
					TickDamage();
				}
			}
		}

		private void UpdateTimeline()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Expected O, but got Unknown
			if (_phases.Count < 2)
			{
				return;
			}
			ComputeState(_elapsed, out var center, out var radius, out var next, out var secondsUntilShrink, out var shrinking);
			Center = center;
			CurrentRadius = radius;
			NextPhase = next;
			if (shrinking && !_wasShrinking)
			{
				StormAudio.PlayShrinkSound();
				Notifier.Send(new Notification
				{
					ShowPopup = true,
					Title = NotificationText.op_Implicit("Storm"),
					Message = NotificationText.op_Implicit("The storm is shrinking! Get to the next circle!"),
					PopupLength = 3f,
					Type = (NotificationType)1
				});
			}
			_wasShrinking = shrinking;
			if (!shrinking && next.HasValue)
			{
				int[] stormCountdownWarnings = FordRoyaleConfig.StormCountdownWarnings;
				foreach (int num in stormCountdownWarnings)
				{
					if (_previousSecondsUntilShrink > (float)num && secondsUntilShrink <= (float)num)
					{
						Notifier.Send(new Notification
						{
							ShowPopup = true,
							Title = NotificationText.op_Implicit("Storm"),
							Message = NotificationText.op_Implicit($"Storm Shrinking in {num} Seconds"),
							PopupLength = 2.5f,
							Type = (NotificationType)1
						});
					}
				}
				_previousSecondsUntilShrink = secondsUntilShrink;
			}
			else
			{
				_previousSecondsUntilShrink = float.MaxValue;
			}
		}

		private void ComputeState(float elapsed, out Vector3 center, out float radius, out StormPhase? next, out float secondsUntilShrink, out bool shrinking)
		{
			//IL_001d: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			float num = elapsed - 90f;
			if (num < 0f)
			{
				center = _phases[0].Center;
				radius = _phases[0].Radius;
				next = _phases[1];
				secondsUntilShrink = 0f - num;
				shrinking = false;
				return;
			}
			float num2 = 75f;
			int num3 = Mathf.FloorToInt(num / num2);
			float num4 = num - (float)num3 * num2;
			if (num3 >= _phases.Count - 1)
			{
				List<StormPhase> phases = _phases;
				center = phases[phases.Count - 1].Center;
				List<StormPhase> phases2 = _phases;
				radius = phases2[phases2.Count - 1].Radius;
				next = null;
				secondsUntilShrink = float.MaxValue;
				shrinking = false;
				return;
			}
			StormPhase stormPhase = _phases[num3];
			StormPhase value = _phases[num3 + 1];
			if (num4 < 30f)
			{
				float num5 = num4 / 30f;
				center = Vector3.Lerp(stormPhase.Center, value.Center, num5);
				radius = Mathf.Lerp(stormPhase.Radius, value.Radius, num5);
				next = value;
				secondsUntilShrink = float.MaxValue;
				shrinking = true;
			}
			else
			{
				bool flag = num3 + 2 <= _phases.Count - 1;
				center = value.Center;
				radius = value.Radius;
				next = (flag ? new StormPhase?(_phases[num3 + 2]) : ((StormPhase?)null));
				secondsUntilShrink = num2 - num4;
				shrinking = false;
			}
		}

		private void TickDamage()
		{
			//IL_0021: 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)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			if (!RigData.HasPlayer)
			{
				return;
			}
			Vector3 val = RigData.Refs.RigManager.physicsRig.feet.transform.position - Center;
			val.y = 0f;
			bool flag = ((Vector3)(ref val)).magnitude > CurrentRadius;
			if (flag)
			{
				float num = 0.25f;
				((Health)RigData.Refs.Health).TAKEDAMAGE(num);
				if (!_inStormLastTick)
				{
					Notifier.Send(new Notification
					{
						ShowPopup = true,
						Title = NotificationText.op_Implicit("Storm"),
						Message = NotificationText.op_Implicit("You're in the storm! Get back inside the circle!"),
						PopupLength = 2f,
						Type = (NotificationType)1
					});
				}
			}
			_inStormLastTick = flag;
		}

		private void CreateWallVisual()
		{
			//IL_004a: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			DestroyWallVisual();
			_wallVisual = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)_wallVisual).name = "FordRoyale Storm Wall";
			Collider component = _wallVisual.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			Shader val = Shader.Find("Sprites/Default");
			_wallMaterial = new Material(val)
			{
				color = new Color(0.55f, 0.2f, 0.85f, 0.3f)
			};
			MeshRenderer component2 = _wallVisual.GetComponent<MeshRenderer>();
			((Renderer)component2).material = _wallMaterial;
			((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)component2).receiveShadows = false;
		}

		private void UpdateWallVisual()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_wallVisual == (Object)null))
			{
				_wallVisual.transform.position = Center;
				_wallVisual.transform.localScale = new Vector3(CurrentRadius * 2f, _wallHeight / 2f, CurrentRadius * 2f);
			}
		}

		private void DestroyWallVisual()
		{
			if ((Object)(object)_wallVisual != (Object)null)
			{
				Object.Destroy((Object)(object)_wallVisual);
				_wallVisual = null;
			}
			if ((Object)(object)_wallMaterial != (Object)null)
			{
				Object.Destroy((Object)(object)_wallMaterial);
				_wallMaterial = null;
			}
		}
	}
	public static class StormAudio
	{
		private const string ResourceName = "FordRoyale.Resources.stormshrinksound.mp3";

		private const string FileName = "stormshrinksound.mp3";

		private static AudioClip _shrinkClip;

		private static GameObject _audioObject;

		public static void OnInitializeMelon()
		{
			try
			{
				string text = Path.Combine(MelonEnvironment.UserDataDirectory, "FordRoyale");
				Directory.CreateDirectory(text);
				string path = Path.Combine(text, "stormshrinksound.mp3");
				using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("FordRoyale.Resources.stormshrinksound.mp3");
				if (stream == null)
				{
					MelonLogger.Warning("FordRoyale: embedded storm sound not found!");
					return;
				}
				using (FileStream destination = File.Create(path))
				{
					stream.CopyTo(destination);
				}
				MelonCoroutines.Start(LoadClip(path));
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("FordRoyale: failed to extract storm sound: " + ex.Message);
			}
		}

		private static IEnumerator LoadClip(string path)
		{
			string text = "file:///" + path.Replace('\\', '/');
			UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)13);
			request.SendWebRequest();
			while (!request.isDone)
			{
				yield return null;
			}
			if ((int)request.result != 1)
			{
				MelonLogger.Warning("FordRoyale: failed to load storm sound: " + request.error);
				yield break;
			}
			_shrinkClip = DownloadHandlerAudioClip.GetContent(request);
			((Object)_shrinkClip).hideFlags = (HideFlags)32;
		}

		public static void PlayShrinkSound()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			if (!((Object)(object)_shrinkClip == (Object)null))
			{
				if ((Object)(object)_audioObject == (Object)null)
				{
					_audioObject = new GameObject("FordRoyale Storm Audio");
					Object.DontDestroyOnLoad((Object)(object)_audioObject);
					_audioObject.AddComponent<AudioSource>();
				}
				AudioSource component = _audioObject.GetComponent<AudioSource>();
				component.spatialBlend = 0f;
				component.volume = 0.8f;
				component.PlayOneShot(_shrinkClip);
			}
		}
	}
	public static class VanillaAmmoCrates
	{
		private static string[] _cached;

		public static string[] GetBarcodes()
		{
			if (_cached != null)
			{
				return _cached;
			}
			List<string> list = new List<string>();
			try
			{
				AssetWarehouse instance = AssetWarehouse.Instance;
				Enumerator<SpawnableCrate> enumerator = instance.GetCrates<SpawnableCrate>((ICrateFilter<SpawnableCrate>)null).GetEnumerator();
				while (enumerator.MoveNext())
				{
					SpawnableCrate current = enumerator.Current;
					Pallet pallet = ((Crate)current).Pallet;
					if (!((Object)(object)pallet == (Object)null) && !instance.palletManifests.ContainsKey(((Scannable)pallet).Barcode))
					{
						string text = ((((Scannable)current).Title != null) ? ((Scannable)current).Title.ToLowerInvariant() : "");
						if (text.Contains("ammo") && !text.Contains("mag"))
						{
							list.Add(((Scannable)current).Barcode.ID);
						}
					}
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("FordRoyale: failed to search for ammo crates: " + ex.Message);
			}
			if (list.Count == 0)
			{
				MelonLogger.Warning("FordRoyale: no vanilla ammo crates found, skipping ammo box spawns");
			}
			_cached = list.ToArray();
			return _cached;
		}
	}
	public static class WristHealthDisplay
	{
		private static GameObject _root;

		private static TextMesh _text;

		public static void Show()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			Hide();
			if (RigData.HasPlayer)
			{
				Transform handLf = ((Rig)RigData.Refs.RigManager.physicsRig).m_handLf;
				if (!((Object)(object)handLf == (Object)null))
				{
					_root = new GameObject("FordRoyale Wrist Health");
					_root.transform.parent = handLf;
					_root.transform.localPosition = new Vector3(0f, 0.05f, -0.08f);
					_root.transform.localRotation = Quaternion.Euler(0f, 90f, 180f);
					_root.transform.localScale = Vector3.one * 0.004f;
					_text = _root.AddComponent<TextMesh>();
					_text.text = "HP";
					_text.fontSize = 64;
					_text.characterSize = 1f;
					_text.anchor = (TextAnchor)4;
					_text.alignment = (TextAlignment)1;
					_text.color = Color.green;
				}
			}
		}

		public static void Hide()
		{
			if ((Object)(object)_root != (Object)null)
			{
				Object.Destroy((Object)(object)_root);
				_root = null;
				_text = null;
			}
		}

		public static void Update()
		{
			//IL_00a7: 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_00be: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_text == (Object)null) && RigData.HasPlayer)
			{
				Player_Health health = RigData.Refs.Health;
				float num = Mathf.Max(((Health)health).curr_Health, 0f);
				float num2 = Mathf.Max(((Health)health).max_Health, 0.01f);
				float num3 = Mathf.Clamp01(num / num2);
				_text.text = $"{Mathf.RoundToInt(num3 * 100f)} HP";
				_text.color = ((num3 > 0.5f) ? Color.Lerp(Color.yellow, Color.green, (num3 - 0.5f) * 2f) : Color.Lerp(Color.red, Color.yellow, num3 * 2f));
			}
		}
	}
}