using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Mirror; using RogueGolf.Core; using RogueGolf.CustomItems; using RogueGolf.CustomItems.Assets; using RogueGolf.Shared; using RogueGolf.Shared.Physics; using Steamworks; using Steamworks.Data; using TMPro; using Unity.Collections; using Unity.Mathematics; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Localization; using UnityEngine.Localization.Components; using UnityEngine.Localization.Settings; using UnityEngine.Localization.Tables; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.Splines; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace RogueGolf.Shared { internal sealed class SharedGravity { internal readonly GravityResolver Resolver = new GravityResolver(); private Vector3 baseline; private bool owned; internal bool TotalOverride => Resolver.Winner(NetworkTime.time) != null; internal float Effective => Resolver.Resolve(NetworkTime.time); internal Vector3 Base { get { //IL_000f: 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 (!owned) { return Physics.gravity; } return baseline; } } internal void Underlying(Vector3 baseVector, float combined) { //IL_001b: 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_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) if (!owned) { baseline = Physics.gravity; owned = true; } baseline = baseVector; Resolver.SetOrdinary("modifiers.combined", combined); Apply(); } internal void Override(string source, float total, int priority, double until) { //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) if (!owned) { baseline = Physics.gravity; owned = true; } Resolver.SetOverride(source, total, priority, until); Apply(); } internal void Remove(string source) { Resolver.RemoveOverride(source); Apply(); } internal void ClearModifiers() { Resolver.RemoveOrdinary("modifiers.combined"); Apply(); } internal void Apply() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) Resolver.Expire(NetworkTime.time); if (owned) { Physics.gravity = baseline * Effective; if (!TotalOverride && Resolver.Underlying == 1f) { owned = false; } } } internal string Inspect() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) return "=== EFFECTIVE GRAVITY STATE ===\nBase vector: " + ((object)Base/*cast due to .constrained prefix*/).ToString() + "\n" + Resolver.Inspect(NetworkTime.time) + "\nActual Physics.gravity: " + ((object)Physics.gravity/*cast due to .constrained prefix*/).ToString(); } } internal sealed class ResetSettingsSnapshot { private readonly Dictionary values; internal ResetSettingsSnapshot(ConfigFile config, Func section) { values = ((IEnumerable>)config).Where((KeyValuePair p) => section(p.Key.Section)).ToDictionary((KeyValuePair p) => p.Value, (KeyValuePair p) => p.Value.BoxedValue); } internal T Read(ConfigEntry entry) { if (!values.TryGetValue((ConfigEntryBase)(object)entry, out var value)) { return entry.Value; } return (T)value; } } } namespace RogueGolf.CustomItems { internal sealed class CustomItemRuntime : IDisposable { private sealed class Capture { internal uint Carrier; internal uint Victim; internal int Slot; internal Vector3 Position; internal Vector3 Velocity; internal Vector3 Fallback; internal double Until; internal bool Flying; internal GameObject Visual; } private sealed class CapturedPlayer { internal PlayerInfo Player; internal bool Kinematic; internal bool Visible; internal Vector3 Position; } private sealed class WeightRow { internal GameObject Root; internal SliderOption Slider; } private sealed class GravityEvent { internal string Id; internal double Start; internal double End; internal float Total; internal bool Applied; } private sealed class Blower { internal int Slot; internal Vector3 Direction; internal double Until; internal double NextForce; } private readonly Dictionary captures = new Dictionary(); private readonly Dictionary hiddenPlayers = new Dictionary(); private readonly Dictionary immunity = new Dictionary(); private ConfigEntry captureDuration; private ConfigEntry captureImmunity; private readonly RaycastHit[] captureHits = (RaycastHit[])(object)new RaycastHit[64]; internal static CustomItemRuntime Current; internal readonly CustomItemRegistry Registry; internal readonly SharedGravity Gravity; private readonly Action log; private readonly Func itemQuality; private readonly Func compatible; private readonly Action notice; private readonly Func peerReady; private readonly Func clientReady; private readonly Harmony itemHarmony; internal bool Faulted; private readonly Random random = new Random(); private readonly Dictionary held = new Dictionary(); private readonly Dictionary heldIds = new Dictionary(); private double nextVisualScan; private double nextState; private bool lastEnabled; private int scene = -1; private int hole = -2; private ConfigFile itemConfig; private ResetSettingsSnapshot resetSettings; private Action diagnosticCheck; private Action diagnosticUndo; private double diagnosticAt; private const int MaxPacket = 32768; private bool remoteEnabled; private bool serverRegistered; private bool clientRegistered; private long sequence; private long revision; private long acceptedRevision; private string session = ""; private string remoteSession = ""; private readonly Dictionary lastRequest = new Dictionary(); private readonly Dictionary lastSequence = new Dictionary(); private readonly Dictionary lastHello = new Dictionary(); private double nextHello; internal Tuple[] remoteSettings; private readonly Dictionary weightRows = new Dictionary(); private MatchSetupRules weightMenu; private double nextWeightRefresh; private bool weightUiFaulted; private bool weightGridVisible; private readonly HashSet customOnlyPools = new HashSet(); private HashSet poolGuardQueue; private static readonly FieldInfo nativeNonzeroQueue = AccessTools.Field(typeof(MatchSetupRules), "serverEnsureItemPoolSpawnChanceNonZeroQueue"); private UnityAction resetNativeItemWeights; private static readonly FieldInfo nativeSliders = AccessTools.Field(typeof(MatchSetupRules), "spawnChanceSliders"); private static readonly FieldInfo nativeInitialized = AccessTools.Field(typeof(MatchSetupRules), "isInitialized"); private static readonly FieldInfo nativeNavigation = AccessTools.Field(typeof(MatchSetupRules), "gridNavigationGroup"); private static readonly MethodInfo nativePool = AccessTools.DeclaredMethod(typeof(MatchSetupRules), "GetCurrentItemPool", (Type[])null, (Type[])null); private static readonly FieldInfo nativePoolIndex = AccessTools.Field(typeof(MatchSetupRules), "currentItemPoolIndex"); private readonly List gravityEvents = new List(); private ConfigEntry gravityWarning; private ConfigEntry gravityDuration; private ConfigEntry extremeChance; private readonly List> gravityRanges = new List>(); private GameObject gravityVisual; private ConfigEntry greenRadius; private ConfigEntry greenWarning; private ConfigEntry greenDuration; private string greenId = ""; private uint greenOwner; private Vector3 greenCenter; private float greenSize; private double greenStart; private double greenEnd; private GameObject greenVisual; private GameObject greenColliders; private static readonly FieldInfo projectileVelocity = AccessTools.Field(typeof(Hittable), "previousVelocity"); private static readonly MethodInfo becomeProjectile = AccessTools.Method(typeof(Hittable), "BecomeSwingProjectile", (Type[])null, (Type[])null); private static readonly MethodInfo setProjectileTarget = AccessTools.Method(typeof(Hittable), "ServerSetHomingTargetHittable", (Type[])null, (Type[])null); private static readonly FieldInfo rocketPrevious = AccessTools.Field(typeof(Rocket), "previousPosition"); private static readonly FieldInfo rocketRadius = AccessTools.Field(typeof(Rocket), "collisionRadius"); private static readonly FieldInfo rocketShootCollider = AccessTools.Field(typeof(Rocket), "shootCollider"); private static readonly FieldInfo rocketTimestamp = AccessTools.Field(typeof(Rocket), "launchOrReflectionTimestamp"); private static readonly FieldInfo rocketReflected = AccessTools.Field(typeof(Rocket), "isReflected"); private static readonly RaycastHit[] greenRocketHits = (RaycastHit[])(object)new RaycastHit[32]; private readonly Dictionary blowers = new Dictionary(); private readonly Collider[] blowerHits = (Collider[])(object)new Collider[128]; private readonly HashSet blowerBodies = new HashSet(); private ConfigEntry blowerRange; private ConfigEntry blowerAcceleration; private double nextBlowerInput; internal bool HostEnabled { get { if (!Faulted && NetworkServer.active && Setting(Registry.Master)) { return compatible(); } return false; } } internal bool Enabled { get { if (!Faulted) { if (!NetworkServer.active) { return remoteEnabled; } return HostEnabled; } return false; } } internal bool Playing { get { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 if (!SingletonBehaviour.HasInstance) { if ((int)CourseManager.MatchState >= 3) { return (int)CourseManager.MatchState < 6; } return false; } return true; } } private bool MenuMaster { get { if (!Faulted) { if (!NetworkServer.active) { return remoteEnabled; } return Registry.Master.Value; } return false; } } private bool ReflectionActive { get { if (HostEnabled && (Object)(object)greenColliders != (Object)null && NetworkTime.time >= greenStart) { return NetworkTime.time < greenEnd; } return false; } } private void ConfigureCapture(ConfigFile c) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown captureDuration = c.Bind("CustomItems.capture_ball", "MaximumSeconds", 3.5f, new ConfigDescription("Maximum occupied time, including throw flight.", (AcceptableValueBase)(object)new AcceptableValueRange(2f, 4f), Array.Empty())); captureImmunity = c.Bind("CustomItems.capture_ball", "ImmunitySeconds", 2.5f, new ConfigDescription("Post-release capture immunity.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 5f), Array.Empty())); } internal bool IsCaptured(uint id) { if (!hiddenPlayers.ContainsKey(id)) { return captures.Values.Any((Capture c) => c.Victim == id && c.Victim != 0); } return true; } internal bool CarrierSlot(uint id, out int slot) { slot = -1; if (!captures.TryGetValue(id, out var value) || value.Victim == 0) { return false; } slot = value.Slot; return true; } private bool ThrowCapture(PlayerInfo p, int slot, Vector3 direction) { //IL_00ce: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (captures.TryGetValue(((NetworkBehaviour)p).netId, out var value)) { if (value.Flying) { return false; } value.Flying = true; value.Position = ((Component)p).transform.position + Vector3.up * 1.2f + direction * 0.8f; value.Velocity = direction * 18f + Vector3.up * 3f; log("Occupied Capture Ball thrown carrier=" + ((NetworkBehaviour)p).netId); return true; } value = new Capture { Carrier = ((NetworkBehaviour)p).netId, Slot = slot, Flying = true, Position = ((Component)p).transform.position + Vector3.up * 1.2f + direction * 0.8f, Velocity = direction * 22f + Vector3.up * 2f, Until = NetworkTime.time + 3.5, Fallback = ((Component)p).transform.position }; captures[((NetworkBehaviour)p).netId] = value; log("Capture Ball launched carrier=" + ((NetworkBehaviour)p).netId); return true; } private void TickProjectiles() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_005b: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) Capture[] array = captures.Values.Where((Capture x) => x.Flying).ToArray(); foreach (Capture capture in array) { capture.Velocity += Physics.gravity * Time.fixedDeltaTime; Vector3 val = capture.Velocity * Time.fixedDeltaTime; int num2 = Physics.SphereCastNonAlloc(capture.Position, 0.2f, ((Vector3)(ref val)).normalized, captureHits, ((Vector3)(ref val)).magnitude, -1, (QueryTriggerInteraction)1); RaycastHit? val2 = null; for (int num3 = 0; num3 < num2; num3++) { RaycastHit value = captureHits[num3]; PlayerInfo componentInParent = ((Component)((RaycastHit)(ref value)).collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (((NetworkBehaviour)componentInParent).netId == capture.Carrier || ((NetworkBehaviour)componentInParent).netId == capture.Victim || IsCaptured(((NetworkBehaviour)componentInParent).netId))) { continue; } if (val2.HasValue) { float distance = ((RaycastHit)(ref value)).distance; RaycastHit value2 = val2.Value; if (!(distance < ((RaycastHit)(ref value2)).distance)) { continue; } } val2 = value; } if (val2.HasValue) { RaycastHit value3 = val2.Value; if (((RaycastHit)(ref value3)).distance > 0.001f) { capture.Position = ((RaycastHit)(ref value3)).point + ((RaycastHit)(ref value3)).normal * 0.25f; } if (capture.Victim != 0) { if (SingletonBehaviour.HasInstance && !BoundsManager.IsPointInLevelBoundsImmediate(capture.Position)) { KillCaptured(capture); } else { Release(capture, capture.Position, "landing"); } continue; } PlayerInfo componentInParent2 = ((Component)((RaycastHit)(ref value3)).collider).GetComponentInParent(); log("Capture collision " + ((Object)((RaycastHit)(ref value3)).collider).name + " victim=" + (((Object)(object)componentInParent2 == (Object)null) ? "none" : (((NetworkBehaviour)componentInParent2).netId + " eligible=" + Eligible(componentInParent2) + " resolved=" + componentInParent2.AsGolfer.IsMatchResolved + " visible=" + componentInParent2.Movement.IsVisible))); if ((Object)(object)componentInParent2 != (Object)null && Eligible(componentInParent2) && !IsCaptured(((NetworkBehaviour)componentInParent2).netId) && (!immunity.TryGetValue(((NetworkBehaviour)componentInParent2).netId, out var value4) || value4 <= NetworkTime.time)) { PlayerInfo val3 = Player(capture.Carrier); if ((Object)(object)val3 == (Object)null || IsCaptured(((NetworkBehaviour)val3).netId)) { FinishMiss(capture); continue; } capture.Victim = ((NetworkBehaviour)componentInParent2).netId; capture.Fallback = ((Component)componentInParent2).transform.position; capture.Until = NetworkTime.time + (double)Setting(captureDuration); capture.Flying = false; capture.Velocity = Vector3.zero; componentInParent2.AsGolfer.CancelAllActions(); ApplyCapturePlayer(capture.Victim, capture.Fallback, visible: false); BroadcastCapturePlayer(capture.Victim, capture.Fallback, visible: false); Notify("CAPTURED — throw within " + Setting(captureDuration).ToString("F1") + "s"); SendState(); } else { FinishMiss(capture); } } else { capture.Position += val; } } } private void TickCapture() { //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0207: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) Capture[] array = captures.Values.ToArray(); foreach (Capture capture in array) { PlayerInfo val = Player(capture.Carrier); PlayerInfo val2 = Player(capture.Victim); if (NetworkServer.active) { if (capture.Victim != 0 && capture.Flying && SingletonBehaviour.HasInstance && !BoundsManager.IsPointInLevelBoundsImmediate(capture.Position)) { KillCaptured(capture); continue; } if ((Object)(object)val == (Object)null || !Eligible(val) || IsCaptured(capture.Carrier) || capture.Slot >= val.Inventory.slots.Count || Registry.Get(val.Inventory.slots[capture.Slot].itemType)?.Id != "capture_ball") { if (capture.Victim != 0) { Release(capture, capture.Fallback, "carrier interrupted"); } else { FinishMiss(capture); } continue; } if (capture.Victim != 0 && ((Object)(object)val2 == (Object)null || val2.AsGolfer.IsMatchResolved || val2.AsSpectator.IsSpectating || val2.Movement.IsRespawningOrDrowning)) { Release(capture, capture.Fallback, "victim interrupted"); continue; } if (NetworkTime.time >= capture.Until || !Valid(capture.Position) || capture.Position.y < capture.Fallback.y - 60f) { if (capture.Victim != 0) { Release(capture, capture.Flying ? capture.Position : ((Component)val).transform.position, "timeout/bounds"); } else { FinishMiss(capture); } continue; } } if (capture.Victim != 0) { if (!hiddenPlayers.ContainsKey(capture.Victim) && (Object)(object)val2 != (Object)null) { ApplyCapturePlayer(capture.Victim, capture.Fallback, visible: false); } if ((Object)(object)val != (Object)null && ((NetworkBehaviour)val).isLocalPlayer && val.Inventory.EquippedItemIndex != capture.Slot) { val.Inventory.TrySelectItemSlot(capture.Slot, true); } } if (capture.Flying) { if ((Object)(object)capture.Visual == (Object)null) { capture.Visual = Registry.Assets.Create("capture_ball"); } capture.Visual.transform.position = capture.Position; capture.Visual.transform.Rotate(140f * Time.deltaTime, 200f * Time.deltaTime, 0f); Registry.Assets.Animate(capture.Visual, capture.Victim != 0, blowing: false); } else if ((Object)(object)capture.Visual != (Object)null) { Object.Destroy((Object)(object)capture.Visual); capture.Visual = null; } } uint[] array2 = (from x in immunity where x.Value <= NetworkTime.time select x.Key).ToArray(); foreach (uint key in array2) { immunity.Remove(key); } } private void ApplyCapturePlayer(uint id, Vector3 position, bool visible) { //IL_0076: 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_0091: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) PlayerInfo val = Player(id); if ((Object)(object)val == (Object)null) { hiddenPlayers.Remove(id); return; } Rigidbody rigidbody = val.AsEntity.Rigidbody; CapturedPlayer value; if (!visible) { if (!hiddenPlayers.ContainsKey(id)) { hiddenPlayers[id] = new CapturedPlayer { Player = val, Kinematic = rigidbody.isKinematic, Visible = val.Movement.IsVisible, Position = ((Component)val).transform.position }; val.AsGolfer.CancelAllActions(); rigidbody.linearVelocity = Vector3.zero; rigidbody.angularVelocity = Vector3.zero; rigidbody.isKinematic = true; val.Movement.NetworkisVisible = false; val.Movement.UpdateEnabledColliders(); log("Captured player suspended id=" + id); } } else if (hiddenPlayers.TryGetValue(id, out value)) { hiddenPlayers.Remove(id); rigidbody.isKinematic = value.Kinematic; val.Movement.NetworkisVisible = value.Visible; val.Movement.UpdateEnabledColliders(); if (((NetworkBehaviour)val).isLocalPlayer) { val.Movement.Teleport(position, ((Component)val).transform.rotation, true); } else { val.AsEntity.InformWillTeleport(); rigidbody.position = position; ((Component)val).transform.position = position; val.AsEntity.InformTeleported(); } if (!rigidbody.isKinematic) { rigidbody.linearVelocity = Vector3.up * 2f; rigidbody.angularVelocity = Vector3.zero; } immunity[id] = NetworkTime.time + (double)Setting(captureImmunity); log("Captured player restored id=" + id + " immunity=" + Setting(captureImmunity)); } } private void BroadcastCapturePlayer(uint id, Vector3 position, bool visible) { //IL_000e: 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) Broadcast(Packet(delegate(BinaryWriter w) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) w.Write((byte)2); w.Write(id); Vector(w, position); w.Write(visible); })); } private Vector3 SafeRelease(Vector3 desired, Vector3 fallback, uint victim) { //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) RaycastHit val3 = default(RaycastHit); for (int i = 0; i < 2; i++) { for (int j = 0; j < 25; j++) { Vector3 val = ((i == 0 && Valid(desired)) ? desired : fallback); Vector3 val2 = ((j == 0) ? Vector3.zero : (Quaternion.Euler(0f, (float)j * 137.5f, 0f) * Vector3.forward * (1f + (float)j / 8f))); if (Physics.Raycast(val + val2 + Vector3.up * 8f, Vector3.down, ref val3, 30f, LayerMask.op_Implicit(GameManager.LayerSettings.PlayerGroundableMask), (QueryTriggerInteraction)1) && !(((RaycastHit)(ref val3)).normal.y < 0.65f)) { Vector3 val4 = ((RaycastHit)(ref val3)).point + Vector3.up * 0.15f; if ((!SingletonBehaviour.HasInstance || BoundsManager.IsPointInLevelBoundsImmediate(val4)) && !Physics.OverlapCapsule(val4 + Vector3.up * 0.5f, val4 + Vector3.up * 1.4f, 0.32f, -1, (QueryTriggerInteraction)1).Any(delegate(Collider x) { PlayerInfo componentInParent = ((Component)x).GetComponentInParent(); return componentInParent == null || ((NetworkBehaviour)componentInParent).netId != victim; })) { return val4; } } } } return fallback + Vector3.up * 0.2f; } private unsafe void Release(Capture c, Vector3 desired, string reason) { //IL_0013: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) captures.Remove(c.Carrier); Vector3 position = SafeRelease(desired, c.Fallback, c.Victim); ApplyCapturePlayer(c.Victim, position, visible: true); BroadcastCapturePlayer(c.Victim, position, visible: true); PlayerInfo val = Player(c.Carrier); if ((Object)(object)val != (Object)null && c.Slot < val.Inventory.slots.Count && Registry.Get(val.Inventory.slots[c.Slot].itemType)?.Id == "capture_ball") { Consume(val.Inventory, c.Slot); } if ((Object)(object)c.Visual != (Object)null) { Object.Destroy((Object)(object)c.Visual); } Registry.Assets.Pulse(position, new Color(0.2f, 1f, 0.7f)); Notify("CAPTURE RELEASED (" + reason + ")"); log("Capture release carrier=" + c.Carrier + " victim=" + c.Victim + " at=" + ((object)(*(Vector3*)(&position))/*cast due to .constrained prefix*/).ToString()); SendState(); } private void FinishMiss(Capture c) { //IL_00b4: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) captures.Remove(c.Carrier); PlayerInfo val = Player(c.Carrier); if ((Object)(object)val != (Object)null && c.Slot < val.Inventory.slots.Count && Registry.Get(val.Inventory.slots[c.Slot].itemType)?.Id == "capture_ball") { Consume(val.Inventory, c.Slot); } if ((Object)(object)c.Visual != (Object)null) { Object.Destroy((Object)(object)c.Visual); } Registry.Assets.Pulse(c.Position, new Color(0.8f, 0.9f, 1f)); log("Capture Ball missed/expired"); } private void KillCaptured(Capture c) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) PlayerInfo val = Player(c.Victim); PlayerInfo val2 = Player(c.Carrier); captures.Remove(c.Carrier); ApplyCapturePlayer(c.Victim, c.Fallback, visible: true); BroadcastCapturePlayer(c.Victim, c.Fallback, visible: true); if ((Object)(object)val != (Object)null) { if ((Object)(object)val2 != (Object)null) { val.AsGolfer.ServerSetPotentialEliminationReason(val2.AsGolfer, ItemUseId.Invalid, (EliminationReason)5); } val.AsGolfer.ServerEliminate((EliminationReason)5); } if ((Object)(object)val2 != (Object)null && c.Slot < val2.Inventory.slots.Count) { Consume(val2.Inventory, c.Slot); } if ((Object)(object)c.Visual != (Object)null) { Object.Destroy((Object)(object)c.Visual); } Notify("CAPTURE BALL — OUT OF BOUNDS KILL"); log("Capture environmental kill carrier=" + c.Carrier + " victim=" + c.Victim); SendState(); } private void CleanupCapture(string reason) { //IL_0048: 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_00a9: Unknown result type (might be due to invalid IL or missing references) Capture[] array = captures.Values.ToArray(); foreach (Capture capture in array) { if (NetworkServer.active && capture.Victim != 0) { Release(capture, capture.Fallback, reason); continue; } if (capture.Victim != 0) { ApplyCapturePlayer(capture.Victim, capture.Fallback, visible: true); } if ((Object)(object)capture.Visual != (Object)null) { Object.Destroy((Object)(object)capture.Visual); } } captures.Clear(); KeyValuePair[] array2 = hiddenPlayers.ToArray(); for (int i = 0; i < array2.Length; i++) { KeyValuePair keyValuePair = array2[i]; ApplyCapturePlayer(keyValuePair.Key, keyValuePair.Value.Position, visible: true); } immunity.Clear(); } private void WriteCapture(BinaryWriter w) { //IL_0052: 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_006a: Unknown result type (might be due to invalid IL or missing references) w.Write(captures.Count); foreach (Capture value in captures.Values) { w.Write(value.Carrier); w.Write(value.Victim); w.Write(value.Slot); Vector(w, value.Position); Vector(w, value.Velocity); Vector(w, value.Fallback); w.Write(value.Until); w.Write(value.Flying); } } private void ReadCapture(BinaryReader r) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_0097: 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_0131: Unknown result type (might be due to invalid IL or missing references) int num = Count(r); HashSet ids = new HashSet(); for (int i = 0; i < num; i++) { uint num2 = r.ReadUInt32(); ids.Add(num2); if (!captures.TryGetValue(num2, out var value)) { Dictionary dictionary = captures; Capture obj = new Capture { Carrier = num2 }; value = obj; dictionary[num2] = obj; } value.Victim = r.ReadUInt32(); value.Slot = r.ReadInt32(); value.Position = Vector(r); value.Velocity = Vector(r); value.Fallback = Vector(r); value.Until = r.ReadDouble(); value.Flying = r.ReadBoolean(); } Capture[] array = captures.Values.Where((Capture c) => !ids.Contains(c.Carrier)).ToArray(); foreach (Capture capture in array) { if (capture.Victim != 0 && hiddenPlayers.ContainsKey(capture.Victim)) { ApplyCapturePlayer(capture.Victim, capture.Fallback, visible: true); } if ((Object)(object)capture.Visual != (Object)null) { Object.Destroy((Object)(object)capture.Visual); } captures.Remove(capture.Carrier); } } internal CustomItemRuntime(ConfigFile config, Harmony harmony, SharedGravity gravity, Func compatible, Func peerReady, Func clientReady, Func itemQuality, Action log, Action notice) { //IL_01a7: 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_01c0: Expected O, but got Unknown //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Expected I4, but got Unknown this.itemQuality = itemQuality; itemConfig = config; Registry = new CustomItemRegistry(config); Gravity = gravity; this.compatible = compatible; this.peerReady = peerReady; this.clientReady = clientReady; this.log = log; this.notice = notice; itemHarmony = harmony; Current = this; ConfigureGravity(config); ConfigureCapture(config); ConfigureBlower(config); ConfigureGreen(config); ConfigureNativeWeights(harmony); ConfigureGreenReflection(harmony); ConfigureRangeWeights(harmony); harmony.Patch((MethodBase)AccessTools.Method(typeof(ItemPool), "GetWeightedRandomItem", (Type[])null, (Type[])null), new HarmonyMethod(typeof(CustomItemRuntime), "SelectCustomItem", (Type[])null) { priority = 800 }, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Hook(harmony, typeof(PlayerInventory), "TryUseItem", "Use"); Hook(harmony, typeof(PlayerInventory), "TrySelectItemSlot", "Select"); Hook(harmony, typeof(PlayerInventory), "TryDeselectItem", "Deselect"); Hook(harmony, typeof(PlayerInventory), "DropItem", "Drop"); Hook(harmony, typeof(ItemData), "get_Name", "Name"); Hook(harmony, typeof(ItemCollection), "TryGetItemData", "Lookup"); Hook(harmony, typeof(ItemCollection), "GetItemIcon", "Icon"); Hook(harmony, typeof(PlayerMovement), "FixedUpdate", "Move"); Hook(harmony, typeof(PlayerMovement), "LocalPlayerUpdateVisibility", "Move"); Hook(harmony, typeof(PlayerMovement), "UpdateOutOfBounds", "Move"); Hook(harmony, typeof(Hittable), "HitWithItem", "Target"); Hook(harmony, typeof(PlayerGolfer), "CanMove", "CanMove"); Hook(harmony, typeof(PlayerGolfer), "CanAimSwing", "CanMove"); Hook(harmony, typeof(PlayerGolfer), "TryStartChargingSwing", "CanMove"); Hook(harmony, typeof(PlayerMovement), "TryTriggerJump", "MotionAction"); Hook(harmony, typeof(PlayerMovement), "TryDive", "MotionAction"); Hook(harmony, typeof(PlayerGolfer), "CancelAllActions", null); BNetworkManager.WillChangeScene += BeforeSceneChange; CustomItemDefinition[] items = Registry.Items; foreach (CustomItemDefinition customItemDefinition in items) { log("Registered " + customItemDefinition.Id + " stableId=" + (int)customItemDefinition.Type + " weight=" + Setting(customItemDefinition.Weight)); } } private static void Hook(Harmony h, Type type, string method, string prefix) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.DeclaredMethod(type, method, (Type[])null, (Type[])null); if (methodInfo == null) { throw new MissingMethodException(type.Name + "." + method); } if (prefix != null) { h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(CustomItemRuntime), prefix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private static bool Lookup(ItemType itemType, ref ItemData itemData, ref bool __result) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) CustomItemDefinition customItemDefinition = Current?.Registry.Get(itemType); if (customItemDefinition == null) { return true; } Current.Registry.EnsureRegistered(); itemData = customItemDefinition.Data; __result = itemData != null; return false; } private static bool Icon(ItemType itemType, ref Sprite __result) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) CustomItemDefinition customItemDefinition = Current?.Registry.Get(itemType); if (customItemDefinition == null) { return true; } Current.Registry.EnsureRegistered(); __result = customItemDefinition.Data.Icon; return false; } private static bool Name(ItemData __instance, ref string __result) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) CustomItemDefinition customItemDefinition = Current?.Registry.Get(__instance.Type); if (customItemDefinition == null) { return true; } __result = customItemDefinition.Name; return false; } private static bool Use(PlayerInventory __instance, bool isAirhornReaction, ref bool shouldEatInput, ref bool __result) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) CustomItemRuntime current = Current; if (current == null) { return true; } if (current.IsCaptured(((NetworkBehaviour)__instance.PlayerInfo).netId)) { shouldEatInput = true; __result = false; return false; } if (current.Registry.Get(__instance.GetEffectivelyEquippedItem(false)) == null) { return true; } shouldEatInput = true; __result = false; if (!isAirhornReaction && current.Enabled && current.Playing && Eligible(__instance.PlayerInfo)) { current.SendUse(__instance.EquippedItemIndex); __result = true; } return false; } private static bool Select(PlayerInventory __instance, int index, ref bool __result) { CustomItemRuntime current = Current; if (current == null) { return true; } if (current.IsCaptured(((NetworkBehaviour)__instance.PlayerInfo).netId) || (current.CarrierSlot(((NetworkBehaviour)__instance.PlayerInfo).netId, out var slot) && slot != index)) { __result = false; return false; } return true; } private static bool Deselect(PlayerInventory __instance, ref bool __result) { CustomItemRuntime current = Current; if (current != null && (current.IsCaptured(((NetworkBehaviour)__instance.PlayerInfo).netId) || current.CarrierSlot(((NetworkBehaviour)__instance.PlayerInfo).netId, out var _))) { __result = false; return false; } return true; } private static bool Drop(PlayerInventory __instance) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) CustomItemRuntime current = Current; if (current == null) { return true; } if (current.IsCaptured(((NetworkBehaviour)__instance.PlayerInfo).netId) || current.Registry.Get(__instance.GetEffectivelyEquippedItem(false)) != null) { return false; } return true; } private static bool Move(PlayerMovement __instance) { if (Current != null) { return !Current.IsCaptured(((NetworkBehaviour)__instance.PlayerInfo).netId); } return true; } private static bool MotionAction(PlayerMovement __instance, ref bool __result) { if (Current == null || !Current.IsCaptured(((NetworkBehaviour)__instance.PlayerInfo).netId)) { return true; } __result = false; return false; } private static bool Target(Hittable __instance) { if (Current != null && !((Object)(object)__instance.AsEntity == (Object)null) && __instance.AsEntity.IsPlayer) { return !Current.IsCaptured(((NetworkBehaviour)__instance.AsEntity.PlayerInfo).netId); } return true; } private static bool CanMove(PlayerGolfer __instance, ref bool __result) { if (Current == null || !Current.IsCaptured(((NetworkBehaviour)__instance.PlayerInfo).netId)) { return true; } __result = false; return false; } internal static bool Eligible(PlayerInfo p) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Invalid comparison between Unknown and I4 if ((Object)(object)p != (Object)null && !p.AsGolfer.IsMatchResolved && !p.AsSpectator.IsSpectating && p.Movement.IsVisible && !p.Movement.IsRespawningOrDrowning && !p.Movement.IsKnockedOutOrRecovering) { GolfCartSeat activeGolfCartSeat = p.ActiveGolfCartSeat; if (!((GolfCartSeat)(ref activeGolfCartSeat)).IsValid()) { return (int)p.AsHittable.FrozenState != 2; } } return false; } internal static PlayerInfo Player(uint id) { if (!(NetworkServer.active ? NetworkServer.spawned : NetworkClient.spawned).TryGetValue(id, out var value)) { return null; } return ((Component)value).GetComponent(); } internal static IEnumerable Players() { return from x in (NetworkServer.active ? NetworkServer.spawned : NetworkClient.spawned).Values select ((Component)x).GetComponent() into x where (Object)(object)x != (Object)null select x; } internal bool TrySelect(ItemPool pool, ref ItemType result, float quality) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected I4, but got Unknown //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Expected I4, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected I4, but got Unknown if (!HostEnabled || !Playing) { return false; } Registry.EnsureRegistered(); CustomItemDefinition[] array = Registry.Items.Where((CustomItemDefinition d) => Setting(d.Enabled) && Setting(d.Weight) > 0).ToArray(); if (array.Length == 0) { return false; } ItemSpawnChance[] array2 = pool.SpawnChances.Where((ItemSpawnChance x) => (int)x.item != 0 && Registry.Get(x.item) == null).ToArray(); double num = random.NextDouble() * (double)(((IEnumerable)array2).Sum((Func)NativeWeight) + (float)array.Sum((CustomItemDefinition x) => Setting(x.Weight))); ItemSpawnChance[] array3 = array2; foreach (ItemSpawnChance val in array3) { num -= (double)NativeWeight(val); if (num < 0.0) { result = (ItemType)(int)val.item; return true; } } CustomItemDefinition[] array4 = array; foreach (CustomItemDefinition customItemDefinition in array4) { num -= (double)Setting(customItemDefinition.Weight); if (num < 0.0) { result = (ItemType)(int)customItemDefinition.Type; log("Native pickup selected " + customItemDefinition.Id); return true; } } result = (ItemType)(int)array[^1].Type; return true; float NativeWeight(ItemSpawnChance x) { //IL_0005: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_0019: 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: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 return Mathf.Max(0f, x.spawnChanceWeight) * (((int)x.item == 7 || (int)x.item == 10 || (int)x.item == 16 || (int)x.item == 15 || (int)x.item == 3 || (int)x.item == 17) ? quality : 1f); } } private static bool SelectCustomItem(ItemPool __instance, ref ItemType __result) { CustomItemRuntime current = Current; if (current != null) { return !current.TrySelect(__instance, ref __result, current.itemQuality()); } return true; } internal void Tick() { //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) if (Faulted) { return; } TickDiagnostics(); PollHost(); Scene activeScene = SceneManager.GetActiveScene(); int num = SceneHandle.op_Implicit(((Scene)(ref activeScene)).handle); if (scene != num || hole != CourseManager.CurrentHoleCourseIndex) { Cleanup("scene/hole changed"); scene = num; hole = CourseManager.CurrentHoleCourseIndex; } bool flag = Enabled && Playing; if (flag != lastEnabled) { if (!flag) { Cleanup("disabled or hole ended"); } log("Master gameplay " + (flag ? "ON (host authority)" : "OFF")); lastEnabled = flag; if (NetworkServer.active) { SendState(); } } Gravity.Apply(); if (flag) { Registry.EnsureRegistered(); TickCapture(); TickGravity(); TickGreen(); TickBlowerInput(); if (NetworkServer.active && NetworkTime.time >= nextState) { nextState = NetworkTime.time + 0.1; SendState(); } if (NetworkTime.time >= nextVisualScan) { nextVisualScan = NetworkTime.time + 0.1; RefreshHeld(); } AnimateVisuals(); } } internal void FixedTick() { if (Enabled && Playing && NetworkServer.active) { TickBlowerForces(); TickProjectiles(); } } private void RefreshHeld() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) foreach (PlayerInfo item in Players()) { CustomItemDefinition customItemDefinition = Registry.Get(item.Inventory.GetEffectivelyEquippedItem(false)); if (customItemDefinition == null || !item.Movement.IsVisible) { RemoveHeld(((NetworkBehaviour)item).netId); continue; } if (!held.TryGetValue(((NetworkBehaviour)item).netId, out var value) || (Object)(object)value == (Object)null || heldIds[((NetworkBehaviour)item).netId] != customItemDefinition.Id) { RemoveHeld(((NetworkBehaviour)item).netId); value = Registry.Assets.Create(customItemDefinition.Id); held[((NetworkBehaviour)item).netId] = value; heldIds[((NetworkBehaviour)item).netId] = customItemDefinition.Id; customItemDefinition.Mount(value.transform, ((Component)item.RightHandEquipmentSwitcher).transform); } Blower value2; bool flag = blowers.TryGetValue(((NetworkBehaviour)item).netId, out value2) && value2.Until > NetworkTime.time && customItemDefinition.Id == "leaf_blower"; value.GetComponent().SetAim(flag ? value2.Direction : Vector3.zero); Registry.Assets.Animate(value, CarrierSlot(((NetworkBehaviour)item).netId, out var _), flag); } uint[] array = held.Keys.Where((uint id2) => (Object)(object)Player(id2) == (Object)null).ToArray(); foreach (uint id in array) { RemoveHeld(id); } } private void RemoveHeld(uint id) { if (held.TryGetValue(id, out var value) && (Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); } held.Remove(id); heldIds.Remove(id); } private void BeforeSceneChange() { Cleanup("before scene unload"); } private void AnimateVisuals() { AnimateGreen(); AnimateGravity(); } internal void Force(string id) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (!HostEnabled) { throw new InvalidOperationException("Enable Custom Items in host setup first"); } Registry.EnsureRegistered(); CustomItemDefinition customItemDefinition = Registry.Get(id) ?? throw new ArgumentException("Unknown stable item id"); PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo; int num = default(int); if (!localPlayerInfo.Inventory.HasSpaceForItem(ref num)) { throw new InvalidOperationException("Inventory full"); } if (!localPlayerInfo.Inventory.ServerTryAddItem(customItemDefinition.Type, customItemDefinition.Uses)) { throw new InvalidOperationException("Native grant rejected"); } localPlayerInfo.Inventory.TrySelectItemSlot(num, false); log("Forced native grant " + id); } internal void Cleanup(string reason) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) diagnosticCheck = null; diagnosticUndo?.Invoke(); diagnosticUndo = null; CleanupCapture(reason); CleanupGreen(); CleanupGravity(); blowers.Clear(); uint[] array = held.Keys.ToArray(); foreach (uint id in array) { RemoveHeld(id); } if (NetworkServer.active) { foreach (PlayerInfo item in Players()) { for (int j = 0; j < item.Inventory.slots.Count; j++) { if (Registry.Get(item.Inventory.slots[j].itemType) != null) { Consume(item.Inventory, j); } } } } if (NetworkServer.active && serverRegistered) { SendState(); } } internal void Consume(PlayerInventory inventory, int slot) { AccessTools.DeclaredMethod(typeof(PlayerInventory), "RemoveItemAt", (Type[])null, (Type[])null).Invoke(inventory, new object[3] { slot, false, true }); } internal void Notify(string text) { notice(text); log(text); } public void Dispose() { BNetworkManager.WillChangeScene -= BeforeSceneChange; try { Cleanup("plugin shutdown"); } finally { ClearNativeWeights(); StopNetworking(); Registry.Dispose(); itemHarmony.UnpatchSelf(); if (Current == this) { Current = null; } } } internal void PreserveSettingsUntilNextCourse() { if (resetSettings == null) { resetSettings = new ResetSettingsSnapshot(itemConfig, (string s) => s == "CustomItems" || s.StartsWith("CustomItems.")); } } internal void UseNextCourseSettings() { resetSettings = null; } private T Setting(ConfigEntry entry) { if (resetSettings == null) { return entry.Value; } return resetSettings.Read(entry); } private void TickDiagnostics() { if (diagnosticCheck == null || NetworkTime.time < diagnosticAt) { return; } Action action = diagnosticCheck; diagnosticCheck = null; try { action(); } catch (Exception ex) { log("DIAGNOSTIC FAILED: " + ex.Message); } finally { diagnosticUndo?.Invoke(); diagnosticUndo = null; } } internal void Inspect() { //IL_0123: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) log("Enabled=" + Enabled + " scene=" + scene + " held=" + held.Count + " captures=" + captures.Count + " hidden=" + hiddenPlayers.Count + " green=" + greenId + " collider=" + ((Object)(object)greenColliders != (Object)null)); foreach (PlayerInfo item in Players()) { log("Player id=" + ((NetworkBehaviour)item).netId + " position=" + ((object)((Component)item).transform.position/*cast due to .constrained prefix*/).ToString() + " eligible=" + Eligible(item) + " equipped=" + ((object)item.Inventory.GetEffectivelyEquippedItem(false)/*cast due to .constrained prefix*/).ToString() + " handActive=" + ((Component)item.RightHandEquipmentSwitcher).gameObject.activeInHierarchy + " handScale=" + ((object)((Component)item.RightHandEquipmentSwitcher).transform.lossyScale/*cast due to .constrained prefix*/).ToString()); } foreach (KeyValuePair item2 in held) { if ((Object)(object)item2.Value != (Object)null) { Renderer componentInChildren = item2.Value.GetComponentInChildren(); log("Held id=" + item2.Key + " active=" + item2.Value.activeInHierarchy + " scale=" + ((object)item2.Value.transform.lossyScale/*cast due to .constrained prefix*/).ToString() + " bounds=" + ((object)componentInChildren.bounds/*cast due to .constrained prefix*/).ToString() + " shader=" + ((Object)componentInChildren.sharedMaterial.shader).name + " visible=" + componentInChildren.isVisible); } } log(Gravity.Inspect()); } internal unsafe void Test(string action, PlayerInfo dummy) { //IL_0e55: 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: Expected O, but got Unknown //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_0667: Unknown result type (might be due to invalid IL or missing references) //IL_066c: Unknown result type (might be due to invalid IL or missing references) //IL_067d: Unknown result type (might be due to invalid IL or missing references) //IL_0682: Unknown result type (might be due to invalid IL or missing references) //IL_0687: Unknown result type (might be due to invalid IL or missing references) //IL_068c: Unknown result type (might be due to invalid IL or missing references) //IL_069c: Unknown result type (might be due to invalid IL or missing references) //IL_06b7: Unknown result type (might be due to invalid IL or missing references) //IL_06c1: 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_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_0726: Unknown result type (might be due to invalid IL or missing references) //IL_0736: Unknown result type (might be due to invalid IL or missing references) //IL_0740: Unknown result type (might be due to invalid IL or missing references) //IL_0745: Unknown result type (might be due to invalid IL or missing references) //IL_0757: Unknown result type (might be due to invalid IL or missing references) //IL_0763: Unknown result type (might be due to invalid IL or missing references) //IL_0795: Unknown result type (might be due to invalid IL or missing references) //IL_079a: Unknown result type (might be due to invalid IL or missing references) //IL_079f: Unknown result type (might be due to invalid IL or missing references) //IL_07af: Unknown result type (might be due to invalid IL or missing references) //IL_07b4: Unknown result type (might be due to invalid IL or missing references) //IL_07b9: Unknown result type (might be due to invalid IL or missing references) //IL_07c3: Unknown result type (might be due to invalid IL or missing references) //IL_07c8: Unknown result type (might be due to invalid IL or missing references) //IL_07cd: Unknown result type (might be due to invalid IL or missing references) //IL_07d1: Unknown result type (might be due to invalid IL or missing references) //IL_0572: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_058d: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_05b4: Unknown result type (might be due to invalid IL or missing references) //IL_05ca: Unknown result type (might be due to invalid IL or missing references) //IL_05d4: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_08b7: Unknown result type (might be due to invalid IL or missing references) //IL_08bc: Unknown result type (might be due to invalid IL or missing references) //IL_0901: Unknown result type (might be due to invalid IL or missing references) //IL_0906: Unknown result type (might be due to invalid IL or missing references) //IL_0923: Unknown result type (might be due to invalid IL or missing references) //IL_092a: Unknown result type (might be due to invalid IL or missing references) //IL_0a74: Unknown result type (might be due to invalid IL or missing references) //IL_0a79: Unknown result type (might be due to invalid IL or missing references) //IL_0a7c: Unknown result type (might be due to invalid IL or missing references) //IL_0a81: Unknown result type (might be due to invalid IL or missing references) //IL_0a8b: Unknown result type (might be due to invalid IL or missing references) //IL_0a90: Unknown result type (might be due to invalid IL or missing references) //IL_0a95: Unknown result type (might be due to invalid IL or missing references) //IL_0a96: Unknown result type (might be due to invalid IL or missing references) //IL_0aa4: Unknown result type (might be due to invalid IL or missing references) //IL_0aa9: Unknown result type (might be due to invalid IL or missing references) //IL_0ab3: Unknown result type (might be due to invalid IL or missing references) //IL_0ab5: Unknown result type (might be due to invalid IL or missing references) //IL_094c: Unknown result type (might be due to invalid IL or missing references) //IL_0951: Unknown result type (might be due to invalid IL or missing references) //IL_0956: Unknown result type (might be due to invalid IL or missing references) //IL_0960: Unknown result type (might be due to invalid IL or missing references) //IL_0965: Unknown result type (might be due to invalid IL or missing references) //IL_0982: Unknown result type (might be due to invalid IL or missing references) //IL_0993: Unknown result type (might be due to invalid IL or missing references) //IL_09de: Unknown result type (might be due to invalid IL or missing references) //IL_09f1: Unknown result type (might be due to invalid IL or missing references) //IL_09f6: Unknown result type (might be due to invalid IL or missing references) //IL_0cd2: Unknown result type (might be due to invalid IL or missing references) //IL_0cd7: Unknown result type (might be due to invalid IL or missing references) //IL_0cdb: Unknown result type (might be due to invalid IL or missing references) //IL_0d06: Unknown result type (might be due to invalid IL or missing references) //IL_0d0b: Unknown result type (might be due to invalid IL or missing references) //IL_0d16: Unknown result type (might be due to invalid IL or missing references) //IL_0d1b: Unknown result type (might be due to invalid IL or missing references) //IL_0af3: Unknown result type (might be due to invalid IL or missing references) //IL_0b01: Unknown result type (might be due to invalid IL or missing references) //IL_0b06: Unknown result type (might be due to invalid IL or missing references) //IL_0b10: Unknown result type (might be due to invalid IL or missing references) //IL_0db9: Unknown result type (might be due to invalid IL or missing references) //IL_0b59: Unknown result type (might be due to invalid IL or missing references) //IL_0b5e: Unknown result type (might be due to invalid IL or missing references) //IL_0b65: Unknown result type (might be due to invalid IL or missing references) //IL_0b6a: Unknown result type (might be due to invalid IL or missing references) //IL_0b6f: Unknown result type (might be due to invalid IL or missing references) //IL_0b70: Unknown result type (might be due to invalid IL or missing references) //IL_0b7a: Unknown result type (might be due to invalid IL or missing references) //IL_0b7f: Unknown result type (might be due to invalid IL or missing references) //IL_0b89: Unknown result type (might be due to invalid IL or missing references) //IL_102a: Unknown result type (might be due to invalid IL or missing references) //IL_102f: Unknown result type (might be due to invalid IL or missing references) //IL_1039: Unknown result type (might be due to invalid IL or missing references) //IL_103e: Unknown result type (might be due to invalid IL or missing references) //IL_1043: Unknown result type (might be due to invalid IL or missing references) //IL_0bc2: Unknown result type (might be due to invalid IL or missing references) //IL_0bcc: Unknown result type (might be due to invalid IL or missing references) //IL_0bd1: Unknown result type (might be due to invalid IL or missing references) //IL_0bdb: Unknown result type (might be due to invalid IL or missing references) PlayerInfo host = GameManager.LocalPlayerInfo; Vector3 val4; if (action == "pool") { ItemSpawner val = Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0).FirstOrDefault(); if ((Object)(object)val == (Object)null) { throw new InvalidOperationException("No item dispenser"); } ItemSpawnerSettings val2 = (ItemSpawnerSettings)AccessTools.Field(typeof(ItemSpawner), "settings").GetValue(val); Dictionary counts = Registry.Items.ToDictionary((CustomItemDefinition x) => x.Id, (CustomItemDefinition x) => 0); for (int num = 0; num < 1000; num++) { ItemType randomItemFor = val2.GetRandomItemFor(host); CustomItemDefinition customItemDefinition = Registry.Get(randomItemFor); if (customItemDefinition != null) { counts[customItemDefinition.Id]++; } } if (HostEnabled && Registry.Items.Any((CustomItemDefinition d) => d.Enabled.Value && d.Weight.Value > 0 && counts[d.Id] == 0)) { throw new InvalidOperationException("Item not drawn"); } if (!HostEnabled && counts.Values.Any((int x) => x != 0)) { throw new InvalidOperationException("Custom item drawn while OFF"); } log("Native pool draws " + string.Join(", ", counts.Select((KeyValuePair x) => x.Key + "=" + x.Value))); } else if (action == "pickup") { if (diagnosticCheck != null) { throw new InvalidOperationException("Diagnostic running"); } int num2 = default(int); if (!HostEnabled || !host.Inventory.HasSpaceForItem(ref num2)) { throw new InvalidOperationException("Enable items and empty inventory first"); } ItemSpawner val3 = Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0).OrderBy(delegate(ItemSpawner x) { //IL_0006: 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_001b: 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) Vector3 val14 = ((Component)x).transform.position - ((Component)host).transform.position; return ((Vector3)(ref val14)).sqrMagnitude; }).FirstOrDefault(); if ((Object)(object)val3 == (Object)null) { throw new InvalidOperationException("No native dispenser"); } int[] weights = Registry.Items.Select((CustomItemDefinition x) => x.Weight.Value).ToArray(); diagnosticUndo = delegate { for (int i = 0; i < weights.Length; i++) { Registry.Items[i].Weight.Value = weights[i]; } }; CustomItemDefinition[] items = Registry.Items; for (num2 = 0; num2 < items.Length; num2++) { items[num2].Weight.Value = 1000; } host.Movement.Teleport(((Component)val3).transform.position + Vector3.up * 0.2f, ((Component)host).transform.rotation, true); diagnosticAt = NetworkTime.time + 6.0; diagnosticCheck = delegate { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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) InventorySlot val14 = ((IEnumerable)host.Inventory.slots).FirstOrDefault((Func)((InventorySlot x) => Registry.Get(x.itemType) != null)); if (Registry.Get(val14.itemType) == null) { throw new InvalidOperationException("No custom pickup received (native draw can miss; retry)"); } log("DIAGNOSTIC PASS actual native dispenser pickup " + Registry.Get(val14.itemType).Id + " uses=" + val14.remainingUses); }; } else if (action == "green_ball") { if ((Object)(object)greenColliders == (Object)null) { throw new InvalidOperationException("Wait for barrier activation"); } GolfBall ownBall = host.AsGolfer.OwnBall; if ((Object)(object)ownBall == (Object)null) { throw new InvalidOperationException("Spawn native ball first"); } ownBall.AsEntity.InformWillTeleport(); ownBall.Rigidbody.position = greenCenter + Vector3.right * (greenSize + 3f) + Vector3.up * 2f; ((Component)ownBall).transform.position = ownBall.Rigidbody.position; ownBall.Rigidbody.linearVelocity = Vector3.left * 15f; ownBall.AsEntity.InformTeleported(); Action action2 = log; val4 = ownBall.Rigidbody.linearVelocity; action2("Barrier approach native ball velocity=" + ((object)(*(Vector3*)(&val4))/*cast due to .constrained prefix*/).ToString()); } else if (action == "green_roof_ball") { if ((Object)(object)greenColliders == (Object)null || diagnosticCheck != null) { throw new InvalidOperationException("Wait for dome/no pending test"); } GolfBall ball = host.AsGolfer.OwnBall ?? host.AsGolfer.ServerSpawnBall(((Component)host).transform.position, Quaternion.identity); host.AsGolfer.NetworkownBall = ball; ball.AsEntity.InformWillTeleport(); ball.Rigidbody.position = greenCenter + Vector3.up * (ItemAssets.DomeHeight(greenSize) + 2f); ((Component)ball).transform.position = ball.Rigidbody.position; ball.Rigidbody.linearVelocity = Vector3.down * 8f; ball.Rigidbody.WakeUp(); ball.AsEntity.InformTeleported(); diagnosticAt = NetworkTime.time + 0.5; diagnosticCheck = delegate { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ball == (Object)null || ball.Rigidbody.linearVelocity.y <= 0f) { throw new InvalidOperationException("Native ball did not bounce from dome roof"); } log("DIAGNOSTIC PASS native ball roof bounce velocity=" + ((object)ball.Rigidbody.linearVelocity/*cast due to .constrained prefix*/).ToString()); }; } else if (action == "green_player") { if ((Object)(object)greenColliders == (Object)null) { throw new InvalidOperationException("Wait for barrier activation"); } host.Movement.Teleport(greenCenter + Vector3.right * (greenSize + 2f) + Vector3.up, ((Component)host).transform.rotation, true); host.AsEntity.Rigidbody.linearVelocity = Vector3.left * 10f; } else if (action == "capture_setup") { if ((Object)(object)dummy == (Object)null) { throw new InvalidOperationException("Spawn training golfer first"); } host.Inventory.TryDeselectItem(false, true); Rigidbody rigidbody = dummy.AsEntity.Rigidbody; rigidbody.position = ((Component)host).transform.position + ((Component)host).transform.forward * 4f; ((Component)dummy).transform.position = rigidbody.position; rigidbody.linearVelocity = Vector3.zero; Force("capture_ball"); PlayerInfo p = host; int equippedItemIndex = host.Inventory.EquippedItemIndex; val4 = ((Component)dummy).transform.position + Vector3.up - ((Component)host).transform.position - Vector3.up * 1.2f; Activate(p, equippedItemIndex, ((Vector3)(ref val4)).normalized); } else if (action == "blower_player" || action == "blower_player_far" || action == "blower_ball") { if (diagnosticCheck != null) { throw new InvalidOperationException("Diagnostic still running"); } Rigidbody body; if (action != "blower_ball") { if ((Object)(object)dummy == (Object)null) { throw new InvalidOperationException("Spawn training golfer first"); } body = dummy.AsEntity.Rigidbody; } else { GolfBall val5 = host.AsGolfer.OwnBall ?? host.AsGolfer.ServerSpawnBall(((Component)host).transform.position, Quaternion.identity); host.AsGolfer.NetworkownBall = val5; body = val5.Rigidbody; } Vector3 direction = ((Component)host).transform.forward; body.position = ((Component)host).transform.position + direction * (float)((action == "blower_player_far") ? 8 : 3) + Vector3.up * 0.6f; ((Component)body).transform.position = body.position; body.linearVelocity = Vector3.zero; body.WakeUp(); Physics.SyncTransforms(); Force("leaf_blower"); StartBlower(host, host.Inventory.EquippedItemIndex, direction); Vector3 start = body.position; diagnosticAt = NetworkTime.time + 0.3; diagnosticCheck = delegate { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) float num8 = Vector3.Dot(body.position - start, direction); float num9 = Vector3.Dot(body.linearVelocity, direction); if (num8 < 0.01f && num9 < 0.1f) { throw new InvalidOperationException(action + " no forward response: " + num8 + " / " + num9 + " kinematic=" + body.isKinematic); } log("DIAGNOSTIC PASS " + action + " travel=" + num8 + " velocity=" + num9); }; } else if (action == "green_geometry") { if ((Object)(object)greenColliders == (Object)null) { throw new InvalidOperationException("Wait for field"); } if ((Object)(object)greenColliders.GetComponent() == (Object)null) { throw new InvalidOperationException("Missing dome collider"); } Vector3 right = Vector3.right; Vector3 val6 = greenCenter + Vector3.up * 2f; RaycastHit val7 = default(RaycastHit); if (!Physics.SphereCast(val6 + right * (greenSize + 2f), 0.2f, -right, ref val7, 4f, -1, (QueryTriggerInteraction)1) || !((Component)((RaycastHit)(ref val7)).collider).transform.IsChildOf(greenColliders.transform)) { throw new InvalidOperationException("Outside approach missed field"); } RaycastHit val8 = default(RaycastHit); if (!Physics.SphereCast(val6 + right * (greenSize - 2f), 0.2f, right, ref val8, 4f, -1, (QueryTriggerInteraction)1) || !((Component)((RaycastHit)(ref val8)).collider).transform.IsChildOf(greenColliders.transform)) { throw new InvalidOperationException("Inside approach missed field"); } float num3 = ItemAssets.DomeHeight(greenSize); Vector3 val9 = greenCenter + Vector3.up * num3; RaycastHit val10 = default(RaycastHit); if (!Physics.SphereCast(val9 + Vector3.up * 2f, 0.2f, Vector3.down, ref val10, 4f, -1, (QueryTriggerInteraction)1) || (Object)(object)((Component)((RaycastHit)(ref val10)).collider).gameObject != (Object)(object)greenColliders) { throw new InvalidOperationException("Outside roof missed dome"); } RaycastHit val11 = default(RaycastHit); if (!Physics.SphereCast(val9 - Vector3.up * 2f, 0.2f, Vector3.up, ref val11, 4f, -1, (QueryTriggerInteraction)1) || (Object)(object)((Component)((RaycastHit)(ref val11)).collider).gameObject != (Object)(object)greenColliders) { throw new InvalidOperationException("Inside roof missed dome"); } string text = greenId; if (StartGreen() || greenId != text) { throw new InvalidOperationException("Stacking accepted"); } log("DIAGNOSTIC PASS two-way dome side/roof sweeps and stacking rejection; layer=" + ((Component)((RaycastHit)(ref val7)).collider).gameObject.layer); } else if (action == "gravity_consumers") { if (!Gravity.TotalOverride) { throw new InvalidOperationException("Wait for active TOTAL override"); } GolfBall ownBall2 = host.AsGolfer.OwnBall; if ((Object)(object)ownBall2 == (Object)null) { throw new InvalidOperationException("Spawn native ball first"); } Rigidbody rigidbody2 = ownBall2.Rigidbody; Vector3 linearVelocity = rigidbody2.linearVelocity; try { rigidbody2.linearVelocity = Vector3.zero; AccessTools.DeclaredMethod(typeof(GolfBall), "ApplyGravity", (Type[])null, (Type[])null).Invoke(ownBall2, null); val4 = rigidbody2.linearVelocity; float magnitude = ((Vector3)(ref val4)).magnitude; val4 = Physics.gravity; float num4 = ((Vector3)(ref val4)).magnitude * Time.fixedDeltaTime; if (Mathf.Abs(magnitude - num4) > 0.001f) { throw new InvalidOperationException("Native ball delta mismatch " + magnitude + " != " + num4); } float num5 = (float)AccessTools.DeclaredMethod(typeof(PlayerMovement), "GetBaseGravitySpeedDelta", (Type[])null, (Type[])null).Invoke(host.Movement, null); float num6 = (float)AccessTools.Field(typeof(PlayerMovement), "gravityFactor").GetValue(host.Movement); float num7 = Physics.gravity.y * GameManager.PlayerMovementSettings.BaseGravityFactor * num6 * Time.fixedDeltaTime; if (Mathf.Abs(num5 - num7) > 0.001f) { throw new InvalidOperationException("Native player delta mismatch"); } log("DIAGNOSTIC PASS native gravity consumers ball=" + magnitude + " player=" + num5 + " TOTAL=" + Gravity.Effective); } finally { rigidbody2.linearVelocity = linearVelocity; } } else if (action == "capture_timeout") { if (!captures.TryGetValue(((NetworkBehaviour)host).netId, out var value) || value.Victim == 0) { throw new InvalidOperationException("No occupied Capture Ball"); } value.Until = NetworkTime.time; } else if (action == "capture_controls") { if (!captures.TryGetValue(((NetworkBehaviour)host).netId, out var value2) || value2.Victim == 0) { throw new InvalidOperationException("No occupied Capture Ball"); } PlayerInfo val12 = Player(value2.Victim); if ((Object)(object)val12 == (Object)null) { throw new InvalidOperationException("Victim disconnected"); } if (val12.Movement.IsVisible || !val12.AsEntity.Rigidbody.isKinematic || val12.AsGolfer.CanMove() || val12.AsGolfer.TryStartChargingSwing() || val12.Movement.TryTriggerJump() || val12.Movement.TryDive() || val12.Inventory.TrySelectItemSlot(0, true) || (bool)AccessTools.DeclaredMethod(typeof(PlayerGolfer), "CanAimSwing", (Type[])null, (Type[])null).Invoke(val12.AsGolfer, null)) { throw new InvalidOperationException("Captured controls not suspended"); } log("DIAGNOSTIC PASS capture native visibility/kinematic/move/aim/swing/jump/dive/inventory guards"); } else if (action == "capture_kill") { if (!captures.TryGetValue(((NetworkBehaviour)host).netId, out var value3) || value3.Victim == 0) { throw new InvalidOperationException("No occupied Capture Ball"); } Bounds val13 = default(Bounds); if (!BoundsManager.TryGetLevelBounds(ref val13)) { throw new InvalidOperationException("No bounds"); } value3.Flying = true; value3.Position = ((Bounds)(ref val13)).max + Vector3.right * 100f; } else { if (!(action == "verify_clean")) { throw new ArgumentException("Unknown custom diagnostic"); } if (captures.Count != 0 || hiddenPlayers.Count != 0 || (Object)(object)greenColliders != (Object)null || (Object)(object)greenVisual != (Object)null || gravityEvents.Count != 0 || blowers.Count != 0 || held.Count != 0 || Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0).Any((Collider c) => ((Object)c).name == "CustomItems.GreenProtector.Colliders" || ((Object)(object)((Component)c).transform.parent != (Object)null && ((Object)((Component)c).transform.parent).name == "CustomItems.GreenProtector.Colliders"))) { throw new InvalidOperationException("Custom item state leaked"); } log("Verified all custom effects/objects/captured states cleared"); } Inspect(); } private static void Write(NetworkWriter w, byte[] data) { if (data == null || data.Length > 32768) { throw new InvalidDataException(); } NetworkWriterExtensions.WriteInt(w, data.Length); w.WriteBytes(data, 0, data.Length); } private static byte[] Read(NetworkReader r) { int num = NetworkReaderExtensions.ReadInt(r); if (num < 0 || num > 32768 || num > r.Remaining) { throw new InvalidDataException(); } return NetworkReaderExtensions.ReadBytes(r, num); } private static void RegisterSerializers() { CheckMessage(); CheckMessage(); Writer.write = delegate(NetworkWriter w, CustomItemsClientMessage m) { Write(w, m.Data); }; Reader.read = (NetworkReader r) => new CustomItemsClientMessage { Data = Read(r) }; Writer.write = delegate(NetworkWriter w, CustomItemsServerMessage m) { Write(w, m.Data); }; Reader.read = (NetworkReader r) => new CustomItemsServerMessage { Data = Read(r) }; } private static void CheckMessage() where T : struct, NetworkMessage { ushort id = NetworkMessages.GetId(); if (NetworkMessages.Lookup.TryGetValue(id, out var value) && value != typeof(T)) { throw new InvalidOperationException("CustomItems Mirror ID collision"); } } internal void StartServer() { RegisterSerializers(); session = Guid.NewGuid().ToString("N"); revision = 0L; NetworkServer.RegisterHandler((Action)ReceiveClient, true); serverRegistered = true; } internal void StartClient() { RegisterSerializers(); remoteEnabled = false; acceptedRevision = 0L; sequence = 0L; remoteSession = ""; nextHello = 0.0; NetworkClient.RegisterHandler((Action)ReceiveServer, true); clientRegistered = true; } internal void StopNetworking() { UseNextCourseSettings(); if (serverRegistered) { NetworkServer.UnregisterHandler(); } if (clientRegistered) { NetworkClient.UnregisterHandler(); } serverRegistered = (clientRegistered = (remoteEnabled = false)); lastRequest.Clear(); lastSequence.Clear(); lastHello.Clear(); remoteSession = ""; } internal void PeerDisconnected(int id) { lastRequest.Remove(id); lastSequence.Remove(id); lastHello.Remove(id); } private static byte[] Packet(Action action) { using MemoryStream memoryStream = new MemoryStream(); using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream, Encoding.UTF8, leaveOpen: true)) { binaryWriter.Write((byte)1); action(binaryWriter); } if (memoryStream.Length > 32768) { throw new InvalidDataException(); } return memoryStream.ToArray(); } private void Broadcast(byte[] bytes) { if (!serverRegistered) { return; } foreach (NetworkConnectionToClient value in NetworkServer.connections.Values) { if (((NetworkConnection)value).isAuthenticated && (object)value != NetworkServer.localConnection && peerReady(value.connectionId)) { ((NetworkConnection)value).Send(new CustomItemsServerMessage { Data = bytes }, 0); } } } private void SendUse(int slot) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active) { Activate(GameManager.LocalPlayerInfo, slot, LocalDirection()); } else if (remoteEnabled && NetworkClient.isConnected && clientReady()) { NetworkClient.Send(new CustomItemsClientMessage { Data = Packet(delegate(BinaryWriter w) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) w.Write((byte)1); w.Write(remoteSession); w.Write(++sequence); w.Write(slot); Vector(w, LocalDirection()); }) }, 0); } } private static Vector3 LocalDirection() { //IL_0027: 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) if (!((Object)(object)GameManager.Camera != (Object)null)) { return ((Component)GameManager.LocalPlayerInfo).transform.forward; } return ((Component)GameManager.Camera).transform.forward; } private void ReceiveClient(NetworkConnectionToClient c, CustomItemsClientMessage m) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) if (Faulted || !peerReady(c.connectionId)) { return; } try { using MemoryStream memoryStream = new MemoryStream(m.Data); using BinaryReader binaryReader = new BinaryReader(memoryStream); if (binaryReader.ReadByte() != 1) { return; } switch (binaryReader.ReadByte()) { case 0: { if (!lastHello.TryGetValue(c.connectionId, out var value3) || NetworkTime.time - value3 > 1.0) { lastHello[c.connectionId] = NetworkTime.time; SendState(c); } break; } case 1: { if (!HostEnabled || !Playing || binaryReader.ReadString() != session) { break; } long num = binaryReader.ReadInt64(); int slot = binaryReader.ReadInt32(); Vector3 v = Vector(binaryReader); if (memoryStream.Position != memoryStream.Length || !Valid(v) || ((Vector3)(ref v)).sqrMagnitude < 0.5f || ((Vector3)(ref v)).sqrMagnitude > 1.5f || (lastSequence.TryGetValue(c.connectionId, out var value) && num <= value)) { break; } lastSequence[c.connectionId] = num; if (!lastRequest.TryGetValue(c.connectionId, out var value2) || !(NetworkTime.time - value2 < 0.07)) { lastRequest[c.connectionId] = NetworkTime.time; NetworkIdentity identity = ((NetworkConnection)c).identity; PlayerInfo val = ((identity != null) ? ((Component)identity).GetComponent() : null); if (!((Object)(object)val == (Object)null)) { Activate(val, slot, ((Vector3)(ref v)).normalized); } } break; } } } catch (Exception ex) when (ex is IOException || ex is ArgumentException) { log("Rejected custom intent: " + ex.GetType().Name); } } private void Activate(PlayerInfo p, int slot, Vector3 direction) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0092: 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_0118: Unknown result type (might be due to invalid IL or missing references) if (!HostEnabled || !Playing || !Eligible(p) || IsCaptured(((NetworkBehaviour)p).netId) || slot < 0 || slot >= p.Inventory.slots.Count || (((NetworkBehaviour)p).isLocalPlayer ? p.Inventory.EquippedItemIndex : p.NetworkedEquippedItemIndex) != slot) { return; } InventorySlot val = p.Inventory.slots[slot]; CustomItemDefinition customItemDefinition = Registry.Get(val.itemType); if (customItemDefinition == null || !Setting(customItemDefinition.Enabled) || val.remainingUses <= 0 || (CarrierSlot(((NetworkBehaviour)p).netId, out var slot2) && slot2 != slot)) { return; } if (customItemDefinition.Id == "leaf_blower") { StartBlower(p, slot, direction); return; } if (customItemDefinition.Id == "green_protector") { if (!StartGreen(p)) { return; } } else if (customItemDefinition.Id == "gravity_swapper") { StartGravity(); } else if (customItemDefinition.Id == "capture_ball") { if (ThrowCapture(p, slot, direction)) { SendState(); } return; } Consume(p.Inventory, slot); log("Activated " + customItemDefinition.Id + " owner=" + ((NetworkBehaviour)p).netId); SendState(); } private void SendState(NetworkConnectionToClient only = null) { byte[] array = Packet(delegate(BinaryWriter w) { w.Write((byte)0); w.Write(session); w.Write(++revision); w.Write(HostEnabled); CustomItemDefinition[] items = Registry.Items; foreach (CustomItemDefinition customItemDefinition in items) { w.Write(Setting(customItemDefinition.Enabled)); w.Write(Setting(customItemDefinition.Weight)); } WriteGreen(w); WriteGravity(w); WriteCapture(w); WriteBlower(w); }); if (only != null) { ((NetworkConnection)only).Send(new CustomItemsServerMessage { Data = array }, 0); } else { Broadcast(array); } } private void ReceiveServer(CustomItemsServerMessage m) { //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_0166: 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) if (Faulted || NetworkServer.active) { return; } try { using MemoryStream input = new MemoryStream(m.Data); using BinaryReader binaryReader = new BinaryReader(input); if (binaryReader.ReadByte() != 1) { return; } switch (binaryReader.ReadByte()) { case 0: { string text = binaryReader.ReadString(); long num = binaryReader.ReadInt64(); if (text.Length == 32 && (!(text == remoteSession) || num > acceptedRevision)) { if (text != remoteSession) { Cleanup("host session changed"); acceptedRevision = 0L; remoteSession = text; } acceptedRevision = num; bool flag = binaryReader.ReadBoolean(); if (!flag && remoteEnabled) { Cleanup("host disabled"); } remoteEnabled = flag; remoteSettings = new Tuple[Registry.Items.Length]; for (int i = 0; i < remoteSettings.Length; i++) { remoteSettings[i] = Tuple.Create(binaryReader.ReadBoolean(), binaryReader.ReadInt32()); } ReadGreen(binaryReader); ReadGravity(binaryReader); ReadCapture(binaryReader); ReadBlower(binaryReader); } break; } case 1: { uint id2 = binaryReader.ReadUInt32(); Vector3 val = Vector(binaryReader); PlayerInfo val2 = Player(id2); if ((Object)(object)val2 != (Object)null && ((NetworkBehaviour)val2).isLocalPlayer && Valid(val) && ((Vector3)(ref val)).magnitude <= 10f && !IsCaptured(id2)) { val2.AsEntity.Rigidbody.AddForce(val, (ForceMode)2); } break; } case 2: { uint id = binaryReader.ReadUInt32(); Vector3 position = Vector(binaryReader); bool visible = binaryReader.ReadBoolean(); ApplyCapturePlayer(id, position, visible); break; } } } catch (Exception ex) when (ex is IOException || ex is ArgumentException) { log("Rejected custom snapshot: " + ex.GetType().Name); } } private void PollHost() { if (!NetworkServer.active && clientRegistered && NetworkClient.isConnected && clientReady() && NetworkTime.time >= nextHello) { nextHello = NetworkTime.time + 2.0; NetworkClient.Send(new CustomItemsClientMessage { Data = Packet(delegate(BinaryWriter w) { w.Write((byte)0); }) }, 0); } } private static void Vector(BinaryWriter w, Vector3 v) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) w.Write(v.x); w.Write(v.y); w.Write(v.z); } private static Vector3 Vector(BinaryReader r) { //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) Vector3 val = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); if (!Valid(val)) { throw new InvalidDataException("Invalid vector"); } return val; } private static bool Valid(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (!float.IsNaN(v.x) && !float.IsNaN(v.y) && !float.IsNaN(v.z) && !float.IsInfinity(v.x) && !float.IsInfinity(v.y) && !float.IsInfinity(v.z)) { return (double)((Vector3)(ref v)).sqrMagnitude < 10000000000.0; } return false; } private static int Count(BinaryReader r, int maximum = 64) { int num = r.ReadInt32(); if (num < 0 || num > maximum) { throw new InvalidDataException("Invalid count"); } return num; } private void ConfigureNativeWeights(Harmony h) { //IL_0027: 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_0049: Expected O, but got Unknown //IL_0049: Expected O, but got Unknown h.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(MatchSetupRules), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(CustomItemRuntime), "ProtectCustomOnlyPools", (Type[])null), new HarmonyMethod(typeof(CustomItemRuntime), "NativeWeightsUpdated", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void ProtectCustomOnlyPools(MatchSetupRules __instance) { CustomItemRuntime current = Current; if (current == null || !NetworkServer.active) { return; } bool flag = current.MenuMaster && current.Registry.Items.Any((CustomItemDefinition d) => d.Enabled.Value && d.Weight.Value > 0); if (!flag && current.customOnlyPools.Count == 0) { return; } HashSet hashSet = (HashSet)nativeNonzeroQueue.GetValue(__instance); if (current.poolGuardQueue != hashSet && current.poolGuardQueue != null) { foreach (int customOnlyPool in current.customOnlyPools) { current.poolGuardQueue.Add(customOnlyPool); } current.customOnlyPools.Clear(); } current.poolGuardQueue = hashSet; if (flag) { foreach (int item in hashSet) { current.customOnlyPools.Add(item); } hashSet.Clear(); return; } foreach (int customOnlyPool2 in current.customOnlyPools) { hashSet.Add(customOnlyPool2); } current.customOnlyPools.Clear(); } private static void NativeWeightsUpdated(MatchSetupRules __instance) { CustomItemRuntime current = Current; if (current == null || current.weightUiFaulted || !MatchSetupMenu.IsActive) { return; } try { current.RefreshNativeWeights(__instance); } catch (Exception ex) { current.weightUiFaulted = true; current.ClearNativeWeights(); current.log("Native item slider integration disabled: " + ex); } } private bool MenuItemEnabled(int index) { if (!NetworkServer.active) { if (remoteSettings != null && index < remoteSettings.Length) { return remoteSettings[index].Item1; } return false; } return Registry.Items[index].Enabled.Value; } private int MenuWeight(int index) { if (!NetworkServer.active) { if (remoteSettings == null || index >= remoteSettings.Length) { return 0; } return remoteSettings[index].Item2; } return Registry.Items[index].Weight.Value; } private void RefreshNativeWeights(MatchSetupRules menu, bool force = false) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Expected O, but got Unknown //IL_01e4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)menu == (Object)null || !(bool)nativeInitialized.GetValue(menu) || (!force && Time.unscaledTimeAsDouble < nextWeightRefresh)) { return; } nextWeightRefresh = Time.unscaledTimeAsDouble + 0.1; if ((Object)(object)weightMenu != (Object)(object)menu) { ClearNativeWeights(); weightMenu = menu; resetNativeItemWeights = (UnityAction)delegate { if (NetworkServer.active && MenuMaster) { CustomItemDefinition[] items = Registry.Items; foreach (CustomItemDefinition customItemDefinition in items) { customItemDefinition.Weight.Value = (int)((ConfigEntryBase)customItemDefinition.Weight).DefaultValue; } itemConfig.Save(); nextWeightRefresh = 0.0; log("Native item chances reset: custom shipped weights restored"); } }; ((UnityEvent)menu.resetItemSpawnChancesButton.onClick).AddListener(resetNativeItemWeights); } if (!MenuMaster && weightRows.Values.All((WeightRow x) => (Object)(object)x.Root != (Object)null && !x.Root.activeSelf)) { return; } bool activeInHierarchy = ((Component)menu.itemsParent).gameObject.activeInHierarchy; bool flag = activeInHierarchy && !weightGridVisible; weightGridVisible = activeInHierarchy; float num = 0f; for (int num2 = 0; num2 < Registry.Items.Length; num2++) { int index = num2; CustomItemDefinition definition = Registry.Items[index]; bool flag2 = MenuMaster && MenuItemEnabled(index); if (flag2 && !weightRows.ContainsKey(definition.Id)) { GameObject val = Object.Instantiate(menu.itemPrefab, (Transform)(object)menu.itemsParent, false); ((Object)val).name = "RogueGolf.ItemWeight." + definition.Id; val.transform.localScale = Vector3.one; SliderOption slider = val.GetComponentInChildren(true); LocalizeStringEvent[] componentsInChildren = val.GetComponentsInChildren(true); for (int num3 = 0; num3 < componentsInChildren.Length; num3++) { ((Behaviour)componentsInChildren[num3]).enabled = false; } TMP_Text[] componentsInChildren2 = val.GetComponentsInChildren(true); foreach (TMP_Text val2 in componentsInChildren2) { if ((Object)(object)val2 != (Object)(object)slider.label) { val2.text = definition.Name; } } WeightRow value = new WeightRow { Root = val, Slider = slider }; weightRows.Add(definition.Id, value); bool initializing = true; slider.Initialize((Action)delegate { if (!initializing && NetworkServer.active && MenuMaster && MenuItemEnabled(index)) { int value4 = Mathf.Clamp(Mathf.RoundToInt(Mathf.Round(slider.value * 40f) / 40f * 100f), 0, 1000); definition.Weight.Value = value4; itemConfig.Save(); menu.SetPreset((Preset)2); nextWeightRefresh = 0.0; log("Native slider " + definition.Id + " weight=" + value4 + " (shared across item pools)"); } }, (float)MenuWeight(index) / 100f); initializing = false; flag = true; } if (weightRows.TryGetValue(definition.Id, out var value2)) { if (value2.Root.activeSelf != flag2) { value2.Root.SetActive(flag2); flag = true; } if (flag2) { int num4 = MenuWeight(index); num += (float)num4; value2.Slider.SetLimits(0f, Mathf.Max(1f, Mathf.Ceil((float)num4 / 100f))); value2.Slider.valueWithoutNotify = (float)num4 / 100f; ((Selectable)value2.Slider.Slider).interactable = NetworkServer.active; menu.SetLabelGreyedOut(value2.Root, num4 == 0); } } } ItemPool val3 = (ItemPool)nativePool.Invoke(menu, null); int num5 = (int)nativePoolIndex.GetValue(menu); float num6 = menu.GetItemPoolTotalWeight(num5) + num; List list = (List)nativeSliders.GetValue(menu); int i; for (i = 0; i < menu.itemOrder.Length && i < list.Count; i++) { float num7 = (val3.SpawnChances.Any((ItemSpawnChance x) => (int)x.item == (int)menu.itemOrder[i]) ? menu.GetWeight(num5, menu.itemOrder[i]) : 0f); list[i].SetValueText(((num6 > 0f) ? (num7 / num6 * 100f) : 0f).ToString("0.#") + "%"); } for (int num8 = 0; num8 < Registry.Items.Length; num8++) { if (weightRows.TryGetValue(Registry.Items[num8].Id, out var value3) && value3.Root.activeSelf) { value3.Slider.SetValueText(((num6 > 0f) ? ((float)MenuWeight(num8) / num6 * 100f) : 0f).ToString("0.#") + "%"); } } if (flag) { LayoutRebuilder.ForceRebuildLayoutImmediate(menu.itemsParent); RebuildItemNavigation(menu); log("Native item rows refreshed: " + weightRows.Values.Count((WeightRow x) => x.Root.activeSelf) + " visible"); } } private void ClearNativeWeights() { if (poolGuardQueue != null) { foreach (int customOnlyPool in customOnlyPools) { poolGuardQueue.Add(customOnlyPool); } customOnlyPools.Clear(); poolGuardQueue = null; } if ((Object)(object)weightMenu != (Object)null && resetNativeItemWeights != null) { ((UnityEvent)weightMenu.resetItemSpawnChancesButton.onClick).RemoveListener(resetNativeItemWeights); } resetNativeItemWeights = null; foreach (WeightRow value in weightRows.Values) { if ((Object)(object)value.Root != (Object)null) { value.Root.SetActive(false); Object.Destroy((Object)(object)value.Root); } } if ((Object)(object)weightMenu != (Object)null && weightRows.Count > 0) { RebuildItemNavigation(weightMenu); } weightRows.Clear(); weightMenu = null; weightGridVisible = false; } private static void RebuildItemNavigation(MatchSetupRules menu) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Invalid comparison between Unknown and I4 //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Expected O, but got Unknown //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected O, but got Unknown GridNavigationGroup val = (GridNavigationGroup)nativeNavigation.GetValue(menu); foreach (Row row in val.rows) { row.elements.RemoveAll((Element e) => (Object)(object)e.selectable == (Object)null || ((Component)e.selectable).transform.IsChildOf((Transform)(object)menu.itemsParent)); } val.rows.RemoveAll((Row r) => r.elements.Count == 0); List list = new List(); foreach (Transform item in (Transform)menu.itemsParent) { Transform val2 = item; if (((Component)val2).gameObject.activeSelf) { SliderOption componentInChildren = ((Component)val2).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { list.Add(componentInChildren); } } } int num = (((int)menu.itemGridLayout.constraint == 1) ? Mathf.Max(1, menu.itemGridLayout.constraintCount) : 2); int num2 = Math.Min(2, val.rows.Count); if (((Component)menu.itemsParent).gameObject.activeInHierarchy) { List list2 = (from s in list orderby ((Component)s).transform.position.y descending, ((Component)s).transform.position.x select s).ToList(); Row val3 = null; float num3 = float.NaN; foreach (SliderOption item2 in list2) { float y = ((Component)item2).transform.position.y; if (val3 == null || Mathf.Abs(num3 - y) > 1f) { val3 = Row.CreateBlankRow(); val.rows.Insert(num2++, val3); num3 = y; } val3.elements.Add(new Element { selectable = (Selectable)(object)item2.Slider }); } val.UpdateNavigation(); return; } for (int num4 = 0; num4 < list.Count; num4 += num) { Row val4 = Row.CreateBlankRow(); for (int num5 = num4; num5 < Math.Min(num4 + num, list.Count); num5++) { val4.elements.Add(new Element { selectable = (Selectable)(object)list[num5].Slider }); } val.rows.Insert(num2++, val4); } val.UpdateNavigation(); } private void ConfigureRangeWeights(Harmony harmony) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown harmony.Patch((MethodBase)AccessTools.Method(typeof(ItemSpawnerSettings), "GetRandomItemFor", (Type[])null, (Type[])null), new HarmonyMethod(typeof(CustomItemRuntime), "SelectRangeItem", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private ItemSpawnerSettings RangeSettings(ItemSpawnerSettings settings, PlayerInfo player) { if (!HostEnabled || !SingletonBehaviour.HasInstance || !SingletonNetworkBehaviour.HasInstance) { return settings; } MatchSetupRules instance = SingletonNetworkBehaviour.Instance; if ((Object)(object)settings == (Object)(object)instance.itemSpawnerSettings || (Object)(object)settings == (Object)(object)instance.mobilityItemSpawnerSettings) { return settings; } ItemSpawnChance[] array = (from e in settings.ItemPools.SelectMany((ItemPoolData p) => p.pool.SpawnChances) where (int)e.item > 0 select e).ToArray(); if (array.Length == 0 || !array.All((ItemSpawnChance e) => (int)e.item == 1 || (int)e.item == 5)) { return instance.itemSpawnerSettings; } return instance.mobilityItemSpawnerSettings; } private static bool SelectRangeItem(ItemSpawnerSettings __instance, PlayerInfo player, ref ItemType __result) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected I4, but got Unknown CustomItemRuntime current = Current; if (current == null) { return true; } ItemSpawnerSettings val = current.RangeSettings(__instance, player); if ((Object)(object)val == (Object)(object)__instance) { return true; } __result = (ItemType)(int)val.GetRandomItemFor(player); return false; } private void ConfigureGravity(ConfigFile c) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown gravityWarning = c.Bind("CustomItems.gravity_swapper", "WarningSeconds", 1.7f, new ConfigDescription("Global activation warning.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 3f), Array.Empty())); gravityDuration = c.Bind("CustomItems.gravity_swapper", "DurationSeconds", 5f, new ConfigDescription("TOTAL override duration.", (AcceptableValueBase)(object)new AcceptableValueRange(2f, 10f), Array.Empty())); extremeChance = c.Bind("CustomItems.gravity_swapper", "ExtremeChance", 0.12f, new ConfigDescription("Probability of an extreme instead of common range.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); string[] array = new string[8] { "LowMin", "LowMax", "ExtremeLowMin", "ExtremeLowMax", "HighMin", "HighMax", "ExtremeHighMin", "ExtremeHighMax" }; float[] array2 = CustomItemDefaults.GravityRanges; for (int i = 0; i < array.Length; i++) { gravityRanges.Add(c.Bind("CustomItems.gravity_swapper", array[i], array2[i], new ConfigDescription("Host random distribution range.", (AcceptableValueBase)(object)new AcceptableValueRange(0.2f, 5f), Array.Empty()))); } } private void StartGravity() { if (gravityEvents.Count >= 32) { throw new InvalidOperationException("Gravity event capacity reached"); } int num = ((random.Next(2) != 0) ? 4 : 0) + ((random.NextDouble() < (double)Setting(extremeChance)) ? 2 : 0); float num2 = Setting(gravityRanges[num]); float num3 = Setting(gravityRanges[num + 1]); GravityEvent gravityEvent = new GravityEvent { Id = "custom.gravity_swapper." + Guid.NewGuid().ToString("N"), Start = NetworkTime.time + (double)Setting(gravityWarning), Total = Mathf.Round((Math.Min(num2, num3) + (float)random.NextDouble() * Math.Abs(num3 - num2)) * 100f) / 100f }; gravityEvent.End = gravityEvent.Start + (double)Setting(gravityDuration); gravityEvents.Add(gravityEvent); Notify("GRAVITY SHIFT in " + Setting(gravityWarning).ToString("F1") + "s"); } private void TickGravity() { GravityEvent[] array = gravityEvents.ToArray(); foreach (GravityEvent gravityEvent in array) { if (NetworkTime.time >= gravityEvent.End) { Gravity.Remove(gravityEvent.Id); gravityEvents.Remove(gravityEvent); Notify("GRAVITY: " + Gravity.Effective.ToString("F2") + "x (resolved)"); log("Gravity override removed " + gravityEvent.Id + "\n" + Gravity.Inspect()); } else if (!gravityEvent.Applied && NetworkTime.time >= gravityEvent.Start) { gravityEvent.Applied = true; Gravity.Override(gravityEvent.Id, gravityEvent.Total, 1000, gravityEvent.End); Notify("GRAVITY: " + gravityEvent.Total.ToString("F2") + "x"); log(Gravity.Inspect()); } } } private void AnimateGravity() { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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) GravityEvent gravityEvent = gravityEvents.OrderByDescending((GravityEvent x) => x.Start).FirstOrDefault(); if (gravityEvent == null) { if ((Object)(object)gravityVisual != (Object)null) { Object.Destroy((Object)(object)gravityVisual); } return; } PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo; if (!((Object)(object)localPlayerInfo == (Object)null)) { if ((Object)(object)gravityVisual == (Object)null) { gravityVisual = Registry.Assets.Rings("Gravity shift", (gravityEvent.Total < 1f) ? new Color(0.3f, 0.9f, 1f, 0.45f) : new Color(1f, 0.65f, 0.2f, 0.45f), 2f); } gravityVisual.transform.position = ((Component)localPlayerInfo).transform.position + Vector3.up * ((gravityEvent.Total < 1f) ? (0.3f + Mathf.Repeat(Time.time * 2f, 2f)) : (2.3f - Mathf.Repeat(Time.time * 2f, 2f))); gravityVisual.transform.localScale = Vector3.one * ((gravityEvent.Total < 1f) ? (1f + Mathf.Repeat(Time.time, 1f)) : (2f - Mathf.Repeat(Time.time, 1f))); } } private void CleanupGravity() { foreach (GravityEvent gravityEvent in gravityEvents) { Gravity.Remove(gravityEvent.Id); } gravityEvents.Clear(); if ((Object)(object)gravityVisual != (Object)null) { Object.Destroy((Object)(object)gravityVisual); } } private void WriteGravity(BinaryWriter w) { w.Write(gravityEvents.Count); foreach (GravityEvent gravityEvent in gravityEvents) { w.Write(gravityEvent.Id); w.Write(gravityEvent.Start); w.Write(gravityEvent.End); w.Write(gravityEvent.Total); } } private void ReadGravity(BinaryReader r) { int num = Count(r, 32); HashSet ids = new HashSet(); for (int i = 0; i < num; i++) { string id = r.ReadString(); double num2 = r.ReadDouble(); double num3 = r.ReadDouble(); float num4 = r.ReadSingle(); if (id.Length > 96 || float.IsNaN(num4) || num4 < 0.2f || num4 > 5f || double.IsNaN(num2) || double.IsInfinity(num2) || double.IsNaN(num3) || double.IsInfinity(num3) || num3 < num2) { throw new InvalidDataException(); } ids.Add(id); GravityEvent gravityEvent = gravityEvents.FirstOrDefault((GravityEvent x) => x.Id == id); if (gravityEvent == null) { List list = gravityEvents; GravityEvent obj = new GravityEvent { Id = id, Start = num2, End = num3, Total = num4 }; gravityEvent = obj; list.Add(obj); Notify("GRAVITY SHIFT incoming"); } } GravityEvent[] array = gravityEvents.Where((GravityEvent x) => !ids.Contains(x.Id)).ToArray(); foreach (GravityEvent gravityEvent2 in array) { Gravity.Remove(gravityEvent2.Id); gravityEvents.Remove(gravityEvent2); } } private void ConfigureGreen(ConfigFile c) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown greenRadius = c.Bind("CustomItems.green_protector", "FallbackRadius", 9f, new ConfigDescription("Used if the current hole has no reliable green spline.", (AcceptableValueBase)(object)new AcceptableValueRange(4f, 30f), Array.Empty())); greenWarning = c.Bind("CustomItems.green_protector", "WarningSeconds", 1.2f, new ConfigDescription("Warning before solid collision.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 2f), Array.Empty())); greenDuration = c.Bind("CustomItems.green_protector", "DurationSeconds", 7f, new ConfigDescription("Solid neutral barrier lifetime.", (AcceptableValueBase)(object)new AcceptableValueRange(3f, 15f), Array.Empty())); } private bool StartGreen(PlayerInfo deployer = null) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) if (greenId != "") { Notify("Green Protector already deployed — item retained"); return false; } GolfHole mainHole = GolfHoleManager.MainHole; if ((Object)(object)mainHole == (Object)null) { Notify("No active green — item retained"); return false; } greenCenter = ((Component)mainHole).transform.position; greenSize = Setting(greenRadius); if (SingletonBehaviour.HasInstance) { object? value = AccessTools.Field(typeof(BoundsManager), "greenBounds").GetValue(SingletonBehaviour.Instance); SplineContainer val = (SplineContainer)((value is SplineContainer) ? value : null); if ((Object)(object)val != (Object)null) { foreach (Spline spline in val.Splines) { Vector3[] array = (Vector3[])(object)new Vector3[64]; float num = 0f; for (int i = 0; i < 64; i++) { array[i] = ((Component)val).transform.TransformPoint(float3.op_Implicit(SplineUtility.EvaluatePosition(spline, (float)i / 64f))); float num2 = num; Vector2 val2 = new Vector2(array[i].x - greenCenter.x, array[i].z - greenCenter.z); num = Mathf.Max(num2, ((Vector2)(ref val2)).magnitude); } bool flag = false; int num3 = 0; int num4 = 63; while (num3 < 64) { if (array[num3].z > greenCenter.z != array[num4].z > greenCenter.z && greenCenter.x < (array[num4].x - array[num3].x) * (greenCenter.z - array[num3].z) / (array[num4].z - array[num3].z) + array[num3].x) { flag = !flag; } num4 = num3++; } if (flag && num >= 2f && num <= 40f) { greenSize = num + 1.5f; break; } } } } greenOwner = (((Object)(object)deployer != (Object)null) ? ((NetworkBehaviour)deployer).netId : (((Object)(object)GameManager.LocalPlayerInfo != (Object)null) ? ((NetworkBehaviour)GameManager.LocalPlayerInfo).netId : 0u)); greenId = Guid.NewGuid().ToString("N"); greenStart = NetworkTime.time + (double)Setting(greenWarning); greenEnd = greenStart + (double)Setting(greenDuration); Notify("GREEN PROTECTOR deploying — return to sender"); return true; } private void TickGreen() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) if (greenId == "") { return; } if (NetworkServer.active && greenOwner != 0 && (Object)(object)Player(greenOwner) == (Object)null) { log("Green Protector deployer disconnected " + greenId); CleanupGreen(); return; } if (NetworkTime.time >= greenEnd) { log("Green Protector expired " + greenId); CleanupGreen(); return; } if ((Object)(object)greenVisual == (Object)null) { greenVisual = Registry.Assets.Barrier(greenSize); greenVisual.transform.position = greenCenter; log("Green Protector created " + greenId + " radius=" + greenSize); } if (NetworkTime.time >= greenStart && (Object)(object)greenColliders == (Object)null) { greenColliders = new GameObject("CustomItems.GreenProtector.Colliders"); greenColliders.transform.position = greenCenter; greenColliders.layer = GameManager.LayerSettings.TerrainAdditionLayer; Mesh val = Registry.Assets.BarrierCollision(greenSize); greenColliders.AddComponent().Mesh = val; MeshCollider obj = greenColliders.AddComponent(); obj.sharedMesh = val; ((Collider)obj).sharedMaterial = Registry.Assets.BarrierPhysics; log("Green Protector collision active " + greenId); } } private void AnimateGreen() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)greenVisual == (Object)null)) { double time = NetworkTime.time; double num = greenEnd - time; Registry.Assets.TintBarrier(greenVisual, GreenFieldEnvelope.Opacity(num), GreenFieldEnvelope.Pulse(num)); greenVisual.transform.localScale = new Vector3(1f, (time < greenStart) ? (0.2f + 0.8f * (1f - (float)(greenStart - time) / Setting(greenWarning))) : 1f, 1f); } } private void CleanupGreen() { if ((Object)(object)greenColliders != (Object)null) { greenColliders.SetActive(false); Object.Destroy((Object)(object)greenColliders); } if ((Object)(object)greenVisual != (Object)null) { Object.Destroy((Object)(object)greenVisual); } greenColliders = (greenVisual = null); greenId = ""; greenOwner = 0u; } private void WriteGreen(BinaryWriter w) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) w.Write(greenId); if (!(greenId == "")) { Vector(w, greenCenter); w.Write(greenSize); w.Write(greenStart); w.Write(greenEnd); } } private void ReadGreen(BinaryReader r) { //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) string text = r.ReadString(); if (text != greenId) { CleanupGreen(); } if (!(text == "")) { greenId = text; greenCenter = Vector(r); greenSize = r.ReadSingle(); greenStart = r.ReadDouble(); greenEnd = r.ReadDouble(); if (text.Length != 32 || greenSize < 2f || greenSize > 45f) { throw new InvalidDataException(); } } } private void ConfigureGreenReflection(Harmony harmony) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown harmony.Patch((MethodBase)AccessTools.Method(typeof(Hittable), "OnCollisionEnter", (Type[])null, (Type[])null), new HarmonyMethod(typeof(CustomItemRuntime), "GreenObjectCollision", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(Rocket), "OnFixedBUpdate", (Type[])null, (Type[])null), new HarmonyMethod(typeof(CustomItemRuntime), "GreenRocketUpdate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static bool GreenObjectCollision(Hittable __instance, Collision collision) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00ca: 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_00e2: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_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_01c4: Unknown result type (might be due to invalid IL or missing references) CustomItemRuntime current = Current; if (current == null || !current.ReflectionActive || collision.contactCount == 0 || (Object)(object)((Component)collision.collider).gameObject != (Object)(object)current.greenColliders) { return true; } Entity asEntity = __instance.AsEntity; if ((Object)(object)asEntity == (Object)null || asEntity.IsPlayer || (Object)(object)asEntity.Rigidbody == (Object)null || asEntity.Rigidbody.isKinematic) { return true; } PlayerGolfer val = __instance.ResponsibleSwingProjectilePlayer; if ((Object)(object)val == (Object)null && asEntity.IsGolfBall) { val = asEntity.AsGolfBall.Owner; } if ((Object)(object)val == (Object)null) { return true; } Vector3 val2 = (Vector3)projectileVelocity.GetValue(__instance); if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { return true; } ContactPoint contact = collision.GetContact(0); Vector3 val3 = ((ContactPoint)(ref contact)).normal; if (Vector3.Dot(val2, val3) > 0f) { val3 = -val3; } Vector3 val4 = ReturnDirection(val2, val3, ((Component)val).transform.position + Vector3.up - ((ContactPoint)(ref contact)).point); float num = Mathf.Min(((Vector3)(ref val2)).magnitude * GameManager.ItemSettings.ElectromagnetShieldProjectileNonHomingReflectSpeedFactor, __instance.SwingSettings.MaxPowerSwingHitSpeed * (1f + GameManager.GolfSettings.MaxSwingOvercharge)); asEntity.Rigidbody.linearVelocity = val4 * num; PlayerInfo val5 = Player(current.greenOwner); becomeProjectile.Invoke(__instance, new object[2] { ((Object)(object)val5 != (Object)null) ? val5.AsGolfer : val, true }); if (__instance.HasHomingTargetHittable) { setProjectileTarget.Invoke(__instance, new object[1] { val.PlayerInfo.AsHittable }); } __instance.NetworkswingHitPosition = ((Component)__instance).transform.position; __instance.NetworksideSpin = 0f; current.log("Green Protector returned " + ((Object)asEntity).name + " to sender; speed=" + num.ToString("0.0")); return false; } private static Vector3 ReturnDirection(Vector3 incoming, Vector3 normal, Vector3 toSender) { //IL_0021: 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_000f: 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_0015: 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_0026: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) Vector3 val; Vector3 normalized; if (!(((Vector3)(ref toSender)).sqrMagnitude > 0.01f)) { val = Vector3.Reflect(incoming, normal); normalized = ((Vector3)(ref val)).normalized; } else { normalized = ((Vector3)(ref toSender)).normalized; } Vector3 val2 = normalized; if (!(Vector3.Dot(val2, normal) > 0.05f)) { val = Vector3.Reflect(incoming, normal); return ((Vector3)(ref val)).normalized; } return val2; } private static bool GreenRocketUpdate(Rocket __instance) { //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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00f7: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: 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_01f1: 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_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) CustomItemRuntime current = Current; if (current == null || !current.ReflectionActive || !((NetworkBehaviour)__instance).isServer) { return true; } Rigidbody rigidbody = ((Component)__instance).GetComponent().Rigidbody; Vector3 val = (Vector3)rocketPrevious.GetValue(__instance); Vector3 val2 = rigidbody.position - val; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude < 0.0001f) { return true; } int num = Physics.SphereCastNonAlloc(val, (float)rocketRadius.GetValue(__instance), val2 / magnitude, greenRocketHits, magnitude, LayerMask.op_Implicit(GameManager.LayerSettings.RocketHittablesMask), (QueryTriggerInteraction)1); if (num == greenRocketHits.Length) { return true; } RaycastHit val3 = default(RaycastHit); float num2 = float.MaxValue; for (int i = 0; i < num; i++) { RaycastHit val4 = greenRocketHits[i]; if (!((Component)((RaycastHit)(ref val4)).collider).transform.IsChildOf(((Component)__instance).transform) && !((Object)(object)((RaycastHit)(ref val4)).collider == (Object)(Collider)rocketShootCollider.GetValue(__instance)) && (!((Object)(object)__instance.Launcher != (Object)null) || !(Time.timeAsDouble - (double)rocketTimestamp.GetValue(__instance) < 0.25) || !((Object)(object)((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent() == (Object)(object)__instance.Launcher)) && ((RaycastHit)(ref val4)).distance < num2) { val3 = val4; num2 = ((RaycastHit)(ref val4)).distance; } } if ((Object)(object)((RaycastHit)(ref val3)).collider == (Object)null || (Object)(object)((Component)((RaycastHit)(ref val3)).collider).gameObject != (Object)(object)current.greenColliders) { return true; } PlayerInfo networklauncher = __instance.Networklauncher; Vector3 val5 = ((RaycastHit)(ref val3)).normal; if (Vector3.Dot(rigidbody.linearVelocity, val5) > 0f) { val5 = -val5; } Vector3 val6 = ReturnDirection(rigidbody.linearVelocity, val5, ((Object)(object)networklauncher != (Object)null) ? (((Component)networklauncher).transform.position + Vector3.up - ((RaycastHit)(ref val3)).point) : Vector3.zero); Vector3 linearVelocity = rigidbody.linearVelocity; rigidbody.linearVelocity = val6 * ((Vector3)(ref linearVelocity)).magnitude; rigidbody.position = ((RaycastHit)(ref val3)).point + val5 * ((float)rocketRadius.GetValue(__instance) + 0.12f); ((Component)__instance).transform.position = rigidbody.position; __instance.NetworkhomingTargetHittable = (((Object)(object)networklauncher != (Object)null) ? networklauncher.AsHittable : null); PlayerInfo val7 = Player(current.greenOwner); if ((Object)(object)val7 != (Object)null) { __instance.Networklauncher = val7; } rocketReflected.SetValue(__instance, true); rocketTimestamp.SetValue(__instance, Time.timeAsDouble); rocketPrevious.SetValue(__instance, rigidbody.position); current.log("Green Protector returned native rocket to sender"); return false; } private void ConfigureBlower(ConfigFile c) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown blowerRange = c.Bind("CustomItems.leaf_blower", "Range", 10f, new ConfigDescription("Cone range in metres.", (AcceptableValueBase)(object)new AcceptableValueRange(3f, 20f), Array.Empty())); blowerAcceleration = c.Bind("CustomItems.leaf_blower", "PlayerAcceleration", 22f, new ConfigDescription("Player acceleration, with distance falloff.", (AcceptableValueBase)(object)new AcceptableValueRange(5f, 40f), Array.Empty())); } private void StartBlower(PlayerInfo p, int slot, Vector3 direction) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (!blowers.TryGetValue(((NetworkBehaviour)p).netId, out var value)) { value = (blowers[((NetworkBehaviour)p).netId] = new Blower()); log("Leaf Blower started owner=" + ((NetworkBehaviour)p).netId); } value.Slot = slot; value.Direction = direction; value.Until = NetworkTime.time + 0.18; } private void TickBlowerInput() { //IL_0039: 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_0066: Unknown result type (might be due to invalid IL or missing references) PollHost(); PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo; if (!((Object)(object)localPlayerInfo == (Object)null) && Eligible(localPlayerInfo) && !IsCaptured(((NetworkBehaviour)localPlayerInfo).netId) && !(Registry.Get(localPlayerInfo.Inventory.GetEffectivelyEquippedItem(false))?.Id != "leaf_blower")) { GameplayActions gameplay = PlayerInput.Controls.Gameplay; if (((GameplayActions)(ref gameplay)).Swing.ReadValue() > 0.05f && NetworkTime.time >= nextBlowerInput) { nextBlowerInput = NetworkTime.time + 0.1; SendUse(localPlayerInfo.Inventory.EquippedItemIndex); } } } private void TickBlowerForces() { //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) //IL_00f9: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: 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_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) KeyValuePair[] array = blowers.ToArray(); RaycastHit val5 = default(RaycastHit); for (int i = 0; i < array.Length; i++) { KeyValuePair keyValuePair = array[i]; PlayerInfo val = Player(keyValuePair.Key); Blower value = keyValuePair.Value; if ((Object)(object)val == (Object)null || !Eligible(val) || value.Until <= NetworkTime.time || value.Slot >= val.Inventory.slots.Count || Registry.Get(val.Inventory.slots[value.Slot].itemType)?.Id != "leaf_blower") { blowers.Remove(keyValuePair.Key); } else { if (NetworkTime.time < value.NextForce) { continue; } value.NextForce = NetworkTime.time + 0.1; InventorySlot val2 = val.Inventory.slots[value.Slot]; Vector3 val3 = ((Component)val).transform.position + Vector3.up * 1.1f + value.Direction * 0.65f; float num = Setting(blowerRange); int num2 = Physics.OverlapSphereNonAlloc(val3, num, blowerHits, -1, (QueryTriggerInteraction)1); blowerBodies.Clear(); for (int j = 0; j < num2; j++) { Rigidbody attachedRigidbody = blowerHits[j].attachedRigidbody; if ((Object)(object)attachedRigidbody == (Object)null || attachedRigidbody.isKinematic || !blowerBodies.Add(attachedRigidbody) || ((Component)attachedRigidbody).transform.IsChildOf(((Component)val).transform)) { continue; } Vector3 val4 = attachedRigidbody.worldCenterOfMass - val3; float magnitude = ((Vector3)(ref val4)).magnitude; if (magnitude > num || magnitude < 0.1f || Vector3.Dot(val4 / magnitude, value.Direction) < 0.86f || (Physics.Raycast(val3, val4 / magnitude, ref val5, magnitude, LayerMask.op_Implicit(GameManager.LayerSettings.PlayerOcclusionMask), (QueryTriggerInteraction)1) && (Object)(object)((RaycastHit)(ref val5)).rigidbody != (Object)(object)attachedRigidbody)) { continue; } PlayerInfo target = ((Component)attachedRigidbody).GetComponentInParent(); if ((Object)(object)target != (Object)null && (!Eligible(target) || IsCaptured(((NetworkBehaviour)target).netId))) { continue; } float num3 = Setting(blowerAcceleration) * (1f - magnitude / num) * 0.1f; if ((Object)(object)target == (Object)null) { num3 *= (((Object)(object)((Component)attachedRigidbody).GetComponentInParent() != (Object)null) ? 0.45f : Mathf.Clamp(3f / Mathf.Max(1f, attachedRigidbody.mass), 0.03f, 1.5f)); } Vector3 delta = (value.Direction + Vector3.up * 0.06f) * num3; if ((Object)(object)target != (Object)null && !((NetworkBehaviour)target).isLocalPlayer) { Broadcast(Packet(delegate(BinaryWriter w) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) w.Write((byte)1); w.Write(((NetworkBehaviour)target).netId); Vector(w, delta); })); if ((object)((NetworkBehaviour)target).connectionToClient == NetworkServer.localConnection) { attachedRigidbody.AddForce(delta, (ForceMode)2); } } else { attachedRigidbody.AddForce(delta, (ForceMode)2); } } if (val2.remainingUses <= 1) { Consume(val.Inventory, value.Slot); blowers.Remove(keyValuePair.Key); log("Leaf Blower exhausted owner=" + ((NetworkBehaviour)val).netId); } else { val.Inventory.ServerValidateAndConsumeItemUse(((InventorySlot)(ref val2)).GetUsageValidationHash(-1)); val2.remainingUses--; val.Inventory.slots[value.Slot] = val2; } } } } private void WriteBlower(BinaryWriter w) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) w.Write(blowers.Count); foreach (KeyValuePair blower in blowers) { w.Write(blower.Key); Vector(w, blower.Value.Direction); w.Write(blower.Value.Until); } } private void ReadBlower(BinaryReader r) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) blowers.Clear(); int num = Count(r); for (int i = 0; i < num; i++) { uint key = r.ReadUInt32(); blowers[key] = new Blower { Direction = Vector(r), Until = r.ReadDouble() }; } } } internal static class CustomItemDefaults { internal const bool Master = false; internal const bool ItemEnabled = true; internal const int BlowerWeight = 12; internal const int ProtectorWeight = 10; internal const int CaptureWeight = 3; internal const int GravityWeight = 8; internal const float BlowerRange = 10f; internal const float BlowerAcceleration = 22f; internal const float GreenRadius = 9f; internal const float GreenWarning = 1.2f; internal const float GreenDuration = 7f; internal const float CaptureDuration = 3.5f; internal const float CaptureImmunity = 2.5f; internal const float GravityWarning = 1.7f; internal const float GravityDuration = 5f; internal const float ExtremeChance = 0.12f; internal static float[] GravityRanges => new float[8] { 0.55f, 0.8f, 0.2f, 0.4f, 1.4f, 2f, 3f, 5f }; } internal sealed class CustomItemDefinition { internal readonly string Id; internal readonly string Name; internal readonly ItemType Type; internal readonly int Uses; internal readonly Vector3 GripPoint; internal readonly Quaternion HeldRotation; internal readonly ItemType AnimationSource; internal readonly ConfigEntry Enabled; internal readonly ConfigEntry Weight; internal ItemData Data; internal CustomItemDefinition(ConfigFile config, string id, string name, int number, int uses, int weight, Vector3 gripPoint, ItemType animationSource = (ItemType)12, float heldYaw = 180f) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown Id = id; Name = name; Type = (ItemType)number; Uses = uses; GripPoint = gripPoint; HeldRotation = Quaternion.Euler(0f, heldYaw, 0f); AnimationSource = animationSource; Enabled = config.Bind("CustomItems." + id, "Enabled", true, "Host: allow " + name + "."); Weight = config.Bind("CustomItems." + id, "Weight", weight, new ConfigDescription("Relative weight in native item pools; 0 excludes.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 1000), Array.Empty())); } internal void Mount(Transform model, Transform hand) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) model.SetParent(hand, false); model.localRotation = HeldRotation; model.localPosition = -(HeldRotation * GripPoint); ((Component)model).gameObject.AddComponent().Initialize(GripPoint, HeldRotation); } } internal sealed class CustomItemRegistry : IDisposable { internal readonly ConfigEntry Master; internal readonly CustomItemDefinition[] Items; private readonly Dictionary byType; internal readonly ItemAssets Assets = new ItemAssets(); private ItemCollection collection; internal CustomItemRegistry(ConfigFile config) { //IL_0059: 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_00c4: 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) Master = config.Bind("CustomItems", "Enabled", false, "Host-authoritative Custom Items master switch. OFF by default."); Items = new CustomItemDefinition[4] { new CustomItemDefinition(config, "leaf_blower", "Leaf Blower", 1396834561, 40, 12, new Vector3(0f, 0.245f, 0.06f), (ItemType)9), new CustomItemDefinition(config, "green_protector", "Green Protector", 1396834562, 1, 10, new Vector3(0f, -0.07f, 0f), (ItemType)12), new CustomItemDefinition(config, "capture_ball", "Capture Ball", 1396834563, 1, 3, new Vector3(0f, -0.1f, -0.04f), (ItemType)12), new CustomItemDefinition(config, "gravity_swapper", "Gravity Swapper", 1396834564, 1, 8, new Vector3(0f, -0.215f, 0f), (ItemType)2) }; byType = Items.ToDictionary((CustomItemDefinition x) => x.Type); } internal CustomItemDefinition Get(ItemType type) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!byType.TryGetValue(type, out var value)) { return null; } return value; } internal CustomItemDefinition Get(string id) { return Items.FirstOrDefault((CustomItemDefinition x) => x.Id == id); } internal void EnsureRegistered() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0187: 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: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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) ItemCollection allItems = GameManager.AllItems; if ((Object)(object)allItems == (Object)null || (Object)(object)allItems == (Object)(object)collection) { return; } Dictionary dictionary = (Dictionary)AccessTools.Field(typeof(ItemCollection), "allItemData").GetValue(allItems); CustomItemDefinition[] items = Items; ItemData val = default(ItemData); foreach (CustomItemDefinition customItemDefinition in items) { if (dictionary.TryGetValue(customItemDefinition.Type, out var value) && value != customItemDefinition.Data) { throw new InvalidOperationException("Custom item ID collision: " + customItemDefinition.Id); } if (customItemDefinition.Data == null) { customItemDefinition.Data = new ItemData(); Set(customItemDefinition.Data, "Type", customItemDefinition.Type); Set(customItemDefinition.Data, "MaxUses", customItemDefinition.Uses); Set(customItemDefinition.Data, "Icon", Assets.Icon(customItemDefinition.Id)); Set(customItemDefinition.Data, "Prefab", Assets.Template(customItemDefinition.Id)); if (allItems.TryGetItemData(customItemDefinition.AnimationSource, ref val)) { Set(customItemDefinition.Data, "AnimatorOverrideController", val.AnimatorOverrideController); Set(customItemDefinition.Data, "AnimatorItemUseOnlyOverrideController", val.AnimatorItemUseOnlyOverrideController); } customItemDefinition.Data.Initialize(); } dictionary[customItemDefinition.Type] = customItemDefinition.Data; StringTable table = ((LocalizedDatabase)(object)LocalizationSettings.StringDatabase).GetTable(TableReference.op_Implicit("Data"), (Locale)null); if ((Object)(object)table != (Object)null) { ((DetailedLocalizationTable)(object)table).AddEntry("ITEM_" + ((object)customItemDefinition.Type/*cast due to .constrained prefix*/).ToString(), customItemDefinition.Name); } } collection = allItems; } private static void Set(object target, string property, object value) { AccessTools.Field(target.GetType(), "<" + property + ">k__BackingField").SetValue(target, value); } public void Dispose() { //IL_0044: 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) if ((Object)(object)collection != (Object)null) { Dictionary dictionary = (Dictionary)AccessTools.Field(typeof(ItemCollection), "allItemData").GetValue(collection); CustomItemDefinition[] items = Items; foreach (CustomItemDefinition customItemDefinition in items) { if (dictionary.TryGetValue(customItemDefinition.Type, out var value) && value == customItemDefinition.Data) { dictionary.Remove(customItemDefinition.Type); } } } Assets.Dispose(); collection = null; } } internal sealed class HeldItemPose : MonoBehaviour { private Vector3 grip; private Vector3 aim; private Quaternion idle; internal void Initialize(Vector3 gripPoint, Quaternion idleRotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_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) grip = gripPoint; idle = idleRotation; } internal void SetAim(Vector3 direction) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) aim = direction; } private void LateUpdate() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)((Component)this).transform.parent == (Object)null)) { if (((Vector3)(ref aim)).sqrMagnitude > 0.001f) { ((Component)this).transform.rotation = Quaternion.LookRotation(aim, Vector3.up); } else { ((Component)this).transform.localRotation = idle; } ((Component)this).transform.localPosition = -(((Component)this).transform.localRotation * grip); } } } public struct CustomItemsClientMessage : NetworkMessage { public byte[] Data; } public struct CustomItemsServerMessage : NetworkMessage { public byte[] Data; } } namespace RogueGolf.CustomItems.Assets { internal sealed class ItemAssets : IDisposable { private readonly Dictionary templates = new Dictionary(); private readonly Dictionary icons = new Dictionary(); private readonly List owned = new List(); private readonly Dictionary materials = new Dictionary(); private PhysicsMaterial physics; private Material FieldPanels { get { //IL_0022: 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_0032: 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_0041: Expected O, but got Unknown //IL_0196: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) if (materials.TryGetValue("field panels", out var value)) { return value; } Texture2D val = new Texture2D(256, 256, (TextureFormat)4, false) { name = "CustomItems cyan mosaic", wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)1 }; Color32[] array = (Color32[])(object)new Color32[65536]; for (int i = 0; i < 256; i++) { for (int j = 0; j < 256; j++) { int num = j / 32; int num2 = i / 32; float num3 = (float)((uint)((num * 73856093) ^ (num2 * 19349663) ^ 0x4F9FFB7) % 997u) / 996f; Color val2 = Color.Lerp(new Color(0.52f, 0.59f, 0.63f), new Color(0.66f, 0.85f, 0.96f), num3); if (j % 32 < 2 || i % 32 < 2) { ((Color)(ref val2))..ctor(0.2f, 0.78f, 1f, 0.28f); } else { float num4 = 1f + 0.06f * (1f - (float)(j % 32 + i % 32) / 62f); val2 *= num4; val2.a = 0.76f; } array[i * 256 + j] = Color32.op_Implicit(val2); } } val.SetPixels32(array); val.Apply(false, true); owned.Add((Object)(object)val); Material obj = Material("field panels", new Color(1f, 1f, 1f, 0.3f), transparent: true); obj.mainTexture = (Texture)(object)val; obj.renderQueue = 3001; return obj; } } internal PhysicsMaterial BarrierPhysics { get { //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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown if ((Object)(object)physics == (Object)null) { physics = new PhysicsMaterial("CustomItems energy bounce") { bounciness = 0.75f, dynamicFriction = 0.1f, staticFriction = 0.1f, bounceCombine = (PhysicsMaterialCombine)3 }; owned.Add((Object)(object)physics); } return physics; } } private Material Dark => Material("graphite", new Color(0.055f, 0.085f, 0.13f)); private Material Light => Material("ivory", new Color(0.95f, 0.95f, 0.88f)); private Material Green => Material("mint", new Color(0.32f, 0.77f, 0.16f)); private Material Orange => Material("amber", new Color(1f, 0.7f, 0.08f)); private Material Energy => Material("core", new Color(0.2f, 0.9f, 1f)); private Material Silver => Material("silver", new Color(0.72f, 0.8f, 0.85f)); private Material Blue => Material("cobalt", new Color(0.12f, 0.36f, 0.78f)); private Material Red => Material("coral", new Color(0.94f, 0.23f, 0.22f)); private Material Rubber => Material("rubber", new Color(0.14f, 0.18f, 0.23f)); internal static float DomeHeight(float radius) { return Mathf.Max(7f, radius * 0.65f); } private Mesh FieldDome(float radius, float height, bool textured) { //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown //IL_00a9: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[1690]; Vector3[] array2 = (Vector3[])(object)new Vector3[array.Length]; Vector2[] array3 = (Vector2[])(object)new Vector2[array.Length]; List list = new List(); for (int i = 0; i <= 25; i++) { for (int j = 0; j <= 64; j++) { float num = (float)j * (float)Math.PI * 2f / 64f; float num2 = (float)Mathf.Max(0, i - 1) * (float)Math.PI / 48f; float num3 = Mathf.Cos(num2); float num4 = Mathf.Sin(num2); int num5 = i * 65 + j; array[num5] = new Vector3(Mathf.Cos(num) * radius * num3, (i == 0) ? (-4f) : (height * num4), Mathf.Sin(num) * radius * num3); Vector3 val = new Vector3(Mathf.Cos(num) * num3 / radius, num4 / height, Mathf.Sin(num) * num3 / radius); array2[num5] = ((Vector3)(ref val)).normalized; array3[num5] = new Vector2((float)j / 64f * 2f * (float)Math.PI * radius / 6.4f, (i == 0) ? (-0.625f) : (num2 * radius / 6.4f)); if (i <= 24 && j < 64) { int num6 = num5 + 65; list.Add(num5); list.Add(num6); list.Add(num5 + 1); if (i < 24) { list.Add(num5 + 1); list.Add(num6); list.Add(num6 + 1); } } } } Mesh val2 = new Mesh { name = (textured ? "CustomItems field mosaic layer" : "CustomItems field cyan layer"), vertices = array, normals = array2, uv = array3 }; val2.SetTriangles(list, 0); val2.RecalculateBounds(); return val2; } internal Mesh BarrierCollision(float radius) { //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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_0119: 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_0135: Expected O, but got Unknown float num = DomeHeight(radius); Mesh val = FieldDome(radius + 0.12f, num + 0.12f, textured: false); Mesh val2 = FieldDome(radius - 0.12f, num - 0.12f, textured: false); List list = new List(val.vertices); list.AddRange(val2.vertices); int vertexCount = val.vertexCount; List list2 = new List(val.triangles); int[] triangles = val2.triangles; for (int i = 0; i < triangles.Length; i += 3) { list2.Add(triangles[i] + vertexCount); list2.Add(triangles[i + 2] + vertexCount); list2.Add(triangles[i + 1] + vertexCount); } for (int j = 0; j < 64; j++) { list2.Add(j); list2.Add(j + 1); list2.Add(vertexCount + j); list2.Add(j + 1); list2.Add(vertexCount + j + 1); list2.Add(vertexCount + j); } Mesh val3 = new Mesh { name = "CustomItems two-way dome shell" }; val3.SetVertices(list); val3.SetTriangles(list2, 0); val3.RecalculateBounds(); Object.Destroy((Object)(object)val); Object.Destroy((Object)(object)val2); return val3; } internal GameObject Barrier(float radius) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) float num = DomeHeight(radius); GameObject val = new GameObject("CustomItems.GreenProtector.Visual"); GreenFieldVisual greenFieldVisual = val.AddComponent(); for (int i = 0; i < 2; i++) { GameObject val2 = new GameObject((i == 0) ? "Cyan energy surface" : "Translucent mosaic panels"); val2.transform.SetParent(val.transform, false); Mesh val3 = FieldDome(radius + (float)i * 0.015f, num + (float)i * 0.015f, i == 1); val2.AddComponent().sharedMesh = val3; val2.AddComponent().Mesh = val3; MeshRenderer val4 = val2.AddComponent(); ((Renderer)val4).sharedMaterial = ((i == 0) ? Material("field cyan", new Color(0.12f, 0.65f, 1f, 0.12f), transparent: true) : FieldPanels); ((Renderer)val4).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val4).receiveShadows = false; greenFieldVisual.Add((Renderer)(object)val4); } Material material = Material("field edge", new Color(0.22f, 0.85f, 1f, 0.65f), transparent: true); GameObject val5 = Ring(val, "perimeter", radius, material); greenFieldVisual.Add(val5.GetComponent()); for (int j = 0; j < 8; j++) { LineRenderer val6 = new GameObject("energy seam").AddComponent(); ((Component)val6).transform.SetParent(val.transform, false); val6.useWorldSpace = false; ((Renderer)val6).sharedMaterial = Material("field seam", new Color(0.28f, 0.8f, 1f, 0.25f), transparent: true); val6.positionCount = 25; float startWidth = (val6.endWidth = 0.015f); val6.startWidth = startWidth; for (int k = 0; k <= 24; k++) { float num3 = (float)k * (float)Math.PI / 48f; val6.SetPosition(k, new Vector3(Mathf.Cos((float)j * (float)Math.PI / 4f) * radius * Mathf.Cos(num3), num * Mathf.Sin(num3), Mathf.Sin((float)j * (float)Math.PI / 4f) * radius * Mathf.Cos(num3))); } greenFieldVisual.Add((Renderer)(object)val6); } GameObject obj = Create("green_protector"); obj.transform.SetParent(val.transform, false); obj.transform.localPosition = new Vector3(radius + 0.5f, 0.2f, 0f); return val; } internal void TintBarrier(GameObject go, float opacity, float pulse) { GreenFieldVisual component = go.GetComponent(); if ((Object)(object)component != (Object)null) { component.Apply(opacity, pulse); } } private Material Material(string name, Color color, bool transparent = false) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) if (materials.TryGetValue(name, out var value)) { return value; } Material val = null; ItemData val2 = default(ItemData); if (!transparent && (Object)(object)GameManager.AllItems != (Object)null && GameManager.AllItems.TryGetItemData((ItemType)9, ref val2) && (Object)(object)val2.Prefab != (Object)null) { Renderer componentInChildren = val2.Prefab.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { val = componentInChildren.sharedMaterial; } } Shader val3 = Shader.Find("Custom/ToonShader") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color"); value = (((Object)(object)val != (Object)null) ? new Material(val) : new Material(transparent ? Shader.Find("Sprites/Default") : val3)); ((Object)value).name = "CustomItems." + name; value.color = color; if (!transparent) { if (value.HasProperty("_MainTex")) { value.SetTexture("_MainTex", (Texture)(object)Texture2D.whiteTexture); } if (value.HasProperty("_EmissiveTex")) { value.SetTexture("_EmissiveTex", (Texture)(object)Texture2D.blackTexture); } if (value.HasProperty("_TintMask")) { value.SetTexture("_TintMask", (Texture)null); } if (value.HasProperty("_NormalMap")) { value.SetTexture("_NormalMap", (Texture)null); } } if (value.HasProperty("_BaseColor")) { value.SetColor("_BaseColor", color); } if (value.HasProperty("_EmissionColor")) { value.EnableKeyword("_EMISSION"); value.SetColor("_EmissionColor", color * 0.25f); } if (transparent) { value.SetOverrideTag("RenderType", "Transparent"); value.SetInt("_SrcBlend", 5); value.SetInt("_DstBlend", 10); value.SetInt("_ZWrite", 0); value.SetFloat("_Surface", 1f); value.SetFloat("_Mode", 3f); value.EnableKeyword("_ALPHABLEND_ON"); value.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); value.renderQueue = 3000; } materials[name] = value; owned.Add((Object)(object)value); return value; } internal GameObject Template(string id) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown if (templates.TryGetValue(id, out var value)) { return value; } value = new GameObject("CustomItems." + id); Object.DontDestroyOnLoad((Object)(object)value); value.SetActive(false); switch (id) { case "leaf_blower": BuildLeaf(value); break; case "green_protector": BuildGreen(value); break; case "capture_ball": BuildCapture(value); break; case "gravity_swapper": BuildGravity(value); break; default: throw new ArgumentException("Unknown custom item asset: " + id, "id"); } CombineStatic(value); templates[id] = value; owned.Add((Object)(object)value); return value; } private void CombineStatic(GameObject root) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00f0: 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_0103: Unknown result type (might be due to invalid IL or missing references) IGrouping[] array = (from f in root.GetComponentsInChildren(true) where !((Object)f).name.StartsWith("gyro", StringComparison.Ordinal) group f by ((Component)f).GetComponent().sharedMaterial).ToArray(); foreach (IGrouping grouping in array) { MeshFilter[] array2 = grouping.ToArray(); Mesh val = new Mesh { name = "CustomItems combined " + ((Object)grouping.Key).name }; val.CombineMeshes(array2.Select(delegate(MeshFilter f) { //IL_0002: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) CombineInstance result = default(CombineInstance); ((CombineInstance)(ref result)).mesh = f.sharedMesh; ((CombineInstance)(ref result)).transform = root.transform.worldToLocalMatrix * ((Component)f).transform.localToWorldMatrix; return result; }).ToArray(), true, true); MeshPart(root, "casing " + ((Object)grouping.Key).name, val, Vector3.zero, grouping.Key); MeshFilter[] array3 = array2; for (int num2 = 0; num2 < array3.Length; num2++) { Object.DestroyImmediate((Object)(object)((Component)array3[num2]).gameObject); } } } internal GameObject Create(string id) { GameObject obj = Object.Instantiate(Template(id)); ((Object)obj).name = "CustomItems." + id; obj.SetActive(true); return obj; } private GameObject Ring(GameObject root, string name, float radius, Material material) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(root.transform, false); LineRenderer val2 = val.AddComponent(); val2.useWorldSpace = false; val2.loop = true; ((Renderer)val2).sharedMaterial = material; float startWidth = (val2.endWidth = 0.025f); val2.startWidth = startWidth; val2.positionCount = 48; for (int i = 0; i < 48; i++) { val2.SetPosition(i, new Vector3(Mathf.Cos((float)i * (float)Math.PI / 24f) * radius, 0f, Mathf.Sin((float)i * (float)Math.PI / 24f) * radius)); } return val; } internal GameObject Rings(string name, Color color, float radius) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0011: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); Ring(val, "wave", radius, Material(name, color, transparent: true)); return val; } internal void Animate(GameObject model, bool occupied, bool blowing) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0107: Unknown result type (might be due to invalid IL or missing references) Transform val = model.transform.Find("occupied"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(occupied); val.localRotation = Quaternion.Euler(Time.time * 75f, 0f, 45f); val.localScale = Vector3.one * (1f + 0.15f * Mathf.Sin(Time.time * 12f)); } Transform val2 = model.transform.Find("air"); if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(blowing); val2.localRotation = Quaternion.Euler(0f, 0f, Time.time * 100f); } for (int i = 0; i < 3; i++) { Transform val3 = model.transform.Find("gyro" + i); if ((Object)(object)val3 != (Object)null) { val3.localRotation = Quaternion.Euler((float)(i * 60) + Time.time * (float)(20 + i * 10), Time.time * 15f, (float)(i * 30)); } } } internal Sprite Icon(string id) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (icons.TryGetValue(id, out var value)) { return value; } Texture2D val = ItemIconRenderer.Render(Template(id), id); value = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 128f); icons[id] = value; owned.Add((Object)(object)value); owned.Add((Object)(object)val); return value; } internal void Pulse(Vector3 position, Color color) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Rings("Capture pulse", color, 0.6f); obj.transform.position = position; obj.AddComponent(); Object.Destroy((Object)(object)obj, 0.6f); } public void Dispose() { foreach (Object item in owned) { if (item != (Object)null) { Object.Destroy(item); } } owned.Clear(); templates.Clear(); icons.Clear(); materials.Clear(); } private GameObject MeshPart(GameObject root, string name, Mesh mesh, Vector3 position, Material material, Vector3 rotation = default(Vector3)) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0031: 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_0039: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown owned.Add((Object)(object)mesh); GameObject val = new GameObject(name); val.transform.SetParent(root.transform, false); val.transform.localPosition = position; val.transform.localRotation = Quaternion.Euler(rotation); val.AddComponent().sharedMesh = mesh; MeshRenderer obj = val.AddComponent(); ((Renderer)obj).sharedMaterial = material; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; return val; } private GameObject Box(GameObject root, string name, Vector3 p, Vector3 size, Material mat, Vector3 rotation = default(Vector3)) { //IL_0003: 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_0012: Unknown result type (might be due to invalid IL or missing references) return MeshPart(root, name, ItemMeshes.Box(size, 0.025f), p, mat, rotation); } private GameObject Rounded(GameObject root, string name, Vector3 p, Vector3 size, float radius, Material mat) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) return MeshPart(root, name, ItemMeshes.RoundedBox(size, radius), p, mat); } private GameObject Disc(GameObject root, string name, Vector3 p, float radius, float height, Material mat, Vector3 rotation = default(Vector3)) { //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_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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a9: 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) return MeshPart(root, name, ItemMeshes.Lathe((Vector2[])(object)new Vector2[6] { new Vector2(0f, (0f - height) / 2f), new Vector2(radius * 0.9f, (0f - height) / 2f), new Vector2(radius, (0f - height) * 0.3f), new Vector2(radius, height * 0.3f), new Vector2(radius * 0.9f, height / 2f), new Vector2(0f, height / 2f) }), p, mat, rotation); } private GameObject Orb(GameObject root, string name, Vector3 p, float radius, Material mat) { //IL_000e: 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_0019: Unknown result type (might be due to invalid IL or missing references) return MeshPart(root, name, ItemMeshes.Sphere(radius), p, mat); } private GameObject Hoop(GameObject root, string name, Vector3 p, float radius, float thickness, Material mat, Vector3 rotation = default(Vector3)) { //IL_0010: 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) return MeshPart(root, name, ItemMeshes.Torus(radius, thickness), p, mat, rotation); } private void Bolt(GameObject root, Vector3 p, Vector3 rotation = default(Vector3)) { //IL_0007: 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_0026: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) Disc(root, "hex fastener", p, 0.016f, 0.012f, Silver, rotation); Box(root, "fastener slot", p + Quaternion.Euler(rotation) * Vector3.up * 0.007f, new Vector3(0.016f, 0.003f, 0.004f), Rubber, rotation); } private void BuildLeaf(GameObject root) { //IL_0016: 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_0056: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00bb: 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_00e5: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_04fc: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Expected O, but got Unknown //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_0572: Unknown result type (might be due to invalid IL or missing references) //IL_05b0: Unknown result type (might be due to invalid IL or missing references) //IL_0600: Unknown result type (might be due to invalid IL or missing references) //IL_062c: Unknown result type (might be due to invalid IL or missing references) Rounded(root, "yellow oblong motor casing", new Vector3(0f, 0.015f, 0.13f), new Vector3(0.36f, 0.28f, 0.46f), 0.095f, Orange); Box(root, "cobalt lower chassis", new Vector3(0f, -0.14f, 0.1f), new Vector3(0.31f, 0.085f, 0.3f), Blue); Box(root, "handle", new Vector3(0f, 0.245f, 0.06f), new Vector3(0.25f, 0.065f, 0.08f), Rubber); for (int i = -1; i <= 1; i += 2) { Box(root, "handle bracket", new Vector3((float)i * 0.095f, 0.18f, 0.06f), new Vector3(0.06f, 0.14f, 0.07f), Blue); } Box(root, "trigger", new Vector3(0f, 0.19f, 0.08f), new Vector3(0.055f, 0.04f, 0.07f), Red); Disc(root, "intake collar", new Vector3(0f, 0f, -0.115f), 0.15f, 0.045f, Blue, new Vector3(90f, 0f, 0f)); Disc(root, "intake grille backing", new Vector3(0f, 0f, -0.141f), 0.125f, 0.018f, Rubber, new Vector3(90f, 0f, 0f)); for (int j = -2; j <= 2; j++) { Box(root, "intake grille bar", new Vector3((float)j * 0.045f, 0f, -0.155f), new Vector3(0.017f, 0.2f - (float)Mathf.Abs(j) * 0.025f, 0.012f), Silver); } MeshPart(root, "tapered barrel", ItemMeshes.Lathe((Vector2[])(object)new Vector2[7] { new Vector2(0f, -0.22f), new Vector2(0.095f, -0.22f), new Vector2(0.068f, 0.17f), new Vector2(0.075f, 0.22f), new Vector2(0.052f, 0.22f), new Vector2(0.049f, 0.12f), new Vector2(0f, 0.12f) }), new Vector3(0f, -0.045f, 0.52f), Rubber, new Vector3(90f, 0f, 0f)); Hoop(root, "barrel collar", new Vector3(0f, -0.045f, 0.37f), 0.086f, 0.015f, Silver, new Vector3(90f, 0f, 0f)); Hoop(root, "muzzle lip", new Vector3(0f, -0.045f, 0.743f), 0.064f, 0.012f, Blue, new Vector3(90f, 0f, 0f)); Disc(root, "dark muzzle interior", new Vector3(0f, -0.045f, 0.707f), 0.046f, 0.01f, Dark, new Vector3(90f, 0f, 0f)); for (int k = -1; k <= 1; k += 2) { Box(root, "side badge", new Vector3((float)k * 0.181f, 0.015f, 0.1f), new Vector3(0.009f, 0.1f, 0.13f), Light); Box(root, "air arrow", new Vector3((float)k * 0.188f, 0.015f, 0.1f), new Vector3(0.01f, 0.024f, 0.07f), Blue); Box(root, "air arrow head", new Vector3((float)k * 0.188f, 0.015f, 0.142f), new Vector3(0.011f, 0.039f, 0.039f), Blue, new Vector3(45f, 0f, 0f)); Bolt(root, new Vector3((float)k * 0.175f, -0.055f, 0.23f), new Vector3(0f, 0f, (float)(k * -90))); } GameObject val = new GameObject("air"); val.transform.SetParent(root.transform, false); val.transform.localPosition = new Vector3(0f, -0.045f, 0.79f); for (int l = 0; l < 7; l++) { LineRenderer obj = new GameObject("air streak").AddComponent(); ((Component)obj).transform.SetParent(val.transform, false); obj.useWorldSpace = false; ((Renderer)obj).sharedMaterial = Material("air", new Color(0.8f, 0.95f, 1f, 0.3f), transparent: true); obj.positionCount = 2; obj.startWidth = 0.02f; obj.endWidth = 0.005f; obj.SetPosition(0, new Vector3(Mathf.Cos((float)l) * 0.08f, Mathf.Sin((float)l) * 0.08f, 0f)); obj.SetPosition(1, new Vector3(Mathf.Cos((float)l) * 0.5f, Mathf.Sin((float)l) * 0.5f, 2f)); } val.SetActive(false); } private void BuildGreen(GameObject root) { //IL_0016: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_00a7: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0221: 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_0244: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Unknown result type (might be due to invalid IL or missing references) Disc(root, "rubber foot", new Vector3(0f, -0.055f, 0f), 0.235f, 0.055f, Rubber); Disc(root, "snowglobe pedestal", new Vector3(0f, -0.01f, 0f), 0.25f, 0.07f, Light); Hoop(root, "blue glass retaining rim", new Vector3(0f, 0.035f, 0f), 0.24f, 0.014f, Blue); Material material = Material("miniature earth", new Color(0.5f, 0.29f, 0.12f)); MeshPart(root, "raised earth mound", ItemMeshes.Lathe((Vector2[])(object)new Vector2[5] { new Vector2(0f, 0.02f), new Vector2(0.185f, 0.02f), new Vector2(0.175f, 0.05f), new Vector2(0.15f, 0.078f), new Vector2(0f, 0.078f) }), Vector3.zero, material); Disc(root, "putting green", new Vector3(0f, 0.087f, 0f), 0.15f, 0.024f, Green); Hoop(root, "fringe", new Vector3(0f, 0.086f, 0f), 0.15f, 0.012f, Material("green fringe", new Color(0.17f, 0.5f, 0.09f))); Disc(root, "miniature cup", new Vector3(0f, 0.101f, 0f), 0.014f, 0.004f, Dark); Disc(root, "white pin", new Vector3(0f, 0.164f, 0f), 0.004f, 0.128f, Light); MeshPart(root, "red pin pennant", ItemMeshes.Pennant(0.067f, 0.045f), new Vector3(0f, 0.208f, 0f), Red, new Vector3(0f, 10f, 0f)); Box(root, "white flag stripe", new Vector3(0.012f, 0.208f, 0.002f), new Vector3(0.015f, 0.025f, 0.004f), Light, new Vector3(0f, 10f, 0f)); Material val = Material("snowglobe glass", new Color(0.35f, 0.78f, 1f, 0.16f), transparent: true); val.SetInt("_Cull", 2); MeshPart(root, "clear blue dome", ItemMeshes.SpherePatch(0.237f, 0f, 90f, 0f, 360f, 64, 24), new Vector3(0f, 0.037f, 0f), val); Material val2 = Material("glass reflection", new Color(0.85f, 0.97f, 1f, 0.48f), transparent: true); val2.SetInt("_Cull", 2); MeshPart(root, "glass reflection streak", ItemMeshes.SpherePatch(0.239f, 25f, 68f, 68f, 73f, 4), new Vector3(0f, 0.037f, 0f), val2); Box(root, "front status bezel", new Vector3(0f, -0.014f, 0.249f), new Vector3(0.14f, 0.04f, 0.017f), Rubber); for (int i = -1; i <= 1; i++) { Box(root, "status lamp", new Vector3((float)i * 0.036f, -0.012f, 0.262f), new Vector3(0.02f, 0.02f, 0.008f), (i == 0) ? Energy : Blue); } } private void BuildCapture(GameObject root) { //IL_0015: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_00ac: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: 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_021a: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_025f: 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) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) MeshPart(root, "inner shell", ItemMeshes.Sphere(0.176f, 24, 12), Vector3.zero, Rubber); for (int i = 0; i < 4; i++) { MeshPart(root, "red upper panel", ItemMeshes.SpherePatch(0.182f, 2f, 90f, i * 90 + 1, i * 90 + 89, 16), Vector3.zero, Red); MeshPart(root, "white lower panel", ItemMeshes.SpherePatch(0.182f, -90f, -2f, i * 90 + 1, i * 90 + 89, 16), Vector3.zero, Light); } Hoop(root, "locking seam", Vector3.zero, 0.177f, 0.012f, Rubber); Hoop(root, "locking band", Vector3.zero, 0.184f, 0.006f, Silver); Disc(root, "top mechanical cap", new Vector3(0f, 0.177f, 0f), 0.057f, 0.035f, Silver); Disc(root, "cap button", new Vector3(0f, 0.199f, 0f), 0.033f, 0.014f, Red); Disc(root, "front lock bezel", new Vector3(0f, 0f, 0.178f), 0.07f, 0.038f, Light, new Vector3(90f, 0f, 0f)); Disc(root, "lock dark recess", new Vector3(0f, 0f, 0.204f), 0.05f, 0.012f, Rubber, new Vector3(90f, 0f, 0f)); Disc(root, "occupiedCore", new Vector3(0f, 0f, 0.217f), 0.032f, 0.014f, Energy, new Vector3(90f, 0f, 0f)); for (int j = -1; j <= 1; j += 2) { Box(root, "lock latch", new Vector3((float)j * 0.065f, 0f, 0.183f), new Vector3(0.028f, 0.075f, 0.032f), Silver); } Ring(root, "occupied", 0.24f, Energy).SetActive(false); } private void BuildGravity(GameObject root) { //IL_0016: 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_0056: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019e: 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_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) Rounded(root, "remote grip", new Vector3(0f, -0.215f, 0f), new Vector3(0.16f, 0.27f, 0.11f), 0.027f, Red); Box(root, "grip inset", new Vector3(0f, -0.25f, 0.059f), new Vector3(0.105f, 0.13f, 0.016f), Rubber); for (int i = 0; i < 3; i++) { Box(root, "grip rib", new Vector3(0f, -0.295f + (float)i * 0.04f, 0.07f), new Vector3(0.112f, 0.012f, 0.02f), Silver); } Rounded(root, "instrument housing", new Vector3(0f, -0.115f, 0f), new Vector3(0.25f, 0.12f, 0.15f), 0.027f, Orange); Box(root, "gauge bezel", new Vector3(0f, -0.11f, 0.081f), new Vector3(0.18f, 0.083f, 0.02f), Rubber); Box(root, "gauge screen", new Vector3(0f, -0.11f, 0.094f), new Vector3(0.146f, 0.055f, 0.008f), Light); Box(root, "gauge needle", new Vector3(0f, -0.11f, 0.101f), new Vector3(0.055f, 0.012f, 0.008f), Red, new Vector3(0f, 0f, 35f)); Orb(root, "energy core", new Vector3(0f, 0.04f, 0f), 0.074f, Energy); for (int j = 0; j < 3; j++) { Hoop(root, "gyro" + j, new Vector3(0f, 0.04f, 0f), 0.145f + (float)j * 0.022f, 0.013f, (j == 1) ? Red : Silver, new Vector3((float)(j * 60), 0f, (float)(j * 30))); } for (int k = -1; k <= 1; k += 2) { Box(root, "yoke arm", new Vector3((float)k * 0.205f, -0.025f, 0f), new Vector3(0.055f, 0.24f, 0.08f), Orange); Disc(root, "pivot", new Vector3((float)k * 0.211f, 0.055f, 0f), 0.032f, 0.03f, Rubber, new Vector3(0f, 0f, 90f)); Bolt(root, new Vector3((float)k * 0.231f, 0.055f, 0f), new Vector3(0f, 0f, (float)(k * -90))); } Box(root, "red activation switch", new Vector3(0.14f, -0.11f, 0.055f), new Vector3(0.04f, 0.04f, 0.03f), Red); } } internal sealed class GreenFieldVisual : MonoBehaviour { private readonly List renderers = new List(); private readonly List colors = new List(); private readonly MaterialPropertyBlock block = new MaterialPropertyBlock(); private static readonly int ColorId = Shader.PropertyToID("_Color"); internal void Add(Renderer renderer) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) renderers.Add(renderer); colors.Add(renderer.sharedMaterial.color); } internal void Apply(float opacity, float pulse) { //IL_000e: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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) for (int i = 0; i < renderers.Count; i++) { Color val = Color.Lerp(colors[i], new Color(0.65f, 0.94f, 1f, colors[i].a), pulse * 0.6f); val.a = colors[i].a * opacity * (1f + pulse * 1.25f); block.SetColor(ColorId, val); renderers[i].SetPropertyBlock(block); } } } internal sealed class OwnedMesh : MonoBehaviour { internal Mesh Mesh; private void OnDestroy() { if ((Object)(object)Mesh != (Object)null) { Object.Destroy((Object)(object)Mesh); } } } internal sealed class PulseVisual : MonoBehaviour { private void Update() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)this).transform; transform.localScale += Vector3.one * Time.deltaTime * 4f; } } internal static class ItemIconRenderer { private const int Size = 128; internal static Texture2D Render(GameObject model, string id) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_009e: 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_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_00b8: 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_00bf: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: 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_0202: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_07cc: Unknown result type (might be due to invalid IL or missing references) //IL_07d1: Unknown result type (might be due to invalid IL or missing references) //IL_07e7: Unknown result type (might be due to invalid IL or missing references) //IL_07ee: Unknown result type (might be due to invalid IL or missing references) //IL_07f6: Unknown result type (might be due to invalid IL or missing references) //IL_07fd: Expected O, but got Unknown //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Unknown result type (might be due to invalid IL or missing references) //IL_0782: Unknown result type (might be due to invalid IL or missing references) //IL_0787: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_0520: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_0564: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Unknown result type (might be due to invalid IL or missing references) //IL_0584: Unknown result type (might be due to invalid IL or missing references) //IL_0586: Unknown result type (might be due to invalid IL or missing references) //IL_059d: Unknown result type (might be due to invalid IL or missing references) //IL_05a7: Unknown result type (might be due to invalid IL or missing references) //IL_05b1: Unknown result type (might be due to invalid IL or missing references) //IL_05bb: Unknown result type (might be due to invalid IL or missing references) //IL_05c7: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Unknown result type (might be due to invalid IL or missing references) //IL_05f5: Unknown result type (might be due to invalid IL or missing references) //IL_05f7: Unknown result type (might be due to invalid IL or missing references) //IL_05fe: Unknown result type (might be due to invalid IL or missing references) //IL_060a: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_0621: Unknown result type (might be due to invalid IL or missing references) //IL_0629: Unknown result type (might be due to invalid IL or missing references) //IL_0630: Unknown result type (might be due to invalid IL or missing references) //IL_063d: Unknown result type (might be due to invalid IL or missing references) //IL_064a: Unknown result type (might be due to invalid IL or missing references) //IL_0651: Unknown result type (might be due to invalid IL or missing references) //IL_0659: Unknown result type (might be due to invalid IL or missing references) //IL_0660: Unknown result type (might be due to invalid IL or missing references) //IL_066d: Unknown result type (might be due to invalid IL or missing references) //IL_067a: Unknown result type (might be due to invalid IL or missing references) //IL_0681: Unknown result type (might be due to invalid IL or missing references) //IL_0689: Unknown result type (might be due to invalid IL or missing references) //IL_0690: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Unknown result type (might be due to invalid IL or missing references) //IL_06ac: Unknown result type (might be due to invalid IL or missing references) //IL_06b1: Unknown result type (might be due to invalid IL or missing references) //IL_05e0: Unknown result type (might be due to invalid IL or missing references) //IL_05e2: Unknown result type (might be due to invalid IL or missing references) float num = id switch { "capture_ball" => 20, "green_protector" => 35, "leaf_blower" => 65, _ => 25, }; Quaternion val = Quaternion.Euler(17f, num, 0f); MeshFilter[] componentsInChildren = model.GetComponentsInChildren(true); Vector3 val2 = Vector3.one * float.MaxValue; Vector3 val3 = Vector3.one * float.MinValue; MeshFilter[] array = componentsInChildren; foreach (MeshFilter val4 in array) { Vector3[] vertices = val4.sharedMesh.vertices; foreach (Vector3 val5 in vertices) { Vector3 val6 = val * model.transform.InverseTransformPoint(((Component)val4).transform.TransformPoint(val5)); val2 = Vector3.Min(val2, val6); val3 = Vector3.Max(val3, val6); } } Vector3 val7 = (val2 + val3) * 0.5f; float num2 = Mathf.Min(110f / (val3.x - val2.x), 110f / (val3.y - val2.y)); Color[] array2 = (Color[])(object)new Color[16384]; float[] array3 = new float[array2.Length]; for (int k = 0; k < array3.Length; k++) { array3[k] = float.MinValue; } Vector3 val8 = new Vector3(-0.4f, 0.65f, 0.7f); Vector3 normalized = ((Vector3)(ref val8)).normalized; Color val14 = default(Color); foreach (MeshFilter item in componentsInChildren.OrderBy((MeshFilter f) => (((Component)f).GetComponent().sharedMaterial.color.a < 0.999f) ? 1 : 0)) { Vector3[] vertices2 = item.sharedMesh.vertices; Vector3[] normals = item.sharedMesh.normals; int[] triangles = item.sharedMesh.triangles; Color color = ((Component)item).GetComponent().sharedMaterial.color; Matrix4x4 val9 = model.transform.worldToLocalMatrix * ((Component)item).transform.localToWorldMatrix; val9 = ((Matrix4x4)(ref val9)).inverse; Matrix4x4 transpose = ((Matrix4x4)(ref val9)).transpose; for (int num3 = 0; num3 < vertices2.Length; num3++) { Vector3 val10 = val * model.transform.InverseTransformPoint(((Component)item).transform.TransformPoint(vertices2[num3])); vertices2[num3] = new Vector3((val10.x - val7.x) * num2 + 64f, (val10.y - val7.y) * num2 + 64f, val10.z); int num4 = num3; val8 = val * ((Matrix4x4)(ref transpose)).MultiplyVector(normals[num3]); normals[num4] = ((Vector3)(ref val8)).normalized; } for (int num5 = 0; num5 < triangles.Length; num5 += 3) { Vector3 val11 = vertices2[triangles[num5]]; Vector3 val12 = vertices2[triangles[num5 + 1]]; Vector3 val13 = vertices2[triangles[num5 + 2]]; float num6 = (val12.y - val13.y) * (val11.x - val13.x) + (val13.x - val12.x) * (val11.y - val13.y); if (num6 <= 1E-05f) { continue; } int num7 = Mathf.Max(0, Mathf.FloorToInt(Mathf.Min(val11.x, Mathf.Min(val12.x, val13.x)))); int num8 = Mathf.Min(127, Mathf.CeilToInt(Mathf.Max(val11.x, Mathf.Max(val12.x, val13.x)))); int num9 = Mathf.Max(0, Mathf.FloorToInt(Mathf.Min(val11.y, Mathf.Min(val12.y, val13.y)))); int num10 = Mathf.Min(127, Mathf.CeilToInt(Mathf.Max(val11.y, Mathf.Max(val12.y, val13.y)))); for (int num11 = num9; num11 <= num10; num11++) { for (int num12 = num7; num12 <= num8; num12++) { float num13 = ((val12.y - val13.y) * ((float)num12 + 0.5f - val13.x) + (val13.x - val12.x) * ((float)num11 + 0.5f - val13.y)) / num6; float num14 = ((val13.y - val11.y) * ((float)num12 + 0.5f - val13.x) + (val11.x - val13.x) * ((float)num11 + 0.5f - val13.y)) / num6; float num15 = 1f - num13 - num14; if (num13 < 0f || num14 < 0f || num15 < 0f) { continue; } float num16 = num13 * val11.z + num14 * val12.z + num15 * val13.z; int num17 = num11 * 128 + num12; if (!(num16 <= array3[num17])) { val8 = normals[triangles[num5]] * num13 + normals[triangles[num5 + 1]] * num14 + normals[triangles[num5 + 2]] * num15; Vector3 normalized2 = ((Vector3)(ref val8)).normalized; float num18 = 0.62f + 0.38f * Mathf.SmoothStep(0f, 1f, Mathf.Max(0f, Vector3.Dot(normalized2, normalized))); ((Color)(ref val14))..ctor(color.r * num18, color.g * num18, color.b * num18, color.a); if (color.a >= 0.999f) { array3[num17] = num16; array2[num17] = val14; } else { Color val15 = array2[num17]; float num19 = color.a + val15.a * (1f - color.a); array2[num17] = new Color((val14.r * color.a + val15.r * val15.a * (1f - color.a)) / num19, (val14.g * color.a + val15.g * val15.a * (1f - color.a)) / num19, (val14.b * color.a + val15.b * val15.a * (1f - color.a)) / num19, num19); } } } } } } Color[] array4 = (Color[])array2.Clone(); for (int num20 = 1; num20 < 127; num20++) { for (int num21 = 1; num21 < 127; num21++) { int num22 = num20 * 128 + num21; if (array2[num22].a > 0f) { continue; } for (int num23 = -1; num23 <= 1; num23++) { for (int num24 = -1; num24 <= 1; num24++) { if (array2[num22 + num23 * 128 + num24].a > 0f) { array4[num22] = new Color(0.94f, 0.97f, 1f, 0.9f); } } } } } Texture2D val16 = new Texture2D(128, 128, (TextureFormat)4, false) { name = "CustomItems." + id + ".icon", filterMode = (FilterMode)1 }; val16.SetPixels(array4); val16.Apply(); return val16; } } internal static class ItemMeshes { private sealed class Builder { private readonly List vertices = new List(); private readonly List triangles = new List(); private readonly List normals = new List(); internal void Face(params Vector3[] points) { Face(points, null); } internal void Face(Vector3[] points, Vector3[] smoothNormals) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0030: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_006c: 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_00a4: 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_0071: Unknown result type (might be due to invalid IL or missing references) int count = vertices.Count; vertices.AddRange(points); Vector3 val = Vector3.zero; for (int i = 1; i < points.Length - 1; i++) { if (!(((Vector3)(ref val)).sqrMagnitude < 1E-12f)) { break; } Vector3 val2 = Vector3.Cross(points[i] - points[0], points[i + 1] - points[0]); float magnitude = ((Vector3)(ref val2)).magnitude; val = ((magnitude > 1E-12f) ? (val2 / magnitude) : Vector3.zero); } for (int j = 0; j < points.Length; j++) { normals.Add((smoothNormals == null) ? val : smoothNormals[j]); } for (int k = 1; k < points.Length - 1; k++) { triangles.Add(count); triangles.Add(count + k); triangles.Add(count + k + 1); } } internal Mesh Finish(string name) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_004e: Expected O, but got Unknown Mesh val = new Mesh { name = name }; val.SetVertices(vertices); val.SetTriangles(triangles, 0); val.SetNormals(normals); val.RecalculateBounds(); val.uv = (Vector2[])(object)new Vector2[vertices.Count]; return val; } } internal static Mesh RoundedBox(Vector3 size, float radius) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_005b: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0151: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: 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_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) Builder builder = new Builder(); Vector3 val = size * 0.5f; radius = Mathf.Min(radius, Mathf.Min(val.x, Mathf.Min(val.y, val.z)) * 0.9f); Vector3 val2 = val - Vector3.one * radius; Vector3[] array = (Vector3[])(object)new Vector3[3] { Vector3.right, Vector3.up, Vector3.forward }; Vector3 val4 = default(Vector3); for (int i = 0; i < 3; i++) { for (int j = -1; j <= 1; j += 2) { int num = (i + 1) % 3; int num2 = (i + 2) % 3; float[] array2 = RoundedCoordinates(((Vector3)(ref val))[num], radius); float[] array3 = RoundedCoordinates(((Vector3)(ref val))[num2], radius); for (int k = 0; k < array2.Length - 1; k++) { for (int l = 0; l < array3.Length - 1; l++) { Vector3[] array4 = (Vector3[])(object)new Vector3[4]; Vector3[] array5 = (Vector3[])(object)new Vector3[4]; int[] array6 = new int[4] { k, k + 1, k + 1, k }; int[] array7 = new int[4] { l, l, l + 1, l + 1 }; for (int m = 0; m < 4; m++) { Vector3 val3 = array[i] * ((Vector3)(ref val))[i] * (float)j + array[num] * array2[array6[m]] + array[num2] * array3[array7[m]]; ((Vector3)(ref val4))..ctor(Mathf.Clamp(val3.x, 0f - val2.x, val2.x), Mathf.Clamp(val3.y, 0f - val2.y, val2.y), Mathf.Clamp(val3.z, 0f - val2.z, val2.z)); int num3 = m; Vector3 val5 = val3 - val4; array5[num3] = ((Vector3)(ref val5)).normalized; array4[m] = val4 + array5[m] * radius; } if (Vector3.Dot(Vector3.Cross(array4[1] - array4[0], array4[2] - array4[0]), array5[0]) < 0f) { Array.Reverse(array4); Array.Reverse(array5); } builder.Face(array4, array5); } } } } return builder.Finish("CustomItems rounded engineered casing"); } private static float[] RoundedCoordinates(float half, float radius) { return new float[9] { 0f - half, 0f - half + radius * 0.25f, 0f - half + radius * 0.6f, 0f - half + radius, 0f, half - radius, half - radius * 0.6f, half - radius * 0.25f, half }; } internal static Mesh Box(Vector3 size, float bevel) { //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_0020: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: 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_01f1: 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) Builder builder = new Builder(); float num = size.x / 2f; float num2 = size.y / 2f; float num3 = size.z / 2f; bevel = Mathf.Min(bevel, Mathf.Min(num, Mathf.Min(num2, num3)) * 0.5f); Vector3[][] array = new Vector3[4][]; for (int i = 0; i < 4; i++) { float num4 = ((i == 0 || i == 3) ? bevel : 0f); float num5 = num - num4; float num6 = num2 - num4; float num7 = i switch { 2 => num3 - bevel, 1 => 0f - num3 + bevel, 0 => 0f - num3, _ => num3, }; float num8 = bevel * 0.6f; array[i] = (Vector3[])(object)new Vector3[8] { new Vector3(0f - num5 + num8, 0f - num6, num7), new Vector3(num5 - num8, 0f - num6, num7), new Vector3(num5, 0f - num6 + num8, num7), new Vector3(num5, num6 - num8, num7), new Vector3(num5 - num8, num6, num7), new Vector3(0f - num5 + num8, num6, num7), new Vector3(0f - num5, num6 - num8, num7), new Vector3(0f - num5, 0f - num6 + num8, num7) }; } Vector3[] array2 = (Vector3[])array[0].Clone(); Array.Reverse(array2); builder.Face(array2); builder.Face(array[3]); for (int j = 0; j < 3; j++) { for (int k = 0; k < 8; k++) { int num9 = (k + 1) % 8; builder.Face(array[j][k], array[j][num9], array[j + 1][num9], array[j + 1][k]); } } return builder.Finish("CustomItems bevel casing"); } internal static Mesh Lathe(Vector2[] profile, int sides = 32) { //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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) Builder builder = new Builder(); for (int i = 0; i < profile.Length - 1; i++) { for (int j = 0; j < sides; j++) { float num = (float)(j * 2) * (float)Math.PI / (float)sides; float num2 = (float)((j + 1) * 2) * (float)Math.PI / (float)sides; Vector2 n = ProfileNormal(profile, i, i); Vector2 n2 = ProfileNormal(profile, i + 1, i); builder.Face((Vector3[])(object)new Vector3[4] { new Vector3(Mathf.Cos(num) * profile[i].x, profile[i].y, Mathf.Sin(num) * profile[i].x), new Vector3(Mathf.Cos(num) * profile[i + 1].x, profile[i + 1].y, Mathf.Sin(num) * profile[i + 1].x), new Vector3(Mathf.Cos(num2) * profile[i + 1].x, profile[i + 1].y, Mathf.Sin(num2) * profile[i + 1].x), new Vector3(Mathf.Cos(num2) * profile[i].x, profile[i].y, Mathf.Sin(num2) * profile[i].x) }, (Vector3[])(object)new Vector3[4] { RadialNormal(n, num), RadialNormal(n2, num), RadialNormal(n2, num2), RadialNormal(n, num2) }); } } return builder.Finish("CustomItems smooth radial shell"); } private static Vector2 ProfileNormal(Vector2[] profile, int at, int segment) { //IL_0004: 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) //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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0088: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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) Vector2 val = profile[segment + 1] - profile[segment]; Vector2 val2 = new Vector2(val.y, 0f - val.x); Vector2 normalized = ((Vector2)(ref val2)).normalized; if (at == 0 || at == profile.Length - 1) { return normalized; } Vector2 val3 = profile[at] - profile[at - 1]; Vector2 val4 = profile[at + 1] - profile[at]; val2 = new Vector2(val3.y, 0f - val3.x); Vector2 normalized2 = ((Vector2)(ref val2)).normalized; val2 = new Vector2(val4.y, 0f - val4.x); Vector2 normalized3 = ((Vector2)(ref val2)).normalized; if (!(Vector2.Dot(normalized2, normalized3) > 0.55f)) { return normalized; } val2 = normalized2 + normalized3; return ((Vector2)(ref val2)).normalized; } private static Vector3 RadialNormal(Vector2 n, float angle) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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) return new Vector3(Mathf.Cos(angle) * n.x, n.y, Mathf.Sin(angle) * n.x); } internal static Mesh Sphere(float radius, int sides = 48, int bands = 24) { return SpherePatch(radius, -90f, 90f, 0f, 360f, sides, bands); } internal static Mesh SpherePatch(float radius, float bottom, float top, float start = 0f, float end = 360f, int sides = 48, int bands = 16) { //IL_00be: 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_00d0: 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_00db: Unknown result type (might be due to invalid IL or missing references) Builder builder = new Builder(); for (int i = 0; i < sides; i++) { for (int j = 0; j < bands; j++) { int[] array = new int[4] { i, i, i + 1, i + 1 }; int[] array2 = new int[4] { j, j + 1, j + 1, j }; Vector3[] array3 = (Vector3[])(object)new Vector3[4]; Vector3[] array4 = (Vector3[])(object)new Vector3[4]; for (int k = 0; k < 4; k++) { float num = Mathf.Lerp(start, end, (float)array[k] / (float)sides) * ((float)Math.PI / 180f); float num2 = Mathf.Lerp(bottom, top, (float)array2[k] / (float)bands) * ((float)Math.PI / 180f); array3[k] = new Vector3(Mathf.Cos(num) * Mathf.Cos(num2), Mathf.Sin(num2), Mathf.Sin(num) * Mathf.Cos(num2)); array4[k] = array3[k] * radius; } builder.Face(array4, array3); } } return builder.Finish("CustomItems smooth spherical surface"); } internal static Mesh Torus(float radius, float thickness, int sides = 64, int section = 12) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) Builder builder = new Builder(); for (int i = 0; i < sides; i++) { for (int j = 0; j < section; j++) { Vector3[] array = (Vector3[])(object)new Vector3[4]; Vector3[] array2 = (Vector3[])(object)new Vector3[4]; int[] array3 = new int[4] { i, i, i + 1, i + 1 }; int[] array4 = new int[4] { j, j + 1, j + 1, j }; for (int k = 0; k < 4; k++) { float num = (float)(array3[k] * 2) * (float)Math.PI / (float)sides; float num2 = (float)(array4[k] * 2) * (float)Math.PI / (float)section; float num3 = radius + Mathf.Cos(num2) * thickness; array[k] = new Vector3(Mathf.Cos(num) * num3, Mathf.Sin(num2) * thickness, Mathf.Sin(num) * num3); array2[k] = new Vector3(Mathf.Cos(num) * Mathf.Cos(num2), Mathf.Sin(num2), Mathf.Sin(num) * Mathf.Cos(num2)); } builder.Face(array, array2); } } return builder.Finish("CustomItems machined ring"); } internal static Mesh Pennant(float width, float height) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0076: 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_007e: 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_0086: 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) Builder builder = new Builder(); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, height / 2f, 0f); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(width, 0f, 0f); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(0f, (0f - height) / 2f, 0f); builder.Face(val, val2, val3); builder.Face(val3, val2, val); return builder.Finish("CustomItems miniature pin flag"); } } } namespace RogueGolf.Plugin { [BepInPlugin("technomancer.roguegolf", "RogueGolf", "1.1.5")] public sealed class RogueGolfPlugin : BaseUnityPlugin { private sealed class SettingRow { internal string Name; internal string Value; internal SettingControlKind Kind; internal Action Previous; internal Action Next; } private sealed class ContactState { internal readonly HashSet Balls; internal readonly float Bounce; internal readonly float Friction; internal volatile string Sample; internal ContactState(IEnumerable balls, float bounce, float friction) { Balls = new HashSet(balls); Bounce = bounce; Friction = friction; } } private sealed class BallShapeLease { private readonly GolfBall ball; private readonly float radius; private readonly Dictionary visuals = new Dictionary(); internal float NativeRadius => radius; internal BallShapeLease(GolfBall value) { ball = value; radius = ball.Collider.radius; RefreshVisuals(); } internal void RefreshVisuals() { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) Transform[] array = visuals.Keys.Where((Transform t) => (Object)(object)t == (Object)null).ToArray(); foreach (Transform key in array) { visuals.Remove(key); } Renderer[] componentsInChildren = ((Component)ball).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (val is MeshRenderer || val is SkinnedMeshRenderer) { Transform val2 = ((Component)val).transform; while ((Object)(object)val2.parent != (Object)(object)((Component)ball).transform && (Object)(object)val2.parent != (Object)null) { val2 = val2.parent; } if ((Object)(object)val2 != (Object)(object)((Component)ball).transform && !visuals.ContainsKey(val2)) { visuals[val2] = val2.localScale; } } } } internal void Apply(float factor) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ball == (Object)null) { return; } ball.Collider.radius = radius * factor; foreach (KeyValuePair visual in visuals) { if ((Object)(object)visual.Key != (Object)null) { visual.Key.localScale = visual.Value * factor; } } } } private struct HitContext { internal PlayerInfo Attacker; internal bool GolfSwing; } private sealed class RateLease { internal FieldInfo Field; internal object Native; internal object Relaxed; internal bool Applied; } private sealed class UiAction { internal RectTransform Rect; internal Action Run; internal ScorecardShape Shape; internal Color Normal; internal string Help; internal string HelpName; internal ScorecardShape FocusOutline; } private WorldEventController worldEvents; private WorldSpawnLocations eventLocations; private uint eventSeed; private string eventRun = ""; private int eventHole = -1; private bool eventFaulted; private ConfigEntry stormCap; private ConfigEntry burstMin; private ConfigEntry burstMax; private ConfigEntry burstIntervalMin; private ConfigEntry burstIntervalMax; private ConfigEntry eventVerbose; private ConfigEntry[] eventWeights; private CustomItemRuntime customItems; private TextMeshProUGUI cycleLabel; private CycleRing cycleRing; private readonly Dictionary conditionValues = new Dictionary(); private readonly Dictionary conditionChanged = new Dictionary(); private readonly List> conditionLabels = new List>(); private string conditionRun = ""; private const ulong DummyGuid = 18446744073709551573uL; private PlayerInfo dummy; private int dummyScene; private bool dummyHooks; private bool dummyNeedsReset; private readonly List dummyUnbind = new List(); private GolfHole dunkHole; private Vector3 dunkCenter; private float dunkRadius; private GameObject dunkVisual; private Mesh dunkMesh; private Material dunkMaterial; private readonly Dictionary dunkPrevious = new Dictionary(); private readonly List dunkRestore = new List(); private bool dunkFailed; private readonly Dictionary impactRearming = new Dictionary(); private readonly HashSet pendingPlayerImpacts = new HashSet(); private bool formula1Available; private MethodInfo formulaGravityTarget; private MethodInfo formulaSpeedTarget; private readonly SharedGravity sharedGravity = new SharedGravity(); private GravityVector gravityBaseline; private ModifierSettings modifierSettings = new ModifierSettings(1.2f, 2f, 0.5f, 0.6f, 1.5f, (IEnumerable>)null); private ModifierManager modifiers; private RunRandom modifierRandom; private EffectValues effects = EffectValues.Normal; private readonly Dictionary massLeases = new Dictionary(); private readonly Dictionary> modifierEnabled = new Dictionary>(); private readonly Dictionary> tuning = new Dictionary>(); private ConfigEntry powerFactor; private ConfigEntry heavyFactor; private ConfigEntry featherFactor; private ConfigEntry lowFactor; private ConfigEntry highFactor; private ConfigEntry traceGravity; private MethodInfo swingSpeedMethod; private string ballSample = ""; private string playerSample = ""; private int peerSceneRefreshFrame = -1; private bool resetConfirmation; private TextMeshProUGUI settingsHelp; private ConfigEntry testingKey; private bool testingOpen; private bool testingUiReady; private int testingPage; private int consoleSuppressFrame = -1; private string testingDetail = ""; private string testingMessage = ""; private string testingRangeId = ""; private readonly HashSet testingDraft = new HashSet(); private readonly IntermissionGate gate = new IntermissionGate(); private ConfigEntry stage; private ConfigEntry holdSeconds; private PrototypeStage runStage; private MethodInfo nextMethod; private bool releasing; private double releaseAt; private ConfigEntry labCommands; private double nextLabRead; private GolfBall labBlastNeighbor; private ResetSettingsSnapshot resetLiveSettings; private bool dampingTraced; private Collider[] scoringTriggers = Array.Empty(); private bool cupTraced; private readonly Dictionary cupSurfaceHeights = new Dictionary(); private readonly Dictionary shapes = new Dictionary(); private static volatile ContactState contacts = new ContactState(Array.Empty(), 1f, 1f); [ThreadStatic] private static HitContext hitContext; private ConfigEntry selectionMode; private ConfigEntry persistenceMode; private ConfigEntry skipMode; private ConfigEntry skipBehavior; private ConfigEntry bossEnabled; private ConfigEntry randomSkips; private ConfigEntry bossInterval; private ConfigEntry randomSkipWeight; private ConfigEntry randomModifierWeight; private readonly List> tierWeights = new List>(); private readonly List> phaseThresholds = new List>(); private readonly Dictionary> modifierWeights = new Dictionary>(); private ProgressionSettings progression = new ProgressionSettings((SelectionMode)0, (PersistenceMode)0, (SkipMode)0, (SkipBehavior)0, true, 4, false, 10, 100, (int[])null, (float[])null, (IEnumerable>)null); private SkipLedger skipLedger; private readonly Dictionary votePlayers = new Dictionary(); private readonly List runHistory = new List(); private RunRandom selectionRandom; private int selectionNumber; private ConfigEntry densityMode; private ConfigEntry densityFloor; private ConfigEntry densityCap; private DensitySettings density = new DensitySettings((SelectionDensityMode)0, 11, 2); private RoundSelectionState roundSelections = new RoundSelectionState(); private int[] densityPlan = Array.Empty(); private bool bossSelection; private bool summaryComplete; private uint progressionSeed; private string dismissedSummary = ""; private int summaryPage; private readonly Dictionary> rateOwners = new Dictionary>(); private double nextRateReview; public const string Id = "technomancer.roguegolf"; public const string Version = "1.1.5"; internal static RogueGolfPlugin Instance; internal readonly RunController Run = new RunController(); private Harmony harmony; private ConfigEntry enabledMode; private bool subscribed; private bool quitting; private string detailId = ""; private readonly Dictionary setupTextures = new Dictionary(StringComparer.Ordinal); private static readonly Color SetupCream = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)253, (byte)229, byte.MaxValue)); private static readonly Color SetupRow = Color32.op_Implicit(new Color32((byte)244, (byte)240, (byte)217, byte.MaxValue)); private static readonly Color SetupBorder = Color32.op_Implicit(new Color32((byte)213, (byte)213, (byte)185, byte.MaxValue)); private TextMeshProUGUI settingsHelpName; private readonly ThunderstormAdapter thunderAdapter = new ThunderstormAdapter(); private ThunderstormAdapter.Lease thunderProof; private string thunderProofRun = ""; private int thunderProofHole = -1; private int thunderProofStrikes; private double thunderProofNext; private ConfigEntry tutorialSeen; private RectTransform tutorialButton; private RectTransform tutorialQuestion; private readonly SetupArtwork[] tutorialSparkles = new SetupArtwork[3]; private float tutorialAttentionStarted = -1f; private NetworkBridge bridge; private VoteCoordinator voting; private ConfigEntry candidateCount; private ConfigEntry skipBudget; private ConfigEntry seed; private ConfigEntry voteSeconds; private ConfigEntry revealSeconds; private ConfigEntry voteChanges; private ConfigEntry earlyClose; private ConfigEntry tieRule; private long snapshotRevision; private string notice = ""; private double noticeUntil; private int lastWinnerVote; private bool networkFault; private static readonly Color Paper = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)251, (byte)224, byte.MaxValue)); private static readonly Color Ink = Color32.op_Implicit(new Color32((byte)48, (byte)58, (byte)37, byte.MaxValue)); private static readonly Color Green = Color32.op_Implicit(new Color32((byte)112, (byte)181, (byte)65, byte.MaxValue)); private static readonly Color Gold = Color32.op_Implicit(new Color32((byte)249, (byte)198, (byte)67, byte.MaxValue)); private static readonly Color Muted = Color32.op_Implicit(new Color32((byte)107, (byte)116, (byte)88, byte.MaxValue)); private GameObject uiObject; private RectTransform uiRoot; private RectTransform uiContent; private TMP_FontAsset uiFont; private TMP_FontAsset uiTitleFont; private string uiKey = ""; private int selected; private int effectPage; private int settingsPage; private int pauseTab; private int weightTab; private bool cursorOwned; private bool previousVisible; private bool uiFocus; private bool pauseMinimized; private bool setupOpen; private CursorLockMode previousCursor; private ModifierSettings hudSettings; private ModifierRegistry hudRegistry; private readonly List uiActions = new List(); private ActiveModifier[] remoteActive = Array.Empty(); private Dictionary playerShotFactors = new Dictionary(); private RunRandom worldRandom; private double nextWorldTick; private double nextPlayerScan; private double nextExplosion; private int worldHole = -1; private int explosionsThisHole; private readonly HashSet grantedPlayers = new HashSet(); private readonly Dictionary deathPositions = new Dictionary(); private readonly HashSet verifiedTrafficScenes = new HashSet(); private ItemType sharedLoadout; private MethodInfo removeItem; private MethodInfo explodeRocket; private bool creatingExplosion; private bool pendingAmmoTrim; private bool explosionRecipientOnly; private Hittable explosionSource; private Mechanic mechanics; private readonly HashSet currentIds = new HashSet(); internal EffectChannel Capabilities { get; private set; } private string GravitySampleKey { get { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) string[] obj = new string[5] { CourseManager.CurrentHoleCourseIndex.ToString(), ":", null, null, null }; Vector3 gravity = Physics.gravity; obj[2] = ((Vector3)(ref gravity)).ToString("F4"); obj[3] = ":"; obj[4] = ((EffectValues)(ref effects))[(Parameter)13].ToString(); return string.Concat(obj); } } private bool InDrivingRange => SingletonBehaviour.HasInstance; private bool RangeTesting => testingRangeId != ""; private bool EffectsPlaying { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 if ((int)Run.State != 3) { return RangeTesting; } return true; } } private string EffectRunId { get { if (!RangeTesting) { return Run.RunId; } return testingRangeId; } } private int TestHole { get { if (!RangeTesting) { return Run.HoleIndex; } return 0; } } internal string BuildFingerprint { get; private set; } = ""; private bool ViewingRangeTest { get { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 if (View != null && (int)View.State == 3) { return View.RunId.StartsWith("range-test-", StringComparison.Ordinal); } return false; } } private bool MatchSetupVisible { get { //IL_0000: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 if ((InputManager.CurrentModeMask & 0x100) != 0) { if ((int)InputManager.CurrentMode != 256) { if (setupOpen) { return uiFocus; } return false; } return true; } return false; } } private RunSnapshot View { get { NetworkBridge networkBridge = bridge; if (networkBridge == null) { return null; } return networkBridge.Replica.Current; } } private bool OverlayVisible { get { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 if (View != null) { if ((int)View.State != 6 && (int)View.State != 7 && (int)View.State != 8) { return (int)View.State == 5; } return true; } return false; } } private bool Paused { get { //IL_0008: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 if (!MatchSetupVisible && (InputManager.CurrentModeMask & 0x20) != 0) { if ((int)InputManager.CurrentMode != 32) { return uiFocus; } return true; } return false; } } private bool NativeMenuFocused { get { //IL_0000: 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) //IL_0013: Invalid comparison between Unknown and I4 //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 if ((int)InputManager.CurrentMode != 32 && (int)InputManager.CurrentMode != 256 && (int)InputManager.CurrentMode != 1024) { return (int)InputManager.CurrentMode == 512; } return true; } } private bool InputAvailable { get { //IL_000f: 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_0022: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 if (Application.isFocused && !NativeMenuFocused && (int)InputManager.CurrentMode != 64 && (int)InputManager.CurrentMode != 2048) { return (int)InputManager.CurrentMode != 128; } return false; } } private bool SummaryVisible { get { if (View != null && View.SummaryComplete && dismissedSummary != View.RunId) { return !NativeMenuFocused; } return false; } } private ModifierRegistry UiRegistry { get { //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (hudSettings != View?.ModifierSettings || hudRegistry == null) { hudSettings = (ModifierSettings)(((object)View?.ModifierSettings) ?? ((object)new ModifierSettings(1.2f, 2f, 0.5f, 0.6f, 1.5f, (IEnumerable>)null))); hudRegistry = ModifierRegistry.Create(hudSettings); } return hudRegistry; } } private IEnumerable CurrentEffects { get { ModifierManager obj = modifiers; return ((obj != null) ? obj.Active : null) ?? remoteActive; } } private void ConfigureActiveEvents() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown stormCap = ((BaseUnityPlugin)this).Config.Bind("LawOfZeus", "MaxActiveStorms", 7, new ConfigDescription("Maximum RogueGolf storms, including fading clouds. Existing vanilla item storms consume free capacity. Captured when the event starts.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 7), Array.Empty())); burstMin = ((BaseUnityPlugin)this).Config.Bind("LawOfZeus", "MinBurstSize", 1, new ConfigDescription("Whole storms per burst, not individual bolts.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 3), Array.Empty())); burstMax = ((BaseUnityPlugin)this).Config.Bind("LawOfZeus", "MaxBurstSize", 2, new ConfigDescription("Maximum whole storms per burst.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 3), Array.Empty())); burstIntervalMin = ((BaseUnityPlugin)this).Config.Bind("LawOfZeus", "MinBurstInterval", 0.8f, new ConfigDescription("Scaled seconds between bursts.", (AcceptableValueBase)(object)new AcceptableValueRange(0.4f, 10f), Array.Empty())); burstIntervalMax = ((BaseUnityPlugin)this).Config.Bind("LawOfZeus", "MaxBurstInterval", 1.5f, new ConfigDescription("Maximum scaled seconds between bursts.", (AcceptableValueBase)(object)new AcceptableValueRange(0.4f, 10f), Array.Empty())); eventVerbose = ((BaseUnityPlugin)this).Config.Bind("LawOfZeus", "VerboseSpawns", false, "Log each chosen storm center; normal logs summarize bursts only."); string[] source = new string[5] { "GreenWeight", "PlayerWeight", "BallWeight", "ItemPointWeight", "FairwayWeight" }; int[] defaults = Zeus.TargetWeights; eventWeights = source.Select((string n, int i) => ((BaseUnityPlugin)this).Config.Bind("LawOfZeus", n, defaults[i], new ConfigDescription("Relative area targeting weight. Zero excludes this category. Unavailable landmarks are omitted.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 1000), Array.Empty()))).ToArray(); Channel((EffectChannel)16384, delegate { if (AccessTools.Method(typeof(ThunderstormManager), "ServerCreateThunderstorm", new Type[3] { typeof(Vector3), typeof(PlayerInventory), typeof(ItemUseId) }, (Type[])null) == null) { throw new MissingMethodException("Vanilla thunderstorm factory"); } }); } private void TickActiveEvents() { //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Expected O, but got Unknown //IL_01c8: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || !enabledMode.Value || !EffectsPlaying || modifiers == null || !modifiers.Active.Any((ActiveModifier e) => e.Id == "law_of_zeus" && !e.Suspended && e.FirstHole <= TestHole) || bridge == null || !bridge.CanStart(out var _)) { StopActiveEvents(); } else { if (eventFaulted) { return; } try { if (worldEvents != null && (eventRun != EffectRunId || eventHole != TestHole)) { StopActiveEvents(); } if (worldEvents == null) { StopThunderProof(); eventRun = EffectRunId; eventHole = TestHole; eventLocations = new WorldSpawnLocations(); int cap = LiveSetting(stormCap); int[] weights = eventWeights.Select((ConfigEntry w) => LiveSetting(w)).ToArray(); if (weights.Sum() == 0) { throw new InvalidOperationException("At least one Zeus targeting weight must be positive."); } worldEvents = new WorldEventController(eventSeed ^ (uint)((TestHole + 1) * 7919), cap, cap, cap, 4); new LawOfZeusEvent((Func)(() => SpawnZeusStorm(weights)), (Action)delegate(int burst, int count) { if (count > 0) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[EVENT] LawOfZeus burst=" + burst + " count=" + count + " active=" + worldEvents.ActiveCount + "/" + cap)); } }, (double)LiveSetting(burstIntervalMin), (double)Math.Max(LiveSetting(burstIntervalMin), LiveSetting(burstIntervalMax)), LiveSetting(burstMin), Math.Max(LiveSetting(burstMin), LiveSetting(burstMax))).Start(worldEvents, Time.timeAsDouble); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[EVENT] LawOfZeus started cap=" + cap + " " + eventLocations.Summary)); } worldEvents.Tick(Time.timeAsDouble, true); } catch (Exception ex) { try { StopActiveEvents(); } finally { eventFaulted = true; } ((BaseUnityPlugin)this).Logger.LogError((object)("[EVENT] Disabled for this hole after failure: " + ex)); } } } private bool SpawnZeusStorm(int[] weights) { Vector3[] activeCenters = ThunderstormAdapter.ActiveCenters; if (activeCenters.Length >= worldEvents.MaxActive) { return false; } if (!eventLocations.TryScatter(worldEvents.Random, weights, Players(), activeCenters, out var point, out var category)) { return false; } bool num = worldEvents.TrySpawn("law_of_zeus", "thunderstorm", (Func)(() => (IWorldHazard)(object)thunderAdapter.Spawn(point)), Math.Max(0, activeCenters.Length - worldEvents.ActiveCount)); if (num && LiveSetting(eventVerbose)) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[EVENT] Thunderstorm target=" + category + " position=" + ((object)Unsafe.As(ref point)/*cast due to .constrained prefix*/).ToString())); } return num; } private void StopActiveEvents() { WorldEventController val = worldEvents; worldEvents = null; eventLocations = null; eventRun = ""; eventHole = -1; if (val != null) { val.Stop(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[EVENT] Stopped; schedules=0 owned=0 spawned=" + val.Spawned + " budgetRejected=" + val.Rejected)); } } private void ConfigureCustomItems() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown Harmony val = new Harmony("technomancer.roguegolf.customitems"); try { customItems = new CustomItemRuntime(((BaseUnityPlugin)this).Config, val, sharedGravity, () => bridge != null && bridge.CanStart(out var _), (int id) => bridge != null && bridge.Verified(id), () => bridge?.ClientVerified ?? false, () => ((EffectValues)(ref effects))[(Parameter)10], delegate(string s) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[CUSTOM] " + s)); }, ShowNotice); } catch (Exception ex) { try { CustomItemRuntime.Current?.Dispose(); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogError((object)("[CUSTOM] Initialization cleanup failed: " + ex2)); } val.UnpatchSelf(); customItems = null; ((BaseUnityPlugin)this).Logger.LogError((object)("[CUSTOM] Unavailable on this game build: " + ex)); } } private void TickCustomItems(bool physics = false) { if (customItems == null) { return; } try { if (physics) { customItems.FixedTick(); } else { customItems.Tick(); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[CUSTOM] Disabled after runtime failure: " + ex)); customItems.Faulted = true; customItems.Registry.Master.Value = false; try { customItems.Cleanup("runtime failure"); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogError((object)("[CUSTOM] Cleanup failure: " + ex2)); } } } private void FixedUpdate() { TickCustomItems(physics: true); } private void DrawCycles() { //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) RunSnapshot s = View; if (conditionRun != s.RunId) { conditionValues.Clear(); conditionChanged.Clear(); conditionRun = s.RunId; } float value = 1f; if ((Object)(object)GameManager.LocalPlayerId != (Object)null) { s.PlayerShotFactors.TryGetValue(GameManager.LocalPlayerId.Guid, out value); } if (value <= 0f) { value = 1f; } KeyValuePair[] array = Conditions.Rows(UiRegistry, s.ModifierSettings, (IEnumerable)s.ActiveModifiers, s.Hole, value); bool flag = s.ActiveModifiers.Any((ActiveModifier e) => !e.Suspended && e.FirstHole <= s.Hole && EffectPresentation.HasCycle(UiRegistry.Get(e.Id).Rule)); if (array.Length == 0 && !flag) { return; } KeyValuePair[] array2 = array; for (int num = 0; num < array2.Length; num++) { KeyValuePair keyValuePair = array2[num]; if (!conditionValues.TryGetValue(keyValuePair.Key, out var value2) || value2 != keyValuePair.Value) { conditionChanged[keyValuePair.Key] = Time.unscaledTime; } conditionValues[keyValuePair.Key] = keyValuePair.Value; } string[] array3 = conditionValues.Keys.Except(array.Select((KeyValuePair r) => r.Key)).ToArray(); foreach (string key in array3) { conditionValues.Remove(key); } int num2 = Math.Min(10, array.Length); Transform transform = ((Component)Shape((Transform)(object)uiContent, 20f, 145f, 282f, 45 + num2 * 22 + ((array.Length > num2) ? 22 : 0), Color32.op_Implicit(new Color32((byte)24, (byte)39, (byte)30, (byte)185)), 10f)).transform; Label(transform, 12f, 9f, 217f, 24f, "CONDITIONS", 13f, Color32.op_Implicit(new Color32((byte)215, (byte)225, (byte)199, byte.MaxValue)), bold: true); if (flag) { RectTransform val = Rect(transform, 239f, 7f, 32f, 32f); cycleRing = ((Component)val).gameObject.AddComponent(); ((Graphic)cycleRing).raycastTarget = false; cycleLabel = Label(transform, 240f, 12f, 30f, 21f, "", 12f, Color.white, bold: true); ((TMP_Text)cycleLabel).alignment = (TextAlignmentOptions)514; } for (int num3 = 0; num3 < num2; num3++) { conditionLabels.Add(new KeyValuePair(array[num3].Key, Label(transform, 12f, 40 + num3 * 22, 258f, 22f, array[num3].Value, 16f, Color.white))); } if (array.Length > num2) { Label(transform, 12f, 40 + num2 * 22, 258f, 22f, "+" + (array.Length - num2) + " conditions · Esc for details", 13f, Color32.op_Implicit(new Color32((byte)215, (byte)225, (byte)199, byte.MaxValue))); } } private void UpdateCycleDisplay() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair conditionLabel in conditionLabels) { if ((Object)(object)conditionLabel.Value != (Object)null) { float value; float num = (conditionChanged.TryGetValue(conditionLabel.Key, out value) ? (Time.unscaledTime - value) : 10f); ((Graphic)conditionLabel.Value).color = Color.Lerp(Color32.op_Implicit(new Color32(byte.MaxValue, (byte)220, (byte)105, byte.MaxValue)), Color.white, Mathf.Clamp01(num / 1.1f)); } } if (!((Object)(object)cycleLabel == (Object)null) && !((Object)(object)cycleRing == (Object)null) && View != null) { double num2 = Math.Max(0.0, View.NextCycleAt - NetworkTime.time); ((TMP_Text)cycleLabel).text = ((View.NextCycleAt <= 0.0) ? "–" : Math.Ceiling(num2).ToString()); cycleRing.Progress = Mathf.Clamp01((float)(num2 / (double)View.ModifierSettings.Interval)); } } private static bool IsDummy(PlayerInfo player) { if ((Object)(object)player != (Object)null && (Object)(object)player.PlayerId != (Object)null) { return player.PlayerId.Guid == 18446744073709551573uL; } return false; } private static bool SimulatesDummy(NetworkBehaviour value) { if (!value.isLocalPlayer) { if (NetworkServer.active) { PlayerMovement val = (PlayerMovement)(object)((value is PlayerMovement) ? value : null); if (val != null) { return IsDummy(val.PlayerInfo); } } return false; } return true; } private static IEnumerable DummyMovementAuthority(IEnumerable code) { MethodInfo getter = AccessTools.PropertyGetter(typeof(NetworkBehaviour), "isLocalPlayer"); int replacements = 0; foreach (CodeInstruction item in code) { if (CodeInstructionExtensions.Calls(item, getter)) { replacements++; item.opcode = OpCodes.Call; item.operand = AccessTools.Method(typeof(RogueGolfPlugin), "SimulatesDummy", (Type[])null, (Type[])null); } yield return item; } if (replacements == 0) { throw new InvalidOperationException("Native dummy movement authority gate changed."); } } private void ConfigureDummy() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown try { string[] array = new string[5] { "FixedUpdate", "LateUpdate", "OnCollisionEnter", "OnCollisionStay", "RemoveStatusEffect" }; foreach (string text in array) { harmony.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(PlayerMovement), text, (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(RogueGolfPlugin), "DummyMovementAuthority", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); } NativeHook(typeof(GameManager), "RegisterPlayer", null, "RegisterDummyRendering"); NativeHook(typeof(PlayerId), "OnGuidChanged", "DummyIdentityChanged"); NativeHook(typeof(CourseManager), "InformPlayerKnockedOut", "DummyKnockoutScore"); NativeHook(typeof(CourseManager), "RegisterMatchParticipant", "DummyParticipant"); NativeHook(typeof(PlayerInfo), "ExitGolfCart", "DummyExitGolfCart"); NativeHook(typeof(PlayerInfo), "CanEnterGolfCart", "DummyCanEnterGolfCart"); NativeHook(typeof(PlayerGolfer), "ServerEliminate", "DummyEliminate"); dummyHooks = true; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[DUMMY] Unavailable: " + ex.Message)); } } private static void RegisterDummyRendering(PlayerInfo playerInfo) { if (IsDummy(playerInfo) && NetworkServer.active) { ((Dictionary)AccessTools.Field(typeof(GameManager), "remotePlayerPerconnectionId").GetValue(SingletonBehaviour.Instance)).Remove(((NetworkBehaviour)playerInfo).connectionToClient.connectionId); } } private static bool DummyIdentityChanged(PlayerId __instance, ulong currentGuid, ref string ___playerNameLocal, ref string ___playerNameNoRichText) { if (currentGuid != 18446744073709551573uL) { return true; } ___playerNameLocal = (___playerNameNoRichText = "Training Golfer"); return false; } private static bool DummyKnockoutScore(PlayerMovement knockedOutPlayer, ref bool knockoutCounted) { if (!IsDummy(knockedOutPlayer.PlayerInfo)) { return true; } knockoutCounted = false; return false; } private static bool DummyParticipant(PlayerGolfer participant) { return !IsDummy(participant.PlayerInfo); } private static bool DummyExitGolfCart(PlayerInfo __instance) { return !IsDummy(__instance); } private static bool DummyCanEnterGolfCart(PlayerInfo __instance, ref bool __result) { if (!IsDummy(__instance)) { return true; } __result = false; return false; } private static bool DummyEliminate(PlayerGolfer __instance) { if (!IsDummy(__instance.PlayerInfo)) { return true; } if ((Object)(object)Instance != (Object)null) { Instance.dummyNeedsReset = true; } return false; } private void SpawnDummy() { //IL_0071: 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_0086: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) if (!dummyHooks || !CanUseTestingMenu(out var _)) { throw new InvalidOperationException("Dummy requires the private host testing context."); } if (NetworkServer.connections.Count != 1) { throw new InvalidOperationException("Training golfer currently requires a solo host session."); } if ((Object)(object)dummy != (Object)null) { ResetDummy(); return; } PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo; if ((Object)(object)localPlayerInfo == (Object)null || NetworkServer.localConnection == null) { throw new InvalidOperationException("A local host golfer is required."); } Vector3 val = ((Component)localPlayerInfo).transform.position + ((Component)localPlayerInfo).transform.forward * 5f + Vector3.up; GameObject val2 = Object.Instantiate(((NetworkManager)BNetworkManager.singleton).playerPrefab, val, ((Component)localPlayerInfo).transform.rotation); try { dummy = val2.GetComponent(); dummy.PlayerId.ServerSetGuid(18446744073709551573uL); dummy.PlayerId.Networkguid = 18446744073709551573uL; NetworkServer.Spawn(val2, (NetworkConnectionToClient)(object)NetworkServer.localConnection); foreach (PropertyInfo item in from p in typeof(PlayerCosmetics).GetProperties() where p.CanRead && p.CanWrite && p.Name.StartsWith("Network") && (p.Name.EndsWith("CosmeticKey") || p.Name == "NetworkskinColorIndex") select p) { item.SetValue(dummy.Cosmetics, item.GetValue(localPlayerInfo.Cosmetics)); } Scene activeScene = SceneManager.GetActiveScene(); dummyScene = SceneHandle.op_Implicit(((Scene)(ref activeScene)).handle); PlayerMovement movement = dummy.Movement; Hittable hittable = dummy.AsHittable; string[][] array = new string[9][] { new string[2] { "WillApplyGolfSwingHitPhysics", "OnLocalPlayerWillApplyGolfSwingHitPhysics" }, new string[2] { "WillApplySwingProjectileHitPhysics", "OnLocalPlayerWillApplySwingProjectileHitPhysics" }, new string[2] { "WillApplyDiveHitPhysics", "OnLocalPlayerWillApplyDiveHitPhysics" }, new string[2] { "WillApplyItemHitPhysics", "OnLocalPlayerWillApplyItemHitPhysics" }, new string[2] { "WillApplyRocketLauncherBackBlastHitPhysics", "OnLocalPlayerWillApplyRocketLauncherBackBlastHitPhysics" }, new string[2] { "WillApplyRocketDriverSwingPostHitSpinHitPhysics", "OnLocalPlayerWillWillApplyRocketDriverSwingPostHitSpinHitPhysics" }, new string[2] { "WillApplyReturnedBallHitPhysics", "OnLocalPlayerWillApplyReturnedBallHitPhysics" }, new string[2] { "WillApplyJumpPadPhysics", "OnLocalPlayerWillApplyJumpPadPhysics" }, new string[2] { "FrozenStateChanged", "OnLocalPlayerFrozenStateChanged" } }; foreach (string[] array2 in array) { EventInfo ev = typeof(Hittable).GetEvent(array2[0]); Delegate handler = Delegate.CreateDelegate(ev.EventHandlerType, movement, AccessTools.DeclaredMethod(typeof(PlayerMovement), array2[1], (Type[])null, (Type[])null)); ev.AddEventHandler(hittable, handler); dummyUnbind.Add(delegate { if ((Object)(object)hittable != (Object)null) { ev.RemoveEventHandler(hittable, handler); } }); } ResetDummy(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[DUMMY] Spawned native golfer netId=" + ((NetworkBehaviour)dummy).netId + " hostIdentity=" + ((NetworkConnection)NetworkServer.localConnection).identity.netId)); } catch { RemoveDummy(); if ((Object)(object)val2 != (Object)null) { Object.Destroy((Object)(object)val2); } throw; } } private unsafe void ResetDummy() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)dummy == (Object)null)) { PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo; if ((Object)(object)localPlayerInfo == (Object)null) { throw new InvalidOperationException("Host golfer unavailable."); } Vector3 val = FindDummyGround(localPlayerInfo); PlayerMovement movement = dummy.Movement; Rigidbody rigidbody = dummy.AsEntity.Rigidbody; dummy.AsHittable.NetworkfrozenState = (FrozenState)0; ((MonoBehaviour)movement).StopAllCoroutines(); AccessTools.DeclaredMethod(typeof(PlayerMovement), "CancelKnockoutImmunity", (Type[])null, (Type[])null).Invoke(movement, null); AccessTools.DeclaredMethod(typeof(PlayerMovement), "SetDivingState", (Type[])null, (Type[])null).Invoke(movement, new object[1] { (object)(DivingState)0 }); rigidbody.isKinematic = false; rigidbody.useGravity = false; rigidbody.constraints = (RigidbodyConstraints)80; AccessTools.DeclaredMethod(typeof(PlayerMovement), "SetKnockOutState", (Type[])null, (Type[])null).Invoke(movement, new object[1] { (object)(KnockoutState)0 }); movement.NetworkisVisible = true; rigidbody.position = val; rigidbody.rotation = ((Component)localPlayerInfo).transform.rotation; ((Component)dummy).transform.SetPositionAndRotation(val, rigidbody.rotation); rigidbody.linearVelocity = Vector3.zero; rigidbody.angularVelocity = Vector3.zero; movement.NetworksyncedVelocity = Vector3.zero; movement.NetworkstatusEffects = (StatusEffect)0; AccessTools.Field(typeof(PlayerMovement), "moveVector2d").SetValue(movement, Vector2.zero); AccessTools.Field(typeof(PlayerMovement), "initialPosition").SetValue(movement, val); movement.UpdateEnabledColliders(); dummy.AsGolfer.NetworkisInitialized = true; dummyNeedsReset = false; ((BaseUnityPlugin)this).Logger.LogInfo((object)("[DUMMY] Reset position=" + ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString())); } } private Vector3 FindDummyGround(PlayerInfo host) { //IL_000e: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00ce: 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_00f7: Unknown result type (might be due to invalid IL or missing references) RaycastHit val2 = default(RaycastHit); for (int i = 0; i < 16; i++) { Vector3 val = Quaternion.AngleAxis((float)(i % 8 * 45), Vector3.up) * ((Component)host).transform.forward; if (Physics.Raycast(((Component)host).transform.position + val * (float)((i < 8) ? 5 : 8) + Vector3.up * 5f, Vector3.down, ref val2, 12f, LayerMask.op_Implicit(GameManager.LayerSettings.PlayerGroundableMask), (QueryTriggerInteraction)1) && !(((RaycastHit)(ref val2)).normal.y < 0.7f)) { Vector3 val3 = ((RaycastHit)(ref val2)).point + Vector3.up * 0.15f; if (!Physics.OverlapCapsule(val3 + Vector3.up * 0.5f, val3 + Vector3.up * 1.5f, 0.35f, -1, (QueryTriggerInteraction)1).Any((Collider c) => !((Component)c).transform.IsChildOf(((Component)dummy).transform))) { return val3; } } } throw new InvalidOperationException("No clear ground nearby. Move to open ground and try again."); } private void RemoveDummy() { foreach (Action item in dummyUnbind) { item(); } dummyUnbind.Clear(); PlayerInfo val = dummy; dummy = null; dummyNeedsReset = false; if ((Object)(object)val != (Object)null) { if (NetworkServer.active) { NetworkServer.Destroy(((Component)val).gameObject); } else { Object.Destroy((Object)(object)((Component)val).gameObject); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"[DUMMY] Removed"); } } private void TickDummy() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_00b1: Invalid comparison between Unknown and I4 //IL_00cd: 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) if ((Object)(object)dummy == (Object)null) { if (dummyUnbind.Count != 0) { RemoveDummy(); } return; } if (NetworkServer.active && NetworkServer.connections.Count == 1 && !((Object)(object)GameManager.LocalPlayerInfo == (Object)null) && enabledMode.Value) { SceneHandle val = SceneHandle.op_Implicit(dummyScene); Scene activeScene = SceneManager.GetActiveScene(); if (!(val != ((Scene)(ref activeScene)).handle) && MatchSetupRules.IsCheatsEnabled() && bridge != null && bridge.CanStart(out var _) && ((InDrivingRange && !Run.Active) || (int)Run.State == 3)) { if (dummyNeedsReset || ((Component)dummy).transform.position.y < ((Component)GameManager.LocalPlayerInfo).transform.position.y - 60f) { try { ResetDummy(); return; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[DUMMY] Reset failed: " + ex.Message)); RemoveDummy(); return; } } return; } } RemoveDummy(); } private void ConfigureDunkGolf() { Channel((EffectChannel)32768, delegate { if (AccessTools.Field(typeof(BoundsManager), "greenBounds") == null) { throw new MissingFieldException("BoundsManager.greenBounds"); } NativeHook(typeof(GolfHoleTrigger), "OnTriggerEnter", "AllowRegularCup"); NativeHook(typeof(GolfBall), "OnTeleported", "DunkBallTeleported"); }); } private static void DunkBallTeleported(GolfBall __instance) { Instance?.dunkPrevious.Remove(__instance); } private static bool AllowRegularCup(GolfHoleTrigger __instance) { RogueGolfPlugin instance = Instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.dunkHole == (Object)null)) { return (Object)(object)((Component)__instance).GetComponentInParent() != (Object)(object)instance.dunkHole; } return true; } private void TickDunkGolf() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) bool num; if (!NetworkServer.active) { RunSnapshot view = View; if (view == null) { goto IL_0033; } num = (int)view.State == 3; } else { num = EffectsPlaying; } if (num && HasRule((Mechanic)524288)) { if (dunkFailed) { return; } try { if ((Object)(object)dunkHole == (Object)null) { GolfHole mainHole = GolfHoleManager.MainHole; if ((Object)(object)mainHole == (Object)null) { return; } BuildDunkGoal(mainHole); } if (!NetworkServer.active) { return; } GolfBall[] array = Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0); foreach (GolfBall val in array) { if (!((Object)(object)val.Owner == (Object)null) && !val.Owner.IsMatchResolved && !val.Rigidbody.isKinematic) { Vector3 val2 = val.Rigidbody.position - dunkCenter; if (dunkPrevious.TryGetValue(val, out var value) && DunkGoal.Crossed(value.x, value.y, value.z, val2.x, val2.y, val2.z, dunkRadius, val.Collider.radius)) { dunkPrevious.Remove(val); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[DUNK] Scored golfer=" + ((NetworkBehaviour)val.Owner.PlayerInfo).netId + " radius=" + dunkRadius)); dunkHole.ServerInformFellIn(val.AsEntity); return; } dunkPrevious[val] = val2; } } PlayerInfo[] array2 = Players(); foreach (PlayerInfo val3 in array2) { PlayerGolfer asGolfer = val3.AsGolfer; Vector3 val4 = ((Component)asGolfer).transform.position - dunkCenter; if (!asGolfer.IsMatchResolved && val3.Movement.IsVisible && val4.y < -1.5f) { Vector2 val5 = new Vector2(val4.x, val4.z); if (((Vector2)(ref val5)).magnitude < dunkRadius - 0.5f) { dunkHole.ServerInformFellIn(val3.AsEntity); return; } } } array = dunkPrevious.Keys.Where((GolfBall b) => (Object)(object)b == (Object)null).ToArray(); foreach (GolfBall key in array) { dunkPrevious.Remove(key); } return; } catch (Exception ex) { StopDunkGolf(); dunkFailed = true; ((BaseUnityPlugin)this).Logger.LogError((object)("[DUNK] Disabled after geometry failure: " + ex)); if (NetworkServer.active && modifiers != null && modifiers.Suspend("dunk_golf", true)) { ApplyEffects(EffectRunId, gravityBaseline, modifiers.Values); Publish(); } return; } } goto IL_0033; IL_0033: StopDunkGolf(); dunkFailed = false; } private void BuildDunkGoal(GolfHole hole) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) SplineContainer val = (SplineContainer)AccessTools.Field(typeof(BoundsManager), "greenBounds").GetValue(SingletonBehaviour.Instance); if ((Object)(object)val == (Object)null) { throw new InvalidOperationException("No native green splines"); } dunkCenter = ((Component)hole).transform.position; float num = 0f; foreach (Spline spline in val.Splines) { Vector3[] array = (Vector3[])(object)new Vector3[128]; for (int i = 0; i < array.Length; i++) { array[i] = ((Component)val).transform.TransformPoint(float3.op_Implicit(SplineUtility.EvaluatePosition(spline, (float)i / (float)array.Length))); } bool flag = false; int num2 = 0; int num3 = array.Length - 1; while (num2 < array.Length) { if (array[num2].z > dunkCenter.z != array[num3].z > dunkCenter.z && dunkCenter.x < (array[num3].x - array[num2].x) * (dunkCenter.z - array[num2].z) / (array[num3].z - array[num2].z) + array[num2].x) { flag = !flag; } num3 = num2++; } if (flag) { num = array.Max(delegate(Vector3 v) { //IL_0000: 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_002e: 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) Vector2 val3 = new Vector2(v.x - dunkCenter.x, v.z - dunkCenter.z); return ((Vector2)(ref val3)).magnitude; }); break; } } if (num < 2f || num > 80f) { throw new InvalidOperationException("Unsupported green radius " + num); } dunkRadius = num + 1.5f; dunkHole = hole; int num4 = 0; Terrain[] activeTerrains = Terrain.activeTerrains; foreach (Terrain val2 in activeTerrains) { TerrainData data = val2.terrainData; Vector3 position = ((Component)val2).transform.position; int holesResolution = data.holesResolution; if (holesResolution <= 0) { continue; } int x0 = Mathf.Clamp(Mathf.FloorToInt((dunkCenter.x - dunkRadius - position.x) / data.size.x * (float)holesResolution), 0, holesResolution - 1); int z0 = Mathf.Clamp(Mathf.FloorToInt((dunkCenter.z - dunkRadius - position.z) / data.size.z * (float)holesResolution), 0, holesResolution - 1); int num6 = Mathf.Clamp(Mathf.CeilToInt((dunkCenter.x + dunkRadius - position.x) / data.size.x * (float)holesResolution), 0, holesResolution); int num7 = Mathf.Clamp(Mathf.CeilToInt((dunkCenter.z + dunkRadius - position.z) / data.size.z * (float)holesResolution), 0, holesResolution); if (num6 <= x0 || num7 <= z0) { continue; } bool[,] original = data.GetHoles(x0, z0, num6 - x0, num7 - z0); bool[,] array2 = (bool[,])original.Clone(); bool flag2 = false; float num8 = Math.Max(data.size.x, data.size.z) / (float)holesResolution * 0.71f; for (int num9 = 0; num9 < array2.GetLength(0); num9++) { for (int num10 = 0; num10 < array2.GetLength(1); num10++) { float num11 = position.x + ((float)(x0 + num10) + 0.5f) / (float)holesResolution * data.size.x - dunkCenter.x; float num12 = position.z + ((float)(z0 + num9) + 0.5f) / (float)holesResolution * data.size.z - dunkCenter.z; if (num11 * num11 + num12 * num12 <= (dunkRadius + num8) * (dunkRadius + num8)) { array2[num9, num10] = false; flag2 = true; } } } if (!flag2) { continue; } dunkRestore.Add(delegate { if (!((Object)(object)data == (Object)null)) { data.SetHoles(x0, z0, original); bool[,] holes = data.GetHoles(x0, z0, original.GetLength(1), original.GetLength(0)); for (int j = 0; j < original.GetLength(0); j++) { for (int k = 0; k < original.GetLength(1); k++) { if (original[j, k] != holes[j, k]) { throw new InvalidOperationException("Terrain hole restoration mismatch"); } } } ((BaseUnityPlugin)this).Logger.LogInfo((object)"[DUNK] Native terrain holes restored exactly"); } }); data.SetHoles(x0, z0, array2); num4++; } if (num4 == 0) { throw new InvalidOperationException("Green does not have a supported terrain surface"); } foreach (Collider c in from val3 in ((Component)hole).GetComponentsInChildren() where !val3.isTrigger && val3.enabled select val3) { c.enabled = false; dunkRestore.Add(delegate { if ((Object)(object)c != (Object)null) { c.enabled = true; } }); } foreach (Renderer r in from val3 in ((Component)hole).GetComponentsInChildren() where ((Object)(object)((Component)val3).gameObject == (Object)(object)((Component)hole).gameObject || ((Object)val3).name == "Object fade plane") && val3.enabled select val3) { r.enabled = false; dunkRestore.Add(delegate { if ((Object)(object)r != (Object)null) { r.enabled = true; } }); } CreateDunkRim(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[DUNK] Built center=" + ((object)Unsafe.As(ref dunkCenter)/*cast due to .constrained prefix*/).ToString() + " greenRadius=" + num + " opening=" + dunkRadius + " terrains=" + num4)); } private void CreateDunkRim() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_001c: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: 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: Expected O, but got Unknown //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) dunkVisual = new GameObject("RogueGolf Dunk Golf rim"); dunkVisual.transform.position = dunkCenter; List list = new List(); List list2 = new List(); List list3 = new List(); float num = 0.35f; Vector3 val = default(Vector3); for (int i = 0; i <= 96; i++) { float num2 = (float)(i * 2) * (float)Math.PI / 96f; ((Vector3)(ref val))..ctor(Mathf.Cos(num2), 0f, Mathf.Sin(num2)); Vector3[] array = (Vector3[])(object)new Vector3[3] { val * (dunkRadius + num) + Vector3.up * 0.12f, val * dunkRadius + Vector3.up * 0.12f, val * dunkRadius - Vector3.up * 6f }; foreach (Vector3 item in array) { list.Add(item); } list3.Add(new Color(1f, 0.48f, 0.08f)); list3.Add(new Color(1f, 0.48f, 0.08f)); list3.Add(new Color(0.05f, 0.04f, 0.025f)); if (i != 96) { int num3 = i * 3; list2.AddRange(new int[12] { num3, num3 + 1, num3 + 4, num3, num3 + 4, num3 + 3, num3 + 1, num3 + 5, num3 + 2, num3 + 1, num3 + 4, num3 + 5 }); } } dunkMesh = new Mesh { name = "RogueGolf original hoop mesh" }; dunkMesh.SetVertices(list); dunkMesh.SetTriangles(list2, 0); dunkMesh.SetColors(list3); dunkMesh.RecalculateNormals(); dunkVisual.AddComponent().sharedMesh = dunkMesh; Shader val2 = Shader.Find("Sprites/Default") ?? throw new InvalidOperationException("Rim material unavailable"); dunkMaterial = new Material(val2); ((Renderer)dunkVisual.AddComponent()).sharedMaterial = dunkMaterial; dunkVisual.AddComponent().sharedMesh = dunkMesh; } private void StopDunkGolf() { for (int num = dunkRestore.Count - 1; num >= 0; num--) { try { dunkRestore[num](); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[DUNK] Restoration failed: " + ex.Message)); } } dunkRestore.Clear(); dunkPrevious.Clear(); dunkHole = null; if ((Object)(object)dunkVisual != (Object)null) { Object.Destroy((Object)(object)dunkVisual); } if ((Object)(object)dunkMesh != (Object)null) { Object.Destroy((Object)(object)dunkMesh); } if ((Object)(object)dunkMaterial != (Object)null) { Object.Destroy((Object)(object)dunkMaterial); } dunkVisual = null; dunkMesh = null; dunkMaterial = null; } private void ResetImpactTracking() { impactRearming.Clear(); pendingPlayerImpacts.Clear(); } private bool ImpactBlocked(Hittable target) { if (impactRearming.TryGetValue(target, out var value)) { return value.Blocked; } return false; } private void SuppressImpact(Hittable target) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0047: Expected O, but got Unknown if (!((Object)(object)target == (Object)null) && (target.AsEntity.IsPlayer || target.AsEntity.IsGolfBall)) { if (!impactRearming.TryGetValue(target, out var value)) { Dictionary dictionary = impactRearming; ImpactRearm val = new ImpactRearm(); value = val; dictionary[target] = val; } value.Suppress(); pendingPlayerImpacts.Remove(target); } } private static void PlayerItemImpact(Hittable __instance, ItemType itemType, PlayerInventory itemUser, bool canHitWithNoUser) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (__instance.AsEntity.IsPlayer && Offensive(itemType) && ((Object)(object)itemUser != (Object)null || canHitWithNoUser) && ((Object)(object)itemUser == (Object)null || (Object)(object)itemUser.PlayerInfo != (Object)(object)__instance.AsEntity.PlayerInfo)) { Instance?.QueuePlayerImpact(__instance); } } private static void PlayerClubImpact(Hittable __instance, float power, PlayerGolfer hitter) { if (__instance.AsEntity.IsPlayer && power > 0f && (Object)(object)hitter != (Object)null && (Object)(object)hitter.PlayerInfo != (Object)(object)__instance.AsEntity.PlayerInfo) { Instance?.QueuePlayerImpact(__instance); } } private static void PlayerProjectileImpact(Hittable __instance, Hittable hitter, float normalizedHitSpeed, PlayerGolfer responsiblePlayer) { RogueGolfPlugin instance = Instance; if (!((Object)(object)instance == (Object)null) && __instance.AsEntity.IsPlayer && !((Object)(object)hitter == (Object)null) && !(normalizedHitSpeed <= 0f) && !instance.ImpactBlocked(hitter)) { PlayerGolfer val = (hitter.AsEntity.IsGolfBall ? ((Component)hitter).GetComponent().Owner : responsiblePlayer); if ((Object)(object)val != (Object)null && (Object)(object)val.PlayerInfo != (Object)(object)__instance.AsEntity.PlayerInfo) { instance.QueuePlayerImpact(__instance); } } } private static void PlayerVehicleImpact(PlayerMovement knockedOutPlayer, KnockoutType knockoutType) { //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_0007: Invalid comparison between Unknown and I4 if ((int)knockoutType == 6 || (int)knockoutType == 27) { Instance?.QueuePlayerImpact(knockedOutPlayer.PlayerInfo.AsHittable); } } private void QueuePlayerImpact(Hittable target) { if (NetworkServer.active && EffectsPlaying && !creatingExplosion && !HasRule((Mechanic)8) && HasRule((Mechanic)131200) && !((Object)(object)target == (Object)null) && target.AsEntity.IsPlayer && !ImpactBlocked(target) && pendingPlayerImpacts.Count < 64) { pendingPlayerImpacts.Add(target); } } private void TickImpactTracking() { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) if (!HasRule((Mechanic)131200)) { ResetImpactTracking(); return; } double time = NetworkTime.time; KeyValuePair[] array = impactRearming.ToArray(); for (int i = 0; i < array.Length; i++) { KeyValuePair keyValuePair = array[i]; Hittable key = keyValuePair.Key; if ((Object)(object)key == (Object)null) { impactRearming.Remove(key); continue; } Entity asEntity = key.AsEntity; bool flag = (asEntity.IsPlayer ? asEntity.PlayerInfo.Movement.IsGrounded : (asEntity.IsGolfBall && ((Component)key).GetComponent().IsGrounded)); ImpactRearm value = keyValuePair.Value; Vector3 networkedVelocity = asEntity.GetNetworkedVelocity(); value.Observe(time, flag, ((Vector3)(ref networkedVelocity)).magnitude); if (!keyValuePair.Value.Blocked) { impactRearming.Remove(key); } } Hittable[] array2 = pendingPlayerImpacts.ToArray(); pendingPlayerImpacts.Clear(); Hittable[] array3 = array2; foreach (Hittable val in array3) { if ((Object)(object)val != (Object)null && !ImpactBlocked(val)) { TryExplosion(((Component)val).transform.position, val, recipientOnly: true); } } } private void RemoveFormula1Hooks() { formula1Available = false; if (formulaGravityTarget != null) { harmony.Unpatch((MethodBase)formulaGravityTarget, AccessTools.Method(typeof(RogueGolfPlugin), "CartGravityInstructions", (Type[])null, (Type[])null)); } if (formulaSpeedTarget != null) { harmony.Unpatch((MethodBase)formulaSpeedTarget, AccessTools.Method(typeof(RogueGolfPlugin), "ScaleCartSpeed", (Type[])null, (Type[])null)); } formulaGravityTarget = (formulaSpeedTarget = null); } private void ConfigureFormula1(Type cartType = null) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown RemoveFormula1Hooks(); try { formulaGravityTarget = AccessTools.GetDeclaredMethods(cartType ?? typeof(GolfCartMovement)).Single((MethodInfo m) => m.Name.Contains("g__ApplyGravity|") && m.Name.Contains("OnFixedBUpdate")); formulaSpeedTarget = AccessTools.DeclaredMethod(typeof(MatchSetupRules), "GetValue", (Type[])null, (Type[])null) ?? throw new MissingMethodException("CartSpeed rule"); harmony.Patch((MethodBase)formulaGravityTarget, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(RogueGolfPlugin), "CartGravityInstructions", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)formulaSpeedTarget, (HarmonyMethod)null, new HarmonyMethod(typeof(RogueGolfPlugin), "ScaleCartSpeed", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); formula1Available = true; } catch (Exception ex) { RemoveFormula1Hooks(); ((BaseUnityPlugin)this).Logger.LogWarning((object)("[MODIFIER] Formula 1 unavailable; other inventory modifiers remain supported: " + ex.Message)); } } private static IEnumerable CartGravityInstructions(IEnumerable instructions) { MethodInfo getter = AccessTools.PropertyGetter(typeof(Physics), "gravity"); int replacements = 0; foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.Calls(instruction, getter)) { instruction.opcode = OpCodes.Call; instruction.operand = AccessTools.Method(typeof(RogueGolfPlugin), "EffectiveCartGravity", (Type[])null, (Type[])null); replacements++; } yield return instruction; } if (replacements != 1) { throw new InvalidOperationException("Native cart gravity expression changed"); } } private static Vector3 EffectiveCartGravity() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) return Physics.gravity * (((Object)(object)Instance != (Object)null && Instance.formula1Available) ? ((EffectValues)(ref Instance.effects))[(Parameter)14] : 1f); } private static void ScaleCartSpeed(Rule rule, ref float __result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)rule == 4 && (Object)(object)Instance != (Object)null && Instance.formula1Available) { __result *= ((EffectValues)(ref Instance.effects))[(Parameter)15]; } } private void PeerSceneLoaded(Scene scene, LoadSceneMode mode) { QueuePeerSceneRefresh(); } private void QueuePeerSceneRefresh() { if (!NetworkServer.active && NetworkClient.active) { peerSceneRefreshFrame = Time.frameCount + 1; } } private void RefreshPeerScene() { if (peerSceneRefreshFrame < 0 || Time.frameCount < peerSceneRefreshFrame) { return; } peerSceneRefreshFrame = -1; if (!NetworkServer.active && NetworkClient.isConnected) { NetworkBridge networkBridge = bridge; if (((networkBridge != null) ? networkBridge.Replica.Current : null) != null) { ReceiveEffects(bridge.Replica.Current); NetLog("Rebound peer effects after scene load"); } } } private static GravityVector ReadGravity() { //IL_0000: 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_0014: 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) return new GravityVector(Physics.gravity.x, Physics.gravity.y, Physics.gravity.z); } private ConfigEntry Factor(string name, float value, float min, float max, string description = "Multiplier captured from host config at run start.") { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown return ((BaseUnityPlugin)this).Config.Bind("Modifiers", name, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange(min, max), Array.Empty())); } private unsafe void ConfigureModifiers() { //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_0936: Unknown result type (might be due to invalid IL or missing references) //IL_093b: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Expected O, but got Unknown //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Expected O, but got Unknown //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Expected O, but got Unknown //IL_08c2: Unknown result type (might be due to invalid IL or missing references) //IL_08cf: Expected O, but got Unknown //IL_08d2: Unknown result type (might be due to invalid IL or missing references) //IL_08d8: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: 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_020e: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Expected O, but got Unknown //IL_0494: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Expected O, but got Unknown //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Expected O, but got Unknown //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Expected O, but got Unknown //IL_057a: Unknown result type (might be due to invalid IL or missing references) //IL_0584: Expected O, but got Unknown //IL_05c2: Unknown result type (might be due to invalid IL or missing references) //IL_05cc: Expected O, but got Unknown //IL_0728: Unknown result type (might be due to invalid IL or missing references) //IL_073d: Unknown result type (might be due to invalid IL or missing references) //IL_074a: Expected O, but got Unknown //IL_074a: Expected O, but got Unknown //IL_074d: Unknown result type (might be due to invalid IL or missing references) //IL_0753: Unknown result type (might be due to invalid IL or missing references) //IL_077e: Unknown result type (might be due to invalid IL or missing references) //IL_078b: Expected O, but got Unknown //IL_0839: Unknown result type (might be due to invalid IL or missing references) //IL_0846: Expected O, but got Unknown //IL_0849: Unknown result type (might be due to invalid IL or missing references) //IL_084f: Unknown result type (might be due to invalid IL or missing references) traceGravity = ((BaseUnityPlugin)this).Config.Bind("Diagnostics", "TraceGravity", false, "Read-only native physics and shot-speed samples for local verification."); powerFactor = Factor("PowerSurge", 1.2f, 1f, 3f); heavyFactor = Factor("HeavyBall", 2f, 1f, 4f, "Ball-only gravity multiplier (previously mass). Multiplies shared gravity; players are unchanged."); featherFactor = Factor("Featherweight", 0.5f, 0.25f, 1f, "Ball-only gravity multiplier (previously mass). Multiplies shared gravity; players are unchanged."); lowFactor = Factor("LowGravity", 0.6f, 0.1f, 1f); highFactor = Factor("HighGravity", 1.5f, 1f, 4f); ModifierDefinition[] definitions = ModifierRegistry.Create(new ModifierSettings(1.2f, 2f, 0.5f, 0.6f, 1.5f, (IEnumerable>)null)).Definitions; foreach (ModifierDefinition val in definitions) { modifierEnabled[val.Id] = ((BaseUnityPlugin)this).Config.Bind("Modifiers.Enabled", val.Id, true, "Offer " + val.Name + " when supported and compatible."); if (!new string[5] { "power_surge", "heavy_ball", "featherweight", "low_gravity", "high_gravity" }.Contains(val.Id)) { Contribution[] contributions = val.Contributions; foreach (Contribution val2 in contributions) { Dictionary> dictionary = tuning; string id = val.Id; Parameter parameter = val2.Parameter; string key = id + "." + ((object)(*(Parameter*)(¶meter))/*cast due to .constrained prefix*/).ToString(); ConfigFile config = ((BaseUnityPlugin)this).Config; string id2 = val.Id; parameter = val2.Parameter; dictionary[key] = config.Bind("Tuning", id2 + "." + ((object)(*(Parameter*)(¶meter))/*cast due to .constrained prefix*/).ToString(), val2.Factor, new ConfigDescription("Per-run channel multiplier.", (AcceptableValueBase)(object)new AcceptableValueRange(CanonicalCatalog.Minimum(val2.Parameter), CanonicalCatalog.Maximum(val2.Parameter)), Array.Empty())); } } } ConfigEntry val3 = ((BaseUnityPlugin)this).Config.Bind("Compatibility", "InfiniteWarfareFiveUses", false, "Tracks the one-time 0.10.0 ammo balance migration."); if (!val3.Value) { if (tuning["infinite_warfare.Ammo"].Value == 10f) { tuning["infinite_warfare.Ammo"].Value = 5f; } val3.Value = true; ((BaseUnityPlugin)this).Config.Save(); } tuning["LeaderTaxFactor"] = ((BaseUnityPlugin)this).Config.Bind("Tuning", "LeaderTaxFactor", 0.8f, new ConfigDescription("Leader shot factor.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 1f), Array.Empty())); tuning["LastPlaceFactor"] = ((BaseUnityPlugin)this).Config.Bind("Tuning", "LastPlaceFactor", 1.2f, new ConfigDescription("Last place shot factor.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 1.5f), Array.Empty())); tuning["ComebackMaximum"] = ((BaseUnityPlugin)this).Config.Bind("Tuning", "ComebackMaximum", 1.3f, new ConfigDescription("Maximum rank assistance.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 1.5f), Array.Empty())); var array = new[] { new { Key = "TimedLow", Value = 0.35f, Min = 0.1f, Max = 1f }, new { Key = "TimedHigh", Value = 2f, Min = 1f, Max = 3f }, new { Key = "RouletteMoon", Value = 0.2f, Min = 0.1f, Max = 1f }, new { Key = "RouletteLow", Value = 0.6f, Min = 0.1f, Max = 1f }, new { Key = "RouletteHigh", Value = 1.5f, Min = 1f, Max = 4f } }; foreach (var anon in array) { tuning[anon.Key] = ((BaseUnityPlugin)this).Config.Bind("Tuning", anon.Key, anon.Value, new ConfigDescription("Timed physics preset factor.", (AcceptableValueBase)(object)new AcceptableValueRange(anon.Min, anon.Max), Array.Empty())); } tuning["IntervalSeconds"] = ((BaseUnityPlugin)this).Config.Bind("Tuning", "IntervalSeconds", 20f, new ConfigDescription("Host interval for timed effects.", (AcceptableValueBase)(object)new AcceptableValueRange(5f, 120f), Array.Empty())); tuning["ImpactThreshold"] = ((BaseUnityPlugin)this).Config.Bind("Tuning", "ImpactThreshold", 12f, new ConfigDescription("Minimum impact speed for explosions.", (AcceptableValueBase)(object)new AcceptableValueRange(5f, 80f), Array.Empty())); tuning["ExplosionCooldown"] = ((BaseUnityPlugin)this).Config.Bind("Tuning", "ExplosionCooldown", 2f, new ConfigDescription("Global explosion cooldown.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 30f), Array.Empty())); tuning["ExplosionRadius"] = ((BaseUnityPlugin)this).Config.Bind("Tuning", "ExplosionRadius", 5f, new ConfigDescription("Native explosion radius, Nuclear Golf doubles it up to 12.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 12f), Array.Empty())); ConfigEntry val4 = ((BaseUnityPlugin)this).Config.Bind("Compatibility", "Balance0101", false, "Tracks the one-time 0.10.1 balance-default migration; custom values are preserved."); if (!val4.Value) { Dictionary dictionary2 = tuning.ToDictionary((KeyValuePair> p) => p.Key, (KeyValuePair> p) => p.Value.Value); int num = BalanceMigration.Apply0101((IDictionary)dictionary2, false); foreach (KeyValuePair item in dictionary2) { tuning[item.Key].Value = item.Value; } val4.Value = true; ((BaseUnityPlugin)this).Config.Save(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[CONFIG] 0.10.1 balance migration updated " + num + " legacy defaults")); } MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(GolfBall), "ApplyGravity", Type.EmptyTypes, (Type[])null); MethodInfo methodInfo2 = AccessTools.DeclaredMethod(typeof(PlayerMovement), "GetBaseGravitySpeedDelta", Type.EmptyTypes, (Type[])null); if (methodInfo != null && methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(RogueGolfPlugin), "BeforeBallGravity", (Type[])null), new HarmonyMethod(typeof(RogueGolfPlugin), "AfterBallGravity", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Capabilities = (EffectChannel)(Capabilities | 2); if (traceGravity.Value) { harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(RogueGolfPlugin), "AfterPlayerGravity", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[MODIFIER] Gravity channel unavailable: missing native consumer hooks"); } try { swingSpeedMethod = AccessTools.DeclaredMethod(typeof(Hittable), "GetSwingHitSpeed", new Type[3] { typeof(bool), typeof(SwingType), typeof(float) }, (Type[])null); if (swingSpeedMethod == null || swingSpeedMethod.ReturnType != typeof(float)) { throw new MissingMethodException("GetSwingHitSpeed"); } harmony.Patch((MethodBase)swingSpeedMethod, (HarmonyMethod)null, new HarmonyMethod(typeof(RogueGolfPlugin), "ScaleShotSpeed", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Capabilities = (EffectChannel)(Capabilities | 1); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[MODIFIER] Shot power unavailable: " + ex.Message)); } try { MethodInfo methodInfo3 = AccessTools.DeclaredMethod(typeof(GolfBall), "Awake", Type.EmptyTypes, (Type[])null); if (methodInfo3 == null) { throw new MissingMethodException("GolfBall.Awake"); } harmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(RogueGolfPlugin), "BallCreated", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Capabilities = (EffectChannel)(Capabilities | 4); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[MODIFIER] Mass unavailable: " + ex2.Message)); } ConfigurePhysicsChannels(); ConfigureWorldChannels(); ConfigureActiveEvents(); ConfigureDunkGolf(); ConfigureLab(); ConfigureTestingMenu(); ConfigureDummy(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[MODIFIER] Supported channels=" + ((object)Capabilities/*cast due to .constrained prefix*/).ToString())); } private void BeginModifiers(uint seedValue) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Expected O, but got Unknown RestoreEffects(); Vector3 val = sharedGravity.Base; gravityBaseline = new GravityVector(val.x, val.y, val.z); modifierSettings = new ModifierSettings(powerFactor.Value, heavyFactor.Value, featherFactor.Value, lowFactor.Value, highFactor.Value, tuning.Select((KeyValuePair> p) => new KeyValuePair(p.Key, p.Value.Value))); modifiers = ((runStage != PrototypeStage.Modifiers) ? ((ModifierManager)null) : new ModifierManager(ModifierRegistry.Create(modifierSettings), from p in modifierEnabled where p.Value.Value select p.Key, Capabilities)); if (modifiers != null) { modifiers.ContextAllows = AllowsContext; } eventSeed = seedValue ^ 0x5E05; worldRandom = new RunRandom(seedValue ^ 0x91317); modifierRandom = new RunRandom(seedValue ^ 0xA511E9B3u); if (modifiers != null) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[MODIFIER] Available=" + string.Join(",", modifiers.Available))); } } private void ActivateModifier(string id) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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) if (modifiers == null || !modifiers.Activate(id, Run.HoleIndex + 1, progression.Persistence)) { throw new InvalidOperationException("Winner is no longer eligible: " + id); } if (CanonicalCatalog.IsTimed(modifiers.Registry.Get(id).Rule)) { modifiers.SetVariant(id, worldRandom.Next(32)); } ApplyEffects(Run.RunId, gravityBaseline, modifiers.Values); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[MODIFIER] Activated " + id + " active=" + string.Join(",", modifiers.Active.Select((ActiveModifier e) => e.Id)))); } private void ExpireModifiers(int hole) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (modifiers == null) { return; } ActiveModifier[] active = modifiers.Active; if (modifiers.CompleteHole(hole)) { ApplyEffects(Run.RunId, gravityBaseline, modifiers.Values); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[MODIFIER] Expired=" + string.Join(",", active.Select((ActiveModifier e) => e.Id).Except(modifiers.Active.Select((ActiveModifier e) => e.Id))) + " hole=" + hole)); } } private void ApplyEffects(string runId, GravityVector baseline, EffectValues values) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_004c: 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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) BindScoringTriggers(); dampingTraced = false; float num = ((EffectValues)(ref effects))[(Parameter)9]; effects = values; RefreshMechanics(); if (((EffectValues)(ref values))[(Parameter)9] < num) { TrimAmmo(); } sharedGravity.Underlying(new Vector3(baseline.X, baseline.Y, baseline.Z), ((EffectValues)(ref values)).Gravity); Rigidbody[] array = massLeases.Keys.Where((Rigidbody b) => (Object)(object)b == (Object)null).ToArray(); foreach (Rigidbody key in array) { massLeases.Remove(key); } GolfBall[] array2 = Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0); foreach (GolfBall ball in array2) { ApplyBallMass(ball); } ManualLogSource logger = ((BaseUnityPlugin)this).Logger; string[] obj = new string[8] { "[MODIFIER] Effective shot=", ((EffectValues)(ref values)).ShotPower.ToString(), " gravity=", ((EffectValues)(ref values)).Gravity.ToString(), " mass=", ((EffectValues)(ref values)).BallMass.ToString(), " vector=", null }; Vector3 gravity = Physics.gravity; obj[7] = ((Vector3)(ref gravity)).ToString("F4"); logger.LogInfo((object)string.Concat(obj)); } private void ApplyBallMass(GolfBall ball) { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown Rigidbody[] array = massLeases.Keys.Where((Rigidbody b) => (Object)(object)b == (Object)null).ToArray(); foreach (Rigidbody key in array) { massLeases.Remove(key); } if ((Object)(object)ball == (Object)null || (Object)(object)ball.Rigidbody == (Object)null) { return; } BindShape(ball); Rigidbody body = ball.Rigidbody; if (!massLeases.TryGetValue(body, out var value)) { if (((EffectValues)(ref effects)).BallMass == 1f) { return; } value = new ScalarLease((Func)(() => body.mass), (Action)delegate(float v) { if ((Object)(object)body != (Object)null) { body.mass = v; } }); massLeases.Add(body, value); } value.Apply(((EffectValues)(ref effects)).BallMass); if (traceGravity.Value) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[PHYSICS] Mass hole=" + CourseManager.CurrentHoleCourseIndex + " factor=" + ((EffectValues)(ref effects)).BallMass + " actual=" + body.mass)); } } private static void BallCreated(GolfBall __instance) { Instance?.ApplyBallMass(__instance); } private static void ScaleShotSpeed(Hittable __instance, ref float __result) { RogueGolfPlugin instance = Instance; if (!((Object)(object)instance == (Object)null) && ((Behaviour)instance).enabled && !((Object)(object)__instance.AsEntity == (Object)null) && __instance.AsEntity.IsGolfBall) { float num = __result; float num2 = __result; float shotPower = ((EffectValues)(ref instance.effects)).ShotPower; PlayerGolfer owner = __instance.AsEntity.AsGolfBall.Owner; __result = num2 * Mathf.Clamp(shotPower * instance.PlayerShotFactor((owner != null) ? owner.PlayerInfo : null), 0.25f, 3f); if (instance.traceGravity.Value) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)("[PHYSICS] Shot native=" + num.ToString("F6") + " factor=" + ((EffectValues)(ref instance.effects)).ShotPower + " actual=" + __result.ToString("F6"))); } } } private void ProbePhysics() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) if (!traceGravity.Value) { return; } GolfBall[] array = Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0); foreach (GolfBall val in array) { ManualLogSource logger = ((BaseUnityPlugin)this).Logger; string[] obj = new string[6] { "[PHYSICS] Probe hole=", CourseManager.CurrentHoleCourseIndex.ToString(), " mass=", val.Rigidbody.mass.ToString(), " gravity=", null }; Vector3 gravity = Physics.gravity; obj[5] = ((Vector3)(ref gravity)).ToString("F4"); logger.LogInfo((object)string.Concat(obj)); if ((Capabilities & 1) != 0) { swingSpeedMethod.Invoke(val.AsEntity.AsHittable, new object[3] { false, (object)(SwingType)0, 0.5f }); } } } internal void ResetPeerEffects() { RestoreEffects(); } private void RestoreEffects() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) peerSceneRefreshFrame = -1; sharedGravity.ClearModifiers(); bool num = ((EffectValues)(ref effects))[(Parameter)9] > 1f; effects = EffectValues.Normal; if (num) { TrimAmmo(); } foreach (KeyValuePair massLease in massLeases) { if ((Object)(object)massLease.Key != (Object)null) { massLease.Value.Restore(); ConfigEntry obj = traceGravity; if (obj != null && obj.Value) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[PHYSICS] Mass restored=" + massLease.Key.mass)); } } } massLeases.Clear(); ModifierManager obj2 = modifiers; if (obj2 != null) { obj2.Clear(); } RestoreShapes(); ResetWorldEffects(); ManualLogSource logger = ((BaseUnityPlugin)this).Logger; Vector3 gravity = Physics.gravity; logger.LogInfo((object)("[MODIFIER] Restored channels; gravity=" + ((Vector3)(ref gravity)).ToString("F4"))); } private void ReceiveEffects(RunSnapshot s) { //IL_0051: 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) if (!NetworkServer.active) { remoteActive = s.ActiveModifiers; modifierSettings = s.ModifierSettings; playerShotFactors = new Dictionary(s.PlayerShotFactors); if (!((Behaviour)this).enabled || s.ActiveModifiers.Length == 0) { RestoreEffects(); } else { ApplyEffects(s.RunId, s.GravityBaseline, ModifierRegistry.Create(s.ModifierSettings).Compose((IEnumerable)s.ActiveModifiers)); } } } private static void BeforeBallGravity(Rigidbody ___rigidbody, out Vector3 __state) { //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) __state = ___rigidbody.linearVelocity; } private static void AfterBallGravity(Rigidbody ___rigidbody, Vector3 __state) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) RogueGolfPlugin instance = Instance; if (!((Object)(object)instance == (Object)null)) { float num = (instance.sharedGravity.TotalOverride ? 1f : ((EffectValues)(ref instance.effects)).BallGravityScale); if (num != 1f) { ___rigidbody.linearVelocity = __state + (___rigidbody.linearVelocity - __state) * num; } if (instance.traceGravity.Value && !(instance.ballSample == instance.GravitySampleKey)) { instance.ballSample = instance.GravitySampleKey; ManualLogSource logger = ((BaseUnityPlugin)instance).Logger; string[] obj = new string[10] { "[PHYSICS] Ball hole=", CourseManager.CurrentHoleCourseIndex.ToString(), " gravity=", null, null, null, null, null, null, null }; Vector3 val = Physics.gravity; obj[3] = ((Vector3)(ref val)).ToString("F4"); obj[4] = " ballFactor="; obj[5] = num.ToString(); obj[6] = " delta="; val = ___rigidbody.linearVelocity - __state; obj[7] = ((Vector3)(ref val)).magnitude.ToString("F6"); obj[8] = " expected="; val = Physics.gravity; obj[9] = (((Vector3)(ref val)).magnitude * Time.fixedDeltaTime * num).ToString("F6"); logger.LogInfo((object)string.Concat(obj)); } } } private static void AfterPlayerGravity(float __result, float ___gravityFactor) { //IL_002f: 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) RogueGolfPlugin instance = Instance; if (!((Object)(object)instance == (Object)null) && !(instance.playerSample == instance.GravitySampleKey)) { instance.playerSample = instance.GravitySampleKey; float num = Physics.gravity.y * GameManager.PlayerMovementSettings.BaseGravityFactor * ___gravityFactor * Time.fixedDeltaTime; ManualLogSource logger = ((BaseUnityPlugin)instance).Logger; string[] obj = new string[8] { "[PHYSICS] Player hole=", CourseManager.CurrentHoleCourseIndex.ToString(), " gravity=", null, null, null, null, null }; Vector3 gravity = Physics.gravity; obj[3] = ((Vector3)(ref gravity)).ToString("F4"); obj[4] = " delta="; obj[5] = __result.ToString("F6"); obj[6] = " expected="; obj[7] = num.ToString("F6"); logger.LogInfo((object)string.Concat(obj)); } } private void OpenRunSetup() { if (NetworkServer.active && MatchSetupVisible) { SetUiFocus(value: true); if (uiFocus) { setupOpen = true; pauseTab = 1; settingsPage = 0; selected = 0; uiKey = ""; } } } private void CloseRunSetup() { resetConfirmation = false; setupOpen = false; pauseTab = 0; SetUiFocus(value: false); selected = 0; uiKey = ""; } private void DrawRunSetup() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) RectTransform val = SetupBook(); SetupHeading((Transform)(object)val, 28f, 13f, 422f, 42f, "RogueGolf Setup", 33f); SetupArt((Transform)(object)val, 443f, 24f, 24f, SetupGlyph.Burst); SetupAction((Transform)(object)val, 514f, 20f, 140f, 34f, CloseRunSetup, Gold, active: true, null, "Back", 20f); Label((Transform)(object)val, 30f, 58f, 470f, 23f, "Private chaos runs · ties resolved randomly", 14f, Muted, bold: true); SetupAction((Transform)(object)val, 511f, 60f, 143f, 22f, delegate { resetConfirmation = true; selected = 1; uiKey = ""; }, SetupCream, active: true, null, "Reset to defaults", 12f); SetupTab(val, 29f, 174f, "Run Settings", 1); SetupTab(val, 209f, 150f, "Weights", 2); SetupTab(val, 365f, 171f, "Custom Items", 3); ScorecardShape scorecardShape = SetupAction((Transform)(object)val, 545f, 96f, 108f, 32f, OpenTutorial, Color32.op_Implicit(new Color32((byte)233, (byte)234, (byte)210, byte.MaxValue))); PrepareTutorialAttention(scorecardShape); ((TMP_Text)Label(((Component)scorecardShape).transform, 24f, 5f, 80f, 24f, "How it works", 11f, null, bold: true)).alignment = (TextAlignmentOptions)514; SetupSurface((Transform)(object)val, 24f, 129f, 634f, 501f, SetupBorder, 20f); SetupSurface((Transform)(object)val, 26f, 131f, 630f, 497f, SetupCream, 18f); settingsHelp = null; settingsHelpName = null; if (resetConfirmation) { uiActions.Clear(); DrawResetConfirmation(val); } else if (pauseTab == 4) { DrawSetupHelp(val); } else { DrawHostSettings(val); } } private SettingRow EnumRow(string name, ConfigEntry entry) where T : struct { //IL_0035: Unknown result type (might be due to invalid IL or missing references) T[] choices = (T[])Enum.GetValues(typeof(T)); return new SettingRow { Kind = (SettingControlKind)2, Name = name, Value = SplitWords(entry.Value.ToString()), Previous = delegate { Step(-1); }, Next = delegate { Step(1); } }; void Step(int direction) { int num = Array.IndexOf(choices, entry.Value); entry.Value = choices[(num + direction + choices.Length) % choices.Length]; SaveUiConfig(); } } private SettingRow DensityModeRow() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Invalid comparison between Unknown and I4 //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) SelectionDensityMode[] choices = (SelectionDensityMode[])(object)new SelectionDensityMode[3] { default(SelectionDensityMode), (SelectionDensityMode)1, (SelectionDensityMode)3 }; return new SettingRow { Kind = (SettingControlKind)2, Name = "Modifier density", Value = (((int)densityMode.Value == 2) ? "High unavailable" : SplitWords(((object)densityMode.Value/*cast due to .constrained prefix*/).ToString())), Previous = delegate { Step(-1); }, Next = delegate { Step(1); } }; void Step(int d) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) int num = Array.IndexOf(choices, densityMode.Value); densityMode.Value = choices[(num + d + choices.Length) % choices.Length]; SaveUiConfig(); } } private SettingRow IntRow(string name, ConfigEntry entry, int min, int max, int step = 1) { return new SettingRow { Name = name, Value = entry.Value.ToString(), Previous = delegate { Step(-1); }, Next = delegate { Step(1); } }; void Step(int d) { entry.Value = Math.Max(min, Math.Min(max, entry.Value + d * step)); SaveUiConfig(); } } private SettingRow BoolRow(string name, ConfigEntry entry) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) return new SettingRow { Kind = (SettingControlKind)1, Name = name, Value = (entry.Value ? "On" : "Off"), Previous = Toggle, Next = Toggle }; void Toggle() { entry.Value = !entry.Value; SaveUiConfig(); } } private SettingRow SecondsRow(string name, ConfigEntry entry, int max) { return new SettingRow { Name = name, Value = EffectPresentation.Number(entry.Value) + "s", Previous = delegate { Step(-1); }, Next = delegate { Step(1); } }; void Step(int d) { entry.Value = Math.Max(1f, Math.Min(max, entry.Value + (float)d)); SaveUiConfig(); } } private static string SplitWords(string text) { return Regex.Replace(text, "([a-z])([A-Z])", "$1 $2"); } private void SaveUiConfig() { ((BaseUnityPlugin)this).Config.Save(); uiKey = ""; } private void DrawHostSettings(RectTransform panel) { //IL_0796: Unknown result type (might be due to invalid IL or missing references) //IL_078a: Unknown result type (might be due to invalid IL or missing references) //IL_078f: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Invalid comparison between Unknown and I4 //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_0802: Unknown result type (might be due to invalid IL or missing references) //IL_07f6: Unknown result type (might be due to invalid IL or missing references) //IL_07fb: Unknown result type (might be due to invalid IL or missing references) //IL_0843: Unknown result type (might be due to invalid IL or missing references) //IL_05e4: Unknown result type (might be due to invalid IL or missing references) //IL_05e9: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_0632: Unknown result type (might be due to invalid IL or missing references) //IL_0637: Unknown result type (might be due to invalid IL or missing references) //IL_0659: Unknown result type (might be due to invalid IL or missing references) //IL_065e: Unknown result type (might be due to invalid IL or missing references) //IL_0d3e: Unknown result type (might be due to invalid IL or missing references) bool active = NetworkServer.active; List list = new List(); if (pauseTab == 3 && customItems != null) { list.Add(active ? BoolRow("Custom Items", customItems.Registry.Master) : new SettingRow { Name = "Custom Items", Value = (customItems.Enabled ? "On" : "Off") }); if (active ? customItems.Registry.Master.Value : customItems.Enabled) { for (int i = 0; i < customItems.Registry.Items.Length; i++) { CustomItemDefinition customItemDefinition = customItems.Registry.Items[i]; Tuple[] remoteSettings = customItems.remoteSettings; list.Add(active ? BoolRow(customItemDefinition.Name, customItemDefinition.Enabled) : new SettingRow { Name = customItemDefinition.Name, Value = ((remoteSettings != null && remoteSettings[i].Item1) ? "On" : "Off") }); list.Add(active ? IntRow(customItemDefinition.Name + " weight", customItemDefinition.Weight, 0, 1000) : new SettingRow { Name = customItemDefinition.Name + " weight", Value = ((remoteSettings == null) ? "—" : remoteSettings[i].Item2.ToString()) }); } } } else if (pauseTab == 1) { if (active) { list.Add(BoolRow("RogueGolf enabled", enabledMode)); list.Add(EnumRow("Selection", selectionMode)); list.Add(DensityModeRow()); list.Add(EnumRow("Persistence", persistenceMode)); list.Add(IntRow("Candidate cards", candidateCount, 2, 5)); list.Add(EnumRow("Skip budget", skipMode)); list.Add(IntRow("Starting skips", skipBudget, 0, 99)); list.Add(EnumRow("Skip effect", skipBehavior)); list.Add(BoolRow("Boss selections", bossEnabled)); list.Add(IntRow("Boss interval (rounds)", bossInterval, 1, 99)); list.Add(BoolRow("Automatic skips", randomSkips)); list.Add(IntRow("Automatic skip weight", randomSkipWeight, 0, 10000, 10)); list.Add(IntRow("Automatic modifier weight", randomModifierWeight, 1, 10000, 10)); list.Add(SecondsRow("Voting time", voteSeconds, 120)); list.Add(SecondsRow("Reveal time", revealSeconds, 15)); list.Add(BoolRow("Allow vote changes", voteChanges)); list.Add(BoolRow("Close when all vote", earlyClose)); list.Add(IntRow("Run seed (0 = random)", seed, 0, 999999999)); if ((int)densityMode.Value == 3) { list.Add(IntRow("Short-run selection floor", densityFloor, 0, 999)); list.Add(IntRow("Max picks / ordinary round", densityCap, 1, 5)); } for (int j = 0; j < phaseThresholds.Count; j++) { int index = j; ConfigEntry entry = phaseThresholds[j]; list.Add(new SettingRow { Name = (new string[3] { "Early-mid starts at progress", "Mid-late starts at progress", "Late starts at progress" })[j], Value = entry.Value.ToString("0.##") + "%", Previous = delegate { Change(-1); }, Next = delegate { Change(1); } }); void Change(int d) { float num6 = ((index == 0) ? 0f : phaseThresholds[index - 1].Value); float num7 = ((index == 2) ? 15001f : phaseThresholds[index + 1].Value); float num8 = entry.Value + (float)d; if (num8 <= num6) { num8 = (num6 + entry.Value) / 2f; } if (num8 >= num7) { num8 = (entry.Value + num7) / 2f; } if (num8 > num6 && num8 < num7) { entry.Value = num8; } SaveUiConfig(); } } } else if (View != null) { ProgressionSettings val = View.Progression; list.Add(new SettingRow { Name = "Modifier density", Value = SplitWords(((object)View.Density.Mode/*cast due to .constrained prefix*/).ToString()) }); list.Add(new SettingRow { Name = "Short-run selection floor", Value = View.Density.ShortRunSelectionFloor.ToString() }); list.Add(new SettingRow { Name = "Max picks / ordinary round", Value = View.Density.EffectiveMaxSelectionsPerOrdinaryRound.ToString() }); for (int num = 1; num < 4; num++) { list.Add(new SettingRow { Name = (new string[4] { "Early", "Early-mid", "Mid-late", "Late" })[num] + " starts at progress", Value = val.PhaseThresholds[num].ToString("0.##") + "%" }); } (string, string)[] array = new(string, string)[7] { ("Selection", ((object)val.Selection/*cast due to .constrained prefix*/).ToString()), ("Persistence", ((object)val.Persistence/*cast due to .constrained prefix*/).ToString()), ("Skip budget", ((object)val.Skips/*cast due to .constrained prefix*/).ToString()), ("Skip effect", ((object)val.SkipEffect/*cast due to .constrained prefix*/).ToString()), ("Boss interval", val.BossEnabled ? val.BossInterval.ToString() : "Off"), ("Seed", View.Seed.ToString()), ("Vote time", View.Settings.Duration + "s") }; for (int num2 = 0; num2 < array.Length; num2++) { (string, string) tuple = array[num2]; list.Add(new SettingRow { Name = tuple.Item1, Value = SplitWords(tuple.Item2) }); } } } else { SetupAction((Transform)(object)panel, 30f, 147f, 195f, 30f, delegate { weightTab = 0; settingsPage = 0; uiKey = ""; }, (weightTab == 0) ? Gold : Color32.op_Implicit(new Color32((byte)225, (byte)231, (byte)200, byte.MaxValue)), active: true, null, "Rarity Weights", 17f); SetupAction((Transform)(object)panel, 232f, 147f, 195f, 30f, delegate { weightTab = 1; settingsPage = 0; uiKey = ""; }, (weightTab == 1) ? Gold : Color32.op_Implicit(new Color32((byte)225, (byte)231, (byte)200, byte.MaxValue)), active: true, null, "Modifier Weights", 17f); Label((Transform)(object)panel, 464f, 153f, 185f, 24f, "0 excludes a choice", 12f, Muted); if (weightTab == 0) { DrawPhaseWeights(panel, active); return; } foreach (ModifierDefinition item in from d in UiRegistry.Definitions orderby d.Rarity, d.Name select d) { object obj; if (!active) { obj = new SettingRow { Name = item.Name }; object obj2 = obj; RunSnapshot view = View; ((SettingRow)obj2).Value = ((view != null) ? view.Progression.Weight(item.Id) : 100).ToString(); } else { obj = IntRow(item.Name + (modifierEnabled[item.Id].Value ? "" : " (disabled)"), modifierWeights[item.Id], 0, 10000, 25); } list.Add((SettingRow)obj); } } if (pauseTab == 1) { settingsPage = Math.Max(0, Math.Min(settingsPage, 2)); int[] groups = ((settingsPage != 0) ? ((settingsPage != 1) ? new int[1] { 4 } : new int[2] { 2, 3 }) : new int[2] { 0, 1 }); float y = 147f; int[] array2 = groups; foreach (int group in array2) { if (group == 1) { SettingRow[] rows = list.Where((SettingRow r) => SetupPresentation.RunSection(r.Name) == 1 && !r.Name.StartsWith("Boss", StringComparison.Ordinal)).ToArray(); DrawSettingGroup(panel, ref y, "Skips", "Control how skips work during the run.", SetupGlyph.Skips, rows, active); SettingRow[] rows2 = list.Where((SettingRow r) => r.Name.StartsWith("Boss", StringComparison.Ordinal)).ToArray(); DrawSettingGroup(panel, ref y, "Bosses", "Settings for one-hole encounters.", SetupGlyph.Crown, rows2, active); } else { SettingRow[] rows3 = list.Where((SettingRow r) => SetupPresentation.RunSection(r.Name) == group).ToArray(); string name = ((group == 0) ? "Run" : ((group == 2) ? "Voting" : ((group == 3) ? "Advanced" : "Progression"))); string caption = ((group == 0) ? "Core settings for how RogueGolf runs work." : ((group == 2) ? "Timing and one normal vote per player." : ((group == 3) ? "Optional automatic skips and reproducible seeds." : "Course phases and Custom density tuning."))); DrawSettingGroup(panel, ref y, name, caption, (group != 0) ? ((group == 2) ? SetupGlyph.Clock : SetupGlyph.Gear) : SetupGlyph.Flag, rows3, active); } } SettingRow settingRow = list.FirstOrDefault((SettingRow r) => groups.Contains(SetupPresentation.RunSection(r.Name))); SetupHelpBox(panel, (settingRow == null) ? "Next-course settings" : SettingTitle(settingRow.Name), (settingRow == null) ? "Captured host settings appear when a run starts." : SetupPresentation.Help(settingRow.Name)); SetupFooter(panel, settingsPage, 3, delegate { settingsPage--; uiKey = ""; }, delegate { settingsPage++; uiKey = ""; }); return; } int num3 = ((pauseTab == 3) ? 9 : 10); int num4 = Math.Max(1, (list.Count + num3 - 1) / num3); settingsPage = Math.Max(0, Math.Min(settingsPage, num4 - 1)); SettingRow[] array3 = list.Skip(settingsPage * num3).Take(num3).ToArray(); float y2 = ((pauseTab == 3) ? 147 : 187); if (pauseTab == 3) { DrawSettingGroup(panel, ref y2, "Custom Items", "Optional additions. RogueGolf works normally without them.", SetupGlyph.Flag, array3, active); } else { for (int num5 = 0; num5 < array3.Length; num5++) { DrawSetting(panel, array3[num5], y2 + (float)(num5 * 31), active); } } if (pauseTab == 3 && list.Count == 1) { SetupArt((Transform)(object)panel, 291f, 275f, 94f, SetupGlyph.Golf, null, 0.45f); ((TMP_Text)SetupHeading((Transform)(object)panel, 85f, 376f, 514f, 34f, "A clean item pool.", 25f)).alignment = (TextAlignmentOptions)514; ((TMP_Text)Label((Transform)(object)panel, 100f, 420f, 485f, 62f, "Custom Items are OFF. Enable the host switch to configure Leaf Blower, Green Protector, Capture Ball and Gravity Swapper.", 16f, Muted)).alignment = (TextAlignmentOptions)514; } SetupHelpBox(panel, (pauseTab == 3) ? "Custom Items" : "Modifier weights", (pauseTab == 3) ? SetupPresentation.Help("Custom Items") : "Relative weight within the selected tier. Zero excludes a card; compatibility and enabled state still apply."); SetupFooter(panel, settingsPage, num4, delegate { settingsPage--; uiKey = ""; }, delegate { settingsPage++; uiKey = ""; }); } private static string SettingTitle(string name) { return name switch { "RogueGolf enabled" => "RogueGolf Enabled", "Modifier density" => "Modifier Density", "Candidate cards" => "Candidate Cards", "Skip budget" => "Skip Budget Mode", "Starting skips" => "Starting Skips", "Skip effect" => "Skip Behavior", "Boss selections" => "Boss Modifiers", "Boss interval (rounds)" => "Boss Frequency", _ => char.ToUpperInvariant(name[0]) + name.Substring(1), }; } private void DrawSettingGroup(RectTransform panel, ref float y, string name, string caption, SetupGlyph icon, SettingRow[] rows, bool host) { SetupSection(panel, y, name, caption, icon, rows.Length); for (int i = 0; i < rows.Length; i++) { DrawSetting(panel, rows[i], y + 35f + (float)(i * 28), host); } y += 44 + rows.Length * 28; } private void DrawSetting(RectTransform panel, SettingRow row, float y, bool host) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Invalid comparison between Unknown and I4 //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Invalid comparison between Unknown and I4 //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) SetupSurface((Transform)(object)panel, 34f, y, 612f, 25f, SetupRow, 8f); Label((Transform)(object)panel, 44f, y + 2f, 184f, 22f, SettingTitle(row.Name), 14f, null, bold: true); Label((Transform)(object)panel, 237f, y + 3f, 220f, 21f, SetupPresentation.ShortDescription(row.Name), 11f, Muted); int count = uiActions.Count; if ((int)row.Kind == 1) { bool flag = row.Value == "On"; ScorecardShape scorecardShape = SetupAction((Transform)(object)panel, 538f, y + 1f, 106f, 23f, delegate { if (NetworkServer.active) { row.Next?.Invoke(); } }, flag ? Green : Color32.op_Implicit(new Color32((byte)209, (byte)212, (byte)187, byte.MaxValue)), host); ((TMP_Text)Label(((Component)scorecardShape).transform, flag ? 6 : 28, 1f, 70f, 21f, flag ? "On" : "Off", 14f, flag ? Color.white : Ink, bold: true)).alignment = (TextAlignmentOptions)514; SetupSurface(((Component)scorecardShape).transform, flag ? 84 : 4, 3f, 18f, 18f, new Color(0f, 0f, 0f, 0.12f), 9f); SetupSurface(((Component)scorecardShape).transform, flag ? 83 : 3, 2f, 18f, 18f, Color.white, 9f); } else { bool flag2 = (int)row.Kind != 2; SetupAction((Transform)(object)panel, 473f, y + 1f, 24f, 24f, delegate { if (NetworkServer.active) { row.Previous?.Invoke(); } }, Gold, host, flag2 ? SetupGlyph.Minus : SetupGlyph.Left); if (flag2) { SetupSurface((Transform)(object)panel, 502f, y + 1f, 117f, 24f, SetupBorder, 8f); SetupSurface((Transform)(object)panel, 504f, y + 3f, 113f, 20f, SetupCream, 6f); } string value = ((row.Name.StartsWith("Boss interval", StringComparison.Ordinal) && row.Value != "Off") ? ("Every " + row.Value + " rounds") : row.Value.Replace(" For ", " for ")); ((TMP_Text)Label((Transform)(object)panel, 501f, y + 1f, 120f, 24f, value, 14f, null, bold: true)).alignment = (TextAlignmentOptions)514; SetupAction((Transform)(object)panel, 623f, y + 1f, 24f, 24f, delegate { if (NetworkServer.active) { row.Next?.Invoke(); } }, Gold, host, flag2 ? SetupGlyph.Plus : SetupGlyph.Right); } for (int num = count; num < uiActions.Count; num++) { uiActions[num].Help = SetupPresentation.Help(row.Name); uiActions[num].HelpName = SettingTitle(row.Name); } } private void DrawPhaseWeights(RectTransform panel, bool host) { //IL_05a6: Unknown result type (might be due to invalid IL or missing references) //IL_05b5: Unknown result type (might be due to invalid IL or missing references) //IL_05ba: Unknown result type (might be due to invalid IL or missing references) //IL_05d0: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05e4: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) string[] array = new string[5] { "Early", "Early-mid", "Mid-late", "Late", "Boss Selection" }; string[] array2 = new string[5] { "Early game cards,\nmore common finds.", "Ramping up variety\nas you progress.", "Higher chance for\nrarer cards.", "End game pushes\nmore powerful cards.", "Choose Legendary\nor Boss cards." }; for (int i = 0; i < 5; i++) { float num = 187 + i * 74; int num2 = ((i == 4) ? 12 : (i * 3)); int num3 = ((i == 4) ? 2 : 3); SetupSurface((Transform)(object)panel, 28f, num, 624f, 68f, SetupBorder); SetupSurface((Transform)(object)panel, 30f, num + 2f, 620f, 64f, SetupRow, 10f); SetupPicture((Transform)(object)panel, 39f, num + 10f, 26f, 39f, (new string[5] { "early-flag", "early-mid-flag", "mid-late-flag", "late-flag", "boss-crown" })[i]); Label((Transform)(object)panel, 73f, num + 5f, 103f, 27f, array[i], (i == 4) ? 13 : 16, null, bold: true); Label((Transform)(object)panel, 73f, num + 31f, 104f, 32f, array2[i], 10f, Muted); int[] array3 = Enumerable.Range(num2, num3).Select(delegate(int num11) { if (!host) { RunSnapshot view = View; if (view == null) { return 0; } return view.Progression.TierWeights[num11]; } return tierWeights[num11].Value; }).ToArray(); double[] array4 = SetupPresentation.Percentages(array3); for (int num4 = 0; num4 < num3; num4++) { int index = num2 + num4; int num5 = ((i == 4) ? (num4 + 2) : num4); float num6 = 182 + num4 * ((i == 4) ? 146 : 98); SetupSurface((Transform)(object)panel, num6 - 7f, num + 8f, 1f, 51f, SetupBorder, 0f); SetupSurface((Transform)(object)panel, num6 + 1f, num + 10f, 8f, 8f, SetupTierColor(num5), 4f); Label((Transform)(object)panel, num6 + 13f, num + 5f, 82f, 21f, ((object)(ModifierRarity)num5/*cast due to .constrained prefix*/).ToString(), 11f, null, bold: true); SetupAction((Transform)(object)panel, num6, num + 32f, 23f, 23f, delegate { tierWeights[index].Value = Math.Max(0, tierWeights[index].Value - 5); SaveUiConfig(); }, Gold, host, SetupGlyph.Minus); ((TMP_Text)Label((Transform)(object)panel, num6 + 24f, num + 30f, 41f, 27f, array3[num4].ToString(), 16f, null, bold: true)).alignment = (TextAlignmentOptions)514; SetupAction((Transform)(object)panel, num6 + 66f, num + 32f, 23f, 23f, delegate { tierWeights[index].Value = Math.Min(10000, tierWeights[index].Value + 5); SaveUiConfig(); }, Gold, host, SetupGlyph.Plus); } SetupSurface((Transform)(object)panel, 477f, num + 8f, 1f, 51f, SetupBorder, 0f); ScorecardShape scorecardShape = SetupSurface((Transform)(object)panel, 490f, num + 18f, 148f, 18f, SetupBorder, 9f); ((Component)scorecardShape).gameObject.AddComponent().showMaskGraphic = true; float num7 = 0f; for (int num8 = 0; num8 < num3; num8++) { float num9 = (float)(array4[num8] * 1.48); if (num9 > 0f) { SetupSurface(((Component)scorecardShape).transform, num7, 0f, num9, 18f, SetupTierColor((i == 4) ? (num8 + 2) : num8), 0f); } num7 += num9; } for (int num10 = 0; num10 < num3; num10++) { ((TMP_Text)Label((Transform)(object)panel, 487f + (float)num10 * (148f / (float)num3), num + 40f, 148f / (float)num3, 23f, array4[num10].ToString("0") + "%", 12f, null, bold: true)).alignment = (TextAlignmentOptions)514; } } SetupHelpBox(panel, "How rarity weights work", "Each card draws a tier first, then a modifier within that tier. Values are raw relative weights; bars show normalized percentages."); SetupArt((Transform)(object)panel, 40f, 566f, 22f, SetupGlyph.Info); RectTransform rectTransform = ((TMP_Text)settingsHelpName).rectTransform; rectTransform.anchoredPosition += new Vector2(25f, 0f); RectTransform rectTransform2 = ((TMP_Text)settingsHelpName).rectTransform; rectTransform2.sizeDelta -= new Vector2(25f, 0f); SetupFooter(panel, 0, 2, delegate { }, delegate { weightTab = 1; settingsPage = 0; uiKey = ""; }); } private void DrawSetupHelp(RectTransform panel) { DrawTutorial(panel); } private void DrawResetConfirmation(RectTransform panel) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) SetupHeading((Transform)(object)panel, 40f, 194f, 600f, 62f, "RESET ROGUEGOLF TO DEFAULTS?", 25f); Label((Transform)(object)panel, 44f, 282f, 592f, 142f, "Restores run settings, weights, modifier tuning and custom-item settings. Changes apply next course.\n\nThe current captured run stays unchanged. Custom Items will be OFF next course.", 21f, Muted); Button((Transform)(object)panel, 126f, 465f, 195f, 42f, "Reset All", ResetGameplayDefaults, Gold, NetworkServer.active); Button((Transform)(object)panel, 353f, 465f, 195f, 42f, "Cancel", delegate { resetConfirmation = false; selected = 0; uiKey = ""; }, Paper); } private void ResetGameplayDefaults() { if (!NetworkServer.active) { return; } if (!Run.Active) { CustomItemRuntime customItemRuntime = customItems; if (customItemRuntime == null || !customItemRuntime.Playing) { goto IL_0040; } } PreserveLiveSettings(); customItems?.PreserveSettingsUntilNextCourse(); goto IL_0040; IL_0040: int num = DefaultsConfig.Reset(((BaseUnityPlugin)this).Config); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[CONFIG] Explicit reset: " + num + " gameplay settings; next course only")); resetConfirmation = false; settingsPage = 0; selected = 0; SaveUiConfig(); ShowNotice("Shipped defaults saved for the next course. Custom Items OFF."); } private void ConfigureTestingMenu() { testingKey = ((BaseUnityPlugin)this).Config.Bind("Diagnostics", "TestingMenuKey", (Key)99, "Host testing menu key, only while the native console is open with Console Commands enabled in a private driving range or playing hole."); try { NativeHook(typeof(DevConsoleGui), "OnGUI", "AllowConsoleGui"); testingUiReady = true; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[TEST] Testing menu unavailable: " + ex.Message)); } } private static bool AllowConsoleGui() { if (!((Object)(object)Instance == (Object)null)) { if (!Instance.testingOpen) { return Time.frameCount != Instance.consoleSuppressFrame; } return false; } return true; } private bool CanUseTestingMenu(out string reason) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Invalid comparison between Unknown and I4 reason = ""; if (!testingUiReady || !((Behaviour)this).enabled || !enabledMode.Value || !NetworkServer.active) { reason = "Only the active RogueGolf host can use the testing menu."; return false; } if (!DevConsoleGui.Active || !MatchSetupRules.IsCheatsEnabled()) { reason = "Enable Console Commands and open the console first."; return false; } if (bridge == null || !bridge.CanStart(out reason)) { return false; } if (InDrivingRange && stage.Value == PrototypeStage.Modifiers && !Run.Active) { return true; } if (runStage != PrototypeStage.Modifiers || (int)Run.State != 3 || modifiers == null) { reason = "Start a RogueGolf course and enter a playing hole first."; return false; } return true; } private void BeginRangeTesting() { if (InDrivingRange && !RangeTesting) { uint seedValue = (uint)DateTime.UtcNow.Ticks; runStage = PrototypeStage.Modifiers; BeginProgression(seedValue); BeginModifiers(seedValue); testingRangeId = "range-test-" + Guid.NewGuid().ToString("N"); StartHoleEffects(0); Publish(); } } private void EndRangeTesting() { if (RangeTesting) { ClearRunResources(); Publish(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[TEST] Driving-range effects cleared"); } } private void UpdateRangeTesting() { if (RangeTesting && (!NetworkServer.active || !InDrivingRange || Run.Active || !enabledMode.Value || !MatchSetupRules.IsCheatsEnabled() || !bridge.CanStart(out var _))) { EndRangeTesting(); } } private void CloseTestingMenu() { testingOpen = false; consoleSuppressFrame = Time.frameCount; uiKey = ""; selected = 0; } private void OpenTestingMenu() { if (!CanUseTestingMenu(out var reason)) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[TEST] " + reason)); return; } try { BeginRangeTesting(); } catch (Exception ex) { EndRangeTesting(); ((BaseUnityPlugin)this).Logger.LogWarning((object)("[TEST] " + ex.Message)); return; } SetUiFocus(value: false); setupOpen = false; testingOpen = true; testingDraft.Clear(); ActiveModifier[] active = modifiers.Active; foreach (ActiveModifier val in active) { testingDraft.Add(val.Id); } testingPage = 0; testingDetail = ""; testingMessage = "Choose modifiers, then Apply stack. Changes affect everyone."; selected = 0; uiKey = ""; } private bool UpdateTestingInput() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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) if (testingOpen && !CanUseTestingMenu(out var _)) { CloseTestingMenu(); } if (!Application.isFocused) { return testingOpen; } if ((InputManager.CurrentModeMask & 0xC80) != 0) { return testingOpen; } Keyboard current = Keyboard.current; if (testingKey != null && (int)testingKey.Value != 0 && current != null && ((ButtonControl)current[testingKey.Value]).wasPressedThisFrame && DevConsoleGui.Active) { if (testingOpen) { CloseTestingMenu(); } else { OpenTestingMenu(); } return true; } if (!testingOpen) { return false; } Gamepad current2 = Gamepad.current; if ((current != null && ((ButtonControl)current.escapeKey).wasPressedThisFrame) || (current2 != null && current2.buttonEast.wasPressedThisFrame)) { CloseTestingMenu(); return true; } Mouse mouse = Mouse.current; if (mouse != null && mouse.leftButton.wasPressedThisFrame) { UiAction uiAction = uiActions.LastOrDefault((UiAction a) => RectTransformUtility.RectangleContainsScreenPoint(a.Rect, ((InputControl)(object)((Pointer)mouse).position).ReadValue())); if (uiAction != null) { uiAction.Run(); uiKey = ""; return true; } } if ((current != null && ((ButtonControl)current.rightArrowKey).wasPressedThisFrame) || (current != null && ((ButtonControl)current.tabKey).wasPressedThisFrame) || (current2 != null && current2.dpad.down.wasPressedThisFrame)) { selected++; } if ((current != null && ((ButtonControl)current.leftArrowKey).wasPressedThisFrame) || (current2 != null && current2.dpad.up.wasPressedThisFrame)) { selected--; } if (uiActions.Count > 0) { selected = (selected % uiActions.Count + uiActions.Count) % uiActions.Count; if ((current != null && ((ButtonControl)current.enterKey).wasPressedThisFrame) || (current2 != null && current2.buttonSouth.wasPressedThisFrame)) { uiActions[selected].Run(); uiKey = ""; } } return true; } private string TestUnavailable(ModifierDefinition d) { //IL_0001: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if ((EffectChannel)(d.Channel & Capabilities) != d.Channel) { return "Required game hooks unavailable"; } if (!AllowsContext(d)) { return "Requires a course with native traffic"; } return ""; } private void TestAction(Action action, string success) { if (!CanUseTestingMenu(out var reason)) { testingMessage = reason; CloseTestingMenu(); return; } try { action(); testingMessage = success; ((BaseUnityPlugin)this).Logger.LogInfo((object)("[TEST] " + success)); Publish(); } catch (Exception ex) { testingMessage = ex.Message; ((BaseUnityPlugin)this).Logger.LogWarning((object)("[TEST] " + ex.Message)); } uiKey = ""; } private void ApplyTestingStack(IEnumerable ids) { string[] copy = ids.ToArray(); TestAction(delegate { //IL_002c: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) ModifierManager val = TestStack.Build(ModifierRegistry.Create(modifierSettings), (IEnumerable)copy, TestHole, progression.Persistence, Capabilities, (Func)AllowsContext); RestoreEffects(); modifiers = val; ApplyEffects(EffectRunId, gravityBaseline, modifiers.Values); StartHoleEffects(TestHole); TickWorldEffects(); testingDraft.Clear(); string[] array = copy; foreach (string item in array) { testingDraft.Add(item); } }, "Applied test stack (" + copy.Length + "). Durations, cycles and starting items restarted."); } private void DrawTestingMenu() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0607: Unknown result type (might be due to invalid IL or missing references) //IL_063e: Unknown result type (might be due to invalid IL or missing references) //IL_0675: Unknown result type (might be due to invalid IL or missing references) //IL_06ac: Unknown result type (might be due to invalid IL or missing references) //IL_06e3: Unknown result type (might be due to invalid IL or missing references) //IL_071a: Unknown result type (might be due to invalid IL or missing references) //IL_0751: Unknown result type (might be due to invalid IL or missing references) //IL_0788: Unknown result type (might be due to invalid IL or missing references) //IL_07c4: Unknown result type (might be due to invalid IL or missing references) //IL_0806: Unknown result type (might be due to invalid IL or missing references) //IL_0842: Unknown result type (might be due to invalid IL or missing references) //IL_05bb: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) Shape((Transform)(object)uiContent, 0f, 0f, 1280f, 720f, new Color(0f, 0f, 0f, 0.8f), 0f, block: true); RectTransform parent = Panel((Transform)(object)uiContent, 100f, 40f, 1080f, 640f, Paper); Label((Transform)(object)parent, 24f, 16f, 800f, 45f, "RogueGolf · Host testing", 32f, null, bold: true); Button((Transform)(object)parent, 888f, 23f, 168f, 34f, "Back to console", CloseTestingMenu, Gold); Label((Transform)(object)parent, 24f, 67f, 1020f, 40f, (RangeTesting ? "Driving range" : "Private course") + " · applies to all players · test selections bypass offer weights and enable switches", 16f, Muted); ModifierDefinition[] array = (from d in ModifierRegistry.Create(modifierSettings).Definitions orderby d.Rarity, d.Name select d).ToArray(); int num = (array.Length + 7) / 8; testingPage = Math.Max(0, Math.Min(testingPage, num - 1)); for (int num2 = 0; num2 < 8 && testingPage * 8 + num2 < array.Length; num2++) { ModifierDefinition val = array[testingPage * 8 + num2]; float num3 = 115 + num2 * 49; string id = val.Id; bool chosen = testingDraft.Contains(id); string text = TestUnavailable(val); Shape((Transform)(object)parent, 20f, num3, 508f, 45f, Color32.op_Implicit(new Color32((byte)244, (byte)239, (byte)210, byte.MaxValue)), 8f); Icon((Transform)(object)parent, 28f, num3 + 6f, 32f, val); Label((Transform)(object)parent, 72f, num3 + 3f, 265f, 25f, val.Name, 18f, Ink, bold: true); Label((Transform)(object)parent, 72f, num3 + 26f, 265f, 18f, (text == "") ? ((object)val.Rarity/*cast due to .constrained prefix*/).ToString() : text, 12f, Muted); Button((Transform)(object)parent, 340f, num3 + 7f, 82f, 31f, "Info", delegate { testingDetail = id; }, Gold); Button((Transform)(object)parent, 430f, num3 + 7f, 88f, 31f, chosen ? "Remove" : "Add", delegate { if (chosen) { testingDraft.Remove(id); } else { testingDraft.Add(id); } }, chosen ? Gold : Green, chosen || text == ""); } Button((Transform)(object)parent, 24f, 517f, 112f, 32f, "Previous", delegate { testingPage--; selected = 0; }, null, testingPage > 0); Label((Transform)(object)parent, 154f, 522f, 225f, 26f, "Page " + (testingPage + 1) + " / " + num + " · " + testingDraft.Count + " selected", 16f, Muted); Button((Transform)(object)parent, 406f, 517f, 112f, 32f, "Next", delegate { testingPage++; selected = 0; }, null, testingPage < num - 1); ModifierDefinition detail = ((IEnumerable)array).FirstOrDefault((Func)((ModifierDefinition d) => d.Id == testingDetail)); ModifierDefinition obj = detail; Label((Transform)(object)parent, 553f, 112f, 490f, 45f, ((obj != null) ? obj.Name : null) ?? "Choose an effect", 27f, null, bold: true); Label((Transform)(object)parent, 553f, 165f, 480f, 210f, (detail == null) ? "Add/remove effects to build a draft stack. Apply stack replaces the current effects.\n\nConflicting groups are rejected before any change. Unsupported effects stay listed with a reason." : EffectPresentation.Details(detail, modifierSettings, ((IEnumerable)modifiers.Active).FirstOrDefault((Func)((ActiveModifier e) => e.Id == detail.Id))), 18f); if (detail != null) { Button((Transform)(object)parent, 553f, 389f, 240f, 35f, "Apply this effect only", delegate { ApplyTestingStack(new string[1] { detail.Id }); }, Gold, TestUnavailable(detail) == ""); } Button((Transform)(object)parent, 553f, 439f, 232f, 38f, "Apply stack", delegate { ApplyTestingStack(testingDraft); }, Green); Button((Transform)(object)parent, 803f, 439f, 232f, 38f, "Clear all effects", delegate { ApplyTestingStack(Array.Empty()); }, Gold); Button((Transform)(object)parent, 553f, 491f, 232f, 35f, "Trigger cycle", delegate { TestAction(delegate { nextWorldTick = 0.0; TickWorldEffects(); }, "Triggered host cycle"); }, Gold); Button((Transform)(object)parent, 803f, 491f, 232f, 35f, "Reload active stack", delegate { testingDraft.Clear(); ActiveModifier[] active = modifiers.Active; foreach (ActiveModifier val2 in active) { testingDraft.Add(val2.Id); } testingMessage = "Draft copied from active effects."; }, Green); Button((Transform)(object)parent, 553f, 535f, 152f, 28f, "Thunder nearby", delegate { TestAction(delegate { SpawnThunderProof(here: false); }, "One vanilla storm spawned nearby. Its lightning can hit players."); }, Gold); Button((Transform)(object)parent, 718f, 535f, 152f, 28f, "Thunder here", delegate { TestAction(delegate { SpawnThunderProof(here: true); }, "One vanilla storm centered here. Its lightning can hit players."); }, Gold); Button((Transform)(object)parent, 883f, 535f, 152f, 28f, "Stop thunder", delegate { TestAction(StopThunderProof, "Test storm cancelled."); }, Green); Button((Transform)(object)parent, 553f, 570f, 152f, 28f, "Spawn dummy", delegate { TestAction(SpawnDummy, "Training golfer spawned. Close console to hit it."); }, Gold, dummyHooks); Button((Transform)(object)parent, 718f, 570f, 152f, 28f, "Reset dummy", delegate { TestAction(ResetDummy, "Training golfer reset."); }, Gold, (Object)(object)dummy != (Object)null); Button((Transform)(object)parent, 883f, 570f, 152f, 28f, "Remove dummy", delegate { TestAction(RemoveDummy, "Training golfer removed."); }, Green, (Object)(object)dummy != (Object)null); Label((Transform)(object)parent, 24f, 608f, 1020f, 28f, testingMessage, 15f, Ink); } private void ProbeLateBallSkin() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_004a: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) GolfBall ownBall = Players().First().AsGolfer.OwnBall; BindShape(ownBall); GameObject val = new GameObject("RogueGolf late mesh probe"); GameObject val2 = new GameObject("RogueGolf late skinned probe"); try { val.transform.SetParent(((Component)ownBall).transform, false); val.transform.localScale = Vector3.one * 0.7f; val.AddComponent(); val2.transform.SetParent(((Component)ownBall).transform, false); val2.transform.localScale = Vector3.one * 0.4f; val2.AddComponent(); MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(GolfBall), "OnModelOverride", (Type[])null, (Type[])null); methodInfo.Invoke(ownBall, null); methodInfo.Invoke(ownBall, null); float num = ((EffectValues)(ref effects))[(Parameter)3]; if (Math.Abs(val.transform.localScale.x - 0.7f * num) > 0.001f || Math.Abs(val2.transform.localScale.x - 0.4f * num) > 0.001f) { throw new InvalidOperationException("Late visual scale incorrect or compounded"); } shapes[ownBall].Apply(1f); if (Math.Abs(val.transform.localScale.x - 0.7f) > 0.001f || Math.Abs(val2.transform.localScale.x - 0.4f) > 0.001f) { throw new InvalidOperationException("Late visual baseline restore failed"); } shapes[ownBall].Apply(num); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[LAB] Late mesh/skinned visual scale and repeat-refresh/restore passed factor=" + num)); } finally { Object.Destroy((Object)(object)val); Object.Destroy((Object)(object)val2); } } private void ProbePlayerImpact() { //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_021a: 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) if (!HasRule((Mechanic)128)) { throw new InvalidOperationException("Apply explosive_collisions first"); } PlayerInfo val = Players().First(); Hittable asHittable = val.AsEntity.AsHittable; ResetImpactTracking(); nextExplosion = 0.0; PlayerItemImpact(asHittable, (ItemType)5, val.Inventory, canHitWithNoUser: false); PlayerItemImpact(asHittable, (ItemType)3, val.Inventory, canHitWithNoUser: false); PlayerClubImpact(asHittable, 1f, val.AsGolfer); PlayerProjectileImpact(asHittable, val.AsGolfer.OwnBall.AsEntity.AsHittable, 1f, val.AsGolfer); PlayerVehicleImpact(val.Movement, (KnockoutType)5); if (pendingPlayerImpacts.Count != 0) { throw new InvalidOperationException("Self/movement impact exclusions failed"); } PlayerVehicleImpact(val.Movement, (KnockoutType)6); if (pendingPlayerImpacts.Count != 1) { throw new InvalidOperationException("Vehicle impact was not queued"); } pendingPlayerImpacts.Clear(); Hittable asHittable2 = val.AsGolfer.OwnBall.AsEntity.AsHittable; creatingExplosion = true; explosionSource = asHittable; explosionRecipientOnly = true; try { if (!AllowExplosionTarget(asHittable, (ItemType)7) || AllowExplosionTarget(asHittable2, (ItemType)7) || ((Object)(object)dummy != (Object)null && AllowExplosionTarget(dummy.AsHittable, (ItemType)7))) { throw new InvalidOperationException("Recipient-only blast filter failed"); } if (!AllowExplosionTarget(asHittable2, (ItemType)2) || ImpactBlocked(asHittable2)) { throw new InvalidOperationException("Blast filter affected unrelated hits or excluded ball rearm"); } } finally { creatingExplosion = false; explosionSource = null; explosionRecipientOnly = false; ResetImpactTracking(); } int num = explosionsThisHole; int rocketHits = 0; int ballHits = 0; Action action = delegate(PlayerInventory a, ItemType b, ItemUseId c, Vector3 d, float e, Vector3 f, bool g, bool h, ProtectiveState i) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)b == 7) { ballHits++; } }; asHittable2.WillApplyItemHitPhysics += action; Action action2 = delegate(PlayerInventory a, ItemType b, ItemUseId c, Vector3 d, float e, Vector3 f, bool g, bool h, ProtectiveState i) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)b == 7) { rocketHits++; } }; asHittable.WillApplyItemHitPhysics += action2; try { AccessTools.DeclaredMethod(typeof(Hittable), "HitWithItemInternal", (Type[])null, (Type[])null).Invoke(asHittable, new object[11] { (object)(ItemType)2, ItemUseId.Invalid, Vector3.zero, Vector3.up, Vector3.zero, 0f, null, false, false, true, NetworkTime.time }); if (pendingPlayerImpacts.Count != 1) { throw new InvalidOperationException("Native player hit was not queued"); } TickImpactTracking(); if (explosionsThisHole != num + 1 || rocketHits != 1 || ballHits != 0 || !ImpactBlocked(asHittable) || explosionRecipientOnly || (Object)(object)explosionSource != (Object)null || creatingExplosion) { throw new InvalidOperationException("Player impact recipient-only targeting/rearm/scope cleanup failed"); } QueuePlayerImpact(asHittable); nextExplosion = 0.0; TickImpactTracking(); if (explosionsThisHole != num + 1) { throw new InvalidOperationException("Blast victim retriggered"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"[LAB] Native player hit queued one blast; recipient rocket hits=1; ball rocket hits=0; recursive trigger blocked"); } finally { asHittable.WillApplyItemHitPhysics -= action2; asHittable2.WillApplyItemHitPhysics -= action; } } private void ConfigureIntermission() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown stage = ((BaseUnityPlugin)this).Config.Bind("General", "Stage", PrototypeStage.Modifiers, "Modifiers (canonical catalogue), Voting (dummy cards), Intermission, or Lifecycle."); holdSeconds = ((BaseUnityPlugin)this).Config.Bind("Intermission", "DurationSeconds", 5f, new ConfigDescription("Phase 2 automatic hold duration.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 60f), Array.Empty())); nextMethod = AccessTools.DeclaredMethod(typeof(CourseManager), "ServerStartNextMatch", new Type[1] { typeof(bool) }, (Type[])null); } private bool InterceptNext(CourseManager manager, bool skipInventories) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Invalid comparison between Unknown and I4 if (releasing || !NetworkServer.active || !Run.Active || runStage == PrototypeStage.Lifecycle || Run.HoleIndex < 0) { return true; } if (gate.WasIntercepted(Run.RunId, Run.HoleIndex)) { return false; } if ((int)Run.State != 4) { return true; } if (!bridge.CanStart(out notice)) { ShowNotice(notice); ClearRunResources(); Run.Stop("PeerNotCompatible"); return true; } if (runStage == PrototypeStage.Modifiers && modifiers == null) { return true; } string id = Run.RunId; int hole = Run.HoleIndex; gate.Hold(id, hole, (Action)delegate { releasing = true; try { nextMethod.Invoke(manager, new object[1] { skipInventories }); } finally { releasing = false; } }, (Func)(() => (Object)(object)manager != (Object)null && NetworkServer.active && Run.RunId == id && Run.HoleIndex == hole && Run.Active)); releaseAt = NetworkTime.time + (double)holdSeconds.Value; NextMatchCountdown.Hide(); VoteCoordinator obj = voting; if (obj != null) { obj.ClearVote(); } if (runStage == PrototypeStage.Modifiers) { int num = Run.HoleIndex + 2; int num2 = ((num > densityPlan.Length) ? 1 : densityPlan[num - 1]); roundSelections.Begin(num2, progression.IsBoss(roundSelections.RoundOrdinal + 1)); } Run.Transition((RunState)4, (RunState)5, "IntermissionHeld"); if (runStage == PrototypeStage.Voting || runStage == PrototypeStage.Modifiers) { OpenVote(); } return false; } private void ReleaseIntermission() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (gate.Held && NetworkServer.active) { Run.Transition(Run.State, (RunState)2, "IntermissionReleased"); if (!gate.Release()) { ClearRunResources(); Run.Stop("InvalidTransitionTarget"); } } } private void Update() { UpdateRangeTesting(); bridge?.Update(); TickRateCompatibility(); TickCustomItems(); UpdateUIInput(); TickWorldEffects(); TickThunderProof(); TickActiveEvents(); TickDunkGolf(); TickLab(); TickDummy(); if (NetworkServer.active && Run.Active && !enabledMode.Value) { ReleaseIntermission(); ClearRunResources(); Run.Stop("Disabled"); } if (runStage == PrototypeStage.Voting || runStage == PrototypeStage.Modifiers) { TickVote(); } else if (gate.Held && NetworkTime.time >= releaseAt) { ReleaseIntermission(); } } private void ConfigureLab() { labCommands = ((BaseUnityPlugin)this).Config.Bind("Diagnostics", "LabCommands", false, "Solo private host only: process RogueGolf.lab.txt in this profile config directory. Testing only."); } private unsafe void TickLab() { //IL_0d99: Unknown result type (might be due to invalid IL or missing references) //IL_0da7: Unknown result type (might be due to invalid IL or missing references) //IL_123d: Unknown result type (might be due to invalid IL or missing references) //IL_1246: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Invalid comparison between Unknown and I4 //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Expected O, but got Unknown //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Expected O, but got Unknown //IL_0541: Unknown result type (might be due to invalid IL or missing references) //IL_054c: Unknown result type (might be due to invalid IL or missing references) //IL_0858: Unknown result type (might be due to invalid IL or missing references) //IL_085d: Unknown result type (might be due to invalid IL or missing references) //IL_087f: Unknown result type (might be due to invalid IL or missing references) //IL_0884: Unknown result type (might be due to invalid IL or missing references) //IL_0725: Unknown result type (might be due to invalid IL or missing references) //IL_072a: Unknown result type (might be due to invalid IL or missing references) //IL_09a5: Unknown result type (might be due to invalid IL or missing references) //IL_09aa: Unknown result type (might be due to invalid IL or missing references) //IL_067a: Unknown result type (might be due to invalid IL or missing references) //IL_0685: Unknown result type (might be due to invalid IL or missing references) //IL_08ef: Unknown result type (might be due to invalid IL or missing references) //IL_08f4: Unknown result type (might be due to invalid IL or missing references) //IL_0915: Unknown result type (might be due to invalid IL or missing references) //IL_091a: Unknown result type (might be due to invalid IL or missing references) //IL_0a64: Unknown result type (might be due to invalid IL or missing references) //IL_0a6f: Unknown result type (might be due to invalid IL or missing references) //IL_09d6: Unknown result type (might be due to invalid IL or missing references) //IL_09db: Unknown result type (might be due to invalid IL or missing references) //IL_09e0: Unknown result type (might be due to invalid IL or missing references) //IL_09ea: Unknown result type (might be due to invalid IL or missing references) //IL_09ef: Unknown result type (might be due to invalid IL or missing references) //IL_0a07: Unknown result type (might be due to invalid IL or missing references) //IL_0a18: Unknown result type (might be due to invalid IL or missing references) //IL_0a22: Unknown result type (might be due to invalid IL or missing references) //IL_0c60: Unknown result type (might be due to invalid IL or missing references) //IL_0c65: Unknown result type (might be due to invalid IL or missing references) //IL_0c6f: Unknown result type (might be due to invalid IL or missing references) //IL_0c74: Unknown result type (might be due to invalid IL or missing references) //IL_0c8c: Unknown result type (might be due to invalid IL or missing references) //IL_0c9d: Unknown result type (might be due to invalid IL or missing references) //IL_0abc: Unknown result type (might be due to invalid IL or missing references) //IL_0ae2: Unknown result type (might be due to invalid IL or missing references) //IL_0ce9: Unknown result type (might be due to invalid IL or missing references) //IL_0cee: Unknown result type (might be due to invalid IL or missing references) //IL_0cf2: Unknown result type (might be due to invalid IL or missing references) //IL_0cf4: Unknown result type (might be due to invalid IL or missing references) //IL_0cfe: Unknown result type (might be due to invalid IL or missing references) //IL_0d03: Unknown result type (might be due to invalid IL or missing references) //IL_0d08: Unknown result type (might be due to invalid IL or missing references) //IL_0d31: Unknown result type (might be due to invalid IL or missing references) //IL_0d36: Unknown result type (might be due to invalid IL or missing references) //IL_0d38: Unknown result type (might be due to invalid IL or missing references) //IL_0d42: Unknown result type (might be due to invalid IL or missing references) //IL_0d47: Unknown result type (might be due to invalid IL or missing references) //IL_0d5f: Unknown result type (might be due to invalid IL or missing references) //IL_0d64: Unknown result type (might be due to invalid IL or missing references) //IL_0f3e: Unknown result type (might be due to invalid IL or missing references) //IL_0f43: Unknown result type (might be due to invalid IL or missing references) //IL_0f48: Unknown result type (might be due to invalid IL or missing references) //IL_1010: Unknown result type (might be due to invalid IL or missing references) //IL_1015: Unknown result type (might be due to invalid IL or missing references) //IL_1019: Unknown result type (might be due to invalid IL or missing references) //IL_101e: Unknown result type (might be due to invalid IL or missing references) //IL_1022: Unknown result type (might be due to invalid IL or missing references) //IL_1027: Unknown result type (might be due to invalid IL or missing references) //IL_0fa8: Unknown result type (might be due to invalid IL or missing references) //IL_0fad: Unknown result type (might be due to invalid IL or missing references) //IL_0fb2: Unknown result type (might be due to invalid IL or missing references) //IL_0fb7: Unknown result type (might be due to invalid IL or missing references) //IL_129d: Unknown result type (might be due to invalid IL or missing references) //IL_12a2: Unknown result type (might be due to invalid IL or missing references) //IL_12ac: Unknown result type (might be due to invalid IL or missing references) //IL_12b1: Unknown result type (might be due to invalid IL or missing references) //IL_12c9: Unknown result type (might be due to invalid IL or missing references) //IL_12da: Unknown result type (might be due to invalid IL or missing references) //IL_12e4: Unknown result type (might be due to invalid IL or missing references) //IL_12f5: Unknown result type (might be due to invalid IL or missing references) //IL_10a5: Unknown result type (might be due to invalid IL or missing references) //IL_10a7: Unknown result type (might be due to invalid IL or missing references) //IL_10ac: Unknown result type (might be due to invalid IL or missing references) //IL_10c4: Unknown result type (might be due to invalid IL or missing references) //IL_10d5: Unknown result type (might be due to invalid IL or missing references) //IL_10df: Unknown result type (might be due to invalid IL or missing references) //IL_10fa: Unknown result type (might be due to invalid IL or missing references) //IL_113b: Unknown result type (might be due to invalid IL or missing references) //IL_15ab: Unknown result type (might be due to invalid IL or missing references) //IL_15b0: Unknown result type (might be due to invalid IL or missing references) //IL_15da: Unknown result type (might be due to invalid IL or missing references) //IL_15df: Unknown result type (might be due to invalid IL or missing references) //IL_1604: Unknown result type (might be due to invalid IL or missing references) //IL_1609: Unknown result type (might be due to invalid IL or missing references) //IL_16f5: Unknown result type (might be due to invalid IL or missing references) //IL_1702: Unknown result type (might be due to invalid IL or missing references) //IL_170f: Unknown result type (might be due to invalid IL or missing references) //IL_1714: Unknown result type (might be due to invalid IL or missing references) //IL_1719: Unknown result type (might be due to invalid IL or missing references) //IL_171e: Unknown result type (might be due to invalid IL or missing references) //IL_1722: Unknown result type (might be due to invalid IL or missing references) //IL_172f: Unknown result type (might be due to invalid IL or missing references) ConfigEntry obj = labCommands; if (obj == null || !obj.Value || NetworkTime.time < nextLabRead) { return; } nextLabRead = NetworkTime.time + 0.25; string path = Path.Combine(Paths.ConfigPath, "RogueGolf.lab.txt"); if (!File.Exists(path)) { return; } string text = File.ReadAllText(path).Trim(); File.Delete(path); try { if (!NetworkServer.active || NetworkServer.connections.Count != 1 || bridge == null || !bridge.CanStart(out var _) || (text != "density_probe" && (int)Run.State != 3 && (!InDrivingRange || (!text.StartsWith("dummy_") && !text.StartsWith("custom_"))))) { throw new InvalidOperationException("Lab requires a playing hole in a solo private host run"); } if (text.Length > 256) { throw new ArgumentException("Lab request too long"); } string[] array = text.Split(' '); string text2 = array[0]; switch (text2) { case "density_probe": { ManualLogSource logger = ((BaseUnityPlugin)this).Logger; string[] obj2 = new string[22] { "[DENSITY-PROBE] active=", Run.Active.ToString(), " held=", gate.Held.ToString(), " status=", ((object)roundSelections.Status/*cast due to .constrained prefix*/).ToString(), " round=", roundSelections.RoundOrdinal.ToString(), " pick=", roundSelections.PickIndex.ToString(), "/", roundSelections.PickCount.ToString(), " acquisitions=", roundSelections.AcquisitionOrdinal.ToString(), " vote=", null, null, null, null, null, null, null }; VoteCoordinator obj3 = voting; int? obj4; if (obj3 == null) { obj4 = null; } else { VoteSession vote = obj3.Vote; obj4 = ((vote != null) ? new int?(vote.Id) : ((int?)null)); } int? num = obj4; obj2[15] = num.GetValueOrDefault().ToString(); obj2[16] = " replicaPick="; obj2[17] = (View?.CurrentRoundPickIndex ?? 0).ToString(); obj2[18] = "/"; obj2[19] = (View?.CurrentRoundPickCount ?? 0).ToString(); obj2[20] = " replicaVote="; obj2[21] = (View?.VoteId ?? 0).ToString(); logger.LogInfo((object)string.Concat(obj2)); break; } case "custom_enable": customItems.Registry.Master.Value = true; ((BaseUnityPlugin)this).Config.Save(); break; case "custom_disable": customItems.Registry.Master.Value = false; customItems.Cleanup("lab disable"); ((BaseUnityPlugin)this).Config.Save(); break; case "custom_give": if (array.Length == 2) { customItems.Force(array[1]); break; } goto default; default: switch (text2) { case "custom_gravity": ((BaseUnityPlugin)this).Logger.LogInfo((object)sharedGravity.Inspect()); break; case "custom_probe": customItems.Inspect(); break; case "custom_test": if (array.Length == 2) { customItems.Test(array[1], dummy); break; } goto default; default: switch (text2) { case "custom_clear": customItems.Cleanup("lab cleanup"); break; case "custom_use": { bool flag = default(bool); GameManager.LocalPlayerInfo.Inventory.TryUseItem(false, ref flag); break; } case "apply": if (array.Length == 2) { ModifierRegistry val = ModifierRegistry.Create(modifierSettings); ModifierDefinition val2 = val.Get(array[1]); if (val2 == null || (EffectChannel)(val2.Channel & Capabilities) != val2.Channel) { throw new ArgumentException("Unsupported lab modifier"); } if (val2.Id == "golf_kart_warfare" && Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0).Length == 0) { throw new ArgumentException("No native traffic in current scene"); } RestoreEffects(); modifiers = new ModifierManager(val, val.Definitions.Select((ModifierDefinition d) => d.Id), Capabilities); modifiers.ContextAllows = AllowsContext; if (!modifiers.Activate(val2.Id, Run.HoleIndex, (PersistenceMode)0)) { throw new InvalidOperationException("Lab activation rejected"); } ApplyEffects(Run.RunId, gravityBaseline, modifiers.Values); StartHoleEffects(Run.HoleIndex); Publish(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[LAB] Applied " + val2.Id)); break; } goto default; default: { if (text2 == "stack" && array.Length > 1 && array.Length <= 13) { ModifierRegistry obj5 = ModifierRegistry.Create(modifierSettings); ModifierManager val3 = new ModifierManager(obj5, obj5.Definitions.Select((ModifierDefinition d) => d.Id), Capabilities); val3.ContextAllows = AllowsContext; foreach (string item in array.Skip(1)) { if (!val3.Activate(item, Run.HoleIndex, (PersistenceMode)0)) { throw new ArgumentException("Incompatible lab stack: " + item); } } RestoreEffects(); modifiers = val3; ApplyEffects(Run.RunId, gravityBaseline, modifiers.Values); StartHoleEffects(Run.HoleIndex); Publish(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[LAB] Applied stack " + string.Join(",", array.Skip(1)))); break; } Vector3 val4; switch (text2) { case "clear": RestoreEffects(); Publish(); break; case "empty": { PlayerInfo[] array2 = Players(); foreach (PlayerInfo val6 in array2) { for (int num4 = 0; num4 < val6.Inventory.slots.Count; num4++) { if ((int)val6.Inventory.slots[num4].itemType != 0) { removeItem.Invoke(val6.Inventory, new object[3] { num4, false, false }); } } } break; } case "tick": nextWorldTick = 0.0; TickWorldEffects(); break; case "green_probe": case "dummy_green_probe": { GolfHole mainHole = GolfHoleManager.MainHole; Collider[] componentsInChildren = ((Component)mainHole).GetComponentsInChildren(true); foreach (Collider val7 in componentsInChildren) { ManualLogSource logger3 = ((BaseUnityPlugin)this).Logger; string[] obj9 = new string[10] { "[GREEN] collider=", ((Object)val7).name, " type=", ((object)val7).GetType().Name, " trigger=", val7.isTrigger.ToString(), " bounds=", ((object)val7.bounds/*cast due to .constrained prefix*/).ToString(), " scale=", null }; val4 = ((Component)val7).transform.lossyScale; obj9[9] = ((object)(*(Vector3*)(&val4))/*cast due to .constrained prefix*/).ToString(); logger3.LogInfo((object)string.Concat(obj9)); } Renderer[] componentsInChildren2 = ((Component)mainHole).GetComponentsInChildren(true); foreach (Renderer val8 in componentsInChildren2) { ManualLogSource logger4 = ((BaseUnityPlugin)this).Logger; string[] obj10 = new string[6] { "[GREEN] renderer=", ((Object)val8).name, " bounds=", ((object)val8.bounds/*cast due to .constrained prefix*/).ToString(), " scale=", null }; val4 = ((Component)val8).transform.lossyScale; obj10[5] = ((object)(*(Vector3*)(&val4))/*cast due to .constrained prefix*/).ToString(); logger4.LogInfo((object)string.Concat(obj10)); } break; } case "dummy_dunk_drop": case "dummy_dunk_miss": { if ((Object)(object)dunkHole == (Object)null) { throw new InvalidOperationException("Dunk rim not active"); } GolfBall ownBall4 = GameManager.LocalPlayerInfo.AsGolfer.OwnBall; ownBall4.AsEntity.InformWillTeleport(); ownBall4.Rigidbody.position = dunkCenter + Vector3.right * ((text2 == "dummy_dunk_drop") ? (dunkRadius * 0.5f) : (dunkRadius + 5f)) + Vector3.up * 8f; ((Component)ownBall4).transform.position = ownBall4.Rigidbody.position; ownBall4.Rigidbody.linearVelocity = Vector3.down * 12f; ownBall4.AsEntity.InformTeleported(); break; } case "dummy_dunk_expire": modifiers.CompleteHole(TestHole); ApplyEffects(EffectRunId, gravityBaseline, modifiers.Values); Publish(); break; case "dummy_dunk_verify_clean": { if ((Object)(object)dunkHole != (Object)null || dunkRestore.Count != 0 || dunkPrevious.Count != 0 || Vector3.Distance(Physics.gravity, new Vector3(gravityBaseline.X, gravityBaseline.Y, gravityBaseline.Z)) > 0.001f || ((EffectValues)(ref effects))[(Parameter)3] != 1f) { throw new InvalidOperationException("Dunk cleanup incomplete"); } GolfHole mainHole2 = GolfHoleManager.MainHole; if ((Object)(object)((Component)mainHole2).GetComponent() == (Object)null || !((Component)mainHole2).GetComponent().enabled || !mainHole2.Collider.enabled) { throw new InvalidOperationException("Native cup renderer not restored"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"[DUNK] Verified rim cleanup, original cup, gravity and ball scale"); break; } case "dummy_dunk_clear": RestoreEffects(); Publish(); break; case "dummy_dunk_status": ((BaseUnityPlugin)this).Logger.LogInfo((object)("[DUNK] active=" + ((Object)(object)dunkHole != (Object)null) + " center=" + ((object)Unsafe.As(ref dunkCenter)/*cast due to .constrained prefix*/).ToString() + " radius=" + dunkRadius + " restore=" + dunkRestore.Count)); break; case "cup": { GolfBall ownBall6 = Players().First().AsGolfer.OwnBall; ownBall6.AsEntity.InformWillTeleport(); ownBall6.Rigidbody.position = ((Component)GolfHoleManager.MainHole).transform.position + Vector3.up * 2f; ((Component)ownBall6).transform.position = ownBall6.Rigidbody.position; ownBall6.Rigidbody.linearVelocity = Vector3.zero; ownBall6.AsEntity.InformTeleported(); break; } case "swap_probe": { PlayerGolfer asGolfer3 = Players().First().AsGolfer; GolfBall ownBall5 = asGolfer3.OwnBall; Vector3 position2 = ownBall5.Rigidbody.position; GolfBall val9 = asGolfer3.ServerSpawnBall(position2 + Vector3.right * 2f, Quaternion.identity); try { RotateBalls((GolfBall[])(object)new GolfBall[2] { ownBall5, val9 }); if (Vector3.Distance(ownBall5.Rigidbody.position, position2 + Vector3.right * 2f) > 0.01f || Vector3.Distance(val9.Rigidbody.position, position2) > 0.01f) { throw new InvalidOperationException("Native swap failed"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"[LAB] Two native ball swap passed"); } finally { ownBall5.Rigidbody.position = position2; ((Component)ownBall5).transform.position = position2; asGolfer3.NetworkownBall = ownBall5; NetworkServer.Destroy(((Component)val9).gameObject); } break; } case "equip_pistol": { PlayerInventory inventory = Players().First().Inventory; Grant(inventory, (ItemType)2, replaceIfFull: true); inventory.TrySelectItemSlot(0, false); break; } case "use_item": { bool flag3 = default(bool); bool flag2 = Players().First().Inventory.TryUseItem(false, ref flag3); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[LAB] Native item use=" + flag2 + " ateInput=" + flag3)); break; } case "thunder": SpawnThunderProof(here: false); break; case "thunder_here": SpawnThunderProof(here: true); break; case "thunder_stop": StopThunderProof(); break; case "thunder_status": ((BaseUnityPlugin)this).Logger.LogInfo((object)("[THUNDER] proof=" + (thunderProof != null) + " storms=" + Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0).Length + " strikes=" + Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0).Length)); break; case "explode": TryExplosion(((Component)Players().First().AsGolfer.OwnBall).transform.position + Vector3.up); break; case "spawn_blast_neighbor": { PlayerGolfer asGolfer2 = Players().First().AsGolfer; GolfBall ownBall3 = asGolfer2.OwnBall; if ((Object)(object)labBlastNeighbor != (Object)null) { NetworkServer.Destroy(((Component)labBlastNeighbor).gameObject); } labBlastNeighbor = asGolfer2.ServerSpawnBall(ownBall3.Rigidbody.position + Vector3.right, Quaternion.identity); asGolfer2.NetworkownBall = ownBall3; break; } case "source_blast_probe": { PlayerGolfer asGolfer = Players().First().AsGolfer; GolfBall ownBall2 = asGolfer.OwnBall; Rigidbody rigidbody2 = ownBall2.Rigidbody; Vector3 position = rigidbody2.position; Vector3 linearVelocity = rigidbody2.linearVelocity; Vector3 angularVelocity = rigidbody2.angularVelocity; GolfBall val5 = labBlastNeighbor; if ((Object)(object)val5 == (Object)null) { throw new InvalidOperationException("Run spawn_blast_neighbor first, then let native initialization finish"); } int sourceHits = 0; float neighborImpulse = 0f; Action action = delegate { sourceHits++; }; Action action2 = delegate(PlayerInventory a, ItemType b, ItemUseId c, Vector3 d, float e, Vector3 f, bool g, bool h, ProtectiveState i) { neighborImpulse += ((Vector3)(ref f)).magnitude; }; ownBall2.AsEntity.AsHittable.WillApplyItemHitPhysics += action; val5.AsEntity.AsHittable.WillApplyItemHitPhysics += action2; try { val5.Rigidbody.position = position + Vector3.right; ((Component)val5).transform.position = val5.Rigidbody.position; val5.Rigidbody.linearVelocity = Vector3.right * 5f; rigidbody2.linearVelocity = new Vector3(1f, 2f, 3f); MethodInfo methodInfo2 = AccessTools.DeclaredMethod(typeof(GolfBall), "UpdateIsStationary", (Type[])null, (Type[])null); methodInfo2.Invoke(ownBall2, null); methodInfo2.Invoke(val5, null); Physics.SyncTransforms(); int num2 = explosionsThisHole; TryExplosion(position, ownBall2.AsEntity.AsHittable); if (explosionsThisHole != num2 + 1 || sourceHits != 0 || neighborImpulse < 0.01f) { throw new InvalidOperationException("Blast probe: count=" + (explosionsThisHole - num2) + " sourceHits=" + sourceHits + " neighborImpulse=" + neighborImpulse); } if ((Object)(object)explosionSource != (Object)null || creatingExplosion) { throw new InvalidOperationException("Blast scope leaked"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("[LAB] Source blast probe passed: sourceHits=0; neighborImpulse=" + neighborImpulse)); } finally { ownBall2.AsEntity.AsHittable.WillApplyItemHitPhysics -= action; val5.AsEntity.AsHittable.WillApplyItemHitPhysics -= action2; rigidbody2.linearVelocity = linearVelocity; rigidbody2.angularVelocity = angularVelocity; asGolfer.NetworkownBall = ownBall2; NetworkServer.Destroy(((Component)val5).gameObject); } break; } case "drop_ball": { GolfBall ownBall = Players().First().AsGolfer.OwnBall; ownBall.AsEntity.InformWillTeleport(); Rigidbody rigidbody = ownBall.Rigidbody; rigidbody.position += Vector3.up * 8f; ((Component)ownBall).transform.position = ownBall.Rigidbody.position; ownBall.Rigidbody.linearVelocity = Vector3.down * 20f; ownBall.Rigidbody.angularVelocity = Vector3.zero; ownBall.AsEntity.InformTeleported(); break; } case "dummy_spawn": SpawnDummy(); break; case "dummy_reset": ResetDummy(); break; case "dummy_remove": RemoveDummy(); break; case "dummy_verify": if ((Object)(object)dummy == (Object)null || ((NetworkBehaviour)dummy).isLocalPlayer || !((NetworkBehaviour)dummy).isOwned || dummy.AsEntity.Rigidbody.isKinematic || !dummy.Movement.IsVisible || (Object)(object)((NetworkConnection)NetworkServer.localConnection).identity != (Object)(object)((NetworkBehaviour)GameManager.LocalPlayerInfo).netIdentity) { throw new InvalidOperationException("Dummy ownership/physics/host identity invariant failed"); } if (((HashSet)AccessTools.Field(typeof(CourseManager), "matchParticipants").GetValue(SingletonNetworkBehaviour.Instance)).Contains(dummy.AsGolfer)) { throw new InvalidOperationException("Dummy counted as a course participant"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"[DUMMY] Verified native simulation and host identity isolation"); break; case "dummy_verify_removed": if ((Object)(object)dummy != (Object)null || dummyUnbind.Count != 0 || Object.FindObjectsByType((FindObjectsSortMode)0).Any(IsDummy)) { throw new InvalidOperationException("Dummy cleanup incomplete"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"[DUMMY] Verified removal and handler cleanup"); break; case "dummy_eliminate": if ((Object)(object)dummy == (Object)null) { throw new InvalidOperationException("Spawn dummy first"); } dummy.AsGolfer.ServerEliminate((EliminationReason)5); break; case "dummy_finish_hole": if (InDrivingRange) { throw new InvalidOperationException("Requires a course"); } AccessTools.Method(typeof(PlayerGolfer), "CmdFinishHole", (Type[])null, (Type[])null).Invoke(GameManager.LocalPlayerInfo.AsGolfer, null); break; case "dummy_stack": { if (!CanUseTestingMenu(out var reason2)) { throw new InvalidOperationException(reason2); } BeginRangeTesting(); ApplyTestingStack(array.Skip(1)); break; } case "dummy_probe": { ManualLogSource logger2 = ((BaseUnityPlugin)this).Logger; object obj8; if (!((Object)(object)dummy == (Object)null)) { string[] obj7 = new string[12] { "position=", null, null, null, null, null, null, null, null, null, null, null }; val4 = ((Component)dummy).transform.position; obj7[1] = ((object)(*(Vector3*)(&val4))/*cast due to .constrained prefix*/).ToString(); obj7[2] = " velocity="; val4 = dummy.AsEntity.Rigidbody.linearVelocity; obj7[3] = ((object)(*(Vector3*)(&val4))/*cast due to .constrained prefix*/).ToString(); obj7[4] = " knockout="; obj7[5] = ((object)dummy.Movement.KnockoutState/*cast due to .constrained prefix*/).ToString(); obj7[6] = " visible="; obj7[7] = dummy.Movement.IsVisible.ToString(); obj7[8] = " local="; obj7[9] = ((NetworkBehaviour)dummy).isLocalPlayer.ToString(); obj7[10] = " owned="; obj7[11] = ((NetworkBehaviour)dummy).isOwned.ToString(); obj8 = string.Concat(obj7); } else { obj8 = "absent"; } logger2.LogInfo((object)("[DUMMY] probe=" + (string?)obj8)); break; } case "dummy_hit": { if ((Object)(object)dummy == (Object)null) { throw new InvalidOperationException("Spawn dummy first"); } MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(Hittable), "HitWithItemInternal", (Type[])null, (Type[])null); Hittable asHittable = dummy.AsHittable; object[] obj6 = new object[11] { (object)(ItemType)2, ItemUseId.Invalid, Vector3.zero, null, null, null, null, null, null, null, null }; val4 = Vector3.up + Vector3.forward; obj6[3] = ((Vector3)(ref val4)).normalized; obj6[4] = Vector3.zero; obj6[5] = 0f; obj6[6] = GameManager.LocalPlayerInfo.Inventory; obj6[7] = false; obj6[8] = false; obj6[9] = false; obj6[10] = NetworkTime.time; methodInfo.Invoke(asHittable, obj6); break; } case "skin_probe": ProbeLateBallSkin(); break; case "player_hit_probe": ProbePlayerImpact(); break; case "eliminate": Players().First().AsGolfer.ServerEliminate((EliminationReason)5); break; default: if (text2 != "probe") { throw new ArgumentException("Unknown lab command"); } break; } break; } } break; } break; } ProbeLab(); File.WriteAllText(Path.Combine(Paths.ConfigPath, "RogueGolf.lab.result.txt"), "OK " + text); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[LAB] Rejected " + ex.Message)); File.WriteAllText(Path.Combine(Paths.ConfigPath, "RogueGolf.lab.result.txt"), "ERROR " + ex.Message); } } private unsafe void ProbeLab() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) ProbePhysics(); Collider[] array = scoringTriggers; Vector3 val2; foreach (Collider val in array) { if ((Object)(object)val != (Object)null) { ManualLogSource logger = ((BaseUnityPlugin)this).Logger; string[] obj = new string[6] { "[LAB] Cup bounds centre=", null, null, null, null, null }; Bounds bounds = val.bounds; val2 = ((Bounds)(ref bounds)).center; obj[1] = ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString(); obj[2] = " extents="; bounds = val.bounds; val2 = ((Bounds)(ref bounds)).extents; obj[3] = ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString(); obj[4] = " surface="; obj[5] = cupSurfaceHeights[val].ToString(); logger.LogInfo((object)string.Concat(obj)); } } string text = string.Join(" ", from Parameter p in Enum.GetValues(typeof(Parameter)) where (int)p != 16 select ((object)(*(Parameter*)(&p))/*cast due to .constrained prefix*/).ToString() + "=" + ((EffectValues)(ref effects))[p]); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[LAB] Values " + text + " rules=" + ((object)Unsafe.As(ref mechanics)/*cast due to .constrained prefix*/).ToString())); foreach (ItemSpawner item in Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0).Take(1)) { ItemSpawnerSettings val3 = (ItemSpawnerSettings)AccessTools.Field(typeof(ItemSpawner), "settings").GetValue(item); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[LAB] Native item respawn=" + val3.RespawnTime)); } string sample = contacts.Sample; if (sample != null) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[LAB] Contact " + sample)); } PlayerInfo[] array2 = Players(); foreach (PlayerInfo val4 in array2) { GolfBall ownBall = val4.AsGolfer.OwnBall; if ((Object)(object)ownBall != (Object)null) { ManualLogSource logger2 = ((BaseUnityPlugin)this).Logger; string[] obj2 = new string[10] { "[LAB] Ball radius=", ownBall.Collider.radius.ToString(), " mass=", ownBall.Rigidbody.mass.ToString(), " visualChildren=", ((Component)ownBall).GetComponentsInChildren(true).Length.ToString(), " position=", null, null, null }; val2 = ownBall.Rigidbody.position; obj2[7] = ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString(); obj2[8] = " kinematic="; obj2[9] = ownBall.Rigidbody.isKinematic.ToString(); logger2.LogInfo((object)string.Concat(obj2)); } Vector3 val5 = val4.AsHittable.ApplyDefaultKnockbackReduction(Vector3.right * 10f); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[LAB] Native incoming knockback=" + ((Vector3)(ref val5)).magnitude + " protection=" + MatchSetupRules.GetValue((Rule)27))); BeginSwingHit(val4.AsGolfer, out var __state); try { ManualLogSource logger3 = ((BaseUnityPlugin)this).Logger; val2 = val4.AsHittable.ApplyDefaultKnockbackReduction(Vector3.right * 10f); logger3.LogInfo((object)("[LAB] Native player-hit knockback=" + ((Vector3)(ref val2)).magnitude)); } finally { EndHit(__state); } foreach (InventorySlot item2 in ((IEnumerable)val4.Inventory.slots).Where((InventorySlot s) => (int)s.itemType > 0)) { InventorySlot current2 = item2; ManualLogSource logger4 = ((BaseUnityPlugin)this).Logger; string[] obj3 = new string[6] { "[LAB] Inventory ", null, null, null, null, null }; ItemType itemType = current2.itemType; obj3[1] = ((object)(*(ItemType*)(&itemType))/*cast due to .constrained prefix*/).ToString(); obj3[2] = " uses="; obj3[3] = current2.remainingUses.ToString(); obj3[4] = " valid="; obj3[5] = (current2.remainingUses <= 0 || val4.Inventory.ServerValidateItemUse(((InventorySlot)(ref current2)).GetUsageValidationHash(-1))).ToString(); logger4.LogInfo((object)string.Concat(obj3)); } } } private void PreserveLiveSettings() { if (resetLiveSettings == null) { resetLiveSettings = new ResetSettingsSnapshot(((BaseUnityPlugin)this).Config, (string s) => s == "LawOfZeus"); } } private T LiveSetting(ConfigEntry entry) { if (resetLiveSettings == null) { return entry.Value; } return resetLiveSettings.Read(entry); } private void NativeHook(Type type, string method, string prefix = null, string postfix = null, string finalizer = null) { //IL_003b: 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_006e: Unknown result type (might be due to invalid IL or missing references) MethodInfo methodInfo = AccessTools.DeclaredMethod(type, method, (Type[])null, (Type[])null) ?? throw new MissingMethodException(type.Name + "." + method); harmony.Patch((MethodBase)methodInfo, (prefix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(RogueGolfPlugin), prefix, (Type[])null), (postfix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(RogueGolfPlugin), postfix, (Type[])null), (HarmonyMethod)null, (finalizer == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(RogueGolfPlugin), finalizer, (Type[])null), (HarmonyMethod)null); } private unsafe void Channel(EffectChannel flag, Action install) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) try { install(); Capabilities |= flag; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[MODIFIER] Unavailable " + ((object)(*(EffectChannel*)(&flag))/*cast due to .constrained prefix*/).ToString() + ": " + ex.Message)); } } private void ConfigurePhysicsChannels() { Channel((EffectChannel)8, delegate { if (AccessTools.Property(typeof(GolfBall), "Collider") == null) { throw new MissingMemberException("Ball collider"); } if (AccessTools.Field(typeof(GolfHoleTrigger), "ballTrigger") == null) { throw new MissingMemberException("Native cup trigger"); } NativeHook(typeof(GolfBall), "OnFixedBUpdate", "PrepareBallShape"); NativeHook(typeof(GolfBall), "OnModelOverride", null, "RefreshBallSkin"); }); Channel((EffectChannel)48, delegate { NativeHook(typeof(PhysicsManager), "ModifyContactsInternal", null, "ModifyBallContacts"); NativeHook(typeof(GolfBall), "ApplyLinearDamping", "BeforeDamping", "AfterDamping"); }); Channel((EffectChannel)64, delegate { NativeHook(typeof(Hittable), "HitWithGolfSwingInternal", "BeginSwingHit", null, "EndHit"); NativeHook(typeof(Hittable), "HitWithItemInternal", "BeginItemHit", null, "EndHit"); NativeHook(typeof(Hittable), "HitWithDiveInternal", "BeginDiveHit", null, "EndHit"); NativeHook(typeof(Hittable), "ApplyDefaultKnockbackReduction", null, "ScaleKnockback"); NativeHook(typeof(Hittable), "ApplyVehicleHitKnockbackReduction", null, "ScaleKnockback"); }); Channel((EffectChannel)4096, delegate { NativeHook(typeof(MatchSetupRules), "GetValue", null, "ScaleProtection"); }); } private void BindShape(GolfBall ball) { GolfBall[] array = shapes.Keys.Where((GolfBall b) => (Object)(object)b == (Object)null).ToArray(); foreach (GolfBall key in array) { shapes.Remove(key); } if (!((Object)(object)ball == (Object)null) && !((Object)(object)ball.Collider == (Object)null)) { if (!shapes.TryGetValue(ball, out var value)) { value = (shapes[ball] = new BallShapeLease(ball)); } value.Apply(((EffectValues)(ref effects))[(Parameter)3]); contacts = new ContactState(from b in shapes.Keys where (Object)(object)b != (Object)null select ((Object)b.Collider).GetInstanceID(), ((EffectValues)(ref effects))[(Parameter)4], ((EffectValues)(ref effects))[(Parameter)5]); } } private static void PrepareBallShape(GolfBall __instance) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) RogueGolfPlugin instance = Instance; if ((Object)(object)instance == (Object)null || !instance.shapes.TryGetValue(__instance, out var value) || ((EffectValues)(ref instance.effects))[(Parameter)3] == 1f || instance.HasRule((Mechanic)524288)) { return; } float num = ((EffectValues)(ref instance.effects))[(Parameter)3]; bool flag = false; Vector3 position = __instance.Rigidbody.position; Collider[] array = instance.scoringTriggers; foreach (Collider val in array) { if (!((Object)(object)val == (Object)null)) { Bounds bounds = val.bounds; if (CupAccommodation.CollisionScale(num, false, position.x, position.y, position.z, ((Bounds)(ref bounds)).min.x, ((Bounds)(ref bounds)).min.y, ((Bounds)(ref bounds)).min.z, ((Bounds)(ref bounds)).max.x, ((Bounds)(ref bounds)).max.y, ((Bounds)(ref bounds)).max.z, instance.cupSurfaceHeights[val], value.NativeRadius) == 1f) { flag = true; break; } } } __instance.Collider.radius = value.NativeRadius * (flag ? 1f : num); if (flag && !instance.cupTraced && instance.traceGravity.Value) { instance.cupTraced = true; ((BaseUnityPlugin)instance).Logger.LogInfo((object)("[PHYSICS] Native cup accommodation scale=" + num + " radius=" + __instance.Collider.radius)); } } private static void RefreshBallSkin(GolfBall __instance) { RogueGolfPlugin instance = Instance; if (!((Object)(object)instance == (Object)null) && instance.shapes.TryGetValue(__instance, out var value)) { value.RefreshVisuals(); value.Apply(((EffectValues)(ref instance.effects))[(Parameter)3]); } } private void BindScoringTriggers() { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) FieldInfo field = AccessTools.Field(typeof(GolfHoleTrigger), "ballTrigger"); scoringTriggers = (from c in ((IEnumerable)Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0)).Select((Func)((GolfHoleTrigger t) => (Collider)field.GetValue(t))) where (Object)(object)c != (Object)null select c).ToArray(); cupSurfaceHeights.Clear(); Collider[] array = scoringTriggers; foreach (Collider val in array) { GolfHole componentInParent = ((Component)val).GetComponentInParent(); Dictionary dictionary = cupSurfaceHeights; float y; if (!((Object)(object)componentInParent != (Object)null)) { Bounds bounds = val.bounds; y = ((Bounds)(ref bounds)).max.y; } else { y = ((Component)componentInParent).transform.position.y; } dictionary[val] = y; } cupTraced = false; } private void RestoreShapes() { foreach (BallShapeLease value in shapes.Values) { value.Apply(1f); } shapes.Clear(); scoringTriggers = Array.Empty(); contacts = new ContactState(Array.Empty(), 1f, 1f); } private static void ModifyBallContacts(NativeArray contactPairs) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) ContactState contactState = contacts; if (contactState.Bounce == 1f && contactState.Friction == 1f) { return; } for (int i = 0; i < contactPairs.Length; i++) { ModifiableContactPair val = contactPairs[i]; if (!contactState.Balls.Contains(((ModifiableContactPair)(ref val)).colliderInstanceID) && !contactState.Balls.Contains(((ModifiableContactPair)(ref val)).otherColliderInstanceID)) { continue; } for (int j = 0; j < ((ModifiableContactPair)(ref val)).contactCount; j++) { float bounciness = ((ModifiableContactPair)(ref val)).GetBounciness(j); float dynamicFriction = ((ModifiableContactPair)(ref val)).GetDynamicFriction(j); ((ModifiableContactPair)(ref val)).SetBounciness(j, Math.Min(1f, bounciness * contactState.Bounce)); ((ModifiableContactPair)(ref val)).SetStaticFriction(j, ((ModifiableContactPair)(ref val)).GetStaticFriction(j) * contactState.Friction); ((ModifiableContactPair)(ref val)).SetDynamicFriction(j, dynamicFriction * contactState.Friction); if (contactState.Sample == null) { contactState.Sample = "bounce=" + bounciness + " -> " + ((ModifiableContactPair)(ref val)).GetBounciness(j) + " friction=" + dynamicFriction + " -> " + ((ModifiableContactPair)(ref val)).GetDynamicFriction(j); } } } } private static void BeforeDamping(GolfBall __instance, out Vector3 __state) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) __state = __instance.Rigidbody.linearVelocity; } private static void AfterDamping(GolfBall __instance, Vector3 __state) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) RogueGolfPlugin instance = Instance; if (!((Object)(object)instance == (Object)null) && __instance.IsGrounded && ((EffectValues)(ref instance.effects))[(Parameter)5] != 1f) { Rigidbody rigidbody = __instance.Rigidbody; Vector3 val = rigidbody.linearVelocity - __state; Vector3 val2 = __state + val * ((EffectValues)(ref instance.effects))[(Parameter)5]; rigidbody.linearVelocity = ((Vector3.Dot(val2, __state) < 0f) ? Vector3.zero : val2); if (!instance.dampingTraced && instance.traceGravity.Value && ((Vector3)(ref val)).sqrMagnitude > 1E-06f) { instance.dampingTraced = true; ManualLogSource logger = ((BaseUnityPlugin)instance).Logger; string[] obj = new string[8] { "[PHYSICS] Damping before=", ((Vector3)(ref __state)).ToString("F6"), " native=", null, null, null, null, null }; Vector3 val3 = __state + val; obj[3] = ((Vector3)(ref val3)).ToString("F6"); obj[4] = " actual="; val3 = rigidbody.linearVelocity; obj[5] = ((Vector3)(ref val3)).ToString("F6"); obj[6] = " factor="; obj[7] = ((EffectValues)(ref instance.effects))[(Parameter)5].ToString(); logger.LogInfo((object)string.Concat(obj)); } } } private static void BeginSwingHit(PlayerGolfer hitter, out HitContext __state) { __state = hitContext; hitContext = new HitContext { Attacker = ((hitter != null) ? hitter.PlayerInfo : null), GolfSwing = true }; } private static void BeginDiveHit(PlayerMovement hitter, out HitContext __state) { __state = hitContext; hitContext = new HitContext { Attacker = ((hitter != null) ? hitter.PlayerInfo : null) }; } private static bool BeginItemHit(ItemType itemType, PlayerInventory itemUser, out HitContext __state) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) __state = hitContext; hitContext = new HitContext { Attacker = ((itemUser != null) ? itemUser.PlayerInfo : null) }; if (!((Object)(object)Instance == (Object)null) && Instance.HasRule((Mechanic)8)) { return !Offensive(itemType); } return true; } private static void EndHit(HitContext __state) { hitContext = __state; } private static void ScaleKnockback(Hittable __instance, ref Vector3 __result) { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) RogueGolfPlugin instance = Instance; if ((Object)(object)instance == (Object)null || (hitContext.GolfSwing && __instance.AsEntity.IsGolfBall)) { return; } float num = (((Object)(object)hitContext.Attacker != (Object)null) ? ((EffectValues)(ref instance.effects))[(Parameter)6] : 1f); if (instance.HasModifier("friendly_fire_sale") && (Object)(object)hitContext.Attacker != (Object)null && !__instance.AsEntity.IsPlayer) { ModifierManager obj = instance.modifiers; EffectValues val = (((obj != null) ? obj.Registry : null) ?? ModifierRegistry.Create(instance.modifierSettings)).Compose(instance.CurrentEffects.Where((ActiveModifier e) => e.Id != "friendly_fire_sale")); num = ((EffectValues)(ref val))[(Parameter)6]; } __result *= Mathf.Clamp(num * ((EffectValues)(ref instance.effects))[(Parameter)7], 0.1f, 6f); } private static void ScaleProtection(Rule rule, ref float __result) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 if ((Object)(object)Instance != (Object)null && (int)rule == 27) { __result *= ((EffectValues)(ref Instance.effects))[(Parameter)11]; } } private void ConfigureProgression() { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Expected O, but got Unknown //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Expected O, but got Unknown //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Expected O, but got Unknown //IL_0287: Unknown result type (might be due to invalid IL or missing references) selectionMode = ((BaseUnityPlugin)this).Config.Bind("Progression", "SelectionMode", (SelectionMode)0, "Vote, Random (one weighted draw), or Hybrid (automatic pick from generated candidates)."); persistenceMode = ((BaseUnityPlugin)this).Config.Bind("Progression", "Persistence", (PersistenceMode)0, "StackForRun or Mixed retain canonical durations; PerHole makes every choice temporary. Boss/Pacifist always remain one hole."); skipMode = ((BaseUnityPlugin)this).Config.Bind("Progression", "SkipBudgetMode", (SkipMode)0, "SharedRun, PerPlayer, Unlimited or Disabled. Voting.SharedSkips is the shared or personal starting budget."); skipBehavior = ((BaseUnityPlugin)this).Config.Bind("Progression", "SkipBehavior", (SkipBehavior)0, "NoNewModifier retains the stack; VanillaHole suspends it for one affected hole."); bossEnabled = ((BaseUnityPlugin)this).Config.Bind("Progression", "BossEnabled", true, "Boss cards are offered only in scheduled Boss selections."); bossInterval = ((BaseUnityPlugin)this).Config.Bind("Progression", "BossInterval", 4, new ConfigDescription("Every Nth inter-hole round is a Boss round, including skips/empty rounds.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 99), Array.Empty())); randomSkips = ((BaseUnityPlugin)this).Config.Bind("Progression", "RandomSkipsEnabled", false, "Allow automatic skips when the budget permits. Personal mode requires every eligible player to afford one; all pay."); randomSkipWeight = WeightConfig("Progression", "RandomSkipWeight", 10); randomModifierWeight = ((BaseUnityPlugin)this).Config.Bind("Progression", "RandomModifierWeight", 100, new ConfigDescription("Weight of choosing a modifier versus an automatic skip.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 10000), Array.Empty())); densityMode = ((BaseUnityPlugin)this).Config.Bind("Density", "Mode", (SelectionDensityMode)0, "Standard: short-course floor; SinglePick: one vote per round; Custom: editable floor/cap. High is reserved and unavailable."); densityFloor = ((BaseUnityPlugin)this).Config.Bind("Density", "ShortRunSelectionFloor", 11, new ConfigDescription("Target minimum opportunities, subject to ordinary-round cap.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 999), Array.Empty())); densityCap = ((BaseUnityPlugin)this).Config.Bind("Density", "MaxSelectionsPerOrdinaryRound", 2, new ConfigDescription("Custom cap 1-5; Standard never exceeds two. Boss rounds always one.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 5), Array.Empty())); string[] array = new string[4] { "Early", "EarlyMid", "MidLate", "Late" }; int[] array2 = RogueGolfDefaults.TierWeights; phaseThresholds.AddRange(ProgressionConfig.BindThresholds(((BaseUnityPlugin)this).Config, delegate(string message) { ((BaseUnityPlugin)this).Logger.LogWarning((object)message); })); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[CONFIG] Adaptive progression thresholds (%)=" + string.Join(",", phaseThresholds.Select((ConfigEntry c) => c.Value)))); for (int num = 0; num < 4; num++) { for (int num2 = 0; num2 < 3; num2++) { tierWeights.Add(WeightConfig("Weights." + array[num], ((object)(ModifierRarity)num2/*cast due to .constrained prefix*/).ToString(), array2[num * 3 + num2])); } } tierWeights.Add(WeightConfig("Weights.BossSelection", "Legendary", array2[12])); tierWeights.Add(WeightConfig("Weights.BossSelection", "Boss", array2[13])); ModifierDefinition[] definitions = ModifierRegistry.Create(new ModifierSettings(1.2f, 2f, 0.5f, 0.6f, 1.5f, (IEnumerable>)null)).Definitions; foreach (ModifierDefinition val in definitions) { modifierWeights.Add(val.Id, WeightConfig("Weights.Modifiers", val.Id, 100)); } } private ConfigEntry WeightConfig(string section, string key, int value) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown return ((BaseUnityPlugin)this).Config.Bind(section, key, value, new ConfigDescription("Relative selection weight (0 excludes). Normalized among eligible choices; need not total 100.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 10000), Array.Empty())); } private void BeginProgression(uint seedValue) { //IL_0007: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Expected O, but got Unknown //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Expected O, but got Unknown //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) progression = new ProgressionSettings(selectionMode.Value, persistenceMode.Value, skipMode.Value, skipBehavior.Value, bossEnabled.Value, bossInterval.Value, randomSkips.Value, randomSkipWeight.Value, randomModifierWeight.Value, tierWeights.Select((ConfigEntry c) => c.Value).ToArray(), new float[1].Concat(phaseThresholds.Select((ConfigEntry c) => c.Value)).ToArray(), modifierWeights.Select((KeyValuePair> p) => new KeyValuePair(p.Key, p.Value.Value))); density = new DensitySettings(densityMode.Value, densityFloor.Value, densityCap.Value); CourseData currentCourse = GameManager.CurrentCourse; densityPlan = SelectionDensityPlanner.Plan(((currentCourse == null) ? ((int?)null) : currentCourse.Holes?.Length) ?? 9, density, (Func)((int n) => progression.IsBoss(n))); roundSelections = new RoundSelectionState(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[DENSITY] captured mode=" + ((object)density.Mode/*cast due to .constrained prefix*/).ToString() + " floor=" + density.ShortRunSelectionFloor + " cap=" + density.MaxSelectionsPerOrdinaryRound + " schedule=" + string.Join(",", densityPlan))); skipLedger = new SkipLedger(progression.Skips, skipBudget.Value); selectionRandom = new RunRandom(seedValue ^ 0xA511E9B3u); selectionNumber = 0; bossSelection = false; summaryComplete = false; progressionSeed = seedValue; runHistory.Clear(); votePlayers.Clear(); summaryPage = 0; ((BaseUnityPlugin)this).Logger.LogInfo((object)("[PROGRESSION] captured selection=" + ((object)progression.Selection/*cast due to .constrained prefix*/).ToString() + " persistence=" + ((object)progression.Persistence/*cast due to .constrained prefix*/).ToString() + " skips=" + ((object)progression.Skips/*cast due to .constrained prefix*/).ToString() + " skipEffect=" + ((object)progression.SkipEffect/*cast due to .constrained prefix*/).ToString() + " bossInterval=" + progression.BossInterval + " positiveWeights=" + string.Join(",", from p in progression.ModifierWeights where p.Value > 0 select p.Key + ":" + p.Value))); } private void PrepareProgressionVote() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Invalid comparison between Unknown and I4 //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Invalid comparison between Unknown and I4 //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Expected O, but got Unknown //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Invalid comparison between Unknown and I4 //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Expected O, but got Unknown selectionNumber++; bossSelection = roundSelections.Boss; votePlayers.Clear(); foreach (int item in bridge.Eligible) { if (bridge.TryPlayerGuid(item, out var guid)) { votePlayers[item] = guid; } } bool flag = (int)progression.Selection > 0; int num = (((int)progression.Selection == 1) ? 1 : voting.Settings.CandidateCount); int num2 = Run.HoleIndex + 2; CourseData currentCourse = GameManager.CurrentCourse; int num3 = ((currentCourse == null) ? ((int?)null) : currentCourse.Holes?.Length) ?? 9; float normalizedProgress = CourseProgress.GetNormalizedProgress(num2, num3); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[PROGRESSION] course=" + num2 + "/" + num3 + " progress=" + normalizedProgress + " phase=" + ((object)progression.GetPhase(normalizedProgress)/*cast due to .constrained prefix*/).ToString() + " selection=" + selectionNumber + " round=" + roundSelections.RoundOrdinal + " pick=" + roundSelections.PickIndex + "/" + roundSelections.PickCount + " acquisition=" + roundSelections.AcquisitionOrdinal + " boss=" + bossSelection)); VoteOption[] array = ProgressionCandidates.Generate(modifiers, progression, num2, num3, bossSelection, num, selectionRandom); bool flag2 = votePlayers.Count > 0 && (flag ? votePlayers.Values.All((ulong id) => skipLedger.Remaining(id) > 0) : votePlayers.Values.Any((ulong id) => skipLedger.Remaining(id) > 0)); List list = array.ToList(); if (array.Length == 0) { list.Add(new VoteOption("none", "No eligible modifier", "No positive-weight compatible choices in this selection. Continue without spending a skip.")); ShowNotice("No eligible weighted choices. Continuing without a new modifier."); } else if (flag2 && (!flag || progression.RandomSkips)) { list.Add(new VoteOption("skip", "Skip", ((int)progression.SkipEffect == 1) ? "Suspend all effects for the next hole. Remaining picks still happen." : "Add no modifier. Existing effects remain.")); } voting.Open((IEnumerable)votePlayers.Keys, NetworkTime.time, list.ToArray()); voting.Vote.MaySkip = (int id) => votePlayers.TryGetValue(id, out var value) && skipLedger.Remaining(value) > 0; if (flag || array.Length == 0) { voting.Vote.ResolveAutomatic(ProgressionCandidates.Automatic(array, progression, flag2, selectionRandom)); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("[PROGRESSION] selection=" + selectionNumber + " hole=" + (Run.HoleIndex + 2) + " boss=" + bossSelection + " mode=" + ((object)progression.Selection/*cast due to .constrained prefix*/).ToString() + " candidates=" + string.Join(",", list.Select((VoteOption o) => o.Id)))); } private void ApplyProgressionWinner() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Invalid comparison between Unknown and I4 //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) string winner = voting.Vote.Winner; if (winner == "skip") { IEnumerable enumerable; if ((int)progression.Selection != 0) { IEnumerable values = votePlayers.Values; enumerable = values; } else { enumerable = from p in voting.Vote.Ballots where p.Value == "skip" select votePlayers[p.Key]; } IEnumerable enumerable2 = enumerable; if (!skipLedger.Charge(enumerable2)) { throw new InvalidOperationException("Resolved skip has no valid budget"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("[PROGRESSION] skip charged mode=" + ((object)progression.Skips/*cast due to .constrained prefix*/).ToString() + " remaining=" + string.Join(",", from p in PersonalSkipView() orderby p.Key select p.Key + ":" + p.Value))); if ((int)progression.SkipEffect == 1) { modifiers.SuspendForHole(Run.HoleIndex + 1); ApplyEffects(Run.RunId, gravityBaseline, modifiers.Values); } } else if (winner != "none") { ActivateModifier(winner); } roundSelections.Resolve(winner != "skip" && winner != "none"); runHistory.Add(new RunChoice(Run.HoleIndex + 2, winner, bossSelection, roundSelections.PickIndex, roundSelections.PickCount, roundSelections.AcquisitionOrdinal)); if (runHistory.Count > 64) { runHistory.RemoveAt(0); } } private void CompleteProgression() { if (runStage == PrototypeStage.Modifiers && Run.Active) { summaryComplete = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)("[SUMMARY] seed=" + progressionSeed + " selections=" + selectionNumber + " history=" + string.Join(",", runHistory.Select((RunChoice h) => h.Hole + "." + h.PickIndex + ":" + h.Id)))); } } private Dictionary PersonalSkipView() { Dictionary dictionary = new Dictionary(); if (skipLedger != null) { foreach (int item in bridge.Eligible) { if (bridge.TryPlayerGuid(item, out var guid)) { dictionary[item] = skipLedger.Remaining(guid); } } } return dictionary; } private void ConfigureRateCompatibility() { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown Type[] array = new Type[4] { typeof(PlayerAudio), typeof(PlayerMovement), typeof(PlayerGolfer), typeof(PlayerInventory) }; foreach (Type type in array) { string[] array2 = CompatibilityPolicy.Fields[type.Name]; foreach (string text in array2) { FieldInfo fieldInfo = AccessTools.Field(type, text); if (fieldInfo == null || (fieldInfo.FieldType != typeof(AntiCheatRateChecker) && fieldInfo.FieldType != typeof(AntiCheatPerPlayerRateChecker))) { throw new MissingFieldException(type.Name, text); } } harmony.Patch((MethodBase)AccessTools.Method(type, "OnStartServer", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(RogueGolfPlugin), "RegisterRateOwner", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("[COMPAT] Policy " + 1 + ": explicit rate allowlist; interval=min(native/10,10ms), suspicion>=200, confirmation>=1000, free hits>=32, reset<=250ms; integrity/scoring checks unchanged")); } private static T RateField(object checker, string field) { return (T)AccessTools.Field(checker.GetType(), field).GetValue(checker); } private static object RelaxedChecker(object original) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown string text = RateField(original, "name"); float num = CompatibilityPolicy.Interval(RateField(original, "expectedMinTimeBetweenHits")); int num2 = CompatibilityPolicy.Suspicion(RateField(original, "minSuspiciousHitCount")); int num3 = CompatibilityPolicy.Confirmation(RateField(original, "minConfirmedCheatHitCount")); float num4 = CompatibilityPolicy.ResetGap(RateField(original, "hitResetTime")); int num5 = Math.Max(32, RateField(original, "nonRateLimitedHitCount")); if (!(original is AntiCheatRateChecker)) { return (object)new AntiCheatPerPlayerRateChecker(text, num, num2, num3, num4, num5); } return (object)new AntiCheatRateChecker(text, RateField(original, "playerConnectionId"), num, num2, num3, num4, num5); } private static void RegisterRateOwner(Component __instance) { RogueGolfPlugin instance = Instance; if ((Object)(object)instance == (Object)null || instance.rateOwners.ContainsKey(__instance)) { return; } List list = new List(); string[] array = CompatibilityPolicy.Fields[((object)__instance).GetType().Name]; foreach (string text in array) { FieldInfo fieldInfo = AccessTools.Field(((object)__instance).GetType(), text); object value = fieldInfo.GetValue(__instance); if (value != null) { list.Add(new RateLease { Field = fieldInfo, Native = value, Relaxed = RelaxedChecker(value) }); } } instance.rateOwners[__instance] = list; instance.ReviewRateOwner(__instance, list); } private void ReviewRateOwner(Component owner, List leases) { NetworkIdentity component = owner.GetComponent(); bool flag = CompatibilityPolicy.MayRelax(((Behaviour)this).enabled && enabledMode.Value, NetworkServer.active, bridge?.IsPrivateSession ?? false, ((component != null) ? component.connectionToClient : null) != null && (bridge?.Verified(component.connectionToClient.connectionId) ?? false), Run.Active || RangeTesting || (customItems != null && customItems.Registry.Master.Value)); bool flag2 = false; foreach (RateLease lease in leases) { if (lease.Applied != flag && lease.Field.GetValue(owner) == (flag ? lease.Native : lease.Relaxed)) { lease.Field.SetValue(owner, flag ? lease.Relaxed : lease.Native); lease.Applied = flag; flag2 = true; } } if (flag2) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[COMPAT] " + (flag ? "Relaxed " : "Restored ") + ((object)owner).GetType().Name + " rate checks=" + leases.Count)); } } private void TickRateCompatibility() { if (Time.realtimeSinceStartupAsDouble < nextRateReview) { return; } nextRateReview = Time.realtimeSinceStartupAsDouble + 0.25; List list = new List(); foreach (KeyValuePair> rateOwner in rateOwners) { if ((Object)(object)rateOwner.Key == (Object)null) { list.Add(rateOwner.Key); } else { ReviewRateOwner(rateOwner.Key, rateOwner.Value); } } foreach (Component item in list) { rateOwners.Remove(item); } } private void RestoreRateCompatibility(bool forget = false) { foreach (KeyValuePair> rateOwner in rateOwners) { if (!((Object)(object)rateOwner.Key != (Object)null)) { continue; } foreach (RateLease item in rateOwner.Value) { if (item.Applied && item.Field.GetValue(rateOwner.Key) == item.Relaxed) { item.Field.SetValue(rateOwner.Key, item.Native); } item.Applied = false; } } if (forget) { rateOwners.Clear(); } nextRateReview = 0.0; } private void StopCompatibilitySession() { RestoreRateCompatibility(forget: true); if (quitting) { return; } if (NetworkServer.active) { NetworkManager singleton = NetworkManager.singleton; if (singleton != null) { singleton.StopHost(); } } else if (NetworkClient.active) { NetworkManager singleton2 = NetworkManager.singleton; if (singleton2 != null) { singleton2.StopClient(); } } } private void Awake() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown Instance = this; tutorialSeen = ((BaseUnityPlugin)this).Config.Bind("Interface", "SeenTutorial", false, "Local tutorial preference. Set true after opening How it works. Preserved by gameplay Reset to Defaults and never synchronized."); enabledMode = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Enable for the next course. Disabling stops the current RogueGolf run and releases any hold."); ConfigureIntermission(); Run.Changed += LogTransition; Run.Warning += delegate(string message) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[RUN] " + message)); }; harmony = new Harmony("technomancer.roguegolf"); try { Hook("StartCourseInternal", "StartRun", Type.EmptyTypes); Hook("EndCourseInternal", "EndRun", Type.EmptyTypes); Hook("ServerStartNextMatch", "NextHole", new Type[1] { typeof(bool) }); PatchStop("OnStopServer"); PatchStop("OnStopClient"); ConfigureVoting(); ConfigureAdmission(); ConfigureRateCompatibility(); ConfigureModifiers(); ConfigureCustomItems(); BuildFingerprint = BuildIdentity.Compute("1.1.5", File.ReadAllBytes(typeof(BuildIdentity).Assembly.Location), File.ReadAllBytes(typeof(RogueGolfPlugin).Assembly.Location), formula1Available ? 1 : 0); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[NET] Build fingerprint=" + BuildFingerprint + " cartHooks=" + formula1Available)); CourseManager.CurrentHoleCourseIndexChanged += OnHoleIndex; CourseManager.MatchStateChanged += OnMatchState; SceneManager.sceneLoaded += PeerSceneLoaded; subscribed = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)("[ENV] RogueGolf 1.1.5 " + GameVersionLabel.GetVersion(false) + " Unity=" + Application.unityVersion)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[RUN] Lifecycle adapter ready"); } catch (Exception ex) { harmony.UnpatchSelf(); ((Behaviour)this).enabled = false; ((BaseUnityPlugin)this).Logger.LogError((object)("[RUN] Critical hooks unavailable: " + ex)); } } private void Hook(string name, string prefix, Type[] parameters) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(CourseManager), name, parameters, (Type[])null); if (methodInfo == null || methodInfo.ReturnType != typeof(void)) { throw new MissingMethodException(name); } harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(RogueGolfPlugin), prefix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private void PatchStop(string name) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown harmony.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(BNetworkManager), name, (Type[])null, (Type[])null), new HarmonyMethod(typeof(RogueGolfPlugin), "NetworkStopped", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static bool StartRun() { if (!((Object)(object)Instance == (Object)null) && ((Behaviour)Instance).enabled) { return Instance.BeginAuthoritativeRun(); } return true; } private static void EndRun() { if (NetworkServer.active && (Object)(object)Instance != (Object)null) { Instance.CompleteProgression(); Instance.ClearRunResources(); Instance.Run.Complete(); } } private static bool NextHole(CourseManager __instance, bool __0) { if (!((Object)(object)Instance == (Object)null)) { return Instance.InterceptNext(__instance, __0); } return true; } private static void NetworkStopped(MethodBase __originalMethod) { if (!((Object)(object)Instance == (Object)null)) { Instance.RestoreRateCompatibility(forget: true); Instance.customItems?.Cleanup("network stopped"); Instance.customItems?.StopNetworking(); Instance.ClearRunResources(); Instance.Run.Stop("NetworkStop"); if (__originalMethod.Name == "OnStopServer") { Instance.bridge?.StopServer(); } else { Instance.bridge?.StopClient(); } Instance.RestoreCursor(); } } private void OnHoleIndex() { if (!NetworkServer.active) { return; } if (CourseManager.CurrentHoleCourseIndex >= 0 && CourseManager.CurrentHoleCourseIndex != Run.HoleIndex) { VoteCoordinator obj = voting; if (obj != null) { obj.ClearVote(); } } Run.HoleLoaded(CourseManager.CurrentHoleCourseIndex); } private void OnMatchState(MatchState before, MatchState after) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Invalid comparison between Unknown and I4 if ((int)after == 6) { customItems?.Cleanup("hole ended"); } if (NetworkServer.active) { int currentHoleCourseIndex = CourseManager.CurrentHoleCourseIndex; if ((int)after == 3) { Run.HoleLoaded(currentHoleCourseIndex); Run.HoleStarted(currentHoleCourseIndex); StartHoleEffects(currentHoleCourseIndex); ProbePhysics(); } else if ((int)after == 6) { ExpireModifiers(currentHoleCourseIndex); Run.HoleEnded(currentHoleCourseIndex); } } } private void LogTransition(string reason) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if ((int)Run.State != 3) { StopThunderProof(); StopActiveEvents(); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("[RUN] id=" + Run.RunId + " rev=" + Run.Revision + " hole=" + Run.HoleIndex + " state=" + ((object)Run.State/*cast due to .constrained prefix*/).ToString() + " event=" + reason)); Publish(); } private void OnApplicationQuit() { quitting = true; RestoreRateCompatibility(forget: true); customItems?.Cleanup("quit"); RestoreEffects(); } private void OnDisable() { if (subscribed) { StopCompatibilitySession(); if (!quitting) { ReleaseIntermission(); } ClearRunResources(); Run.Stop("PluginDisabled"); DisposeUi(); RestoreCursor(); } } private void OnDestroy() { StopCompatibilitySession(); if (subscribed) { CourseManager.CurrentHoleCourseIndexChanged -= OnHoleIndex; CourseManager.MatchStateChanged -= OnMatchState; SceneManager.sceneLoaded -= PeerSceneLoaded; } DisposeUi(); DisposeSetupTextures(); ClearRunResources(); customItems?.Dispose(); Run.Stop(quitting ? "ApplicationQuit" : "PluginDestroyed"); try { bridge?.Dispose(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[NET] Shutdown cleanup: " + ex.Message)); } finally { RestoreCursor(); Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } Instance = null; } ((BaseUnityPlugin)this).Logger.LogInfo((object)"[RUN] Adapter subscriptions and patches removed"); } private void DrawModifierHud() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) RunSnapshot view = View; if (view.ActiveModifiers.Length == 0) { return; } float num = Math.Max(300, Math.Min(12, view.ActiveModifiers.Length) * 38 + 16); float num2 = (float)Math.Ceiling((float)view.ActiveModifiers.Length / 12f) * 40f + 29f; RectTransform parent = Panel((Transform)(object)uiContent, 20f, 704f - num2, num, num2, Paper, block: false); Label((Transform)(object)parent, 10f, 4f, num - 20f, 22f, (ViewingRangeTest ? "RANGE TEST" : "CHAOS RUN") + " · " + view.ActiveModifiers.Length + " effects · Esc for details", 13f, Muted, bold: true); for (int i = 0; i < view.ActiveModifiers.Length; i++) { ActiveModifier val = view.ActiveModifiers[i]; Icon((Transform)(object)parent, 8 + i % 12 * 38, 27 + i / 12 * 40, 34f, UiRegistry.Get(val.Id), val.Suspended); if (val.RemainingHoles > 0) { Shape((Transform)(object)parent, 8 + i % 12 * 38, 62 + i / 12 * 40, 34f, 2f, Gold, 1f); } } } private void DrawPause() { //IL_005f: 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_016f: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) if (pauseMinimized) { Button((Transform)(object)uiContent, 475f, 70f, 250f, 40f, "RogueGolf · Open", delegate { SetPauseMinimized(value: false); }); return; } RectTransform val = Panel((Transform)(object)uiContent, 350f, 70f, 500f, 600f, Paper); Label((Transform)(object)val, 20f, 17f, 220f, 45f, "RogueGolf", 32f, null, bold: true); Label((Transform)(object)val, 20f, 61f, 460f, 25f, ViewingRangeTest ? "Driving-range testing · effects clear at course start" : ((View != null && (int)View.State != 0) ? ("Hole " + (View.Hole + 1) + " · Seed " + View.Seed + " · " + SkipLabel(View)) : "Ready for the next chaos run"), 15f, Muted); Label((Transform)(object)val, 20f, 103f, 460f, 28f, "ACTIVE EFFECTS · Settings are in Match Setup", 16f, Muted, bold: true); if (uiFocus) { Button((Transform)(object)val, 250f, 24f, 100f, 34f, "Unfocus", delegate { SetUiFocus(value: false); }, Gold); } Button((Transform)(object)val, 360f, 24f, 120f, 34f, "Minimize", delegate { SetPauseMinimized(value: true); }, Gold); DrawEffectLedger(val); Label((Transform)(object)val, 20f, 561f, 460f, 32f, uiFocus ? "Arrows / D-pad: select · Enter / A: use · Esc / B: unfocus" : "F7 / Y: focus · Q / E: pages · Mouse: select", 14f, Muted); } private void DrawEffectLedger(RectTransform p) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0365: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_051f: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Unknown result type (might be due to invalid IL or missing references) ActiveModifier[] array = View?.ActiveModifiers ?? Array.Empty(); if (array.Length == 0) { Label((Transform)(object)p, 25f, 185f, 450f, 52f, "A clean scorecard.", 28f, null, bold: true); Label((Transform)(object)p, 25f, 245f, 450f, 120f, "Active modifiers will appear here with their exact values, duration and current status. Your first hole starts with standard rules.", 20f, Muted); return; } if (detailId != "") { ActiveModifier val = ((IEnumerable)array).FirstOrDefault((Func)((ActiveModifier e) => e.Id == detailId)); if (detailId == "combined") { Label((Transform)(object)p, 25f, 160f, 450f, 42f, "Combined values", 28f, null, bold: true); string text = EffectPresentation.Combined(UiRegistry, (IEnumerable)array).Replace(" · ", "\n"); if (View.PlayerShotFactors.TryGetValue(SteamClient.SteamId.Value, out var value)) { string text2 = text; EffectValues val2 = UiRegistry.Compose((IEnumerable)array); text = text2 + "\nYour rank-adjusted shot speed ×" + EffectPresentation.Number(Mathf.Clamp(((EffectValues)(ref val2)).ShotPower * value, 0.25f, 3f)); } string[] value2 = text.Split('\n'); Label((Transform)(object)p, 25f, 215f, 450f, 295f, string.Join("\n", value2), 17f); } else { if (val == null) { detailId = ""; DrawEffectLedger(p); return; } ModifierDefinition val3 = UiRegistry.Get(val.Id); Icon((Transform)(object)p, 25f, 157f, 64f, val3, val.Suspended); Label((Transform)(object)p, 104f, 157f, 371f, 65f, val3.Name, 26f, null, bold: true); Label((Transform)(object)p, 25f, 226f, 450f, 30f, ((object)val3.Rarity/*cast due to .constrained prefix*/).ToString() + " · " + EffectPresentation.Status(val, View.Hole), 16f, Muted); Label((Transform)(object)p, 25f, 267f, 450f, 240f, EffectPresentation.Details(val3, View.ModifierSettings, val), 19f); } Button((Transform)(object)p, 26f, 519f, 205f, 33f, "Back to effects", delegate { detailId = ""; }); return; } Label((Transform)(object)p, 20f, 147f, 320f, 54f, "COMBINED EFFECTS\n" + EffectPresentation.Combined(UiRegistry, (IEnumerable)array), 16f, Muted); Button((Transform)(object)p, 350f, 152f, 130f, 34f, "All values", delegate { detailId = "combined"; }, Gold); int num = (array.Length + 2) / 3; effectPage = Math.Min(effectPage, num - 1); for (int num2 = 0; num2 < 3 && effectPage * 3 + num2 < array.Length; num2++) { ActiveModifier val4 = array[effectPage * 3 + num2]; ModifierDefinition val5 = UiRegistry.Get(val4.Id); float num3 = 214 + num2 * 98; Shape((Transform)(object)p, 20f, num3, 460f, 91f, Color32.op_Implicit(new Color32((byte)244, (byte)239, (byte)210, byte.MaxValue)), 12f); Icon((Transform)(object)p, 30f, num3 + 14f, 48f, val5, val4.Suspended); Label((Transform)(object)p, 90f, num3 + 6f, 280f, 28f, val5.Name, 20f, null, bold: true); Label((Transform)(object)p, 90f, num3 + 34f, 285f, 21f, ((object)val5.Rarity/*cast due to .constrained prefix*/).ToString() + " · " + EffectPresentation.Status(val4, View.Hole), 13f, val4.Suspended ? Muted : Ink); Label((Transform)(object)p, 90f, num3 + 58f, 280f, 27f, EffectPresentation.Details(val5, View.ModifierSettings, val4).Replace("\n", " · "), 15f, Muted); string id = val4.Id; Button((Transform)(object)p, 380f, num3 + 29f, 90f, 34f, "Details", delegate { detailId = id; }, Gold); } Pager(p, effectPage, num, delegate { effectPage--; }, delegate { effectPage++; }); } private void DrawVote() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 //IL_0041: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_0727: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_0746: Unknown result type (might be due to invalid IL or missing references) //IL_0758: Unknown result type (might be due to invalid IL or missing references) //IL_075e: Invalid comparison between Unknown and I4 //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_04fc: Unknown result type (might be due to invalid IL or missing references) //IL_0501: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_05ed: Invalid comparison between Unknown and I4 //IL_062f: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_05f7: Invalid comparison between Unknown and I4 //IL_06cc: Unknown result type (might be due to invalid IL or missing references) //IL_06c5: Unknown result type (might be due to invalid IL or missing references) if ((int)View.State == 8) { DrawVoteResult(); return; } RunSnapshot view = View; bool flag = (int)view.State == 7; RectTransform parent = Panel((Transform)(object)uiContent, 70f, 92f, 1140f, 540f, Paper); Shape((Transform)(object)parent, 2f, 2f, 1136f, 9f, view.BossSelection ? TierColor((ModifierRarity)3) : Gold, 4f); Label((Transform)(object)parent, 30f, 27f, 900f, 27f, "CHAOS RUN / HOLE " + (view.Hole + 2) + (view.BossSelection ? " / BOSS ROUND" : "") + ((view.CurrentRoundPickCount > 1) ? (" / PICK " + view.CurrentRoundPickIndex + " OF " + view.CurrentRoundPickCount) : ""), 17f, Muted, bold: true); Label((Transform)(object)parent, 30f, 65f, 870f, 50f, flag ? "Break the tie." : "Make the next hole interesting.", 34f, null, bold: true); double num = (flag ? view.TieDeadline : view.Deadline); double num2 = Math.Ceiling(Math.Max(0.0, num - NetworkTime.time)); RectTransform parent2 = Panel((Transform)(object)parent, 930f, 25f, 180f, 125f, (num2 <= 5.0) ? Color32.op_Implicit(new Color32(byte.MaxValue, (byte)210, (byte)175, byte.MaxValue)) : Gold, block: false); ((TMP_Text)Label((Transform)(object)parent2, 8f, 7f, 164f, 24f, flag ? "TIE ENDS IN" : "VOTE ENDS IN", 15f, Ink, bold: true)).alignment = (TextAlignmentOptions)514; ((TMP_Text)Label((Transform)(object)parent2, 8f, 32f, 164f, 80f, num2 + "s", 56f, Ink, bold: true)).alignment = (TextAlignmentOptions)514; Label((Transform)(object)parent, 30f, 124f, 870f, 30f, SkipLabel(view) + " · " + (((int)view.Progression.Selection == 0) ? (view.Ballots.Count + " / " + view.Eligible.Length + " voted") : (((object)view.Progression.Selection/*cast due to .constrained prefix*/).ToString() + " selection")), 18f, Muted); int num3 = view.Options.Length; float num4 = 1080f / (float)Math.Max(1, num3); for (int i = 0; i < num3; i++) { VoteOption option = view.Options[i]; ModifierDefinition val = UiRegistry.Get(option.Id); string value; bool flag2 = view.Ballots.TryGetValue(view.Recipient, out value) && value == option.Id; RectTransform parent3 = Panel((Transform)(object)parent, 30f + (float)i * num4, 173f, num4 - 12f, 276f, Color32.op_Implicit(new Color32((byte)248, (byte)242, (byte)213, byte.MaxValue))); if (val != null) { Icon((Transform)(object)parent3, (num4 - 76f) / 2f, 12f, 64f, val); ((TMP_Text)Label((Transform)(object)parent3, 12f, 79f, num4 - 36f, 17f, ((object)val.Rarity/*cast due to .constrained prefix*/).ToString(), 12f, Muted, bold: true)).alignment = (TextAlignmentOptions)514; } else if (option.IsSkip) { Shape((Transform)(object)parent3, (num4 - 12f) / 2f - 16f, 27f, 10f, 35f, Muted, 3f); Shape((Transform)(object)parent3, (num4 - 12f) / 2f + 6f, 27f, 10f, 35f, Muted, 3f); } else { EffectIconGraphic effectIconGraphic = ((Component)Rect((Transform)(object)parent3, (num4 - 76f) / 2f, 17f, 64f, 64f)).gameObject.AddComponent(); effectIconGraphic.Symbol = new EffectSymbol((EffectGlyph)2, 0); ((Graphic)effectIconGraphic).color = Muted; ((Graphic)effectIconGraphic).raycastTarget = false; } ((TMP_Text)Label((Transform)(object)parent3, 10f, 94f, num4 - 32f, 60f, option.Name, (num3 > 4) ? 18 : 23, null, bold: true)).alignment = (TextAlignmentOptions)514; ((TMP_Text)Label((Transform)(object)parent3, 12f, 157f, num4 - 36f, 56f, (val == null) ? option.Description : ((val.Id == "law_of_zeus") ? "The gods are displeased." : EffectPresentation.Details(val, view.ModifierSettings, (ActiveModifier)null)), (num3 > 4) ? 14 : 16, Muted)).alignment = (TextAlignmentOptions)514; string value2 = ((val == null) ? "" : (((int)view.Progression.Persistence == 1 || (int)val.Duration == 1) ? "ONE HOLE" : "THIS RUN")); ((TMP_Text)Label((Transform)(object)parent3, 12f, 218f, num4 - 36f, 20f, value2, 12f, Muted, bold: true)).alignment = (TextAlignmentOptions)514; string title = (flag2 ? "Your vote" : (i + 1 + " · " + view.Ballots.Values.Count((string b) => b == option.Id) + " votes")); Button((Transform)(object)parent3, 10f, 239f, num4 - 32f, 30f, title, delegate { Choose(option.Id); }, flag2 ? Green : Gold, InputAvailable && CanChoose(view, option.Id)); } Label((Transform)(object)parent, 30f, 473f, 1070f, 40f, flag ? "Host chooses a tied card. The timer provides a random fallback." : (((int)view.Progression.Selection != 0) ? "Chosen automatically from the host's weighted pool." : "1–6: vote D-pad + A: vote Your effects are listed in the pause menu."), 17f, Muted); if ((int)view.State == 5 && NetworkServer.active) { Button((Transform)(object)parent, 810f, 475f, 290f, 36f, "Resume next hole", ReleaseIntermission); } } private void DrawVoteResult() { //IL_00a1: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) RunSnapshot s = View; VoteOption val = ((IEnumerable)s.Options).FirstOrDefault((Func)((VoteOption o) => o.Id == s.Winner)); ModifierDefinition val2 = UiRegistry.Get(s.Winner); bool num = s.Winner == "skip"; bool flag = s.Winner == "none" || string.IsNullOrEmpty(s.Winner); RectTransform parent = Panel((Transform)(object)uiContent, 240f, 200f, 800f, 320f, Paper); Shape((Transform)(object)parent, 2f, 2f, 796f, 9f, (val2 == null) ? Gold : TierColor(val2.Rarity), 4f); ((TMP_Text)Label((Transform)(object)parent, 32f, 24f, 736f, 26f, "SELECTION COMPLETE" + ((s.CurrentRoundPickCount > 1) ? (" · PICK " + s.CurrentRoundPickIndex + " OF " + s.CurrentRoundPickCount) : ""), 17f, Muted, bold: true)).alignment = (TextAlignmentOptions)514; if (val2 != null) { Icon((Transform)(object)parent, 368f, 62f, 64f, val2); } string text = ((val != null) ? val.Name : null) ?? ((val2 != null) ? val2.Name : null) ?? s.Winner; string value = (num ? "Skip was chosen" : (flag ? "No modifier was chosen" : (text + " modifier was chosen"))); TextMeshProUGUI obj = Label((Transform)(object)parent, 32f, 139f, 736f, 92f, value, 34f, Ink, bold: true); ((TMP_Text)obj).fontSizeMin = 24f; ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; double num2 = Math.Ceiling(Math.Max(0.0, s.RevealUntil - NetworkTime.time)); ((TMP_Text)Label((Transform)(object)parent, 32f, 259f, 736f, 30f, ((s.CurrentRoundPickIndex < s.CurrentRoundPickCount) ? "Next selection in " : "Next hole in ") + num2 + "s", 20f, Muted)).alignment = (TextAlignmentOptions)514; } private void DrawRunSummary() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) RunSnapshot s = View; RectTransform parent = Panel((Transform)(object)uiContent, 220f, 70f, 840f, 580f, Paper); Label((Transform)(object)parent, 32f, 25f, 750f, 28f, "CHAOS RUN / SCORECARD", 18f, Muted, bold: true); Label((Transform)(object)parent, 32f, 65f, 750f, 55f, "That's a wrap!", 40f, null, bold: true); Label((Transform)(object)parent, 32f, 131f, 750f, 50f, "Seed " + s.Seed + " · " + ((object)s.Progression.Selection/*cast due to .constrained prefix*/).ToString() + " · " + s.SelectionNumber + " opportunities · " + s.AcquisitionOrdinal + " modifiers", 19f, Muted); int num = Math.Max(1, (s.History.Length + 4) / 5); summaryPage = Math.Max(0, Math.Min(summaryPage, num - 1)); for (int i = 0; i < 5 && summaryPage * 5 + i < s.History.Length; i++) { RunChoice val = s.History[summaryPage * 5 + i]; ModifierDefinition val2 = UiRegistry.Get(val.Id); float num2 = 200 + i * 52; if (val2 != null) { Icon((Transform)(object)parent, 32f, num2, 42f, val2); } Label((Transform)(object)parent, 90f, num2 + 8f, 690f, 37f, "Hole " + val.Hole + ((val.PickCount > 1) ? (" · Pick " + val.PickIndex + "/" + val.PickCount) : "") + " " + (((val2 != null) ? val2.Name : null) ?? ((val.Id == "skip") ? "Skip" : "No eligible modifier")) + (val.Boss ? " · Boss selection" : ""), 21f); } if (s.History.Length == 0) { Label((Transform)(object)parent, 32f, 225f, 750f, 100f, "A clean round. No modifiers selected.", 23f, Muted); } if (num > 1) { Button((Transform)(object)parent, 32f, 473f, 120f, 34f, "Previous", delegate { summaryPage--; }, null, summaryPage > 0); Button((Transform)(object)parent, 167f, 473f, 120f, 34f, "Next", delegate { summaryPage++; }, null, summaryPage < num - 1); } Label((Transform)(object)parent, 320f, 477f, 410f, 28f, "Page " + (summaryPage + 1) + " / " + num + ((s.SelectionNumber > 64) ? " · latest 64" : ""), 16f, Muted); Button((Transform)(object)parent, 530f, 523f, 278f, 39f, "Back to the range · F9", delegate { dismissedSummary = s.RunId; }); } private void ConfigureAdmission() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown harmony.Patch((MethodBase)AccessTools.Method(typeof(BNetworkManager), "OnServerConnect", (Type[])null, (Type[])null), new HarmonyMethod(typeof(RogueGolfPlugin), "AdmissionServerConnect", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(BNetworkManager), "OnClientConnect", (Type[])null, (Type[])null), new HarmonyMethod(typeof(RogueGolfPlugin), "AdmissionClientConnect", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(BNetworkManager), "OnClientSceneChanged", (Type[])null, (Type[])null), new HarmonyMethod(typeof(RogueGolfPlugin), "AdmissionClientScene", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); string[] array = new string[2] { "OnServerReady", "OnServerAddPlayer" }; foreach (string text in array) { harmony.Patch((MethodBase)AccessTools.Method(typeof(BNetworkManager), text, (Type[])null, (Type[])null), new HarmonyMethod(typeof(RogueGolfPlugin), "AdmissionPlayer", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private static bool AdmissionServerConnect(NetworkConnectionToClient __0) { return Instance?.bridge?.HoldServerConnect(__0) == true; } private static bool AdmissionClientConnect() { return Instance?.bridge?.HoldClientConnect() == true; } private static bool AdmissionClientScene(NetworkManager __instance) { if (__instance is BNetworkManager) { return Instance?.bridge?.HoldClientScene() == true; } return true; } private static bool AdmissionPlayer(NetworkConnectionToClient __0) { return Instance?.bridge?.AllowPlayer(__0) == true; } internal void AdmissionNotice() { ShowNotice("Matching private RogueGolf lobby required. Use Vanilla for other lobbies."); } private Texture2D SetupTexture(string name) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown if (setupTextures.TryGetValue(name, out var value)) { return value; } using (Stream stream = typeof(RogueGolfPlugin).Assembly.GetManifestResourceStream("RogueGolf.Setup." + name + ".png")) { if (stream == null) { throw new InvalidOperationException("Missing embedded setup asset: " + name); } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); value = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(value, memoryStream.ToArray(), true)) { Object.Destroy((Object)(object)value); throw new InvalidDataException("Invalid setup image: " + name); } } ((Object)value).name = "RogueGolf setup " + name; ((Texture)value).filterMode = (FilterMode)1; ((Texture)value).wrapMode = (TextureWrapMode)1; setupTextures.Add(name, value); return value; } private void SetupPicture(Transform p, float x, float y, float width, float height, string name, float alpha = 1f) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) Texture2D val = SetupTexture(name); float num = Math.Min(width / (float)((Texture)val).width, height / (float)((Texture)val).height); float num2 = (float)((Texture)val).width * num; float num3 = (float)((Texture)val).height * num; RawImage obj = ((Component)Rect(p, x + (width - num2) / 2f, y + (height - num3) / 2f, num2, num3, "Approved artwork: " + name)).gameObject.AddComponent(); obj.texture = (Texture)(object)val; ((Graphic)obj).color = new Color(1f, 1f, 1f, alpha); ((Graphic)obj).raycastTarget = false; } private void DisposeSetupTextures() { foreach (Texture2D value in setupTextures.Values) { if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); } } setupTextures.Clear(); } private ScorecardShape SetupSurface(Transform p, float x, float y, float w, float h, Color tint, float radius = 12f, Color? end = null, bool topOnly = false) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) ScorecardShape scorecardShape = Shape(p, x, y, w, h, tint, radius); scorecardShape.TopCornersOnly = topOnly; if (end.HasValue) { scorecardShape.Gradient = true; scorecardShape.GradientEnd = end.Value; } return scorecardShape; } private SetupArtwork SetupArt(Transform p, float x, float y, float size, SetupGlyph glyph, Color? accent = null, float alpha = 1f) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) SetupArtwork setupArtwork = ((Component)Rect(p, x, y, size, size)).gameObject.AddComponent(); setupArtwork.Glyph = glyph; ((Graphic)setupArtwork).color = new Color(1f, 1f, 1f, alpha); ((Graphic)setupArtwork).raycastTarget = false; if (accent.HasValue) { setupArtwork.Accent = accent.Value; } return setupArtwork; } private TextMeshProUGUI SetupHeading(Transform p, float x, float y, float w, float h, string value, float size) { //IL_0035: 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) TextMeshProUGUI val = Label(p, x, y, w, h, value, size, null, bold: true); if (size < 28f || (Object)(object)uiTitleFont == (Object)null) { ((TMP_Text)val).fontStyle = (FontStyles)(((TMP_Text)val).fontStyle | 2); } return val; } private ScorecardShape SetupAction(Transform p, float x, float y, float w, float h, Action action, Color normal, bool active = true, SetupGlyph? glyph = null, string title = null, float font = 16f, bool topOnly = false) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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) ScorecardShape scorecardShape = SetupSurface(p, x - 2f, y - 2f, w + 4f, h + 4f, Gold, h / 2f + 2f, null, topOnly); ScorecardShape scorecardShape2 = SetupSurface(p, x, y, w, h, active ? normal : Color32.op_Implicit(new Color32((byte)225, (byte)225, (byte)205, byte.MaxValue)), h / 2f, null, topOnly); ((Component)scorecardShape).gameObject.SetActive(false); ((Graphic)scorecardShape2).raycastTarget = true; if (glyph.HasValue) { SetupArt(((Component)scorecardShape2).transform, (w - h * 0.62f) / 2f, h * 0.19f, h * 0.62f, glyph.Value, null, active ? 1f : 0.4f); } if (title != null) { ((TMP_Text)Label(((Component)scorecardShape2).transform, 5f, 2f, w - 10f, h - 4f, title, font, active ? Ink : Muted, bold: true)).alignment = (TextAlignmentOptions)514; } if (active) { uiActions.Add(new UiAction { Rect = (RectTransform)((Component)scorecardShape2).transform, Run = action, Shape = scorecardShape2, Normal = normal, FocusOutline = scorecardShape }); } return scorecardShape2; } private RectTransform SetupBook() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) Shape((Transform)(object)uiContent, 0f, 0f, 1280f, 720f, new Color(0f, 0f, 0f, 0.35f), 0f, block: true); SetupSurface((Transform)(object)uiContent, 294f, 19f, 692f, 695f, new Color(0f, 0f, 0f, 0.25f), 22f); RectTransform val = (RectTransform)((Component)SetupSurface((Transform)(object)uiContent, 298f, 12f, 684f, 696f, Ink, 23f)).transform; SetupSurface((Transform)(object)val, 2f, 2f, 680f, 692f, Color32.op_Implicit(new Color32((byte)245, (byte)236, (byte)202, byte.MaxValue)), 21f); SetupArtwork setupArtwork = ((Component)Rect((Transform)(object)val, 4f, 4f, 676f, 688f)).gameObject.AddComponent(); setupArtwork.Glyph = SetupGlyph.Stripes; ((Graphic)setupArtwork).color = Color.white; ((Graphic)setupArtwork).raycastTarget = false; SetupSurface((Transform)(object)val, 8f, 4f, 672f, 688f, SetupCream, 20f); for (int i = 0; i < 9; i++) { float num = 139 + i * 60; SetupSurface((Transform)(object)val, 0f, num - 1f, 15f, 13f, Color32.op_Implicit(new Color32((byte)115, (byte)119, (byte)92, byte.MaxValue)), 6f); SetupSurface((Transform)(object)val, -10f, num, 28f, 12f, Ink, 6f); SetupSurface((Transform)(object)val, -8f, num + 2f, 24f, 8f, SetupCream, 4f); } return val; } private void SetupTab(RectTransform p, float x, float width, string name, int tab) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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) if (pauseTab == tab) { SetupSurface((Transform)(object)p, x - 3f, 87f, width + 6f, 49f, Gold, 17f, null, topOnly: true); SetupSurface((Transform)(object)p, x - 1f, 89f, width + 2f, 45f, SetupCream, 15f, null, topOnly: true); } SetupAction((Transform)(object)p, x, 91f, width, 42f, delegate { pauseTab = tab; settingsPage = 0; selected = 0; uiKey = ""; }, (pauseTab == tab) ? Gold : Green, active: true, null, name, 18f, topOnly: true); } private void SetupSection(RectTransform p, float y, string name, string description, SetupGlyph glyph, int rows) { //IL_0018: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) float num = 36 + rows * 28; SetupSurface((Transform)(object)p, 26f, y, 628f, num, SetupBorder); SetupSurface((Transform)(object)p, 28f, y + 2f, 624f, num - 4f, SetupCream, 10f); SetupSurface((Transform)(object)p, 28f, y + 2f, 624f, 32f, Color32.op_Implicit(new Color32((byte)207, (byte)227, (byte)171, byte.MaxValue)), 10f, Color32.op_Implicit(new Color32((byte)242, (byte)247, (byte)211, byte.MaxValue))); string text = name switch { "Bosses" => "bosses-heading", "Skips" => "skips-heading", "Run" => "run-heading", _ => null, }; if (text != null) { Texture2D val = SetupTexture(text); SetupPicture((Transform)(object)p, 40f, y + 3f, (float)((Texture)val).width * 0.6f, (float)((Texture)val).height * 0.6f, text); } else { SetupArt((Transform)(object)p, 40f, y + 5f, 27f, glyph); SetupHeading((Transform)(object)p, 80f, y + 2f, (name == "HOW IT WORKS") ? 185 : 155, 30f, name, (name == "HOW IT WORKS") ? 18 : 23); } Label((Transform)(object)p, (text != null) ? 184 : ((name == "HOW IT WORKS") ? 270 : 240), y + 7f, (text != null) ? 454 : ((name == "HOW IT WORKS") ? 368 : 398), 22f, description, 12f, Muted, name == "HOW IT WORKS"); } private void SetupRule(RectTransform p, float y) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 76; i++) { SetupSurface((Transform)(object)p, 28 + i * 8, y, 4f, 1f, Color32.op_Implicit(new Color32((byte)211, (byte)213, (byte)180, byte.MaxValue)), 0f); } } private void SetupHelpBox(RectTransform p, string title, string description, float y = 559f) { //IL_0022: 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) SetupRule(p, y - 6f); SetupSurface((Transform)(object)p, 28f, y, 624f, 64f, SetupRow, 13f); settingsHelpName = Label((Transform)(object)p, 44f, y + 6f, 486f, 22f, title, 16f, null, bold: true); settingsHelp = Label((Transform)(object)p, 44f, y + 30f, 492f, 28f, description, 12f, Muted); SetupArt((Transform)(object)p, 553f, y + 5f, 54f, SetupGlyph.Golf, null, 0.23f); } private void SetupFooter(RectTransform p, int page, int pages, Action previous, Action next) { //IL_0018: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) SetupAction((Transform)(object)p, 28f, 630f, 164f, 35f, previous, Green, page > 0, null, "Previous", 19f); ((TMP_Text)Label((Transform)(object)p, 240f, 630f, 204f, 24f, "Page " + (page + 1) + " of " + pages, 15f, Muted, bold: true)).alignment = (TextAlignmentOptions)514; float num = 342 - (pages - 1) * 6; for (int i = 0; i < Math.Min(pages, 16); i++) { SetupSurface((Transform)(object)p, num + (float)(i * 12), 658f, 8f, 8f, (i == page) ? Green : SetupBorder, 4f); } SetupAction((Transform)(object)p, 488f, 630f, 164f, 35f, next, Green, page < pages - 1, null, "Next", 19f); SetupRule(p, 674f); ((TMP_Text)Label((Transform)(object)p, 30f, 679f, 620f, 18f, "Arrows / D-pad: select · Enter / A: use · Esc / B: back", 11f, Muted)).alignment = (TextAlignmentOptions)514; } private Color SetupTierColor(int tier) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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) return Color32.op_Implicit((new Color32[4] { new Color32((byte)103, (byte)174, (byte)65, byte.MaxValue), new Color32((byte)52, (byte)126, (byte)232, byte.MaxValue), new Color32((byte)142, (byte)72, (byte)208, byte.MaxValue), new Color32((byte)223, (byte)79, (byte)101, byte.MaxValue) })[tier]); } private void SpawnThunderProof(bool here) { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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_011b: 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) if (!NetworkServer.active || !enabledMode.Value || !EffectsPlaying || bridge == null || !bridge.CanStart(out var _)) { throw new InvalidOperationException("Thunder proof requires a compatible private host in active play."); } if (worldEvents != null || HasModifier("law_of_zeus")) { throw new InvalidOperationException("Clear Law of Zeus before spawning a manual test storm."); } TickThunderProof(); if (thunderProof != null) { throw new InvalidOperationException("One test storm is already active. Let it finish or stop it first."); } if (Time.timeAsDouble < thunderProofNext) { throw new InvalidOperationException("Wait two seconds between storm requests."); } PlayerInfo val = ((IEnumerable)Players()).FirstOrDefault((Func)((PlayerInfo p) => ((NetworkBehaviour)p).isLocalPlayer)); if ((Object)(object)val == (Object)null) { throw new InvalidOperationException("Host golfer unavailable."); } Vector3 val2 = ((Component)val).transform.position; if (!here) { Vector3 forward = ((Component)val).transform.forward; forward.y = 0f; val2 += ((Vector3)(ref forward)).normalized * Math.Min(12f, GameManager.ItemSettings.ThunderstormRadius * 0.75f); } thunderProofNext = Time.timeAsDouble + 2.0; thunderProof = thunderAdapter.Spawn(val2); thunderProofRun = EffectRunId; thunderProofHole = TestHole; thunderProofStrikes = 0; ((BaseUnityPlugin)this).Logger.LogInfo((object)("[THUNDER] Spawned one ownerless vanilla storm netId=" + ((NetworkBehaviour)thunderProof.Storm).netId + " position=" + ((object)thunderProof.Storm.NetworkaimPoint/*cast due to .constrained prefix*/).ToString() + " " + ThunderstormAdapter.SettingsSummary())); } private void TickThunderProof() { if (thunderProof == null) { return; } if (!NetworkServer.active || !enabledMode.Value || !EffectsPlaying || EffectRunId != thunderProofRun || TestHole != thunderProofHole || bridge == null || !bridge.CanStart(out var _)) { StopThunderProof(); return; } thunderProof.Observe(); thunderProofStrikes = Math.Max(thunderProofStrikes, thunderProof.StrikeCount); if (!thunderProof.Alive) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[THUNDER] Native expiry complete; peak observed concurrent strikes=" + thunderProofStrikes)); thunderProof = null; } } private void StopThunderProof() { if (thunderProof != null) { thunderProof.Stop(); thunderProof = null; thunderProofRun = ""; thunderProofHole = -1; ((BaseUnityPlugin)this).Logger.LogInfo((object)"[THUNDER] Test storm and its pending strikes cancelled."); } } private void OpenTutorial() { tutorialSeen.Value = true; ((BaseUnityPlugin)this).Config.Save(); pauseTab = 4; settingsPage = 0; selected = 0; uiKey = ""; } private void PrepareTutorialAttention(ScorecardShape button) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0021: 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_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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_00fe: Unknown result type (might be due to invalid IL or missing references) tutorialButton = (RectTransform)((Component)button).transform; tutorialButton.pivot = new Vector2(0.5f, 0.5f); RectTransform obj = tutorialButton; obj.anchoredPosition += new Vector2(54f, -16f); tutorialQuestion = (RectTransform)((Component)SetupArt(((Component)button).transform, 5f, 8f, 16f, SetupGlyph.Question)).transform; ((TMP_Text)Label((Transform)(object)tutorialQuestion, 0f, -1f, 16f, 18f, "?", 13f, Color.white, bold: true)).alignment = (TextAlignmentOptions)514; tutorialQuestion.pivot = new Vector2(0.5f, 0.5f); RectTransform obj2 = tutorialQuestion; obj2.anchoredPosition += new Vector2(8f, -8f); float[] array = new float[3] { 4f, 106f, 87f }; float[] array2 = new float[3] { -5f, 4f, 31f }; for (int i = 0; i < 3; i++) { tutorialSparkles[i] = SetupArt(((Component)button).transform, array[i], array2[i], 6f, SetupGlyph.Spark, null, 0f); } if (tutorialAttentionStarted < 0f) { tutorialAttentionStarted = Time.unscaledTime; } } private void UpdateTutorialAttention() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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) if ((Object)(object)tutorialButton == (Object)null) { return; } bool flag = setupOpen && pauseTab != 4 && !resetConfirmation && !tutorialSeen.Value; float num = Time.unscaledTime - tutorialAttentionStarted; float num2 = (flag ? TutorialPresentation.Pulse(num) : 0f); ((Transform)tutorialButton).localScale = Vector3.one * (1f + 0.04f * num2); if ((Object)(object)tutorialQuestion != (Object)null) { ((Transform)tutorialQuestion).localRotation = Quaternion.Euler(0f, 0f, flag ? TutorialPresentation.Wobble(num) : 0f); } SetupArtwork[] array = tutorialSparkles; foreach (SetupArtwork setupArtwork in array) { if ((Object)(object)setupArtwork != (Object)null) { ((Graphic)setupArtwork).color = new Color(1f, 1f, 1f, num2); } } } private void DrawTutorial(RectTransform panel) { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) SetupSection(panel, 147f, "HOW IT WORKS", "A normal first hole. An unreasonable finish.", SetupGlyph.Golf, 0); TextMeshProUGUI[] array = (TextMeshProUGUI[])(object)new TextMeshProUGUI[TutorialPresentation.Bodies.Length]; TextMeshProUGUI[] array2 = (TextMeshProUGUI[])(object)new TextMeshProUGUI[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = Label((Transform)(object)panel, 44f, 0f, 592f, 18f, TutorialPresentation.Headings[i], 14f, null, bold: true); array[i] = Label((Transform)(object)panel, 44f, 0f, 592f, 1f, TutorialPresentation.Bodies[i], 12f, Muted); ((TMP_Text)array[i]).richText = true; ((TMP_Text)array[i]).enableAutoSizing = false; } float num = 12f; float num2 = 0f; while (true) { num2 = 0f; TextMeshProUGUI[] array3 = array; foreach (TextMeshProUGUI val in array3) { ((TMP_Text)val).fontSize = num; num2 += ((TMP_Text)val).GetPreferredValues(((TMP_Text)val).text, 592f, float.PositiveInfinity).y + 26f; } if (num2 <= 435f || num <= 10f) { break; } num -= 0.5f; } float num3 = 193f; for (int k = 0; k < array.Length; k++) { ((TMP_Text)array2[k]).rectTransform.anchoredPosition = new Vector2(44f, 0f - num3); num3 += 19f; float y = ((TMP_Text)array[k]).GetPreferredValues(((TMP_Text)array[k]).text, 592f, float.PositiveInfinity).y; ((TMP_Text)array[k]).rectTransform.anchoredPosition = new Vector2(44f, 0f - num3); ((TMP_Text)array[k]).rectTransform.sizeDelta = new Vector2(592f, y + 1f); num3 += y + 7f; } SetupRule(panel, 634f); ((TMP_Text)Label((Transform)(object)panel, 44f, 640f, 592f, 32f, "Make bad decisions, together.\n— Techn0m4ncer", 12f, null, bold: true)).alignment = (TextAlignmentOptions)514; SetupRule(panel, 674f); ((TMP_Text)Label((Transform)(object)panel, 110f, 679f, 510f, 18f, "Arrows / D-pad: select · Enter / A: use · Esc / B: back", 11f, Muted)).alignment = (TextAlignmentOptions)514; } private void ConfigureVoting() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) candidateCount = ((BaseUnityPlugin)this).Config.Bind("Voting", "CandidateCount", 4, new ConfigDescription("Maximum candidate count; smaller pools offer fewer cards.", (AcceptableValueBase)(object)new AcceptableValueRange(2, 5), Array.Empty())); voteSeconds = ((BaseUnityPlugin)this).Config.Bind("Voting", "DurationSeconds", 15f, new ConfigDescription("Host-authoritative voting deadline.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 120f), Array.Empty())); revealSeconds = ((BaseUnityPlugin)this).Config.Bind("Voting", "RevealSeconds", 3f, new ConfigDescription("Result display before next hole.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 15f), Array.Empty())); skipBudget = ((BaseUnityPlugin)this).Config.Bind("Voting", "SharedSkips", 2, new ConfigDescription("Soft skips per run; zero disables Skip.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 99), Array.Empty())); voteChanges = ((BaseUnityPlugin)this).Config.Bind("Voting", "AllowChanges", true, "Players may replace their vote until close."); earlyClose = ((BaseUnityPlugin)this).Config.Bind("Voting", "CloseWhenAllVote", true, "Resolve once every eligible player has voted."); tieRule = ((BaseUnityPlugin)this).Config.Bind("Voting", "TieRule", (TieRule)0, "Ties always use an equal-chance host random draw. Legacy values are reset to Random."); if ((int)tieRule.Value != 0) { tieRule.Value = (TieRule)0; ((BaseUnityPlugin)this).Config.Save(); } seed = ((BaseUnityPlugin)this).Config.Bind("Voting", "Seed", 0, "Zero chooses a seed each run; nonzero is reproducible."); ConfigureProgression(); bridge = new NetworkBridge(this); PatchNetwork("OnStartServer", "ServerStarted", prefix: false); PatchNetwork("OnStartClient", "ClientStarted", prefix: false); PatchNetwork("OnClientSceneChanged", "ClientSceneReady", prefix: false); PatchNetwork("OnServerDisconnect", "ServerPeerLeft", prefix: true); } private void PatchNetwork(string method, string hook, bool prefix) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(BNetworkManager), method, (Type[])null, (Type[])null); if (methodInfo == null) { throw new MissingMethodException(method); } HarmonyMethod val = new HarmonyMethod(typeof(RogueGolfPlugin), hook, (Type[])null); harmony.Patch((MethodBase)methodInfo, prefix ? val : null, prefix ? null : val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void ServerStarted() { Instance?.NetworkAction(delegate { Instance.bridge.StartServer(); Instance.customItems?.StartServer(); }); } private static void ClientStarted() { Instance?.NetworkAction(delegate { Instance.bridge.StartClient(); Instance.customItems?.StartClient(); }); } private static void ClientSceneReady() { Instance?.QueuePeerSceneRefresh(); } private static void ServerPeerLeft(NetworkConnectionToClient __0) { Instance?.bridge.Disconnect(__0.connectionId); } private void NetworkAction(Action action) { try { action(); } catch (Exception ex) { networkFault = true; ShowNotice("RogueGolf networking unavailable; see log."); ((BaseUnityPlugin)this).Logger.LogError((object)ex); } } private void ShowNotice(string message) { notice = message; noticeUntil = Time.realtimeSinceStartup + 8f; } internal void NetLog(string message) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[NET] " + message)); } private bool BeginAuthoritativeRun() { //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Expected O, but got Unknown //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Expected O, but got Unknown //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { return true; } EndRangeTesting(); if (Run.Active) { return false; } resetLiveSettings = null; customItems?.UseNextCourseSettings(); try { ((BaseUnityPlugin)this).Config.Reload(); } catch (Exception ex) { ShowNotice("Cannot read RogueGolf config; course start blocked."); ((BaseUnityPlugin)this).Logger.LogWarning((object)ex); return false; } if (!enabledMode.Value) { return true; } if (networkFault || (stage.Value != PrototypeStage.Lifecycle && !bridge.CanStart(out notice))) { ShowNotice(notice); ((BaseUnityPlugin)this).Logger.LogWarning((object)("[RUN] Course start blocked: " + notice)); return false; } runStage = stage.Value; notice = ""; lastWinnerVote = 0; uint num = (uint)((seed.Value == 0) ? DateTime.UtcNow.Ticks : seed.Value); try { BeginProgression(num); } catch (ArgumentException ex2) { ShowNotice("Invalid progression config: " + ex2.Message); ((BaseUnityPlugin)this).Logger.LogWarning((object)("[PROGRESSION] " + ex2.Message)); return false; } voting = new VoteCoordinator(new VoteSettings(candidateCount.Value, (double)voteSeconds.Value, voteChanges.Value, earlyClose.Value, (TieRule)0, skipBudget.Value, (double)revealSeconds.Value), num, runStage != PrototypeStage.Modifiers) { RandomChoice = SecureVoteRandom.Next }; BeginModifiers(num); ManualLogSource logger = ((BaseUnityPlugin)this).Logger; Vector3 gravity = Physics.gravity; logger.LogInfo((object)("[MODIFIER] Run baseline=" + ((Vector3)(ref gravity)).ToString("F4"))); Run.Begin(Guid.NewGuid().ToString("N")); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[RUN] seed=" + num + " stage=" + runStage)); return true; } private void OpenVote() { if (runStage == PrototypeStage.Modifiers) { PrepareProgressionVote(); } else { voting.Open(bridge.Eligible, NetworkTime.time, (VoteOption[])null); } Run.Transition((RunState)5, (RunState)6, "VoteOpened"); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[VOTE] Opened id=" + voting.Vote.Id + " candidates=" + string.Join(",", voting.Vote.Options.Select((VoteOption o) => o.Id)) + " eligible=" + voting.Vote.Eligible.Length + " skips=" + ((runStage == PrototypeStage.Modifiers) ? skipLedger.Shared : voting.Skips))); } internal void AcceptIntent(int player, Packet packet) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Invalid comparison between Unknown and I4 //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Invalid comparison between Unknown and I4 //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || !Run.Active) { return; } VoteCoordinator obj = voting; if (((obj != null) ? obj.Vote : null) != null && !(packet.RunId != Run.RunId) && packet.VoteId == voting.Vote.Id) { bool flag = false; if ((int)packet.Kind == 3 && (int)Run.State == 6 && (runStage != PrototypeStage.Modifiers || (int)progression.Selection == 0)) { flag = voting.Vote.Cast(player, packet.Option, NetworkTime.time); } if ((int)packet.Kind == 4 && player == bridge.HostId) { flag = voting.Vote.HostChoose(packet.Option, NetworkTime.time); } if (flag) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[VOTE] Accepted connection=" + player + " option=" + packet.Option + " vote=" + packet.VoteId)); TickVote(); Publish(); } } } internal void PeerDisconnected(int id) { customItems?.PeerDisconnected(id); if (id == bridge.HostId) { ClearRunResources(); Run.Stop("HostDisconnect"); return; } VoteCoordinator obj = voting; if (((obj != null) ? obj.Vote : null) != null && voting.Vote.Disconnect(id)) { TickVote(); Publish(); } } private void TickVote() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 if (!gate.Held || (runStage != PrototypeStage.Voting && runStage != PrototypeStage.Modifiers)) { return; } VoteCoordinator obj = voting; if (((obj != null) ? obj.Vote : null) == null) { return; } bool flag = voting.Tick(NetworkTime.time); if (voting.Vote.Closed && (int)Run.State == 6) { Run.Transition((RunState)6, (RunState)7, "VoteClosed"); } if (voting.Vote.Winner != "" && lastWinnerVote != voting.Vote.Id) { lastWinnerVote = voting.Vote.Id; if (runStage == PrototypeStage.Modifiers) { ApplyProgressionWinner(); } Run.Transition((RunState)7, (RunState)8, (runStage == PrototypeStage.Modifiers) ? "ModifierWinnerReveal" : "DummyWinnerReveal"); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[VOTE] Winner=" + voting.Vote.Winner + " vote=" + lastWinnerVote + " skips=" + ((runStage == PrototypeStage.Modifiers) ? skipLedger.Shared : voting.Skips) + " effect=" + ((modifiers == null) ? "none" : string.Join(",", modifiers.Active.Select((ActiveModifier e) => e.Id))))); } if (flag) { Publish(); } if (voting.RevealUntil > 0.0 && NetworkTime.time >= voting.RevealUntil) { if (runStage == PrototypeStage.Modifiers && roundSelections.Advance()) { voting.ClearVote(); Run.Transition((RunState)8, (RunState)5, "NextRoundPick"); OpenVote(); Publish(); } else { ReleaseIntermission(); } } } internal void Publish() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0065: 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_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_008d: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Expected O, but got Unknown if (bridge != null && NetworkServer.active && !quitting) { VoteCoordinator obj = voting; VoteSession val = ((obj != null) ? obj.Vote : null); RunSnapshot val2 = new RunSnapshot { Session = bridge.Session, RunId = EffectRunId, Revision = ++snapshotRevision, State = (RunState)(RangeTesting ? 3 : ((int)Run.State)), Hole = TestHole, Density = density, RoundOrdinal = roundSelections.RoundOrdinal, AcquisitionOrdinal = roundSelections.AcquisitionOrdinal, CurrentRoundPickIndex = roundSelections.PickIndex, CurrentRoundPickCount = roundSelections.PickCount, Progression = progression, SelectionNumber = selectionNumber, BossSelection = bossSelection, SummaryComplete = summaryComplete, History = runHistory.ToArray(), PersonalSkips = PersonalSkipView(), ModifierMode = (runStage == PrototypeStage.Modifiers), GravityBaseline = gravityBaseline, ModifierSettings = modifierSettings, PlayerShotFactors = new Dictionary(playerShotFactors) }; ModifierManager obj2 = modifiers; val2.AvailableModifiers = ((obj2 != null) ? obj2.Available : null) ?? Array.Empty(); ModifierManager obj3 = modifiers; val2.ActiveModifiers = ((obj3 != null) ? obj3.Active : null) ?? Array.Empty(); int skips; if (runStage != PrototypeStage.Modifiers) { VoteCoordinator obj4 = voting; skips = ((obj4 != null) ? obj4.Skips : 0); } else { SkipLedger obj5 = skipLedger; skips = ((obj5 != null) ? obj5.Shared : 0); } val2.Skips = skips; val2.Seed = progressionSeed; VoteCoordinator obj6 = voting; val2.Settings = (VoteSettings)(((object)((obj6 != null) ? obj6.Settings : null)) ?? ((object)new VoteSettings(4, 15.0, true, true, (TieRule)0, 2, 3.0))); val2.Host = bridge.HostId; val2.VoteId = ((val != null) ? val.Id : 0); val2.Deadline = ((val != null) ? val.Deadline : releaseAt); val2.TieDeadline = ((val != null) ? val.TieDeadline : 0.0); VoteCoordinator obj7 = voting; val2.RevealUntil = ((obj7 != null) ? obj7.RevealUntil : 0.0); val2.NextCycleAt = (EffectsPlaying ? nextWorldTick : 0.0); val2.Winner = ((val != null) ? val.Winner : null) ?? ""; val2.Options = ((val != null) ? val.Options : null) ?? Array.Empty(); val2.Eligible = ((val != null) ? val.Eligible : null) ?? Array.Empty(); val2.Ballots = ((val == null) ? new Dictionary() : val.Ballots.ToDictionary((KeyValuePair x) => x.Key, (KeyValuePair x) => x.Value)); val2.Tied = ((val != null) ? val.Tied : null) ?? Array.Empty(); val2.Notice = notice; RunSnapshot source = val2; bridge.SendSnapshot(source); } } internal void SnapshotReceived(RunSnapshot snapshot) { ReceiveEffects(snapshot); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[NET] Snapshot rev=" + snapshot.Revision + " state=" + ((object)Unsafe.As(ref snapshot.State)/*cast due to .constrained prefix*/).ToString() + " vote=" + snapshot.VoteId + " ballots=" + snapshot.Ballots.Count + " skips=" + snapshot.Skips + " winner=" + snapshot.Winner)); } private void ClearRunResources() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Invalid comparison between Unknown and I4 //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Invalid comparison between Unknown and I4 RestoreRateCompatibility(); resetLiveSettings = null; customItems?.UseNextCourseSettings(); customItems?.Cleanup("run resources cleared"); RemoveDummy(); testingRangeId = ""; CloseTestingMenu(); if ((int)roundSelections.Status == 1 || (int)roundSelections.Status == 2) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[DENSITY] Cancel pending round=" + roundSelections.RoundOrdinal + " pick=" + roundSelections.PickIndex + "/" + roundSelections.PickCount + " status=" + ((object)roundSelections.Status/*cast due to .constrained prefix*/).ToString())); } roundSelections.Cancel(); gate.Cancel(); RestoreEffects(); modifiers = null; voting = null; lastWinnerVote = 0; } private bool CanChoose(RunSnapshot s, string option) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Invalid comparison between Unknown and I4 if (s.ModifierMode && (int)s.Progression.Selection != 0) { return false; } if ((int)s.State == 7) { if (s.Recipient == s.Host && s.Tied.Contains(option)) { return s.Winner == ""; } return false; } if (s.ModifierMode && option == "skip" && (!s.PersonalSkips.TryGetValue(s.Recipient, out var value) || value <= 0)) { return false; } if ((int)s.State == 6 && s.Eligible.Contains(s.Recipient)) { if (!s.Settings.AllowChanges) { return !s.Ballots.ContainsKey(s.Recipient); } return true; } return false; } private void Choose(string option) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 if (InputAvailable && View != null && CanChoose(View, option)) { bridge.Vote(option, (int)View.State == 7); } } private void SetUiFocus(bool value) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if ((!value || (InputManager.CurrentModeMask & 0x1000) == 0) && uiFocus != value) { uiFocus = value; if (value) { InputManager.EnableMode((InputMode)4096); } else if (!quitting) { InputManager.DisableMode((InputMode)4096); } uiKey = ""; } } private void UpdateUIInput() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) if (UpdateTestingInput() || !Application.isFocused || (InputManager.CurrentModeMask & 0xEC0) != 0) { return; } Keyboard current = Keyboard.current; Gamepad current2 = Gamepad.current; if (setupOpen && ((current != null && ((ButtonControl)current.escapeKey).wasPressedThisFrame) || (current2 != null && current2.buttonEast.wasPressedThisFrame))) { if (resetConfirmation) { resetConfirmation = false; uiKey = ""; } else { CloseRunSetup(); } return; } if (MatchSetupVisible && NetworkServer.active && ((current != null && ((ButtonControl)current.f7Key).wasPressedThisFrame) || (current2 != null && current2.buttonNorth.wasPressedThisFrame))) { if (setupOpen) { CloseRunSetup(); } else { OpenRunSetup(); } return; } if (uiFocus && ((current != null && ((ButtonControl)current.escapeKey).wasPressedThisFrame) || (current2 != null && current2.buttonEast.wasPressedThisFrame))) { SetUiFocus(value: false); return; } if (Paused && ((current != null && ((ButtonControl)current.f7Key).wasPressedThisFrame) || (current2 != null && current2.buttonNorth.wasPressedThisFrame))) { SetPauseMinimized(value: false); SetUiFocus(!uiFocus); return; } if (SummaryVisible && ((current != null && ((ButtonControl)current.f9Key).wasPressedThisFrame) || (current2 != null && current2.buttonEast.wasPressedThisFrame))) { dismissedSummary = View.RunId; uiKey = ""; return; } if (NetworkServer.active && current != null && ((ButtonControl)current.f8Key).wasPressedThisFrame) { enabledMode.Value = !enabledMode.Value; ((BaseUnityPlugin)this).Config.Save(); ShowNotice("RogueGolf " + (enabledMode.Value ? "enabled for next course" : "disabled")); } if (((Paused && !pauseMinimized) || setupOpen) && current != null) { if (((ButtonControl)current.qKey).wasPressedThisFrame) { ChangePage(-1); } if (((ButtonControl)current.eKey).wasPressedThisFrame) { ChangePage(1); } } if (OverlayVisible && InputAvailable && current != null) { KeyControl[] array = (KeyControl[])(object)new KeyControl[6] { current.digit1Key, current.digit2Key, current.digit3Key, current.digit4Key, current.digit5Key, current.digit6Key }; for (int i = 0; i < View.Options.Length; i++) { if (((ButtonControl)array[i]).wasPressedThisFrame) { Choose(View.Options[i].Id); } } } if (!Paused && !MatchSetupVisible && !SummaryVisible && (!OverlayVisible || !InputAvailable)) { return; } Mouse current3 = Mouse.current; if (current3 != null && current3.leftButton.wasPressedThisFrame) { Vector2 point = ((InputControl)(object)((Pointer)current3).position).ReadValue(); UiAction uiAction = uiActions.LastOrDefault((UiAction a) => RectTransformUtility.RectangleContainsScreenPoint(a.Rect, point)); if (uiAction != null) { uiAction.Run(); uiKey = ""; return; } } if ((Paused || MatchSetupVisible) && !uiFocus) { return; } if ((current != null && ((ButtonControl)current.rightArrowKey).wasPressedThisFrame) || (current != null && ((ButtonControl)current.tabKey).wasPressedThisFrame) || (current2 != null && current2.dpad.right.wasPressedThisFrame) || (current2 != null && current2.dpad.down.wasPressedThisFrame)) { selected++; } if ((current != null && ((ButtonControl)current.leftArrowKey).wasPressedThisFrame) || (current2 != null && current2.dpad.left.wasPressedThisFrame) || (current2 != null && current2.dpad.up.wasPressedThisFrame)) { selected--; } if (uiActions.Count > 0) { selected = (selected % uiActions.Count + uiActions.Count) % uiActions.Count; if ((current != null && ((ButtonControl)current.enterKey).wasPressedThisFrame) || (current2 != null && current2.buttonSouth.wasPressedThisFrame)) { uiActions[selected].Run(); uiKey = ""; } } } private void ChangePage(int delta) { if (pauseTab == 0) { effectPage = Math.Max(0, effectPage + delta); } else { settingsPage = Math.Max(0, settingsPage + delta); } uiKey = ""; } private void SetPauseMinimized(bool value) { pauseMinimized = value; if (value) { SetUiFocus(value: false); } selected = 0; uiKey = ""; } private void LateUpdate() { //IL_0026: 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_0048: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) RefreshPeerScene(); if (testingOpen && !CanUseTestingMenu(out var _)) { CloseTestingMenu(); } if (setupOpen && ((InputManager.CurrentModeMask & 0x100) == 0 || !NetworkServer.active)) { CloseRunSetup(); } if (uiFocus && ((InputManager.CurrentModeMask & 0x120) == 0 || (!NetworkClient.active && !NetworkServer.active))) { SetUiFocus(value: false); } RenderUi(); UpdateCycleDisplay(); UpdateTutorialAttention(); if (testingOpen || (OverlayVisible && !NativeMenuFocused) || SummaryVisible) { if (!cursorOwned) { previousCursor = Cursor.lockState; previousVisible = Cursor.visible; cursorOwned = true; } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } else { RestoreCursor(); } int num = -1; if (Mouse.current != null) { for (int i = 0; i < uiActions.Count; i++) { if (RectTransformUtility.RectangleContainsScreenPoint(uiActions[i].Rect, ((InputControl)(object)((Pointer)Mouse.current).position).ReadValue())) { num = i; } } } int num2 = ((num >= 0) ? num : selected); if ((Object)(object)settingsHelp != (Object)null && num2 >= 0 && num2 < uiActions.Count && !string.IsNullOrEmpty(uiActions[num2].Help)) { ((TMP_Text)settingsHelp).text = uiActions[num2].Help; if ((Object)(object)settingsHelpName != (Object)null) { ((TMP_Text)settingsHelpName).text = uiActions[num2].HelpName ?? "How it works"; } } for (int j = 0; j < uiActions.Count; j++) { UiAction uiAction = uiActions[j]; bool flag = j == num || ((testingOpen || uiFocus || OverlayVisible || SummaryVisible) && j == selected); if ((Object)(object)uiAction.FocusOutline != (Object)null) { ((Component)uiAction.FocusOutline).gameObject.SetActive(flag); ((Graphic)uiAction.Shape).color = uiAction.Normal; } else { ((Graphic)uiAction.Shape).color = (flag ? Gold : uiAction.Normal); } } } private void RestoreCursor() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_0021: 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_0030: Invalid comparison between Unknown and I4 //IL_0044: 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_0038: Invalid comparison between Unknown and I4 if (!cursorOwned) { return; } cursorOwned = false; if (quitting) { return; } int num; int num2; if ((int)InputManager.CurrentMode != 2 && (int)InputManager.CurrentMode != 16 && (int)InputManager.CurrentMode != 4) { num = (((int)InputManager.CurrentMode != 8) ? 1 : 0); if (num != 0) { num2 = 0; goto IL_004c; } } else { num = 0; } num2 = (int)previousCursor; goto IL_004c; IL_004c: Cursor.lockState = (CursorLockMode)num2; Cursor.visible = num != 0 || previousVisible; } private void DisposeUi() { CloseTestingMenu(); setupOpen = false; pauseTab = 0; SetUiFocus(value: false); if ((Object)(object)uiObject != (Object)null) { Object.Destroy((Object)(object)uiObject); } uiObject = null; uiKey = ""; uiActions.Clear(); } private bool EnsureUi() { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)uiObject != (Object)null) { return true; } TMP_FontAsset[] source = Resources.FindObjectsOfTypeAll(); uiFont = ((IEnumerable)source).FirstOrDefault((Func)((TMP_FontAsset f) => ((Object)f).name.IndexOf("Gabarito-SemiBold", StringComparison.OrdinalIgnoreCase) >= 0)) ?? ((IEnumerable)source).FirstOrDefault((Func)((TMP_FontAsset f) => ((Object)f).name.IndexOf("Gabarito", StringComparison.OrdinalIgnoreCase) >= 0)) ?? TMP_Settings.defaultFontAsset ?? source.FirstOrDefault(); if ((Object)(object)uiFont == (Object)null) { return false; } uiObject = new GameObject("RogueGolf scorecards", new Type[4] { typeof(RectTransform), typeof(Canvas), typeof(CanvasScaler), typeof(GraphicRaycaster) }); Object.DontDestroyOnLoad((Object)(object)uiObject); uiRoot = (RectTransform)uiObject.transform; Canvas component = uiObject.GetComponent(); component.renderMode = (RenderMode)0; component.sortingOrder = 30000; CanvasScaler component2 = uiObject.GetComponent(); component2.uiScaleMode = (ScaleMode)1; component2.referenceResolution = new Vector2(1280f, 720f); component2.screenMatchMode = (ScreenMatchMode)1; ((BaseUnityPlugin)this).Logger.LogInfo((object)("[UI] Native font=" + ((Object)uiFont).name + "; original vector icons ready")); return true; } private RectTransform Rect(Transform parent, float x, float y, float width, float height, string name = "Element") { //IL_0015: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0054: 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_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_0072: Expected O, but got Unknown RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) }).transform; ((Transform)val).SetParent(parent, false); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 1f); val.pivot = val2; Vector2 anchorMin = (val.anchorMax = val2); val.anchorMin = anchorMin; val.anchoredPosition = new Vector2(x, 0f - y); val.sizeDelta = new Vector2(width, height); return val; } private ScorecardShape Shape(Transform parent, float x, float y, float w, float h, Color color, float radius = 14f, bool block = false) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) ScorecardShape scorecardShape = ((Component)Rect(parent, x, y, w, h)).gameObject.AddComponent(); ((Graphic)scorecardShape).color = color; scorecardShape.Radius = radius; ((Graphic)scorecardShape).raycastTarget = block; return scorecardShape; } private RectTransform Panel(Transform parent, float x, float y, float w, float h, Color color, bool block = true) { //IL_0022: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown Shape(parent, x, y + 4f, w, h, new Color(0f, 0f, 0f, 0.2f), 18f); ScorecardShape scorecardShape = Shape(parent, x, y, w, h, Ink, 18f, block); Shape(((Component)scorecardShape).transform, 2f, 2f, w - 4f, h - 4f, color, 16f); return (RectTransform)((Component)scorecardShape).transform; } private TextMeshProUGUI Label(Transform parent, float x, float y, float w, float h, string value, float size = 20f, Color? color = null, bool bold = false) { //IL_007f: 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) TextMeshProUGUI obj = ((Component)Rect(parent, x, y, w, h, "Text")).gameObject.AddComponent(); ((TMP_Text)obj).font = ((bold && size >= 28f && (Object)(object)uiTitleFont != (Object)null) ? uiTitleFont : uiFont); ((TMP_Text)obj).text = value; ((TMP_Text)obj).fontSize = size; ((TMP_Text)obj).fontStyle = (FontStyles)(bold ? 1 : 0); ((Graphic)obj).color = (Color)(((??)color) ?? Ink); ((Graphic)obj).raycastTarget = false; ((TMP_Text)obj).enableAutoSizing = true; ((TMP_Text)obj).fontSizeMin = size - 2f; ((TMP_Text)obj).fontSizeMax = size; ((TMP_Text)obj).overflowMode = (TextOverflowModes)1; ((TMP_Text)obj).richText = false; return obj; } private void Button(Transform parent, float x, float y, float w, float h, string title, Action action, Color? color = null, bool active = true) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) ScorecardShape scorecardShape = Shape(parent, x, y, w, h, (Color)((!active) ? Color32.op_Implicit(new Color32((byte)225, (byte)224, (byte)202, byte.MaxValue)) : (((??)color) ?? Green)), h / 2f, block: true); ((TMP_Text)Label(((Component)scorecardShape).transform, 10f, 4f, w - 20f, h - 8f, title, 18f, active ? Ink : Muted, bold: true)).alignment = (TextAlignmentOptions)514; if (active) { uiActions.Add(new UiAction { Rect = (RectTransform)((Component)scorecardShape).transform, Run = action, Shape = scorecardShape, Normal = (Color)(((??)color) ?? Green) }); } } private Color TierColor(ModifierRarity rarity) { //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_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_0053: 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_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) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) return Color32.op_Implicit((new Color32[4] { new Color32((byte)132, (byte)185, (byte)84, byte.MaxValue), new Color32((byte)88, (byte)184, (byte)195, byte.MaxValue), new Color32((byte)239, (byte)179, (byte)53, byte.MaxValue), new Color32((byte)223, (byte)104, (byte)106, byte.MaxValue) })[rarity]); } private void Icon(Transform parent, float x, float y, float size, ModifierDefinition d, bool suspended = false) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected I4, but got Unknown //IL_0105: 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_019b: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) ScorecardShape scorecardShape = Shape(parent, x, y, size, size, suspended ? Color32.op_Implicit(new Color32((byte)174, (byte)178, (byte)157, byte.MaxValue)) : TierColor(d.Rarity), size / 3f); Shape(((Component)scorecardShape).transform, 2f, 2f, size - 4f, size - 4f, Paper, size / 3f); EffectIconGraphic effectIconGraphic = ((Component)Rect(((Component)scorecardShape).transform, 5f, 5f, size - 10f, size - 10f)).gameObject.AddComponent(); effectIconGraphic.Symbol = EffectPresentation.Symbol(d.Id); ((Graphic)effectIconGraphic).color = (suspended ? Muted : Ink); ((Graphic)effectIconGraphic).raycastTarget = false; if (suspended) { Shape(((Component)scorecardShape).transform, size - 14f, size - 15f, 4f, 10f, Muted, 1f); Shape(((Component)scorecardShape).transform, size - 7f, size - 15f, 4f, 10f, Muted, 1f); } int num = d.Rarity + 1; float num2 = Math.Max(2f, size / 14f); for (int i = 0; i < num; i++) { Shape(((Component)scorecardShape).transform, 3f + (float)i * (num2 + 1f), size - 5f, num2, 2f, suspended ? Muted : Ink, 0f); } string text = Conditions.Direction(d); if (text != "") { float num3 = Math.Max(13f, size * 0.39f); ScorecardShape scorecardShape2 = Shape(((Component)scorecardShape).transform, size - num3, -2f, num3, num3, suspended ? Muted : Color32.op_Implicit((Color32)((text == "+") ? new Color32((byte)53, (byte)111, (byte)88, byte.MaxValue) : ((text == "−") ? new Color32((byte)154, (byte)74, (byte)66, byte.MaxValue) : Color32.op_Implicit(Ink)))), num3 / 2f); ((TMP_Text)Label(((Component)scorecardShape2).transform, 0f, -1f, num3, num3 + 1f, text, num3 - 2f, Color.white, bold: true)).alignment = (TextAlignmentOptions)514; } } private void RenderUi() { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Invalid comparison between Unknown and I4 //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) if (!EnsureUi()) { return; } if ((Object)(object)uiTitleFont == (Object)null && (Object)(object)PauseMenu.ResumeButton != (Object)null) { TMP_Text componentInChildren = ((Component)PauseMenu.ResumeButton).GetComponentInChildren(); uiTitleFont = ((componentInChildren != null) ? componentInChildren.font : null); uiKey = ""; if ((Object)(object)uiTitleFont != (Object)null) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[UI] Native heading font=" + ((Object)uiTitleFont).name)); } } bool flag = Paused && (NetworkServer.active || NetworkClient.active); string text = (testingOpen ? "testing" : ((MatchSetupVisible && NetworkServer.active) ? (setupOpen ? "setup" : "setupLink") : (flag ? "pause" : (SummaryVisible ? "summary" : ((OverlayVisible && !NativeMenuFocused) ? "vote" : ((View != null && (int)View.State == 3 && InputAvailable) ? "hud" : "none")))))); string text2 = text + ":" + (View?.Revision ?? 0) + ":" + pauseTab + ":" + effectPage + ":" + settingsPage + ":" + weightTab + ":" + summaryPage + ":" + uiFocus + ":" + pauseMinimized + ":" + Screen.width + ":" + Screen.height; if (text == "vote") { text2 = text2 + ":" + (int)NetworkTime.time; } text2 += ((notice != "" && (double)Time.realtimeSinceStartup < noticeUntil) ? (":" + notice) : ":clear"); if (!(text2 == uiKey)) { uiKey = text2; uiActions.Clear(); cycleLabel = null; cycleRing = null; conditionLabels.Clear(); if ((Object)(object)uiContent != (Object)null) { ((Component)uiContent).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)uiContent).gameObject); } RectTransform parent = uiRoot; Rect rect = uiRoot.rect; float x = Math.Max(0f, (((Rect)(ref rect)).width - 1280f) / 2f); rect = uiRoot.rect; uiContent = Rect((Transform)(object)parent, x, Math.Max(0f, (((Rect)(ref rect)).height - 720f) / 2f), 1280f, 720f, "Content"); switch (text) { case "testing": DrawTestingMenu(); break; case "setup": DrawRunSetup(); break; case "setupLink": Button((Transform)(object)uiContent, 795f, 646f, 240f, 38f, "RogueGolf Settings F7", OpenRunSetup, Gold); break; case "pause": DrawPause(); break; case "summary": DrawRunSummary(); break; case "vote": DrawVote(); break; case "hud": DrawModifierHud(); DrawCycles(); break; } if (text != "pause" && text != "testing" && notice != "" && (double)Time.realtimeSinceStartup < noticeUntil) { RectTransform parent2 = Panel((Transform)(object)uiContent, 320f, 20f, 640f, 54f, Paper, block: false); Label((Transform)(object)parent2, 18f, 12f, 604f, 34f, notice, 18f); } selected = Math.Max(0, Math.Min(selected, uiActions.Count - 1)); } } private string SkipLabel(RunSnapshot s) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Invalid comparison between Unknown and I4 if (!s.ModifierMode) { return s.Skips + " skips left"; } if ((int)s.Progression.Skips == 2) { return "Unlimited skips"; } if ((int)s.Progression.Skips == 3) { return "No skips"; } if ((int)s.Progression.Skips != 1) { return s.Skips + " shared skips left"; } int value; return (s.PersonalSkips.TryGetValue(s.Recipient, out value) ? value : 0) + " personal skips left"; } private void Pager(RectTransform p, int page, int pages, Action previous, Action next) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) Button((Transform)(object)p, 20f, 519f, 110f, 33f, "Previous", previous, null, page > 0); Label((Transform)(object)p, 145f, 524f, 210f, 26f, "Page " + (page + 1) + " of " + pages, 16f, Muted); Button((Transform)(object)p, 370f, 519f, 110f, 33f, "Next", next, null, page < pages - 1); } private bool HasRule(Mechanic rule) { //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 return (mechanics & rule) > 0; } private bool HasModifier(string id) { return currentIds.Contains(id); } private void RefreshMechanics() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) mechanics = (Mechanic)0; currentIds.Clear(); ModifierManager obj = modifiers; ModifierRegistry val = ((obj != null) ? obj.Registry : null) ?? ModifierRegistry.Create(modifierSettings); foreach (ActiveModifier item in CurrentEffects.Where((ActiveModifier e) => !e.Suspended)) { mechanics |= val.Get(item.Id).Rule; currentIds.Add(item.Id); } } private float PlayerShotFactor(PlayerInfo player) { if (!((Object)(object)player != (Object)null) || !playerShotFactors.TryGetValue(player.PlayerId.Guid, out var value)) { return 1f; } return value; } private static bool Offensive(ItemType item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_000b: 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_0013: Invalid comparison between Unknown and I4 if ((int)item != 0 && (int)item != 1 && (int)item != 5 && (int)item != 13) { return (int)item != 17; } return false; } private static bool Powerful(ItemType item) { //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_0007: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if ((int)item != 7 && (int)item != 10 && (int)item != 16 && (int)item != 15 && (int)item != 3) { return (int)item == 17; } return true; } private bool AllowsContext(ModifierDefinition definition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_0018: 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) if ((int)definition.Rule == 1048576 && !formula1Available) { return false; } if ((definition.Channel & 0x2000) != 0) { if (EffectsPlaying || InDrivingRange) { return Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0).Length != 0; } int num = Run.HoleIndex + 1; CourseData currentCourse = GameManager.CurrentCourse; if ((Object)(object)currentCourse != (Object)null && num >= 0 && num < currentCourse.Holes.Length) { return verifiedTrafficScenes.Contains(currentCourse.Holes[num].Scene.Name); } return false; } return true; } private void ConfigureWorldChannels() { Channel((EffectChannel)128, delegate { NativeHook(typeof(ItemSpawnerSettings), "get_RespawnTime", null, "ScaleRespawn"); NativeHook(typeof(ItemPool), "GetWeightedRandomItem", "SelectWeightedItem"); }); Channel((EffectChannel)256, delegate { removeItem = AccessTools.DeclaredMethod(typeof(PlayerInventory), "RemoveItemAt", (Type[])null, (Type[])null) ?? throw new MissingMethodException("RemoveItemAt"); NativeHook(typeof(ItemData), "get_MaxUses", null, "ScaleAmmo"); NativeHook(typeof(PlayerInventory), "TryUseItem", "RestrictItemUse"); }); ConfigureFormula1(); Channel((EffectChannel)2048, delegate { if (AccessTools.DeclaredMethod(typeof(CourseManager), "GetSortedPlayerStates", (Type[])null, (Type[])null) == null) { throw new MissingMethodException("Leaderboard"); } }); Channel((EffectChannel)8192, delegate { NativeHook(typeof(TrafficSpawner), "OnBUpdate", "BeforeTraffic", "AfterTraffic"); }); Channel((EffectChannel)1024, delegate { if (AccessTools.DeclaredMethod(typeof(Entity), "InformTeleported", (Type[])null, (Type[])null) == null) { throw new MissingMethodException("Entity teleport"); } }); Channel((EffectChannel)512, delegate { explodeRocket = AccessTools.DeclaredMethod(typeof(Rocket), "ServerExplode", (Type[])null, (Type[])null) ?? throw new MissingMethodException("Native rocket explosion"); NativeHook(typeof(GolfBall), "OnCollisionEnter", null, "BallImpact"); NativeHook(typeof(Hittable), "HitWithItemInternal", null, "PlayerItemImpact"); NativeHook(typeof(Hittable), "HitWithGolfSwingInternal", null, "PlayerClubImpact"); NativeHook(typeof(Hittable), "HitWithSwingProjectileInternal", null, "PlayerProjectileImpact"); NativeHook(typeof(CourseManager), "InformPlayerKnockedOut", null, "PlayerVehicleImpact"); NativeHook(typeof(PlayerGolfer), "ServerEliminate", "BeforeElimination", "AfterElimination"); NativeHook(typeof(CourseManager), "InformPlayerEliminated", "ConfirmedElimination"); NativeHook(typeof(ItemSettings), "get_RocketExplosionRange", null, "ExplosionRange"); NativeHook(typeof(Hittable), "HitWithItem", "AllowExplosionTarget"); }); } private static void ScaleRespawn(ref float __result) { if ((Object)(object)Instance != (Object)null && ((EffectValues)(ref Instance.effects))[(Parameter)8] != 1f) { __result = Math.Max(0.5f, __result / ((EffectValues)(ref Instance.effects))[(Parameter)8]); } } private static void ScaleAmmo(ref int __result) { if ((Object)(object)Instance != (Object)null && ((EffectValues)(ref Instance.effects))[(Parameter)9] != 1f && __result > 0) { __result = Math.Min(100, (int)Math.Ceiling((float)__result * ((EffectValues)(ref Instance.effects))[(Parameter)9])); } } private static bool SelectWeightedItem(ItemPool __instance, ref ItemType __result) { //IL_00c3: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected I4, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected I4, but got Unknown RogueGolfPlugin p = Instance; if ((Object)(object)p == (Object)null || !NetworkServer.active || p.worldRandom == null || ((EffectValues)(ref p.effects))[(Parameter)10] == 1f) { return true; } ItemSpawnChance[] array = __instance.SpawnChances.Where((ItemSpawnChance e) => e.spawnChanceWeight > 0f && (int)e.item > 0).ToArray(); if (array.Length == 0) { return true; } double num = (double)p.worldRandom.Next(1000000) / 1000000.0 * (double)((IEnumerable)array).Sum((Func)Weight); ItemSpawnChance[] array2 = array; foreach (ItemSpawnChance val in array2) { num -= (double)Weight(val); if (num <= 0.0) { __result = (ItemType)(int)val.item; return false; } } __result = (ItemType)(int)array[^1].item; return false; float Weight(ItemSpawnChance e) { //IL_0000: 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_0007: Unknown result type (might be due to invalid IL or missing references) return e.spawnChanceWeight * (Powerful(e.item) ? ((EffectValues)(ref p.effects))[(Parameter)10] : 1f); } } private static bool RestrictItemUse(PlayerInventory __instance, ref bool __result, ref bool shouldEatInput) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Instance == (Object)null || !Instance.HasRule((Mechanic)8) || !Offensive(__instance.GetEffectivelyEquippedItem(false))) { return true; } __result = false; shouldEatInput = true; return false; } private static void BeforeTraffic(ref float ___spawnDelay, out float __state) { __state = ___spawnDelay; if ((Object)(object)Instance != (Object)null && NetworkServer.active && ((EffectValues)(ref Instance.effects))[(Parameter)12] != 1f) { ___spawnDelay = Math.Max(0.5f, ___spawnDelay / ((EffectValues)(ref Instance.effects))[(Parameter)12]); } } private static void AfterTraffic(ref float ___spawnDelay, float __state) { RogueGolfPlugin instance = Instance; if (!((Object)(object)instance == (Object)null) && NetworkServer.active && ((EffectValues)(ref instance.effects))[(Parameter)12] != 1f && Math.Abs(___spawnDelay - Math.Max(0.5f, __state / ((EffectValues)(ref instance.effects))[(Parameter)12])) < 0.0001f) { ___spawnDelay = __state; } } private void ResetWorldEffects() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) StopDunkGolf(); StopThunderProof(); StopActiveEvents(); eventFaulted = false; remoteActive = Array.Empty(); playerShotFactors.Clear(); mechanics = (Mechanic)0; currentIds.Clear(); nextWorldTick = (nextPlayerScan = (nextExplosion = 0.0)); worldHole = -1; explosionsThisHole = 0; grantedPlayers.Clear(); deathPositions.Clear(); creatingExplosion = false; explosionSource = null; explosionRecipientOnly = false; ResetImpactTracking(); } private void StartHoleEffects(int hole) { //IL_002e: 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_00d6: 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_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) if (NetworkServer.active && modifiers != null && hole != worldHole) { bool flag = Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0).Length != 0; if (flag) { HashSet hashSet = verifiedTrafficScenes; Scene activeScene = SceneManager.GetActiveScene(); hashSet.Add(((Scene)(ref activeScene)).name); } if (modifiers.Suspend("golf_kart_warfare", !flag)) { ApplyEffects(EffectRunId, gravityBaseline, modifiers.Values); } eventFaulted = false; BindScoringTriggers(); worldHole = hole; nextWorldTick = NetworkTime.time + (double)modifierSettings.Interval; nextPlayerScan = 0.0; grantedPlayers.Clear(); deathPositions.Clear(); explosionsThisHole = 0; ResetImpactTracking(); sharedLoadout = ChooseItem(basic: false, powerful: false); RecalculateRankEffects(); Publish(); } } private void RecalculateRankEffects() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) playerShotFactors.Clear(); PlayerState[] source = (from p in CourseManager.GetSortedPlayerStates() where p.isConnected && !p.isInSpectatorMode select p).ToArray(); playerShotFactors = RankEffects.Calculate(source.Select((PlayerState p) => p.playerGuid), mechanics, modifierSettings); } private ItemType ChooseItem(bool basic, bool powerful) { ItemData val = default(ItemData); ItemType[] array = (from ItemType t in Enum.GetValues(typeof(ItemType)) where (int)t != 0 && (!basic || (int)t == 1 || (int)t == 2 || (int)t == 4 || (int)t == 5) && (!powerful || Powerful(t)) && GameManager.AllItems.TryGetItemData(t, ref val) select t).ToArray(); if (array.Length == 0) { return (ItemType)0; } return array[worldRandom.Next(array.Length)]; } private unsafe void Grant(PlayerInventory inventory, ItemType item, bool replaceIfFull = false) { //IL_0000: 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_005d: Unknown result type (might be due to invalid IL or missing references) ItemData val = default(ItemData); if ((int)item == 0 || !GameManager.AllItems.TryGetItemData(item, ref val)) { return; } int num = default(int); if (!inventory.HasSpaceForItem(ref num)) { if (!replaceIfFull || inventory.slots.Count == 0) { return; } removeItem.Invoke(inventory, new object[3] { 0, false, false }); } if (inventory.ServerTryAddItem(item, val.MaxUses)) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[EFFECT] Granted " + ((object)(*(ItemType*)(&item))/*cast due to .constrained prefix*/).ToString() + " uses=" + val.MaxUses + " hole=" + worldHole)); } } private void Reroll(PlayerInventory inventory, bool powerful) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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) if ((int)inventory.PlayerInfo.NetworkedCurrentItemUse != 0 || inventory.PlayerInfo.NetworkedIsAimingItem) { return; } for (int i = 0; i < inventory.slots.Count; i++) { if ((int)inventory.slots[i].itemType != 0) { removeItem.Invoke(inventory, new object[3] { i, false, false }); } } int num = (powerful ? inventory.slots.Count : Math.Min(2, inventory.slots.Count)); for (int j = 0; j < num; j++) { Grant(inventory, ChooseItem(basic: false, powerful)); } } private void TrimAmmo() { //IL_002f: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_008c: 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_00d7: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || removeItem == null) { return; } pendingAmmoTrim = false; PlayerInfo[] array = Players(); ItemData val3 = default(ItemData); foreach (PlayerInfo val in array) { if ((int)val.NetworkedCurrentItemUse != 0 || val.NetworkedIsAimingItem) { pendingAmmoTrim = true; continue; } for (int j = 0; j < val.Inventory.slots.Count; j++) { InventorySlot val2 = val.Inventory.slots[j]; if ((int)val2.itemType != 0 && GameManager.AllItems.TryGetItemData(val2.itemType, ref val3) && val3.MaxUses > 0 && val2.remainingUses > val3.MaxUses) { removeItem.Invoke(val.Inventory, new object[3] { j, false, false }); val.Inventory.ServerTryAddItem(val2.itemType, val3.MaxUses); } } } } private static PlayerInfo[] Players() { return (from p in Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0) where (Object)(object)p.Inventory != (Object)null && (Object)(object)p.AsGolfer != (Object)null && !IsDummy(p) orderby ((NetworkBehaviour)p).netId select p).ToArray(); } private void TickWorldEffects() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Invalid comparison between Unknown and I4 //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_02d3: Unknown result type (might be due to invalid IL or missing references) if (pendingAmmoTrim) { TrimAmmo(); } if (!NetworkServer.active || modifiers == null || !EffectsPlaying || worldRandom == null) { return; } TickImpactTracking(); PlayerInfo[] array; if (NetworkTime.time >= nextPlayerScan) { nextPlayerScan = NetworkTime.time + 0.5; array = Players(); foreach (PlayerInfo val in array) { if ((int)val.AsGolfer.MatchResolution != 0 || !grantedPlayers.Add(((NetworkBehaviour)val).netId)) { continue; } if (HasRule((Mechanic)65536)) { Reroll(val.Inventory, powerful: true); } else { if (HasRule((Mechanic)1)) { Grant(val.Inventory, ChooseItem(basic: true, powerful: false), replaceIfFull: true); } if (HasRule((Mechanic)2)) { Grant(val.Inventory, ChooseItem(basic: false, powerful: false), replaceIfFull: true); } if (HasRule((Mechanic)4)) { Grant(val.Inventory, sharedLoadout, replaceIfFull: true); } } if (HasRule((Mechanic)524288)) { Grant(val.Inventory, (ItemType)11, replaceIfFull: true); } if (HasRule((Mechanic)1048576)) { Grant(val.Inventory, (ItemType)6, replaceIfFull: true); } } } if (NetworkTime.time < nextWorldTick) { return; } nextWorldTick = NetworkTime.time + (double)modifierSettings.Interval; bool flag = false; ActiveModifier[] active = modifiers.Active; foreach (ActiveModifier val2 in active) { if (!val2.Suspended && CanonicalCatalog.IsTimed(modifiers.Registry.Get(val2.Id).Rule)) { flag |= modifiers.SetVariant(val2.Id, ((int)modifiers.Registry.Get(val2.Id).Rule == 16384) ? ((val2.Variant + 1) % 4) : worldRandom.Next(32)); } } if (flag) { ApplyEffects(EffectRunId, gravityBaseline, modifiers.Values); Publish(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[EFFECT] Timed physics updated hole=" + worldHole)); } array = Players(); foreach (PlayerInfo val3 in array) { if (!val3.Movement.IsRespawning && (int)val3.AsGolfer.MatchResolution == 0) { if (HasRule((Mechanic)65536)) { Reroll(val3.Inventory, powerful: true); } else if (HasRule((Mechanic)32)) { Reroll(val3.Inventory, powerful: false); } else if (HasRule((Mechanic)16)) { Grant(val3.Inventory, ChooseItem(basic: false, powerful: false)); } } } if (HasRule((Mechanic)256)) { SwapBalls(); } if (!flag && CurrentEffects.Any((ActiveModifier e) => !e.Suspended && EffectPresentation.HasCycle(modifiers.Registry.Get(e.Id).Rule))) { Publish(); } } private void SwapBalls() { GolfBall[] array = (from p in Players() where !p.Movement.IsRespawning && (int)p.AsGolfer.MatchResolution == 0 select p.AsGolfer.OwnBall into b where (Object)(object)b != (Object)null && !b.Rigidbody.isKinematic select b).ToArray(); if (array.Length >= 2) { RotateBalls(array); } } private void RotateBalls(GolfBall[] balls) { //IL_004c: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = balls.Select((GolfBall b) => b.Rigidbody.position).ToArray(); for (int num = 0; num < balls.Length; num++) { GolfBall val = balls[num]; val.AsEntity.InformWillTeleport(); val.Rigidbody.position = array[(num + 1) % balls.Length]; ((Component)val).transform.position = val.Rigidbody.position; val.Rigidbody.linearVelocity = Vector3.zero; val.Rigidbody.angularVelocity = Vector3.zero; val.AsEntity.InformTeleported(); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("[EFFECT] Swapped balls=" + balls.Length + " hole=" + worldHole)); } private static void BeforeElimination(PlayerGolfer __instance) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Instance != (Object)null && NetworkServer.active) { Instance.deathPositions[__instance] = ((Component)__instance).transform.position; } } private static void AfterElimination(PlayerGolfer __instance) { Instance?.deathPositions.Remove(__instance); } private static void ConfirmedElimination(PlayerGolfer eliminatedPlayer) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) RogueGolfPlugin instance = Instance; if ((Object)(object)instance != (Object)null && NetworkServer.active && instance.HasRule((Mechanic)131136)) { instance.TryExplosion(instance.deathPositions.TryGetValue(eliminatedPlayer, out var value) ? value : ((Component)eliminatedPlayer).transform.position); } } private static void BallImpact(GolfBall __instance, Collision collision) { //IL_0024: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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) RogueGolfPlugin instance = Instance; if ((Object)(object)instance == (Object)null || !NetworkServer.active || !instance.HasRule((Mechanic)131200)) { return; } Vector3 relativeVelocity = collision.relativeVelocity; if (((Vector3)(ref relativeVelocity)).magnitude < instance.modifierSettings.ImpactThreshold || (Object)(object)((Component)collision.collider).GetComponentInParent() != (Object)null) { return; } for (int i = 0; i < collision.contactCount; i++) { ContactPoint contact = collision.GetContact(i); if (!(((ContactPoint)(ref contact)).normal.y < 0.5f)) { instance.TryExplosion(((ContactPoint)(ref contact)).point, __instance.AsEntity.AsHittable); break; } } } private static bool AllowExplosionTarget(Hittable __instance, ItemType itemType) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 RogueGolfPlugin instance = Instance; if ((Object)(object)instance == (Object)null || !instance.creatingExplosion || (int)itemType != 7) { return true; } bool num = (instance.explosionRecipientOnly ? ((Object)(object)__instance == (Object)(object)instance.explosionSource) : ((Object)(object)__instance != (Object)(object)instance.explosionSource)); if (num) { instance.SuppressImpact(__instance); } return num; } private static void ExplosionRange(ref float __result) { if ((Object)(object)Instance != (Object)null && Instance.creatingExplosion) { __result = Math.Min(12f, Instance.modifierSettings.ExplosionRadius * (float)((!Instance.HasRule((Mechanic)131072)) ? 1 : 2)); } } private void TryExplosion(Vector3 position, Hittable source = null, bool recipientOnly = false) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_00db: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || (!EffectsPlaying && (int)Run.State != 4) || creatingExplosion || NetworkTime.time < nextExplosion || explosionsThisHole >= 24 || HasRule((Mechanic)8) || ((Object)(object)source != (Object)null && ImpactBlocked(source)) || (recipientOnly && ((Object)(object)source == (Object)null || !source.AsEntity.IsPlayer)) || (Object)(object)GameManager.ItemSettings.RocketPrefab == (Object)null) { return; } if ((Object)(object)source != (Object)null) { SuppressImpact(source); } nextExplosion = NetworkTime.time + (double)modifierSettings.ExplosionCooldown; explosionsThisHole++; creatingExplosion = true; explosionSource = source; explosionRecipientOnly = recipientOnly; try { Rocket val = Object.Instantiate(GameManager.ItemSettings.RocketPrefab, position, Quaternion.identity); val.ServerInitialize((PlayerInfo)null, (Hittable)null, ItemUseId.Invalid); NetworkServer.Spawn(((Component)val).gameObject, (NetworkConnectionToClient)null); explodeRocket.Invoke(val, new object[1] { position }); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[EFFECT] Native explosion count=" + explosionsThisHole + " hole=" + worldHole)); } finally { creatingExplosion = false; explosionSource = null; explosionRecipientOnly = false; } } } public sealed class CycleRing : MaskableGraphic { private float progress; public float Progress { set { if (!(Mathf.Abs(progress - value) < 0.002f)) { progress = value; ((Graphic)this).SetVerticesDirty(); } } } protected override void OnPopulateMesh(VertexHelper mesh) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) mesh.Clear(); Rect rect = ((Graphic)this).rectTransform.rect; float num = Mathf.Min(((Rect)(ref rect)).width, ((Rect)(ref rect)).height) / 2f; Vector2 val2 = default(Vector2); Vector2 val3 = default(Vector2); for (int i = 0; i < 64; i++) { float num2 = (90f - (float)i * 360f / 64f) * ((float)Math.PI / 180f); float num3 = (90f - (float)(i + 1) * 360f / 64f) * ((float)Math.PI / 180f); Color32 val = (((float)i / 64f < progress) ? new Color32((byte)237, (byte)207, (byte)107, byte.MaxValue) : new Color32((byte)150, (byte)163, (byte)138, (byte)70)); ((Vector2)(ref val2))..ctor(Mathf.Cos(num2), Mathf.Sin(num2)); ((Vector2)(ref val3))..ctor(Mathf.Cos(num3), Mathf.Sin(num3)); int currentVertCount = mesh.currentVertCount; Vector2[] array = (Vector2[])(object)new Vector2[4] { ((Rect)(ref rect)).center + val2 * num, ((Rect)(ref rect)).center + val3 * num, ((Rect)(ref rect)).center + val3 * (num - 3f), ((Rect)(ref rect)).center + val2 * (num - 3f) }; foreach (Vector2 val4 in array) { mesh.AddVert(Vector2.op_Implicit(val4), val, Vector4.op_Implicit(Vector2.zero)); } mesh.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2); mesh.AddTriangle(currentVertCount, currentVertCount + 2, currentVertCount + 3); } } } internal static class DefaultsConfig { internal const PrototypeStage Stage = PrototypeStage.Modifiers; internal const float IntermissionSeconds = 5f; internal static bool IsGameplaySection(string section) { if (!new string[10] { "General", "Intermission", "Voting", "Progression", "Density", "Modifiers", "Modifiers.Enabled", "Tuning", "LawOfZeus", "CustomItems" }.Contains(section) && !section.StartsWith("Weights.", StringComparison.Ordinal)) { return section.StartsWith("CustomItems.", StringComparison.Ordinal); } return true; } internal static int Reset(ConfigFile config) { ConfigEntryBase[] array = (from p in (IEnumerable>)config where IsGameplaySection(p.Key.Section) select p.Value).ToArray(); bool saveOnConfigSet = config.SaveOnConfigSet; config.SaveOnConfigSet = false; try { ConfigEntryBase[] array2 = array; foreach (ConfigEntryBase val in array2) { int num2 = Array.IndexOf(new string[3] { "EarlyMidStartsAtPercent", "MidLateStartsAtPercent", "LateStartsAtPercent" }, val.Definition.Key); val.BoxedValue = ((val.Definition.Section == "Progression" && num2 >= 0) ? ((object)RogueGolfDefaults.PhaseThresholds[num2 + 1]) : val.DefaultValue); } config.Save(); } finally { config.SaveOnConfigSet = saveOnConfigSet; } return array.Length; } } public sealed class ScorecardShape : MaskableGraphic { public float Radius = 14f; public bool TopCornersOnly; public bool Gradient; public Color GradientEnd; protected override void OnPopulateMesh(VertexHelper mesh) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) mesh.Clear(); Rect r = ((Graphic)this).rectTransform.rect; float num = Math.Min(Radius, Math.Min(((Rect)(ref r)).width, ((Rect)(ref r)).height) / 2f); mesh.AddVert(Vector2.op_Implicit(((Rect)(ref r)).center), Color32.op_Implicit(Tint(((Rect)(ref r)).center)), Vector4.op_Implicit(Vector2.zero)); Vector2 val = default(Vector2); for (int i = 0; i < 4; i++) { float num2 = ((TopCornersOnly && i >= 2) ? 0f : num); ((Vector2)(ref val))..ctor((i == 0 || i == 3) ? (((Rect)(ref r)).xMax - num2) : (((Rect)(ref r)).xMin + num2), (i < 2) ? (((Rect)(ref r)).yMax - num2) : (((Rect)(ref r)).yMin + num2)); for (int j = 0; j <= 8; j++) { float num3 = ((float)(i * 90) + (float)j * 90f / 8f) * ((float)Math.PI / 180f); Vector2 val2 = val + new Vector2(Mathf.Cos(num3), Mathf.Sin(num3)) * num2; mesh.AddVert(Vector2.op_Implicit(val2), Color32.op_Implicit(Tint(val2)), Vector4.op_Implicit(Vector2.zero)); } } for (int k = 1; k <= 36; k++) { mesh.AddTriangle(0, k, (k == 36) ? 1 : (k + 1)); } Color Tint(Vector2 p) { //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_001b: 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_0009: Unknown result type (might be due to invalid IL or missing references) if (!Gradient) { return ((Graphic)this).color; } return Color.Lerp(((Graphic)this).color, GradientEnd, (p.x - ((Rect)(ref r)).xMin) / Math.Max(1f, ((Rect)(ref r)).width)); } } } public sealed class EffectIconGraphic : MaskableGraphic { public EffectSymbol Symbol; private VertexHelper mesh; private Vector2 P(float x, float y) { //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) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Rect rect = ((Graphic)this).rectTransform.rect; return new Vector2(((Rect)(ref rect)).xMin + x * ((Rect)(ref rect)).width / 100f, ((Rect)(ref rect)).yMax - y * ((Rect)(ref rect)).height / 100f); } private void Line(float x, float y, float x2, float y2, float width = 5f) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0055: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0087: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00a3: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) Vector2 val = P(x, y); Vector2 val2 = P(x2, y2); Vector2 val3 = new Vector2(0f - (val2 - val).y, (val2 - val).x); Vector2 normalized = ((Vector2)(ref val3)).normalized; Rect rect = ((Graphic)this).rectTransform.rect; Vector2 val4 = normalized * ((Rect)(ref rect)).width * width / 200f; int currentVertCount = mesh.currentVertCount; Vector2[] array = (Vector2[])(object)new Vector2[4] { val - val4, val + val4, val2 + val4, val2 - val4 }; foreach (Vector2 val5 in array) { mesh.AddVert(Vector2.op_Implicit(val5), Color32.op_Implicit(((Graphic)this).color), Vector4.op_Implicit(Vector2.zero)); } mesh.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2); mesh.AddTriangle(currentVertCount, currentVertCount + 2, currentVertCount + 3); } private void Path(params float[] xy) { for (int i = 0; i < xy.Length - 2; i += 2) { Line(xy[i], xy[i + 1], xy[i + 2], xy[i + 3]); } } private void Circle(float x, float y, float radius, bool fill = false) { //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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (fill) { int currentVertCount = mesh.currentVertCount; mesh.AddVert(Vector2.op_Implicit(P(x, y)), Color32.op_Implicit(((Graphic)this).color), Vector4.op_Implicit(Vector2.zero)); for (int i = 0; i < 24; i++) { float num = (float)i * (float)Math.PI / 12f; mesh.AddVert(Vector2.op_Implicit(P(x + Mathf.Cos(num) * radius, y + Mathf.Sin(num) * radius)), Color32.op_Implicit(((Graphic)this).color), Vector4.op_Implicit(Vector2.zero)); } for (int j = 0; j < 24; j++) { mesh.AddTriangle(currentVertCount, currentVertCount + 1 + j, currentVertCount + 1 + (j + 1) % 24); } } else { for (int k = 0; k < 24; k++) { float num2 = (float)k * (float)Math.PI / 12f; float num3 = (float)(k + 1) * (float)Math.PI / 12f; Line(x + Mathf.Cos(num2) * radius, y + Mathf.Sin(num2) * radius, x + Mathf.Cos(num3) * radius, y + Mathf.Sin(num3) * radius, 4f); } } } private void Box(float x, float y, float w, float h) { Path(x, y, x + w, y, x + w, y + h, x, y + h, x, y); } protected override void OnPopulateMesh(VertexHelper helper) { //IL_001f: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected I4, but got Unknown //IL_095a: Unknown result type (might be due to invalid IL or missing references) //IL_0960: Invalid comparison between Unknown and I4 helper.Clear(); mesh = helper; int variant = Symbol.Variant; EffectGlyph glyph = Symbol.Glyph; switch ((int)glyph) { case 0: Path(56f, 13f, 26f, 54f, 48f, 54f, 39f, 87f, 77f, 41f, 55f, 41f, 56f, 13f); break; case 1: Circle(50f, 24f, 10f); Path(28f, 37f, 72f, 37f, 84f, 80f, 16f, 80f, 28f, 37f); Line(50f, 50f, 50f, 68f); break; case 2: Path(21f, 81f, 70f, 23f, 82f, 18f, 81f, 39f, 65f, 65f, 40f, 72f, 27f, 83f); Line(41f, 62f, 39f, 44f); Line(51f, 51f, 69f, 48f); break; case 3: { float radius = variant switch { 4 => 32, 2 => 27, 1 => 21, 3 => 15, 5 => 10, _ => 36, }; Circle(50f, 48f, radius); Circle(44f, 42f, 2f, fill: true); Circle(54f, 48f, 2f, fill: true); Circle(44f, 54f, 2f, fill: true); Line(17f, 88f, 83f, 88f, 3f); break; } case 4: Path(14f, 66f, 30f, 83f, 52f, 33f, 70f, 68f, 86f, 30f); Circle(86f, 20f, 7f); Line(15f, 90f, 87f, 90f, 3f); break; case 5: Line(50f, 16f, 50f, 78f); Line(23f, 31f, 77f, 64f); Line(23f, 64f, 77f, 31f); Path(39f, 20f, 50f, 30f, 61f, 20f); Path(39f, 75f, 50f, 65f, 61f, 75f); Line(14f, 88f, 83f, 88f, 3f); break; case 6: Path(39f, 16f, 61f, 16f, 61f, 31f, 71f, 43f, 71f, 77f, 29f, 77f, 29f, 43f, 39f, 31f, 39f, 16f); Line(31f, 54f, 69f, 54f); Circle(50f, 66f, 4f, fill: true); Line(20f, 88f, 80f, 88f); break; case 7: Box(21f, 39f, 58f, 43f); Box(17f, 31f, 66f, 12f); Line(50f, 31f, 50f, 82f); Path(50f, 30f, 30f, 27f, 26f, 15f, 39f, 15f, 50f, 30f, 61f, 15f, 74f, 15f, 70f, 27f, 50f, 30f); break; case 8: Path(24f, 53f, 24f, 33f, 37f, 33f, 37f, 23f, 50f, 23f, 50f, 20f, 63f, 20f, 63f, 28f, 76f, 28f, 76f, 62f, 63f, 80f, 32f, 80f, 18f, 61f, 18f, 49f, 33f, 49f, 44f, 60f); Line(37f, 35f, 37f, 48f); Line(50f, 29f, 50f, 48f); Line(63f, 32f, 63f, 49f); break; case 9: Path(50f, 13f, 81f, 25f, 76f, 60f, 64f, 77f, 50f, 88f, 36f, 77f, 24f, 60f, 19f, 25f, 50f, 13f); if (variant == 2 || variant == 4) { Path(55f, 24f, 43f, 46f, 58f, 52f, 44f, 75f); } else { Path(34f, 50f, 46f, 63f, 68f, 37f); } break; case 10: Path(21f, 80f, 21f, 31f, 31f, 15f, 41f, 31f, 41f, 80f, 21f, 80f); Line(21f, 66f, 41f, 66f); Path(57f, 80f, 57f, 31f, 67f, 15f, 77f, 31f, 77f, 80f, 57f, 80f); Line(57f, 66f, 77f, 66f); break; case 11: Circle(50f, 50f, 20f); Path(14f, 65f, 21f, 41f, 45f, 20f, 73f, 13f, 87f, 24f, 79f, 50f, 53f, 75f, 26f, 87f, 14f, 76f, 14f, 65f); Circle(79f, 27f, 7f, fill: true); break; case 12: Box(20f, 20f, 60f, 60f); Circle(34f, 34f, 5f, fill: true); Circle(66f, 66f, 5f, fill: true); Circle(50f, 50f, 5f, fill: true); if (variant > 1) { Circle(34f, 66f, 5f, fill: true); Circle(66f, 34f, 5f, fill: true); } break; case 13: Circle(50f, 50f, 34f); Line(50f, 16f, 50f, 84f); Path(23f, 72f, 50f, 47f, 77f, 72f); break; case 14: Path(19f, 30f, 34f, 48f, 50f, 20f, 66f, 48f, 82f, 30f, 73f, 74f, 27f, 74f, 19f, 30f); Line(28f, 84f, 73f, 84f); break; case 15: Line(28f, 87f, 28f, 16f); Path(29f, 18f, 77f, 18f, 61f, 35f, 77f, 51f, 29f, 51f); Circle(29f, 87f, 8f); break; case 16: Circle(50f, 53f, 31f); Line(50f, 53f, 50f, 30f); Line(50f, 53f, 68f, 61f); Line(40f, 11f, 60f, 11f); Line(50f, 11f, 50f, 22f); break; case 17: Path(50f, 10f, 60f, 35f, 82f, 20f, 72f, 44f, 94f, 50f, 70f, 60f, 83f, 83f, 58f, 72f, 50f, 94f, 40f, 71f, 17f, 84f, 29f, 60f, 7f, 50f, 30f, 40f, 18f, 17f, 42f, 29f, 50f, 10f); Circle(50f, 51f, 9f); break; case 18: Path(16f, 34f, 80f, 34f, 64f, 19f); Line(80f, 34f, 64f, 49f); Path(84f, 67f, 20f, 67f, 36f, 52f); Line(20f, 67f, 36f, 82f); break; case 19: Path(17f, 67f, 17f, 47f, 28f, 45f, 38f, 27f, 67f, 27f, 77f, 45f, 86f, 47f, 86f, 67f, 17f, 67f); Line(30f, 45f, 74f, 45f); Circle(32f, 71f, 10f); Circle(72f, 71f, 10f); break; case 20: Circle(50f, 50f, 35f); Path(50f, 15f, 36f, 32f, 32f, 52f, 39f, 73f, 50f, 85f, 62f, 68f, 68f, 50f, 61f, 29f, 50f, 15f); Line(18f, 40f, 83f, 40f); Line(18f, 62f, 83f, 62f); break; case 22: Path(50f, 50f, 32f, 27f, 18f, 30f, 10f, 48f, 19f, 68f, 33f, 72f, 50f, 50f, 67f, 28f, 82f, 29f, 91f, 48f, 82f, 69f, 66f, 70f, 50f, 50f); break; case 23: Path(18f, 49f, 12f, 39f, 20f, 27f, 34f, 27f, 39f, 16f, 57f, 14f, 69f, 28f, 82f, 27f, 91f, 39f, 84f, 50f, 18f, 49f); Path(54f, 51f, 34f, 70f, 50f, 70f, 43f, 89f, 71f, 62f, 55f, 62f); break; default: Circle(50f, 50f, 28f); break; } if ((int)Symbol.Glyph != 3 && variant > 1) { for (int i = 0; i < variant - 1; i++) { Circle(32 + i * 10, 95f, 2.5f, fill: true); } } } } public enum PrototypeStage { Lifecycle, Intermission, Voting, Modifiers } public struct RogueClientMessage : NetworkMessage { public byte[] Data; } public struct RogueServerMessage : NetworkMessage { public byte[] Data; } internal sealed class NetworkBridge : IDisposable { private const string HostKey = "roguegolf_host_v1"; private const string MemberKey = "roguegolf_peer_v1"; private static readonly string Capability = 10 + "/1.1.5/"; private readonly RogueGolfPlugin plugin; private readonly Dictionary ready = new Dictionary(); private readonly IntentGuard guard = new IntentGuard(); internal readonly Replica Replica = new Replica(); private string expectedHost = ""; private string nonce = ""; private long intentSequence; private double pollAt; private double helloAt; private bool serverRegistered; private bool clientRegistered; private readonly AdmissionGate admission = new AdmissionGate(); private readonly Dictionary pendingConnections = new Dictionary(); private readonly Dictionary challenges = new Dictionary(); private bool replayConnect; private bool clientAdmitted; private bool heldClientConnect; private bool heldClientScene; private bool rejectingHost; private string challenge = ""; private double clientDeadline; private double admissionPoll; internal string Session { get; private set; } = ""; internal int HostId => ((NetworkConnectionToClient)(NetworkServer.localConnection?)).connectionId ?? 0; internal IEnumerable Eligible => (from c in NetworkServer.connections.Values where ((NetworkConnection)c).isAuthenticated && ((object)c == NetworkServer.localConnection || ready.ContainsKey(c.connectionId)) select c.connectionId).ToArray(); internal bool IsPrivateSession { get { Lobby val = default(Lobby); if (BNetworkManager.TryGetSteamLobby(ref val)) { return CompatibilityPolicy.PrivateLobby(((Lobby)(ref val)).GetData("sbg_lobbyMode")); } return false; } } internal bool ClientVerified { get { if (clientRegistered && clientAdmitted) { return NetworkClient.isConnected; } return false; } } private static double Now => Time.realtimeSinceStartupAsDouble; internal NetworkBridge(RogueGolfPlugin owner) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown plugin = owner; } private static void CheckId() where T : struct, NetworkMessage { ushort id = NetworkMessages.GetId(); if (NetworkMessages.Lookup.TryGetValue(id, out var value) && value != typeof(T)) { throw new InvalidOperationException("Mirror message ID collision with " + value.FullName); } } private static void Write(NetworkWriter w, byte[] bytes) { if (bytes == null || bytes.Length > 16384) { throw new InvalidDataException("Invalid RogueGolf message length"); } NetworkWriterExtensions.WriteInt(w, bytes.Length); w.WriteBytes(bytes, 0, bytes.Length); } private static byte[] Read(NetworkReader r) { int num = NetworkReaderExtensions.ReadInt(r); if (num < 0 || num > 16384 || num > r.Remaining) { throw new InvalidDataException("Invalid RogueGolf message length"); } return NetworkReaderExtensions.ReadBytes(r, num); } private static void Serializers() { Writer.write = delegate(NetworkWriter w, RogueClientMessage m) { Write(w, m.Data); }; Reader.read = (NetworkReader r) => new RogueClientMessage { Data = Read(r) }; Writer.write = delegate(NetworkWriter w, RogueServerMessage m) { Write(w, m.Data); }; Reader.read = (NetworkReader r) => new RogueServerMessage { Data = Read(r) }; } internal void StartServer() { CheckId(); Serializers(); ready.Clear(); guard.Clear(); Session = Guid.NewGuid().ToString("N"); NetworkServer.RegisterHandler((Action)ReceiveClient, true); serverRegistered = true; BeginServerAdmission(); plugin.NetLog("Server handlers ready"); } internal void StartClient() { CheckId(); Serializers(); nonce = Guid.NewGuid().ToString("N"); expectedHost = ""; intentSequence = 0L; helloAt = 0.0; NetworkClient.RegisterHandler((Action)ReceiveServer, true); clientRegistered = true; BeginClientAdmission(); plugin.NetLog("Client handlers ready"); if (NetworkServer.active) { expectedHost = Session; Replica.Reset(Session); } } internal void Update() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: 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_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown TickAdmission(); if (NetworkTime.time < pollAt) { return; } pollAt = NetworkTime.time + 0.5; Lobby val = default(Lobby); if (!BNetworkManager.TryGetSteamLobby(ref val)) { return; } if (NetworkServer.active && serverRegistered) { string text = Capability + SteamClient.SteamId.Value + "/" + Session; if (((Lobby)(ref val)).GetData("roguegolf_host_v1") != text) { ((Lobby)(ref val)).SetData("roguegolf_host_v1", text); } } else { if (!clientRegistered || !clientAdmitted || !NetworkClient.isConnected || NetworkClient.connection == null || !((NetworkConnection)NetworkClient.connection).isAuthenticated) { return; } string data = ((Lobby)(ref val)).GetData("roguegolf_host_v1"); string text2 = Capability + ((Lobby)(ref val)).Owner.Id.Value + "/"; if (!data.StartsWith(text2, StringComparison.Ordinal) || data.Length != text2.Length + 32) { return; } string text3 = data.Substring(text2.Length); if (expectedHost != text3) { RejectHost("Host verification changed during the session."); return; } string text4 = Capability + text3 + "/" + nonce; if (((Lobby)(ref val)).GetMemberData(new Friend(SteamClient.SteamId), "roguegolf_peer_v1") != text4) { ((Lobby)(ref val)).SetMemberData("roguegolf_peer_v1", text4); } if (Replica.Current == null && NetworkTime.time >= helloAt) { helloAt = NetworkTime.time + 2.0; NetworkClient.Send(new RogueClientMessage { Data = Wire.Encode(new Packet { Kind = (PacketKind)1, Session = text3, Nonce = nonce, Capabilities = plugin.Capabilities }) }, 0); } } } internal bool CanStart(out string reason) { reason = ""; Lobby val = default(Lobby); if (!serverRegistered || !BNetworkManager.TryGetSteamLobby(ref val)) { reason = "RogueGolf requires a private Steam host lobby."; return false; } if (NetworkServer.connections.Count > 64) { reason = "RogueGolf supports at most 64 connections."; return false; } if (!CompatibilityPolicy.PrivateLobby(((Lobby)(ref val)).GetData("sbg_lobbyMode"))) { reason = "Set lobby mode to Invite Only or Friends Only for RogueGolf."; return false; } if (NetworkServer.connections.Values.Any((NetworkConnectionToClient c) => (object)c != NetworkServer.localConnection && (!((NetworkConnection)c).isAuthenticated || !ready.ContainsKey(c.connectionId)))) { reason = "Waiting for every player to connect with RogueGolf 1.1.5 with matching physics hooks."; return false; } return true; } internal bool TryPlayerGuid(int connectionId, out ulong guid) { guid = 0uL; if (NetworkServer.connections.TryGetValue(connectionId, out var value)) { NetworkManager singleton = NetworkManager.singleton; BNetworkManager val = (BNetworkManager)(object)((singleton is BNetworkManager) ? singleton : null); if (val != null && val.TryGetSteamPlayerGuid(value, ref guid)) { return guid != 0; } } return false; } private bool MemberMatches(NetworkConnectionToClient c, string clientNonce) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (clientNonce.Length == 32) { NetworkManager singleton = NetworkManager.singleton; BNetworkManager val = (BNetworkManager)(object)((singleton is BNetworkManager) ? singleton : null); ulong num = default(ulong); Lobby val2 = default(Lobby); if (val != null && val.TryGetSteamPlayerGuid(c, ref num) && BNetworkManager.TryGetSteamLobby(ref val2)) { return ((Lobby)(ref val2)).GetMemberData(new Friend(SteamId.op_Implicit(num)), "roguegolf_peer_v1") == Capability + Session + "/" + clientNonce; } } return false; } private void ReceiveClient(NetworkConnectionToClient c, RogueClientMessage message) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) try { Packet val = Wire.Decode(message.Data); if ((int)val.Kind == 6) { ReceiveProof(c, val); } else { if (val.Session != Session) { return; } if ((int)val.Kind == 1) { if (admission.Verified(c.connectionId) && MemberMatches(c, val.Nonce)) { if (val.Capabilities != plugin.Capabilities) { plugin.NetLog("Peer physics capabilities differ; excluded from readiness"); } else if (!ready.ContainsKey(c.connectionId)) { ready[c.connectionId] = val.Nonce; plugin.NetLog("Compatible peer ready connection=" + c.connectionId); plugin.Publish(); } } } else if (((object)c == NetworkServer.localConnection || ready.ContainsKey(c.connectionId)) && guard.Accept(c.connectionId, val.Sequence, NetworkTime.time)) { plugin.AcceptIntent(c.connectionId, val); } } } catch (Exception ex) when (ex is IOException || ex is ArgumentException) { plugin.NetLog("Rejected malformed client packet: " + ex.GetType().Name); if (!admission.Verified(c.connectionId)) { RejectPeer(c, "Incompatible RogueGolf protocol."); } } } private void ReceiveServer(RogueServerMessage message) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 try { Packet val = Wire.Decode(message.Data); if ((int)val.Kind == 5 || (int)val.Kind == 7) { ReceiveAdmission(val); } else if (clientAdmitted && (int)val.Kind == 2 && !(val.Session != expectedHost) && Replica.Accept(val.Snapshot)) { plugin.SnapshotReceived(val.Snapshot); } } catch (Exception ex) when (ex is IOException || ex is ArgumentException) { plugin.NetLog("Rejected malformed server snapshot: " + ex.GetType().Name); if (!clientAdmitted) { RejectHost("Incompatible RogueGolf protocol."); } } } internal void SendSnapshot(RunSnapshot source) { //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) //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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown if (!serverRegistered) { return; } foreach (NetworkConnectionToClient value in NetworkServer.connections.Values) { if (((NetworkConnection)value).isAuthenticated && ((object)value == NetworkServer.localConnection || ready.ContainsKey(value.connectionId)) && ((object)value != NetworkServer.localConnection || (clientRegistered && NetworkClient.active && NetworkClient.isConnected))) { source.Recipient = value.connectionId; ((NetworkConnection)value).Send(new RogueServerMessage { Data = Wire.Encode(new Packet { Kind = (PacketKind)2, Session = Session, Snapshot = source }) }, 0); } } } internal void Vote(string option, bool breakTie = false) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_006e: Expected O, but got Unknown RunSnapshot current = Replica.Current; if (current != null && clientRegistered) { Packet val = new Packet { Kind = (PacketKind)(breakTie ? 4 : 3), Session = current.Session, RunId = current.RunId, VoteId = current.VoteId, Option = option, Sequence = ++intentSequence }; NetworkClient.Send(new RogueClientMessage { Data = Wire.Encode(val) }, 0); } } internal void Disconnect(int id) { admission.Remove(id); pendingConnections.Remove(id); challenges.Remove(id); ready.Remove(id); guard.Remove(id); plugin.PeerDisconnected(id); } internal void StopServer() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (serverRegistered) { NetworkServer.UnregisterHandler(); } Lobby val = default(Lobby); if (SteamClient.IsValid && BNetworkManager.TryGetSteamLobby(ref val) && ((Lobby)(ref val)).IsOwnedBy(SteamClient.SteamId)) { ((Lobby)(ref val)).DeleteData("roguegolf_host_v1"); } serverRegistered = false; admission.Clear(); pendingConnections.Clear(); challenges.Clear(); ready.Clear(); guard.Clear(); Session = ""; pollAt = 0.0; } internal void StopClient() { if (clientRegistered) { NetworkClient.UnregisterHandler(); } Lobby val = default(Lobby); if (SteamClient.IsValid && BNetworkManager.TryGetSteamLobby(ref val)) { ((Lobby)(ref val)).SetMemberData("roguegolf_peer_v1", ""); } clientRegistered = false; clientAdmitted = false; challenge = ""; expectedHost = ""; Replica.Reset(""); pollAt = 0.0; } public void Dispose() { StopClient(); StopServer(); } internal bool Verified(int id) { if (serverRegistered && NetworkServer.active) { LocalConnectionToClient localConnection = NetworkServer.localConnection; if (localConnection == null || ((NetworkConnectionToClient)localConnection).connectionId != id) { return admission.Verified(id); } return true; } return false; } private Packet AdmissionPacket(PacketKind kind, string token) { //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0030: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown return new Packet { Kind = kind, Session = Session, Nonce = token, Build = plugin.BuildFingerprint, Policy = 1, Capabilities = plugin.Capabilities }; } private bool Matches(Packet p) { //IL_0038: 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) if (p.Nonce.Length == 32 && p.Session.Length == 32) { return CompatibilityPolicy.Matches(p.Build, plugin.BuildFingerprint, 10, p.Policy, p.Capabilities, plugin.Capabilities); } return false; } private void BeginServerAdmission() { admission.Clear(); pendingConnections.Clear(); challenges.Clear(); admissionPoll = 0.0; } private void BeginClientAdmission() { clientAdmitted = NetworkServer.active; heldClientConnect = (heldClientScene = (rejectingHost = false)); challenge = ""; clientDeadline = Now + 12.0; } internal bool HoldServerConnect(NetworkConnectionToClient c) { if (replayConnect || (object)c == NetworkServer.localConnection) { return true; } if (!serverRegistered || !((Behaviour)plugin).enabled) { RejectPeer(c, "RogueGolf admission unavailable."); return false; } if (pendingConnections.ContainsKey(c.connectionId)) { return false; } string text = Guid.NewGuid().ToString("N"); admission.Begin(c.connectionId, text, Now); pendingConnections[c.connectionId] = c; challenges[c.connectionId] = AdmissionPacket((PacketKind)5, text); plugin.NetLog("Admission pending connection=" + c.connectionId + "; native player registration held"); return false; } internal bool HoldClientConnect() { if (clientAdmitted) { return true; } heldClientConnect = true; return false; } internal bool HoldClientScene() { if (clientAdmitted) { return true; } heldClientScene = true; return false; } internal bool AllowPlayer(NetworkConnectionToClient c) { if (Verified(c.connectionId)) { return true; } RejectPeer(c, "Matching RogueGolf required before gameplay."); return false; } private void TickAdmission() { if (Now < admissionPoll) { return; } admissionPoll = Now + 0.25; if (serverRegistered && NetworkServer.active) { KeyValuePair[] array = pendingConnections.ToArray(); for (int i = 0; i < array.Length; i++) { KeyValuePair keyValuePair = array[i]; Packet value; if (admission.Expired(keyValuePair.Key, Now)) { RejectPeer(keyValuePair.Value, "RogueGolf verification timed out."); } else if (IsPrivateSession && challenges.TryGetValue(keyValuePair.Key, out value)) { ((NetworkConnection)keyValuePair.Value).Send(new RogueServerMessage { Data = Wire.Encode(value) }, 0); challenges.Remove(keyValuePair.Key); } } Lobby val = default(Lobby); if (!BNetworkManager.TryGetSteamLobby(ref val) || CompatibilityPolicy.PrivateLobby(((Lobby)(ref val)).GetData("sbg_lobbyMode"))) { return; } NetworkConnectionToClient[] array2 = NetworkServer.connections.Values.ToArray(); foreach (NetworkConnectionToClient val2 in array2) { if ((object)val2 != NetworkServer.localConnection) { RejectPeer(val2, "RogueGolf requires a private lobby."); } } } else if (clientRegistered && NetworkClient.active) { if (clientAdmitted && !IsPrivateSession) { RejectHost("RogueGolf requires a verified private host."); } else if (!clientAdmitted && Now >= clientDeadline) { RejectHost("This host did not verify matching RogueGolf. Vanilla lobbies are unavailable with this mod loaded."); } } } private void ReceiveProof(NetworkConnectionToClient c, Packet p) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) if (!IsPrivateSession || p.Session != Session || !Matches(p) || !admission.Verify(c.connectionId, p.Nonce, true, Now)) { RejectPeer(c, "RogueGolf build, capabilities or policy mismatch."); return; } pendingConnections.Remove(c.connectionId); challenges.Remove(c.connectionId); ready[c.connectionId] = p.Nonce; try { replayConnect = true; ((NetworkManager)(BNetworkManager)NetworkManager.singleton).OnServerConnect(c); } finally { replayConnect = false; } ((NetworkConnection)c).Send(new RogueServerMessage { Data = Wire.Encode(AdmissionPacket((PacketKind)7, p.Nonce)) }, 0); plugin.NetLog("Admission verified connection=" + c.connectionId); plugin.Publish(); } private void ReceiveAdmission(Packet p) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown if (NetworkServer.active) { return; } if (!IsPrivateSession || !Matches(p)) { RejectHost("Matching RogueGolf private host required."); } else if ((int)p.Kind == 5) { if (clientAdmitted) { RejectHost("Host verification changed during the session."); return; } expectedHost = p.Session; challenge = p.Nonce; Replica.Reset(expectedHost); NetworkClient.Send(new RogueClientMessage { Data = Wire.Encode(new Packet { Kind = (PacketKind)6, Session = expectedHost, Nonce = challenge, Build = plugin.BuildFingerprint, Policy = 1, Capabilities = plugin.Capabilities }) }, 0); } else { if (clientAdmitted) { return; } if (Now >= clientDeadline || p.Session != expectedHost || p.Nonce != challenge || challenge == "") { RejectHost("Invalid RogueGolf admission acknowledgement."); return; } clientAdmitted = true; nonce = challenge; NetworkManager singleton = NetworkManager.singleton; BNetworkManager val = (BNetworkManager)(object)((singleton is BNetworkManager) ? singleton : null); if ((Object)(object)val == (Object)null) { RejectHost("Native session unavailable."); return; } plugin.NetLog("Host verified; releasing native client readiness"); if (heldClientConnect) { heldClientConnect = false; ((NetworkManager)val).OnClientConnect(); } if (heldClientScene) { heldClientScene = false; ((NetworkManager)val).OnClientSceneChanged(); } } } private void RejectPeer(NetworkConnectionToClient c, string reason) { plugin.NetLog("Admission rejected connection=" + c.connectionId + ": " + reason); admission.Remove(c.connectionId); pendingConnections.Remove(c.connectionId); challenges.Remove(c.connectionId); ready.Remove(c.connectionId); ((NetworkConnection)c).Disconnect(); } private void RejectHost(string reason) { if (!rejectingHost) { rejectingHost = true; plugin.AdmissionNotice(); plugin.NetLog("Host rejected: " + reason); NetworkManager singleton = NetworkManager.singleton; if (singleton != null) { singleton.StopClient(); } } } } internal static class ProgressionConfig { internal static ConfigEntry[] BindThresholds(ConfigFile config, Action warn) { string[] array = new string[3] { "EarlyMid", "MidLate", "Late" }; int[] legacyPhaseStarts = RogueGolfDefaults.LegacyPhaseStarts; for (int i = 0; i < 3; i++) { legacyPhaseStarts[i + 1] = config.Bind("Progression", array[i] + "StartsAtHole", legacyPhaseStarts[i + 1], "Deprecated: retained for migration/reference. Edit StartsAtPercent instead.").Value; } float[] migrated; try { migrated = CourseProgress.MigrateLegacyStarts(legacyPhaseStarts); } catch (ArgumentException) { migrated = RogueGolfDefaults.PhaseThresholds; warn?.Invoke("[CONFIG] Invalid legacy progression boundaries retained; using adaptive defaults."); } ConfigEntry[] result = array.Select((string band, int num) => config.Bind("Progression", band + "StartsAtPercent", migrated[num + 1], new ConfigDescription("Selectable-course completion percentage. Strictly increasing above 0. Values above 100 keep a migrated phase unreachable. Deprecated hole keys are used only when this key is absent.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 15000f), Array.Empty()))).ToArray(); config.Save(); return result; } } internal enum SetupGlyph { Flag, Skips, Crown, Golf, Info, Question, Spark, Left, Right, Minus, Plus, Burst, Clock, Gear, Stripes } internal sealed class SetupArtwork : MaskableGraphic { internal SetupGlyph Glyph; internal Color Accent = Color32.op_Implicit(new Color32((byte)101, (byte)166, (byte)66, byte.MaxValue)); private VertexHelper mesh; private Color ink = Color32.op_Implicit(new Color32((byte)48, (byte)58, (byte)37, byte.MaxValue)); private Vector2 Point(float x, float y) { //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) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Rect rect = ((Graphic)this).rectTransform.rect; return new Vector2(((Rect)(ref rect)).xMin + x * ((Rect)(ref rect)).width / 100f, ((Rect)(ref rect)).yMax - y * ((Rect)(ref rect)).height / 100f); } private void Poly(Color tint, params float[] xy) { //IL_001f: 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_0029: 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_0030: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) int currentVertCount = mesh.currentVertCount; for (int i = 0; i < xy.Length; i += 2) { mesh.AddVert(Vector2.op_Implicit(Point(xy[i], xy[i + 1])), Color32.op_Implicit(tint * ((Graphic)this).color), Vector4.op_Implicit(Vector2.zero)); } for (int j = 1; j < xy.Length / 2 - 1; j++) { mesh.AddTriangle(currentVertCount, currentVertCount + j, currentVertCount + j + 1); } } private void Box(Color tint, float x, float y, float w, float h) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Poly(tint, x, y, x + w, y, x + w, y + h, x, y + h); } private void Disc(Color tint, float x, float y, float radius) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) float[] array = new float[64]; for (int i = 0; i < 32; i++) { float num = (float)i * (float)Math.PI / 16f; array[i * 2] = x + (float)Math.Cos(num) * radius; array[i * 2 + 1] = y + (float)Math.Sin(num) * radius; } Poly(tint, array); } protected override void OnPopulateMesh(VertexHelper helper) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_05f2: Unknown result type (might be due to invalid IL or missing references) //IL_060d: Unknown result type (might be due to invalid IL or missing references) //IL_0626: Unknown result type (might be due to invalid IL or missing references) //IL_063f: Unknown result type (might be due to invalid IL or missing references) //IL_0669: Unknown result type (might be due to invalid IL or missing references) //IL_066e: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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_00e9: 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_0424: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_0728: Unknown result type (might be due to invalid IL or missing references) //IL_072d: Unknown result type (might be due to invalid IL or missing references) //IL_06f2: Unknown result type (might be due to invalid IL or missing references) //IL_070a: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_05a4: Unknown result type (might be due to invalid IL or missing references) //IL_05d2: Unknown result type (might be due to invalid IL or missing references) //IL_05d7: Unknown result type (might be due to invalid IL or missing references) //IL_0767: Unknown result type (might be due to invalid IL or missing references) //IL_077f: Unknown result type (might be due to invalid IL or missing references) //IL_07a1: Unknown result type (might be due to invalid IL or missing references) //IL_07bd: Unknown result type (might be due to invalid IL or missing references) //IL_07f8: Unknown result type (might be due to invalid IL or missing references) //IL_07fd: Unknown result type (might be due to invalid IL or missing references) //IL_06b5: Unknown result type (might be due to invalid IL or missing references) //IL_06ba: Unknown result type (might be due to invalid IL or missing references) //IL_080c: Unknown result type (might be due to invalid IL or missing references) //IL_0811: Unknown result type (might be due to invalid IL or missing references) //IL_0813: Unknown result type (might be due to invalid IL or missing references) //IL_08d2: Unknown result type (might be due to invalid IL or missing references) //IL_08d7: Unknown result type (might be due to invalid IL or missing references) //IL_08e6: Unknown result type (might be due to invalid IL or missing references) //IL_08f5: Unknown result type (might be due to invalid IL or missing references) //IL_08fd: Unknown result type (might be due to invalid IL or missing references) //IL_0902: Unknown result type (might be due to invalid IL or missing references) //IL_091b: Unknown result type (might be due to invalid IL or missing references) //IL_0920: Unknown result type (might be due to invalid IL or missing references) //IL_0926: Unknown result type (might be due to invalid IL or missing references) //IL_092b: Unknown result type (might be due to invalid IL or missing references) //IL_0930: Unknown result type (might be due to invalid IL or missing references) //IL_0935: Unknown result type (might be due to invalid IL or missing references) //IL_093a: Unknown result type (might be due to invalid IL or missing references) //IL_084c: Unknown result type (might be due to invalid IL or missing references) //IL_0820: Unknown result type (might be due to invalid IL or missing references) //IL_086d: Unknown result type (might be due to invalid IL or missing references) //IL_086f: Unknown result type (might be due to invalid IL or missing references) //IL_085b: Unknown result type (might be due to invalid IL or missing references) //IL_085d: Unknown result type (might be due to invalid IL or missing references) //IL_0863: Unknown result type (might be due to invalid IL or missing references) //IL_0843: Unknown result type (might be due to invalid IL or missing references) //IL_082f: Unknown result type (might be due to invalid IL or missing references) //IL_0831: Unknown result type (might be due to invalid IL or missing references) //IL_0837: Unknown result type (might be due to invalid IL or missing references) helper.Clear(); mesh = helper; Color tint = Color32.op_Implicit(new Color32((byte)101, (byte)166, (byte)66, byte.MaxValue)); Color tint2 = Color32.op_Implicit(new Color32((byte)51, (byte)157, (byte)204, byte.MaxValue)); Color tint3 = Color32.op_Implicit(new Color32((byte)136, (byte)77, (byte)198, byte.MaxValue)); Color tint4 = Color32.op_Implicit(new Color32((byte)252, (byte)204, (byte)68, byte.MaxValue)); switch (Glyph) { case SetupGlyph.Minus: Box(ink, 28f, 43f, 44f, 14f); break; case SetupGlyph.Plus: Box(ink, 28f, 43f, 44f, 14f); Box(ink, 43f, 28f, 14f, 44f); break; case SetupGlyph.Left: Poly(ink, 65f, 22f, 35f, 50f, 65f, 78f); break; case SetupGlyph.Right: Poly(ink, 35f, 22f, 65f, 50f, 35f, 78f); break; case SetupGlyph.Flag: Disc(Color32.op_Implicit(new Color32((byte)75, (byte)136, (byte)50, byte.MaxValue)), 34f, 88f, 15f); Box(Color32.op_Implicit(new Color32((byte)112, (byte)105, (byte)76, byte.MaxValue)), 31f, 17f, 7f, 69f); Poly(Accent, 38f, 16f, 84f, 29f, 38f, 49f); Poly(Color.Lerp(Accent, Color.white, 0.3f), 38f, 16f, 84f, 29f, 63f, 29f); break; case SetupGlyph.Skips: Poly(Color32.op_Implicit(new Color32((byte)34, (byte)107, (byte)148, byte.MaxValue)), 15f, 14f, 51f, 51f, 15f, 88f); Poly(tint2, 9f, 9f, 45f, 46f, 9f, 83f); Poly(Color32.op_Implicit(new Color32((byte)34, (byte)107, (byte)148, byte.MaxValue)), 53f, 14f, 89f, 51f, 53f, 88f); Poly(Color32.op_Implicit(new Color32((byte)71, (byte)183, (byte)220, byte.MaxValue)), 47f, 9f, 83f, 46f, 47f, 83f); break; case SetupGlyph.Crown: Poly(Color32.op_Implicit(new Color32((byte)88, (byte)48, (byte)140, byte.MaxValue)), 24f, 64f, 77f, 64f, 77f, 80f, 24f, 80f); Poly(tint3, 9f, 30f, 22f, 72f, 40f, 72f); Poly(tint3, 28f, 64f, 46f, 13f, 66f, 64f); Poly(tint3, 86f, 26f, 75f, 72f, 60f, 72f); Box(tint3, 22f, 60f, 53f, 12f); Box(Color32.op_Implicit(new Color32((byte)166, (byte)109, (byte)219, byte.MaxValue)), 24f, 64f, 49f, 8f); break; case SetupGlyph.Info: Disc(Color32.op_Implicit(new Color32((byte)108, (byte)120, (byte)91, byte.MaxValue)), 50f, 50f, 43f); Disc(Color.white, 50f, 28f, 5f); Box(Color.white, 45f, 41f, 10f, 34f); break; case SetupGlyph.Question: Disc(Color32.op_Implicit(new Color32((byte)108, (byte)120, (byte)91, byte.MaxValue)), 50f, 50f, 43f); break; case SetupGlyph.Spark: Poly(tint4, 50f, 2f, 98f, 50f, 50f, 98f, 2f, 50f); break; case SetupGlyph.Burst: Poly(tint4, 43f, 13f, 51f, 3f, 65f, 7f, 58f, 25f); Poly(tint4, 67f, 40f, 86f, 28f, 93f, 43f, 70f, 52f); Poly(tint4, 67f, 66f, 91f, 71f, 85f, 89f, 65f, 80f); break; case SetupGlyph.Clock: Disc(Color32.op_Implicit(new Color32((byte)161, (byte)137, (byte)60, byte.MaxValue)), 50f, 55f, 39f); Disc(tint4, 50f, 52f, 35f); Disc(Color32.op_Implicit(new Color32(byte.MaxValue, (byte)248, (byte)206, byte.MaxValue)), 50f, 52f, 28f); Box(ink, 47f, 29f, 6f, 25f); Box(ink, 48f, 50f, 22f, 6f); Box(ink, 43f, 6f, 14f, 9f); break; case SetupGlyph.Gear: { for (int l = 0; l < 8; l++) { float num2 = (float)l * (float)Math.PI / 4f; Disc(ink, 50f + (float)Math.Cos(num2) * 31f, 50f + (float)Math.Sin(num2) * 31f, 12f); } Disc(ink, 50f, 50f, 32f); Disc(Color32.op_Implicit(new Color32((byte)229, (byte)235, (byte)197, byte.MaxValue)), 50f, 50f, 13f); break; } case SetupGlyph.Golf: { Box(tint, 9f, 85f, 83f, 6f); Poly(tint, 13f, 85f, 17f, 63f, 25f, 78f, 32f, 66f, 39f, 85f); Poly(tint, 62f, 85f, 73f, 65f, 77f, 79f, 88f, 67f, 85f, 85f); Disc(tint, 60f, 46f, 34f); Disc(Color32.op_Implicit(new Color32((byte)252, (byte)251, (byte)224, byte.MaxValue)), 60f, 45f, 29f); for (int j = 0; j < 4; j++) { for (int k = 0; k < 4; k++) { if ((j != 0 && j != 3) || (k != 0 && k != 3)) { Disc(Color32.op_Implicit(new Color32((byte)148, (byte)162, (byte)119, byte.MaxValue)), 42 + j * 12, 27 + k * 12, 3f); } } } Poly(tint, 8f, 26f, 22f, 17f, 32f, 32f, 13f, 35f); Poly(tint, 1f, 51f, 21f, 41f, 28f, 58f, 6f, 64f); break; } case SetupGlyph.Stripes: { Rect rect = ((Graphic)this).rectTransform.rect; float w = ((Rect)(ref rect)).width; float h = ((Rect)(ref rect)).height; for (float num = 0f - h; num < w; num += 12f) { List list = new List { new Vector2(num, 0f), new Vector2(num + 4f, 0f), new Vector2(num + 4f + h, h), new Vector2(num + h, h) }; int edge; for (edge = 0; edge < 4; edge++) { List list2 = list; list = new List(); if (list2.Count == 0) { break; } Vector2 val = list2[list2.Count - 1]; foreach (Vector2 item in list2) { if (Inside(item)) { if (!Inside(val)) { list.Add(Intersect(val, item)); } list.Add(item); } else if (Inside(val)) { list.Add(Intersect(val, item)); } val = item; } } if (list.Count < 3) { continue; } int currentVertCount = mesh.currentVertCount; foreach (Vector2 item2 in list) { mesh.AddVert(Vector2.op_Implicit(new Vector2(((Rect)(ref rect)).xMin + item2.x, ((Rect)(ref rect)).yMax - item2.y)), Color32.op_Implicit(Color32.op_Implicit(new Color32((byte)229, (byte)216, (byte)173, byte.MaxValue)) * ((Graphic)this).color), Vector4.op_Implicit(Vector2.zero)); } for (int i = 1; i < list.Count - 1; i++) { mesh.AddTriangle(currentVertCount, currentVertCount + i, currentVertCount + i + 1); } bool Inside(Vector2 p) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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) if (edge != 0) { if (edge != 1) { if (edge != 2) { return p.y <= h; } return p.y >= 0f; } return p.x <= w; } return p.x >= 0f; } Vector2 Intersect(Vector2 a, Vector2 b) { //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_0058: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) float num3 = ((edge < 2) ? ((((edge == 0) ? 0f : w) - a.x) / (b.x - a.x)) : ((((edge == 2) ? 0f : h) - a.y) / (b.y - a.y))); return a + (b - a) * num3; } } break; } } } } internal sealed class ThunderstormAdapter { internal sealed class Lease : IWorldHazard { internal readonly Thunderstorm Storm; private readonly HashSet strikes = new HashSet(); internal int StrikeCount => strikes.Count((ThunderstormLightningStrike s) => (Object)(object)s != (Object)null); public bool Alive { get { if (!((Object)(object)Storm != (Object)null)) { return StrikeCount > 0; } return true; } } internal Lease(Thunderstorm storm) { Storm = storm; } public void Observe() { strikes.RemoveWhere((ThunderstormLightningStrike s) => (Object)(object)s == (Object)null); if ((Object)(object)Storm == (Object)null) { return; } ThunderstormLightningStrike val = default(ThunderstormLightningStrike); foreach (NetworkIdentity value in NetworkServer.spawned.Values) { if ((Object)(object)value != (Object)null && ((Component)value).TryGetComponent(ref val) && (Object)(object)val.NetworkowningThunderstorm == (Object)(object)Storm) { strikes.Add(val); } } } public void Stop() { if (NetworkServer.active) { Observe(); ThunderstormLightningStrike[] array = strikes.ToArray(); foreach (ThunderstormLightningStrike val in array) { if ((Object)(object)val != (Object)null) { NetworkServer.Destroy(((Component)val).gameObject); } } if ((Object)(object)Storm != (Object)null) { NetworkServer.Destroy(((Component)Storm).gameObject); } } strikes.Clear(); } } internal static Vector3[] ActiveCenters => (from s in Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0) select s.NetworkaimPoint).ToArray(); internal Lease Spawn(Vector3 requestedPosition) { //IL_002a: 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_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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { throw new InvalidOperationException("Thunder Storm requires server authority."); } if (!SingletonBehaviour.HasInstance) { throw new InvalidOperationException("Native ThunderstormManager unavailable in this scene."); } if (!Finite(requestedPosition) || TerrainManager.Terrains == null || TerrainManager.Terrains.Length == 0) { throw new InvalidOperationException("Thunder Storm requires a finite position and loaded course terrain."); } RaycastHit val = default(RaycastHit); if (!Physics.Raycast(new Ray(requestedPosition + Vector3.up * 30f, Vector3.down), ref val, 130f, LayerMask.op_Implicit(GameManager.LayerSettings.ThunderstormTargetablesMask), (QueryTriggerInteraction)1)) { throw new InvalidOperationException("No native thunder target surface below the requested position."); } HashSet before = new HashSet(NetworkServer.spawned.Keys); ThunderstormManager instance = SingletonBehaviour.Instance; HashSet hashSet = new HashSet(from s in ((Component)instance).GetComponentsInChildren() select ((Object)s).GetInstanceID()); Lease lease = null; try { ThunderstormManager.ServerCreateThunderstorm(((RaycastHit)(ref val)).point, (PlayerInventory)null, ItemUseId.Invalid); Thunderstorm[] array = (from p in NetworkServer.spawned where !before.Contains(p.Key) && (Object)(object)p.Value != (Object)null select ((Component)p.Value).GetComponent() into s where (Object)(object)s != (Object)null select s).ToArray(); if (array.Length != 1) { Thunderstorm[] array2 = array; for (int num = 0; num < array2.Length; num++) { new Lease(array2[num]).Stop(); } throw new InvalidOperationException("Native factory did not create exactly one networked storm."); } lease = new Lease(array[0]); if (!Finite(array[0].NetworkcloudPosition)) { throw new InvalidOperationException("Native cloud placement was invalid."); } return lease; } catch { lease?.Stop(); if ((Object)(object)instance != (Object)null) { Thunderstorm[] array2 = ((Component)instance).GetComponentsInChildren(); foreach (Thunderstorm val2 in array2) { if (!hashSet.Contains(((Object)val2).GetInstanceID())) { new Lease(val2).Stop(); } } } throw; } } private static bool Finite(Vector3 p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (Finite(p.x) && Finite(p.y)) { return Finite(p.z); } return false; } private static bool Finite(float n) { if (!float.IsNaN(n) && !float.IsInfinity(n)) { return Math.Abs(n) < 100000f; } return false; } internal static string SettingsSummary() { ItemSettings itemSettings = GameManager.ItemSettings; return "duration=" + itemSettings.ThunderstormDuration + " interval=" + itemSettings.ThunderstormMinTimeBetweenLightningStrikes + ".." + itemSettings.ThunderstormMaxTimeBetweenLightningStrikes + " radius=" + itemSettings.ThunderstormRadius + " warning=" + itemSettings.ThunderstormLightningStrikeAnticipationDuration + " strikeDespawn=" + itemSettings.ThunderstormLightningStrikedPostStrikeDespawnDelay + " cloudDespawn=" + itemSettings.ThunderstormDespawnDuration; } } internal sealed class WorldSpawnLocations { private readonly Vector3[] greens; private readonly Vector3[] items; private readonly Vector3[] tees; private int previous = -1; internal string Summary => "greens=" + greens.Length + " items=" + items.Length + " tees=" + tees.Length; internal WorldSpawnLocations() { greens = (from g in Find() select ((Component)g).GetComponentInChildren() into c where (Object)(object)c != (Object)null select c).Select(delegate(Collider c) { //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_0009: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = c.bounds; return ((Bounds)(ref bounds)).center; }).ToArray(); if (greens.Length == 0) { greens = (from g in Find() select ((Component)g).transform.position).ToArray(); } items = (from i in Find() select ((Component)i).transform.position).ToArray(); tees = (from t in Find() where t.IsActive select ((Component)t).transform.position).ToArray(); } private static T[] Find() where T : Object { return Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0); } internal bool TryScatter(RunRandom random, int[] weights, PlayerInfo[] players, Vector3[] occupied, out Vector3 position, out string category) { //IL_0008: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) position = default(Vector3); category = ""; PlayerInfo[] source = players.Where((PlayerInfo p) => (Object)(object)p != (Object)null && !p.Movement.IsRespawning && p.Movement.IsVisible && (int)p.AsGolfer.MatchResolution == 0).ToArray(); Vector3[] array = source.Select((PlayerInfo p) => ((Component)p).transform.position).ToArray(); Vector3[] array2 = (from p in source select p.AsGolfer.OwnBall into b where (Object)(object)b != (Object)null select ((Component)b).transform.position).ToArray(); Vector3[] routeStart = ((tees.Length != 0) ? tees : array); Vector3[] array3 = items.Concat(greens).ToArray(); Vector3[][] categories = new Vector3[5][] { greens, array, array2, items, array3 }; int num = WorldSpawnPatterns.ChooseCategory(random, weights, (from i in Enumerable.Range(0, 5) select categories[i].Length != 0 && (i != 4 || routeStart.Length != 0)).ToArray(), previous); if (num < 0) { return false; } RaycastHit hit = default(RaycastHit); for (int num2 = 0; num2 < 12; num2++) { Vector3[] array4 = categories[num]; Vector3 val = array4[random.Next(array4.Length)]; if (num == 4) { val = Vector3.Lerp(routeStart[random.Next(routeStart.Length)], val, 0.2f + (float)random.Next(600000) / 1000000f); } float num3 = num switch { 4 => 12, 3 => 8, 0 => 10, _ => 16, }; float num4 = (float)random.Next(1000000) / 1000000f * (float)Math.PI * 2f; float num5 = Mathf.Sqrt((float)random.Next(1000000) / 1000000f) * num3; if (Physics.Raycast(new Ray(val + new Vector3(Mathf.Cos(num4) * num5, 0f, Mathf.Sin(num4) * num5) + Vector3.up * 40f, Vector3.down), ref hit, 120f, LayerMask.op_Implicit(GameManager.LayerSettings.ThunderstormTargetablesMask), (QueryTriggerInteraction)1) && !(((RaycastHit)(ref hit)).normal.y < 0.45f) && !((Object)(object)((RaycastHit)(ref hit)).collider.attachedRigidbody != (Object)null) && !(((RaycastHit)(ref hit)).point.y <= MainOutOfBoundsHazard.Height + 1f) && !occupied.Any(delegate(Vector3 p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_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_002e: 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) Vector2 val2 = new Vector2(p.x - ((RaycastHit)(ref hit)).point.x, p.z - ((RaycastHit)(ref hit)).point.z); return ((Vector2)(ref val2)).sqrMagnitude < 256f; })) { position = ((RaycastHit)(ref hit)).point; category = (new string[5] { "Green", "Player", "Ball", "ItemPoint", "FairwayRoute" })[num]; previous = num; return true; } } return false; } } }