using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using FMODUnity; using Microsoft.CodeAnalysis; using Mirror; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("EmpressMeteors")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("EmpressMeteors")] [assembly: AssemblyTitle("EmpressMeteors")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Empress.SuperBattleGolf.Meteors { [BepInPlugin("empress.superbattlegolf.meteors", "Empress Meteors", "1.0.0")] public sealed class EmpressMeteorsPlugin : BaseUnityPlugin { private readonly struct ImpactSample { public readonly Vector3 ClosestPoint; public readonly float DistanceSquared; public ImpactSample(Vector3 closestPoint, float distanceSquared) { //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) ClosestPoint = closestPoint; DistanceSquared = distanceSquared; } } private struct MeteorSpawnMessage : NetworkMessage { public ulong Id; public string SceneName; public double SpawnTime; public double ImpactTime; public Vector3 StartPoint; public Vector3 ImpactPoint; public Vector3 ImpactNormal; public float Scale; public float ImpactRadius; public uint Seed; } private sealed class MeteorVisual { private readonly MeteorSpawnMessage message; private readonly GameObject meteorRoot; private readonly GameObject warningRoot; private readonly Transform meteorTransform; private readonly Transform warningTransform; private readonly TrailRenderer trail; private readonly LineRenderer warningRing; private readonly float swayStrength; private readonly float swaySpeed; private readonly float rotationSpeed; private readonly float phase; private readonly Renderer meteorRenderer; private bool meteorActivated; private bool impacted; private bool disposed; public MeteorVisual(MeteorSpawnMessage message, Material meteorMaterial, Material warningMaterial) { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Expected O, but got Unknown //IL_0210: 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_0220: 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_0235: 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_0240: 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) this.message = message; swayStrength = Mathf.Lerp(0.35f, 1f, NormalizeSeed(11u)); swaySpeed = Mathf.Lerp(5f, 8f, NormalizeSeed(17u)); rotationSpeed = Mathf.Lerp(250f, 420f, NormalizeSeed(23u)); phase = NormalizeSeed(31u) * MathF.PI * 2f; meteorRoot = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)meteorRoot).name = $"EmpressMeteor_{message.Id}"; ((Object)meteorRoot).hideFlags = (HideFlags)61; meteorTransform = meteorRoot.transform; meteorTransform.position = message.StartPoint; meteorTransform.localScale = Vector3.one * message.Scale * 0.9f; Collider component = meteorRoot.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } meteorRenderer = meteorRoot.GetComponent(); if ((Object)(object)meteorRenderer != (Object)null) { meteorRenderer.sharedMaterial = meteorMaterial; } trail = meteorRoot.AddComponent(); ((Renderer)trail).sharedMaterial = warningMaterial; trail.time = 0.25f; trail.minVertexDistance = 0.05f; trail.widthCurve = CreateTrailWidthCurve(message.Scale); trail.colorGradient = CreateTrailGradient(); trail.alignment = (LineAlignment)0; trail.emitting = false; meteorRoot.SetActive(false); warningRoot = new GameObject($"EmpressMeteorWarning_{message.Id}"); ((Object)warningRoot).hideFlags = (HideFlags)61; warningTransform = warningRoot.transform; warningTransform.position = message.ImpactPoint + message.ImpactNormal * 0.08f; warningTransform.rotation = Quaternion.FromToRotation(Vector3.up, message.ImpactNormal); warningRing = warningRoot.AddComponent(); warningRing.loop = true; warningRing.useWorldSpace = false; ((Renderer)warningRing).sharedMaterial = warningMaterial; warningRing.widthMultiplier = 0.22f; warningRing.alignment = (LineAlignment)0; warningRing.positionCount = 40; for (int i = 0; i < 40; i++) { float num = (float)i / 40f * MathF.PI * 2f; warningRing.SetPosition(i, new Vector3(Mathf.Cos(num), 0f, Mathf.Sin(num))); } UpdateWarning(0f, 0f); } public bool Tick(double now) { //IL_00db: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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) //IL_015a: 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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019f: 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_01c4: 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) if (disposed) { return false; } if (impacted) { return false; } float warmupProgress = Mathf.Clamp01((float)((now - (message.SpawnTime - 1.100000023841858)) / 1.100000023841858)); float num = Mathf.Clamp01((float)((now - message.SpawnTime) / (message.ImpactTime - message.SpawnTime))); UpdateWarning(warmupProgress, num); if (now >= message.ImpactTime) { TriggerImpact(); return false; } if (now < message.SpawnTime) { return true; } if (!meteorActivated) { meteorActivated = true; meteorRoot.SetActive(true); trail.emitting = true; } float num2 = 1f - Mathf.Pow(1f - num, 3f); Vector3 val = Vector3.Lerp(message.StartPoint, message.ImpactPoint, num2); val += new Vector3(Mathf.Sin(phase + num * swaySpeed * 3.1f), 0f, Mathf.Cos(phase * 0.8f + num * swaySpeed * 2.4f)) * swayStrength * (1f - num); meteorTransform.position = val; meteorTransform.Rotate(new Vector3(rotationSpeed, rotationSpeed * 0.72f, rotationSpeed * 0.54f) * Time.deltaTime, (Space)1); meteorTransform.localScale = Vector3.one * message.Scale * Mathf.Lerp(0.7f, 1.15f, num); if ((Object)(object)meteorRenderer != (Object)null) { float num3 = Mathf.Lerp(0.8f, 1.25f, Mathf.PingPong(Time.time * 5.5f + phase, 1f)); meteorRenderer.material.color = new Color(1f, 0.32f + num3 * 0.12f, 0.08f, 0.95f); } return true; } public void Dispose() { if (!disposed) { disposed = true; if ((Object)(object)meteorRoot != (Object)null) { Object.Destroy((Object)(object)meteorRoot); } if ((Object)(object)warningRoot != (Object)null) { Object.Destroy((Object)(object)warningRoot); } } } private void TriggerImpact() { //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_002b: 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_004d: 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_009d: 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_0074: Unknown result type (might be due to invalid IL or missing references) if (impacted) { return; } impacted = true; if (SingletonNetworkBehaviour.HasInstance) { VfxManager.PlayPooledVfxLocalOnly((VfxType)25, message.ImpactPoint, Quaternion.identity, default(Vector3), 0u, false, 0f, (Action)null); } if (SingletonBehaviour.HasInstance) { if (GameplayCameraManager.ShouldPlayImpactFrameForExplosion(message.ImpactPoint, message.ImpactRadius, GameManager.CameraGameplaySettings.LandmineImpactFrameDistanceSquared)) { CameraModuleController.PlayImpactFrame(message.ImpactPoint); } CameraModuleController.Shake(GameManager.CameraGameplaySettings.LandmineExplosionScreenshakeSettings, message.ImpactPoint); RuntimeManager.PlayOneShot(GameManager.AudioSettings.LandmineExplosionEvent, message.ImpactPoint); } Dispose(); } private void UpdateWarning(float warmupProgress, float flightProgress) { //IL_0060: 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) if (!((Object)(object)warningTransform == (Object)null) && !((Object)(object)warningRing == (Object)null)) { float num = Mathf.Lerp(1.45f, 1f, Mathf.Clamp01(flightProgress + warmupProgress * 0.4f)); warningTransform.localScale = new Vector3(message.ImpactRadius * num, 1f, message.ImpactRadius * num); warningRing.widthMultiplier = Mathf.Lerp(0.08f, 0.22f, warmupProgress); float num2 = Mathf.Lerp(0.2f, 0.95f, warmupProgress); float num3 = 0.65f + Mathf.PingPong(Time.time * Mathf.Lerp(1.8f, 6f, warmupProgress) + phase, 0.35f); Color val = default(Color); ((Color)(ref val))..ctor(1f, 0.45f + num3 * 0.2f, 0.08f, num2); warningRing.startColor = val; warningRing.endColor = val; } } private float NormalizeSeed(uint salt) { return (float)((message.Seed ^ (salt * 1103515245)) % 1000) / 999f; } private static AnimationCurve CreateTrailWidthCurve(float scale) { //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_002a: 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_003a: Expected O, but got Unknown return new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, 0.65f * scale), new Keyframe(1f, 0f) }); } private static Gradient CreateTrailGradient() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_001e: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_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) Gradient val = new Gradient(); val.SetKeys((GradientColorKey[])(object)new GradientColorKey[3] { new GradientColorKey(new Color(1f, 0.8f, 0.45f), 0f), new GradientColorKey(new Color(1f, 0.32f, 0.05f), 0.4f), new GradientColorKey(new Color(0.25f, 0.05f, 0.02f), 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[3] { new GradientAlphaKey(0.95f, 0f), new GradientAlphaKey(0.7f, 0.5f), new GradientAlphaKey(0f, 1f) }); return val; } } private const string PluginGuid = "empress.superbattlegolf.meteors"; private const string PluginName = "Empress Meteors"; private const string PluginVersion = "1.0.0"; private const float SpawnLeadTime = 1.1f; private const float FallDuration = 1.25f; private const float BurstSpacing = 0.28f; private const float FirstMeteorDelay = 2.5f; private const float MinMeteorInterval = 6f; private const float MaxMeteorInterval = 9f; private const float HandlerRefreshInterval = 0.5f; private const int WarningSegments = 40; private static bool mirrorTypesRegistered; private readonly Collider[] impactBuffer = (Collider[])(object)new Collider[256]; private readonly List targetBuffer = new List(16); private readonly List pendingImpacts = new List(16); private readonly List completedMeteorIds = new List(16); private readonly Dictionary meteorVisuals = new Dictionary(); private readonly Dictionary impactSamples = new Dictionary(); private Material meteorMaterial; private Material warningMaterial; private double nextMeteorTime = double.NaN; private double nextHandlerRefreshTime; private ulong nextMeteorId = 1uL; private bool landmineTransfersToGolfCartPassengers = true; private bool lastClientActive; private bool lastServerActive; private MatchState lastMatchState = (MatchState)(-1); private void Awake() { //IL_0015: 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) meteorMaterial = CreateMaterial(new Color(1f, 0.4f, 0.1f, 0.95f)); warningMaterial = CreateMaterial(new Color(1f, 0.65f, 0.2f, 0.85f)); RegisterMirrorTypes(); EnsureNetworkHooks(force: true); TryRefreshLandmineTransferSetting(); SceneManager.sceneLoaded += OnSceneLoaded; } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; NetworkClient.UnregisterHandler(); NetworkServer.UnregisterHandler(); ClearMeteors(); pendingImpacts.Clear(); impactSamples.Clear(); if ((Object)(object)meteorMaterial != (Object)null) { Object.Destroy((Object)(object)meteorMaterial); } if ((Object)(object)warningMaterial != (Object)null) { Object.Destroy((Object)(object)warningMaterial); } } private void Update() { double now = GetNow(); EnsureNetworkHooks(force: false); TrackMatchState(now); TickLocalMeteors(now); if (NetworkServer.active) { TickHost(now); } } private void TickHost(double now) { ResolvePendingImpacts(now); if (!CanSpawnMeteors()) { nextMeteorTime = double.NaN; return; } if (double.IsNaN(nextMeteorTime)) { ScheduleNextMeteor(now); } if (!(now < nextMeteorTime)) { SpawnMeteorBurst(now); ScheduleNextMeteor(now); } } private void ResolvePendingImpacts(double now) { for (int num = pendingImpacts.Count - 1; num >= 0; num--) { MeteorSpawnMessage message = pendingImpacts[num]; if (!(now < message.ImpactTime)) { pendingImpacts.RemoveAt(num); ResolveImpact(message); } } } private void ResolveImpact(MeteorSpawnMessage message) { //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_0036: 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_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) //IL_008a: 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_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_00a4: Unknown result type (might be due to invalid IL or missing references) if (BNetworkManager.IsChangingSceneOrShuttingDown) { return; } Scene activeScene = SceneManager.GetActiveScene(); if (!string.Equals(((Scene)(ref activeScene)).name, message.SceneName, StringComparison.Ordinal)) { return; } TryRefreshLandmineTransferSetting(); impactSamples.Clear(); int num = Physics.OverlapSphereNonAlloc(message.ImpactPoint, message.ImpactRadius, impactBuffer, LayerMask.op_Implicit(GameManager.LayerSettings.LandmineHittablesMask), (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Collider val = impactBuffer[i]; impactBuffer[i] = null; if (!((Object)(object)val == (Object)null)) { Vector3 val2 = val.ClosestPoint(message.ImpactPoint); Vector3 val3 = val2 - message.ImpactPoint; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; QueueColliderImpact(val, val2, sqrMagnitude); } } foreach (KeyValuePair impactSample in impactSamples) { ApplyLandmineHit(impactSample.Key, impactSample.Value, message); } impactSamples.Clear(); } private void QueueColliderImpact(Collider collider, Vector3 closestPoint, float distanceSquared) { //IL_0012: 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) PlayerInfo componentInParent = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { QueuePlayerImpact(componentInParent, closestPoint, distanceSquared); return; } GolfCartInfo componentInParent2 = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent2 != (Object)null) { QueueGolfCartImpact(componentInParent2, closestPoint, distanceSquared); } } private void QueuePlayerImpact(PlayerInfo player, Vector3 closestPoint, float distanceSquared) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_002e: 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) if (CanTargetPlayer(player)) { GolfCartSeat activeGolfCartSeat = player.ActiveGolfCartSeat; if (((GolfCartSeat)(ref activeGolfCartSeat)).IsValid() && (Object)(object)player.ActiveGolfCartSeat.golfCart != (Object)null) { QueueGolfCartImpact(player.ActiveGolfCartSeat.golfCart, closestPoint, distanceSquared); } else { RegisterImpact(player.AsHittable, closestPoint, distanceSquared); } } } private void QueueGolfCartImpact(GolfCartInfo golfCart, Vector3 closestPoint, float distanceSquared) { //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) if ((Object)(object)golfCart == (Object)null || (Object)(object)golfCart.AsEntity == (Object)null || golfCart.AsEntity.IsDestroyed) { return; } if (landmineTransfersToGolfCartPassengers) { RegisterImpact(golfCart.AsEntity.AsHittable, closestPoint, distanceSquared); return; } for (int i = 0; i < golfCart.passengers.Count; i++) { PlayerInfo val = golfCart.passengers[i]; if (CanTargetPlayer(val)) { RegisterImpact(val.AsHittable, closestPoint, distanceSquared); } } } private void RegisterImpact(Hittable hittable, Vector3 closestPoint, float distanceSquared) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)hittable == (Object)null) && !((Object)(object)hittable.AsEntity == (Object)null) && !hittable.AsEntity.IsDestroyed && (!impactSamples.TryGetValue(hittable, out var value) || !(value.DistanceSquared <= distanceSquared))) { impactSamples[hittable] = new ImpactSample(closestPoint, distanceSquared); } } private static void ApplyLandmineHit(Hittable hittable, ImpactSample sample, MeteorSpawnMessage message) { //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_0011: 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_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_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_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) Vector3 val = sample.ClosestPoint - message.ImpactPoint; if (((Vector3)(ref val)).sqrMagnitude <= 0.0001f) { val = Vector3.up; } else { ((Vector3)(ref val)).Normalize(); } hittable.HitWithItem((ItemType)8, ItemUseId.Invalid, ((Component)hittable).transform.InverseTransformPoint(sample.ClosestPoint), val, ((Component)hittable).transform.InverseTransformPoint(message.ImpactPoint), Mathf.Sqrt(sample.DistanceSquared), (PlayerInventory)null, false, false, true); } private void SpawnMeteorBurst(double now) { int num = ((!(Random.value < 0.3f)) ? 1 : 2); for (int i = 0; i < num; i++) { if (TryCreateMeteorMessage(now, (float)i * 0.28f, out var message)) { pendingImpacts.Add(message); CreateMeteorVisual(message); NetworkServer.SendToReady(message, 0); } } } private bool TryCreateMeteorMessage(double now, float burstOffset, out MeteorSpawnMessage message) { //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_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_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) //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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0100: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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) message = default(MeteorSpawnMessage); if (!TryPickTarget(out var player)) { return false; } Vector3 playerTargetPosition = GetPlayerTargetPosition(player); Vector2 val = Random.insideUnitCircle * Random.Range(0.25f, 3.6f); Vector3 impactNormal; Vector3 val2 = ResolveImpactPoint(playerTargetPosition + new Vector3(val.x, 0f, val.y), out impactNormal); Vector3 startPoint = val2 + new Vector3(Random.Range(-9f, 9f), Random.Range(30f, 38f), Random.Range(-9f, 9f)); MeteorSpawnMessage meteorSpawnMessage = new MeteorSpawnMessage { Id = nextMeteorId++ }; Scene activeScene = SceneManager.GetActiveScene(); meteorSpawnMessage.SceneName = ((Scene)(ref activeScene)).name; meteorSpawnMessage.SpawnTime = now + 1.100000023841858 + (double)burstOffset; meteorSpawnMessage.ImpactTime = now + 1.100000023841858 + (double)burstOffset + 1.25; meteorSpawnMessage.StartPoint = startPoint; meteorSpawnMessage.ImpactPoint = val2; meteorSpawnMessage.ImpactNormal = impactNormal; meteorSpawnMessage.Scale = Random.Range(0.9f, 1.3f); meteorSpawnMessage.ImpactRadius = GameManager.ItemSettings.LandmineExplosionRange; meteorSpawnMessage.Seed = (uint)Random.Range(1, int.MaxValue); message = meteorSpawnMessage; return true; } private bool TryPickTarget(out PlayerInfo player) { player = null; targetBuffer.Clear(); foreach (KeyValuePair item in PlayerInfo.playerInfoPerPlayerGuid) { if (CanTargetPlayer(item.Value)) { targetBuffer.Add(item.Value); } } if (targetBuffer.Count <= 0) { return false; } player = targetBuffer[Random.Range(0, targetBuffer.Count)]; return (Object)(object)player != (Object)null; } private static bool CanTargetPlayer(PlayerInfo player) { if ((Object)(object)player != (Object)null && (Object)(object)player.AsHittable != (Object)null) { return OrbitalLaserManager.CanTarget(player.AsHittable); } return false; } private static Vector3 GetPlayerTargetPosition(PlayerInfo player) { //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_003f: 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_0024: 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) GolfCartSeat activeGolfCartSeat = player.ActiveGolfCartSeat; if (((GolfCartSeat)(ref activeGolfCartSeat)).IsValid() && (Object)(object)player.ActiveGolfCartSeat.golfCart != (Object)null) { return ((Component)player.ActiveGolfCartSeat.golfCart).transform.position; } return ((Component)player).transform.position; } private static Vector3 ResolveImpactPoint(Vector3 desiredImpactPoint, out Vector3 impactNormal) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_009b: Unknown result type (might be due to invalid IL or missing references) RaycastHit[] array = Physics.RaycastAll(desiredImpactPoint + Vector3.up * 48f, Vector3.down, 96f, -1, (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); for (int i = 0; i < array.Length; i++) { Collider collider = ((RaycastHit)(ref array[i])).collider; if (!((Object)(object)collider == (Object)null) && !((Object)(object)((Component)collider).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)collider).GetComponentInParent() != (Object)null)) { impactNormal = ((RaycastHit)(ref array[i])).normal; return ((RaycastHit)(ref array[i])).point; } } impactNormal = Vector3.up; return desiredImpactPoint; } private void TickLocalMeteors(double now) { if (meteorVisuals.Count <= 0) { return; } completedMeteorIds.Clear(); foreach (KeyValuePair meteorVisual in meteorVisuals) { if (!meteorVisual.Value.Tick(now)) { completedMeteorIds.Add(meteorVisual.Key); } } for (int i = 0; i < completedMeteorIds.Count; i++) { ulong key = completedMeteorIds[i]; meteorVisuals[key].Dispose(); meteorVisuals.Remove(key); } completedMeteorIds.Clear(); } private bool CanSpawnMeteors() { //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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 if (BNetworkManager.IsChangingSceneOrShuttingDown) { return false; } if ((Object)(object)GolfHoleManager.MainHole == (Object)null) { return false; } MatchState matchState = CourseManager.MatchState; if ((int)matchState != 3 && (int)matchState != 4) { return (int)matchState == 5; } return true; } private void ScheduleNextMeteor(double now) { nextMeteorTime = now + (double)Random.Range(6f, 9f); } private void EnsureNetworkHooks(bool force) { bool active = NetworkClient.active; bool active2 = NetworkServer.active; double unscaledTimeAsDouble = Time.unscaledTimeAsDouble; if (force || active != lastClientActive || active2 != lastServerActive || !(unscaledTimeAsDouble < nextHandlerRefreshTime)) { lastClientActive = active; lastServerActive = active2; nextHandlerRefreshTime = unscaledTimeAsDouble + 0.5; NetworkClient.ReplaceHandler((Action)OnMeteorSpawnMessage, false); NetworkServer.ReplaceHandler((Action)OnMeteorSpawnMessageServerSide, false); } } private void OnMeteorSpawnMessage(MeteorSpawnMessage message) { CreateMeteorVisual(message); } private void OnMeteorSpawnMessageServerSide(NetworkConnectionToClient connection, MeteorSpawnMessage message) { ((BaseUnityPlugin)this).Logger.LogWarning((object)string.Format("Unexpected server-side meteor message {0} from {1}", message.Id, (connection != null) ? connection.connectionId.ToString() : "null")); } private void CreateMeteorVisual(MeteorSpawnMessage message) { //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) if (!meteorVisuals.ContainsKey(message.Id)) { Scene activeScene = SceneManager.GetActiveScene(); if (string.Equals(((Scene)(ref activeScene)).name, message.SceneName, StringComparison.Ordinal)) { meteorVisuals.Add(message.Id, new MeteorVisual(message, meteorMaterial, warningMaterial)); } } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) ClearMeteors(); pendingImpacts.Clear(); impactSamples.Clear(); nextMeteorTime = double.NaN; lastMatchState = (MatchState)(-1); TryRefreshLandmineTransferSetting(); EnsureNetworkHooks(force: true); } private void ClearMeteors() { foreach (KeyValuePair meteorVisual in meteorVisuals) { meteorVisual.Value.Dispose(); } meteorVisuals.Clear(); completedMeteorIds.Clear(); } private void TryRefreshLandmineTransferSetting() { ItemData val = default(ItemData); if (SingletonBehaviour.HasInstance && (Object)(object)GameManager.AllItems != (Object)null && GameManager.AllItems.TryGetItemData((ItemType)8, ref val)) { landmineTransfersToGolfCartPassengers = val.HitTransfersToGolfCartPassengers; } } private void TrackMatchState(double now) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 MatchState matchState = CourseManager.MatchState; if (matchState != lastMatchState) { lastMatchState = matchState; if (NetworkServer.active && (int)matchState == 3) { nextMeteorTime = now + 2.5; } } } private static double GetNow() { if (NetworkClient.active || NetworkServer.active) { return NetworkTime.time; } return Time.unscaledTime; } private static void RegisterMirrorTypes() { if (!mirrorTypesRegistered) { Writer.write = WriteMeteorSpawnMessage; Reader.read = ReadMeteorSpawnMessage; mirrorTypesRegistered = true; } } private static void WriteMeteorSpawnMessage(NetworkWriter writer, MeteorSpawnMessage message) { //IL_0032: 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_004a: Unknown result type (might be due to invalid IL or missing references) writer.Write(message.Id); writer.Write(message.SceneName); writer.Write(message.SpawnTime); writer.Write(message.ImpactTime); writer.Write(message.StartPoint); writer.Write(message.ImpactPoint); writer.Write(message.ImpactNormal); writer.Write(message.Scale); writer.Write(message.ImpactRadius); writer.Write(message.Seed); } private static MeteorSpawnMessage ReadMeteorSpawnMessage(NetworkReader reader) { //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_004c: 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_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) MeteorSpawnMessage result = default(MeteorSpawnMessage); result.Id = reader.Read(); result.SceneName = reader.Read(); result.SpawnTime = reader.Read(); result.ImpactTime = reader.Read(); result.StartPoint = reader.Read(); result.ImpactPoint = reader.Read(); result.ImpactNormal = reader.Read(); result.Scale = reader.Read(); result.ImpactRadius = reader.Read(); result.Seed = reader.Read(); return result; } private static Material CreateMaterial(Color color) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0049: Expected O, but got Unknown Shader val = Shader.Find("Sprites/Default"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Legacy Shaders/Particles/Additive"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Unlit/Color"); } return new Material(val) { color = color, hideFlags = (HideFlags)61 }; } } }