Decompiled source of GolfMayhem v1.2.2
GolfMayhem.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FMOD.Studio; using FMODUnity; using GolfMayhem.ChaosEventSystem; using GolfMayhem.ChaosEventSystem.Events; using GolfMayhem.Patches; using HarmonyLib; using Mirror; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.0.0.0")] namespace GolfMayhem { public static class Configuration { public static ConfigEntry<bool> ChaosEventsEnabled { get; private set; } public static ConfigEntry<float> ChaosEventIntervalMin { get; private set; } public static ConfigEntry<float> ChaosEventIntervalMax { get; private set; } public static ConfigEntry<float> ChaosEventDuration { get; private set; } public static ConfigEntry<bool> EnableGravityFlip { get; private set; } public static ConfigEntry<bool> EnableSpeedSurge { get; private set; } public static ConfigEntry<bool> EnableMineFlood { get; private set; } public static ConfigEntry<bool> EnableMagnetHole { get; private set; } public static ConfigEntry<bool> EnableFogOfWar { get; private set; } public static ConfigEntry<bool> EnableMiniature { get; private set; } public static ConfigEntry<bool> EnableOrbitalStrike { get; private set; } public static ConfigEntry<bool> EnableGiantMode { get; private set; } public static ConfigEntry<bool> EnableNightTime { get; private set; } public static ConfigEntry<bool> EnableGolfCartChaos { get; private set; } public static ConfigEntry<bool> EnableCoffeeRush { get; private set; } public static ConfigEntry<bool> EnableTornado { get; private set; } public static ConfigEntry<bool> EnableGauntlet { get; private set; } public static ConfigEntry<bool> EnableGolfCartRace { get; private set; } public static ConfigEntry<bool> EnableRain { get; private set; } public static ConfigEntry<bool> EnableDuelingPistol { get; private set; } public static ConfigEntry<float> WeightGravityFlip { get; private set; } public static ConfigEntry<float> WeightSpeedSurge { get; private set; } public static ConfigEntry<float> WeightMineFlood { get; private set; } public static ConfigEntry<float> WeightMagnetHole { get; private set; } public static ConfigEntry<float> WeightFogOfWar { get; private set; } public static ConfigEntry<float> WeightMiniature { get; private set; } public static ConfigEntry<float> WeightOrbitalStrike { get; private set; } public static ConfigEntry<float> WeightGiantMode { get; private set; } public static ConfigEntry<float> WeightNightTime { get; private set; } public static ConfigEntry<float> WeightGolfCartChaos { get; private set; } public static ConfigEntry<float> WeightCoffeeRush { get; private set; } public static ConfigEntry<float> WeightTornado { get; private set; } public static ConfigEntry<float> WeightGauntlet { get; private set; } public static ConfigEntry<float> WeightGolfCartRace { get; private set; } public static ConfigEntry<float> WeightRain { get; private set; } public static ConfigEntry<float> WeightDuelingPistol { get; private set; } public static ConfigEntry<float> GravityFlipMultiplier { get; private set; } public static ConfigEntry<float> SpeedSurgeMultiplier { get; private set; } public static void Initialize(ConfigFile cfg) { ChaosEventsEnabled = cfg.Bind<bool>("ChaosEvents", "Enabled", true, "Master toggle for the Chaos Event system."); ChaosEventIntervalMin = cfg.Bind<float>("ChaosEvents", "IntervalMin", 10f, "Minimum seconds between chaos events."); ChaosEventIntervalMax = cfg.Bind<float>("ChaosEvents", "IntervalMax", 35f, "Maximum seconds between chaos events."); ChaosEventDuration = cfg.Bind<float>("ChaosEvents", "Duration", 20f, "How many seconds each chaos event lasts."); EnableGravityFlip = cfg.Bind<bool>("ChaosEvents.Events", "GravityFlip", true, "Briefly inverts or amplifies gravity for all balls."); EnableSpeedSurge = cfg.Bind<bool>("ChaosEvents.Events", "SpeedSurge", false, "Doubles ball velocity for all players."); EnableMineFlood = cfg.Bind<bool>("ChaosEvents.Events", "MineFlood", true, "Spawns a wave of mines across the course."); EnableMagnetHole = cfg.Bind<bool>("ChaosEvents.Events", "MagnetHole", true, "The hole briefly repels ALL balls away from it."); EnableFogOfWar = cfg.Bind<bool>("ChaosEvents.Events", "FogOfWar", true, "Blankets the course in thick fog, hiding player positions."); EnableMiniature = cfg.Bind<bool>("ChaosEvents.Events", "Miniature", true, "Shrinks every player and ball to half size."); EnableOrbitalStrike = cfg.Bind<bool>("ChaosEvents.Events", "OrbitalStrike", true, "Fires an orbital laser at every player simultaneously."); EnableGiantMode = cfg.Bind<bool>("ChaosEvents.Events", "GiantMode", true, "Grows every player and ball to 2.5x size."); EnableNightTime = cfg.Bind<bool>("ChaosEvents.Events", "NightTime", true, "Dims all lights and fades the scene to near darkness."); EnableGolfCartChaos = cfg.Bind<bool>("ChaosEvents.Events", "GolfCartChaos", true, "Spawns a golf cart for every player simultaneously."); EnableCoffeeRush = cfg.Bind<bool>("ChaosEvents.Events", "CoffeeRush", true, "Applies the coffee speed boost to every player."); EnableTornado = cfg.Bind<bool>("ChaosEvents.Events", "Tornado", true, "Spirals every player upward in a tornado funnel."); EnableGauntlet = cfg.Bind<bool>("ChaosEvents.Events", "Gauntlet", false, "Pairs players into sky arenas for a dueling pistol 1v1."); EnableGolfCartRace = cfg.Bind<bool>("ChaosEvents.Events", "GolfCartRace", false, "Figure-8 golf cart race track in the sky. First to 2 laps wins."); EnableRain = cfg.Bind<bool>("ChaosEvents.Events", "Rain", true, "Spawns rain particles above all players."); EnableDuelingPistol = cfg.Bind<bool>("ChaosEvents.Events", "DuelingPistol", true, "Everyone gets an auto-firing dueling pistol with infinite ammo."); WeightGravityFlip = cfg.Bind<float>("ChaosEvents.Weights", "GravityFlip", 1f, "Relative spawn weight."); WeightSpeedSurge = cfg.Bind<float>("ChaosEvents.Weights", "SpeedSurge", 1f, "Relative spawn weight."); WeightMineFlood = cfg.Bind<float>("ChaosEvents.Weights", "MineFlood", 1f, "Relative spawn weight."); WeightMagnetHole = cfg.Bind<float>("ChaosEvents.Weights", "MagnetHole", 1f, "Relative spawn weight."); WeightFogOfWar = cfg.Bind<float>("ChaosEvents.Weights", "FogOfWar", 1f, "Relative spawn weight."); WeightMiniature = cfg.Bind<float>("ChaosEvents.Weights", "Miniature", 1f, "Relative spawn weight."); WeightOrbitalStrike = cfg.Bind<float>("ChaosEvents.Weights", "OrbitalStrike", 1f, "Relative spawn weight."); WeightGiantMode = cfg.Bind<float>("ChaosEvents.Weights", "GiantMode", 1f, "Relative spawn weight."); WeightNightTime = cfg.Bind<float>("ChaosEvents.Weights", "NightTime", 1f, "Relative spawn weight."); WeightGolfCartChaos = cfg.Bind<float>("ChaosEvents.Weights", "GolfCartChaos", 1f, "Relative spawn weight."); WeightCoffeeRush = cfg.Bind<float>("ChaosEvents.Weights", "CoffeeRush", 1f, "Relative spawn weight."); WeightTornado = cfg.Bind<float>("ChaosEvents.Weights", "Tornado", 1f, "Relative spawn weight."); WeightGauntlet = cfg.Bind<float>("ChaosEvents.Weights", "Gauntlet", 1f, "Relative spawn weight."); WeightGolfCartRace = cfg.Bind<float>("ChaosEvents.Weights", "GolfCartRace", 1f, "Relative spawn weight."); WeightRain = cfg.Bind<float>("ChaosEvents.Weights", "Rain", 1f, "Relative spawn weight."); WeightDuelingPistol = cfg.Bind<float>("ChaosEvents.Weights", "DuelingPistol", 1f, "Relative spawn weight."); GravityFlipMultiplier = cfg.Bind<float>("Physics", "GravityFlipMultiplier", -2.5f, "Y-gravity during a GravityFlip event. Negative = upward."); SpeedSurgeMultiplier = cfg.Bind<float>("Physics", "SpeedSurgeMultiplier", 2.5f, "Velocity multiplier applied to all balls during SpeedSurge."); GolfMayhemPlugin.Log.LogInfo((object)"Configuration initialized."); } } public class EnvironmentManager : MonoBehaviour { private RainEvent _rainEvent; private NightTimeEvent _nightTimeEvent; private Coroutine _nightFadeCoroutine; private static bool _pendingRain; private static bool _pendingNightTime; private static bool _hasPending; public static EnvironmentManager Instance { get; private set; } public static bool RainActive { get; private set; } public static bool NightTimeActive { get; private set; } public static void StorePending(bool rain, bool nightTime) { _pendingRain = rain; _pendingNightTime = nightTime; _hasPending = true; } private void Awake() { if ((Object)(object)Instance != (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Instance = this; _rainEvent = new RainEvent(); _nightTimeEvent = new NightTimeEvent(); GolfMayhemPlugin.Log.LogInfo((object)"[EnvironmentManager] Ready."); if (_hasPending) { _hasPending = false; ApplyEnvironment(_pendingRain, _pendingNightTime); } } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { DeactivateAll(); Instance = null; } } public void BroadcastEnvironment(bool rain, bool nightTime) { if (NetworkServer.active) { GolfMayhemPlugin.Log.LogInfo((object)$"[EnvironmentManager] Broadcasting rain={rain} nightTime={nightTime}"); GolfMayhemNetwork.SendEnvironment(rain, nightTime); } } public void ApplyEnvironment(bool rain, bool nightTime) { GolfMayhemPlugin.Log.LogInfo((object)$"[EnvironmentManager] Applying rain={rain} nightTime={nightTime}"); if (rain && !RainActive) { RainActive = true; _rainEvent.OnActivate(); } else if (!rain && RainActive) { RainActive = false; _rainEvent.OnDeactivate(); } if (nightTime && !NightTimeActive) { NightTimeActive = true; _nightTimeEvent.OnActivate(); } else if (!nightTime && NightTimeActive) { NightTimeActive = false; _nightTimeEvent.OnDeactivate(); } } public void DeactivateAll() { if (RainActive) { RainActive = false; _rainEvent?.OnDeactivate(); } if (NightTimeActive) { NightTimeActive = false; _nightTimeEvent?.OnDeactivate(); } } public Coroutine StartManagedCoroutine(IEnumerator routine) { return ((MonoBehaviour)this).StartCoroutine(routine); } public void StopManagedCoroutine(Coroutine c) { if (c != null) { ((MonoBehaviour)this).StopCoroutine(c); } } } public static class GolfMayhemNetwork { private const string PREFIX = "##GOLFMAYHEM##"; private static MethodInfo _serverShowInfoFeedMessage; public static bool IsInitialized { get; private set; } public static event Action<string> OnZombieSpawnData; public static void Initialize() { if (!IsInitialized) { IsInitialized = true; GolfMayhemPlugin.Log.LogInfo((object)"[GolfMayhemNetwork] Initialized."); } } public static void Shutdown() { IsInitialized = false; } public static void SendWarn(string eventName, string warnMessage) { Send("##GOLFMAYHEM##0|" + eventName + "|" + warnMessage); } public static void SendActivate(string eventName, string activateMessage) { Send("##GOLFMAYHEM##1|" + eventName + "|" + activateMessage); } public static void SendDeactivate(string eventName, string deactivateMessage) { Send("##GOLFMAYHEM##2|" + eventName + "|" + deactivateMessage); } public static void SendEnvironment(bool rain, bool nightTime) { Send(string.Format("{0}3|env|{1}|{2}", "##GOLFMAYHEM##", rain ? 1 : 0, nightTime ? 1 : 0)); } public static void SendZombieHorde(List<(ulong guid, Vector3 pos)> spawnData) { //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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < spawnData.Count; i++) { if (i > 0) { stringBuilder.Append(','); } var (num, val) = spawnData[i]; stringBuilder.Append($"{num}:{val.x:F2}:{val.y:F2}:{val.z:F2}"); } Send(string.Format("{0}4|zombies|{1}", "##GOLFMAYHEM##", stringBuilder)); } private static void Send(string encoded) { if (NetworkServer.active) { TextChatManager.SendChatMessage(encoded); } } public static bool TryHandleMessage(string message) { if (string.IsNullOrEmpty(message) || !message.StartsWith("##GOLFMAYHEM##")) { return false; } string text = message.Substring("##GOLFMAYHEM##".Length); if (text.StartsWith("3|")) { string[] array = text.Split(new char[1] { '|' }); if (array.Length >= 4) { bool rain = array[2] == "1"; bool nightTime = array[3] == "1"; if ((Object)(object)EnvironmentManager.Instance != (Object)null) { EnvironmentManager.Instance.ApplyEnvironment(rain, nightTime); } else { EnvironmentManager.StorePending(rain, nightTime); } } return true; } if (text.StartsWith("4|")) { string[] array2 = text.Split(new char[1] { '|' }, 3); if (array2.Length >= 3) { GolfMayhemNetwork.OnZombieSpawnData?.Invoke(array2[2]); } return true; } string[] array3 = text.Split(new char[1] { '|' }, 3); if (array3.Length < 3) { return true; } string text2 = array3[2]; if (!string.IsNullOrEmpty(text2)) { string text3 = GameManager.UiSettings.ApplyColorTag("GolfMayhem", (TextHighlight)0); TextChatUi.ShowMessage(text3 + ": " + text2); } if (!NetworkServer.active) { byte b = byte.Parse(array3[0]); string networkId = array3[1]; ChaosEventManager instance = ChaosEventManager.Instance; if ((Object)(object)instance != (Object)null) { ChaosEvent eventByName = instance.GetEventByName(networkId); if (eventByName != null) { switch (b) { case 1: instance.ActivateEventLocally(eventByName); break; case 2: instance.DeactivateEventLocally(eventByName); break; } } } } return true; } } [HarmonyPatch(typeof(TextChatManager), "UserCode_RpcMessage__String__PlayerInfo")] public static class Patch_TextChatManager_RpcMessage { [HarmonyPrefix] public static bool Prefix(string message, PlayerInfo sender) { return !GolfMayhemNetwork.TryHandleMessage(message); } } [BepInPlugin("com.maflingus.golfmayhem", "GolfMayhem", "1.2.2")] public class GolfMayhemPlugin : BaseUnityPlugin { private Harmony _harmony; private static bool _systemsInjected; public static GolfMayhemPlugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown if ((Object)(object)Instance != (Object)null) { Object.Destroy((Object)(object)this); return; } Instance = this; Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"GolfMayhem 1.2.2 loading..."); Configuration.Initialize(((BaseUnityPlugin)this).Config); RulesPatch.InitFromConfig(); _harmony = new Harmony("com.maflingus.golfmayhem"); _harmony.PatchAll(typeof(GolfMayhemPlugin).Assembly); Log.LogInfo((object)"Harmony patches applied."); GameSessionPatch.Subscribe(); CourseManager.MatchStateChanged += OnMatchStateChanged; GolfMayhemNetwork.Initialize(); Log.LogInfo((object)"GolfMayhem by Maflingus loaded. Let chaos reign."); } private void OnDestroy() { CourseManager.MatchStateChanged -= OnMatchStateChanged; GameSessionPatch.Unsubscribe(); GolfMayhemNetwork.Shutdown(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } Log.LogInfo((object)"GolfMayhem unloaded."); } private void OnMatchStateChanged(MatchState previousState, MatchState currentState) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected I4, but got Unknown switch (currentState - 2) { case 0: if (!_systemsInjected && !SingletonBehaviour<DrivingRangeManager>.HasInstance) { SpawnLocalSystems(); _systemsInjected = true; } if (NetworkServer.active && (Object)(object)EnvironmentManager.Instance != (Object)null) { bool rainEnabled = RulesPatch.RainEnabled; bool nightTimeEnabled = RulesPatch.NightTimeEnabled; EnvironmentManager.Instance.BroadcastEnvironment(rainEnabled, nightTimeEnabled); } break; case 1: GameSessionPatch.OnNewHoleStarted(); break; case 4: _systemsInjected = false; CleanupGameSystems(); break; case 2: case 3: break; } } public void SpawnLocalSystems() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown if (Configuration.ChaosEventsEnabled.Value && (Object)(object)ChaosEventManager.Instance == (Object)null) { GameObject val = new GameObject("GolfMayhem_ChaosManager"); Object.DontDestroyOnLoad((Object)(object)val); val.AddComponent<ChaosEventManager>(); Log.LogInfo((object)"ChaosEventManager spawned."); } if ((Object)(object)EnvironmentManager.Instance == (Object)null) { GameObject val2 = new GameObject("GolfMayhem_EnvironmentManager"); Object.DontDestroyOnLoad((Object)(object)val2); val2.AddComponent<EnvironmentManager>(); Log.LogInfo((object)"EnvironmentManager spawned."); } } private static void CleanupGameSystems() { if ((Object)(object)ChaosEventManager.Instance != (Object)null) { Object.Destroy((Object)(object)((Component)ChaosEventManager.Instance).gameObject); } if ((Object)(object)EnvironmentManager.Instance != (Object)null) { Object.Destroy((Object)(object)((Component)EnvironmentManager.Instance).gameObject); } Log.LogDebug((object)"Game systems cleaned up."); } } internal static class PluginInfo { public const string PLUGIN_GUID = "com.maflingus.golfmayhem"; public const string PLUGIN_NAME = "GolfMayhem"; public const string PLUGIN_VERSION = "1.2.2"; } } namespace GolfMayhem.Patches { public static class RulesPatch { public static bool RainEnabled { get; set; } public static bool NightTimeEnabled { get; set; } public static bool DisableCoffeeRush { get; set; } public static bool DisableFogOfWar { get; set; } public static bool DisableGiantMode { get; set; } public static bool DisableGolfCartChaos { get; set; } public static bool DisableGravityFlip { get; set; } public static bool DisableMagnetHole { get; set; } public static bool DisableMineFlood { get; set; } public static bool DisableMiniature { get; set; } public static bool DisableNightTime { get; set; } public static bool DisableOrbitalStrike { get; set; } public static bool DisableRain { get; set; } public static bool DisableTornado { get; set; } public static bool DisableDuelingPistol { get; set; } public static void InitFromConfig() { DisableCoffeeRush = !Configuration.EnableCoffeeRush.Value; DisableFogOfWar = !Configuration.EnableFogOfWar.Value; DisableGiantMode = !Configuration.EnableGiantMode.Value; DisableGolfCartChaos = !Configuration.EnableGolfCartChaos.Value; DisableGravityFlip = !Configuration.EnableGravityFlip.Value; DisableMagnetHole = !Configuration.EnableMagnetHole.Value; DisableMineFlood = !Configuration.EnableMineFlood.Value; DisableMiniature = !Configuration.EnableMiniature.Value; DisableNightTime = !Configuration.EnableNightTime.Value; DisableOrbitalStrike = !Configuration.EnableOrbitalStrike.Value; DisableRain = !Configuration.EnableRain.Value; DisableTornado = !Configuration.EnableTornado.Value; DisableDuelingPistol = !Configuration.EnableDuelingPistol.Value; } } [HarmonyPatch(typeof(MatchSetupRules), "Initialize")] public static class Patch_MatchSetupRules_Initialize { [HarmonyPostfix] public static void Postfix(MatchSetupRules __instance) { try { InjectOptions(__instance); } catch (Exception arg) { GolfMayhemPlugin.Log.LogError((object)$"[GolfMayhem] Failed to inject UI: {arg}"); } } private static void InjectOptions(MatchSetupRules rules) { DropdownOption hitOtherPlayersBalls = rules.hitOtherPlayersBalls; if ((Object)(object)hitOtherPlayersBalls == (Object)null) { GolfMayhemPlugin.Log.LogWarning((object)"[GolfMayhem] Could not find hitOtherPlayersBalls template."); return; } Transform parent = ((Component)hitOtherPlayersBalls).transform.parent.parent; if ((Object)(object)parent == (Object)null) { return; } Transform parent2 = parent.parent; if ((Object)(object)parent2 == (Object)null) { return; } bool active = NetworkServer.active; int num = -1; Transform val = null; for (int i = 0; i < parent2.childCount; i++) { if (((Object)parent2.GetChild(i)).name == "Battle Rules") { num = i; if (i > 0) { val = parent2.GetChild(i - 1); } break; } } if ((Object)(object)val == (Object)null || num < 0) { GolfMayhemPlugin.Log.LogWarning((object)"[GolfMayhem] Could not find Battle section."); return; } int num2 = num + 1; GameObject val2 = MakeHeader(((Component)val).gameObject, parent2, "Environment"); GameObject val3 = MakeContainer(((Component)parent).gameObject, parent2, "Environment Rules"); val2.transform.SetSiblingIndex(num2++); val3.transform.SetSiblingIndex(num2++); Transform child = val3.transform.GetChild(0); ClearChildren(child); AddToggle(child, ((Component)hitOtherPlayersBalls).gameObject, "GolfMayhem_Rain", "Rain", active, RulesPatch.RainEnabled, delegate(bool v) { RulesPatch.RainEnabled = v; }, requireHost: true); AddToggle(child, ((Component)hitOtherPlayersBalls).gameObject, "GolfMayhem_NightTime", "Night time", active, RulesPatch.NightTimeEnabled, delegate(bool v) { RulesPatch.NightTimeEnabled = v; }, requireHost: true); GameObject val4 = MakeHeader(((Component)val).gameObject, parent2, "Events"); GameObject val5 = MakeContainer(((Component)parent).gameObject, parent2, "Event Rules"); val4.transform.SetSiblingIndex(num2++); val5.transform.SetSiblingIndex(num2++); Transform child2 = val5.transform.GetChild(0); ClearChildren(child2); AddToggle(child2, ((Component)hitOtherPlayersBalls).gameObject, "GolfMayhem_CoffeeRush", "Coffee Rush", active, !RulesPatch.DisableCoffeeRush, delegate(bool v) { RulesPatch.DisableCoffeeRush = !v; Configuration.EnableCoffeeRush.Value = v; }); AddToggle(child2, ((Component)hitOtherPlayersBalls).gameObject, "GolfMayhem_DuelingPistol", "Dueling Pistol", active, !RulesPatch.DisableDuelingPistol, delegate(bool v) { RulesPatch.DisableDuelingPistol = !v; Configuration.EnableDuelingPistol.Value = v; }); AddToggle(child2, ((Component)hitOtherPlayersBalls).gameObject, "GolfMayhem_FogOfWar", "Fog of War", active, !RulesPatch.DisableFogOfWar, delegate(bool v) { RulesPatch.DisableFogOfWar = !v; Configuration.EnableFogOfWar.Value = v; }); AddToggle(child2, ((Component)hitOtherPlayersBalls).gameObject, "GolfMayhem_GiantMode", "Giant Mode", active, !RulesPatch.DisableGiantMode, delegate(bool v) { RulesPatch.DisableGiantMode = !v; Configuration.EnableGiantMode.Value = v; }); AddToggle(child2, ((Component)hitOtherPlayersBalls).gameObject, "GolfMayhem_GolfCartChaos", "Golf Cart Chaos", active, !RulesPatch.DisableGolfCartChaos, delegate(bool v) { RulesPatch.DisableGolfCartChaos = !v; Configuration.EnableGolfCartChaos.Value = v; }); AddToggle(child2, ((Component)hitOtherPlayersBalls).gameObject, "GolfMayhem_GravityFlip", "Gravity Flip", active, !RulesPatch.DisableGravityFlip, delegate(bool v) { RulesPatch.DisableGravityFlip = !v; Configuration.EnableGravityFlip.Value = v; }); AddToggle(child2, ((Component)hitOtherPlayersBalls).gameObject, "GolfMayhem_MagnetHole", "Magnet Hole", active, !RulesPatch.DisableMagnetHole, delegate(bool v) { RulesPatch.DisableMagnetHole = !v; Configuration.EnableMagnetHole.Value = v; }); AddToggle(child2, ((Component)hitOtherPlayersBalls).gameObject, "GolfMayhem_MineFlood", "Mine Flood", active, !RulesPatch.DisableMineFlood, delegate(bool v) { RulesPatch.DisableMineFlood = !v; Configuration.EnableMineFlood.Value = v; }); AddToggle(child2, ((Component)hitOtherPlayersBalls).gameObject, "GolfMayhem_Miniature", "Miniature", active, !RulesPatch.DisableMiniature, delegate(bool v) { RulesPatch.DisableMiniature = !v; Configuration.EnableMiniature.Value = v; }); AddToggle(child2, ((Component)hitOtherPlayersBalls).gameObject, "GolfMayhem_NightTimeEvt", "Night Time", active, !RulesPatch.DisableNightTime, delegate(bool v) { RulesPatch.DisableNightTime = !v; Configuration.EnableNightTime.Value = v; }); AddToggle(child2, ((Component)hitOtherPlayersBalls).gameObject, "GolfMayhem_OrbitalStrike", "Orbital Strike", active, !RulesPatch.DisableOrbitalStrike, delegate(bool v) { RulesPatch.DisableOrbitalStrike = !v; Configuration.EnableOrbitalStrike.Value = v; }); AddToggle(child2, ((Component)hitOtherPlayersBalls).gameObject, "GolfMayhem_Rain_Evt", "Rain", active, !RulesPatch.DisableRain, delegate(bool v) { RulesPatch.DisableRain = !v; Configuration.EnableRain.Value = v; }); AddToggle(child2, ((Component)hitOtherPlayersBalls).gameObject, "GolfMayhem_Tornado", "Tornado", active, !RulesPatch.DisableTornado, delegate(bool v) { RulesPatch.DisableTornado = !v; Configuration.EnableTornado.Value = v; }); GolfMayhemPlugin.Log.LogInfo((object)"[GolfMayhem] Environment and Events sections injected."); } private static GameObject MakeHeader(GameObject source, Transform parent, string text) { GameObject val = Object.Instantiate<GameObject>(source, parent); ((Object)val).name = text; Component[] components = val.GetComponents<Component>(); foreach (Component val2 in components) { if (!(val2 is Transform) && !(val2 is TMP_Text) && !(val2 is CanvasRenderer)) { Object.Destroy((Object)(object)val2); } } TMP_Text component = val.GetComponent<TMP_Text>(); if ((Object)(object)component != (Object)null) { component.text = text; } return val; } private static GameObject MakeContainer(GameObject source, Transform parent, string name) { GameObject val = Object.Instantiate<GameObject>(source, parent); ((Object)val).name = name; return val; } private static void ClearChildren(Transform t) { for (int num = t.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)t.GetChild(num)).gameObject); } } private static void AddToggle(Transform parent, GameObject template, string goName, string label, bool isHost, bool initialOn, Action<bool> onChanged, bool requireHost = false) { GameObject val = Object.Instantiate<GameObject>(template, parent); ((Object)val).name = goName; DropdownOption dropdown = val.GetComponent<DropdownOption>(); if ((Object)(object)dropdown != (Object)null) { dropdown.Initialize((Action)delegate { if (!requireHost || NetworkServer.active) { onChanged(dropdown.value == 0); } }, (!initialOn) ? 1 : 0); SetInteractable(val, isHost); } SetLabel(val, label); } private static void SetLabel(GameObject go, string text) { TMP_Text[] componentsInChildren = go.GetComponentsInChildren<TMP_Text>(true); TMP_Text[] array = componentsInChildren; foreach (TMP_Text val in array) { if (!(((Object)((Component)val).gameObject).name == "Label Text")) { continue; } Component[] components = ((Component)val).gameObject.GetComponents<Component>(); foreach (Component val2 in components) { if (!(val2 is Transform) && !(val2 is TMP_Text) && !(val2 is CanvasRenderer)) { Object.Destroy((Object)(object)val2); } } val.text = text; return; } if (componentsInChildren.Length != 0) { componentsInChildren[0].text = text; } } private static void SetInteractable(GameObject go, bool interactable) { Selectable[] componentsInChildren = go.GetComponentsInChildren<Selectable>(true); foreach (Selectable val in componentsInChildren) { val.interactable = interactable; } } } public static class GameSessionPatch { private static bool _subscribed; public static void Subscribe() { if (!_subscribed) { _subscribed = true; PlayerGolfer.AnyPlayerMatchResolutionChanged += OnAnyPlayerMatchResolutionChanged; PlayerGolfer.PlayerHitOwnBall += OnPlayerHitOwnBall; PlayerGolfer.AnyPlayerEliminated += OnPlayerEliminated; GolfMayhemPlugin.Log.LogInfo((object)"[GolfMayhem] Subscribed to game events."); } } public static void Unsubscribe() { if (_subscribed) { _subscribed = false; PlayerGolfer.AnyPlayerMatchResolutionChanged -= OnAnyPlayerMatchResolutionChanged; PlayerGolfer.PlayerHitOwnBall -= OnPlayerHitOwnBall; PlayerGolfer.AnyPlayerEliminated -= OnPlayerEliminated; GolfMayhemPlugin.Log.LogInfo((object)"[GolfMayhem] Unsubscribed from game events."); } } private static void OnAnyPlayerMatchResolutionChanged(PlayerGolfer player, PlayerMatchResolution previousResolution, PlayerMatchResolution currentResolution) { } private static void OnPlayerEliminated(PlayerGolfer player) { } private static void OnPlayerHitOwnBall(PlayerGolfer player) { ManualLogSource log = GolfMayhemPlugin.Log; object obj; if (player == null) { obj = null; } else { PlayerInfo playerInfo = player.PlayerInfo; obj = ((playerInfo != null) ? playerInfo.PlayerId.PlayerName : null); } if (obj == null) { obj = "?"; } log.LogDebug((object)("[GolfMayhem] " + (string?)obj + " hit their ball.")); } public static void OnNewHoleStarted() { GolfMayhemPlugin.Log.LogDebug((object)"[GolfMayhem] Per-hole state reset for new hole."); } } } namespace GolfMayhem.ChaosEventSystem { public abstract class ChaosEvent { public virtual string NetworkId => DisplayName; public abstract string DisplayName { get; } public abstract string WarnMessage { get; } public abstract string ActivateMessage { get; } public abstract float Weight { get; } public virtual float Duration => Configuration.ChaosEventDuration.Value; public virtual bool IsEnabled => true; public abstract void OnActivate(); public abstract void OnDeactivate(); public virtual void OnUpdate() { } } public class ChaosEventManager : MonoBehaviour { private bool _isEventCycleRunning; private readonly List<ChaosEvent> _registeredEvents = new List<ChaosEvent>(); private Coroutine _schedulerCoroutine; private ChaosEvent _lastEvent; public static ChaosEventManager Instance { get; private set; } public ChaosEvent ActiveEvent { get; private set; } public bool IsEventActive => ActiveEvent != null; public static event Action<ChaosEvent> OnChaosEventStarted; public static event Action<ChaosEvent> OnChaosEventEnded; private void Awake() { if ((Object)(object)Instance != (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Instance = this; RegisterBuiltInEvents(); GolfMayhemPlugin.Log.LogInfo((object)$"ChaosEventManager ready with {_registeredEvents.Count} events."); } private void Start() { if (NetworkServer.active) { _schedulerCoroutine = ((MonoBehaviour)this).StartCoroutine(ChaosSchedulerRoutine()); } } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } if (_schedulerCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_schedulerCoroutine); } ForceDeactivateCurrentEvent(); } private void Update() { ActiveEvent?.OnUpdate(); } private void RegisterBuiltInEvents() { Register(new GravityFlipEvent()); Register(new MineFloodEvent()); Register(new MagnetHoleEvent()); Register(new FogOfWarEvent()); Register(new MiniatureEvent()); Register(new OrbitalStrikeEvent()); Register(new GiantModeEvent()); Register(new NightTimeEvent()); Register(new GolfCartChaosEvent()); Register(new CoffeeEvent()); Register(new TornadoEvent()); Register(new RainEvent()); Register(new DuelingPistolEvent()); } public void Register(ChaosEvent evt) { if (evt == null) { throw new ArgumentNullException("evt"); } _registeredEvents.Add(evt); } public ChaosEvent GetEventByName(string networkId) { return _registeredEvents.FirstOrDefault((ChaosEvent e) => e.NetworkId == networkId); } private IEnumerator ChaosSchedulerRoutine() { yield return (object)new WaitForSeconds(15f); while (true) { float interval = Random.Range(Configuration.ChaosEventIntervalMin.Value, Configuration.ChaosEventIntervalMax.Value); yield return (object)new WaitForSeconds(interval); if (!_isEventCycleRunning) { TriggerRandomEvent(); } } } private void TriggerRandomEvent() { List<ChaosEvent> list = _registeredEvents.Where((ChaosEvent e) => e.IsEnabled && e.Weight > 0f && e != _lastEvent).ToList(); if (list.Count == 0) { list = _registeredEvents.Where((ChaosEvent e) => e.IsEnabled && e.Weight > 0f).ToList(); } if (list.Count == 0) { GolfMayhemPlugin.Log.LogWarning((object)"No eligible chaos events to pick from."); } else { ((MonoBehaviour)this).StartCoroutine(RunEventRoutine(_lastEvent = WeightedRandom(list))); } } private IEnumerator RunEventRoutine(ChaosEvent evt) { _isEventCycleRunning = true; try { GolfMayhemPlugin.Log.LogInfo((object)("[ChaosEvent] WARNING: " + evt.DisplayName)); GolfMayhemNetwork.SendWarn(evt.NetworkId, evt.WarnMessage); yield return (object)new WaitForSeconds(3f); GolfMayhemPlugin.Log.LogInfo((object)("[ChaosEvent] ACTIVATING: " + evt.DisplayName)); ActiveEvent = evt; evt.OnActivate(); ChaosEventManager.OnChaosEventStarted?.Invoke(evt); GolfMayhemNetwork.SendActivate(evt.NetworkId, evt.ActivateMessage); float elapsed = 0f; while (ActiveEvent == evt && !(elapsed >= evt.Duration)) { elapsed += Time.deltaTime; yield return null; } if (ActiveEvent == evt) { GolfMayhemPlugin.Log.LogInfo((object)("[ChaosEvent] DEACTIVATING: " + evt.DisplayName)); evt.OnDeactivate(); ChaosEventManager.OnChaosEventEnded?.Invoke(evt); ActiveEvent = null; GolfMayhemNetwork.SendDeactivate(evt.NetworkId, ""); } } finally { _isEventCycleRunning = false; } } public void ActivateEventLocally(ChaosEvent evt) { if (ActiveEvent != evt) { ActiveEvent = evt; evt.OnActivate(); ChaosEventManager.OnChaosEventStarted?.Invoke(evt); } } public void DeactivateEventLocally(ChaosEvent evt) { if (ActiveEvent == evt) { evt.OnDeactivate(); ChaosEventManager.OnChaosEventEnded?.Invoke(evt); ActiveEvent = null; } } private void ForceDeactivateCurrentEvent() { if (ActiveEvent != null) { try { ActiveEvent.OnDeactivate(); } catch (Exception arg) { GolfMayhemPlugin.Log.LogError((object)$"Error deactivating on destroy: {arg}"); } ActiveEvent = null; } } private static ChaosEvent WeightedRandom(List<ChaosEvent> events) { float num = events.Sum((ChaosEvent e) => e.Weight); float num2 = Random.Range(0f, num); float num3 = 0f; foreach (ChaosEvent @event in events) { num3 += @event.Weight; if (num2 <= num3) { return @event; } } return events[events.Count - 1]; } } } namespace GolfMayhem.ChaosEventSystem.Events { public class CoffeeEvent : ChaosEvent { public override string DisplayName => "Coffee Rush"; public override string NetworkId => "CoffeeRush"; public override string WarnMessage => "Something's brewing..."; public override string ActivateMessage => "Coffee rush! Everyone's wired!"; public override float Weight => Configuration.WeightCoffeeRush.Value; public override bool IsEnabled => Configuration.EnableCoffeeRush.Value; public override void OnActivate() { PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo; if (!((Object)(object)((localPlayerInfo != null) ? localPlayerInfo.Movement : null) == (Object)null)) { localPlayerInfo.Movement.InformDrankCoffee(); GolfMayhemPlugin.Log.LogInfo((object)"[CoffeeRush] Speed boost applied to local player."); } } public override void OnDeactivate() { GolfMayhemPlugin.Log.LogInfo((object)"[CoffeeRush] Deactivated."); } } public class DuelingPistolEvent : ChaosEvent { private const int PISTOL_USES = 1; public override string DisplayName => "Dueling Pistols"; public override string NetworkId => "DuelingPistol"; public override string WarnMessage => "Draw your weapons..."; public override string ActivateMessage => "Everyone is armed!"; public override float Weight => Configuration.WeightDuelingPistol.Value; public override bool IsEnabled => Configuration.EnableDuelingPistol.Value; public override float Duration => Configuration.ChaosEventDuration.Value; public override void OnActivate() { if (!NetworkServer.active) { return; } List<PlayerInfo> list = new List<PlayerInfo>(); if ((Object)(object)GameManager.LocalPlayerInfo != (Object)null) { list.Add(GameManager.LocalPlayerInfo); } foreach (PlayerInfo remotePlayer in GameManager.RemotePlayers) { if ((Object)(object)remotePlayer != (Object)null) { list.Add(remotePlayer); } } foreach (PlayerInfo item in list) { GivePistol(item); } } public override void OnDeactivate() { } private void GivePistol(PlayerInfo player) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)((player != null) ? player.Inventory : null) == (Object)null)) { if (player.Inventory.ServerTryAddItem((ItemType)2, 1)) { GolfMayhemPlugin.Log.LogInfo((object)("[DuelingPistol] Added pistol to " + player.PlayerId.PlayerName + "'s inventory.")); return; } ItemUseId val = default(ItemUseId); ((ItemUseId)(ref val))..ctor(player.PlayerId.Guid, 0, (ItemType)2); Vector3 val2 = ((Component)player).transform.position + ((Component)player).transform.forward * 2f + Vector3.up * 0.5f; CourseManager.ServerSpawnItem((ItemType)2, 1, val2, ((Component)player).transform.rotation, Vector3.zero, Vector3.zero, val, (PlayerInventory)null); GolfMayhemPlugin.Log.LogInfo((object)("[DuelingPistol] Inventory full — spawned pistol on ground for " + player.PlayerId.PlayerName + ".")); } } } public class FogOfWarEvent : ChaosEvent { private const float MAX_ALPHA = 0.65f; private const float FADE_IN_TIME = 5.5f; private const float FAR_CLIP = 25f; private static readonly Color FOG_COLOR = new Color(0.85f, 0.92f, 1f, 1f); private GameObject _fogGO; private RawImage _fogImage; private Camera _camera; private float _originalFarClip; public override string DisplayName => "Fog of War"; public override string WarnMessage => "A strange mist approaches..."; public override string ActivateMessage => "A thick fog has appeared on the map!"; public override float Weight => Configuration.WeightFogOfWar.Value; public override bool IsEnabled => Configuration.EnableFogOfWar.Value; public override void OnActivate() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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) _camera = GameManager.Camera; if ((Object)(object)_camera != (Object)null) { _originalFarClip = _camera.farClipPlane; _camera.farClipPlane = 25f; } _fogGO = new GameObject("GolfMayhem_FogOverlay"); Object.DontDestroyOnLoad((Object)(object)_fogGO); Canvas val = _fogGO.AddComponent<Canvas>(); val.renderMode = (RenderMode)0; val.sortingOrder = 998; _fogGO.AddComponent<CanvasScaler>().uiScaleMode = (ScaleMode)1; GameObject val2 = new GameObject("FogImage"); val2.transform.SetParent(_fogGO.transform, false); _fogImage = val2.AddComponent<RawImage>(); _fogImage.texture = (Texture)(object)BuildRadialGradientTexture(256); ((Graphic)_fogImage).color = new Color(FOG_COLOR.r, FOG_COLOR.g, FOG_COLOR.b, 0f); RectTransform component = ((Component)_fogImage).GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; ((MonoBehaviour)GolfMayhemPlugin.Instance).StartCoroutine(FadeIn()); GolfMayhemPlugin.Log.LogInfo((object)"[FogOfWar] Fog overlay spawned."); } public override void OnDeactivate() { if ((Object)(object)_fogGO != (Object)null) { Object.Destroy((Object)(object)_fogGO); _fogGO = null; _fogImage = null; } if ((Object)(object)_camera != (Object)null) { _camera.farClipPlane = _originalFarClip; _camera = null; } GolfMayhemPlugin.Log.LogInfo((object)"[FogOfWar] Fog cleared."); } private IEnumerator FadeIn() { float elapsed = 0f; while (elapsed < 5.5f && (Object)(object)_fogImage != (Object)null) { elapsed += Time.deltaTime; float alpha = Mathf.Lerp(0f, 0.65f, elapsed / 5.5f); Color c = ((Graphic)_fogImage).color; ((Graphic)_fogImage).color = new Color(c.r, c.g, c.b, alpha); yield return null; } } private static Texture2D BuildRadialGradientTexture(int size) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false); ((Texture)val).wrapMode = (TextureWrapMode)1; float num = (float)size * 0.5f; float num2 = (float)size * 0.5f; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num3 = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num, num)); float num4 = Mathf.Clamp01(num3 / num2); num4 *= num4; val.SetPixel(j, i, new Color(1f, 1f, 1f, num4)); } } val.Apply(); return val; } } public class GauntletEvent : ChaosEvent { private class DuelState { public PlayerInfo PlayerA; public PlayerInfo PlayerB; public Vector3 OriginalPosA; public Vector3 OriginalPosB; public Quaternion OriginalRotA; public Quaternion OriginalRotB; public List<GameObject> ArenaWalls = new List<GameObject>(); public bool Resolved; } private const float ARENA_HEIGHT = 60f; private const float ARENA_SIZE = 36f; private const float ARENA_WALL_H = 16f; private const float ARENA_THICKNESS = 0.5f; private const float ARENA_SPACING = 60f; private const float DUEL_DISTANCE = 18f; private readonly List<DuelState> _activeDuels = new List<DuelState>(); private readonly List<Coroutine> _watchCoroutines = new List<Coroutine>(); public override string DisplayName => "Gauntlet"; public override string NetworkId => "Gauntlet"; public override string WarnMessage => "Prepare for the 1v1 arena..."; public override string ActivateMessage => "1v1 Arena! Fight to the death!"; public override float Weight => Configuration.WeightGauntlet.Value; public override bool IsEnabled => Configuration.EnableGauntlet.Value; public override void OnActivate() { //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: 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_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) List<PlayerInfo> list = new List<PlayerInfo>(); if ((Object)(object)GameManager.LocalPlayerInfo != (Object)null) { list.Add(GameManager.LocalPlayerInfo); } foreach (PlayerInfo item in new List<PlayerInfo>(GameManager.RemotePlayers)) { if ((Object)(object)item != (Object)null) { list.Add(item); } } GolfMayhemPlugin.Log.LogInfo((object)$"[Gauntlet] Found {list.Count} players."); if (list.Count < 1) { GolfMayhemPlugin.Log.LogWarning((object)"[Gauntlet] No players found, aborting."); return; } for (int num = list.Count - 1; num > 0; num--) { int num2 = Random.Range(0, num + 1); int index = num; List<PlayerInfo> list2 = list; int index2 = num2; PlayerInfo val = list[num2]; PlayerInfo val2 = list[num]; PlayerInfo val4 = (list[index] = val); val4 = (list2[index2] = val2); } _activeDuels.Clear(); _watchCoroutines.Clear(); if (list.Count == 1) { list.Add(list[0]); } int num3 = 0; Vector3 arenaCenter = default(Vector3); for (int i = 0; i + 1 < list.Count; i += 2) { DuelState duelState = new DuelState { PlayerA = list[i], PlayerB = list[i + 1] }; _activeDuels.Add(duelState); Vector3 val6 = (duelState.OriginalPosA + duelState.OriginalPosB) / 2f; ((Vector3)(ref arenaCenter))..ctor(val6.x + (float)num3 * 60f, val6.y + 60f, val6.z); StartDuel(duelState, arenaCenter); num3++; } if (list.Count % 2 != 0 && list.Count > 0) { GolfMayhemPlugin.Log.LogInfo((object)("[Gauntlet] " + list[list.Count - 1].PlayerId.PlayerName + " sits this round out.")); } } private void StartDuel(DuelState duel, Vector3 arenaCenter) { //IL_000d: 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_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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_00bb: 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_00d6: 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_00eb: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) duel.OriginalPosA = duel.PlayerA.Rigidbody.position; duel.OriginalPosB = duel.PlayerB.Rigidbody.position; duel.OriginalRotA = ((Component)duel.PlayerA).transform.rotation; duel.OriginalRotB = ((Component)duel.PlayerB).transform.rotation; if (NetworkServer.active) { BuildArena(duel, arenaCenter); BuildObstacles(duel, arenaCenter); } PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo; if ((Object)(object)localPlayerInfo != (Object)null && ((Object)(object)localPlayerInfo == (Object)(object)duel.PlayerA || (Object)(object)localPlayerInfo == (Object)(object)duel.PlayerB)) { BoundsManager.DeregisterLevelBoundsTracker(localPlayerInfo.LevelBoundsTracker); } Vector3 val = arenaCenter + new Vector3(-9f, 1f, 0f); Vector3 val2 = arenaCenter + new Vector3(9f, 1f, 0f); Quaternion val3 = Quaternion.LookRotation(Vector3.right); Quaternion val4 = Quaternion.LookRotation(Vector3.left); if ((Object)(object)localPlayerInfo == (Object)(object)duel.PlayerA) { localPlayerInfo.Movement.Teleport(val, val3, true); } else if ((Object)(object)localPlayerInfo == (Object)(object)duel.PlayerB) { localPlayerInfo.Movement.Teleport(val2, val4, true); } if ((Object)(object)localPlayerInfo != (Object)null && ((Object)(object)localPlayerInfo == (Object)(object)duel.PlayerA || (Object)(object)localPlayerInfo == (Object)(object)duel.PlayerB)) { localPlayerInfo.Inventory.ServerTryAddItem((ItemType)2, 999); } Coroutine item = ((MonoBehaviour)ChaosEventManager.Instance).StartCoroutine(WatchDuel(duel, val, val2, val3, val4)); _watchCoroutines.Add(item); } private void BuildArena(DuelState duel, Vector3 center) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) float num = 18f; float num2 = 8f; float num3 = 0.25f; duel.ArenaWalls.Add(CreateWall(center + new Vector3(0f, 0f - num3, 0f), new Vector3(36f, 0.5f, 36f))); duel.ArenaWalls.Add(CreateWall(center + new Vector3(0f, 16f + num3, 0f), new Vector3(36f, 0.5f, 36f))); duel.ArenaWalls.Add(CreateWall(center + new Vector3(0f, num2, num + num3), new Vector3(36f, 16f, 0.5f))); duel.ArenaWalls.Add(CreateWall(center + new Vector3(0f, num2, 0f - num - num3), new Vector3(36f, 16f, 0.5f))); duel.ArenaWalls.Add(CreateWall(center + new Vector3(0f - num - num3, num2, 0f), new Vector3(0.5f, 16f, 36f))); duel.ArenaWalls.Add(CreateWall(center + new Vector3(num + num3, num2, 0f), new Vector3(0.5f, 16f, 36f))); } private void BuildObstacles(DuelState duel, Vector3 center) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0048: Unknown result type (might be due to invalid IL or missing references) //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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) duel.ArenaWalls.Add(CreateWall(center + new Vector3(-3f, 2f, 0f), new Vector3(1.5f, 4f, 6f))); duel.ArenaWalls.Add(CreateWall(center + new Vector3(3f, 2f, 0f), new Vector3(1.5f, 4f, 6f))); duel.ArenaWalls.Add(CreateWall(center + new Vector3(-10f, 2f, -8f), new Vector3(2f, 4f, 2f))); duel.ArenaWalls.Add(CreateWall(center + new Vector3(-10f, 2f, 8f), new Vector3(2f, 4f, 2f))); duel.ArenaWalls.Add(CreateWall(center + new Vector3(10f, 2f, -8f), new Vector3(2f, 4f, 2f))); duel.ArenaWalls.Add(CreateWall(center + new Vector3(10f, 2f, 8f), new Vector3(2f, 4f, 2f))); duel.ArenaWalls.Add(CreateWall(center + new Vector3(-7f, 1f, 0f), new Vector3(1f, 2f, 10f))); duel.ArenaWalls.Add(CreateWall(center + new Vector3(7f, 1f, 0f), new Vector3(1f, 2f, 10f))); } private GameObject CreateWall(Vector3 position, Vector3 scale) { //IL_000e: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive((PrimitiveType)3); val.transform.position = position; val.transform.localScale = scale; val.layer = LayerMask.NameToLayer("Default"); Renderer component = val.GetComponent<Renderer>(); if ((Object)(object)component != (Object)null) { component.material = new Material(Shader.Find("Standard")); component.material.color = new Color(0.15f, 0.15f, 0.15f); } return val; } private IEnumerator WatchDuel(DuelState duel, Vector3 posA, Vector3 posB, Quaternion rotA, Quaternion rotB) { //IL_0015: 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_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_0025: 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_002d: Unknown result type (might be due to invalid IL or missing references) bool aKnockedOut = false; bool bKnockedOut = false; duel.PlayerA.Movement.IsKnockedOutOrRecoveringChanged += OnAChanged; duel.PlayerB.Movement.IsKnockedOutOrRecoveringChanged += OnBChanged; while (!aKnockedOut && !bKnockedOut && !duel.Resolved) { yield return null; } duel.PlayerA.Movement.IsKnockedOutOrRecoveringChanged -= OnAChanged; duel.PlayerB.Movement.IsKnockedOutOrRecoveringChanged -= OnBChanged; if (duel.Resolved) { yield break; } duel.Resolved = true; string winner = (aKnockedOut ? duel.PlayerB.PlayerId.PlayerName : duel.PlayerA.PlayerId.PlayerName); string loser = (aKnockedOut ? duel.PlayerA.PlayerId.PlayerName : duel.PlayerB.PlayerId.PlayerName); GolfMayhemPlugin.Log.LogInfo((object)("[Gauntlet] " + winner + " wins! " + loser + " is eliminated.")); yield return (object)new WaitForSeconds(2f); PlayerInfo localPlayer = GameManager.LocalPlayerInfo; if ((aKnockedOut && (Object)(object)localPlayer == (Object)(object)duel.PlayerA) || (bKnockedOut && (Object)(object)localPlayer == (Object)(object)duel.PlayerB)) { BoundsManager.RegisterLevelBoundsTracker(localPlayer.LevelBoundsTracker); localPlayer.Movement.TryBeginRespawn(true); } else if ((Object)(object)localPlayer == (Object)(object)duel.PlayerA || (Object)(object)localPlayer == (Object)(object)duel.PlayerB) { BoundsManager.RegisterLevelBoundsTracker(localPlayer.LevelBoundsTracker); Vector3 returnPos = (((Object)(object)localPlayer == (Object)(object)duel.PlayerA) ? duel.OriginalPosA : duel.OriginalPosB); Quaternion returnRot = (((Object)(object)localPlayer == (Object)(object)duel.PlayerA) ? duel.OriginalRotA : duel.OriginalRotB); localPlayer.Movement.Teleport(returnPos, returnRot, true); } if (NetworkServer.active) { foreach (GameObject wall in duel.ArenaWalls) { if ((Object)(object)wall != (Object)null) { Object.Destroy((Object)(object)wall); } } } duel.ArenaWalls.Clear(); void OnAChanged() { if (duel.PlayerA.Movement.IsKnockedOutOrRecovering) { aKnockedOut = true; } } void OnBChanged() { if (duel.PlayerB.Movement.IsKnockedOutOrRecovering) { bKnockedOut = true; } } } public override void OnDeactivate() { //IL_00a7: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) ChaosEventManager instance = ChaosEventManager.Instance; foreach (Coroutine watchCoroutine in _watchCoroutines) { if (watchCoroutine != null && (Object)(object)instance != (Object)null) { ((MonoBehaviour)instance).StopCoroutine(watchCoroutine); } } _watchCoroutines.Clear(); foreach (DuelState activeDuel in _activeDuels) { activeDuel.Resolved = true; PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo; if ((Object)(object)localPlayerInfo == (Object)(object)activeDuel.PlayerA) { localPlayerInfo.Movement.Teleport(activeDuel.OriginalPosA, activeDuel.OriginalRotA, true); BoundsManager.RegisterLevelBoundsTracker(localPlayerInfo.LevelBoundsTracker); } else if ((Object)(object)localPlayerInfo == (Object)(object)activeDuel.PlayerB) { localPlayerInfo.Movement.Teleport(activeDuel.OriginalPosB, activeDuel.OriginalRotB, true); BoundsManager.RegisterLevelBoundsTracker(localPlayerInfo.LevelBoundsTracker); } if (NetworkServer.active) { foreach (GameObject arenaWall in activeDuel.ArenaWalls) { if ((Object)(object)arenaWall != (Object)null) { Object.Destroy((Object)(object)arenaWall); } } } activeDuel.ArenaWalls.Clear(); } _activeDuels.Clear(); GolfMayhemPlugin.Log.LogInfo((object)"[Gauntlet] Deactivated."); } } public class GiantModeEvent : ChaosEvent { private const float GIANT_SCALE = 2.5f; private readonly Dictionary<Transform, Vector3> _originalScales = new Dictionary<Transform, Vector3>(); private readonly Dictionary<Transform, Vector3> _originalPositions = new Dictionary<Transform, Vector3>(); public override string DisplayName => "Giant Mode"; public override string NetworkId => "GiantMode"; public override string WarnMessage => "Something feels different..."; public override string ActivateMessage => "Everyone is now giant!"; public override float Weight => Configuration.WeightGiantMode.Value; public override bool IsEnabled => Configuration.EnableGiantMode.Value; public override void OnActivate() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_009e: 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_00b8: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) _originalScales.Clear(); _originalPositions.Clear(); PlayerInfo[] array = Object.FindObjectsByType<PlayerInfo>((FindObjectsSortMode)0); PlayerInfo[] array2 = array; foreach (PlayerInfo val in array2) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.HipBone == (Object)null)) { Transform hipBone = val.HipBone; _originalScales[hipBone] = hipBone.localScale; _originalPositions[hipBone] = hipBone.localPosition; hipBone.localScale = Vector3.one * 2.5f; float num = hipBone.localPosition.y * 1.5f; hipBone.localPosition += Vector3.up * num; } } GolfBall[] array3 = Object.FindObjectsByType<GolfBall>((FindObjectsSortMode)0); GolfBall[] array4 = array3; foreach (GolfBall val2 in array4) { if (!((Object)(object)val2 == (Object)null)) { _originalScales[((Component)val2).transform] = ((Component)val2).transform.localScale; ((Component)val2).transform.localScale = Vector3.one * 2.5f; } } GolfMayhemPlugin.Log.LogInfo((object)$"[GiantMode] Grew {array.Length} players and {array3.Length} balls."); } public override void OnDeactivate() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<Transform, Vector3> originalScale in _originalScales) { if ((Object)(object)originalScale.Key != (Object)null) { originalScale.Key.localScale = originalScale.Value; } } foreach (KeyValuePair<Transform, Vector3> originalPosition in _originalPositions) { if ((Object)(object)originalPosition.Key != (Object)null) { originalPosition.Key.localPosition = originalPosition.Value; } } _originalScales.Clear(); _originalPositions.Clear(); GolfMayhemPlugin.Log.LogInfo((object)"[GiantMode] Restored original scales."); } } public class GolfCartChaosEvent : ChaosEvent { private static MethodInfo _serverEnter; public override string DisplayName => "Golf Cart Chaos"; public override string NetworkId => "GolfCartChaos"; public override string WarnMessage => "Something's approaching..."; public override string ActivateMessage => "Everyone now has golf carts!"; public override float Weight => Configuration.WeightGolfCartChaos.Value; public override bool IsEnabled => Configuration.EnableGolfCartChaos.Value; public override void OnActivate() { //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { return; } if (_serverEnter == null) { _serverEnter = typeof(GolfCartInfo).GetMethod("ServerEnter", BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[1] { typeof(PlayerInfo) }, null); if (_serverEnter == null) { GolfMayhemPlugin.Log.LogError((object)"[GolfCartChaos] Could not find GolfCartInfo.ServerEnter!"); return; } } GolfCartInfo prefab = GameManager.GolfCartSettings.Prefab; if ((Object)(object)prefab == (Object)null) { GolfMayhemPlugin.Log.LogError((object)"[GolfCartChaos] GolfCartSettings.Prefab is null!"); return; } List<PlayerInfo> list = new List<PlayerInfo>(); if ((Object)(object)GameManager.LocalPlayerInfo != (Object)null) { list.Add(GameManager.LocalPlayerInfo); } foreach (PlayerInfo remotePlayer in GameManager.RemotePlayers) { list.Add(remotePlayer); } int num = 0; foreach (PlayerInfo item in list) { if ((Object)(object)item == (Object)null) { continue; } GolfCartInfo val = Object.Instantiate<GolfCartInfo>(prefab, ((Component)item).transform.position, Quaternion.Euler(0f, ((Component)item).transform.eulerAngles.y, 0f)); if ((Object)(object)val == (Object)null) { GolfMayhemPlugin.Log.LogError((object)("[GolfCartChaos] Cart failed to instantiate for " + item.PlayerId.PlayerName)); continue; } val.ServerReserveDriverSeatPreNetworkSpawn(item); NetworkServer.Spawn(((Component)val).gameObject, (NetworkConnectionToClient)null); val.ServerReserveDriverSeatPostNetworkSpawn(); NetworkConnectionToClient connectionToClient = ((NetworkBehaviour)item).connectionToClient; if (connectionToClient != null) { NetworkIdentity component = ((Component)val).GetComponent<NetworkIdentity>(); if (component != null) { component.AssignClientAuthority(connectionToClient); } } try { _serverEnter.Invoke(val, new object[1] { item }); num++; GolfMayhemPlugin.Log.LogInfo((object)("[GolfCartChaos] Spawned and seated " + item.PlayerId.PlayerName + ".")); } catch (Exception ex) { GolfMayhemPlugin.Log.LogError((object)("[GolfCartChaos] ServerEnter failed for " + item.PlayerId.PlayerName + ": " + ex.Message)); } } GolfMayhemPlugin.Log.LogInfo((object)$"[GolfCartChaos] Done. {num}/{list.Count} players seated."); } public override void OnDeactivate() { GolfMayhemPlugin.Log.LogInfo((object)"[GolfCartChaos] Deactivated."); } } public class GolfCartRaceEvent : ChaosEvent { private const float TRACK_HEIGHT = 100f; private const float TRACK_WIDTH = 42f; private const float TRACK_THICKNESS = 0.8f; private const float WALL_HEIGHT = 4f; private const float WALL_THICKNESS = 1.2f; private const float LOOP_W = 160f; private const float LOOP_D = 80f; private const int CURVE_SEG = 24; private const float GRID_SPACING_Z = 10f; private NightTimeEvent night; private static readonly Color COL_ROAD = new Color(0.15f, 0.15f, 0.18f); private static readonly Color COL_KERB_R = new Color(0.9f, 0.1f, 0.1f); private static readonly Color COL_KERB_W = new Color(0.95f, 0.95f, 0.95f); private static readonly Color COL_START = new Color(0.95f, 0.85f, 0.1f); private static readonly Color COL_FINISH = new Color(0.1f, 0.8f, 0.2f); private static readonly Color COL_BARRIER = new Color(0.85f, 0.5f, 0.05f); private static readonly Color COL_CHECKPOINT = new Color(0.6f, 0.1f, 0.9f); private static MethodInfo _serverEnter; private readonly List<GameObject> _trackObjects = new List<GameObject>(); private readonly List<GolfCartInfo> _raceCarts = new List<GolfCartInfo>(); private readonly List<PlayerInfo> _racers = new List<PlayerInfo>(); private readonly List<PlayerInfo> _finishOrder = new List<PlayerInfo>(); private readonly HashSet<PlayerInfo> _checkpointPassed = new HashSet<PlayerInfo>(); private readonly Dictionary<PlayerInfo, int> _lapCounts = new Dictionary<PlayerInfo, int>(); private readonly Dictionary<PlayerInfo, Vector3> _preTeleportPositions = new Dictionary<PlayerInfo, Vector3>(); private GameObject _finishTriggerObj; private GameObject _checkpointTriggerObj; private Vector3 _trackOrigin; private Coroutine _raceCoroutine; public static bool RaceActive { get; private set; } public static bool RaceStarting { get; private set; } public override string DisplayName => "Golf Cart Race"; public override string NetworkId => "GolfCartRace"; public override string WarnMessage => "Start your engines..."; public override string ActivateMessage => "Golf Cart race! First to complete one lap wins!"; public override float Weight => Configuration.WeightGolfCartRace.Value; public override bool IsEnabled => Configuration.EnableGolfCartRace.Value; public override float Duration => float.MaxValue; public override void OnActivate() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) if (RaceActive) { GolfMayhemPlugin.Log.LogWarning((object)"[GolfCartRace] OnActivate called while already active — ignoring."); return; } RaceActive = true; _trackOrigin = new Vector3(((Component)GolfHoleManager.MainHole).transform.position.x, 100f, ((Component)GolfHoleManager.MainHole).transform.position.z); PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo; if ((Object)(object)localPlayerInfo != (Object)null) { BoundsManager.DeregisterLevelBoundsTracker(localPlayerInfo.LevelBoundsTracker); } _trackObjects.Clear(); BuildTrack(); if (!NetworkServer.active || !CacheServerEnter()) { return; } _racers.Clear(); _lapCounts.Clear(); _finishOrder.Clear(); _raceCarts.Clear(); _checkpointPassed.Clear(); _preTeleportPositions.Clear(); if ((Object)(object)GameManager.LocalPlayerInfo != (Object)null) { _racers.Add(GameManager.LocalPlayerInfo); } foreach (PlayerInfo item in new List<PlayerInfo>(GameManager.RemotePlayers)) { if ((Object)(object)item != (Object)null) { _racers.Add(item); } } _racers.Sort((PlayerInfo a, PlayerInfo b) => a.PlayerId.Guid.CompareTo(b.PlayerId.Guid)); foreach (PlayerInfo racer in _racers) { _lapCounts[racer] = 0; } foreach (PlayerInfo racer2 in _racers) { if ((Object)(object)racer2 != (Object)null) { _preTeleportPositions[racer2] = ((Component)racer2).transform.position; } } night = new NightTimeEvent(); night.OnActivate(); _raceCoroutine = ((MonoBehaviour)ChaosEventManager.Instance).StartCoroutine(RaceRoutine()); } public override void OnDeactivate() { if (!RaceActive) { return; } RaceActive = false; RaceStarting = false; if (_raceCoroutine != null) { ChaosEventManager instance = ChaosEventManager.Instance; if (instance != null) { ((MonoBehaviour)instance).StopCoroutine(_raceCoroutine); } } night.OnDeactivate(); UnsubscribeTriggers(); Cleanup(); } private void SubscribeTriggers() { if ((Object)(object)_finishTriggerObj != (Object)null) { FinishLineTrigger component = _finishTriggerObj.GetComponent<FinishLineTrigger>(); if ((Object)(object)component != (Object)null) { component.ClearCooldowns(); component.OnCartCrossed += OnCartCrossedFinishLine; } } if ((Object)(object)_checkpointTriggerObj != (Object)null) { CheckpointTrigger component2 = _checkpointTriggerObj.GetComponent<CheckpointTrigger>(); if ((Object)(object)component2 != (Object)null) { component2.ClearCooldowns(); component2.OnCartCrossed += OnCartCrossedCheckpoint; } } } private void UnsubscribeTriggers() { if ((Object)(object)_finishTriggerObj != (Object)null) { FinishLineTrigger component = _finishTriggerObj.GetComponent<FinishLineTrigger>(); if ((Object)(object)component != (Object)null) { component.OnCartCrossed -= OnCartCrossedFinishLine; } } if ((Object)(object)_checkpointTriggerObj != (Object)null) { CheckpointTrigger component2 = _checkpointTriggerObj.GetComponent<CheckpointTrigger>(); if ((Object)(object)component2 != (Object)null) { component2.OnCartCrossed -= OnCartCrossedCheckpoint; } } } private void BuildTrack() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00f2: Unknown result type (might be due to invalid IL or missing references) float num = 80f; float num2 = 40f; BuildStraight(new Vector3(0f - num, 0f, num2), new Vector3(num, 0f, num2), kerbAlt: false); BuildStraight(new Vector3(0f - num, 0f, 0f - num2), new Vector3(num, 0f, 0f - num2), kerbAlt: true); BuildCurve(new Vector3(0f - num, 0f, 0f), num2, 90f, 270f, kerbAlt: false); BuildCurve(new Vector3(num, 0f, 0f), num2, 270f, 90f, kerbAlt: true); float num3 = 0f - num + 20f; BuildStartLine(new Vector3(num3, 0f, num2)); BuildFinishLine(new Vector3(num3 + 42f + 4f, 0f, num2)); BuildCheckpoint(new Vector3(num3 + 42f + 4f, 0f, 0f - num2)); } private void BuildStraight(Vector3 a, Vector3 b, bool kerbAlt, float overlapFactor = 1f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0016: 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_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_002c: 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_004e: 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_0052: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00cf: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_013e: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) Vector3 val = b - a; float num = ((Vector3)(ref val)).magnitude * overlapFactor; Vector3 val2 = (a + b) * 0.5f; float num2 = Mathf.Atan2(val.x, val.z) * 57.29578f; Quaternion val3 = Quaternion.Euler(0f, num2, 0f); Vector3 val4 = val3 * Vector3.right; float num3 = 1.2f; Color color = (kerbAlt ? COL_KERB_W : COL_KERB_R); AddBlock(_trackOrigin + val2, new Vector3(42f, 0.8f, num), val3, COL_ROAD); AddBlock(_trackOrigin + val2 + val4 * (21f + num3 * 0.5f), new Vector3(num3, 4f, num), val3, color); AddBlock(_trackOrigin + val2 - val4 * (21f + num3 * 0.5f), new Vector3(num3, 4f, num), val3, color); AddBlock(_trackOrigin + val2 + val4 * (21f + num3 * 0.5f) + Vector3.up * 4f, new Vector3(num3 * 0.4f, 0.6f, num), val3, COL_BARRIER); AddBlock(_trackOrigin + val2 - val4 * (21f + num3 * 0.5f) + Vector3.up * 4f, new Vector3(num3 * 0.4f, 0.6f, num), val3, COL_BARRIER); } private void BuildCurve(Vector3 centre, float radius, float startDeg, float endDeg, bool kerbAlt) { //IL_0048: 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_006a: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_0093: Unknown result type (might be due to invalid IL or missing references) float num = endDeg - startDeg; if (num < 0f) { num += 360f; } float num2 = num / 24f; for (int i = 0; i < 24; i++) { float num3 = (startDeg + num2 * (float)i) * ((float)Math.PI / 180f); float num4 = (startDeg + num2 * (float)(i + 1)) * ((float)Math.PI / 180f); Vector3 a = centre + new Vector3(Mathf.Cos(num3) * radius, 0f, Mathf.Sin(num3) * radius); Vector3 b = centre + new Vector3(Mathf.Cos(num4) * radius, 0f, Mathf.Sin(num4) * radius); BuildStraight(a, b, (i % 2 == 0) ? kerbAlt : (!kerbAlt), 2f); } } private void BuildStartLine(Vector3 rel) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0022: 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) //IL_0040: 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_0053: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) AddBlock(_trackOrigin + rel + new Vector3(0f, 0.42000002f, -10.5f), new Vector3(2f, 0.05f, 21f), Quaternion.identity, COL_START); AddBlock(_trackOrigin + rel + new Vector3(0f, 0.42000002f, 10.5f), new Vector3(2f, 0.05f, 21f), Quaternion.identity, COL_KERB_W); } private void BuildFinishLine(Vector3 rel) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_00ae: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_015b: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = _trackOrigin + rel; _finishTriggerObj = new GameObject("GolfCartRaceFinishLine"); _finishTriggerObj.transform.position = val + Vector3.up * 2f; _finishTriggerObj.transform.rotation = Quaternion.identity; _finishTriggerObj.transform.localScale = new Vector3(2f, 4f, 42f); ((Collider)_finishTriggerObj.AddComponent<BoxCollider>()).isTrigger = true; _finishTriggerObj.AddComponent<FinishLineTrigger>(); AddBlock(val + new Vector3(0f, 0.42000002f, 0f), new Vector3(2f, 0.05f, 42f), Quaternion.identity, COL_FINISH); AddBlock(val + new Vector3(0f, 8f, 0f), new Vector3(0.5f, 0.5f, 48f), Quaternion.identity, COL_FINISH); AddBlock(val + new Vector3(0f, 4f, -24f), new Vector3(0.5f, 8f, 0.5f), Quaternion.identity, COL_BARRIER); AddBlock(val + new Vector3(0f, 4f, 24f), new Vector3(0.5f, 8f, 0.5f), Quaternion.identity, COL_BARRIER); } private void BuildCheckpoint(Vector3 rel) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_00ae: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_015b: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = _trackOrigin + rel; _checkpointTriggerObj = new GameObject("GolfCartRaceCheckpoint"); _checkpointTriggerObj.transform.position = val + Vector3.up * 2f; _checkpointTriggerObj.transform.rotation = Quaternion.identity; _checkpointTriggerObj.transform.localScale = new Vector3(2f, 4f, 42f); ((Collider)_checkpointTriggerObj.AddComponent<BoxCollider>()).isTrigger = true; _checkpointTriggerObj.AddComponent<CheckpointTrigger>(); AddBlock(val + new Vector3(0f, 0.42000002f, 0f), new Vector3(2f, 0.05f, 42f), Quaternion.identity, COL_CHECKPOINT); AddBlock(val + new Vector3(0f, 8f, 0f), new Vector3(0.5f, 0.5f, 48f), Quaternion.identity, COL_CHECKPOINT); AddBlock(val + new Vector3(0f, 4f, -24f), new Vector3(0.5f, 8f, 0.5f), Quaternion.identity, COL_BARRIER); AddBlock(val + new Vector3(0f, 4f, 24f), new Vector3(0.5f, 8f, 0.5f), Quaternion.identity, COL_BARRIER); } private void AddBlock(Vector3 pos, Vector3 scale, Quaternion rot, Color color) { //IL_000e: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive((PrimitiveType)3); val.transform.position = pos; val.transform.localScale = scale; val.transform.rotation = rot; val.layer = LayerMask.NameToLayer("Default"); Renderer component = val.GetComponent<Renderer>(); if ((Object)(object)component != (Object)null) { component.material = new Material(Shader.Find("Standard")); component.material.color = color; } _trackObjects.Add(val); } private Vector3 GetGridPosition(int index) { //IL_004b: 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_005e: 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_0067: Unknown result type (might be due to invalid IL or missing references) int num = index % 4; int num2 = index / 4; float num3 = 80f; float num4 = 40f; float num5 = 0f - num3 + 20f; float num6 = num4 - 21f + ((float)num + 0.5f) * 10.5f; float num7 = num5 - 4f - (float)num2 * 10f; return _trackOrigin + new Vector3(num7, 2.8f, num6); } private void SpawnCarts() { //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) GolfCartInfo prefab = GameManager.GolfCartSettings.Prefab; if ((Object)(object)prefab == (Object)null) { return; } for (int i = 0; i < _racers.Count; i++) { PlayerInfo val = _racers[i]; GolfCartInfo val2 = Object.Instantiate<GolfCartInfo>(prefab, GetGridPosition(i), Quaternion.Euler(0f, 90f, 0f)); if (!((Object)(object)val2 == (Object)null)) { val2.ServerReserveDriverSeatPreNetworkSpawn(val); NetworkConnectionToClient connectionToClient = ((NetworkBehaviour)val).connectionToClient; NetworkServer.Spawn(((Component)val2).gameObject, connectionToClient); val2.ServerReserveDriverSeatPostNetworkSpawn(); Entity asEntity = val2.AsEntity; LevelBoundsTracker val3 = ((asEntity != null) ? asEntity.LevelBoundsTracker : null); if ((Object)(object)val3 != (Object)null) { BoundsManager.DeregisterLevelBoundsTracker(val3); val3.InformLevelBoundsStateChanged((BoundsState)0); } try { _serverEnter.Invoke(val2, new object[1] { val }); _raceCarts.Add(val2); GolfMayhemPlugin.Log.LogInfo((object)$"[GolfCartRace] Seated {val.PlayerId.PlayerName} at grid {i}."); } catch (Exception ex) { GolfMayhemPlugin.Log.LogError((object)("[GolfCartRace] ServerEnter failed for " + val.PlayerId.PlayerName + ": " + ex.Message)); } } } } private void OnCartCrossedCheckpoint(GolfCartInfo cart) { PlayerInfo val = default(PlayerInfo); if (RaceActive && !((Object)(object)cart == (Object)null) && cart.TryGetDriver(ref val) && _lapCounts.ContainsKey(val)) { _checkpointPassed.Add(va