using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using Mirror; using Steamworks; using Steamworks.Data; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("ProGolfMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ProGolfMod")] [assembly: AssemblyTitle("ProGolfMod")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ProGolfMod { [BepInPlugin("codex.superbattlegolf.progolfplus", "Pro Golf Plus", "0.1.43")] public sealed class ProGolfPlugin : BaseUnityPlugin { private sealed class DriveCandidate { public PlayerInfo Player; public ulong PlayerGuid; public Vector3 StartPosition; } private sealed class FirstDriveResult { public string PlayerName; public float Distance; public bool IsValid; } private sealed class ClosestToPinResult { public string PlayerName; public float Distance; public bool IsValid; } private sealed class CartFlipState { public WheelCollider[] Wheels = Array.Empty(); public bool WasUprightOnWheels; public bool FlipInProgress; public int CurrentFlipStreak; public float AccumulatedFlipRadians; public float LastFlipPollTime = -1f; public float SettledSince = -1f; public ulong ResponsiblePlayerGuid; public string ResponsiblePlayerName; } [HarmonyPatch(typeof(CourseManager), "BeginCountdownToMatchEnd")] private static class SkipFirstFinishCountdownPatch { private static bool Prefix(CourseManager __instance) { if (!IsProGolfScoringActive() || (Object)(object)__instance == (Object)null) { return true; } if (ShouldBlockNativeEndCountdown(__instance)) { return false; } if (AllActivePlayersResolved(__instance)) { TryAnnounceClosestToPinIfReady(); TryAnnounceHoleStatsIfReady(); return true; } ProGolfPlugin instance = ProGolfPlugin.instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)"Skipped Pro Golf end-of-hole countdown because active players are still playing."); } return false; } } [HarmonyPatch(typeof(CourseManager), "CountDownToMatchEndRoutine")] private static class SkipMatchEndCountdownRoutinePatch { private static bool Prefix(CourseManager __instance, ref IEnumerator __result) { if (ShouldBlockNativeEndCountdown(__instance)) { __result = EmptyReadyUpHoldRoutine(); return false; } return true; } } [HarmonyPatch(typeof(CourseManager), "OnMatchStateChanged")] private static class HoldReadyUpMatchStatePatch { private static bool Prefix(CourseManager __instance, MatchState previousState, MatchState currentState) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (suppressReadyMatchStateRollback || (int)currentState != 4 || !ShouldBlockNativeEndCountdown(__instance)) { return true; } RollBackReadyUpMatchState(__instance, (MatchState)(((int)previousState == 4) ? 3 : ((int)previousState))); return false; } } [HarmonyPatch(typeof(CourseManager), "set_NetworkmatchState")] private static class BlockReadyUpMatchStateSetterPatch { private static bool Prefix(CourseManager __instance, ref MatchState value) { //IL_0002: 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_0014: Expected I4, but got Unknown MatchState replacementState = value; if (!TryBlockReadyUpMatchStateChange(__instance, value, ref replacementState)) { return true; } value = (MatchState)(int)replacementState; return true; } } [HarmonyPatch(typeof(CourseManager), "ServerStartNextMatch")] private static class BlockReadyUpNextMatchPatch { private static bool Prefix(CourseManager __instance) { if (!ShouldBlockNextMatchForReadyUp(__instance)) { return true; } return false; } } [HarmonyPatch(typeof(MatchEndCountdown), "Show")] private static class SuppressReadyCountdownShowPatch { private static bool Prefix() { return !ShouldSuppressReadyCountdownUi(); } } [HarmonyPatch(typeof(MatchEndCountdown), "SetTime")] private static class SuppressReadyCountdownSetTimePatch { private static bool Prefix() { if (!ShouldSuppressReadyCountdownUi()) { return true; } MatchEndCountdown.Hide(); return false; } } [HarmonyPatch(typeof(MatchEndCountdown), "EnterOvertime")] private static class SuppressReadyCountdownOvertimePatch { private static bool Prefix() { if (!ShouldSuppressReadyCountdownUi()) { return true; } MatchEndCountdown.Hide(); return false; } } [HarmonyPatch(typeof(CourseManager), "OnPlayerStatesChanged")] private static class AnnounceHoleStatsOnPlayerStateChangedPatch { private static void Postfix(CourseManager __instance) { if (!((Object)(object)__instance == (Object)null) && NetworkServer.active && IsProGolfScoringActive() && AllActivePlayersResolved(__instance)) { TryAnnounceClosestToPinIfReady(); TryAnnounceHoleStatsIfReady(); OpenReadyGateForCurrentHole(); } } } [HarmonyPatch(typeof(PlayerState), "CompareTo")] private static class ProGolfStrokeFirstPlayerStateSortPatch { private static bool Prefix(PlayerState __instance, PlayerState other, ref int __result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return !TryCompareProGolfPlayerStates(__instance, other, ref __result); } } [HarmonyPatch(typeof(ScoreboardEntry), "PopulateWith")] private static class ProGolfScoreboardEntryStatsPatch { private static void Postfix(ScoreboardEntry __instance, PlayerState playerState) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) UpdateScoreboardEntryProGolfStats(__instance, playerState); } } [HarmonyPatch(typeof(Scoreboard), "Show")] private static class OpenReadyGateOnScoreboardShowPatch { private static void Postfix() { if (NetworkServer.active && IsReadyScoreboardWindowActive()) { OpenReadyGateForCurrentHole(); } } } [HarmonyPatch(typeof(Scoreboard), "Refresh")] private static class ProGolfScoreboardStatCardPatch { private static void Postfix(Scoreboard __instance) { UpdateScoreboardProGolfStatCard(__instance); } } [HarmonyPatch(typeof(PlayerGolfer), "InformScored")] private static class CaptureClosestToPinOnScorePatch { private static void Prefix(PlayerGolfer __instance) { CaptureClosestToPinOnScore(__instance); } } [HarmonyPatch(typeof(CourseManager), "TryPlayHoleMusic")] private static class ForceNormalHoleMusicPatch { private static void Prefix(ref bool hurryUpInstantly) { if (IsActiveProGolf()) { hurryUpInstantly = false; } } } [HarmonyPatch(typeof(CourseManager), "HurryUpHoleMusic")] private static class PreventHurryUpMusicPatch { private static bool Prefix() { return !IsActiveProGolf(); } } [HarmonyPatch(typeof(GolfBall), "OnWillApplyGolfSwingHitPhysics")] private static class BeginLongestDriveTrackingPatch { private static void Prefix(GolfBall __instance) { BeginDriveTracking(__instance); } } [HarmonyPatch(typeof(PlayerGolfer), "OnPlayerHitOwnBall")] private static class TrackPerfectShotPatch { private static void Postfix(PlayerGolfer __instance) { TrackPerfectShot(__instance); } } [HarmonyPatch(typeof(GolfBall), "set_IsStationary")] private static class CompleteLongestDriveTrackingPatch { private static void Postfix(GolfBall __instance, bool value) { if (value) { TryCompleteDriveTracking(__instance); TryCaptureClosestToPinFromStationaryBall(__instance); } } } [HarmonyPatch(typeof(CourseManager), "AddPenaltyStroke")] private static class InvalidatePenaltyDrivePatch { private static void Prefix(PlayerGolfer penalizedPlayer) { InvalidateFirstDrive((penalizedPlayer != null) ? penalizedPlayer.PlayerInfo : null); } } [HarmonyPatch(typeof(PlayerGolfer), "ServerEliminate")] private static class HazardEliminationRespawnPatch { private static bool Prefix(PlayerGolfer __instance, EliminationReason immediateEliminationReason) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (TryRespawnHazardEliminationAtBall(__instance, immediateEliminationReason)) { return false; } MarkBallRespawnForHazardElimination(__instance, immediateEliminationReason); return true; } } [HarmonyPatch(typeof(PlayerMovement), "TryBeginRespawn")] private static class BeginRespawnAtBallPatch { private static void Prefix(PlayerMovement __instance, ref RespawnTarget respawnTarget) { RedirectHazardRespawnToBall(__instance, ref respawnTarget); } } [HarmonyPatch(typeof(PlayerMovement), "CmdPlayOutOfBoundsEliminationExplosionForAllClients")] private static class SuppressPlayerOutOfBoundsExplosionCommandPatch { private static bool Prefix() { return !IsActiveProGolf(); } } [HarmonyPatch(typeof(PlayerMovement), "RpcPlayOutOfBoundsEliminationExplosion")] private static class SuppressPlayerOutOfBoundsExplosionRpcPatch { private static bool Prefix() { return !IsActiveProGolf(); } } [HarmonyPatch(typeof(PlayerMovement), "PlayOutOfBoundsEliminationExplosionInternal")] private static class SuppressPlayerOutOfBoundsExplosionPatch { private static bool Prefix() { return !IsActiveProGolf(); } } [HarmonyPatch(typeof(GolfCartInfo), "ServerPlayOutOfBoundsEliminationExplosionForAllClients")] private static class SuppressCartOutOfBoundsExplosionServerPatch { private static bool Prefix() { return !IsActiveProGolf(); } } [HarmonyPatch(typeof(GolfCartInfo), "RpcPlayOutOfBoundsEliminationExplosion")] private static class SuppressCartOutOfBoundsExplosionRpcPatch { private static bool Prefix() { return !IsActiveProGolf(); } } [HarmonyPatch(typeof(GolfCartInfo), "PlayOutOfBoundsEliminationExplosionInternal")] private static class SuppressCartOutOfBoundsExplosionPatch { private static bool Prefix() { return !IsActiveProGolf(); } } [HarmonyPatch(typeof(PlayerGolfer), "CanMove")] private static class AllowMovementAfterHoleOutPatch { private static void Postfix(PlayerGolfer __instance, ref bool __result) { if (IsActiveProGolf() && HasPlayerScoredThisHole(__instance)) { __result = true; } } } [HarmonyPatch(typeof(GolfHole), "ServerOnBallScored")] private static class SuppressHoleOutScoreBlastPatch { private static bool Prefix() { return !IsActiveProGolf(); } } [HarmonyPatch(typeof(PlayerInfo), "RpcPopUpPlacementScore")] private static class SuppressPlacementScorePopupPatch { private static bool Prefix(PlayerInfo __instance) { if (!IsActiveProGolf()) { return true; } ShowProGolfHoleOutPopup(__instance); return false; } } [HarmonyPatch] private static class SuppressPlacementScorePopupUserCodePatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(PlayerInfo), "UserCode_RpcPopUpPlacementScore__Int32__Int32", (Type[])null, (Type[])null); } private static bool Prefix(PlayerInfo __instance) { if (!IsActiveProGolf()) { return true; } ShowProGolfHoleOutPopup(__instance); return false; } } [HarmonyPatch(typeof(PlayerInfo), "RpcPopUp")] private static class SuppressScorePopupPatch { private static bool Prefix(PlayerTextPopupType popupType) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (IsActiveProGolf()) { return !IsProGolfScorePopupType(popupType); } return true; } } [HarmonyPatch] private static class SuppressScorePopupUserCodePatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(PlayerInfo), "UserCode_RpcPopUp__PlayerTextPopupType__Int32", (Type[])null, (Type[])null); } private static bool Prefix(PlayerInfo __instance, PlayerTextPopupType popupType) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!IsActiveProGolf() || !IsProGolfScorePopupType(popupType)) { return true; } if (HasPlayerScoredThisHole((__instance != null) ? __instance.AsGolfer : null)) { ShowProGolfHoleOutPopup(__instance); } return false; } } [HarmonyPatch(typeof(PlayerInfo), "PopUpInternal")] private static class SuppressNativePlayerPopupInternalPatch { private static bool Prefix(PlayerInfo __instance) { if (!IsActiveProGolf() || isShowingProGolfHoleOutPopup) { return true; } if (HasPlayerScoredThisHole((__instance != null) ? __instance.AsGolfer : null)) { ShowProGolfHoleOutPopup(__instance); } return false; } } [HarmonyPatch(typeof(Checkpoint), "Awake")] private static class HideCheckpointOnAwakePatch { private static void Postfix(Checkpoint __instance) { if (IsActiveProGolf()) { SuppressCheckpointVisuals(__instance); } } } [HarmonyPatch(typeof(PlayerInventorySettings), "get_MaxItems")] private static class MinimumProGolfInventoryPatch { private static void Postfix(ref int __result) { if (IsActiveProGolf()) { __result = 3; } } } [HarmonyPatch(typeof(PlayerInventory), "OnStartServer")] private static class ServerStartLoadoutPatch { private static void Postfix(PlayerInventory __instance) { EnsureProGolfLoadout(__instance); } } [HarmonyPatch(typeof(PlayerInventory), "OnStartLocalPlayer")] private static class LocalStartLoadoutPatch { private static void Postfix(PlayerInventory __instance) { EnsureProGolfLoadout(__instance); } } [HarmonyPatch(typeof(PlayerInventory), "ServerTryAddItem")] private static class ProGolfItemGrantPatch { private static bool Prefix(PlayerInventory __instance, ItemType itemToAdd, ref bool __result) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 if (!IsActiveProGolf() || !NetworkServer.active) { return true; } EnsureProGolfLoadout(__instance); if ((int)itemToAdd == 6 || (int)itemToAdd == 1 || (int)itemToAdd == 5) { __result = true; return false; } __result = false; return false; } } [HarmonyPatch(typeof(ItemPool), "GetWeightedRandomItem")] private static class RemovePermanentItemsFromItemPoolsPatch { private static bool Prefix(ItemPool __instance, ref ItemType __result) { if (!IsActiveProGolf()) { return true; } return !TryGetWeightedRandomAllowedPickupItem(__instance, out __result); } } [HarmonyPatch(typeof(ItemSpawner), "OnStartServer")] private static class HideInitialItemSpawnersPatch { private static void Postfix(ItemSpawner __instance) { if (IsActiveProGolf() && (Object)(object)__instance != (Object)null) { SuppressItemSpawner(__instance); } } } [HarmonyPatch(typeof(ItemSpawner), "ServerSpawnItemBox")] private static class PreventItemSpawnerRespawnsPatch { private static bool Prefix(ItemSpawner __instance) { if (!IsActiveProGolf()) { return true; } if ((Object)(object)__instance != (Object)null) { SuppressItemSpawner(__instance); } return false; } } [HarmonyPatch(typeof(PlayerInventory), "DecrementUseFromSlotAt")] private static class KeepPermanentItemsLoadedPatch { private static bool Prefix(PlayerInventory __instance, int index) { return !IsReservedPermanentSlot(__instance, index); } } [HarmonyPatch(typeof(PlayerInventory), "RemoveIfOutOfUses")] private static class PreventPermanentItemsRemovalPatch { private static bool Prefix(PlayerInventory __instance, int index) { return !IsReservedPermanentSlot(__instance, index); } } [HarmonyPatch(typeof(PlayerInventory), "DropItem")] private static class PreventDroppingPermanentItemsPatch { private static bool Prefix(PlayerInventory __instance) { return !IsReservedPermanentSlot(__instance, __instance.EquippedItemIndex); } } private const string PluginGuid = "codex.superbattlegolf.progolfplus"; private const string PluginName = "Pro Golf Plus"; private const string PluginVersion = "0.1.43"; private const string LobbyMemberVersionKey = "codex_progolfplus_member_version"; private const string LobbyRequiredVersionKey = "codex_progolfplus_required_version"; private const string LobbyActiveStateKey = "codex_progolfplus_active"; private const string LobbyActiveVersionKey = "codex_progolfplus_active_version"; private const string LobbyAnnouncementTextKey = "codex_progolfplus_announcement_text"; private const string LobbyAnnouncementVersionKey = "codex_progolfplus_announcement_version"; private const string LobbyHoleStatsPayloadKey = "codex_progolfplus_hole_stats_payload"; private const string LobbyHoleStatsVersionKey = "codex_progolfplus_hole_stats_version"; private const string LobbyReadyHoleKey = "codex_progolfplus_ready_hole"; private const string LobbyReadyGateHoleKey = "codex_progolfplus_ready_gate_hole"; private const string LobbyReadyGateVersionKey = "codex_progolfplus_ready_gate_version"; private const float LobbyPollInterval = 1f; private const float LocalMemberVersionPublishInterval = 2f; private const int ReservedCartSlotIndex = 0; private const int ReservedCoffeeSlotIndex = 1; private const int ReservedSpringBootsSlotIndex = 2; private const int TotalInventorySlots = 3; private const float CartFlipPollInterval = 0.25f; private const float CartDiscoveryPollInterval = 1f; private const float CartUprightDotThreshold = 0.65f; private const float CartMovingSpeedThreshold = 0.35f; private const float CartMovingAngularThreshold = 0.35f; private const float CartFlipStartAngularThreshold = 1f; private const float CartFlipFullRotationRadians = (float)Math.PI * 2f; private const float CartSettledSeconds = 0.5f; private const float ClosestToPinRadiusMeters = 9.144f; private static ProGolfPlugin instance; private static FieldInfo inventorySlotsField; private static FieldInfo itemPoolSpawnChancesField; private static FieldInfo itemSpawnerVisualsField; private static FieldInfo itemSpawnerPickupColliderField; private static FieldInfo itemSpawnerVisualsFillingObjectField; private static FieldInfo itemSpawnerVisualsIdleObjectField; private static FieldInfo itemSpawnerVisualsFillRendererField; private static FieldInfo itemSpawnerVisualsAnimatorField; private static FieldInfo checkpointVisualCenterField; private static FieldInfo checkpointBaseMeshField; private static FieldInfo checkpointScreenMeshField; private static FieldInfo checkpointAnimatorField; private static FieldInfo scoreboardEntryStatsBackgroundField; private static FieldInfo scoreboardEntryNameField; private static FieldInfo scoreboardEntryParentField; private static FieldInfo scoreboardBestHoleScoreStatField; private static FieldInfo scoreboardLongestChipInStatField; private static FieldInfo scoreboardItemPickupsStatField; private static FieldInfo scoreboardKnockoutRatioStatField; private static FieldInfo scoreboardStatLabelField; private static FieldInfo golfBallIsInHoleField; private static MethodInfo scoreboardMarkDirtyMethod; private static MethodInfo playerPopUpTextMethod; private static bool isShowingProGolfHoleOutPopup; private static bool allLobbyMembersCompatible = true; private static string incompatibleLobbyMembers = string.Empty; private static float nextLobbyPollTime; private static float nextLocalMemberVersionPublishTime; private static float nextCompatibilityWarningTime; private static bool lastPublishedActiveState; private static string lastObservedActiveVersion = string.Empty; private static bool hasObservedActiveState; private static bool lastObservedActiveState; private static string lastObservedHoleStatsVersion = string.Empty; private static string lastObservedReadyGateVersion = string.Empty; private static int observedReadyGateHoleIndex = int.MinValue; private static readonly Dictionary activeDrives = new Dictionary(); private static readonly Dictionary firstDriveResults = new Dictionary(); private static readonly Dictionary closestToPinResults = new Dictionary(); private static readonly Dictionary perfectShotCounts = new Dictionary(); private static readonly Dictionary cartBestFlipStreaks = new Dictionary(); private static readonly Dictionary scoreboardRowRelativeScoreTexts = new Dictionary(); private static readonly Dictionary parByHoleIndex = new Dictionary(); private static readonly Dictionary holeStatsLongestDriveDistances = new Dictionary(); private static readonly Dictionary holeStatsClosestToPinDistances = new Dictionary(); private static readonly Dictionary holeStatsChipInDistances = new Dictionary(); private static readonly HashSet holeOutPopupsShown = new HashSet(); private static readonly Dictionary cartFlipStates = new Dictionary(); private static readonly HashSet forceNextRespawnAtBall = new HashSet(); private static readonly HashSet suppressedItemSpawners = new HashSet(); private static readonly HashSet suppressedCheckpoints = new HashSet(); private static readonly List cachedCarts = new List(); private static readonly List staleCarts = new List(); private static int longestDriveHoleIndex = int.MinValue; private static bool longestDriveAnnounced; private static bool closestToPinAnnounced; private static bool holeStatsAnnounced; private static string lastObservedAnnouncementVersion = string.Empty; private static string topAnnouncementText = string.Empty; private static string topAnnouncementDetailText = string.Empty; private static float topAnnouncementVisibleUntil; private static float nextCartFlipPollTime; private static float nextCartDiscoveryPollTime; private static GUIStyle topAnnouncementBoxStyle; private static GUIStyle topAnnouncementTextStyle; private static GUIStyle topAnnouncementDetailStyle; private static GUIStyle readyUpBoxStyle; private static GUIStyle readyUpHeaderStyle; private static GUIStyle readyUpRowStyle; private static GUIStyle readyUpPromptStyle; private static Texture2D topAnnouncementBoxTexture; private static Texture2D readyUpBoxTexture; private static Texture2D proGolfCardHeaderTexture; private static Texture2D proGolfCardBandTexture; private static Texture2D proGolfReadyFlagTexture; private static Sprite proGolfCardHeaderSprite; private static Sprite proGolfCardBandSprite; private static Sprite proGolfReadyFlagSprite; private static readonly Dictionary scoreboardEntryStatLabels = new Dictionary(); private static readonly Dictionary scoreboardEntryReadyIndicators = new Dictionary(); private static readonly Dictionary scoreboardAllPlayerStatsPanels = new Dictionary(); private static readonly Dictionary scoreboardReadyUpPanels = new Dictionary(); private static int readyGateHoleIndex = int.MinValue; private static int readyGateCountdownTriggeredHoleIndex = int.MinValue; private static int localReadyHoleIndex = int.MinValue; private static int lastParTrackedHoleIndex = int.MinValue; private static float nextReadyGateLogTime; private static float nextReadyScoreboardRefreshTime; private static float nextReadyStateBlockLogTime; private static bool suppressReadyMatchStateRollback; private Harmony harmony; private ConfigEntry enabledConfig; private ConfigEntry readyUpBetweenHolesConfig; private ConfigEntry grantCheckIntervalConfig; private ConfigEntry longestDriveMinimumMetersConfig; private float nextGrantCheckTime; private void Awake() { //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Expected O, but got Unknown instance = this; enabledConfig = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Enable Pro Golf Plus."); readyUpBetweenHolesConfig = ((BaseUnityPlugin)this).Config.Bind("Ready Up", "Enabled", true, "Require every active Pro Golf player to press A before the host advances from the end-of-hole scoreboard."); grantCheckIntervalConfig = ((BaseUnityPlugin)this).Config.Bind("General", "GrantCheckIntervalSeconds", 0.5f, "How often the host checks whether every Pro Golf player needs a cart."); longestDriveMinimumMetersConfig = ((BaseUnityPlugin)this).Config.Bind("Longest Drive", "MinimumDistanceMeters", 15f, "Minimum drive distance required before a Longest Drive popup can appear."); inventorySlotsField = AccessTools.Field(typeof(PlayerInventory), "slots"); itemPoolSpawnChancesField = AccessTools.Field(typeof(ItemPool), "spawnChances"); itemSpawnerVisualsField = AccessTools.Field(typeof(ItemSpawner), "visuals"); itemSpawnerPickupColliderField = AccessTools.Field(typeof(ItemSpawner), "pickUpCollider"); itemSpawnerVisualsFillingObjectField = AccessTools.Field(typeof(ItemSpawnerVisuals), "fillingObj"); itemSpawnerVisualsIdleObjectField = AccessTools.Field(typeof(ItemSpawnerVisuals), "idleObj"); itemSpawnerVisualsFillRendererField = AccessTools.Field(typeof(ItemSpawnerVisuals), "fillMeshRenderer"); itemSpawnerVisualsAnimatorField = AccessTools.Field(typeof(ItemSpawnerVisuals), "animator"); checkpointVisualCenterField = AccessTools.Field(typeof(Checkpoint), "visualCenter"); checkpointBaseMeshField = AccessTools.Field(typeof(Checkpoint), "baseMesh"); checkpointScreenMeshField = AccessTools.Field(typeof(Checkpoint), "screenMesh"); checkpointAnimatorField = AccessTools.Field(typeof(Checkpoint), "animator"); scoreboardEntryStatsBackgroundField = AccessTools.Field(typeof(ScoreboardEntry), "statsBackground"); scoreboardEntryNameField = AccessTools.Field(typeof(ScoreboardEntry), "name"); scoreboardEntryParentField = AccessTools.Field(typeof(Scoreboard), "entryParent"); scoreboardBestHoleScoreStatField = AccessTools.Field(typeof(Scoreboard), "bestHoleScore"); scoreboardLongestChipInStatField = AccessTools.Field(typeof(Scoreboard), "longestChipIn"); scoreboardItemPickupsStatField = AccessTools.Field(typeof(Scoreboard), "itemPickups"); scoreboardKnockoutRatioStatField = AccessTools.Field(typeof(Scoreboard), "knockoutRatio"); scoreboardStatLabelField = AccessTools.Field(typeof(ScoreboardStat), "label"); golfBallIsInHoleField = AccessTools.Field(typeof(GolfBall), "isInHole"); scoreboardMarkDirtyMethod = AccessTools.Method(typeof(Scoreboard), "MarkDirty", (Type[])null, (Type[])null); playerPopUpTextMethod = AccessTools.Method(typeof(PlayerInfo), "PopUpText", new Type[2] { typeof(string), typeof(bool) }, (Type[])null); harmony = new Harmony("codex.superbattlegolf.progolfplus"); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Pro Golf Plus 0.1.43 loaded."); } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } DestroyTopAnnouncementStyles(); DestroyReadyUpStyles(); if (instance == this) { instance = null; } } private void OnGUI() { DrawTopAnnouncement(); } private void Update() { PollLobbyCompatibility(); PollReadyUpInput(); PollReadyUpScoreboards(); PollCartFlipStats(); if (IsProGolfScoringActive()) { TrackCurrentHolePar(); ResetLongestDriveIfHoleChanged(); } if (IsActiveProGolf() && !(Time.unscaledTime < nextGrantCheckTime)) { nextGrantCheckTime = Time.unscaledTime + Mathf.Max(0.25f, grantCheckIntervalConfig.Value); TryEnsureAllPlayersHaveProGolfLoadout(); TrySuppressAllItemSpawners(); TrySuppressCheckpoints(); } } private static bool IsActiveProGolf() { if ((Object)(object)instance == (Object)null || !instance.enabledConfig.Value) { return false; } if (NetworkServer.active && !allLobbyMembersCompatible) { return false; } if (!HostAllowsClientProGolf()) { return false; } if (IsCurrentPresetProGolf()) { return IsMatchUnderway(); } return false; } private static bool IsMatchUnderway() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 MatchState matchState = CourseManager.MatchState; if ((int)matchState >= 1) { return (int)matchState < 6; } return false; } private static bool IsProGolfScoringActive() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 if ((Object)(object)instance == (Object)null || !instance.enabledConfig.Value) { return false; } if (NetworkServer.active && !allLobbyMembersCompatible) { return false; } if (!HostAllowsClientProGolf()) { return false; } if (IsCurrentPresetProGolf()) { return (int)CourseManager.MatchState >= 1; } return false; } private static bool IsCurrentPresetProGolf() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 MatchSetupRules val = FindMatchSetupRules(); if ((Object)(object)val != (Object)null) { return (int)val.CurrentPreset == 1; } return false; } private static bool IsProGolfScoreboardState() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 if ((Object)(object)instance != (Object)null && instance.enabledConfig.Value && IsCurrentPresetProGolf()) { return (int)CourseManager.MatchState == 6; } return false; } private static bool HostAllowsClientProGolf() { if (NetworkClient.active && !NetworkServer.active && hasObservedActiveState) { return lastObservedActiveState; } return true; } private static void TrackCurrentHolePar() { int currentHoleGlobalIndex = CourseManager.CurrentHoleGlobalIndex; if (currentHoleGlobalIndex >= 0) { if (lastParTrackedHoleIndex != int.MinValue && currentHoleGlobalIndex < lastParTrackedHoleIndex) { parByHoleIndex.Clear(); } lastParTrackedHoleIndex = currentHoleGlobalIndex; int currentHoleParSafe = GetCurrentHoleParSafe(); if (currentHoleParSafe > 0) { parByHoleIndex[currentHoleGlobalIndex] = currentHoleParSafe; } } } private static void ResetLongestDriveIfHoleChanged() { int currentHoleGlobalIndex = CourseManager.CurrentHoleGlobalIndex; if (currentHoleGlobalIndex != longestDriveHoleIndex) { longestDriveHoleIndex = currentHoleGlobalIndex; longestDriveAnnounced = false; closestToPinAnnounced = false; holeStatsAnnounced = false; readyGateHoleIndex = int.MinValue; readyGateCountdownTriggeredHoleIndex = int.MinValue; localReadyHoleIndex = int.MinValue; observedReadyGateHoleIndex = int.MinValue; nextReadyGateLogTime = 0f; nextReadyStateBlockLogTime = 0f; activeDrives.Clear(); firstDriveResults.Clear(); closestToPinResults.Clear(); perfectShotCounts.Clear(); cartBestFlipStreaks.Clear(); scoreboardRowRelativeScoreTexts.Clear(); holeStatsLongestDriveDistances.Clear(); holeStatsClosestToPinDistances.Clear(); holeStatsChipInDistances.Clear(); holeOutPopupsShown.Clear(); cartFlipStates.Clear(); suppressedItemSpawners.Clear(); suppressedCheckpoints.Clear(); cachedCarts.Clear(); staleCarts.Clear(); } } private static void PollLobbyCompatibility() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) if (Time.unscaledTime < nextLobbyPollTime) { return; } nextLobbyPollTime = Time.unscaledTime + 1f; Lobby lobby = default(Lobby); if (!BNetworkManager.TryGetSteamLobby(ref lobby)) { if (!NetworkServer.active && !NetworkClient.active) { allLobbyMembersCompatible = true; incompatibleLobbyMembers = string.Empty; hasObservedActiveState = false; lastObservedActiveState = false; } return; } PublishLocalMemberVersion(lobby); PollActiveState(lobby); PollProGolfAnnouncement(lobby); PollProGolfHoleStats(lobby); PollReadyGateState(lobby); if (NetworkServer.active) { UpdateLobbyCompatibility(lobby); PublishActiveState(lobby, IsActiveProGolf() || IsProGolfScoreboardState()); } } private static void PollReadyGateState(Lobby lobby) { string data = ((Lobby)(ref lobby)).GetData("codex_progolfplus_ready_gate_version"); if (!string.IsNullOrEmpty(data) && !(data == lastObservedReadyGateVersion)) { lastObservedReadyGateVersion = data; observedReadyGateHoleIndex = (int.TryParse(((Lobby)(ref lobby)).GetData("codex_progolfplus_ready_gate_hole"), out var result) ? result : int.MinValue); MarkScoreboardsDirty(); } } private static void PollProGolfHoleStats(Lobby lobby) { string data = ((Lobby)(ref lobby)).GetData("codex_progolfplus_hole_stats_version"); if (!string.IsNullOrEmpty(data) && !(data == lastObservedHoleStatsVersion)) { lastObservedHoleStatsVersion = data; ApplyHoleStatsPayload(((Lobby)(ref lobby)).GetData("codex_progolfplus_hole_stats_payload")); MarkScoreboardsDirty(); } } private static void PublishActiveState(Lobby lobby, bool active) { if (active != lastPublishedActiveState || string.IsNullOrEmpty(((Lobby)(ref lobby)).GetData("codex_progolfplus_active"))) { lastPublishedActiveState = active; ((Lobby)(ref lobby)).SetData("codex_progolfplus_active", active ? "1" : "0"); ((Lobby)(ref lobby)).SetData("codex_progolfplus_active_version", Time.unscaledTime.ToString("R")); ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogInfo((object)$"Published Pro Golf Plus active lobby state: {active}."); } } } private static void PollActiveState(Lobby lobby) { string data = ((Lobby)(ref lobby)).GetData("codex_progolfplus_active_version"); if (!string.IsNullOrEmpty(data) && !(data == lastObservedActiveVersion)) { bool flag = ((Lobby)(ref lobby)).GetData("codex_progolfplus_active") == "1"; hasObservedActiveState = true; lastObservedActiveState = flag; lastObservedActiveVersion = data; ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogInfo((object)$"Observed Pro Golf Plus active lobby state: {flag}."); } } } private static void PollProGolfAnnouncement(Lobby lobby) { string data = ((Lobby)(ref lobby)).GetData("codex_progolfplus_announcement_version"); if (!string.IsNullOrEmpty(data) && !(data == lastObservedAnnouncementVersion)) { lastObservedAnnouncementVersion = data; string data2 = ((Lobby)(ref lobby)).GetData("codex_progolfplus_announcement_text"); if (!string.IsNullOrEmpty(data2)) { ShowTopAnnouncement(data2); } } } private static void PublishLocalMemberVersion(Lobby lobby) { if (SteamClient.IsValid && !(Time.unscaledTime < nextLocalMemberVersionPublishTime)) { nextLocalMemberVersionPublishTime = Time.unscaledTime + 2f; ((Lobby)(ref lobby)).SetMemberData("codex_progolfplus_member_version", "0.1.43"); } } private unsafe static void UpdateLobbyCompatibility(Lobby lobby) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_007b: 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) if (!string.Equals(((Lobby)(ref lobby)).GetData("codex_progolfplus_required_version"), "0.1.43", StringComparison.Ordinal)) { ((Lobby)(ref lobby)).SetData("codex_progolfplus_required_version", "0.1.43"); } List list = new List(); foreach (Friend member in ((Lobby)(ref lobby)).Members) { Friend current = member; string memberData = ((Lobby)(ref lobby)).GetMemberData(current, "codex_progolfplus_member_version"); if (!string.Equals(memberData, "0.1.43", StringComparison.Ordinal)) { string? text; if (!string.IsNullOrEmpty(((Friend)(ref current)).Name)) { text = ((Friend)(ref current)).Name; } else { SteamId id = current.Id; text = ((object)(*(SteamId*)(&id))/*cast due to .constrained prefix*/).ToString(); } string text2 = text; list.Add(string.IsNullOrEmpty(memberData) ? (text2 + " (missing Pro Golf Plus 0.1.43)") : (text2 + " (Pro Golf Plus " + memberData + ", needs 0.1.43)")); } } allLobbyMembersCompatible = list.Count == 0; incompatibleLobbyMembers = string.Join(", ", list); if (!allLobbyMembersCompatible && Time.unscaledTime >= nextCompatibilityWarningTime) { nextCompatibilityWarningTime = Time.unscaledTime + 10f; ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogWarning((object)("Pro Golf Plus disabled until every lobby member is running Pro Golf Plus 0.1.43: " + incompatibleLobbyMembers)); } } } private static MatchSetupRules FindMatchSetupRules() { if (SingletonNetworkBehaviour.HasInstance) { return SingletonNetworkBehaviour.Instance; } if (SingletonBehaviour.HasInstance) { return SingletonBehaviour.Instance; } return Object.FindFirstObjectByType((FindObjectsInactive)1); } private void TryEnsureAllPlayersHaveProGolfLoadout() { if (!NetworkServer.active) { return; } int num = 0; int num2 = 0; PlayerInventory[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (PlayerInventory val in array) { if (!((Object)(object)val == (Object)null)) { num++; if (EnsureProGolfLoadout(val)) { num2++; } } } if (num2 > 0) { ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogInfo((object)$"Ensured Pro Golf loadout for {num2}/{num} player inventories."); } } } private static void TrySuppressAllItemSpawners() { if (!IsActiveProGolf()) { return; } ItemSpawner[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (ItemSpawner val in array) { if ((Object)(object)val != (Object)null) { SuppressItemSpawner(val); } } } private static void SuppressItemSpawner(ItemSpawner spawner) { if ((Object)(object)spawner == (Object)null) { return; } if (suppressedItemSpawners.Contains(spawner)) { if (NetworkServer.active) { if (spawner.NetworkhasItemBox) { spawner.NetworkhasItemBox = false; } if (spawner.NetworkvisualsFill != 0f) { spawner.NetworkvisualsFill = 0f; } } return; } if (NetworkServer.active) { spawner.NetworkhasItemBox = false; spawner.NetworkvisualsFill = 0f; } object? obj = itemSpawnerPickupColliderField?.GetValue(spawner); Collider val = (Collider)((obj is Collider) ? obj : null); if ((Object)(object)val != (Object)null) { val.enabled = false; } object obj2 = itemSpawnerVisualsField?.GetValue(spawner); object? obj3 = itemSpawnerVisualsFillingObjectField?.GetValue(obj2); SetSpawnerVisualObjectActive((GameObject)((obj3 is GameObject) ? obj3 : null), active: false); object? obj4 = itemSpawnerVisualsIdleObjectField?.GetValue(obj2); SetSpawnerVisualObjectActive((GameObject)((obj4 is GameObject) ? obj4 : null), active: false); object? obj5 = itemSpawnerVisualsFillRendererField?.GetValue(obj2); MeshRenderer val2 = (MeshRenderer)((obj5 is MeshRenderer) ? obj5 : null); if ((Object)(object)val2 != (Object)null) { ((Renderer)val2).enabled = false; } object? obj6 = itemSpawnerVisualsAnimatorField?.GetValue(obj2); Behaviour val3 = (Behaviour)((obj6 is Behaviour) ? obj6 : null); if ((Object)(object)val3 != (Object)null) { val3.enabled = false; } Renderer[] componentsInChildren = ((Component)spawner).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } suppressedItemSpawners.Add(spawner); } private static void SetSpawnerVisualObjectActive(GameObject gameObject, bool active) { if ((Object)(object)gameObject != (Object)null && gameObject.activeSelf != active) { gameObject.SetActive(active); } } private static void ShowTopAnnouncement(string text) { SplitAnnouncementText(text, out topAnnouncementText, out topAnnouncementDetailText); topAnnouncementVisibleUntil = Time.unscaledTime + (text.StartsWith("Hole Stats:", StringComparison.Ordinal) ? 8f : 6f); } private static void DrawTopAnnouncement() { //IL_00ba: 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_014a: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(topAnnouncementText) && !(Time.unscaledTime >= topAnnouncementVisibleUntil)) { EnsureTopAnnouncementStyles(); float num = Mathf.Clamp((float)Screen.width * 0.78f, 620f, 1060f); int num2 = ((!string.IsNullOrEmpty(topAnnouncementDetailText)) ? topAnnouncementDetailText.Split(new char[1] { '\n' }).Length : 0); float num3 = (string.IsNullOrEmpty(topAnnouncementDetailText) ? 104f : (100f + Mathf.Max(42f, (float)num2 * 34f))); Rect val = default(Rect); ((Rect)(ref val))..ctor(((float)Screen.width - num) * 0.5f, Mathf.Max(64f, (float)Screen.height * 0.28f), num, num3); GUI.Box(val, GUIContent.none, topAnnouncementBoxStyle); GUI.Label(new Rect(((Rect)(ref val)).x + 26f, ((Rect)(ref val)).y + 20f, ((Rect)(ref val)).width - 52f, 64f), topAnnouncementText, topAnnouncementTextStyle); if (!string.IsNullOrEmpty(topAnnouncementDetailText)) { GUI.Label(new Rect(((Rect)(ref val)).x + 26f, ((Rect)(ref val)).y + 82f, ((Rect)(ref val)).width - 52f, ((Rect)(ref val)).height - 92f), topAnnouncementDetailText, topAnnouncementDetailStyle); } } } private static void EnsureTopAnnouncementStyles() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0063: 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_0076: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_008e: Expected O, but got Unknown //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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_00db: 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_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) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown if (topAnnouncementBoxStyle == null) { topAnnouncementBoxTexture = CreateStripedGuiTexture(new Color(0.05f, 0.16f, 0.27f, 0.82f), new Color(0.12f, 0.3f, 0.47f, 0.82f)); GUIStyle val = new GUIStyle(GUI.skin.box); val.normal.background = topAnnouncementBoxTexture; val.border = new RectOffset(14, 14, 14, 14); val.padding = new RectOffset(22, 22, 18, 18); topAnnouncementBoxStyle = val; GUIStyle val2 = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontSize = 46, fontStyle = (FontStyle)1 }; val2.normal.textColor = Color.white; val2.wordWrap = false; val2.clipping = (TextClipping)1; topAnnouncementTextStyle = val2; GUIStyle val3 = new GUIStyle(topAnnouncementTextStyle) { fontSize = 34, wordWrap = true }; val3.normal.textColor = new Color(0.82f, 0.86f, 0.9f, 1f); topAnnouncementDetailStyle = val3; } } private static void SplitAnnouncementText(string text, out string title, out string detail) { title = text; detail = string.Empty; int num = text.IndexOf(':'); if (num >= 0 && num < text.Length - 1) { title = text.Substring(0, num + 1).Trim(); detail = text.Substring(num + 1).Trim(); } } private static Texture2D CreateGuiTexture(Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_001f: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1); val.SetPixel(0, 0, color); val.Apply(); ((Object)val).hideFlags = (HideFlags)61; return val; } private static Texture2D CreateStripedGuiTexture(Color baseColor, Color stripeColor) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_0026: 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) Texture2D val = new Texture2D(64, 64); for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { bool flag = (j + i) / 8 % 2 == 0; val.SetPixel(j, i, flag ? stripeColor : baseColor); } } ((Texture)val).wrapMode = (TextureWrapMode)0; val.Apply(); ((Object)val).hideFlags = (HideFlags)61; return val; } private static void DestroyTopAnnouncementStyles() { if ((Object)(object)topAnnouncementBoxTexture != (Object)null) { Object.Destroy((Object)(object)topAnnouncementBoxTexture); topAnnouncementBoxTexture = null; } topAnnouncementBoxStyle = null; topAnnouncementTextStyle = null; topAnnouncementDetailStyle = null; } private static void PollReadyUpInput() { if (NetworkServer.active && IsReadyScoreboardWindowActive()) { OpenReadyGateForCurrentHole(); } if (!IsReadyUpWindowActive()) { return; } if (WasReadyPressedThisFrame()) { PublishLocalReadyForCurrentHole(); } if (NetworkServer.active && readyGateHoleIndex == CourseManager.CurrentHoleGlobalIndex && readyGateCountdownTriggeredHoleIndex != readyGateHoleIndex && AreAllActivePlayersReadyForCurrentHole()) { readyGateCountdownTriggeredHoleIndex = readyGateHoleIndex; ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogInfo((object)"All Pro Golf players are ready; starting next hole."); } InvokeServerStartNextMatch(); } } private static void PollReadyUpScoreboards() { if (!(Time.unscaledTime < nextReadyScoreboardRefreshTime)) { nextReadyScoreboardRefreshTime = Time.unscaledTime + 0.25f; Scoreboard[] array = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { UpdateScoreboardReadyUpPanel(array[i]); } if (IsReadyUpWindowActive()) { MarkScoreboardsDirty(); } } } private static bool WasReadyPressedThisFrame() { try { return (Keyboard.current != null && (((ButtonControl)Keyboard.current.aKey).wasPressedThisFrame || ((ButtonControl)Keyboard.current.bKey).wasPressedThisFrame || ((ButtonControl)Keyboard.current.xKey).wasPressedThisFrame)) || (Gamepad.current != null && (Gamepad.current.buttonEast.wasPressedThisFrame || Gamepad.current.buttonWest.wasPressedThisFrame || Gamepad.current.buttonSouth.wasPressedThisFrame)); } catch { return false; } } private static bool IsReadyUpWindowActive() { if ((Object)(object)instance != (Object)null && instance.readyUpBetweenHolesConfig.Value && IsProGolfScoringActive() && Scoreboard.IsVisible && (IsReadyScoreboardWindowActive() || IsReadyGateOpenForCurrentHole())) { return GetActivePlayerGuids().Count > 0; } return false; } private static bool IsReadyScoreboardWindowActive() { if ((Object)(object)instance != (Object)null && instance.readyUpBetweenHolesConfig.Value && IsProGolfScoringActive() && Scoreboard.IsVisible && AllActivePlayersResolvedForCurrentHole()) { return GetActivePlayerGuids().Count > 0; } return false; } private static bool IsReadyGateOpenForCurrentHole() { int currentHoleGlobalIndex = CourseManager.CurrentHoleGlobalIndex; if (readyGateHoleIndex != currentHoleGlobalIndex) { return observedReadyGateHoleIndex == currentHoleGlobalIndex; } return true; } private static void OpenReadyGateForCurrentHole() { int currentHoleGlobalIndex = CourseManager.CurrentHoleGlobalIndex; if (readyGateHoleIndex != currentHoleGlobalIndex) { readyGateHoleIndex = currentHoleGlobalIndex; readyGateCountdownTriggeredHoleIndex = int.MinValue; PublishReadyGateState(currentHoleGlobalIndex); MarkScoreboardsDirty(); ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogInfo((object)$"Opened Pro Golf ready-up gate for hole {currentHoleGlobalIndex}."); } } } private static void PublishReadyGateState(int holeIndex) { Lobby val = default(Lobby); if (NetworkServer.active && BNetworkManager.TryGetSteamLobby(ref val)) { observedReadyGateHoleIndex = holeIndex; ((Lobby)(ref val)).SetData("codex_progolfplus_ready_gate_hole", holeIndex.ToString()); ((Lobby)(ref val)).SetData("codex_progolfplus_ready_gate_version", $"{holeIndex}:{Time.unscaledTime:R}"); } } private static void PublishLocalReadyForCurrentHole() { int currentHoleGlobalIndex = CourseManager.CurrentHoleGlobalIndex; if (localReadyHoleIndex != currentHoleGlobalIndex) { localReadyHoleIndex = currentHoleGlobalIndex; Lobby val = default(Lobby); if (BNetworkManager.TryGetSteamLobby(ref val)) { ((Lobby)(ref val)).SetMemberData("codex_progolfplus_ready_hole", currentHoleGlobalIndex.ToString()); } MarkScoreboardsDirty(); ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogInfo((object)$"Published local Pro Golf ready-up for hole {currentHoleGlobalIndex}."); } } } private static bool AreAllActivePlayersReadyForCurrentHole() { if (!IsReadyGateOpenForCurrentHole()) { return false; } List activePlayerGuids = GetActivePlayerGuids(); if (activePlayerGuids.Count == 0) { return false; } foreach (ulong item in activePlayerGuids) { if (!IsPlayerReadyForCurrentHole(item)) { return false; } } return true; } private static bool IsPlayerReadyForCurrentHole(ulong playerGuid) { //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_003c: 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) int currentHoleGlobalIndex = CourseManager.CurrentHoleGlobalIndex; if (playerGuid != 0L && playerGuid == GetLocalPlayerGuid() && localReadyHoleIndex == currentHoleGlobalIndex) { return true; } Lobby val = default(Lobby); if (!BNetworkManager.TryGetSteamLobby(ref val)) { return false; } foreach (Friend member in ((Lobby)(ref val)).Members) { if (TryGetFriendSteamId(member, out var steamId) && steamId == playerGuid) { return string.Equals(((Lobby)(ref val)).GetMemberData(member, "codex_progolfplus_ready_hole"), currentHoleGlobalIndex.ToString(), StringComparison.Ordinal); } } return false; } private static ulong GetLocalPlayerGuid() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return CourseManager.GetLocalPlayerState().playerGuid; } private unsafe static bool TryGetFriendSteamId(Friend member, out ulong steamId) { return ulong.TryParse(((object)(*(SteamId*)(&member.Id))/*cast due to .constrained prefix*/).ToString(), out steamId); } private static bool TryHoldForReadyUp(CourseManager courseManager) { if ((Object)(object)instance == (Object)null || !instance.readyUpBetweenHolesConfig.Value || !NetworkServer.active || (Object)(object)courseManager == (Object)null) { return false; } int currentHoleGlobalIndex = CourseManager.CurrentHoleGlobalIndex; OpenReadyGateForCurrentHole(); if (AreAllActivePlayersReadyForCurrentHole()) { return false; } if (Time.unscaledTime >= nextReadyGateLogTime) { nextReadyGateLogTime = Time.unscaledTime + 4f; ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogInfo((object)$"Holding Pro Golf end-of-hole countdown for ready-up on hole {currentHoleGlobalIndex}: {BuildReadyStatusSummary()}."); } } return true; } private static bool ShouldBlockNativeEndCountdown(CourseManager courseManager) { if ((Object)(object)instance == (Object)null || !instance.readyUpBetweenHolesConfig.Value || !NetworkServer.active || (Object)(object)courseManager == (Object)null || !IsProGolfScoringActive()) { return false; } if (!AllActivePlayersResolved(courseManager)) { if (Time.unscaledTime >= nextReadyGateLogTime) { nextReadyGateLogTime = Time.unscaledTime + 4f; ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogInfo((object)"Holding Pro Golf end-of-hole countdown because active players are still playing."); } } MatchEndCountdown.Hide(); return true; } return false; } private static void MaintainReadyUpHold() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Invalid comparison between Unknown and I4 //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Invalid comparison between Unknown and I4 if ((Object)(object)instance == (Object)null || !instance.readyUpBetweenHolesConfig.Value || !IsProGolfScoringActive()) { return; } if (ShouldSuppressReadyCountdownUi()) { MatchEndCountdown.Hide(); } if (NetworkServer.active && SingletonNetworkBehaviour.HasInstance) { CourseManager val = SingletonNetworkBehaviour.Instance; if (!((Object)(object)val == (Object)null) && ShouldBlockNativeEndCountdown(val) && ((int)CourseManager.MatchState == 4 || (int)CourseManager.MatchState == 5)) { RollBackReadyUpMatchState(val, (MatchState)3); } } } private static bool ShouldSuppressReadyCountdownUi() { if ((Object)(object)instance == (Object)null || !instance.readyUpBetweenHolesConfig.Value || !IsProGolfScoringActive()) { return false; } if (Scoreboard.IsVisible && IsReadyGateOpenForCurrentHole()) { return !AreAllActivePlayersReadyForCurrentHole(); } return false; } private static void RollBackReadyUpMatchState(CourseManager courseManager, MatchState fallbackState) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)courseManager == (Object)null || suppressReadyMatchStateRollback) { return; } suppressReadyMatchStateRollback = true; try { courseManager.NetworkmatchState = fallbackState; MatchEndCountdown.Hide(); } finally { suppressReadyMatchStateRollback = false; } } private static bool TryBlockReadyUpMatchStateChange(CourseManager courseManager, MatchState requestedState, ref MatchState replacementState) { return false; } private static bool IsReadyHoldState(MatchState state) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 if ((int)state != 4 && (int)state != 5) { return (int)state == 6; } return true; } private static bool ShouldBlockNextMatchForReadyUp(CourseManager courseManager) { if ((Object)(object)instance == (Object)null || !instance.readyUpBetweenHolesConfig.Value || !NetworkServer.active || (Object)(object)courseManager == (Object)null || !IsProGolfScoringActive()) { return false; } if (!Scoreboard.IsVisible && !IsReadyGateOpenForCurrentHole()) { return false; } OpenReadyGateForCurrentHole(); if (AreAllActivePlayersReadyForCurrentHole()) { return false; } MatchEndCountdown.Hide(); if (Time.unscaledTime >= nextReadyStateBlockLogTime) { nextReadyStateBlockLogTime = Time.unscaledTime + 2f; ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogInfo((object)("Blocked Pro Golf next-hole start until scoreboard ready-up completes: " + BuildReadyStatusSummary() + ".")); } } return true; } private static IEnumerator EmptyReadyUpHoldRoutine() { yield break; } private static void InvokeBeginCountdownToMatchEnd() { if (SingletonNetworkBehaviour.HasInstance) { AccessTools.Method(typeof(CourseManager), "BeginCountdownToMatchEnd", (Type[])null, (Type[])null)?.Invoke(SingletonNetworkBehaviour.Instance, Array.Empty()); } } private static void InvokeServerStartNextMatch() { if (!NetworkServer.active || !SingletonNetworkBehaviour.HasInstance) { return; } MethodInfo methodInfo = AccessTools.Method(typeof(CourseManager), "ServerStartNextMatch", (Type[])null, (Type[])null); if (methodInfo == null) { ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogWarning((object)"Could not find CourseManager.ServerStartNextMatch for Pro Golf ready-up."); } } else { methodInfo.Invoke(SingletonNetworkBehaviour.Instance, new object[1] { false }); } } private static string BuildReadyStatusSummary() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_002d: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (PlayerState sortedActivePlayerState in GetSortedActivePlayerStates()) { list.Add(GetPlayerName(null, sortedActivePlayerState.playerGuid) + "=" + (IsPlayerReadyForCurrentHole(sortedActivePlayerState.playerGuid) ? "ready" : "waiting")); } if (list.Count != 0) { return string.Join(", ", list); } return "no active players"; } private static void DrawReadyUpOverlay() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_0177: 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) if (!IsReadyUpWindowActive()) { return; } EnsureReadyUpStyles(); List sortedActivePlayerStates = GetSortedActivePlayerStates(); float num = Mathf.Clamp((float)Screen.width * 0.3f, 360f, 520f); float num2 = 28f; float num3 = 118f + (float)Mathf.Max(1, sortedActivePlayerStates.Count) * num2; Rect val = default(Rect); ((Rect)(ref val))..ctor((float)Screen.width - num - 32f, Mathf.Max(86f, (float)Screen.height * 0.18f), num, num3); GUI.Box(val, GUIContent.none, readyUpBoxStyle); GUI.Label(new Rect(((Rect)(ref val)).x + 18f, ((Rect)(ref val)).y + 14f, ((Rect)(ref val)).width - 36f, 30f), "Ready for next hole", readyUpHeaderStyle); GUI.Label(new Rect(((Rect)(ref val)).x + 18f, ((Rect)(ref val)).y + 46f, ((Rect)(ref val)).width - 36f, 28f), (localReadyHoleIndex == CourseManager.CurrentHoleGlobalIndex) ? "You are ready" : "Press X to ready up", readyUpPromptStyle); float num4 = ((Rect)(ref val)).y + 82f; foreach (PlayerState item in sortedActivePlayerStates) { string text = (IsPlayerReadyForCurrentHole(item.playerGuid) ? "[Ready]" : "[Waiting]"); GUI.Label(new Rect(((Rect)(ref val)).x + 22f, num4, ((Rect)(ref val)).width - 44f, num2), text + " " + GetPlayerName(null, item.playerGuid), readyUpRowStyle); num4 += num2; } } private static void EnsureReadyUpStyles() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0063: 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_0076: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_008e: Expected O, but got Unknown //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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00c8: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown //IL_0114: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown if (readyUpBoxStyle == null) { readyUpBoxTexture = CreateStripedGuiTexture(new Color(0.04f, 0.18f, 0.12f, 0.88f), new Color(0.08f, 0.3f, 0.19f, 0.88f)); GUIStyle val = new GUIStyle(GUI.skin.box); val.normal.background = readyUpBoxTexture; val.border = new RectOffset(14, 14, 14, 14); val.padding = new RectOffset(16, 16, 14, 14); readyUpBoxStyle = val; GUIStyle val2 = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontSize = 24, fontStyle = (FontStyle)1 }; val2.normal.textColor = Color.white; readyUpHeaderStyle = val2; GUIStyle val3 = new GUIStyle(readyUpHeaderStyle) { fontSize = 18, fontStyle = (FontStyle)1 }; val3.normal.textColor = new Color(0.78f, 1f, 0.72f, 1f); readyUpPromptStyle = val3; GUIStyle val4 = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)3, fontSize = 17, fontStyle = (FontStyle)1 }; val4.normal.textColor = Color.white; val4.clipping = (TextClipping)1; readyUpRowStyle = val4; } } private static void DestroyReadyUpStyles() { if ((Object)(object)readyUpBoxTexture != (Object)null) { Object.Destroy((Object)(object)readyUpBoxTexture); readyUpBoxTexture = null; } readyUpBoxStyle = null; readyUpHeaderStyle = null; readyUpRowStyle = null; readyUpPromptStyle = null; if ((Object)(object)proGolfReadyFlagTexture != (Object)null) { Object.Destroy((Object)(object)proGolfReadyFlagTexture); proGolfReadyFlagTexture = null; proGolfReadyFlagSprite = null; } } private static void TrySuppressCheckpoints() { if (IsActiveProGolf()) { Checkpoint[] array = Object.FindObjectsByType((FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { SuppressCheckpointVisuals(array[i]); } } } private static void SuppressCheckpointVisuals(Checkpoint checkpoint) { if ((Object)(object)checkpoint == (Object)null || suppressedCheckpoints.Contains(checkpoint)) { return; } object? obj = checkpointBaseMeshField?.GetValue(checkpoint); MeshRenderer val = (MeshRenderer)((obj is MeshRenderer) ? obj : null); if ((Object)(object)val != (Object)null) { ((Renderer)val).enabled = false; } object? obj2 = checkpointScreenMeshField?.GetValue(checkpoint); MeshRenderer val2 = (MeshRenderer)((obj2 is MeshRenderer) ? obj2 : null); if ((Object)(object)val2 != (Object)null) { ((Renderer)val2).enabled = false; } object? obj3 = checkpointAnimatorField?.GetValue(checkpoint); Behaviour val3 = (Behaviour)((obj3 is Behaviour) ? obj3 : null); if ((Object)(object)val3 != (Object)null) { val3.enabled = false; } object? obj4 = checkpointVisualCenterField?.GetValue(checkpoint); Transform val4 = (Transform)((obj4 is Transform) ? obj4 : null); if ((Object)(object)val4 != (Object)null) { Renderer[] componentsInChildren = ((Component)val4).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } Collider[] componentsInChildren2 = ((Component)val4).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].enabled = false; } suppressedCheckpoints.Add(checkpoint); } else { Renderer[] componentsInChildren = ((Component)checkpoint).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } suppressedCheckpoints.Add(checkpoint); } } private static SyncList GetSlots(PlayerInventory inventory) { return inventorySlotsField?.GetValue(inventory) as SyncList; } private static void EnsureSlotCount(PlayerInventory inventory) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) SyncList slots = GetSlots(inventory); if (slots != null) { while (slots.Count < 3) { slots.Add(InventorySlot.Empty); } while (slots.Count > 3) { slots.RemoveAt(slots.Count - 1); } } } private static bool IsCart(InventorySlot slot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) if ((int)slot.itemType == 6) { return slot.remainingUses > 0; } return false; } private static bool IsCoffee(InventorySlot slot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) if ((int)slot.itemType == 1) { return slot.remainingUses > 0; } return false; } private static bool IsSpringBoots(InventorySlot slot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) if ((int)slot.itemType == 5) { return slot.remainingUses > 0; } return false; } private static bool IsPistol(InventorySlot slot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) if ((int)slot.itemType == 2) { return slot.remainingUses > 0; } return false; } private static bool IsEmpty(InventorySlot slot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if ((int)slot.itemType != 0) { return slot.remainingUses <= 0; } return true; } private static bool IsReservedPermanentSlot(PlayerInventory inventory, int index) { //IL_0017: 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_002f: Unknown result type (might be due to invalid IL or missing references) if (!IsActiveProGolf() || !TryGetSlot(inventory, index, out var slot)) { return false; } if ((index != 0 || !IsCart(slot)) && (index != 1 || !IsCoffee(slot))) { if (index == 2) { return IsSpringBoots(slot); } return false; } return true; } private static bool TryGetSlot(PlayerInventory inventory, int index, out InventorySlot slot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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) slot = InventorySlot.Empty; SyncList slots = GetSlots(inventory); if (slots == null || index < 0 || index >= slots.Count) { return false; } slot = slots[index]; return true; } private static bool EnsureProGolfLoadout(PlayerInventory inventory) { if (!IsActiveProGolf() || !NetworkServer.active) { return false; } SyncList slots = GetSlots(inventory); if (slots == null) { return false; } EnsureSlotCount(inventory); return (byte)(0u | (SetSlotIfDifferent(slots, 0, (ItemType)6) ? 1u : 0u) | (SetSlotIfDifferent(slots, 1, (ItemType)1) ? 1u : 0u) | (SetSlotIfDifferent(slots, 2, (ItemType)5) ? 1u : 0u) | (ClearNonPermanentItems(slots) ? 1u : 0u)) != 0; } private static bool SetSlotIfDifferent(SyncList slots, int index, ItemType itemType) { //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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0011: Unknown result type (might be due to invalid IL or missing references) InventorySlot val = slots[index]; if (val.itemType == itemType && val.remainingUses > 0) { return false; } slots[index] = new InventorySlot(itemType, 1); return true; } private static bool ClearNonPermanentItems(SyncList slots) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) bool result = false; for (int i = 0; i < slots.Count; i++) { if (!IsPermanentLoadoutSlot(i) && !IsEmpty(slots[i])) { slots[i] = InventorySlot.Empty; result = true; } } return result; } private static bool IsPermanentLoadoutSlot(int index) { if (index != 0 && index != 1) { return index == 2; } return true; } private static bool IsBlockedProGolfPickupItem(ItemType itemType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 if ((int)itemType != 6 && (int)itemType != 1 && (int)itemType != 5 && (int)itemType != 2) { return (int)itemType == 0; } return true; } private static void MarkBallRespawnForHazardElimination(PlayerGolfer golfer, EliminationReason immediateEliminationReason) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (IsActiveProGolf() && !((Object)(object)golfer == (Object)null) && IsHazardElimination(immediateEliminationReason)) { PlayerInfo playerInfo = golfer.PlayerInfo; PlayerMovement val = ((playerInfo != null) ? playerInfo.Movement : null); GolfBall ownBall = golfer.OwnBall; if (!((Object)(object)val == (Object)null) && !((Object)(object)ownBall == (Object)null)) { forceNextRespawnAtBall.Add(val); } } } private static bool IsHazardElimination(EliminationReason reason) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 if ((int)reason != 5 && (int)reason != 6) { return (int)reason == 23; } return true; } private static void RedirectHazardRespawnToBall(PlayerMovement movement, ref RespawnTarget respawnTarget) { if (IsActiveProGolf() && !((Object)(object)movement == (Object)null) && (int)respawnTarget == 0 && forceNextRespawnAtBall.Remove(movement)) { respawnTarget = (RespawnTarget)1; ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogInfo((object)"Redirected Pro Golf Plus hazard respawn to player's ball."); } } } private static bool TryRespawnHazardEliminationAtBall(PlayerGolfer golfer, EliminationReason immediateEliminationReason) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!IsActiveProGolf() || !IsHazardElimination(immediateEliminationReason)) { return false; } object obj; if (golfer == null) { obj = null; } else { PlayerInfo playerInfo = golfer.PlayerInfo; obj = ((playerInfo != null) ? playerInfo.Movement : null); } PlayerMovement val = (PlayerMovement)obj; if ((Object)(object)val == (Object)null) { return false; } if (!val.TryBeginRespawn(false, (RespawnTarget)1)) { return false; } ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogInfo((object)"Converted Pro Golf Plus hazard elimination into a ball respawn without knockout/elimination reporting."); } return true; } private static bool IsProGolfScorePopupType(PlayerTextPopupType popupType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Invalid comparison between Unknown and I4 //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between Unknown and I4 if ((int)popupType != 1 && (int)popupType != 2 && (int)popupType != 3 && (int)popupType != 4 && (int)popupType != 5 && (int)popupType != 6 && (int)popupType != 7 && (int)popupType != 8 && (int)popupType != 9 && (int)popupType != 10 && (int)popupType != 11 && (int)popupType != 12 && (int)popupType != 13 && (int)popupType != 14 && (int)popupType != 15 && (int)popupType != 16 && (int)popupType != 17 && (int)popupType != 18) { return (int)popupType == 21; } return true; } private static bool HasPlayerScoredThisHole(PlayerGolfer golfer) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 PlayerState val = default(PlayerState); if ((Object)(object)golfer != (Object)null && CourseManager.TryGetPlayerState(golfer.PlayerInfo, ref val)) { return (int)val.matchResolution == 1; } return false; } private static bool AllActivePlayersResolved(CourseManager courseManager) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Invalid comparison between Unknown and I4 //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) SyncList playerStates = CourseManager.PlayerStates; if (playerStates == null) { return false; } int num = 0; int num2 = 0; Enumerator enumerator = playerStates.GetEnumerator(); try { while (enumerator.MoveNext()) { PlayerState current = enumerator.Current; if (current.isConnected && !current.isSpectator && (int)current.matchResolution != -1) { num++; if ((int)current.matchResolution != 0) { num2++; } } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } if (num > 0) { return num == num2; } return false; } private static bool TryCompareProGolfPlayerStates(PlayerState self, PlayerState other, ref int result) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_009f: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) if (!IsProGolfScoringActive()) { return false; } if (self.courseStrokes != other.courseStrokes) { result = self.courseStrokes.CompareTo(other.courseStrokes); return true; } if (self.courseScore != other.courseScore) { result = other.courseScore.CompareTo(self.courseScore); return true; } if (self.wins != other.wins) { result = other.wins.CompareTo(self.wins); return true; } if (self.finishes != other.finishes) { result = other.finishes.CompareTo(self.finishes); return true; } if (self.courseKnockouts != other.courseKnockouts) { result = other.courseKnockouts.CompareTo(self.courseKnockouts); return true; } if (self.losses != other.losses) { result = self.losses.CompareTo(other.losses); return true; } if (!self.scoreTimestamp.Equals(other.scoreTimestamp)) { result = self.scoreTimestamp.CompareTo(other.scoreTimestamp); return true; } result = self.joinIndex.CompareTo(other.joinIndex); return true; } private static bool TryGetWeightedRandomAllowedPickupItem(ItemPool pool, out ItemType item) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected I4, but got Unknown item = (ItemType)0; if (!(itemPoolSpawnChancesField?.GetValue(pool) is Array { Length: not 0 } array)) { return false; } float num = 0f; foreach (object item2 in array) { ItemType itemType = (ItemType)AccessTools.Field(item2.GetType(), "item").GetValue(item2); float num2 = (float)AccessTools.Field(item2.GetType(), "spawnChanceWeight").GetValue(item2); if (!IsBlockedProGolfPickupItem(itemType) && num2 > 0f) { num += num2; } } if (num <= 0f) { item = (ItemType)3; return true; } float num3 = Random.value * num; foreach (object item3 in array) { ItemType val = (ItemType)AccessTools.Field(item3.GetType(), "item").GetValue(item3); float num4 = (float)AccessTools.Field(item3.GetType(), "spawnChanceWeight").GetValue(item3); if (!IsBlockedProGolfPickupItem(val) && !(num4 <= 0f)) { num3 -= num4; if (num3 <= 0f) { item = (ItemType)(int)val; return true; } } } item = (ItemType)3; return true; } private static void BeginDriveTracking(GolfBall ball) { //IL_00ac: 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) if (NetworkServer.active && IsActiveProGolf() && !((Object)(object)ball == (Object)null) && !((Object)(object)ball.Owner == (Object)null) && !((Object)(object)ball.Owner.PlayerInfo == (Object)null) && !((Object)(object)ball.Owner.PlayerInfo.PlayerId == (Object)null)) { ResetLongestDriveIfHoleChanged(); ulong guid = ball.Owner.PlayerInfo.PlayerId.Guid; if (!firstDriveResults.ContainsKey(guid) && !HasActiveDriveForPlayer(guid)) { activeDrives[ball] = new DriveCandidate { Player = ball.Owner.PlayerInfo, PlayerGuid = guid, StartPosition = ((Component)ball).transform.position }; } } } private static void TryCompleteDriveTracking(GolfBall ball) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active && IsActiveProGolf() && !((Object)(object)ball == (Object)null) && ball.IsStationary && activeDrives.TryGetValue(ball, out var value)) { activeDrives.Remove(ball); if (!((Object)(object)value.Player == (Object)null) && !((Object)(object)value.Player.PlayerId == (Object)null) && !firstDriveResults.ContainsKey(value.PlayerGuid)) { Vector3 val = ((Component)ball).transform.position - value.StartPosition; val.y = 0f; float magnitude = ((Vector3)(ref val)).magnitude; float num = Mathf.Max(0f, instance?.longestDriveMinimumMetersConfig.Value ?? 0f); firstDriveResults[value.PlayerGuid] = new FirstDriveResult { PlayerName = GetPlayerName(value.Player, value.PlayerGuid), Distance = magnitude, IsValid = (magnitude >= num) }; TryAnnounceLongestDriveIfReady(); } } } private static void TryCaptureClosestToPinFromStationaryBall(GolfBall ball) { if (!NetworkServer.active || !IsActiveProGolf() || (Object)(object)ball == (Object)null || !ball.IsStationary || (Object)(object)ball.Owner == (Object)null || (Object)(object)ball.Owner.PlayerInfo == (Object)null || (Object)(object)ball.Owner.PlayerInfo.PlayerId == (Object)null) { return; } ResetLongestDriveIfHoleChanged(); PlayerInfo playerInfo = ball.Owner.PlayerInfo; ulong guid = playerInfo.PlayerId.Guid; if (!closestToPinResults.ContainsKey(guid) && !IsBallInHole(ball) && !HasPlayerScoredThisHole(playerInfo.AsGolfer) && TryGetDistanceToPinWithinRadius(ball, out var distanceToPin)) { closestToPinResults[guid] = new ClosestToPinResult { PlayerName = GetPlayerName(playerInfo, guid), Distance = distanceToPin, IsValid = true }; ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogInfo((object)("Captured Closest to Pin inside 10yd radius: " + GetPlayerName(playerInfo, guid) + " " + FormatDistanceFeet(distanceToPin) + ".")); } TryAnnounceClosestToPinIfReady(); } } private static void CaptureClosestToPinOnScore(PlayerGolfer player) { if (NetworkServer.active && IsActiveProGolf()) { object obj; if (player == null) { obj = null; } else { PlayerInfo playerInfo = player.PlayerInfo; obj = ((playerInfo != null) ? playerInfo.PlayerId : null); } if (!((Object)obj == (Object)null)) { ResetLongestDriveIfHoleChanged(); _ = player.PlayerInfo.PlayerId.Guid; CaptureChipInOnScore(player); } } } private static void CaptureChipInOnScore(PlayerGolfer player) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_0062: 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_0087: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || !IsActiveProGolf()) { return; } object obj; if (player == null) { obj = null; } else { PlayerInfo playerInfo = player.PlayerInfo; obj = ((playerInfo != null) ? playerInfo.PlayerId : null); } if ((Object)obj == (Object)null) { return; } GolfHole val = FindMainHole(); GolfBall ownBall = player.OwnBall; if ((Object)(object)val == (Object)null || (Object)(object)ownBall == (Object)null) { return; } Vector3 serverLastStrokePosition = ownBall.ServerLastStrokePosition; Vector3 val2 = serverLastStrokePosition - ((Component)val).transform.position; val2.y = 0f; float magnitude = ((Vector3)(ref val2)).magnitude; if (!(magnitude < 1f) && !val.IsPointInGreenTrigger(serverLastStrokePosition)) { ulong guid = player.PlayerInfo.PlayerId.Guid; holeStatsChipInDistances[guid] = magnitude; ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogInfo((object)("Tracked Pro Golf chip-in: " + GetPlayerName(player.PlayerInfo, guid) + " " + FormatDistanceYards(magnitude) + ".")); } } } private static void FinalizeMissingClosestToPinResults(List activePlayers) { if (!AllActivePlayersResolvedForCurrentHole()) { return; } foreach (ulong activePlayer in activePlayers) { if (!closestToPinResults.ContainsKey(activePlayer)) { closestToPinResults[activePlayer] = new ClosestToPinResult { PlayerName = CourseManager.GetPlayerName(activePlayer), Distance = float.PositiveInfinity, IsValid = false }; } } } private static void TrackPerfectShot(PlayerGolfer player) { if (!NetworkServer.active || !IsActiveProGolf()) { return; } object obj; if (player == null) { obj = null; } else { PlayerInfo playerInfo = player.PlayerInfo; obj = ((playerInfo != null) ? playerInfo.PlayerId : null); } if ((Object)obj == (Object)null) { return; } ResetLongestDriveIfHoleChanged(); float swingNormalizedCharge = player.SwingNormalizedCharge; if (!(swingNormalizedCharge <= 0.99f) && !(swingNormalizedCharge > 1f)) { ulong guid = player.PlayerInfo.PlayerId.Guid; perfectShotCounts.TryGetValue(guid, out var value); perfectShotCounts[guid] = value + 1; ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogInfo((object)$"Tracked Pro Golf perfect shot: {GetPlayerName(player.PlayerInfo, guid)} ({value + 1})."); } } } private static void PollCartFlipStats() { if (!NetworkServer.active || !IsActiveProGolf()) { cartFlipStates.Clear(); } else { if (Time.unscaledTime < nextCartFlipPollTime) { return; } nextCartFlipPollTime = Time.unscaledTime + 0.25f; ResetLongestDriveIfHoleChanged(); RefreshCachedCartsIfNeeded(); foreach (GolfCartMovement cachedCart in cachedCarts) { if (!((Object)(object)cachedCart == (Object)null)) { if (!cartFlipStates.TryGetValue(cachedCart, out var value)) { value = new CartFlipState { Wheels = ((Component)cachedCart).GetComponentsInChildren(true) }; cartFlipStates[cachedCart] = value; } UpdateCartFlipState(cachedCart, value); } } staleCarts.Clear(); foreach (GolfCartMovement key in cartFlipStates.Keys) { if ((Object)(object)key == (Object)null || !cachedCarts.Contains(key)) { staleCarts.Add(key); } } foreach (GolfCartMovement staleCart in staleCarts) { cartFlipStates.Remove(staleCart); } } } private static void RefreshCachedCartsIfNeeded() { if (Time.unscaledTime < nextCartDiscoveryPollTime) { return; } nextCartDiscoveryPollTime = Time.unscaledTime + 1f; cachedCarts.Clear(); GolfCartMovement[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (GolfCartMovement val in array) { if ((Object)(object)val != (Object)null) { cachedCarts.Add(val); } } } private static void UpdateCartFlipState(GolfCartMovement cart, CartFlipState state) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Dot(((Component)cart).transform.up, Vector3.up); bool flag = AreAllCartWheelsGrounded(cart, state); bool flag2 = IsCartMoving(cart); float cartTumbleAngularSpeed = GetCartTumbleAngularSpeed(cart); float unscaledTime = Time.unscaledTime; if (!state.FlipInProgress) { if (num >= 0.65f) { state.WasUprightOnWheels = true; } bool flag3 = !flag || num < 0.65f; if (!state.WasUprightOnWheels || !flag3 || !flag2 || cartTumbleAngularSpeed < 1f) { return; } state.FlipInProgress = true; state.CurrentFlipStreak = 0; state.AccumulatedFlipRadians = 0f; state.LastFlipPollTime = unscaledTime; state.SettledSince = -1f; CaptureCartResponsiblePlayer(cart, state); } CaptureCartResponsiblePlayer(cart, state); AccumulateCartFlipRotation(state, cartTumbleAngularSpeed, unscaledTime); if (flag && num >= 0.65f) { CreditCartFlipStreak(state); ResetCartFlipSession(state, keepUprightReady: true); } else if (flag2) { state.SettledSince = -1f; } else if (state.SettledSince < 0f) { state.SettledSince = Time.unscaledTime; } else if (!(Time.unscaledTime - state.SettledSince < 0.5f)) { CreditCartFlipStreak(state); ResetCartFlipSession(state, keepUprightReady: false); } } private static void ResetCartFlipSession(CartFlipState state, bool keepUprightReady) { state.FlipInProgress = false; state.WasUprightOnWheels = keepUprightReady; state.CurrentFlipStreak = 0; state.AccumulatedFlipRadians = 0f; state.LastFlipPollTime = -1f; state.SettledSince = -1f; state.ResponsiblePlayerGuid = 0uL; state.ResponsiblePlayerName = null; } private static void AccumulateCartFlipRotation(CartFlipState state, float tumbleAngularSpeed, float now) { if (state.LastFlipPollTime < 0f) { state.LastFlipPollTime = now; return; } float num = Mathf.Clamp(now - state.LastFlipPollTime, 0f, 0.5f); state.LastFlipPollTime = now; if (!(num <= 0f)) { state.AccumulatedFlipRadians += tumbleAngularSpeed * num; state.CurrentFlipStreak = Mathf.FloorToInt(state.AccumulatedFlipRadians / ((float)Math.PI * 2f)); } } private static bool AreAllCartWheelsGrounded(GolfCartMovement cart, CartFlipState state) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) WheelCollider[] array = state.Wheels; if (array == null || array.Length < 4) { array = ((Component)cart).GetComponentsInChildren(true); state.Wheels = array ?? Array.Empty(); } if (array != null && array.Length >= 4) { int num = 0; WheelCollider[] array2 = array; foreach (WheelCollider val in array2) { if ((Object)(object)val != (Object)null && val.isGrounded) { num++; } } return num >= 4; } return Vector3.Dot(((Component)cart).transform.up, Vector3.up) >= 0.65f; } private static bool IsCartMoving(GolfCartMovement cart) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) Rigidbody component = ((Component)cart).GetComponent(); if ((Object)(object)component == (Object)null) { return false; } Vector3 val = component.linearVelocity; if (!(((Vector3)(ref val)).sqrMagnitude > 0.122499995f)) { val = component.angularVelocity; return ((Vector3)(ref val)).sqrMagnitude > 0.122499995f; } return true; } private static float GetCartTumbleAngularSpeed(GolfCartMovement cart) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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) Rigidbody component = ((Component)cart).GetComponent(); if ((Object)(object)component == (Object)null) { return 0f; } Vector3 val = Vector3.ProjectOnPlane(component.angularVelocity, Vector3.up); return ((Vector3)(ref val)).magnitude; } private static void CaptureCartResponsiblePlayer(GolfCartMovement cart, CartFlipState state) { if (TryGetCartResponsiblePlayer(cart, out var player) && !((Object)(object)((player != null) ? player.PlayerId : null) == (Object)null)) { state.ResponsiblePlayerGuid = player.PlayerId.Guid; state.ResponsiblePlayerName = GetPlayerName(player, state.ResponsiblePlayerGuid); } } private static bool TryGetCartResponsiblePlayer(GolfCartMovement cart, out PlayerInfo player) { player = null; GolfCartInfo val = ((cart != null) ? cart.GolfCartInfo : null); if ((Object)(object)val == (Object)null && (Object)(object)cart != (Object)null) { val = ((Component)cart).GetComponent() ?? ((Component)cart).GetComponentInParent(); } if ((Object)(object)val == (Object)null) { return false; } try { if (val.TryGetDriver(ref player) && (Object)(object)player != (Object)null) { return true; } } catch (Exception ex) { ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogDebug((object)("Could not read golf cart driver for flip stats: " + ex.Message)); } } player = val.ResponsiblePlayer; return (Object)(object)player != (Object)null; } private static void CreditCartFlipStreak(CartFlipState state) { if (state.ResponsiblePlayerGuid == 0L || state.CurrentFlipStreak <= 0) { return; } cartBestFlipStreaks.TryGetValue(state.ResponsiblePlayerGuid, out var value); if (state.CurrentFlipStreak > value) { cartBestFlipStreaks[state.ResponsiblePlayerGuid] = state.CurrentFlipStreak; string arg = (string.IsNullOrEmpty(state.ResponsiblePlayerName) ? GetPlayerName(null, state.ResponsiblePlayerGuid) : state.ResponsiblePlayerName); ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogInfo((object)$"Tracked Pro Golf best cart flip streak: {arg} ({state.CurrentFlipStreak})."); } } } private static bool TryGetDistanceToPinWithinRadius(GolfBall ball, out float distanceToPin) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) distanceToPin = 0f; GolfHole val = FindMainHole(); if ((Object)(object)val == (Object)null || (Object)(object)ball == (Object)null) { return false; } Vector3 val2 = ((Component)ball).transform.position - ((Component)val).transform.position; val2.y = 0f; distanceToPin = ((Vector3)(ref val2)).magnitude; if (distanceToPin > 0.05f) { return distanceToPin <= 9.144f; } return false; } private static bool IsBallInHole(GolfBall ball) { object obj = golfBallIsInHoleField?.GetValue(ball); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } private static GolfHole FindMainHole() { if ((Object)(object)GolfHoleManager.MainHole != (Object)null) { return GolfHoleManager.MainHole; } GolfHole[] array = Object.FindObjectsByType((FindObjectsSortMode)0); GolfHole[] array2 = array; foreach (GolfHole val in array2) { if ((Object)(object)val != (Object)null && val.IsMainHole) { return val; } } if (array.Length == 0) { return null; } return array[0]; } private static bool HasActiveDriveForPlayer(ulong playerGuid) { foreach (DriveCandidate value in activeDrives.Values) { if (value.PlayerGuid == playerGuid) { return true; } } return false; } private static void InvalidateFirstDrive(PlayerInfo player) { if (!NetworkServer.active || !IsActiveProGolf() || (Object)(object)((player != null) ? player.PlayerId : null) == (Object)null) { return; } ResetLongestDriveIfHoleChanged(); ulong guid = player.PlayerId.Guid; bool flag = false; List list = new List(); foreach (KeyValuePair activeDrife in activeDrives) { if (activeDrife.Value.PlayerGuid == guid) { list.Add(activeDrife.Key); flag = true; } } foreach (GolfBall item in list) { activeDrives.Remove(item); } if (!firstDriveResults.ContainsKey(guid) && flag) { firstDriveResults[guid] = new FirstDriveResult { PlayerName = GetPlayerName(player, guid), Distance = 0f, IsValid = false }; TryAnnounceLongestDriveIfReady(); } } private static void TryAnnounceLongestDriveIfReady() { if (longestDriveAnnounced) { return; } List activePlayerGuids = GetActivePlayerGuids(); if (activePlayerGuids.Count == 0) { return; } foreach (ulong item in activePlayerGuids) { if (!firstDriveResults.ContainsKey(item)) { return; } } FirstDriveResult longestDriveWinner = GetLongestDriveWinner(activePlayerGuids); longestDriveAnnounced = true; if (longestDriveWinner != null) { string text = "Longest Drive: " + longestDriveWinner.PlayerName + " " + FormatDistanceYards(longestDriveWinner.Distance); PublishProGolfAnnouncement(text); ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogInfo((object)text); } } } private static void TryAnnounceClosestToPinIfReady() { if (closestToPinAnnounced || !NetworkServer.active || !IsActiveProGolf()) { return; } List activePlayerGuids = GetActivePlayerGuids(); if (activePlayerGuids.Count == 0) { return; } FinalizeMissingClosestToPinResults(activePlayerGuids); foreach (ulong item in activePlayerGuids) { if (!closestToPinResults.ContainsKey(item)) { return; } } ClosestToPinResult closestToPinWinner = GetClosestToPinWinner(activePlayerGuids); closestToPinAnnounced = true; if (closestToPinWinner != null) { string text = "Closest to Pin: " + closestToPinWinner.PlayerName + " " + FormatDistanceFeet(closestToPinWinner.Distance); PublishProGolfAnnouncement(text); ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogInfo((object)text); } } } private static FirstDriveResult GetLongestDriveWinner(List activePlayers) { FirstDriveResult firstDriveResult = null; foreach (ulong activePlayer in activePlayers) { if (firstDriveResults.TryGetValue(activePlayer, out var value) && value.IsValid && (firstDriveResult == null || value.Distance > firstDriveResult.Distance)) { firstDriveResult = value; } } return firstDriveResult; } private static ClosestToPinResult GetClosestToPinWinner(List activePlayers) { ClosestToPinResult closestToPinResult = null; foreach (ulong activePlayer in activePlayers) { if (closestToPinResults.TryGetValue(activePlayer, out var value) && value.IsValid && (closestToPinResult == null || value.Distance < closestToPinResult.Distance)) { closestToPinResult = value; } } return closestToPinResult; } private static void TryAnnounceHoleStatsIfReady() { if (holeStatsAnnounced || !NetworkServer.active || !IsProGolfScoringActive()) { return; } List activePlayerGuids = GetActivePlayerGuids(); if (activePlayerGuids.Count != 0) { holeStatsAnnounced = true; PublishProGolfHoleStats(activePlayerGuids); MarkScoreboardsDirty(); ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogInfo((object)"Published Pro Golf Plus hole stats for scoreboard rows."); } } } private static void PublishProGolfHoleStats(List activePlayers) { string text = BuildHoleStatsPayload(activePlayers); ApplyHoleStatsPayload(text); Lobby val = default(Lobby); if (BNetworkManager.TryGetSteamLobby(ref val)) { string text2 = (lastObservedHoleStatsVersion = $"{CourseManager.CurrentHoleGlobalIndex}:{Time.unscaledTime:R}"); ((Lobby)(ref val)).SetData("codex_progolfplus_hole_stats_payload", text); ((Lobby)(ref val)).SetData("codex_progolfplus_hole_stats_version", text2); } } private static string BuildHoleStatsPayload(List activePlayers) { List list = new List(); ulong longestDriveWinnerGuid = GetLongestDriveWinnerGuid(activePlayers); ulong closestToPinWinnerGuid = GetClosestToPinWinnerGuid(activePlayers); foreach (ulong activePlayer in activePlayers) { perfectShotCounts.TryGetValue(activePlayer, out var value); cartBestFlipStreaks.TryGetValue(activePlayer, out var value2); FirstDriveResult value3; float num = ((activePlayer == longestDriveWinnerGuid && firstDriveResults.TryGetValue(activePlayer, out value3) && value3.IsValid) ? value3.Distance : (-1f)); ClosestToPinResult value4; float num2 = ((activePlayer == closestToPinWinnerGuid && closestToPinResults.TryGetValue(activePlayer, out value4) && value4.IsValid) ? value4.Distance : (-1f)); float value5; float num3 = (holeStatsChipInDistances.TryGetValue(activePlayer, out value5) ? value5 : (-1f)); list.Add(string.Join(",", activePlayer.ToString(), value.ToString(), value2.ToString(), num.ToString("R", CultureInfo.InvariantCulture), num2.ToString("R", CultureInfo.InvariantCulture), num3.ToString("R", CultureInfo.InvariantCulture))); } return string.Join(";", list); } private static void ApplyHoleStatsPayload(string payload) { if (string.IsNullOrEmpty(payload)) { return; } string[] array = payload.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { ',' }); if (array2.Length >= 3 && ulong.TryParse(array2[0], out var result) && int.TryParse(array2[1], out var result2) && int.TryParse(array2[2], out var result3)) { perfectShotCounts[result] = result2; cartBestFlipStreaks[result] = result3; if (array2.Length >= 6) { ApplyOptionalDistance(array2[3], result, holeStatsLongestDriveDistances); ApplyOptionalDistance(array2[4], result, holeStatsClosestToPinDistances); ApplyOptionalDistance(array2[5], result, holeStatsChipInDistances); } } } } private static void ApplyOptionalDistance(string rawValue, ulong playerGuid, Dictionary target) { if (!float.TryParse(rawValue, NumberStyles.Float, CultureInfo.InvariantCulture, out var result) || result < 0f) { target.Remove(playerGuid); } else { target[playerGuid] = result; } } private static ulong GetLongestDriveWinnerGuid(List activePlayers) { ulong num = 0uL; float num2 = 0f; foreach (ulong activePlayer in activePlayers) { if (firstDriveResults.TryGetValue(activePlayer, out var value) && value.IsValid && (num == 0L || value.Distance > num2)) { num = activePlayer; num2 = value.Distance; } } return num; } private static ulong GetClosestToPinWinnerGuid(List activePlayers) { ulong num = 0uL; float num2 = 0f; foreach (ulong activePlayer in activePlayers) { if (closestToPinResults.TryGetValue(activePlayer, out var value) && value.IsValid && (num == 0L || value.Distance < num2)) { num = activePlayer; num2 = value.Distance; } } return num; } private static void MarkScoreboardsDirty() { Scoreboard[] array = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); foreach (Scoreboard val in array) { if ((Object)(object)val != (Object)null) { scoreboardMarkDirtyMethod?.Invoke(val, null); } } } private static string FormatDistance(float meters) { if (meters < 10f) { return $"{meters:0.0}m"; } return $"{Mathf.RoundToInt(meters)}m"; } private static string FormatDistanceYards(float meters) { float num = meters * 1.0936133f; if (num < 10f) { return $"{num:0.0}yd"; } return $"{Mathf.RoundToInt(num)}yd"; } private static string FormatDistanceFeet(float meters) { float num = meters * 3.28084f; if (num < 10f) { return $"{num:0.0}ft"; } return $"{Mathf.RoundToInt(num)}ft"; } private static int GetCurrentHoleShotCount(PlayerInfo player) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) PlayerState val = default(PlayerState); if (CourseManager.TryGetPlayerState(player, ref val)) { return Mathf.Max(0, val.matchStrokes); } return 0; } private static int GetCurrentHoleParSafe() { try { return Mathf.Max(0, CourseManager.GetCurrentHolePar()); } catch (Exception ex) { ProGolfPlugin proGolfPlugin = instance; if (proGolfPlugin != null) { ((BaseUnityPlugin)proGolfPlugin).Logger.LogDebug((object)("Could not read current Pro Golf par: " + ex.Message)); } return 0; } } private static string GetGolfScoreName(int strokes, int par) { if (strokes <= 0) { return "-"; } if (strokes == 1) { return "Hole-in-One"; } if (par <= 0) { return "Finished"; } int num = strokes - par; switch (num) { case -4: return "Condor"; case -3: return "Albatross"; case -2: return "Eagle"; case -1: return "Birdie"; case 0: return "Par"; case 1: return "Bogey"; case 2: return "Double Bogey"; case 3: return "Triple Bogey"; default: if (num >= -4) { return $"{num} over par"; } return $"{Mathf.Abs(num)} under par"; } } private static void ShowProGolfHoleOutPopup(PlayerInfo player) { if (!IsActiveProGolf() || (Object)(object)((player != null) ? player.PlayerId : null) == (Object)null) { return; } ulong guid = player.PlayerId.Guid; if (!holeOutPopupsShown.Add(guid)) { return; } int currentHoleShotCount = GetCurrentHoleShotCount(player); string golfScoreName = GetGolfScoreName(currentHoleShotCount, GetCurrentHoleParSafe()); string text = ((currentHoleShotCount == 1) ? "1 shot" : $"{currentHoleShotCount} shots"); isShowingProGolfHoleOutPopup = true; try { playerPopUpTextMethod?.Invoke(player, new object[2] { text + "\n" + golfScoreName, false }); } finally { isShowingProGolfHoleOutPopup = false; } } private static bool AllActivePlayersResolvedForCurrentHole() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Invalid comparison between Unknown and I4 //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) SyncList playerStates = CourseManager.PlayerStates; if (playerStates == null) { return false; } int num = 0; int num2 = 0; Enumerator enumerator = playerStates.GetEnumerator(); try { while (enumerator.MoveNext()) { PlayerState current = enumerator.Current; if (current.isConnected && !current.isSpectator && (int)current.matchResolution != -1) { num++; if ((int)current.matchResolution != 0) { num2++; } } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } if (num > 0) { return num == num2; } return false; } private static List GetActivePlayerGuids() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 //IL_003c: Unknown result type (might be due to invalid IL or missing references) List list = new List(); SyncList playerStates = CourseManager.PlayerStates; if (playerStates == null) { return list; } Enumerator enumerator = playerStates.GetEnumerator(); try { while (enumerator.MoveNext()) { PlayerState current = enumerator.Current; if (current.isConnected && !current.isSpectator && (int)current.matchResolution != -1) { list.Add(current.playerGuid); } } return list; } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } } private static void UpdateScoreboardEntryProGolfStats(ScoreboardEntry entry, PlayerState playerState) { //IL_0022: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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) if ((Object)(object)entry == (Object)null) { return; } TextMeshProUGUI orCreateScoreboardEntryStatsLabel = GetOrCreateScoreboardEntryStatsLabel(entry); if (!((Object)(object)orCreateScoreboardEntryStatsLabel == (Object)null)) { if (!IsProGolfScoringActive() || playerState.isSpectator || playerState.playerGuid == 0L) { ((Component)orCreateScoreboardEntryStatsLabel).gameObject.SetActive(false); HideScoreboardEntryReadyIndicator(entry); return; } CaptureNativeScoreboardRowRelativeScore(entry, playerState.playerGuid); perfectShotCounts.TryGetValue(playerState.playerGuid, out var value); cartBestFlipStreaks.TryGetValue(playerState.playerGuid, out var value2); string golfScoreName = GetGolfScoreName(playerState.matchStrokes, GetCurrentHoleParSafe()); string text = BuildPlayerHighlightText(playerState.playerGuid); bool flag = GetActivePlayerGuids().Count >= 4; ConfigureScoreboardEntryStatsLabel(orCreateScoreboardEntryStatsLabel, flag); ((TMP_Text)orCreateScoreboardEntryStatsLabel).text = (flag ? $"Strokes {playerState.matchStrokes} ({golfScoreName}) | Points {playerState.courseScore}\n{CompactHighlightText(text)} | Perfect {value} | Flip {value2}" : $"Strokes {playerState.matchStrokes} ({golfScoreName}) | Points {playerState.courseScore}\n{text}\nPerfect {value} | Cart Flip {value2}"); ((Component)orCreateScoreboardEntryStatsLabel).gameObject.SetActive(true); UpdateScoreboardEntryReadyIndicator(entry, playerState); } } private static void ConfigureScoreboardEntryStatsLabel(TextMeshProUGUI label, bool compact) { //IL_0039: 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_0062: 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_006d: 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) if (!((Object)(object)label == (Object)null)) { RectTransform component = ((Component)label).GetComponent(); if ((Object)(object)component != (Object)null) { component.anchorMin = (compact ? new Vector2(0.04f, 0f) : new Vector2(0.04f, 0.01f)); component.anchorMax = (compact ? new Vector2(0.96f, 0.44f) : new Vector2(0.96f, 0.6f)); component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; } ((TMP_Text)label).fontSizeMin = (compact ? 6f : 7f); ((TMP_Text)label).fontSizeMax = (compact ? 10f : 12f); ((TMP_Text)label).lineSpacing = (compact ? (-18f) : 0f); } } private static string CompactHighlightText(string highlights) { if (string.IsNullOrWhiteSpace(highlights) || highlights == "-") { return "Awards -"; } return highlights.Replace("Longest Drive", "LD").Replace("Closest to Pin", "CTP").Replace("Chip-in", "Chip"); } private static void CaptureNativeScoreboardRowRelativeScore(ScoreboardEntry entry, ulong playerGuid) { if ((Object)(object)entry == (Object)null || playerGuid == 0L) { return; } string value = null; int num = int.MaxValue; TMP_Text[] componentsInChildren = ((Component)entry).GetComponentsInChildren(true); foreach (TMP_Text val in componentsInChildren) { if ((Object)(object)val == (Object)null || IsProGolfInjectedScoreboardText(val)) { continue; } string text = (val.text ?? string.Empty).Trim(); if (TryParseNativeRelativeScoreText(text, out var value2)) { int num2 = Mathf.Abs(value2); if (num2 <= 40 && (num2 < num || (num2 == num && text.StartsWith("+", StringComparison.Ordinal)))) { num = num2; value = FormatRelativeToPar(value2); } } } if (!string.IsNullOrWhiteSpace(value)) { scoreboardRowRelativeScoreTexts[playerGuid] = value; } } private static bool IsProGolfInjectedScoreboardText(TMP_Text text) { Transform val = text.transform; while ((Object)(object)val != (Object)null) { if ((((Object)val).name ?? string.Empty).StartsWith("ProGolfPlus", StringComparison.Ordinal)) { return true; } val = val.parent; } return false; } private static bool TryParseNativeRelativeScoreText(string text, out int value) { value = 0; if (string.IsNullOrWhiteSpace(text)) { return false; } string text2 = text.Trim(); if (text2.Equals("E", StringComparison.OrdinalIgnoreCase)) { return true; } if (!text2.StartsWith("+", StringComparison.Ordinal) && !text2.StartsWith("-", StringComparison.Ordinal)) { return false; } return int.TryParse(text2, out value); } private static string BuildPlayerHighlightText(ulong playerGuid) { List list = new List(); if (holeStatsLongestDriveDistances.TryGetValue(playerGuid, out var value)) { list.Add("Longest Drive " + FormatDistanceYards(value)); } if (holeStatsClosestToPinDistances.TryGetValue(playerGuid, out var value2)) { list.Add("Closest " + FormatDistanceFeet(value2)); } if (holeStatsChipInDistances.TryGetValue(playerGuid, out var value3)) { list.Add("Chip-in " + FormatDistanceYards(value3)); } if (list.Count != 0) { return string.Join(" | ", list); } return "Highlights -"; } private static TextMeshProUGUI GetOrCreateScoreboardEntryStatsLabel(ScoreboardEntry entry) { //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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) if (scoreboardEntryStatLabels.TryGetValue(entry, out var value) && (Object)(object)value != (Object)null) { return value; } object? obj = scoreboardEntryStatsBackgroundField?.GetValue(entry); Image val = (Image)((obj is Image) ? obj : null); Transform val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform : ((Component)entry).transform); GameObject val3 = new GameObject("ProGolfPlusStats"); val3.transform.SetParent(val2, false); RectTransform obj2 = val3.AddComponent(); obj2.anchorMin = new Vector2(0.04f, 0.01f); obj2.anchorMax = new Vector2(0.96f, 0.6f); obj2.offsetMin = Vector2.zero; obj2.offsetMax = Vector2.zero; TextMeshProUGUI val4 = val3.AddComponent(); object? obj3 = scoreboardEntryNameField?.GetValue(entry); TextMeshProUGUI val5 = (TextMeshProUGUI)((obj3 is TextMeshProUGUI) ? obj3 : null); if ((Object)(object)val5 != (Object)null) { ((TMP_Text)val4).font = ((TMP_Text)val5).font; ((TMP_Text)val4).fontSharedMaterial = ((TMP_Text)val5).fontSharedMaterial; } ((TMP_Text)val4).alignment = (TextAlignmentOptions)514; ((TMP_Text)val4).enableAutoSizing = true; ((TMP_Text)val4).fontSizeMin = 7f; ((TMP_Text)val4).fontSizeMax = 12f; ((Graphic)val4).color = new Color(0.82f, 0.88f, 1f, 1f); ((Graphic)val4).raycastTarget = false; ((TMP_Text)val4).text = string.Empty; scoreboardEntryStatLabels[entry] = val4; return val4; } private static void UpdateScoreboardEntryReadyIndicator(ScoreboardEntry entry, PlayerState playerState) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_00a5: 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) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)entry == (Object)null) { return; } if (!IsReadyUpWindowActive() || playerState.playerGuid == 0L || playerState.isSpectator) { HideScoreboardEntryReadyIndicator(entry); return; } GameObject orCreateScoreboardEntryReadyIndicator = GetOrCreateScoreboardEntryReadyIndicator(entry); if (!((Object)(object)orCreateScoreboardEntryReadyIndicator == (Object)null)) { bool flag = IsPlayerReadyForCurrentHole(playerState.playerGuid); orCreateScoreboardEntryReadyIndicator.SetActive(true); Transform obj = orCreateScoreboardEntryReadyIndicator.transform.Find("Flag"); Image val = ((obj != null) ? ((Component)obj).GetComponent() : null); if ((Object)(object)val != (Object)null) { ((Graphic)val).color = (flag ? new Color(0.26f, 0.78f, 0.32f, 1f) : new Color(0.94f, 0.18f, 0.22f, 1f)); } Transform obj2 = orCreateScoreboardEntryReadyIndicator.transform.Find("Label"); TextMeshProUGUI val2 = ((obj2 != null) ? ((Component)obj2).GetComponent() : null); if ((Object)(object)val2 != (Object)null) { ((TMP_Text)val2).text = (flag ? "READY" : "A"); ((Graphic)val2).color = (flag ? new Color(0.19f, 0.5f, 0.25f, 1f) : new Color(0.7f, 0.18f, 0.18f, 1f)); } } } private static void HideScoreboardEntryReadyIndicator(ScoreboardEntry entry) { if ((Object)(object)entry != (Object)null && scoreboardEntryReadyIndicators.TryGetValue(entry, out var value) && (Object)(object)value != (Object)null) { value.SetActive(false); } } private static GameObject GetOrCreateScoreboardEntryReadyIndicator(ScoreboardEntry entry) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0083: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) if (scoreboardEntryReadyIndicators.TryGetValue(entry, out var value) && (Object)(object)value != (Object)null) { return value; } Transform transform = ((Component)entry).transform; GameObject val = new GameObject("ProGolfPlusReadyFlag"); val.transform.SetParent(transform, false); RectTransform obj = val.AddComponent(); obj.anchorMin = new Vector2(0.015f, 0.1f); obj.anchorMax = new Vector2(0.115f, 0.9f); obj.offsetMin = Vector2.zero; obj.offsetMax = Vector2.zero; GameObject val2 = new GameObject("Pole"); val2.transform.SetParent(val.transform, false); RectTransform obj2 = val2.AddComponent(); obj2.anchorMin = new Vector2(0.24f, 0.18f); obj2.anchorMax = new Vector2(0.3f, 0.86f); obj2.offsetMin = Vector2.zero; obj2.offsetMax = Vector2.zero; Image obj3 = val2.AddComponent(); ((Graphic)obj3).color = new Color(0.96f, 0.96f, 0.92f, 1f); ((Graphic)obj3).raycastTarget = false; GameObject val3 = new GameObject("Flag"); val3.transform.SetParent(val.transform, false); RectTransform obj4 = val3.AddComponent(); obj4.anchorMin = new Vector2(0.28f, 0.5f); obj4.anchorMax = new Vector2(0.72f, 0.86f); obj4.offsetMin = Vector2.zero; obj4.offsetMax = Vector2.zero; Image obj5 = val3.AddComponent(); obj5.sprite = GetReadyFlagSprite(); ((Graphic)obj5).color = new Color(0.94f, 0.18f, 0.22f, 1f); ((Graphic)obj5).raycastTarget = false; GameObject val4 = new GameObject("Label"); val4.transform.SetParent(val.transform, false); RectTransform obj6 = val4.AddComponent(); obj6.anchorMin = new Vector2(0.58f, 0.06f); obj6.anchorMax = new Vector2(1f, 0.5f); obj6.offsetMin = Vector2.zero; obj6.offsetMax = Vector2.zero; TextMeshProUGUI val5 = val4.AddComponent(); object? obj7 = scoreboardEntryNameField?.GetValue(entry); TextMeshProUGUI val6 = (TextMeshProUGUI)((obj7 is TextMeshProUGUI) ? obj7 : null); if ((Object)(object)val6 != (Object)null) { ((TMP_Text)val5).font = ((TMP_Text)val6).font; ((TMP_Text)val5).fontSharedMaterial = ((TMP_Text)val6).fontSharedMaterial; } ((TMP_Text)val5).alignment = (TextAlignmentOptions)4097; ((TMP_Text)val5).enableAutoSizing = true; ((TMP_Text)val5).fontSizeMin = 6f; ((TMP_Text)val5).fontSizeMax = 12f; ((TMP_Text)val5).fontStyle = (FontStyles)1; ((Graphic)val5).color = new Color(0.7f, 0.18f, 0.18f, 1f); ((Graphic)val5).raycastTarget = false; ((TMP_Text)val5).text = "A"; val.SetActive(false); scoreboardEntryReadyIndicators[entry] = val; return val; } private static void UpdateScoreboardProGolfStatCard(Scoreboard scoreboard) { //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_0023: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)scoreboard == (Object)null || !IsProGolfScoringActive()) { HideScoreboardAllPlayerStatsPanel(scoreboard); HideScoreboardReadyUpPanel(scoreboard); return; } PlayerState localPlayerState = CourseManager.GetLocalPlayerState(); if (localPlayerState.playerGuid != 0L && !localPlayerState.isSpectator) { perfectShotCounts.TryGetValue(localPlayerState.playerGuid, out var value); cartBestFlipStreaks.TryGetValue(localPlayerState.playerGuid, out var value2); object? obj = scoreboardBestHoleScoreStatField?.GetValue(scoreboard); ScoreboardStat stat = (ScoreboardStat)((obj is ScoreboardStat) ? obj : null); object? obj2 = scoreboardLongestChipInStatField?.GetValue(scoreboard); ScoreboardStat stat2 = (ScoreboardStat)((obj2 is ScoreboardStat) ? obj2 : null); object? obj3 = scoreboardItemPickupsStatField?.GetValue(scoreboard); ScoreboardStat stat3 = (ScoreboardStat)((obj3 is ScoreboardStat) ? obj3 : null); object? obj4 = scoreboardKnockoutRatioStatField?.GetValue(scoreboard); object? stat4 = ((obj4 is ScoreboardStat) ? obj4 : null); UpdateScoreboardMainStrokeCard(scoreboard, localPlayerState); UpdateScoreboardStat(stat, "Best Hole Score", "Longest Drive", GetLongestDriveAwardText()); UpdateScoreboardStat(stat2, "Longest Chip In", "Closest to Pin", GetClosestToPinAwardText()); UpdateScoreboardStat(stat3, "Item Pickups", "Chip-ins", GetChipInAwardText()); UpdateScoreboardStat((ScoreboardStat)stat4, "Knockout Ratio", "My Stats", $"Perfect {value} | Flip {value2}"); UpdateScoreboardAllPlayerStatsPanel(scoreboard); UpdateScoreboardReadyUpPanel(scoreboard); } } private static void UpdateScoreboardAllPlayerStatsPanel(Scoreboard scoreboard) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)scoreboard == (Object)null) { return; } GameObject orCreateScoreboardAllPlayerStatsPanel = GetOrCreateScoreboardAllPlayerStatsPanel(scoreboard); if ((Object)(object)orCreateScoreboardAllPlayerStatsPanel == (Object)null) { return; } orCreateScoreboardAllPlayerStatsPanel.SetActive(true); Transform val = orCreateScoreboardAllPlayerStatsPanel.transform.Find("Content"); if ((Object)(object)val == (Object)null) { return; } for (int num = val.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)val.GetChild(num)).gameObject); } List sortedActivePlayerStates = GetSortedActivePlayerStates(); if (sortedActivePlayerStates.Count == 0) { return; } ConfigureAllPlayerStatsPanelLayout(orCreateScoreboardAllPlayerStatsPanel, sortedActivePlayerStates.Count); foreach (PlayerState item in sortedActivePlayerStates) { CreateAllPlayerStatsCard(val, item, scoreboard); } } private static void HideScoreboardAllPlayerStatsPanel(Scoreboard scoreboard) { if ((Object)(object)scoreboard != (Object)null && scoreboardAllPlayerStatsPanels.TryGetValue(scoreboard, out var value) && (Object)(object)value != (Object)null) { value.SetActive(false); } } private static void UpdateScoreboardMainStrokeCard(Scoreboard scoreboard, PlayerState localState) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)scoreboard == (Object)null || localState.playerGuid == 0L || localState.isSpectator) { return; } TMP_Text val = FindScoreboardText(((Component)scoreboard).transform, "Your Score") ?? FindScoreboardText(((Component)scoreboard).transform, "Your Strokes"); if ((Object)(object)val == (Object)null) { return; } DisableLocalizers((Component)(object)val); val.text = "Your Score"; Transform val2 = FindAncestorContainingText(val.transform, "Longest Drive", 5) ?? FindAncestorContainingText(val.transform, "Best Hole Score", 5) ?? FindAncestorContainingText(val.transform, "Closest to Pin", 5) ?? FindAncestorContainingText(val.transform, "Longest Chip In", 5) ?? val.transform.parent; if ((Object)(object)val2 == (Object)null) { return; } string value = localState.courseScore.ToString(); string value2 = Mathf.Max(0, localState.courseStrokes).ToString(); string scoreboardRelativeToParText = GetScoreboardRelativeToParText(localState); TMP_Text val3 = null; float num = 0f; TMP_Text[] componentsInChildren = ((Component)val2).GetComponentsInChildren(true); foreach (TMP_Text val4 in componentsInChildren) { if ((Object)(object)val4 == (Object)null || val4 == val) { continue; } string text = (val4.text ?? string.Empty).Trim(); if (text.Equals(value, StringComparison.Ordinal) || text.Equals(value2, StringComparison.Ordinal) || IsRelativeToParText(text)) { float num2 = ((val4.fontSize > 0f) ? val4.fontSize : val4.fontSizeMax); if (num2 >= num) { num = num2; val3 = val4; } } } if ((Object)(object)val3 != (Object)null) { DisableLocalizers((Component)(object)val3); val3.text = scoreboardRelativeToParText; } } private static int GetCourseRelativeToPar(PlayerState state) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Max(0, state.courseStrokes); int knownCumulativeParThroughCurrentHole = GetKnownCumulativeParThroughCurrentHole(); return num - knownCumulativeParThroughCurrentHole; } private static string GetScoreboardRelativeToParText(PlayerState state) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (scoreboardRowRelativeScoreTexts.TryGetValue(state.playerGuid, out var value) && !string.IsNullOrWhiteSpace(value)) { return value; } return FormatRelativeToPar(GetCourseRelativeToPar(state)); } private static int GetKnownCumulativeParThroughCurrentHole() { int currentHoleGlobalIndex = CourseManager.CurrentHoleGlobalIndex; int num = 0; foreach (KeyValuePair item in parByHoleIndex) { if (item.Key <= currentHoleGlobalIndex) { num += Mathf.Max(0, item.Value); } } return num; } private static string FormatRelativeToPar(int relativeToPar) { if (relativeToPar == 0) { return "E"; } if (relativeToPar <= 0) { return relativeToPar.ToString(); } return $"+{relativeToPar}"; } private static bool IsRelativeToParText(string text) { if (string.IsNullOrWhiteSpace(text)) { return false; } string text2 = text.Trim(); if (text2.Equals("E", StringComparison.OrdinalIgnoreCase)) { return true; } if (!int.TryParse(text2, out var result)) { if (text2.StartsWith("+", StringComparison.Ordinal)) { return int.TryParse(text2.Substring(1), out result); } return false; } return true; } private static TMP_Text FindScoreboardText(Transform root, string expectedText) { if ((Object)(object)root == (Object)null) { return null; } TMP_Text[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (TMP_Text val in componentsInChildren) { if ((Object)(object)val != (Object)null && string.Equals((val.text ?? string.Empty).Trim(), expectedText, StringComparison.OrdinalIgnoreCase)) { return val; } } return null; } private static Transform FindAncestorContainingText(Transform start, string expectedText, int maxDepth) { Transform val = start; int num = 0; while (num < maxDepth && (Object)(object)val != (Object)null) { if ((Object)(object)FindScoreboardText(val, expectedText) != (Object)null) { return val; } num++; val = val.parent; } return null; } private static void DisableLocalizers(Component component) { if ((Object)(object)component == (Object)null) { return; } Behaviour[] components = component.GetComponents(); foreach (Behaviour val in components) { if ((Object)(object)val != (Object)null && ((object)val).GetType().Name == "LocalizeStringEvent") { val.enabled = false; } } } private static void UpdateScoreboardReadyUpPanel(Scoreboard scoreboard) { if (!((Object)(object)scoreboard == (Object)null)) { HideScoreboardReadyUpPanel(scoreboard); } } private static void HideScoreboardReadyUpPanel(Scoreboard scoreboard) { if ((Object)(object)scoreboard != (Object)null && scoreboardReadyUpPanels.TryGetValue(scoreboard, out var value) && (Object)(object)value != (Object)null) { value.SetActive(false); } } private static GameObject GetOrCreateScoreboardReadyUpPanel(Scoreboard scoreboard) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0099: 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_00c5: 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_00eb: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) if (scoreboardReadyUpPanels.TryGetValue(scoreboard, out var value) && (Object)(object)value != (Object)null) { return value; } Transform scoreboardMiddlePanelParent = GetScoreboardMiddlePanelParent(scoreboard); GameObject val = new GameObject("ProGolfPlusReadyUpPanel"); val.transform.SetParent(scoreboardMiddlePanelParent, false); RectTransform obj = val.AddComponent(); obj.anchorMin = new Vector2(0.745f, 0.065f); obj.anchorMax = new Vector2(0.965f, 0.225f); obj.offsetMin = Vector2.zero; obj.offsetMax = Vector2.zero; Image obj2 = val.AddComponent(); ((Graphic)obj2).color = new Color(0.94f, 0.91f, 0.84f, 0.95f); ((Graphic)obj2).raycastTarget = false; GameObject val2 = new GameObject("Accent"); val2.transform.SetParent(val.transform, false); RectTransform obj3 = val2.AddComponent(); obj3.anchorMin = new Vector2(0f, 0.76f); obj3.anchorMax = new Vector2(1f, 1f); obj3.offsetMin = Vector2.zero; obj3.offsetMax = Vector2.zero; Image obj4 = val2.AddComponent(); obj4.sprite = GetCardHeaderSprite(); obj4.type = (Type)2; ((Graphic)obj4).color = new Color(1f, 1f, 1f, 0.9f); ((Graphic)obj4).raycastTarget = false; scoreboardReadyUpPanels[scoreboard] = val; return val; } private static TextMeshProUGUI SetReadyPanelText(Transform parent, Scoreboard scoreboard, string name, Vector2 anchorMin, Vector2 anchorMax, string text, float fontMin, float fontMax, Color color, TextAlignmentOptions alignment) { //IL_0027: 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_0030: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_005a: 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) Transform val = parent.Find(name); TextMeshProUGUI val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if ((Object)(object)val2 == (Object)null) { val2 = CreateCardText(parent, scoreboard, name, anchorMin, anchorMax, text, fontMin, fontMax, color, alignment); } RectTransform component = ((Component)val2).GetComponent(); if ((Object)(object)component != (Object)null) { component.anchorMin = anchorMin; component.anchorMax = anchorMax; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; } ((TMP_Text)val2).enableAutoSizing = true; ((TMP_Text)val2).fontSizeMin = fontMin; ((TMP_Text)val2).fontSizeMax = fontMax; ((Graphic)val2).color = color; ((TMP_Text)val2).alignment = alignment; ((TMP_Text)val2).text = text; return val2; } private static GameObject GetOrCreateScoreboardAllPlayerStatsPanel(Scoreboard scoreboard) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0083: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown if (scoreboardAllPlayerStatsPanels.TryGetValue(scoreboard, out var value) && (Object)(object)value != (Object)null) { return value; } Transform scoreboardMiddlePanelParent = GetScoreboardMiddlePanelParent(scoreboard); GameObject val = new GameObject("ProGolfPlusAllPlayerStats"); val.transform.SetParent(scoreboardMiddlePanelParent, false); RectTransform obj = val.AddComponent(); obj.anchorMin = new Vector2(0.16f, 0.08f); obj.anchorMax = new Vector2(0.72f, 0.27f); obj.offsetMin = Vector2.zero; obj.offsetMax = Vector2.zero; GameObject val2 = new GameObject("Content"); val2.transform.SetParent(val.transform, false); RectTransform obj2 = val2.AddComponent(); obj2.anchorMin = Vector2.zero; obj2.anchorMax = Vector2.one; obj2.offsetMin = Vector2.zero; obj2.offsetMax = Vector2.zero; GridLayoutGroup obj3 = val2.AddComponent(); obj3.cellSize = new Vector2(238f, 154f); obj3.spacing = new Vector2(10f, 10f); obj3.constraint = (Constraint)1; obj3.constraintCount = 4; ((LayoutGroup)obj3).childAlignment = (TextAnchor)0; ((LayoutGroup)obj3).padding = new RectOffset(6, 6, 6, 6); scoreboardAllPlayerStatsPanels[scoreboard] = val; return val; } private static Transform GetScoreboardMiddlePanelParent(Scoreboard scoreboard) { object? obj = scoreboardEntryParentField?.GetValue(scoreboard); Transform val = (Transform)((obj is Transform) ? obj : null); if ((Object)(object)val != (Object)null && (Object)(object)val.parent != (Object)null) { return val.parent; } RectTransform val2 = (((Object)(object)scoreboard != (Object)null) ? ((Component)scoreboard).GetComponent() : null); if (!((Object)(object)val2 != (Object)null)) { if (scoreboard == null) { return null; } return ((Component)scoreboard).transform; } return (Transform)(object)val2; } private static void ConfigureAllPlayerStatsPanelLayout(GameObject panel, int playerCount) { //IL_0055: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_015b: 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_0193: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: 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_01d6: Expected O, but got Unknown //IL_0144: Unknown result type (might be due to invalid IL or missing references) RectTransform component = panel.GetComponent(); Transform val = panel.transform.Find("Content"); GridLayoutGroup val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if (!((Object)(object)component == (Object)null) && !((Object)(object)val2 == (Object)null)) { int num = Mathf.Max(1, playerCount); if (num == 1) { component.anchorMin = new Vector2(0.3f, 0.055f); component.anchorMax = new Vector2(0.7f, 0.245f); val2.constraintCount = 1; ((LayoutGroup)val2).childAlignment = (TextAnchor)4; val2.cellSize = new Vector2(360f, 132f); } else if (num == 2) { component.anchorMin = new Vector2(0.18f, 0.055f); component.anchorMax = new Vector2(0.84f, 0.245f); val2.constraintCount = 2; ((LayoutGroup)val2).childAlignment = (TextAnchor)4; val2.cellSize = new Vector2(320f, 128f); } else if (num <= 4) { component.anchorMin = new Vector2(0.07f, 0.05f); component.anchorMax = new Vector2(0.95f, 0.245f); val2.constraintCount = num; ((LayoutGroup)val2).childAlignment = (TextAnchor)4; val2.cellSize = new Vector2((num == 3) ? 300f : 240f, 116f); } else { component.anchorMin = new Vector2(0.06f, 0.04f); component.anchorMax = new Vector2(0.95f, 0.285f); val2.constraintCount = 3; ((LayoutGroup)val2).childAlignment = (TextAnchor)4; val2.cellSize = new Vector2(220f, 104f); } val2.spacing = ((num <= 4) ? new Vector2(14f, 10f) : new Vector2(10f, 8f)); ((LayoutGroup)val2).padding = new RectOffset(6, 6, 6, 6); } } private static void CreateAllPlayerStatsCard(Transform parent, PlayerState state, Scoreboard scoreboard) { //IL_0005: 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_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_0041: 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_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_0058: 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_006c: 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_0090: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //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_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject($"ProGolfPlusStats_{state.playerGuid}"); val.transform.SetParent(parent, false); ((Graphic)val.AddComponent()).color = new Color(0.94f, 0.91f, 0.84f, 0.94f); Vector2 val2 = (val.GetComponent().sizeDelta = GetAllPlayerStatsCardSize(parent)); bool flag = val2.y < 124f; CreateCardImage(val.transform, "Header", new Vector2(0f, flag ? 0.72f : 0.7f), Vector2.one, GetCardHeaderSprite(), new Color(1f, 1f, 1f, 0.94f)); string playerName = GetPlayerName(null, state.playerGuid); string golfScoreName = GetGolfScoreName(state.matchStrokes, GetCurrentHoleParSafe()); perfectShotCounts.TryGetValue(state.playerGuid, out var value); cartBestFlipStreaks.TryGetValue(state.playerGuid, out var value2); CreateCardText(val.transform, scoreboard, "Name", new Vector2(0.05f, 0.8f), new Vector2(0.95f, 0.97f), "" + playerName + "", flag ? 8f : 9f, flag ? 15f : 17f, new Color(0.3f, 0.25f, 0.23f, 1f), (TextAlignmentOptions)514); CreateCardText(val.transform, scoreboard, "Score", new Vector2(0.06f, 0.64f), new Vector2(0.94f, 0.78f), "Score " + GetScoreboardRelativeToParText(state) + "", flag ? 8f : 9f, flag ? 14f : 16f, new Color(0.32f, 0.3f, 0.3f, 1f), (TextAlignmentOptions)514); CreateStatBand(val.transform, scoreboard, 0.51f, "Hole", $"{state.matchStrokes} shots | {golfScoreName}", flag); CreateStatBand(val.transform, scoreboard, 0.34f, "Awards", BuildPlayerAwardValueText(state.playerGuid), flag); CreateStatBand(val.transform, scoreboard, 0.17f, "Stats", $"Perfect {value} | Flip {value2}", flag); } private static Vector2 GetAllPlayerStatsCardSize(Transform parent) { //IL_002d: 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) GridLayoutGroup val = (((Object)(object)parent != (Object)null) ? ((Component)parent).GetComponent() : null); if (!((Object)(object)val != (Object)null)) { return new Vector2(238f, 154f); } return val.cellSize; } private static string BuildPlayerAwardValueText(ulong playerGuid) { List list = new List(); if (holeStatsLongestDriveDistances.TryGetValue(playerGuid, out var value)) { list.Add("LD " + FormatDistanceYards(value)); } if (holeStatsClosestToPinDistances.TryGetValue(playerGuid, out var value2)) { list.Add("CTP " + FormatDistanceFeet(value2)); } if (holeStatsChipInDistances.TryGetValue(playerGuid, out var value3)) { list.Add("Chip " + FormatDistanceYards(value3)); } if (list.Count != 0) { return string.Join(" | ", list); } return "-"; } private static void CreateStatBand(Transform parent, Scoreboard scoreboard, float centerY, string title, string value, bool compact) { //IL_003a: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) float num = (compact ? 0.065f : 0.075f); float num2 = (compact ? 0.06f : 0.07f); CreateCardImage(parent, title + "Band", new Vector2(0.06f, centerY + 0.035f), new Vector2(0.94f, centerY + 0.035f + num), GetCardBandSprite(), Color.white); CreateCardText(parent, scoreboard, title + "Title", new Vector2(0.08f, centerY + 0.035f), new Vector2(0.92f, centerY + 0.035f + num), title, compact ? 7f : 8f, compact ? 11f : 13f, new Color(0.88f, 0.37f, 0.18f, 1f), (TextAlignmentOptions)514); CreateCardText(parent, scoreboard, title + "Value", new Vector2(0.05f, centerY - num2), new Vector2(0.95f, centerY + 0.035f), value, compact ? 7f : 8f, compact ? 12f : 14f, new Color(0.28f, 0.26f, 0.27f, 1f), (TextAlignmentOptions)514); } private static Image CreateCardImage(Transform parent, string name, Vector2 anchorMin, Vector2 anchorMax, Sprite sprite, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); RectTransform obj = val.AddComponent(); obj.anchorMin = anchorMin; obj.anchorMax = anchorMax; obj.offsetMin = Vector2.zero; obj.offsetMax = Vector2.zero; Image obj2 = val.AddComponent(); obj2.sprite = sprite; ((Graphic)obj2).color = color; obj2.type = (Type)1; ((Graphic)obj2).raycastTarget = false; return obj2; } private static TextMeshProUGUI CreateCardText(Transform parent, Scoreboard scoreboard, string name, Vector2 anchorMin, Vector2 anchorMax, string text, float fontMin, float fontMax, Color color, TextAlignmentOptions alignment) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_006a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); RectTransform obj = val.AddComponent(); obj.anchorMin = anchorMin; obj.anchorMax = anchorMax; obj.offsetMin = Vector2.zero; obj.offsetMax = Vector2.zero; TextMeshProUGUI val2 = val.AddComponent(); ApplyScoreboardTextTemplate(scoreboard, val2); ((TMP_Text)val2).alignment = alignment; ((TMP_Text)val2).enableAutoSizing = true; ((TMP_Text)val2).fontSizeMin = fontMin; ((TMP_Text)val2).fontSizeMax = fontMax; ((Graphic)val2).color = color; ((Graphic)val2).raycastTarget = false; ((TMP_Text)val2).text = text; return val2; } private static Sprite GetCardHeaderSprite() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) return GetStripedSprite(ref proGolfCardHeaderTexture, ref proGolfCardHeaderSprite, new Color(1f, 0.95f, 0.25f, 1f), new Color(1f, 1f, 0.56f, 1f)); } private static Sprite GetCardBandSprite() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) return GetStripedSprite(ref proGolfCardBandTexture, ref proGolfCardBandSprite, new Color(1f, 0.89f, 0.64f, 0.8f), new Color(1f, 0.95f, 0.78f, 0.8f)); } private static Sprite GetReadyFlagSprite() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_00aa: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)proGolfReadyFlagSprite != (Object)null) { return proGolfReadyFlagSprite; } proGolfReadyFlagTexture = new Texture2D(24, 18, (TextureFormat)4, false) { name = "ProGolfPlusReadyFlagTexture", wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; Color val = default(Color); ((Color)(ref val))..ctor(1f, 1f, 1f, 0f); for (int i = 0; i < ((Texture)proGolfReadyFlagTexture).height; i++) { for (int j = 0; j < ((Texture)proGolfReadyFlagTexture).width; j++) { float num = (float)i / (float)Mathf.Max(1, ((Texture)proGolfReadyFlagTexture).height - 1); int num2 = Mathf.RoundToInt(Mathf.Lerp(22f, 8f, Mathf.Abs(num - 0.5f) * 2f)); proGolfReadyFlagTexture.SetPixel(j, i, (j < num2) ? Color.white : val); } } proGolfReadyFlagTexture.Apply(); proGolfReadyFlagSprite = Sprite.Create(proGolfReadyFlagTexture, new Rect(0f, 0f, (float)((Texture)proGolfReadyFlagTexture).width, (float)((Texture)proGolfReadyFlagTexture).height), new Vector2(0f, 0.5f), 24f); return proGolfReadyFlagSprite; } private static Sprite GetStripedSprite(ref Texture2D texture, ref Sprite sprite, Color baseColor, Color stripeColor) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_004c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)sprite != (Object)null) { return sprite; } texture = new Texture2D(32, 32, (TextureFormat)4, false) { name = "ProGolfPlusStripeTexture", wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)0 }; for (int i = 0; i < ((Texture)texture).height; i++) { for (int j = 0; j < ((Texture)texture).width; j++) { bool flag = (j + i) % 16 < 8; texture.SetPixel(j, i, flag ? stripeColor : baseColor); } } texture.Apply(); sprite = Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0.5f, 0.5f), 32f, 0u, (SpriteMeshType)0, new Vector4(8f, 8f, 8f, 8f)); return sprite; } private static List GetSortedActivePlayerStates() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 //IL_003c: Unknown result type (might be due to invalid IL or missing references) List list = new List(); SyncList playerStates = CourseManager.PlayerStates; if (playerStates == null) { return list; } Enumerator enumerator = playerStates.GetEnumerator(); try { while (enumerator.MoveNext()) { PlayerState current = enumerator.Current; if (current.isConnected && !current.isSpectator && (int)current.matchResolution != -1) { list.Add(current); } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } list.Sort((PlayerState left, PlayerState right) => ((PlayerState)(ref left)).CompareTo(right)); return list; } private static void ApplyScoreboardTextTemplate(Scoreboard scoreboard, TextMeshProUGUI label) { if ((Object)(object)scoreboard == (Object)null || (Object)(object)label == (Object)null) { return; } TextMeshProUGUI[] componentsInChildren = ((Component)scoreboard).GetComponentsInChildren(true); foreach (TextMeshProUGUI val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && val != label && !((Object)(object)((TMP_Text)val).font == (Object)null)) { ((TMP_Text)label).font = ((TMP_Text)val).font; ((TMP_Text)label).fontSharedMaterial = ((TMP_Text)val).fontSharedMaterial; break; } } } private static string GetLongestDriveAwardText() { using (Dictionary.Enumerator enumerator = holeStatsLongestDriveDistances.GetEnumerator()) { if (enumerator.MoveNext()) { KeyValuePair current = enumerator.Current; return GetPlayerName(null, current.Key) + " " + FormatDistanceYards(current.Value); } } return "-"; } private static string GetClosestToPinAwardText() { using (Dictionary.Enumerator enumerator = holeStatsClosestToPinDistances.GetEnumerator()) { if (enumerator.MoveNext()) { KeyValuePair current = enumerator.Current; return GetPlayerName(null, current.Key) + " " + FormatDistanceFeet(current.Value); } } return "-"; } private static string GetChipInAwardText() { List list = new List(); foreach (KeyValuePair holeStatsChipInDistance in holeStatsChipInDistances) { list.Add(GetPlayerName(null, holeStatsChipInDistance.Key) + " " + FormatDistanceYards(holeStatsChipInDistance.Value)); } if (list.Count != 0) { return string.Join(", ", list); } return "-"; } private static void UpdateScoreboardStat(ScoreboardStat stat, string oldTitle, string newTitle, string value) { if (!((Object)(object)stat == (Object)null)) { stat.Initialize(value, (Sprite)null); TryReplaceScoreboardStatTitle(stat, oldTitle, newTitle); } } private static void TryReplaceScoreboardStatTitle(ScoreboardStat stat, string oldTitle, string newTitle) { object? obj = scoreboardStatLabelField?.GetValue(stat); TextMeshProUGUI val = (TextMeshProUGUI)((obj is TextMeshProUGUI) ? obj : null); Transform val2 = (((Object)(object)((Component)stat).transform.parent != (Object)null) ? ((Component)stat).transform.parent : ((Component)stat).transform); int num = 0; while (num < 3 && (Object)(object)val2 != (Object)null) { TMP_Text[] componentsInChildren = ((Component)val2).GetComponentsInChildren(true); foreach (TMP_Text val3 in componentsInChildren) { if ((Object)(object)val3 == (Object)null || (object)val3 == val) { continue; } string text = (val3.text ?? string.Empty).Trim(); if (!text.Equals(oldTitle, StringComparison.OrdinalIgnoreCase) && !text.Equals(newTitle, StringComparison.OrdinalIgnoreCase)) { continue; } Behaviour[] components = ((Component)val3).GetComponents(); foreach (Behaviour val4 in components) { if ((Object)(object)val4 != (Object)null && ((object)val4).GetType().Name == "LocalizeStringEvent") { val4.enabled = false; } } val3.text = newTitle; return; } num++; val2 = val2.parent; } } private static void PublishProGolfAnnouncement(string text) { string text2 = (lastObservedAnnouncementVersion = $"{CourseManager.CurrentHoleGlobalIndex}:{Time.unscaledTime:R}"); ShowTopAnnouncement(text); Lobby val = default(Lobby); if (BNetworkManager.TryGetSteamLobby(ref val)) { ((Lobby)(ref val)).SetData("codex_progolfplus_announcement_text", text); ((Lobby)(ref val)).SetData("codex_progolfplus_announcement_version", text2); } } private static string GetPlayerName(PlayerInfo player, ulong playerGuid) { string text = null; if ((Object)(object)((player != null) ? player.PlayerId : null) != (Object)null) { text = CourseManager.GetPlayerName(player.PlayerId); } if (string.IsNullOrEmpty(text) && playerGuid != 0L) { text = CourseManager.GetPlayerName(playerGuid); } if (!string.IsNullOrEmpty(text)) { return text; } return "Player"; } } }