Decompiled source of Tokyo Race Course v1.0.5

BepInEx/plugins/Omniscye-Tokyo_Race_Course/EmpressUmuRace.dll

Decompiled 5 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using REPOLib.Modules;
using REPOLib.Objects.Sdk;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Empress")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4")]
[assembly: AssemblyProduct("EmpressUmuRace")]
[assembly: AssemblyTitle("EmpressUmuRace")]
[assembly: AssemblyVersion("1.0.4.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 Empress.REPO.UmuRace
{
	internal static class EmpressUmuAccess
	{
		private static readonly FieldInfo EnvironmentSetupDoneField = AccessTools.Field(typeof(EnvironmentDirector), "SetupDone");

		private static readonly FieldInfo EnvironmentMainCameraField = AccessTools.Field(typeof(EnvironmentDirector), "MainCamera");

		private static readonly FieldInfo EnvironmentAmbientColorField = AccessTools.Field(typeof(EnvironmentDirector), "AmbientColor");

		private static readonly FieldInfo EnvironmentAmbientColorNewField = AccessTools.Field(typeof(EnvironmentDirector), "AmbientColorNew");

		private static readonly FieldInfo EnvironmentAmbientColorPreviousField = AccessTools.Field(typeof(EnvironmentDirector), "AmbientColorPrevious");

		private static readonly FieldInfo EnvironmentAmbientColorAdaptationField = AccessTools.Field(typeof(EnvironmentDirector), "AmbientColorAdaptation");

		private static readonly FieldInfo EnvironmentAmbientColorAdaptationNewField = AccessTools.Field(typeof(EnvironmentDirector), "AmbientColorAdaptationNew");

		private static readonly FieldInfo EnvironmentAmbientColorAdaptationPreviousField = AccessTools.Field(typeof(EnvironmentDirector), "AmbientColorAdaptationPrevious");

		private static readonly FieldInfo EnvironmentDarkAdaptationLerpField = AccessTools.Field(typeof(EnvironmentDirector), "DarkAdaptationLerp");

		private static readonly FieldInfo EnvironmentFogColorField = AccessTools.Field(typeof(EnvironmentDirector), "FogColor");

		private static readonly FieldInfo EnvironmentFogColorNewField = AccessTools.Field(typeof(EnvironmentDirector), "FogColorNew");

		private static readonly FieldInfo EnvironmentFogColorPreviousField = AccessTools.Field(typeof(EnvironmentDirector), "FogColorPrevious");

		private static readonly FieldInfo EnvironmentFogStartDistanceField = AccessTools.Field(typeof(EnvironmentDirector), "FogStartDistance");

		private static readonly FieldInfo EnvironmentFogStartDistanceNewField = AccessTools.Field(typeof(EnvironmentDirector), "FogStartDistanceNew");

		private static readonly FieldInfo EnvironmentFogStartDistancePreviousField = AccessTools.Field(typeof(EnvironmentDirector), "FogStartDistancePrevious");

		private static readonly FieldInfo EnvironmentFogEndDistanceField = AccessTools.Field(typeof(EnvironmentDirector), "FogEndDistance");

		private static readonly FieldInfo EnvironmentFogEndDistanceNewField = AccessTools.Field(typeof(EnvironmentDirector), "FogEndDistanceNew");

		private static readonly FieldInfo EnvironmentFogEndDistancePreviousField = AccessTools.Field(typeof(EnvironmentDirector), "FogEndDistancePrevious");

		private static readonly FieldInfo GeneratorAllPlayersReadyField = AccessTools.Field(typeof(LevelGenerator), "AllPlayersReady");

		private static readonly FieldInfo GeneratorEnemyReadyField = AccessTools.Field(typeof(LevelGenerator), "EnemyReady");

		private static readonly FieldInfo GeneratorModulesSpawnedField = AccessTools.Field(typeof(LevelGenerator), "ModulesSpawned");

		private static readonly FieldInfo GeneratorPlayerSpawnedField = AccessTools.Field(typeof(LevelGenerator), "playerSpawned");

		private static readonly FieldInfo RunLevelPreviousField = AccessTools.Field(typeof(RunManager), "levelPrevious");

		private static readonly FieldInfo ModuleSetupDoneField = AccessTools.Field(typeof(Module), "SetupDone");

		private static readonly FieldInfo ModuleStartRoomField = AccessTools.Field(typeof(Module), "StartRoom");

		private static readonly FieldInfo ModuleGridXField = AccessTools.Field(typeof(Module), "GridX");

		private static readonly FieldInfo ModuleGridYField = AccessTools.Field(typeof(Module), "GridY");

		private static readonly FieldInfo ModuleFirstField = AccessTools.Field(typeof(Module), "First");

		private static readonly FieldInfo LevelPointInStartRoomField = AccessTools.Field(typeof(LevelPoint), "inStartRoom");

		private static readonly FieldRef<PlayerAvatar, bool> AvatarIsMovingRef = AccessTools.FieldRefAccess<PlayerAvatar, bool>("isMoving");

		private static readonly FieldRef<PlayerAvatar, bool> AvatarIsSprintingRef = AccessTools.FieldRefAccess<PlayerAvatar, bool>("isSprinting");

		private static readonly FieldRef<PlayerAvatar, bool> AvatarIsCrouchingRef = AccessTools.FieldRefAccess<PlayerAvatar, bool>("isCrouching");

		private static readonly FieldRef<PlayerAvatar, bool> AvatarIsCrawlingRef = AccessTools.FieldRefAccess<PlayerAvatar, bool>("isCrawling");

		private static readonly FieldRef<PlayerAvatar, bool> AvatarIsSlidingRef = AccessTools.FieldRefAccess<PlayerAvatar, bool>("isSliding");

		private static readonly FieldRef<PlayerAvatar, bool> AvatarIsTumblingRef = AccessTools.FieldRefAccess<PlayerAvatar, bool>("isTumbling");

		private static readonly FieldRef<PlayerController, bool> ControllerMovingRef = AccessTools.FieldRefAccess<PlayerController, bool>("moving");

		private static readonly FieldRef<PlayerController, bool> ControllerSprintingRef = AccessTools.FieldRefAccess<PlayerController, bool>("sprinting");

		private static readonly FieldRef<PlayerController, bool> ControllerCrouchingRef = AccessTools.FieldRefAccess<PlayerController, bool>("Crouching");

		private static readonly FieldRef<PlayerController, bool> ControllerCrawlingRef = AccessTools.FieldRefAccess<PlayerController, bool>("Crawling");

		private static readonly FieldRef<PlayerController, bool> ControllerSlidingRef = AccessTools.FieldRefAccess<PlayerController, bool>("Sliding");

		private static readonly FieldInfo AvatarNameField = AccessTools.Field(typeof(PlayerAvatar), "playerName");

		private static readonly FieldInfo AvatarHealthField = AccessTools.Field(typeof(PlayerAvatar), "playerHealth");

		private static readonly FieldInfo AvatarRigidbodyField = AccessTools.Field(typeof(PlayerAvatar), "rb");

		private static readonly FieldInfo ControllerRigidbodyField = AccessTools.Field(typeof(PlayerController), "rb");

		private static readonly FieldInfo ControllerVelocityField = AccessTools.Field(typeof(PlayerController), "Velocity");

		private static readonly FieldInfo ControllerVelocityRelativeField = AccessTools.Field(typeof(PlayerController), "VelocityRelative");

		private static readonly FieldInfo ControllerVelocityRelativeNewField = AccessTools.Field(typeof(PlayerController), "VelocityRelativeNew");

		private static readonly FieldInfo VisualPositionField = AccessTools.Field(typeof(PlayerAvatarVisuals), "visualPosition");

		private static readonly FieldInfo VisualPlayerAvatarField = AccessTools.Field(typeof(PlayerAvatarVisuals), "playerAvatar");

		private static readonly FieldInfo VisualMeshParentField = AccessTools.Field(typeof(PlayerAvatarVisuals), "meshParent");

		private static readonly FieldInfo VisualAnimatorField = AccessTools.Field(typeof(PlayerAvatarVisuals), "animator");

		private static readonly FieldInfo VisualLocalVisibilityField = AccessTools.Field(typeof(PlayerAvatarVisuals), "localVisibility");

		private static readonly FieldInfo VisualShowSelfOverrideTimerField = AccessTools.Field(typeof(PlayerAvatarVisuals), "showSelfOverrideTimer");

		private static readonly MethodInfo ModuleChecklistMethod = AccessTools.Method(typeof(Module), "SetAllChecklist", (Type[])null, (Type[])null);

		private static readonly MethodInfo GeneratorDoneMethod = AccessTools.Method(typeof(LevelGenerator), "GenerateDone", new Type[1] { typeof(PhotonMessageInfo) }, (Type[])null);

		private static readonly MethodInfo InputDisableMethod = AccessTools.Method(typeof(PlayerController), "InputDisable", new Type[1] { typeof(float) }, (Type[])null);

		private static readonly MethodInfo VisualApplyVisibilityBodyMethod = AccessTools.Method(typeof(PlayerAvatarVisuals), "ApplyLocalVisibilityBody", (Type[])null, (Type[])null);

		private static readonly MethodInfo SteamIdMethod = AccessTools.Method(typeof(SemiFunc), "PlayerGetSteamID", new Type[1] { typeof(PlayerAvatar) }, (Type[])null);

		private static readonly MethodInfo HurtMethod = AccessTools.Method(typeof(PlayerHealth), "Hurt", new Type[4]
		{
			typeof(int),
			typeof(bool),
			typeof(int),
			typeof(bool)
		}, (Type[])null);

		private static readonly MethodInfo ExplosionMethod = AccessTools.Method(typeof(ParticleScriptExplosion), "Spawn", new Type[8]
		{
			typeof(Vector3),
			typeof(float),
			typeof(int),
			typeof(int),
			typeof(float),
			typeof(bool),
			typeof(bool),
			typeof(float)
		}, (Type[])null);

		private static readonly MethodInfo SyncDictionariesMethod = AccessTools.Method(typeof(PunManager), "SyncAllDictionaries", (Type[])null, (Type[])null);

		private static readonly MethodInfo[] HideUiMethods = new MethodInfo[8]
		{
			AccessTools.Method(typeof(SemiFunc), "UIHideAim", (Type[])null, (Type[])null),
			AccessTools.Method(typeof(SemiFunc), "UIHideHealth", (Type[])null, (Type[])null),
			AccessTools.Method(typeof(SemiFunc), "UIHideEnergy", (Type[])null, (Type[])null),
			AccessTools.Method(typeof(SemiFunc), "UIHideInventory", (Type[])null, (Type[])null),
			AccessTools.Method(typeof(SemiFunc), "UIHideHaul", (Type[])null, (Type[])null),
			AccessTools.Method(typeof(SemiFunc), "UIHideGoal", (Type[])null, (Type[])null),
			AccessTools.Method(typeof(SemiFunc), "UIHideCurrency", (Type[])null, (Type[])null),
			AccessTools.Method(typeof(SemiFunc), "UIHideShopCost", (Type[])null, (Type[])null)
		};

		private static readonly FieldInfo[] UiInstanceFields = new FieldInfo[8]
		{
			AccessTools.Field(typeof(Aim), "instance"),
			AccessTools.Field(typeof(HealthUI), "instance"),
			AccessTools.Field(typeof(EnergyUI), "instance"),
			AccessTools.Field(typeof(InventoryUI), "instance"),
			AccessTools.Field(typeof(HaulUI), "instance"),
			AccessTools.Field(typeof(GoalUI), "instance"),
			AccessTools.Field(typeof(CurrencyUI), "instance"),
			AccessTools.Field(typeof(ShopCostUI), "instance")
		};

		private static readonly MethodInfo[] UpgradeMethods = new MethodInfo[10]
		{
			AccessTools.Method(typeof(PunManager), "UpgradePlayerHealth", new Type[2]
			{
				typeof(string),
				typeof(int)
			}, (Type[])null),
			AccessTools.Method(typeof(PunManager), "UpgradePlayerEnergy", new Type[2]
			{
				typeof(string),
				typeof(int)
			}, (Type[])null),
			AccessTools.Method(typeof(PunManager), "UpgradePlayerSprintSpeed", new Type[2]
			{
				typeof(string),
				typeof(int)
			}, (Type[])null),
			AccessTools.Method(typeof(PunManager), "UpgradePlayerExtraJump", new Type[2]
			{
				typeof(string),
				typeof(int)
			}, (Type[])null),
			AccessTools.Method(typeof(PunManager), "UpgradePlayerGrabStrength", new Type[2]
			{
				typeof(string),
				typeof(int)
			}, (Type[])null),
			AccessTools.Method(typeof(PunManager), "UpgradePlayerThrowStrength", new Type[2]
			{
				typeof(string),
				typeof(int)
			}, (Type[])null),
			AccessTools.Method(typeof(PunManager), "UpgradePlayerGrabRange", new Type[2]
			{
				typeof(string),
				typeof(int)
			}, (Type[])null),
			AccessTools.Method(typeof(PunManager), "UpgradePlayerTumbleLaunch", new Type[2]
			{
				typeof(string),
				typeof(int)
			}, (Type[])null),
			AccessTools.Method(typeof(PunManager), "UpgradePlayerTumbleClimb", new Type[2]
			{
				typeof(string),
				typeof(int)
			}, (Type[])null),
			AccessTools.Method(typeof(PunManager), "UpgradePlayerTumbleWings", new Type[2]
			{
				typeof(string),
				typeof(int)
			}, (Type[])null)
		};

		private static readonly string[] UpgradeNames = new string[10] { "Health", "Energy", "Sprint Speed", "Extra Jump", "Grab Strength", "Throw Strength", "Grab Range", "Tumble Launch", "Tumble Climb", "Tumble Wings" };

		internal static bool GetAllPlayersReady(LevelGenerator generator)
		{
			return GetBool(GeneratorAllPlayersReadyField, generator);
		}

		internal static int GetPlayerSpawnedCount(LevelGenerator generator)
		{
			return GetInt(GeneratorPlayerSpawnedField, generator);
		}

		internal static void SetAllPlayersReady(LevelGenerator generator, bool value)
		{
			Set(GeneratorAllPlayersReadyField, generator, value);
		}

		internal static void SetEnemyReady(LevelGenerator generator, bool value)
		{
			Set(GeneratorEnemyReadyField, generator, value);
		}

		internal static void SetModulesSpawned(LevelGenerator generator, int value)
		{
			Set(GeneratorModulesSpawnedField, generator, value);
		}

		internal static void SetPlayerSpawnedCount(LevelGenerator generator, int value)
		{
			Set(GeneratorPlayerSpawnedField, generator, value);
		}

		internal static void SetLevelPrevious(RunManager manager, Level level)
		{
			Set(RunLevelPreviousField, manager, level);
		}

		internal static void MarkLevelPointInStartRoom(LevelPoint point, bool value)
		{
			Set(LevelPointInStartRoomField, point, value);
		}

		internal static void ConfigureStartRoomModule(Module module)
		{
			ModuleChecklistMethod?.Invoke(module, null);
			Set(ModuleSetupDoneField, module, true);
			Set(ModuleStartRoomField, module, true);
			Set(ModuleFirstField, module, true);
			Set(ModuleGridXField, module, 0);
			Set(ModuleGridYField, module, 0);
		}

		internal static void GenerateDone(LevelGenerator generator)
		{
			//IL_0015: 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)
			GeneratorDoneMethod?.Invoke(generator, new object[1] { (object)default(PhotonMessageInfo) });
		}

		internal static void ConfigureEnvironment(EnvironmentDirector director, Color fog, Color ambient, float fogStart, float fogEnd)
		{
			//IL_0006: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			Set(EnvironmentFogColorField, director, fog);
			Set(EnvironmentFogColorNewField, director, fog);
			Set(EnvironmentFogColorPreviousField, director, fog);
			Set(EnvironmentFogStartDistanceField, director, fogStart);
			Set(EnvironmentFogStartDistanceNewField, director, fogStart);
			Set(EnvironmentFogStartDistancePreviousField, director, fogStart);
			Set(EnvironmentFogEndDistanceField, director, fogEnd);
			Set(EnvironmentFogEndDistanceNewField, director, fogEnd);
			Set(EnvironmentFogEndDistancePreviousField, director, fogEnd);
			Set(EnvironmentAmbientColorField, director, ambient);
			Set(EnvironmentAmbientColorNewField, director, ambient);
			Set(EnvironmentAmbientColorPreviousField, director, ambient);
			Set(EnvironmentAmbientColorAdaptationField, director, ambient);
			Set(EnvironmentAmbientColorAdaptationNewField, director, ambient);
			Set(EnvironmentAmbientColorAdaptationPreviousField, director, ambient);
			Set(EnvironmentDarkAdaptationLerpField, director, 0f);
			Set(EnvironmentSetupDoneField, director, true);
			if ((Object)(object)Get<Camera>(EnvironmentMainCameraField, director) == (Object)null)
			{
				Set(EnvironmentMainCameraField, director, Camera.main);
			}
		}

		internal static List<PlayerAvatar> Players()
		{
			if (!((Object)(object)GameDirector.instance != (Object)null) || GameDirector.instance.PlayerList == null)
			{
				return new List<PlayerAvatar>();
			}
			return GameDirector.instance.PlayerList;
		}

		internal static PlayerAvatar LocalAvatar()
		{
			if (!((Object)(object)PlayerController.instance != (Object)null))
			{
				return null;
			}
			return PlayerController.instance.playerAvatarScript;
		}

		internal static PlayerAvatar AvatarByViewId(int viewId)
		{
			List<PlayerAvatar> list = Players();
			for (int i = 0; i < list.Count; i++)
			{
				PlayerAvatar val = list[i];
				if ((Object)(object)val != (Object)null && (Object)(object)val.photonView != (Object)null && val.photonView.ViewID == viewId)
				{
					return val;
				}
			}
			return null;
		}

		internal static string PlayerName(PlayerAvatar avatar)
		{
			string text = (((Object)(object)avatar != (Object)null) ? (AvatarNameField?.GetValue(avatar) as string) : null);
			if (!string.IsNullOrWhiteSpace(text))
			{
				return text;
			}
			return "Runner";
		}

		internal static GameObject VisualMeshParent(PlayerAvatarVisuals visuals)
		{
			return Get<GameObject>(VisualMeshParentField, visuals);
		}

		internal static PlayerAvatar VisualPlayerAvatar(PlayerAvatarVisuals visuals)
		{
			return Get<PlayerAvatar>(VisualPlayerAvatarField, visuals);
		}

		internal static Animator VisualAnimator(PlayerAvatarVisuals visuals)
		{
			return Get<Animator>(VisualAnimatorField, visuals);
		}

		internal static bool IsLocalVisuals(PlayerAvatarVisuals visuals)
		{
			PlayerAvatar val = LocalAvatar();
			if ((Object)(object)visuals != (Object)null && (Object)(object)val != (Object)null)
			{
				return (Object)(object)visuals == (Object)(object)val.playerAvatarVisuals;
			}
			return false;
		}

		internal static ShadowCastingMode VisualVisibility(PlayerAvatarVisuals visuals)
		{
			//IL_0028: 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)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			object obj = ((!((Object)(object)visuals != (Object)null)) ? null : VisualLocalVisibilityField?.GetValue(visuals));
			if (obj is ShadowCastingMode)
			{
				return (ShadowCastingMode)obj;
			}
			return (ShadowCastingMode)3;
		}

		internal static void SetVisualVisibility(PlayerAvatarVisuals visuals, ShadowCastingMode mode, bool apply)
		{
			//IL_0010: 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: Invalid comparison between Unknown and I4
			if (!((Object)(object)visuals == (Object)null))
			{
				Set(VisualLocalVisibilityField, visuals, mode);
				if ((int)mode == 1)
				{
					Set(VisualShowSelfOverrideTimerField, visuals, 0.35f);
				}
				else
				{
					Set(VisualShowSelfOverrideTimerField, visuals, 0f);
				}
				if (apply)
				{
					VisualApplyVisibilityBodyMethod?.Invoke(visuals, null);
				}
			}
		}

		internal static void HideVanillaHud()
		{
			for (int i = 0; i < HideUiMethods.Length; i++)
			{
				if (!(HideUiMethods[i] == null))
				{
					FieldInfo fieldInfo = UiInstanceFields[i];
					if (fieldInfo == null || fieldInfo.GetValue(null) != null)
					{
						HideUiMethods[i].Invoke(null, null);
					}
				}
			}
		}

		internal static void LockControls()
		{
			PlayerController instance = PlayerController.instance;
			if (!((Object)(object)instance == (Object)null))
			{
				InputDisableMethod?.Invoke(instance, new object[1] { 0.25f });
			}
		}

		internal static void MoveLocal(Vector3 position, Quaternion rotation, Vector3 velocity)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0078: 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_009a: 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_0042: 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_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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			PlayerController instance = PlayerController.instance;
			PlayerAvatar val = LocalAvatar();
			if (!((Object)(object)instance == (Object)null) && !((Object)(object)val == (Object)null))
			{
				((Component)instance).transform.SetPositionAndRotation(position, rotation);
				Rigidbody val2 = Get<Rigidbody>(ControllerRigidbodyField, instance);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.position = position;
					val2.rotation = rotation;
					val2.velocity = velocity;
					val2.angularVelocity = Vector3.zero;
				}
				Set(ControllerVelocityField, instance, velocity);
				Set(ControllerVelocityRelativeField, instance, velocity);
				Set(ControllerVelocityRelativeNewField, instance, velocity);
				((Component)val).transform.SetPositionAndRotation(position, rotation);
				if ((Object)(object)val.playerTransform != (Object)null)
				{
					val.playerTransform.SetPositionAndRotation(position, rotation);
				}
				Rigidbody val3 = Get<Rigidbody>(AvatarRigidbodyField, val);
				if ((Object)(object)val3 != (Object)null)
				{
					val3.position = position;
					val3.rotation = rotation;
					val3.velocity = velocity;
					val3.angularVelocity = Vector3.zero;
				}
				if ((Object)(object)val.playerAvatarVisuals != (Object)null)
				{
					((Component)val.playerAvatarVisuals).transform.position = position;
					Set(VisualPositionField, val.playerAvatarVisuals, position);
				}
			}
		}

		internal static void SetRunFlags(PlayerAvatar avatar, bool running)
		{
			if (!((Object)(object)avatar == (Object)null))
			{
				AvatarIsCrouchingRef.Invoke(avatar) = false;
				AvatarIsCrawlingRef.Invoke(avatar) = false;
				AvatarIsSlidingRef.Invoke(avatar) = false;
				AvatarIsTumblingRef.Invoke(avatar) = false;
				AvatarIsSprintingRef.Invoke(avatar) = running;
				AvatarIsMovingRef.Invoke(avatar) = running;
				PlayerController instance = PlayerController.instance;
				if ((Object)(object)instance != (Object)null && (Object)(object)avatar == (Object)(object)LocalAvatar())
				{
					ControllerCrouchingRef.Invoke(instance) = false;
					ControllerCrawlingRef.Invoke(instance) = false;
					ControllerSlidingRef.Invoke(instance) = false;
					ControllerMovingRef.Invoke(instance) = running;
					ControllerSprintingRef.Invoke(instance) = running;
				}
			}
		}

		internal static void ForceAnimatorRun(PlayerAvatar avatar, bool running, float intensity)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Invalid comparison between Unknown and I4
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Invalid comparison between Unknown and I4
			if ((Object)(object)avatar == (Object)null)
			{
				return;
			}
			PlayerAvatarVisuals playerAvatarVisuals = avatar.playerAvatarVisuals;
			Animator val = (((Object)(object)playerAvatarVisuals != (Object)null) ? Get<Animator>(VisualAnimatorField, playerAvatarVisuals) : null);
			if ((Object)(object)val == (Object)null || (Object)(object)val.runtimeAnimatorController == (Object)null)
			{
				return;
			}
			((Behaviour)val).enabled = true;
			val.cullingMode = (AnimatorCullingMode)0;
			AnimatorControllerParameter[] parameters = val.parameters;
			foreach (AnimatorControllerParameter val2 in parameters)
			{
				string text = val2.name.ToLowerInvariant();
				if ((int)val2.type == 1)
				{
					if (text.Contains("horizontal") || text.Contains("strafe"))
					{
						val.SetFloat(val2.nameHash, 0f);
					}
					else if (text.Contains("vertical") || text.Contains("forward") || text.Contains("speed") || text.Contains("move") || text.Contains("velocity") || text.Contains("run") || text.Contains("walk") || text.Contains("locomotion") || text.Contains("blend"))
					{
						val.SetFloat(val2.nameHash, running ? 1f : 0f);
					}
				}
				else if ((int)val2.type == 4)
				{
					if (text.Contains("crouch") || text.Contains("crawl") || text.Contains("slid") || text.Contains("jump") || text.Contains("fall") || text.Contains("tumbl") || text.Contains("turn") || text.Contains("grab") || text.Contains("sit"))
					{
						val.SetBool(val2.nameHash, false);
					}
					else if (text.Contains("ground"))
					{
						val.SetBool(val2.nameHash, true);
					}
					else if (text.Contains("sprint") || text.Contains("moving") || text.Contains("move") || text.Contains("walk") || text.Contains("run"))
					{
						val.SetBool(val2.nameHash, running);
					}
				}
			}
			val.speed = (running ? Mathf.Clamp(intensity, 0.9f, 1.9f) : 1f);
		}

		internal static void KeepAnimatorAwake(PlayerAvatar avatar)
		{
			PlayerAvatarVisuals val = (((Object)(object)avatar != (Object)null) ? avatar.playerAvatarVisuals : null);
			Animator val2 = (((Object)(object)val != (Object)null) ? Get<Animator>(VisualAnimatorField, val) : null);
			if ((Object)(object)val2 != (Object)null)
			{
				((Behaviour)val2).enabled = true;
				val2.cullingMode = (AnimatorCullingMode)0;
			}
		}

		internal static string ApplyUpgrade(PlayerAvatar winner, int index)
		{
			if ((Object)(object)winner == (Object)null || (Object)(object)PunManager.instance == (Object)null)
			{
				return "Mystery Upgrade";
			}
			string text = SteamIdMethod?.Invoke(null, new object[1] { winner }) as string;
			if (string.IsNullOrEmpty(text))
			{
				return "Mystery Upgrade";
			}
			int num = Mathf.Abs(index) % UpgradeMethods.Length;
			UpgradeMethods[num]?.Invoke(PunManager.instance, new object[2] { text, 1 });
			SyncDictionariesMethod?.Invoke(PunManager.instance, null);
			return UpgradeNames[num];
		}

		internal static string UpgradeName(int index)
		{
			return UpgradeNames[Mathf.Abs(index) % UpgradeNames.Length];
		}

		internal static void KillLocalPlayer()
		{
			PlayerAvatar val = LocalAvatar();
			PlayerHealth val2 = (PlayerHealth)(((Object)(object)val != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
			if ((Object)(object)val2 != (Object)null)
			{
				HurtMethod?.Invoke(val2, new object[4] { 9999, false, -1, false });
			}
		}

		internal static bool SpawnGameExplosion(Vector3 position)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			ParticleScriptExplosion val = Object.FindObjectOfType<ParticleScriptExplosion>(true);
			if ((Object)(object)val == (Object)null || ExplosionMethod == null)
			{
				return false;
			}
			ExplosionMethod.Invoke(val, new object[8] { position, 6f, 0, 0, 1f, true, false, 1.7f });
			return true;
		}

		private static T Get<T>(FieldInfo field, object instance) where T : class
		{
			if (!(field != null) || instance == null)
			{
				return null;
			}
			return field.GetValue(instance) as T;
		}

		private static bool GetBool(FieldInfo field, object instance)
		{
			object obj = ((field != null && instance != null) ? field.GetValue(instance) : null);
			bool flag = default(bool);
			int num;
			if (obj is bool)
			{
				flag = (bool)obj;
				num = 1;
			}
			else
			{
				num = 0;
			}
			return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
		}

		private static int GetInt(FieldInfo field, object instance)
		{
			object obj = ((field != null && instance != null) ? field.GetValue(instance) : null);
			if (obj is int)
			{
				return (int)obj;
			}
			return 0;
		}

		private static void Set(FieldInfo field, object instance, object value)
		{
			if (field != null && instance != null)
			{
				field.SetValue(instance, value);
			}
		}
	}
	internal static class EmpressUmuAssets
	{
		private static readonly List<AssetBundle> Bundles = new List<AssetBundle>();

		private static readonly List<GameObject> RacePrefabs = new List<GameObject>();

		private static readonly Dictionary<string, AudioClip> Clips = new Dictionary<string, AudioClip>(StringComparer.OrdinalIgnoreCase);

		private static readonly string[] AuthenticAudio = new string[4] { "call_to_post", "gate_open", "race_music", "crowd_cheer" };

		private static bool _loaded;

		private static bool _audioLoaded;

		internal static Texture2D TurfTexture { get; private set; }

		internal static Texture2D BaseTexture { get; private set; }

		internal static Texture2D TurfDetailTexture { get; private set; }

		internal static IReadOnlyList<GameObject> Prefabs => RacePrefabs;

		internal static AudioClip Clip(string name)
		{
			Clips.TryGetValue(name, out var value);
			return value;
		}

		internal static IEnumerator LoadAudio()
		{
			if (_audioLoaded)
			{
				yield break;
			}
			_audioLoaded = true;
			string directory = Path.Combine(EmpressUmuRacePlugin.PluginDirectory ?? string.Empty, "audio");
			for (int i = 0; i < AuthenticAudio.Length; i++)
			{
				string name = AuthenticAudio[i];
				string text = Path.Combine(directory, name + ".ogg");
				if (!File.Exists(text))
				{
					ManualLogSource log = EmpressUmuRacePlugin.Log;
					if (log != null)
					{
						log.LogError((object)("Authentic Uma audio is missing: " + name));
					}
					continue;
				}
				string text2 = "file://" + text;
				UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(text2, (AudioType)14);
				try
				{
					yield return request.SendWebRequest();
					if ((int)request.result == 1)
					{
						AudioClip content = DownloadHandlerAudioClip.GetContent(request);
						if ((Object)(object)content != (Object)null)
						{
							((Object)content).name = name;
							Clips[((Object)content).name] = content;
						}
					}
					else
					{
						ManualLogSource log2 = EmpressUmuRacePlugin.Log;
						if (log2 != null)
						{
							log2.LogError((object)("Authentic Uma audio failed to load: " + name + " - " + request.error));
						}
					}
				}
				finally
				{
					((IDisposable)request)?.Dispose();
				}
			}
			ManualLogSource log3 = EmpressUmuRacePlugin.Log;
			if (log3 != null)
			{
				log3.LogInfo((object)("Empress UMU authentic audio loaded: " + Clips.Count + "/" + AuthenticAudio.Length + " clips."));
			}
		}

		internal static void Load()
		{
			if (_loaded)
			{
				return;
			}
			_loaded = true;
			string path = Path.Combine(EmpressUmuRacePlugin.PluginDirectory ?? string.Empty, "AssetBundles", "uma");
			if (!Directory.Exists(path))
			{
				return;
			}
			string[] files = Directory.GetFiles(path);
			Array.Sort(files, (IComparer<string>?)StringComparer.OrdinalIgnoreCase);
			for (int i = 0; i < files.Length; i++)
			{
				AssetBundle val = AssetBundle.LoadFromFile(files[i]);
				if ((Object)(object)val != (Object)null)
				{
					Bundles.Add(val);
				}
			}
			for (int j = 0; j < Bundles.Count; j++)
			{
				string[] allAssetNames = Bundles[j].GetAllAssetNames();
				for (int k = 0; k < allAssetNames.Length; k++)
				{
					string text = allAssetNames[k].ToLowerInvariant();
					if (text.Contains("tex_env_race10005_0000_412_turf00_sub"))
					{
						TurfDetailTexture = Bundles[j].LoadAsset<Texture2D>(allAssetNames[k]);
					}
					else if (text.Contains("tex_env_race10005_0000_412_turf00"))
					{
						TurfTexture = Bundles[j].LoadAsset<Texture2D>(allAssetNames[k]);
					}
					else if (text.Contains("tex_env_race10005_0000_412_base00"))
					{
						BaseTexture = Bundles[j].LoadAsset<Texture2D>(allAssetNames[k]);
					}
					if (text.Contains("pfb_env_race10005_guest000_000") || text.Contains("pfb_env_race10005_prop000_000") || text.Contains("pfb_env_race10005_prop000_001") || text.Contains("pfb_env_race10005_tree001_100"))
					{
						GameObject val2 = Bundles[j].LoadAsset<GameObject>(allAssetNames[k]);
						if ((Object)(object)val2 != (Object)null && !RacePrefabs.Contains(val2))
						{
							RacePrefabs.Add(val2);
						}
					}
				}
			}
			ManualLogSource log = EmpressUmuRacePlugin.Log;
			if (log != null)
			{
				log.LogInfo((object)("Empress UMU assets loaded: " + Bundles.Count + " bundles, " + RacePrefabs.Count + " Tokyo prefabs."));
			}
		}
	}
	internal sealed class EmpressUmuGate : MonoBehaviour
	{
		private Quaternion _closed;

		private Quaternion _open;

		private bool _opening;

		internal void Configure(Quaternion open)
		{
			//IL_0007: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			_closed = ((Component)this).transform.localRotation;
			_open = open;
		}

		internal void Open()
		{
			_opening = true;
		}

		private void Update()
		{
			//IL_0015: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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)
			if (_opening)
			{
				((Component)this).transform.localRotation = Quaternion.RotateTowards(((Component)this).transform.localRotation, _open, 240f * Time.deltaTime);
				if (Quaternion.Angle(((Component)this).transform.localRotation, _open) < 0.5f)
				{
					_opening = false;
				}
			}
		}
	}
	internal sealed class EmpressUmuCrowdBob : MonoBehaviour
	{
		private Vector3 _base;

		private float _phase;

		private float _amplitude;

		private void Start()
		{
			//IL_0007: 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)
			_base = ((Component)this).transform.localPosition;
			_phase = _base.x * 1.7f + _base.z * 0.9f;
			_amplitude = 0.22f;
		}

		private void Update()
		{
			//IL_002b: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Abs(Mathf.Sin(Time.time * 3.4f + _phase)) * _amplitude;
			((Component)this).transform.localPosition = _base + Vector3.up * num;
		}
	}
	internal sealed class EmpressUmuCourse
	{
		internal const float CenterRadiusX = 72f;

		internal const float CenterRadiusZ = 36f;

		internal const float TrackWidth = 16f;

		internal const float TrackY = 0.18f;

		internal const int Segments = 192;

		internal readonly List<Vector3> SpawnPositions = new List<Vector3>();

		internal readonly List<Quaternion> SpawnRotations = new List<Quaternion>();

		private readonly List<EmpressUmuGate> _gates = new List<EmpressUmuGate>();

		private Text _scoreText;

		private readonly Transform _root;

		private readonly Material _trackMaterial;

		private readonly Material _grassMaterial;

		private readonly Material _whiteMaterial;

		private readonly Material _pinkMaterial;

		private readonly Material _darkMaterial;

		private readonly Material _goldMaterial;

		private EmpressUmuCourse(Transform root)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			_root = root;
			_trackMaterial = Material("Empress Uma Dirt", Color.white, (Texture)(object)CreateDirtTexture(), (Vector2?)new Vector2(24f, 6f));
			_grassMaterial = Material("Empress Uma Turf", new Color(0.2f, 0.55f, 0.2f), (Texture)(object)EmpressUmuAssets.TurfTexture, (Vector2?)new Vector2(13f, 7f));
			_whiteMaterial = Material("Empress Derby White", new Color(0.95f, 0.97f, 1f));
			_pinkMaterial = Material("Empress Derby Pink", new Color(1f, 0.12f, 0.46f));
			_darkMaterial = Material("Empress Derby Dark", new Color(0.045f, 0.055f, 0.085f));
			_goldMaterial = Material("Empress Derby Gold", new Color(1f, 0.66f, 0.08f));
		}

		internal static EmpressUmuCourse Build(Transform parent)
		{
			//IL_0005: 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)
			GameObject val = new GameObject("Empress Tokyo Racecourse");
			val.transform.SetParent(parent, false);
			EmpressUmuCourse empressUmuCourse = new EmpressUmuCourse(val.transform);
			empressUmuCourse.BuildGround();
			empressUmuCourse.BuildRails();
			empressUmuCourse.BuildLaneLines();
			empressUmuCourse.BuildFinishLine();
			empressUmuCourse.BuildGrandstands();
			empressUmuCourse.BuildScoreboard();
			empressUmuCourse.BuildCrowd();
			empressUmuCourse.BuildUmaScenery();
			empressUmuCourse.BuildDecor();
			empressUmuCourse.BuildSpawns();
			empressUmuCourse.BuildStalls();
			return empressUmuCourse;
		}

		internal void OpenGates()
		{
			for (int i = 0; i < _gates.Count; i++)
			{
				if ((Object)(object)_gates[i] != (Object)null)
				{
					_gates[i].Open();
				}
			}
		}

		internal void SetScoreboard(string text)
		{
			if ((Object)(object)_scoreText != (Object)null)
			{
				_scoreText.text = text;
			}
		}

		internal static void Evaluate(float progress, float laneOffset, out Vector3 position, out Vector3 tangent)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			float num = progress * MathF.PI * 2f - MathF.PI / 2f;
			float num2 = 72f + laneOffset;
			float num3 = 36f + laneOffset;
			position = new Vector3(Mathf.Cos(num) * num2, 0.24000001f, Mathf.Sin(num) * num3);
			Vector3 val = new Vector3((0f - Mathf.Sin(num)) * num2, 0f, Mathf.Cos(num) * num3);
			tangent = ((Vector3)(ref val)).normalized;
		}

		internal static float LaneOffset(int index, int count)
		{
			if (count <= 1)
			{
				return 0f;
			}
			return Mathf.Lerp(-5.76f, 5.76f, (float)index / (float)(count - 1));
		}

		private void BuildGround()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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)
			Primitive("Empress Stadium Foundation", (PrimitiveType)3, _root, Vector3.zero, new Vector3(260f, 1f, 180f), _grassMaterial).transform.position = new Vector3(0f, -0.55f, 0f);
			CreateDisc("Empress Turf Infield", 63.52f, 27.52f, 0.15f, _grassMaterial, collider: true);
			CreateRing("Empress Racing Surface", 64f, 28f, 80f, 44f, 0.18f, _trackMaterial, collider: true);
			CreateRing("Empress Outer Turf", 80f, 44f, 92f, 56f, 0.13000001f, _grassMaterial, collider: true);
		}

		private void BuildRails()
		{
			BuildRail(63.52f, 27.52f, 1.25f);
			BuildRail(80.479996f, 44.48f, 1.45f);
		}

		private void BuildRail(float rx, float rz, float height)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_008f: 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_009c: 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)
			//IL_00bf: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_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_00f0: 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)
			//IL_0109: 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)
			Vector3 val = default(Vector3);
			Vector3 val2 = default(Vector3);
			for (int i = 0; i < 96; i++)
			{
				float num = (float)i * MathF.PI * 2f / 96f;
				float num2 = (float)(i + 1) * MathF.PI * 2f / 96f;
				((Vector3)(ref val))..ctor(Mathf.Cos(num) * rx, 0.18f + height, Mathf.Sin(num) * rz);
				((Vector3)(ref val2))..ctor(Mathf.Cos(num2) * rx, 0.18f + height, Mathf.Sin(num2) * rz);
				Vector3 position = (val + val2) * 0.5f;
				Transform transform = Primitive("Empress Race Rail", (PrimitiveType)3, _root, position, new Vector3(0.13f, 0.13f, Vector3.Distance(val, val2) + 0.15f), _whiteMaterial).transform;
				Vector3 val3 = val2 - val;
				transform.rotation = Quaternion.LookRotation(((Vector3)(ref val3)).normalized, Vector3.up);
				if ((i & 1) == 0)
				{
					Primitive("Empress Rail Post", (PrimitiveType)2, _root, new Vector3(val.x, 0.18f + height * 0.5f, val.z), new Vector3(0.15f, height * 0.5f, 0.15f), _whiteMaterial);
				}
			}
		}

		private void BuildLaneLines()
		{
			//IL_00b5: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00d4: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			Vector3 val2 = default(Vector3);
			for (int i = 1; i < 8; i++)
			{
				float num = Mathf.Lerp(-8f, 8f, (float)i / 8f);
				float num2 = 72f + num;
				float num3 = 36f + num * 0.55f;
				for (int j = 0; j < 96; j += 2)
				{
					float num4 = (float)j * MathF.PI * 2f / 96f;
					float num5 = (float)(j + 1) * MathF.PI * 2f / 96f;
					((Vector3)(ref val))..ctor(Mathf.Cos(num4) * num2, 0.23500001f, Mathf.Sin(num4) * num3);
					((Vector3)(ref val2))..ctor(Mathf.Cos(num5) * num2, 0.23500001f, Mathf.Sin(num5) * num3);
					Transform transform = Primitive("Empress Lane Dash", (PrimitiveType)3, _root, (val + val2) * 0.5f, new Vector3(0.055f, 0.025f, Vector3.Distance(val, val2) * 0.72f), _whiteMaterial, collider: false).transform;
					Vector3 val3 = val2 - val;
					transform.rotation = Quaternion.LookRotation(((Vector3)(ref val3)).normalized, Vector3.up);
				}
			}
		}

		private void BuildFinishLine()
		{
			//IL_001a: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_00e8: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: 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_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(0f, 0.18f, -36f);
			for (int i = 0; i < 14; i++)
			{
				float num = val.z - 8f + (float)i * 1.2307693f;
				Material material = ((i % 2 == 0) ? _darkMaterial : _whiteMaterial);
				Primitive("Empress Finish Check", (PrimitiveType)3, _root, new Vector3(0f, 0.27f, num), new Vector3(0.62f, 0.03f, 1.2307693f), material, collider: false);
			}
			Primitive("Empress Finish Pink", (PrimitiveType)3, _root, val + Vector3.up * 0.16f, new Vector3(0.17f, 0.025f, 17f), _pinkMaterial, collider: false);
			Primitive("Empress Finish Inner", (PrimitiveType)3, _root, val + new Vector3(0f, 4.5f, -9.92f), new Vector3(0.7f, 9f, 0.7f), _pinkMaterial);
			Primitive("Empress Finish Outer", (PrimitiveType)3, _root, val + new Vector3(0f, 4.5f, 9.92f), new Vector3(0.7f, 9f, 0.7f), _pinkMaterial);
			Primitive("Empress Finish Header", (PrimitiveType)3, _root, val + new Vector3(0f, 8.4f, 0f), new Vector3(0.85f, 1.25f, 21.6f), _darkMaterial);
			Primitive("Empress Finish Banner", (PrimitiveType)3, _root, val + new Vector3(0f, 7.1f, 0f), new Vector3(0.3f, 1.4f, 19.2f), _goldMaterial, collider: false);
		}

		private void BuildStalls()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0042: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Expected O, but got Unknown
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: 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_025a: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < SpawnPositions.Count; i++)
			{
				GameObject val = new GameObject("Empress Starting Stall " + (i + 1));
				val.transform.SetParent(_root, false);
				val.transform.position = SpawnPositions[i];
				val.transform.rotation = SpawnRotations[i];
				StallPart(val.transform, "Left Wall", new Vector3(-0.85f, 1.15f, -0.2f), new Vector3(0.1f, 2.3f, 2.2f), _darkMaterial);
				StallPart(val.transform, "Right Wall", new Vector3(0.85f, 1.15f, -0.2f), new Vector3(0.1f, 2.3f, 2.2f), _darkMaterial);
				StallPart(val.transform, "Back Wall", new Vector3(0f, 1.15f, -1.35f), new Vector3(1.7f, 2.3f, 0.12f), _darkMaterial);
				StallPart(val.transform, "Roof", new Vector3(0f, 2.55f, -0.2f), new Vector3(1.8f, 0.12f, 2.35f), _darkMaterial);
				GameObject val2 = new GameObject("Empress Stall Gate");
				val2.transform.SetParent(val.transform, false);
				val2.transform.localPosition = new Vector3(0f, 2.3f, 1.02f);
				val2.transform.localRotation = Quaternion.identity;
				StallPart(val2.transform, "Gate Panel", new Vector3(0f, -1f, 0f), new Vector3(1.6f, 2f, 0.08f), _darkMaterial);
				for (int j = 0; j < 3; j++)
				{
					StallPart(val2.transform, "Gate Bar", new Vector3(0f, -0.5f - (float)j * 0.55f, 0.18f), new Vector3(1.64f, 0.09f, 0.06f), _pinkMaterial);
				}
				EmpressUmuGate empressUmuGate = val2.AddComponent<EmpressUmuGate>();
				empressUmuGate.Configure(Quaternion.Euler(-88f, 0f, 0f));
				_gates.Add(empressUmuGate);
			}
		}

		private void StallPart(Transform parent, string name, Vector3 localPosition, Vector3 scale, Material material)
		{
			//IL_0040: 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)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)obj).name = "Empress " + name;
			Collider component = obj.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			obj.transform.SetParent(parent, false);
			obj.transform.localPosition = localPosition;
			obj.transform.localScale = scale;
			obj.GetComponent<Renderer>().sharedMaterial = material;
		}

		private void BuildGrandstands()
		{
			//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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			BuildGrandstand(new Vector3(0f, 0f, 67f), Quaternion.identity, 118f);
			BuildGrandstand(new Vector3(0f, 0f, -70f), Quaternion.Euler(0f, 180f, 0f), 104f);
			Primitive("Empress Stadium Tower", (PrimitiveType)3, _root, new Vector3(-103f, 14f, 5f), new Vector3(20f, 28f, 32f), _darkMaterial);
			for (int i = 0; i < 5; i++)
			{
				Primitive("Empress Tower Glass", (PrimitiveType)3, _root, new Vector3(-92.8f, 5f + (float)i * 4.6f, 5f), new Vector3(0.25f, 2.8f, 27f), (i % 2 == 0) ? _pinkMaterial : _goldMaterial, collider: false);
			}
		}

		private void BuildGrandstand(Vector3 origin, Quaternion rotation, float width)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0023: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_00f7: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Empress Tokyo Grandstand");
			val.transform.SetParent(_root, false);
			val.transform.position = origin;
			val.transform.rotation = rotation;
			for (int i = 0; i < 8; i++)
			{
				Primitive("Empress Stand Tier", (PrimitiveType)3, val.transform, new Vector3(0f, (float)i * 1.05f + 0.5f, (float)i * 1.35f), new Vector3(width, 1f, 2.7f), (i % 2 == 0) ? _whiteMaterial : _darkMaterial).transform.localPosition = new Vector3(0f, (float)i * 1.05f + 0.5f, (float)i * 1.35f);
			}
			Primitive("Empress Stand Roof", (PrimitiveType)3, val.transform, new Vector3(0f, 13.5f, 8f), new Vector3(width + 8f, 0.8f, 18f), _darkMaterial).transform.localPosition = new Vector3(0f, 13.5f, 8f);
			for (int j = -2; j <= 2; j++)
			{
				Primitive("Empress Roof Post", (PrimitiveType)3, val.transform, Vector3.zero, new Vector3(0.6f, 13f, 0.6f), _pinkMaterial).transform.localPosition = new Vector3((float)j * width * 0.2f, 6.5f, 1f);
			}
		}

		private void BuildScoreboard()
		{
			//IL_0022: 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_0050: 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_0065: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_00f5: 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_010a: 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_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Expected O, but got Unknown
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(0f, 10f, 5f);
			Primitive("Empress Infield Scoreboard", (PrimitiveType)3, _root, val, new Vector3(28f, 14f, 1.3f), _darkMaterial);
			Primitive("Empress Scoreboard Frame", (PrimitiveType)3, _root, val + new Vector3(0f, 0f, -0.72f), new Vector3(30f, 15.5f, 0.3f), _pinkMaterial, collider: false);
			Primitive("Empress Scoreboard Screen", (PrimitiveType)3, _root, val + new Vector3(0f, 0f, -0.95f), new Vector3(26.5f, 11.5f, 0.2f), _darkMaterial, collider: false);
			GameObject val2 = new GameObject("Empress Scoreboard Canvas");
			val2.transform.SetParent(_root, false);
			val2.transform.position = val + new Vector3(0f, 0.4f, -1.15f);
			val2.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
			val2.transform.localScale = Vector3.one * 0.02f;
			Canvas obj = val2.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)2;
			((Component)obj).GetComponent<RectTransform>().sizeDelta = new Vector2(1200f, 520f);
			GameObject val3 = new GameObject("Empress Scoreboard Text");
			val3.transform.SetParent(val2.transform, false);
			_scoreText = val3.AddComponent<Text>();
			Font val4 = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf") ?? Resources.GetBuiltinResource<Font>("Arial.ttf");
			if ((Object)(object)val4 == (Object)null)
			{
				Font[] array = Resources.FindObjectsOfTypeAll<Font>();
				for (int i = 0; i < array.Length; i++)
				{
					if ((Object)(object)array[i] != (Object)null && array[i].dynamic)
					{
						val4 = array[i];
						break;
					}
				}
				if ((Object)(object)val4 == (Object)null && array.Length != 0)
				{
					val4 = array[0];
				}
			}
			_scoreText.font = val4;
			_scoreText.fontSize = 54;
			_scoreText.fontStyle = (FontStyle)1;
			_scoreText.alignment = (TextAnchor)1;
			_scoreText.horizontalOverflow = (HorizontalWrapMode)1;
			_scoreText.verticalOverflow = (VerticalWrapMode)1;
			((Graphic)_scoreText).color = new Color(0.4f, 1f, 0.55f);
			RectTransform rectTransform = ((Graphic)_scoreText).rectTransform;
			rectTransform.anchorMin = Vector2.zero;
			rectTransform.anchorMax = Vector2.one;
			rectTransform.offsetMin = new Vector2(30f, 20f);
			rectTransform.offsetMax = new Vector2(-30f, -20f);
			_scoreText.text = "- EMPRESS UMU DERBY -";
		}

		private void BuildDecor()
		{
			//IL_0071: 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_00f4: 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_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: 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_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			Material[] array = (Material[])(object)new Material[3] { _pinkMaterial, _goldMaterial, _whiteMaterial };
			Vector3 position = default(Vector3);
			for (int i = 0; i < 120; i++)
			{
				float num = (float)i / 120f * MathF.PI * 2f;
				float num2 = 61.920002f;
				float num3 = 25.92f;
				((Vector3)(ref position))..ctor(Mathf.Cos(num) * num2, 0.43f, Mathf.Sin(num) * num3);
				Primitive("Empress Flower Bed", (PrimitiveType)0, _root, position, new Vector3(0.9f, 0.5f, 0.9f), array[i % array.Length], collider: false);
			}
			Vector3 position2 = default(Vector3);
			for (int j = 0; j < 72; j++)
			{
				float num4 = (float)j / 72f * MathF.PI * 2f;
				float num5 = 83.2f;
				float num6 = 47.2f;
				((Vector3)(ref position2))..ctor(Mathf.Cos(num4) * num5, 0.73f, Mathf.Sin(num4) * num6);
				Primitive("Empress Hedge", (PrimitiveType)3, _root, position2, new Vector3(2.4f, 1.1f, 1.1f), _grassMaterial, collider: false);
			}
			for (int k = 1; k <= 6; k++)
			{
				Evaluate((float)k / 8f, 10f, out var position3, out var tangent);
				position3.y = 1.28f;
				Primitive("Empress Distance Board", (PrimitiveType)3, _root, position3, new Vector3(1.4f, 2.2f, 0.18f), _whiteMaterial, collider: false).transform.rotation = Quaternion.LookRotation(tangent, Vector3.up);
				Primitive("Empress Distance Marker", (PrimitiveType)3, _root, position3 + Vector3.up * 0.4f, new Vector3(0.9f, 0.6f, 0.24f), (k % 2 == 0) ? _pinkMaterial : _goldMaterial, collider: false);
			}
			Vector3 val = default(Vector3);
			for (int l = 0; l < 16; l++)
			{
				float num7 = Mathf.Lerp(-55f, 55f, (float)l / 15f);
				((Vector3)(ref val))..ctor(num7, 15.5f, 67f);
				Primitive("Empress Flag Pole", (PrimitiveType)2, _root, val, new Vector3(0.12f, 1.6f, 0.12f), _whiteMaterial, collider: false);
				Primitive("Empress Flag", (PrimitiveType)3, _root, val + new Vector3(0.6f, 0.9f, 0f), new Vector3(1.1f, 0.7f, 0.06f), (l % 2 == 0) ? _pinkMaterial : _goldMaterial, collider: false);
			}
		}

		private void BuildCrowd()
		{
			//IL_0017: 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_0032: 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_004d: 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_0068: 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_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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			Color[] array = (Color[])(object)new Color[5]
			{
				new Color(1f, 0.2f, 0.48f),
				new Color(0.2f, 0.75f, 1f),
				new Color(1f, 0.82f, 0.1f),
				new Color(0.58f, 0.3f, 1f),
				Color.white
			};
			Material[] array2 = (Material[])(object)new Material[array.Length];
			for (int i = 0; i < array.Length; i++)
			{
				array2[i] = Material("Empress Crowd " + i, array[i]);
			}
			Random random = new Random(10005);
			for (int j = -1; j <= 1; j += 2)
			{
				for (int k = 0; k < 130; k++)
				{
					float num = Mathf.Lerp(-52f, 52f, (float)random.NextDouble());
					int num2 = random.Next(0, 8);
					float num3 = ((j > 0) ? (66f + (float)num2 * 1.35f) : (-69f - (float)num2 * 1.35f));
					float num4 = 1.5f + (float)num2 * 1.05f;
					GameObject obj = Primitive("Empress Race Fan", (PrimitiveType)0, _root, new Vector3(num, num4, num3), new Vector3(0.42f, 0.55f, 0.42f), array2[random.Next(array2.Length)], collider: false);
					obj.transform.rotation = Quaternion.Euler(0f, (float)random.Next(0, 360), 0f);
					obj.AddComponent<EmpressUmuCrowdBob>();
				}
			}
		}

		private void BuildUmaScenery()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_00cd: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			IReadOnlyList<GameObject> prefabs = EmpressUmuAssets.Prefabs;
			for (int i = 0; i < prefabs.Count; i++)
			{
				GameObject val = prefabs[i];
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				string text = ((Object)val).name.ToLowerInvariant();
				if (text.Contains("guest") || text.Contains("prop"))
				{
					GameObject obj = Object.Instantiate<GameObject>(val, _root, false);
					((Object)obj).name = "Empress Authentic Tokyo " + ((Object)val).name;
					obj.transform.localPosition = Vector3.zero;
					obj.SetActive(true);
					PrepareImported(obj);
				}
				else if (text.Contains("tree"))
				{
					Vector3[] array = (Vector3[])(object)new Vector3[4]
					{
						new Vector3(-91f, 0f, 47f),
						new Vector3(91f, 0f, 48f),
						new Vector3(-94f, 0f, -45f),
						new Vector3(94f, 0f, -44f)
					};
					for (int j = 0; j < array.Length; j++)
					{
						GameObject obj2 = Object.Instantiate<GameObject>(val, _root, false);
						((Object)obj2).name = "Empress Authentic Tokyo Tree";
						obj2.transform.localPosition = array[j];
						obj2.transform.localRotation = Quaternion.Euler(0f, (float)j * 73f, 0f);
						obj2.SetActive(true);
						PrepareImported(obj2);
					}
				}
			}
		}

		private static void PrepareImported(GameObject instance)
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_00e9: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			Collider[] componentsInChildren = instance.GetComponentsInChildren<Collider>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].enabled = false;
			}
			Renderer[] componentsInChildren2 = instance.GetComponentsInChildren<Renderer>(true);
			Shader val = Shader.Find("Standard");
			for (int j = 0; j < componentsInChildren2.Length; j++)
			{
				Material[] materials = componentsInChildren2[j].materials;
				for (int k = 0; k < materials.Length; k++)
				{
					Material val2 = materials[k];
					if ((Object)(object)val2 == (Object)null || (Object)(object)val2.shader == (Object)null || !val2.shader.isSupported || ((Object)val2.shader).name == "Hidden/InternalErrorShader")
					{
						Texture mainTexture = (((Object)(object)val2 != (Object)null) ? val2.mainTexture : null);
						Color color = (((Object)(object)val2 != (Object)null && val2.HasProperty("_Color")) ? val2.color : Color.white);
						Material val3 = new Material(val)
						{
							mainTexture = mainTexture,
							color = color
						};
						materials[k] = val3;
					}
				}
				componentsInChildren2[j].materials = materials;
			}
		}

		private void BuildSpawns()
		{
			//IL_001c: 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_0023: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 12; i++)
			{
				float laneOffset = LaneOffset(i, 12);
				Evaluate(0f, laneOffset, out var position, out var tangent);
				position -= tangent * 2.8f;
				SpawnPositions.Add(position);
				SpawnRotations.Add(Quaternion.LookRotation(tangent, Vector3.up));
			}
		}

		private static Texture2D CreateDirtTexture()
		{
			//IL_000c: 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_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_002b: Expected O, but got Unknown
			//IL_00bc: 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)
			Texture2D val = new Texture2D(128, 128, (TextureFormat)3, true)
			{
				name = "Empress Uma Dirt Texture",
				wrapMode = (TextureWrapMode)0,
				filterMode = (FilterMode)1
			};
			Color[] array = (Color[])(object)new Color[16384];
			Random random = new Random(10005);
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					float num = (float)random.NextDouble() * 0.13f;
					float num2 = Mathf.Sin((float)j * 0.38f) * 0.025f + Mathf.Sin((float)j * 0.09f) * 0.018f;
					float num3 = 0.78f + num + num2;
					array[i * 128 + j] = new Color(0.55f * num3, 0.37f * num3, 0.22f * num3, 1f);
				}
			}
			val.SetPixels(array);
			val.Apply(true, false);
			return val;
		}

		private void CreateRing(string name, float innerX, float innerZ, float outerX, float outerZ, float y, Material material, bool collider)
		{
			//IL_0058: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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)
			Vector3[] array = (Vector3[])(object)new Vector3[386];
			Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
			int[] array3 = new int[1152];
			for (int i = 0; i <= 192; i++)
			{
				float num = (float)i / 192f;
				float num2 = num * MathF.PI * 2f;
				array[i * 2] = new Vector3(Mathf.Cos(num2) * innerX, y, Mathf.Sin(num2) * innerZ);
				array[i * 2 + 1] = new Vector3(Mathf.Cos(num2) * outerX, y, Mathf.Sin(num2) * outerZ);
				array2[i * 2] = new Vector2(num * 18f, 0f);
				array2[i * 2 + 1] = new Vector2(num * 18f, 5f);
				if (i < 192)
				{
					int num3 = i * 6;
					int num4 = (array3[num3] = i * 2);
					array3[num3 + 1] = num4 + 3;
					array3[num3 + 2] = num4 + 1;
					array3[num3 + 3] = num4;
					array3[num3 + 4] = num4 + 2;
					array3[num3 + 5] = num4 + 3;
				}
			}
			CreateMeshObject(name, array, array3, array2, material, collider);
		}

		private void CreateDisc(string name, float rx, float rz, float y, Material material, bool collider)
		{
			//IL_002d: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[193];
			Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
			int[] array3 = new int[576];
			array[0] = new Vector3(0f, y, 0f);
			array2[0] = new Vector2(0.5f, 0.5f);
			for (int i = 0; i < 192; i++)
			{
				float num = (float)i * MathF.PI * 2f / 192f;
				array[i + 1] = new Vector3(Mathf.Cos(num) * rx, y, Mathf.Sin(num) * rz);
				array2[i + 1] = new Vector2(Mathf.Cos(num) * 0.5f + 0.5f, Mathf.Sin(num) * 0.5f + 0.5f) * 8f;
				int num2 = i * 3;
				array3[num2] = 0;
				array3[num2 + 1] = (i + 1) % 192 + 1;
				array3[num2 + 2] = i + 1;
			}
			CreateMeshObject(name, array, array3, array2, material, collider);
		}

		private void CreateMeshObject(string name, Vector3[] vertices, int[] triangles, Vector2[] uv, Material material, bool collider)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_0030: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.transform.SetParent(_root, false);
			Mesh val2 = new Mesh
			{
				name = name + " Mesh"
			};
			val2.vertices = vertices;
			val2.triangles = triangles;
			val2.uv = uv;
			val2.RecalculateNormals();
			val2.RecalculateBounds();
			val.AddComponent<MeshFilter>().sharedMesh = val2;
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = material;
			if (collider)
			{
				val.AddComponent<MeshCollider>().sharedMesh = val2;
			}
		}

		private static GameObject Primitive(string name, PrimitiveType type, Transform parent, Vector3 position, Vector3 scale, Material material, bool collider = true)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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)
			GameObject val = GameObject.CreatePrimitive(type);
			((Object)val).name = name;
			val.transform.SetParent(parent, true);
			val.transform.position = position;
			val.transform.localScale = scale;
			val.GetComponent<Renderer>().sharedMaterial = material;
			if (!collider)
			{
				Collider component = val.GetComponent<Collider>();
				if ((Object)(object)component != (Object)null)
				{
					Object.Destroy((Object)(object)component);
				}
			}
			return val;
		}

		private static Material Material(string name, Color color, Texture texture = null, Vector2? scale = null)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_0017: 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_0025: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(Shader.Find("Standard"))
			{
				name = name,
				color = color,
				mainTexture = texture
			};
			if (scale.HasValue)
			{
				val.mainTextureScale = scale.Value;
			}
			val.SetFloat("_Glossiness", 0.18f);
			return val;
		}
	}
	internal static class EmpressUmuLevelRegistry
	{
		private static readonly FieldRef<LevelContent, Level> LevelRef = AccessTools.FieldRefAccess<LevelContent, Level>("_level");

		private static readonly FieldRef<LevelContent, List<GameObject>> StartRoomsRef = AccessTools.FieldRefAccess<LevelContent, List<GameObject>>("_startRooms");

		private static readonly string[] ModuleFields = new string[12]
		{
			"_modulesNormal1", "_modulesNormal2", "_modulesNormal3", "_modulesPassage1", "_modulesPassage2", "_modulesPassage3", "_modulesDeadEnd1", "_modulesDeadEnd2", "_modulesDeadEnd3", "_modulesExtraction1",
			"_modulesExtraction2", "_modulesExtraction3"
		};

		internal static Level RegisterLevel()
		{
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			Level val = ScriptableObject.CreateInstance<Level>();
			((Object)val).name = "Level - Empress UMU Race";
			val.NarrativeName = "Empress UMU Derby";
			LevelValuables val2 = ScriptableObject.CreateInstance<LevelValuables>();
			((Object)val2).name = "Valuables - Empress UMU Race";
			val2.tiny = new List<PrefabRef>();
			val2.small = new List<PrefabRef>();
			val2.medium = new List<PrefabRef>();
			val2.big = new List<PrefabRef>();
			val2.wide = new List<PrefabRef>();
			val2.tall = new List<PrefabRef>();
			val2.veryTall = new List<PrefabRef>();
			SetLevelField(val, "ModuleAmount", 0);
			SetLevelField(val, "PassageMaxAmount", 0);
			SetLevelField(val, "HasEnemies", false);
			SetLevelField(val, "ValuablePresets", new List<LevelValuables> { val2 });
			SetLevelField(val, "AmbiencePresets", new List<LevelAmbience>());
			SetLevelField(val, "FogColor", (object)new Color(0.58f, 0.72f, 0.88f));
			SetLevelField(val, "FogStartDistance", 180f);
			SetLevelField(val, "FogEndDistance", 650f);
			SetLevelField(val, "AmbientColor", (object)new Color(0.74f, 0.78f, 0.82f));
			SetLevelField(val, "AmbientColorAdaptation", (object)new Color(0.68f, 0.72f, 0.78f));
			SetLevelField(val, "ColorTemperature", 4f);
			SetLevelField(val, "ColorFilter", (object)new Color(1f, 0.98f, 0.94f));
			SetLevelField(val, "BloomIntensity", 0.55f);
			SetLevelField(val, "BloomThreshold", 1.1f);
			SetLevelField(val, "VignetteIntensity", 0.16f);
			SetLevelField(val, "VignetteSmoothness", 0.72f);
			SetLevelField(val, "DiscordIcon", "level");
			EnsureLevelFieldInstance(val, "LoadingGraphic01");
			EnsureLevelFieldInstance(val, "LoadingGraphic02");
			EnsureLevelFieldInstance(val, "LoadingGraphic03");
			EnsureLevelFieldInstance(val, "ConnectObject");
			EnsureLevelFieldInstance(val, "BlockObject");
			LevelContent val3 = ScriptableObject.CreateInstance<LevelContent>();
			((Object)val3).name = "Empress UMU Race Content";
			LevelRef.Invoke(val3) = val;
			StartRoomsRef.Invoke(val3) = new List<GameObject>();
			for (int i = 0; i < ModuleFields.Length; i++)
			{
				AccessTools.Field(typeof(LevelContent), ModuleFields[i])?.SetValue(val3, new List<GameObject>());
			}
			AccessTools.Field(typeof(LevelContent), "_connectObject")?.SetValue(val3, null);
			AccessTools.Field(typeof(LevelContent), "_blockObject")?.SetValue(val3, null);
			Levels.RegisterLevel(val3);
			return val;
		}

		private static void SetLevelField(Level level, string fieldName, object value)
		{
			FieldInfo fieldInfo = AccessTools.Field(typeof(Level), fieldName);
			if (fieldInfo != null && value != null && fieldInfo.FieldType.IsInstanceOfType(value))
			{
				fieldInfo.SetValue(level, value);
			}
		}

		private static void EnsureLevelFieldInstance(Level level, string fieldName)
		{
			FieldInfo fieldInfo = AccessTools.Field(typeof(Level), fieldName);
			if (!(fieldInfo == null) && fieldInfo.FieldType.IsClass && !(fieldInfo.FieldType == typeof(string)) && fieldInfo.GetValue(level) == null)
			{
				fieldInfo.SetValue(level, FormatterServices.GetUninitializedObject(fieldInfo.FieldType));
			}
		}
	}
	[HarmonyPatch(typeof(RunManager), "SetRunLevel")]
	internal static class EmpressUmuPatchSetRunLevel
	{
		private static void Postfix(RunManager __instance)
		{
			if (EmpressUmuRacePlugin.Settings != null && EmpressUmuRacePlugin.Settings.ForceLevel.Value && (Object)(object)EmpressUmuRacePlugin.RaceLevel != (Object)null)
			{
				__instance.levelCurrent = EmpressUmuRacePlugin.RaceLevel;
			}
		}
	}
	[HarmonyPatch(typeof(LevelGenerator), "Generate")]
	internal static class EmpressUmuPatchGenerate
	{
		private static bool Prefix(LevelGenerator __instance, ref IEnumerator __result)
		{
			if (!EmpressUmuRacePlugin.IsRaceLevel(Object.op_Implicit((Object)(object)RunManager.instance) ? RunManager.instance.levelCurrent : null))
			{
				return true;
			}
			__result = EmpressUmuRaceRuntime.EnsureHost().GenerateLevel(__instance);
			return false;
		}
	}
	[HarmonyPatch(typeof(LevelPoint), "NavMeshCheck")]
	internal static class EmpressUmuPatchNavMesh
	{
		private static bool Prefix(ref IEnumerator __result)
		{
			if (!EmpressUmuRacePlugin.IsRaceLevel(Object.op_Implicit((Object)(object)RunManager.instance) ? RunManager.instance.levelCurrent : null))
			{
				return true;
			}
			__result = EmpressUmuRaceRuntime.EmptyCoroutine();
			return false;
		}
	}
	[HarmonyPatch(typeof(EnvironmentDirector), "Setup")]
	internal static class EmpressUmuPatchEnvironment
	{
		private static bool Prefix(EnvironmentDirector __instance)
		{
			//IL_004f: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			if (!EmpressUmuRacePlugin.IsRaceLevel(Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? LevelGenerator.Instance.Level : null))
			{
				return true;
			}
			Color val = default(Color);
			((Color)(ref val))..ctor(0.58f, 0.72f, 0.88f);
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0.74f, 0.78f, 0.82f);
			EmpressUmuAccess.ConfigureEnvironment(__instance, val, val2, 180f, 650f);
			RenderSettings.fog = true;
			RenderSettings.fogMode = (FogMode)1;
			RenderSettings.fogColor = val;
			RenderSettings.fogStartDistance = 180f;
			RenderSettings.fogEndDistance = 650f;
			RenderSettings.ambientLight = val2;
			RenderSettings.ambientMode = (AmbientMode)3;
			Camera val3 = (((Object)(object)GameDirector.instance != (Object)null) ? GameDirector.instance.MainCamera : Camera.main);
			if ((Object)(object)val3 != (Object)null)
			{
				val3.clearFlags = (CameraClearFlags)2;
				val3.backgroundColor = val;
				val3.farClipPlane = 900f;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(LoadingUI), "LevelAnimationStart")]
	internal static class EmpressUmuPatchLoading
	{
		private static void Postfix(LoadingUI __instance)
		{
			//IL_0054: 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)
			if (EmpressUmuRacePlugin.IsRaceLevel(Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? LevelGenerator.Instance.Level : null))
			{
				if ((Object)(object)__instance.levelNumberText != (Object)null)
				{
					((TMP_Text)__instance.levelNumberText).text = "TOKYO RACECOURSE";
					((Graphic)__instance.levelNumberText).color = new Color(1f, 0.38f, 0.58f);
				}
				if ((Object)(object)__instance.levelNameText != (Object)null)
				{
					((TMP_Text)__instance.levelNameText).text = "Empress UMU Derby";
					((Graphic)__instance.levelNameText).color = Color.white;
				}
			}
		}
	}
	[HarmonyPatch(typeof(LightManager), "HandleLightActivation")]
	internal static class EmpressUmuPatchLights
	{
		private static bool Prefix()
		{
			return !EmpressUmuRacePlugin.IsRaceLevel(Object.op_Implicit((Object)(object)RunManager.instance) ? RunManager.instance.levelCurrent : null);
		}
	}
	[HarmonyPatch(typeof(PlayerAvatarVisuals), "ApplyLocalVisibility")]
	internal static class EmpressUmuPatchLocalVisibility
	{
		private static void Prefix(PlayerAvatarVisuals __instance, ref ShadowCastingMode __0)
		{
			EmpressUmuRaceRuntime instance = EmpressUmuRaceRuntime.Instance;
			if ((Object)(object)instance != (Object)null && instance.Active && EmpressUmuAccess.IsLocalVisuals(__instance))
			{
				__0 = (ShadowCastingMode)1;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerAvatarVisuals), "Update")]
	internal static class EmpressUmuPatchRunnerAnimation
	{
		private static void Prefix(PlayerAvatarVisuals __instance)
		{
			EmpressUmuRaceRuntime instance = EmpressUmuRaceRuntime.Instance;
			if ((Object)(object)instance != (Object)null && instance.Active)
			{
				instance.PrepareRunnerAnimation(__instance);
			}
		}

		private static void Postfix(PlayerAvatarVisuals __instance)
		{
			EmpressUmuRaceRuntime instance = EmpressUmuRaceRuntime.Instance;
			if ((Object)(object)instance != (Object)null && instance.Active)
			{
				instance.FinalizeRunnerAnimation(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerAvatarVisuals), "AnimationLogic")]
	internal static class EmpressUmuPatchAnimationLogic
	{
		private static void Postfix(PlayerAvatarVisuals __instance)
		{
			EmpressUmuRaceRuntime instance = EmpressUmuRaceRuntime.Instance;
			if ((Object)(object)instance != (Object)null && instance.Active)
			{
				instance.FinalizeRunnerAnimation(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerAvatarVisuals), "ApplyLocalVisibilityBody")]
	internal static class EmpressUmuPatchLocalVisibilityBody
	{
		private static void Prefix(PlayerAvatarVisuals __instance)
		{
			EmpressUmuRaceRuntime instance = EmpressUmuRaceRuntime.Instance;
			if ((Object)(object)instance != (Object)null && instance.Active && EmpressUmuAccess.IsLocalVisuals(__instance))
			{
				EmpressUmuAccess.SetVisualVisibility(__instance, (ShadowCastingMode)1, apply: false);
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.empress.repo.umurace", "Empress UMU Race", "1.0.4")]
	public sealed class EmpressUmuRacePlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.empress.repo.umurace";

		public const string PluginName = "Empress UMU Race";

		public const string PluginVersion = "1.0.4";

		public const string LevelName = "Level - Empress UMU Race";

		public const string DisplayName = "Empress UMU Derby";

		internal const byte RaceStartEventCode = 197;

		internal const byte RaceFinishEventCode = 198;

		private static bool _photonHooked;

		private static LoadBalancingClient _hookedClient;

		private Harmony _harmony;

		internal static EmpressUmuRacePlugin Instance { get; private set; }

		internal static ManualLogSource Log { get; private set; }

		internal static EmpressUmuRaceSettings Settings { get; private set; }

		internal static Level RaceLevel { get; private set; }

		internal static string PluginDirectory { get; private set; }

		private void Awake()
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			PluginDirectory = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			Settings = new EmpressUmuRaceSettings(((BaseUnityPlugin)this).Config);
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			RaceLevel = EmpressUmuLevelRegistry.RegisterLevel();
			_harmony = new Harmony("com.empress.repo.umurace");
			_harmony.PatchAll(typeof(EmpressUmuRacePlugin).Assembly);
			EmpressUmuRaceRuntime.EnsureHost();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Empress UMU Race v1.0.4 loaded. Level registered: Level - Empress UMU Race");
		}

		private void OnDestroy()
		{
			RemovePhotonHook();
		}

		internal static bool IsRaceLevel(Level level)
		{
			if ((Object)(object)level != (Object)null)
			{
				return ((Object)level).name == "Level - Empress UMU Race";
			}
			return false;
		}

		internal static void EnsurePhotonHooked()
		{
			if (!PhotonNetwork.InRoom)
			{
				return;
			}
			LoadBalancingClient networkingClient = PhotonNetwork.NetworkingClient;
			if (networkingClient != null && (!_photonHooked || _hookedClient != networkingClient))
			{
				if (_hookedClient != null)
				{
					_hookedClient.EventReceived -= OnPhotonEvent;
				}
				networkingClient.EventReceived -= OnPhotonEvent;
				networkingClient.EventReceived += OnPhotonEvent;
				_hookedClient = networkingClient;
				_photonHooked = true;
			}
		}

		internal static void RemovePhotonHook()
		{
			if (_photonHooked)
			{
				if (_hookedClient != null)
				{
					_hookedClient.EventReceived -= OnPhotonEvent;
				}
				_hookedClient = null;
				_photonHooked = false;
			}
		}

		private static void OnPhotonEvent(EventData ev)
		{
			if (!(ev.CustomData is object[] data))
			{
				return;
			}
			EmpressUmuRaceRuntime instance = EmpressUmuRaceRuntime.Instance;
			if (!((Object)(object)instance == (Object)null))
			{
				if (ev.Code == 197)
				{
					instance.ReceiveRaceStart(data);
				}
				else if (ev.Code == 198)
				{
					instance.ReceiveRaceFinish(data);
				}
			}
		}

		internal static void RaiseToAll(byte code, object[] data)
		{
			//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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			EnsurePhotonHooked();
			if (!PhotonNetwork.InRoom)
			{
				switch (code)
				{
				case 197:
					EmpressUmuRaceRuntime.Instance?.ReceiveRaceStart(data);
					break;
				case 198:
					EmpressUmuRaceRuntime.Instance?.ReceiveRaceFinish(data);
					break;
				}
			}
			else
			{
				RaiseEventOptions val = new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)1
				};
				PhotonNetwork.RaiseEvent(code, (object)data, val, SendOptions.SendReliable);
			}
		}
	}
	internal sealed class EmpressUmuRaceSettings
	{
		public readonly ConfigEntry<bool> ForceLevel;

		public readonly ConfigEntry<float> Countdown;

		public readonly ConfigEntry<float> ExitDelay;

		public readonly ConfigEntry<bool> DebugLogs;

		public EmpressUmuRaceSettings(ConfigFile config)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			ForceLevel = config.Bind<bool>("Level", "ForceLevel", false, "Forces every normal run to load Empress UMU Derby for testing.");
			Countdown = config.Bind<float>("Race", "Countdown", 10f, new ConfigDescription("Seconds before the gates open.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 15f), Array.Empty<object>()));
			ExitDelay = config.Bind<float>("Race", "ExitDelay", 9f, new ConfigDescription("Seconds to show the result before leaving.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 20f), Array.Empty<object>()));
			DebugLogs = config.Bind<bool>("Debug", "DebugLogs", false, "Logs Empress UMU Race diagnostics.");
		}
	}
	internal sealed class EmpressUmuRaceRuntime : MonoBehaviour
	{
		private enum RaceState
		{
			Inactive,
			Waiting,
			Countdown,
			Racing,
			Finished
		}

		private struct AbilityProc
		{
			internal string Name;

			internal double Start;

			internal double End;

			internal double Boost;
		}

		private sealed class Runner
		{
			internal int ViewId;

			internal string Name;

			internal float Lane;

			internal float FinishTime;

			internal float Phase;

			internal float Progress;

			internal float Speed;

			internal float Stamina;

			internal float Power;

			internal float Guts;

			internal float Wit;

			internal double SimTime;

			internal double SimProgress;

			internal AbilityProc[] Procs;

			internal int ActiveProc;

			internal float GlowUntil;
		}

		private sealed class RunnerGlow
		{
			internal GameObject Root;

			internal Light Light;

			internal ParticleSystem Particles;
		}

		private static readonly AbilityProc[] AbilityCatalog = new AbilityProc[10]
		{
			new AbilityProc
			{
				Name = "Escape Artist",
				Start = 0.0,
				End = 0.17,
				Boost = 0.3
			},
			new AbilityProc
			{
				Name = "Rushing Gale",
				Start = 0.05,
				End = 0.24,
				Boost = 0.24
			},
			new AbilityProc
			{
				Name = "Corner Adept",
				Start = 0.28,
				End = 0.46,
				Boost = 0.22
			},
			new AbilityProc
			{
				Name = "Professor of Curvature",
				Start = 0.44,
				End = 0.6,
				Boost = 0.23
			},
			new AbilityProc
			{
				Name = "Straightaway Ace",
				Start = 0.54,
				End = 0.74,
				Boost = 0.21
			},
			new AbilityProc
			{
				Name = "Second Wind",
				Start = 0.6,
				End = 0.8,
				Boost = 0.26
			},
			new AbilityProc
			{
				Name = "Uma Overdrive",
				Start = 0.7,
				End = 0.86,
				Boost = 0.27
			},
			new AbilityProc
			{
				Name = "Homestretch Haste",
				Start = 0.8,
				End = 0.94,
				Boost = 0.32
			},
			new AbilityProc
			{
				Name = "Last Spurt",
				Start = 0.88,
				End = 1.0,
				Boost = 0.4
			},
			new AbilityProc
			{
				Name = "Gutsy Finale",
				Start = 0.9,
				End = 1.0,
				Boost = 0.36
			}
		};

		private readonly List<Runner> _runners = new List<Runner>();

		private readonly Dictionary<int, RunnerGlow> _runnerGlows = new Dictionary<int, RunnerGlow>();

		private readonly List<KeyValuePair<string, float>> _announcements = new List<KeyValuePair<string, float>>();

		private Transform _root;

		private EmpressUmuCourse _course;

		private RaceState _state;

		private int _sceneHandle = -1;

		private int _seed;

		private double _raceStartTime;

		private float _waitingTimer;

		private float _standingsTimer;

		private bool _active;

		private bool _startSent;

		private bool _finishSent;

		private bool _leaving;

		private int _winnerId = -1;

		private int _lastId = -1;

		private int _upgradeIndex;

		private string _upgradeName = string.Empty;

		private Transform _cameraAnchor;

		private Transform _cameraPreviousParent;

		private float _cameraPreviousFov;

		private bool _cameraActive;

		private bool _cameraInitialized;

		private bool _localVisualForced;

		private bool _localVisualWasVisible;

		private bool _localAnimatorWasEnabled;

		private AnimatorCullingMode _localAnimatorCulling;

		private ShadowCastingMode _localVisibility;

		private int _cameraOriginalCullingMask = -1;

		private Vector3 _lastLocalPosition;

		private bool _haveLastLocalPosition;

		private GUIStyle _countdownStyle;

		private GUIStyle _placeStyle;

		private GUIStyle _smallStyle;

		private GUIStyle _skillStyle;

		private AudioSource _sfx;

		private AudioSource _music;

		private const float AudioVolume = 0.3f;

		private static Material _particleMaterial;

		internal static EmpressUmuRaceRuntime Instance { get; private set; }

		internal bool Active => _active;

		internal static EmpressUmuRaceRuntime EnsureHost()
		{
			//IL_0018: 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: 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_0037: Expected O, but got Unknown
			if ((Object)(object)Instance != (Object)null)
			{
				return Instance;
			}
			GameObject val = new GameObject("Empress UMU Race Runtime");
			val.transform.parent = null;
			((Object)val).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)val);
			Instance = val.AddComponent<EmpressUmuRaceRuntime>();
			return Instance;
		}

		internal static IEnumerator EmptyCoroutine()
		{
			yield break;
		}

		private void Awake()
		{
			Instance = this;
		}

		private void Update()
		{
			//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)
			if (_active && _sceneHandle != -1)
			{
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).handle != _sceneHandle)
				{
					Deactivate();
					return;
				}
			}
			if (!_active)
			{
				return;
			}
			if (!EmpressUmuRacePlugin.IsRaceLevel(Object.op_Implicit((Object)(object)RunManager.instance) ? RunManager.instance.levelCurrent : null))
			{
				Deactivate();
				return;
			}
			EmpressUmuAccess.LockControls();
			_waitingTimer += Time.deltaTime;
			if (_state == RaceState.Waiting && SemiFunc.IsMasterClientOrSingleplayer() && !_startSent && _waitingTimer >= 6f)
			{
				StartRaceHost();
			}
			if (_state == RaceState.Countdown || _state == RaceState.Racing)
			{
				UpdateRace();
			}
			else if (_state == RaceState.Finished)
			{
				UpdateCamera();
			}
		}

		private void LateUpdate()
		{
			if (_active)
			{
				EmpressUmuAccess.HideVanillaHud();
				ForceLocalAvatarVisible(visible: true);
				for (int i = 0; i < _runners.Count; i++)
				{
					EmpressUmuAccess.KeepAnimatorAwake(EmpressUmuAccess.AvatarByViewId(_runners[i].ViewId));
				}
			}
		}

		internal IEnumerator GenerateLevel(LevelGenerator generator)
		{
			Empress