Decompiled source of GunGame v1.2.3
plugins/GunGameMod.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using FishNet; using FishNet.Connection; using FishNet.Managing; using FishNet.Managing.Scened; using FishNet.Object; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("GunGameMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+87e1819de472829ee4359e1459224afd33ef4312")] [assembly: AssemblyProduct("GunGameMod")] [assembly: AssemblyTitle("GunGameMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 GunGameMod { public static class GunGamePatches { [CompilerGenerated] private sealed class <ClearOnStartRoundScreen>d__88 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public PauseManager pm; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ClearOnStartRoundScreen>d__88(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.8f); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)pm != (Object)null) { pm.onStartRoundScreen = false; } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <DeferredDropCleanup>d__59 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public bool rightHand; public PlayerPickup pickup; public bool isPlaceable; public bool isThrowable; public GameObject obj; public int playerId; public int weaponIndex; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DeferredDropCleanup>d__59(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; try { if (rightHand) { pickup.sync___set_value_hasObjectInHand(false, true); pickup.sync___set_value_objInHand((GameObject)null, true); } else { pickup.sync___set_value_hasObjectInLeftHand(false, true); pickup.sync___set_value_objInLeftHand((GameObject)null, true); } } catch { } if (!isPlaceable && !isThrowable && (Object)(object)this.obj != (Object)null) { NetworkObject component = this.obj.GetComponent<NetworkObject>(); if ((Object)(object)component != (Object)null && component.IsSpawned) { try { InstanceFinder.ServerManager.Despawn(component, (DespawnType?)null); } catch { } } else { try { Object.Destroy((Object)(object)this.obj); } catch { } } } <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 2; return true; case 2: <>1__state = -1; if (playerId < 0 || GunGamePlugin.MatchOver) { return false; } if (isPlaceable) { string handReplaceKey = GetHandReplaceKey(playerId, rightHand); if (!_pendingPlaceableReplace.Contains(handReplaceKey)) { _pendingPlaceableReplace.Add(handReplaceKey); object obj = ((object)GameManager.Instance) ?? ((object)GunGamePlugin.Instance); if (obj != null) { ((MonoBehaviour)obj).StartCoroutine(EnsurePlaceableReplaced(playerId, rightHand)); } } } else { GunGameWeaponManager.ReplaceWeaponInHand(playerId, weaponIndex, rightHand); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <DelayedInitialSpawnFallback>d__61 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public int playerId; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DelayedInitialSpawnFallback>d__61(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(7f); <>1__state = 1; return true; case 1: <>1__state = -1; if (GunGamePlugin.MatchOver) { return false; } try { if (GunGameWeaponManager.IsGivingWeapon(playerId)) { return false; } PlayerPickup val = GunGamePlugin.FindPickupForPlayerId(playerId); if ((Object)(object)val != (Object)null && !val.sync___get_value_hasObjectInHand()) { GunGameWeaponManager.GiveWeaponToPlayer(playerId, GetCurrentWeaponIndex(playerId)); } } catch { } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <DelayedKillWeaponGive>d__60 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public int killerId; public int weaponIndex; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DelayedKillWeaponGive>d__60(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(3f); <>1__state = 1; return true; case 1: <>1__state = -1; if (GunGamePlugin.MatchOver) { return false; } try { PlayerPickup val = GunGamePlugin.FindPickupForPlayerId(killerId); if ((Object)(object)val != (Object)null && !val.sync___get_value_hasObjectInHand()) { GunGameWeaponManager.GiveWeaponToPlayer(killerId, weaponIndex); } } catch { } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <DelayedRespawnWeaponFallback>d__62 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public int playerId; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DelayedRespawnWeaponFallback>d__62(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(3f); <>1__state = 1; return true; case 1: <>1__state = -1; if (GunGamePlugin.MatchOver) { return false; } try { if (GunGameWeaponManager.IsGivingWeapon(playerId)) { return false; } PlayerPickup val = GunGamePlugin.FindPickupForPlayerId(playerId); if ((Object)(object)val != (Object)null && !val.sync___get_value_hasObjectInHand()) { GunGameWeaponManager.GiveWeaponToPlayer(playerId, GetCurrentWeaponIndex(playerId)); } } catch { } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <EmptyCoroutine>d__36 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <EmptyCoroutine>d__36(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <EnsurePlaceableReplaced>d__63 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public int playerId; public bool rightHand; private bool <gave>5__2; private int <attempt>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <EnsurePlaceableReplaced>d__63(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>1__state = -2; } private bool MoveNext() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown bool result; try { switch (<>1__state) { default: result = false; goto end_IL_0000; case 0: <>1__state = -1; <gave>5__2 = false; <>1__state = -3; <attempt>5__3 = 0; goto IL_00dc; case 1: { <>1__state = -3; if (GunGamePlugin.MatchOver) { result = false; break; } if (!GunGameWeaponManager.IsGivingWeaponInHand(playerId, rightHand)) { PlayerPickup val = GunGamePlugin.FindPickupForPlayerId(playerId); if (!((Object)(object)val == (Object)null)) { if (IsHandEmpty(val, rightHand)) { int currentWeaponIndex = GetCurrentWeaponIndex(playerId); GunGameWeaponManager.ReplaceWeaponInHand(playerId, currentWeaponIndex, rightHand); <gave>5__2 = true; } result = false; break; } } <attempt>5__3++; goto IL_00dc; } IL_00dc: if (<attempt>5__3 < 12) { <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; result = true; } else { if (!<gave>5__2 && !GunGamePlugin.MatchOver) { PlayerPickup val2 = GunGamePlugin.FindPickupForPlayerId(playerId); if ((Object)(object)val2 != (Object)null && IsHandEmpty(val2, rightHand)) { GunGameWeaponManager.ReplaceWeaponInHand(playerId, GetCurrentWeaponIndex(playerId), rightHand); } } <>m__Finally1(); result = false; } goto end_IL_0000; } <>m__Finally1(); end_IL_0000:; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; _pendingPlaceableReplace.Remove(GetHandReplaceKey(playerId, rightHand)); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <KeepPlayerMovable>d__78 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public float duration; public PlayerManager pm; private float <end>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <KeepPlayerMovable>d__78(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <end>5__2 = Time.time + duration; break; case 1: <>1__state = -1; break; } if (Time.time < <end>5__2) { try { if ((Object)(object)pm != (Object)null) { pm.SetPlayerMove(true); if ((Object)(object)pm.player != (Object)null) { pm.player.sync___set_value_canMove(true, true); pm.player.startOfRound = false; } if ((Object)(object)PauseManager.Instance != (Object)null) { PauseManager.Instance.startRound = false; } } } catch { } <>2__current = null; <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <SinglePlayerRespawnCoroutine>d__72 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public int deadPlayerId; private float <gateTimeout>5__2; private bool <spawned>5__3; private int <attempt>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SinglePlayerRespawnCoroutine>d__72(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 3) <= 2u) { try { } finally { <>m__Finally1(); } } <>1__state = -2; } private bool MoveNext() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Expected O, but got Unknown //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(GunGamePlugin.RespawnDelay.Value + 3f); <>1__state = 1; return true; case 1: <>1__state = -1; if (GunGamePlugin.MatchOver) { return false; } if ((Object)(object)GameManager.Instance == (Object)null || (Object)(object)InstanceFinder.NetworkManager == (Object)null || !InstanceFinder.NetworkManager.IsServer) { return false; } <gateTimeout>5__2 = Time.time + 5f; goto IL_00cd; case 2: <>1__state = -1; goto IL_00cd; case 3: <>1__state = -3; goto IL_029b; case 4: <>1__state = -3; goto IL_029b; case 5: { <>1__state = -3; PlayerManager pm = FindPlayerManagerForId(deadPlayerId); if (IsPlayerRespawnValid(deadPlayerId, pm, out var reason)) { <spawned>5__3 = true; LogRespawn(deadPlayerId, <attempt>5__4, "respawn verified"); if ((Object)(object)GameManager.Instance != (Object)null) { GameManager.Instance.SetStartTime(0f); } GameManager instance = GameManager.Instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(KeepPlayerMovable(pm, 4f)); } break; } LogRespawn(deadPlayerId, <attempt>5__4, "verify failed: " + reason); goto IL_029b; } IL_00cd: if (_respawnInProgress.Contains(deadPlayerId) && Time.time < <gateTimeout>5__2) { <>2__current = null; <>1__state = 2; return true; } if (_respawnInProgress.Contains(deadPlayerId)) { return false; } _respawnInProgress.Add(deadPlayerId); <spawned>5__3 = false; <>1__state = -3; <attempt>5__4 = 1; goto IL_02ad; IL_02ad: if (<attempt>5__4 <= 3 && !GunGamePlugin.MatchOver) { PlayerManager pm = FindPlayerManagerForId(deadPlayerId); if ((Object)(object)pm == (Object)null) { LogRespawn(deadPlayerId, <attempt>5__4, "missing PlayerManager"); <>2__current = (object)new WaitForSeconds(0.6f); <>1__state = 3; return true; } CleanupRespawnArtifacts(deadPlayerId); if (<attempt>5__4 > 1) { CleanupSpawnedObjectForPlayer(pm, deadPlayerId); } if (!TryInvokeRespawn(pm, deadPlayerId, <attempt>5__4)) { <>2__current = (object)new WaitForSeconds(0.6f); <>1__state = 4; return true; } <>2__current = (object)new WaitForSeconds(0.6f); <>1__state = 5; return true; } break; IL_029b: <attempt>5__4++; goto IL_02ad; } <>m__Finally1(); if (<spawned>5__3) { GameManager instance2 = GameManager.Instance; if (instance2 != null) { ((MonoBehaviour)instance2).StartCoroutine(DelayedRespawnWeaponFallback(deadPlayerId)); } } else { LogRespawn(deadPlayerId, 3, "respawn failed after all attempts"); } return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; _respawnInProgress.Remove(deadPlayerId); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <WinSequenceCoroutine>d__67 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public int winnerPlayerId; private bool <endRoundCalled>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WinSequenceCoroutine>d__67(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(1.5f); <>1__state = 1; return true; case 1: { <>1__state = -1; <endRoundCalled>5__2 = false; int num = -1; try { num = GetPlayerTeam(winnerPlayerId); BroadcastChat("<b><color=yellow>[Gun Game]</color></b> <b><color=white>" + GetPlayerName(winnerPlayerId) + "</color></b> wins the round!"); if ((Object)(object)ScoreManager.Instance != (Object)null) { ScoreManager.Instance.AddRoundScore(num, 1); } if (_miRoundWon != null) { _miRoundWon.Invoke(GameManager.Instance, new object[1] { num }); } if ((Object)(object)RoundManager.Instance != (Object)null) { RoundManager.Instance.CmdEndRound(num); <endRoundCalled>5__2 = true; } } catch { } <>2__current = (object)new WaitForSeconds(4f); <>1__state = 2; return true; } case 2: <>1__state = -1; if (<endRoundCalled>5__2) { try { if ((Object)(object)SceneMotor.Instance != (Object)null) { SceneMotor.Instance.ChangeNetworkScene(); } } catch { } } GunGamePlugin.MatchOver = false; ResetState(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static Harmony _harmony; private static Dictionary<int, int> _killsPerPlayer = new Dictionary<int, int>(); private static HashSet<int> _waitingForSetStartTime = new HashSet<int>(); private static HashSet<string> _pendingPlaceableReplace = new HashSet<string>(); private static Dictionary<int, GameObject> _playerRagdolls = new Dictionary<int, GameObject>(); private static bool _winSequenceInProgress = false; private static HashSet<int> _respawnInProgress = new HashSet<int>(); private static Dictionary<int, float> _lastKillAwardTime = new Dictionary<int, float>(); private static Dictionary<int, int> _lastKillAwardCount = new Dictionary<int, int>(); private static Dictionary<string, float> _suppressThrowableOpenUntil = new Dictionary<string, float>(); private static HashSet<int> _minigunDropQueued = new HashSet<int>(); private const float MultiKillAwardSuppressSeconds = 0.35f; private const float ThrowableOpenSuppressSeconds = 0.35f; private const int MaxRespawnAttempts = 3; private const float RespawnSettleSeconds = 0.6f; private static MethodInfo _miCmdRespawn; private static MethodInfo _miRoundWon; private static FieldInfo _fiSpawnedObject; private static MethodInfo _miUnsubscribeFromInput; private static MethodInfo _miSpawnPlayer4Args; private static MethodInfo _miReturnSpawnPoint; private static MethodInfo _miRpcLogic_DropObjectServer; private static MethodInfo _miMatchLogsSendToAll; private static FieldInfo _fiRightIdlePosition; private static FieldInfo _fiRigBuilder; private static Type _particleSystemType; public static void Apply() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Expected O, but got Unknown if (_harmony != null) { return; } _harmony = new Harmony("com.modder.gungame.patches"); CacheReflectionMethods(); try { PatchPrefix(typeof(GameManager), "WaitForDraw", "GameManager_WaitForDraw_Prefix"); PatchPrefix(typeof(GameManager), "RpcLogic___PlayerDied_3316948804", "GameManager_RpcLogic_PlayerDied_Prefix"); if (_miCmdRespawn != null) { _harmony.Patch((MethodBase)_miCmdRespawn, new HarmonyMethod(typeof(GunGamePatches).GetMethod("PlayerManager_RpcLogic_CmdRespawn_Prefix", BindingFlags.Static | BindingFlags.Public)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } PatchPrefix(typeof(RoundManager), "CmdEndRound", "RoundManager_CmdEndRound_Prefix"); PatchPrefix(typeof(GameManager), "SetStartTime", "GameManager_SetStartTime_Prefix"); PatchPrefix(typeof(PlayerManager), "RpcLogic___SetPlayerMove_1140765316", "PlayerManager_RpcLogic_SetPlayerMove_Prefix"); PatchPrefix(typeof(KillCam), "Update", "KillCam_Update_Prefix"); PatchPrefix(typeof(ItemBehaviour), "Start", "ItemBehaviour_Start_Prefix"); PatchPostfixReflected(typeof(PlayerPickup), "RpcLogic___SetObjectInHandObserver_46969756", "PlayerPickup_SetObjectInHandObserver_Postfix"); PatchPrefix(typeof(ItemBehaviour), "StickOnGround", "ItemBehaviour_StickOnGround_Prefix"); PatchPrefix(typeof(Spawner), "Update", "Spawner_Update_Prefix"); PatchPrefix(typeof(PlayerPickup), "RightHandFix", "PlayerPickup_RightHandFix_Prefix"); PatchPrefix(typeof(PlayerPickup), "LeftHandFix", "PlayerPickup_LeftHandFix_Prefix"); PatchPrefix(typeof(PlayerPickup), "HandsReconstruct", "PlayerPickup_HandsReconstruct_Prefix"); PatchPrefix(typeof(PlayerPickup), "RightHandDrop", "PlayerPickup_RightHandDrop_Prefix"); PatchPrefix(typeof(PlayerPickup), "RightHandPickup", "PlayerPickup_RightHandPickup_Prefix"); PatchPrefix(typeof(PlayerPickup), "SwitchWeapons", "PlayerPickup_SwitchWeapons_Prefix"); PatchPrefix(typeof(PlayerPickup), "LeftHandPickup", "PlayerPickup_LeftHandPickup_Prefix"); if (_miRpcLogic_DropObjectServer != null) { _harmony.Patch((MethodBase)_miRpcLogic_DropObjectServer, new HarmonyMethod(typeof(GunGamePatches).GetMethod("PlayerPickup_RpcLogic_DropObjectServer_Prefix", BindingFlags.Static | BindingFlags.Public)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } PatchPrefix(typeof(PauseManager), "StartRoundDelay", "PauseManager_StartRoundDelay_Prefix"); PatchPrefix(typeof(ProximityMine), "KillShockWave", "ProximityMine_KillShockWave_Prefix"); PatchPrefix(typeof(Claymore), "KillShockWave", "Claymore_KillShockWave_Prefix"); PatchPostfix(typeof(Minigun), "Update", "Minigun_Update_Postfix"); PatchPrefix(typeof(DualLauncher), "SetBool", "DualLauncher_SetBool_Prefix"); PatchPostfix(typeof(WeaponHandSpawner), "RpcLogic___SpawnObject_2587446063", "WeaponHandSpawner_SpawnObject_Postfix"); PatchPrefix(typeof(MatchLogs), "RpcLogic___RpcSendChatLine_3615296227", "MatchLogs_RpcSendChatLine_Prefix"); PatchPostfix(typeof(PlayerManager), "SpawnPlayer", "PlayerManager_SpawnPlayer_Postfix", new Type[2] { typeof(int), typeof(int) }); PatchPostfix(typeof(PlayerManager), "RpcLogic___CmdRespawn_2166136261", "PlayerManager_RpcLogic_CmdRespawn_Postfix"); PatchPostfix(typeof(PlayerHealth), "RpcLogic___ExplodeForAll_576886416", "PlayerHealth_ExplodeForAll_Postfix"); PatchPostfixReflected(typeof(PlayerValues), "sync___set_value_playerClient", "PlayerValues_SetPlayerClient_Postfix"); PatchPrefix(typeof(DamageZone), "OnEnable", "DamageZone_OnEnable_Prefix"); PatchPrefix(typeof(FirstPersonController), "OnTriggerStay", "FirstPersonController_OnTriggerStay_Prefix"); } catch { } } private static void CacheReflectionMethods() { _miCmdRespawn = typeof(PlayerManager).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo m) => m.Name.Contains("RpcLogic___CmdRespawn")); _miRoundWon = typeof(GameManager).GetMethod("RoundWon", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _fiSpawnedObject = typeof(PlayerManager).GetField("SpawnedObject", BindingFlags.Instance | BindingFlags.NonPublic); _miUnsubscribeFromInput = typeof(PlayerManager).GetMethod("UnsubscribeFromInput", BindingFlags.Instance | BindingFlags.NonPublic); _miReturnSpawnPoint = typeof(PlayerManager).GetMethod("ReturnSpawnPoint", BindingFlags.Instance | BindingFlags.NonPublic); _miSpawnPlayer4Args = typeof(PlayerManager).GetMethod("SpawnPlayer", BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[4] { typeof(int), typeof(int), typeof(Vector3), typeof(Quaternion) }, null); _miRpcLogic_DropObjectServer = typeof(PlayerPickup).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo m) => m.Name.Contains("RpcLogic___DropObjectServer")); _miMatchLogsSendToAll = typeof(MatchLogs).GetMethod("RpcSendChatLineToAllObservers", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _fiRightIdlePosition = typeof(PlayerPickup).GetField("RightIdlePosition", BindingFlags.Instance | BindingFlags.NonPublic); _fiRigBuilder = typeof(PlayerPickup).GetField("RigBuilder", BindingFlags.Instance | BindingFlags.NonPublic); } private static void PatchPrefix(Type type, string methodName, string patchName, Type[] paramTypes = null) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown MethodInfo methodInfo = ((paramTypes == null) ? type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) : type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, paramTypes, null)); if (!(methodInfo == null)) { _harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(GunGamePatches).GetMethod(patchName, BindingFlags.Static | BindingFlags.Public)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private static void PatchPostfix(Type type, string methodName, string patchName, Type[] paramTypes = null) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown MethodInfo methodInfo = ((paramTypes == null) ? type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) : type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, paramTypes, null)); if (!(methodInfo == null)) { _harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(GunGamePatches).GetMethod(patchName, BindingFlags.Static | BindingFlags.Public)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private static void PatchPostfixReflected(Type type, string methodName, string patchName) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown MethodInfo method = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(method == null)) { _harmony.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(typeof(GunGamePatches).GetMethod(patchName, BindingFlags.Static | BindingFlags.Public)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } public static void ResetState() { _killsPerPlayer.Clear(); _waitingForSetStartTime.Clear(); _pendingPlaceableReplace.Clear(); _playerRagdolls.Clear(); _winSequenceInProgress = false; _respawnInProgress.Clear(); _lastKillAwardTime.Clear(); _lastKillAwardCount.Clear(); _suppressThrowableOpenUntil.Clear(); _minigunDropQueued.Clear(); } public static int GetCurrentWeaponIndex(int playerId) { int progressStage = GetProgressStage(playerId); int orderedWeaponCount = GunGamePlugin.GetOrderedWeaponCount(); if (orderedWeaponCount <= 0) { return 0; } return (progressStage - 1) % orderedWeaponCount; } private static int GetProgressStage(int playerId) { if (!_killsPerPlayer.TryGetValue(playerId, out var value) || value <= 0) { return 1; } return value; } private static int GetCompletedKillCount(int playerId) { return GetProgressStage(playerId) - 1; } public static bool GameManager_WaitForDraw_Prefix(ref IEnumerator __result) { if (!GunGamePlugin.MatchOver) { __result = EmptyCoroutine(); return false; } return true; } public static bool KillCam_Update_Prefix() { return !GunGamePlugin.Enabled.Value; } [IteratorStateMachine(typeof(<EmptyCoroutine>d__36))] private static IEnumerator EmptyCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <EmptyCoroutine>d__36(0); } public static bool PlayerManager_RpcLogic_CmdRespawn_Prefix(PlayerManager __instance) { //IL_015b: 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_017d: Unknown result type (might be due to invalid IL or missing references) if (!GunGamePlugin.Enabled.Value) { return true; } try { if (_miSpawnPlayer4Args == null) { return true; } object? obj = _miReturnSpawnPoint?.Invoke(__instance, null); Transform val = (Transform)((obj is Transform) ? obj : null); if ((Object)(object)val == (Object)null) { SpawnPoint[] array = Object.FindObjectsOfType<SpawnPoint>(); if (array.Length != 0) { val = ((Component)array[Random.Range(0, array.Length)]).transform; } } if ((Object)(object)val == (Object)null) { return true; } object? obj2 = _fiSpawnedObject?.GetValue(__instance); GameObject val2 = (GameObject)((obj2 is GameObject) ? obj2 : null); if ((Object)(object)val2 != (Object)null) { try { _miUnsubscribeFromInput?.Invoke(__instance, null); } catch { } if (((NetworkBehaviour)__instance).IsServer) { NetworkObject component = val2.GetComponent<NetworkObject>(); if ((Object)(object)component != (Object)null && component.IsSpawned) { if (!val2.activeSelf) { val2.SetActive(true); } ((NetworkBehaviour)__instance).NetworkManager.ServerManager.Despawn(val2, (DespawnType?)null); } else { Object.Destroy((Object)(object)val2); } } } int num = (((Object)(object)CosmeticsManager.Instance != (Object)null) ? CosmeticsManager.Instance.currentsuitIndex : 0); int num2 = (((Object)(object)CosmeticsManager.Instance != (Object)null) ? CosmeticsManager.Instance.currentcigIndex : 0); try { _miSpawnPlayer4Args.Invoke(__instance, new object[4] { num, num2, val.position, Quaternion.Euler(0f, val.eulerAngles.y, 0f) }); } catch { try { if ((Object)(object)val2 != (Object)null) { val2.SetActive(true); } } catch { } return true; } } catch { return true; } return false; } public static bool GameManager_RpcLogic_PlayerDied_Prefix(int playerId) { if (!GunGamePlugin.Enabled.Value) { return true; } if (GunGamePlugin.MatchOver) { return false; } try { if ((Object)(object)InstanceFinder.NetworkManager != (Object)null && InstanceFinder.NetworkManager.IsServer) { PlayerPickup val = GunGamePlugin.FindPickupForPlayerId(playerId); if ((Object)(object)val != (Object)null) { GunGameWeaponManager.DespawnHeldWeapon(val); } ClearPlacedExplosivesForPlayer(playerId); GunGameWeaponManager.QueueWeaponUpgrade(playerId, GetCurrentWeaponIndex(playerId)); } if (GameManager.Instance?.alivePlayers != null && !GameManager.Instance.alivePlayers.Contains(playerId)) { GameManager.Instance.alivePlayers.Add(playerId); } if ((Object)(object)InstanceFinder.NetworkManager == (Object)null || !InstanceFinder.NetworkManager.IsServer) { return true; } int num = FindKillerId(playerId); if (num >= 0 && num != playerId) { float unscaledTime = Time.unscaledTime; int progressStage = GetProgressStage(num); int completedKillCount = GetCompletedKillCount(num); int num2 = progressStage + 1; if (progressStage > 1 && _lastKillAwardTime.TryGetValue(num, out var value) && unscaledTime - value <= 0.35f && _lastKillAwardCount.TryGetValue(num, out var value2) && value2 == progressStage) { string playerName = GetPlayerName(num); string playerName2 = GetPlayerName(playerId); int orderedWeaponCount = GunGamePlugin.GetOrderedWeaponCount(); GameObject orderedWeaponPrefab = GunGamePlugin.GetOrderedWeaponPrefab((orderedWeaponCount > 0) ? ((completedKillCount - 1 + orderedWeaponCount) % orderedWeaponCount) : 0); string text = ((orderedWeaponPrefab != null) ? ((Object)orderedWeaponPrefab).name : null) ?? "Unknown"; BroadcastChat($"<b><color=yellow>[Gun Game]</color></b> <b>{playerName}</b> <color=red>killed</color> <b>{playerName2}</b> with <b><color=white>{text}</color></b> <color=#00FFFF>[{completedKillCount}/{GunGamePlugin.KillsToWin.Value}]</color>"); } else { _lastKillAwardTime[num] = unscaledTime; _lastKillAwardCount[num] = num2; _killsPerPlayer[num] = num2; int num3 = num2 - 1; int orderedWeaponCount2 = GunGamePlugin.GetOrderedWeaponCount(); int weaponIndex = ((orderedWeaponCount2 > 0) ? ((num2 - 1) % orderedWeaponCount2) : 0); GameObject orderedWeaponPrefab2 = GunGamePlugin.GetOrderedWeaponPrefab((orderedWeaponCount2 > 0) ? ((num2 - 2 + orderedWeaponCount2) % orderedWeaponCount2) : 0); string text2 = ((orderedWeaponPrefab2 != null) ? ((Object)orderedWeaponPrefab2).name : null) ?? "Unknown"; string playerName3 = GetPlayerName(num); string playerName4 = GetPlayerName(playerId); BroadcastChat((num3 >= GunGamePlugin.KillsToWin.Value) ? ("<b><color=yellow>[Gun Game]</color></b> <b>" + playerName3 + "</b> <color=red>killed</color> <b>" + playerName4 + "</b> with <b><color=white>" + text2 + "</color></b> — <b><color=yellow>WINS THE ROUND!</color></b>") : $"<b><color=yellow>[Gun Game]</color></b> <b>{playerName3}</b> <color=red>killed</color> <b>{playerName4}</b> with <b><color=white>{text2}</color></b> <color=#00FFFF>[{num3}/{GunGamePlugin.KillsToWin.Value}]</color>"); GunGameWeaponManager.GiveWeaponToPlayer(num, weaponIndex); ((MonoBehaviour)GameManager.Instance).StartCoroutine(DelayedKillWeaponGive(num, weaponIndex)); switch (text2) { case "ProximityMine": case "APMine": case "Claymore": ClearPlacedExplosivesForPlayer(num); break; } if (num3 >= GunGamePlugin.KillsToWin.Value && !_winSequenceInProgress) { _winSequenceInProgress = true; GunGamePlugin.MatchOver = true; ((MonoBehaviour)GameManager.Instance).StartCoroutine(WinSequenceCoroutine(num)); return false; } } } else { string playerName5 = GetPlayerName(playerId); BroadcastChat("<b><color=yellow>[Gun Game]</color></b> <b>" + playerName5 + "</b> <color=#888888>killed themselves</color>"); } if ((Object)(object)GameManager.Instance != (Object)null) { ((MonoBehaviour)GameManager.Instance).StartCoroutine(SinglePlayerRespawnCoroutine(playerId)); } } catch { try { if ((Object)(object)GameManager.Instance != (Object)null) { ((MonoBehaviour)GameManager.Instance).StartCoroutine(SinglePlayerRespawnCoroutine(playerId)); } } catch { } } return false; } public static void PlayerManager_SpawnPlayer_Postfix(PlayerManager __instance) { if (!GunGamePlugin.Enabled.Value || (Object)(object)__instance == (Object)null) { return; } ClientInstance component = ((Component)__instance).GetComponent<ClientInstance>(); if ((Object)(object)component == (Object)null) { return; } int playerId = component.PlayerId; if (playerId < 0) { return; } if ((Object)(object)InstanceFinder.NetworkManager != (Object)null && InstanceFinder.NetworkManager.IsServer) { int num; if (!_respawnInProgress.Contains(playerId)) { num = (GunGameWeaponManager.HasPendingWeapon(playerId) ? 1 : 0); if (num == 0) { if (_killsPerPlayer.ContainsKey(playerId)) { _killsPerPlayer.Remove(playerId); } GunGameWeaponManager.ClearPendingForPlayer(playerId); } } else { num = 1; } if (GameManager.Instance?.alivePlayers != null && !GameManager.Instance.alivePlayers.Contains(playerId)) { GameManager.Instance.alivePlayers.Add(playerId); } _waitingForSetStartTime.Add(playerId); if (num == 0 && GunGamePlugin.GetOrderedWeaponCount() > 0) { GunGameWeaponManager.GiveWeaponToPlayer(playerId, 0); GameManager instance = GameManager.Instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(DelayedInitialSpawnFallback(playerId)); } } } if (((NetworkBehaviour)__instance).IsOwner) { if ((Object)(object)PauseManager.Instance != (Object)null) { PauseManager.Instance.startRound = false; } GameManager instance2 = GameManager.Instance; if (instance2 != null) { ((MonoBehaviour)instance2).StartCoroutine(KeepPlayerMovable(__instance, 4f)); } } } public static void PlayerManager_RpcLogic_CmdRespawn_Postfix(PlayerManager __instance) { if (!GunGamePlugin.Enabled.Value || (Object)(object)__instance == (Object)null) { return; } ClientInstance component = ((Component)__instance).GetComponent<ClientInstance>(); if ((Object)(object)component == (Object)null) { return; } int playerId = component.PlayerId; if (playerId < 0) { return; } _waitingForSetStartTime.Add(playerId); if ((Object)(object)InstanceFinder.NetworkManager != (Object)null && InstanceFinder.NetworkManager.IsServer) { if (GunGameWeaponManager.HasPendingWeapon(playerId)) { GunGameWeaponManager.ApplyPendingWeaponOnSpawn(playerId); } else { GunGameWeaponManager.GiveWeaponToPlayer(playerId, GetCurrentWeaponIndex(playerId)); } } if (((NetworkBehaviour)__instance).IsOwner) { if ((Object)(object)PauseManager.Instance != (Object)null) { PauseManager.Instance.startRound = false; } GameManager instance = GameManager.Instance; if ((Object)(object)instance != (Object)null) { ((MonoBehaviour)instance).StartCoroutine(KeepPlayerMovable(__instance, 4f)); } } } public static void GameManager_SetStartTime_Prefix(ref float serverTimeTillStart) { if (GunGamePlugin.Enabled.Value && !GunGamePlugin.MatchOver) { serverTimeTillStart = 0f; } } public static bool PlayerManager_RpcLogic_SetPlayerMove_Prefix(PlayerManager __instance, bool state) { if (!GunGamePlugin.Enabled.Value || GunGamePlugin.MatchOver) { return true; } ClientInstance component = ((Component)__instance).GetComponent<ClientInstance>(); if ((Object)(object)component == (Object)null) { return true; } int playerId = component.PlayerId; if (playerId < 0) { return true; } if (!state && _waitingForSetStartTime.Contains(playerId)) { _waitingForSetStartTime.Remove(playerId); try { if ((Object)(object)__instance.player != (Object)null) { __instance.player.sync___set_value_canMove(true, true); __instance.player.startOfRound = false; } if ((Object)(object)PauseManager.Instance != (Object)null) { PauseManager.Instance.startRound = false; PauseManager.Instance.pause = false; PauseManager.Instance.otherPauseBools = false; } } catch { } return false; } return true; } public static bool ItemBehaviour_Start_Prefix(ItemBehaviour __instance) { //IL_0031: 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) if ((Object)(object)__instance == (Object)null) { return true; } __instance.dispenserStart = true; Rigidbody component = ((Component)__instance).GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { component.isKinematic = true; component.useGravity = false; component.velocity = Vector3.zero; component.angularVelocity = Vector3.zero; } return true; } public static void PlayerPickup_SetObjectInHandObserver_Postfix(PlayerPickup __instance, GameObject obj) { if (!((Object)(object)obj == (Object)null)) { ItemBehaviour component = obj.GetComponent<ItemBehaviour>(); if ((Object)(object)component != (Object)null) { component.dispenserStart = false; } } } public static bool ItemBehaviour_StickOnGround_Prefix(ItemBehaviour __instance) { if ((Object)(object)__instance.cam == (Object)null) { return false; } return true; } public static bool Spawner_Update_Prefix() { return !GunGamePlugin.Enabled.Value; } public static bool PlayerPickup_RightHandFix_Prefix(PlayerPickup __instance) { //IL_0076: 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) if (!GunGamePlugin.Enabled.Value) { return true; } if (__instance.sync___get_value_hasObjectInHand() && (Object)(object)__instance.sync___get_value_objInHand() == (Object)null) { __instance.sync___set_value_hasObjectInHand(false, true); return false; } GameObject val = __instance.sync___get_value_objInHand(); if ((Object)(object)val == (Object)null) { return true; } if (val.layer == 7 || val.layer == 9) { MethodInfo setObjectInHandObserverLogic = GunGameWeaponManager.SetObjectInHandObserverLogic; if (setObjectInHandObserverLogic != null) { try { setObjectInHandObserverLogic.Invoke(__instance, new object[5] { val, val.transform.position, val.transform.rotation, ((Component)__instance).gameObject, true }); } catch { } } return false; } return true; } public static bool PlayerPickup_LeftHandFix_Prefix(PlayerPickup __instance) { //IL_0076: 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) if (!GunGamePlugin.Enabled.Value) { return true; } if (__instance.sync___get_value_hasObjectInLeftHand() && (Object)(object)__instance.sync___get_value_objInLeftHand() == (Object)null) { __instance.sync___set_value_hasObjectInLeftHand(false, true); return false; } GameObject val = __instance.sync___get_value_objInLeftHand(); if ((Object)(object)val == (Object)null) { return true; } if (val.layer == 7 || val.layer == 9) { MethodInfo setObjectInHandObserverLogic = GunGameWeaponManager.SetObjectInHandObserverLogic; if (setObjectInHandObserverLogic != null) { try { setObjectInHandObserverLogic.Invoke(__instance, new object[5] { val, val.transform.position, val.transform.rotation, ((Component)__instance).gameObject, false }); } catch { } } return false; } return true; } public static bool PlayerPickup_RightHandDrop_Prefix(PlayerPickup __instance) { if (!GunGamePlugin.Enabled.Value) { return true; } GameObject val = __instance.sync___get_value_objInHand(); if (__instance.sync___get_value_hasObjectInHand() && ((Object)(object)val == (Object)null || (Object)(object)val.GetComponent<ItemBehaviour>() == (Object)null)) { __instance.sync___set_value_hasObjectInHand(false, true); __instance.sync___set_value_objInHand((GameObject)null, true); return false; } PlayerHealth componentInParent = ((Component)__instance).GetComponentInParent<PlayerHealth>(); if ((Object)(object)componentInParent != (Object)null && componentInParent.sync___get_value_isKilled()) { return false; } return true; } public static bool PlayerPickup_HandsReconstruct_Prefix(PlayerPickup __instance) { if (!GunGamePlugin.Enabled.Value || (Object)(object)__instance == (Object)null) { return true; } try { GameObject val = __instance.sync___get_value_objInLeftHand(); GameObject val2 = __instance.sync___get_value_objInHand(); if ((Object)(object)val == (Object)null || (Object)(object)val2 != (Object)null) { return true; } object? obj = _fiRightIdlePosition?.GetValue(__instance); Transform rightIKTarget = (Transform)((obj is Transform) ? obj : null); ItemBehaviour component = val.GetComponent<ItemBehaviour>(); __instance.SetRightIKTarget(rightIKTarget); __instance.SetLeftIKTarget(((Object)(object)component != (Object)null) ? component.gripLeft : null); object obj2 = _fiRigBuilder?.GetValue(__instance); obj2?.GetType().GetMethod("Build", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(obj2, null); return false; } catch { return true; } } public static bool PlayerPickup_RightHandPickup_Prefix() { return !GunGamePlugin.Enabled.Value; } public static bool PlayerPickup_SwitchWeapons_Prefix() { return !GunGamePlugin.Enabled.Value; } public static bool PlayerPickup_LeftHandPickup_Prefix() { return !GunGamePlugin.Enabled.Value; } public static bool PlayerPickup_RpcLogic_DropObjectServer_Prefix(PlayerPickup __instance, GameObject obj, bool rightHand) { if (!GunGamePlugin.Enabled.Value) { return true; } if (!InstanceFinder.NetworkManager.IsServer) { return true; } string droppedName = (((Object)(object)obj != (Object)null) ? ((Object)obj).name.Replace("(Clone)", "").Trim() : ""); bool flag = IsPlaceableDrop(droppedName); bool flag2 = IsThrowableDrop(droppedName); try { PlayerValues playerValues = __instance.playerValues; int num = ((playerValues != null) ? playerValues.sync___get_value_playerClient() : null)?.PlayerId ?? (-1); int weaponIndex = ((num >= 0) ? GetCurrentWeaponIndex(num) : 0); bool rightHand2; bool num2 = TryGetHeldObjectHand(__instance, obj, out rightHand2); if ((flag || flag2) && (Object)(object)obj != (Object)null) { obj.transform.SetParent((Transform)null); } if (!num2) { return true; } if (num >= 0 && GunGameWeaponManager.IsDropProtected(num) && IsProtectedHeldDrop(__instance, obj, rightHand2)) { return false; } object obj2 = ((object)GameManager.Instance) ?? ((object)GunGamePlugin.Instance); if (obj2 != null) { ((MonoBehaviour)obj2).StartCoroutine(DeferredDropCleanup(__instance, obj, flag, flag2, num, weaponIndex, rightHand2)); } } catch { } return false; } private static bool TryGetHeldObjectHand(PlayerPickup pickup, GameObject obj, out bool rightHand) { rightHand = true; if ((Object)(object)pickup == (Object)null || (Object)(object)obj == (Object)null) { return false; } if ((Object)(object)pickup.sync___get_value_objInHand() == (Object)(object)obj) { return true; } if (pickup.sync___get_value_hasObjectInLeftHand() && (Object)(object)pickup.sync___get_value_objInLeftHand() == (Object)(object)obj) { rightHand = false; return true; } return false; } private static bool IsPlaceableDrop(string droppedName) { switch (droppedName) { default: return droppedName == "tptrap"; case "Claymore": case "ProximityMine": case "APMine": case "Teleport Mine": case "TPTrap": return true; } } private static bool IsThrowableDrop(string droppedName) { switch (droppedName) { default: return droppedName == "repulsiongrenade"; case "HandGrenade": case "GlandGrenade": case "Repulsion Grenade": case "RepulsionGrenade": case "RepulsorGrenadeMerged": case "KBGrenade": return true; } } private static bool IsProtectedHeldDrop(PlayerPickup pickup, GameObject obj, bool rightHand) { if ((Object)(object)pickup == (Object)null || (Object)(object)obj == (Object)null) { return false; } if ((Object)(object)(rightHand ? pickup.sync___get_value_objInHand() : (pickup.sync___get_value_hasObjectInLeftHand() ? pickup.sync___get_value_objInLeftHand() : null)) != (Object)(object)obj) { return false; } Weapon component = obj.GetComponent<Weapon>(); if ((Object)(object)component == (Object)null) { return false; } try { return component.sync___get_value_currentAmmo() > 0; } catch { return false; } } [IteratorStateMachine(typeof(<DeferredDropCleanup>d__59))] private static IEnumerator DeferredDropCleanup(PlayerPickup pickup, GameObject obj, bool isPlaceable, bool isThrowable, int playerId, int weaponIndex, bool rightHand) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DeferredDropCleanup>d__59(0) { pickup = pickup, obj = obj, isPlaceable = isPlaceable, isThrowable = isThrowable, playerId = playerId, weaponIndex = weaponIndex, rightHand = rightHand }; } [IteratorStateMachine(typeof(<DelayedKillWeaponGive>d__60))] private static IEnumerator DelayedKillWeaponGive(int killerId, int weaponIndex) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedKillWeaponGive>d__60(0) { killerId = killerId, weaponIndex = weaponIndex }; } [IteratorStateMachine(typeof(<DelayedInitialSpawnFallback>d__61))] private static IEnumerator DelayedInitialSpawnFallback(int playerId) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedInitialSpawnFallback>d__61(0) { playerId = playerId }; } [IteratorStateMachine(typeof(<DelayedRespawnWeaponFallback>d__62))] private static IEnumerator DelayedRespawnWeaponFallback(int playerId) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedRespawnWeaponFallback>d__62(0) { playerId = playerId }; } [IteratorStateMachine(typeof(<EnsurePlaceableReplaced>d__63))] private static IEnumerator EnsurePlaceableReplaced(int playerId, bool rightHand) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <EnsurePlaceableReplaced>d__63(0) { playerId = playerId, rightHand = rightHand }; } private static string GetHandReplaceKey(int playerId, bool rightHand) { return playerId + (rightHand ? ":R" : ":L"); } private static bool IsHandEmpty(PlayerPickup pickup, bool rightHand) { if ((Object)(object)pickup == (Object)null) { return false; } if (!rightHand) { return !pickup.sync___get_value_hasObjectInLeftHand(); } return !pickup.sync___get_value_hasObjectInHand(); } public static bool RoundManager_CmdEndRound_Prefix(int winningTeamId) { if (!GunGamePlugin.MatchOver) { return false; } return true; } [IteratorStateMachine(typeof(<WinSequenceCoroutine>d__67))] private static IEnumerator WinSequenceCoroutine(int winnerPlayerId) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WinSequenceCoroutine>d__67(0) { winnerPlayerId = winnerPlayerId }; } private static Type GetParticleSystemType() { if (_particleSystemType != null) { return _particleSystemType; } Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type type = assemblies[i].GetType("UnityEngine.ParticleSystem"); if (type != null) { _particleSystemType = type; break; } } return _particleSystemType; } private static void CleanupBloodAndHats() { try { Type particleSystemType = GetParticleSystemType(); if (particleSystemType != null) { Object[] array = Object.FindObjectsOfType(particleSystemType, true); foreach (Object val in array) { try { Component val2 = (Component)(object)((val is Component) ? val : null); if ((Object)(object)val2 != (Object)null && (Object)(object)val2.transform.parent == (Object)null) { Object.Destroy((Object)(object)val2.gameObject); } } catch { } } } HatPosition[] array2 = Object.FindObjectsOfType<HatPosition>(true); foreach (HatPosition val3 in array2) { try { if ((Object)(object)((Component)val3).transform.parent == (Object)null) { Object.Destroy((Object)(object)((Component)val3).gameObject); } } catch { } } } catch { } } internal static void CleanupWorldEffects() { try { foreach (KeyValuePair<int, GameObject> playerRagdoll in _playerRagdolls) { try { if ((Object)(object)playerRagdoll.Value != (Object)null) { Object.Destroy((Object)(object)playerRagdoll.Value); } } catch { } } _playerRagdolls.Clear(); RagdollDress[] array = Object.FindObjectsOfType<RagdollDress>(true); foreach (RagdollDress val in array) { try { Object.Destroy((Object)(object)((Component)val).gameObject); } catch { } } } catch { } CleanupBloodAndHats(); } [IteratorStateMachine(typeof(<SinglePlayerRespawnCoroutine>d__72))] private static IEnumerator SinglePlayerRespawnCoroutine(int deadPlayerId) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SinglePlayerRespawnCoroutine>d__72(0) { deadPlayerId = deadPlayerId }; } private static bool TryInvokeRespawn(PlayerManager pm, int playerId, int attempt) { if (_miCmdRespawn == null || (Object)(object)pm == (Object)null) { return false; } try { _waitingForSetStartTime.Add(playerId); _miCmdRespawn.Invoke(pm, BuildDefaultArgs(_miCmdRespawn)); if ((Object)(object)GameManager.Instance != (Object)null) { GameManager.Instance.SetStartTime(0f); } GameManager instance = GameManager.Instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(KeepPlayerMovable(pm, 4f)); } LogRespawn(playerId, attempt, "respawn invoked"); return true; } catch (Exception ex) { LogRespawn(playerId, attempt, "respawn invoke failed: " + ex.GetType().Name); return false; } } private static bool IsPlayerRespawnValid(int playerId, PlayerManager pm, out string reason) { reason = ""; if ((Object)(object)pm == (Object)null) { reason = "missing PlayerManager"; return false; } if ((Object)(object)pm.player == (Object)null) { reason = "missing player controller"; return false; } GameObject gameObject = ((Component)pm.player).gameObject; if ((Object)(object)gameObject == (Object)null || !gameObject.activeInHierarchy) { reason = "inactive player object"; return false; } PlayerValues component = gameObject.GetComponent<PlayerValues>(); if (((component == null) ? null : component.sync___get_value_playerClient()?.PlayerId).GetValueOrDefault(-1) != playerId) { reason = "player id mismatch"; return false; } PlayerHealth component2 = gameObject.GetComponent<PlayerHealth>(); if ((Object)(object)component2 == (Object)null) { reason = "missing PlayerHealth"; return false; } if (component2.sync___get_value_health() <= 0f || component2.sync___get_value_isKilled()) { reason = "still dead"; return false; } if ((Object)(object)gameObject.GetComponentInChildren<PlayerPickup>(true) == (Object)null) { reason = "missing PlayerPickup"; return false; } try { pm.SetPlayerMove(true); pm.player.sync___set_value_canMove(true, true); pm.player.startOfRound = false; if ((Object)(object)PauseManager.Instance != (Object)null) { PauseManager.Instance.startRound = false; } } catch { reason = "could not force movement"; return false; } return true; } private static void CleanupRespawnArtifacts(int playerId) { try { if (_playerRagdolls.TryGetValue(playerId, out var value) && (Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); } _playerRagdolls.Remove(playerId); CleanupBloodAndHats(); } catch { } } private static void CleanupSpawnedObjectForPlayer(PlayerManager pm, int playerId) { try { object? obj = _fiSpawnedObject?.GetValue(pm); GameObject val = (GameObject)((obj is GameObject) ? obj : null); if ((Object)(object)val == (Object)null) { return; } PlayerValues obj2 = val.GetComponent<PlayerValues>() ?? val.GetComponentInChildren<PlayerValues>(true); if (((obj2 == null) ? null : obj2.sync___get_value_playerClient()?.PlayerId).GetValueOrDefault(playerId) == playerId) { try { _miUnsubscribeFromInput?.Invoke(pm, null); } catch { } NetworkObject component = val.GetComponent<NetworkObject>(); if ((Object)(object)InstanceFinder.NetworkManager != (Object)null && InstanceFinder.NetworkManager.IsServer && (Object)(object)component != (Object)null && component.IsSpawned) { InstanceFinder.ServerManager.Despawn(component, (DespawnType?)null); } else { Object.Destroy((Object)(object)val); } } } catch { } } private static void LogRespawn(int playerId, int attempt, string message) { try { ManualLogSource log = GunGamePlugin.Log; if (log != null) { log.LogInfo((object)$"[GunGame Respawn] player={playerId} attempt={attempt}: {message}"); } } catch { } } [IteratorStateMachine(typeof(<KeepPlayerMovable>d__78))] private static IEnumerator KeepPlayerMovable(PlayerManager pm, float duration) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <KeepPlayerMovable>d__78(0) { pm = pm, duration = duration }; } private static object[] BuildDefaultArgs(MethodInfo mi) { if (mi == null) { return null; } ParameterInfo[] parameters = mi.GetParameters(); if (parameters.Length == 0) { return null; } object[] array = new object[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { array[i] = (parameters[i].ParameterType.IsValueType ? Activator.CreateInstance(parameters[i].ParameterType) : null); } return array; } private static int FindKillerId(int deadPlayerId) { PlayerHealth val = FindPlayerHealth(deadPlayerId); if ((Object)(object)val == (Object)null) { return -1; } Transform killer = val.killer; if ((Object)(object)killer == (Object)null) { return -1; } ClientInstance componentInParent = ((Component)killer).GetComponentInParent<ClientInstance>(true); if ((Object)(object)componentInParent != (Object)null) { return componentInParent.PlayerId; } PlayerValues obj = ((Component)killer).GetComponentInParent<PlayerValues>(true) ?? ((Component)killer).GetComponentInChildren<PlayerValues>(true); int? num = ((obj == null) ? null : obj.sync___get_value_playerClient()?.PlayerId); if (num.HasValue) { int valueOrDefault = num.GetValueOrDefault(); if (valueOrDefault >= 0) { return valueOrDefault; } } GameObject val2 = null; ProximityMine val3 = ((Component)killer).GetComponentInParent<ProximityMine>(true) ?? ((Component)killer).GetComponentInChildren<ProximityMine>(true); if ((Object)(object)val3 != (Object)null) { val2 = val3.sync___get_value__rootObject(); } else { Claymore val4 = ((Component)killer).GetComponentInParent<Claymore>(true) ?? ((Component)killer).GetComponentInChildren<Claymore>(true); if ((Object)(object)val4 != (Object)null) { val2 = val4.sync___get_value__rootObject(); } } if ((Object)(object)val2 != (Object)null) { int ownerIdFromRootObject = GetOwnerIdFromRootObject(val2); if (ownerIdFromRootObject >= 0) { return ownerIdFromRootObject; } } return -1; } public static bool DamageZone_OnEnable_Prefix(DamageZone __instance) { if (!GunGamePlugin.Enabled.Value) { return true; } try { Collider[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } if ((Object)(object)__instance.toDestroy != (Object)null) { Object.Destroy((Object)(object)__instance.toDestroy); } Object.Destroy((Object)(object)((Component)__instance).gameObject); } catch { } return false; } public static bool FirstPersonController_OnTriggerStay_Prefix(Collider col) { if (GunGamePlugin.Enabled.Value && ((Component)col).CompareTag("DamageZone")) { return false; } return true; } public static void PlayerHealth_ExplodeForAll_Postfix(PlayerHealth __instance) { //IL_0074: 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) if (!GunGamePlugin.Enabled.Value) { return; } try { PlayerValues playerValues = __instance.playerValues; int valueOrDefault = ((playerValues == null) ? null : playerValues.sync___get_value_playerClient()?.PlayerId).GetValueOrDefault(-1); if (valueOrDefault < 0) { return; } RagdollDress val = null; float num = float.MaxValue; RagdollDress[] array = Object.FindObjectsOfType<RagdollDress>(true); foreach (RagdollDress val2 in array) { float num2 = Vector3.Distance(((Component)val2).transform.position, ((Component)__instance).transform.position); if (num2 < num) { num = num2; val = val2; } } if ((Object)(object)val != (Object)null) { _playerRagdolls[valueOrDefault] = ((Component)val).gameObject; } } catch { } } public static void PlayerValues_SetPlayerClient_Postfix(ClientInstance __0) { if (!GunGamePlugin.Enabled.Value || (Object)(object)__0 == (Object)null) { return; } try { int playerId = __0.PlayerId; if (playerId >= 0) { if (_playerRagdolls.TryGetValue(playerId, out var value) && (Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); _playerRagdolls.Remove(playerId); } CleanupBloodAndHats(); } } catch { } } private static PlayerHealth FindPlayerHealth(int deadPlayerId) { PlayerHealth[] array = Object.FindObjectsOfType<PlayerHealth>(true); foreach (PlayerHealth val in array) { if (val != null) { PlayerValues playerValues = val.playerValues; if (((playerValues == null) ? null : playerValues.sync___get_value_playerClient()?.PlayerId) == deadPlayerId) { return val; } } } return null; } private static PlayerManager FindPlayerManagerForId(int playerId) { if (ClientInstance.playerInstances.TryGetValue(playerId, out var value) && (Object)(object)value != (Object)null) { return ((Component)value).GetComponent<PlayerManager>(); } return null; } public static bool PauseManager_StartRoundDelay_Prefix(PauseManager __instance) { if (!GunGamePlugin.Enabled.Value) { return true; } try { __instance.InvokeRoundStarted(); __instance.onStartRoundScreen = true; MonoBehaviour val = (MonoBehaviour)(((object)GunGamePlugin.Instance) ?? ((object)GameManager.Instance)); if ((Object)(object)val != (Object)null) { val.StartCoroutine(ClearOnStartRoundScreen(__instance)); } } catch { } return false; } [IteratorStateMachine(typeof(<ClearOnStartRoundScreen>d__88))] private static IEnumerator ClearOnStartRoundScreen(PauseManager pm) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ClearOnStartRoundScreen>d__88(0) { pm = pm }; } public static bool ProximityMine_KillShockWave_Prefix(ProximityMine __instance) { GameObject val = __instance.sync___get_value__rootObject(); if ((Object)(object)val == (Object)null) { return false; } if ((Object)(object)val.GetComponent<FirstPersonController>() == (Object)null) { return false; } return true; } public static bool Claymore_KillShockWave_Prefix(Claymore __instance) { GameObject val = __instance.sync___get_value__rootObject(); if ((Object)(object)val == (Object)null) { return false; } if ((Object)(object)val.GetComponent<FirstPersonController>() == (Object)null) { return false; } return true; } public static void Minigun_Update_Postfix(Minigun __instance) { if (!GunGamePlugin.Enabled.Value || (Object)(object)__instance == (Object)null) { return; } try { if ((Object)(object)__instance == (Object)null || ((Weapon)__instance).sync___get_value_currentAmmo() > 0) { if ((Object)(object)__instance != (Object)null) { _minigunDropQueued.Remove(((Object)__instance).GetInstanceID()); } return; } object obj = ((Weapon)__instance).behaviour?.playerPickup; if (obj == null) { GameObject rootObject = ((Weapon)__instance).rootObject; obj = ((rootObject != null) ? rootObject.GetComponent<PlayerPickup>() : null); } PlayerPickup val = (PlayerPickup)obj; if ((Object)(object)val == (Object)null || !TryGetHeldObjectHand(val, ((Component)__instance).gameObject, out var rightHand)) { return; } int instanceID = ((Object)__instance).GetInstanceID(); if (_minigunDropQueued.Add(instanceID)) { if (rightHand) { val.RightHandDrop(); } else { val.LeftHandDrop(); } } } catch { } } public static bool DualLauncher_SetBool_Prefix(DualLauncher __instance, bool value) { if (!GunGamePlugin.Enabled.Value || (Object)(object)__instance == (Object)null || !value) { return true; } try { object obj = ((Weapon)(__instance?)).behaviour?.playerPickup; if (obj == null) { if (__instance == null) { obj = null; } else { GameObject rootObject = ((Weapon)__instance).rootObject; obj = ((rootObject != null) ? rootObject.GetComponent<PlayerPickup>() : null); } } PlayerPickup val = (PlayerPickup)obj; if ((Object)(object)__instance == (Object)null || (Object)(object)val == (Object)null) { return true; } if (!TryGetHeldObjectHand(val, ((Component)__instance).gameObject, out var rightHand)) { return true; } PlayerValues playerValues = val.playerValues; int valueOrDefault = ((playerValues == null) ? null : playerValues.sync___get_value_playerClient()?.PlayerId).GetValueOrDefault(-1); if (valueOrDefault < 0) { return true; } string handReplaceKey = GetHandReplaceKey(valueOrDefault, rightHand); if (_suppressThrowableOpenUntil.TryGetValue(handReplaceKey, out var value2) && Time.unscaledTime <= value2) { return false; } } catch { } return true; } public static void WeaponHandSpawner_SpawnObject_Postfix(WeaponHandSpawner __instance) { if (!GunGamePlugin.Enabled.Value || (Object)(object)__instance == (Object)null) { return; } try { object obj = ((Weapon)(__instance?)).behaviour?.playerPickup; if (obj == null) { if (__instance == null) { obj = null; } else { GameObject rootObject = ((Weapon)__instance).rootObject; obj = ((rootObject != null) ? rootObject.GetComponent<PlayerPickup>() : null); } } PlayerPickup val = (PlayerPickup)obj; if (!((Object)(object)__instance == (Object)null) && !((Object)(object)val == (Object)null) && TryGetHeldObjectHand(val, ((Component)__instance).gameObject, out var rightHand) && IsThrowableHeldWeapon((!rightHand) ? val.sync___get_value_objInHand() : (val.sync___get_value_hasObjectInLeftHand() ? val.sync___get_value_objInLeftHand() : null))) { PlayerValues playerValues = val.playerValues; int valueOrDefault = ((playerValues == null) ? null : playerValues.sync___get_value_playerClient()?.PlayerId).GetValueOrDefault(-1); if (valueOrDefault >= 0) { _suppressThrowableOpenUntil[GetHandReplaceKey(valueOrDefault, !rightHand)] = Time.unscaledTime + 0.35f; } } } catch { } } private static bool IsThrowableHeldWeapon(GameObject obj) { if ((Object)(object)obj == (Object)null) { return false; } if (!IsThrowableDrop(((Object)obj).name?.Replace("(Clone)", "").Trim() ?? "")) { return (Object)(object)obj.GetComponent<DualLauncher>() != (Object)null; } return true; } public static bool MatchLogs_RpcSendChatLine_Prefix() { return !GunGamePlugin.Enabled.Value; } private static int GetOwnerIdFromRootObject(GameObject root) { if ((Object)(object)root == (Object)null) { return -1; } ClientInstance val = root.GetComponentInParent<ClientInstance>(true) ?? root.GetComponentInChildren<ClientInstance>(true); if ((Object)(object)val != (Object)null) { return val.PlayerId; } PlayerValues obj = root.GetComponentInParent<PlayerValues>(true) ?? root.GetComponentInChildren<PlayerValues>(true); int valueOrDefault = ((obj == null) ? null : obj.sync___get_value_playerClient()?.PlayerId).GetValueOrDefault(-1); if (valueOrDefault >= 0) { return valueOrDefault; } foreach (KeyValuePair<int, ClientInstance> playerInstance in ClientInstance.playerInstances) { try { ClientInstance value = playerInstance.Value; PlayerManager val2 = ((value != null) ? ((Component)value).GetComponent<PlayerManager>() : null); if (!((Object)(object)val2 == (Object)null)) { if ((Object)(object)val2.player != (Object)null && ((Object)(object)((Component)val2.player).gameObject == (Object)(object)root || root.transform.IsChildOf(((Component)val2.player).transform))) { return playerInstance.Key; } object? obj2 = _fiSpawnedObject?.GetValue(val2); GameObject val3 = (GameObject)((obj2 is GameObject) ? obj2 : null); if ((Object)(object)val3 != (Object)null && ((Object)(object)val3 == (Object)(object)root || root.transform.IsChildOf(val3.transform))) { return playerInstance.Key; } } } catch { } } return -1; } private static void ClearPlacedExplosivesForPlayer(int playerId) { try { ProximityMine[] array = Object.FindObjectsOfType<ProximityMine>(true); foreach (ProximityMine val in array) { try { if (GetOwnerIdFromRootObject(val.sync___get_value__rootObject()) == playerId) { NetworkObject component = ((Component)val).GetComponent<NetworkObject>(); if ((Object)(object)component != (Object)null && component.IsSpawned) { InstanceFinder.ServerManager.Despawn(component, (DespawnType?)null); } else { Object.Destroy((Object)(object)((Component)val).gameObject); } } } catch { } } Claymore[] array2 = Object.FindObjectsOfType<Claymore>(true); foreach (Claymore val2 in array2) { try { if (GetOwnerIdFromRootObject(val2.sync___get_value__rootObject()) == playerId) { NetworkObject component2 = ((Component)val2).GetComponent<NetworkObject>(); if ((Object)(object)component2 != (Object)null && component2.IsSpawned) { InstanceFinder.ServerManager.Despawn(component2, (DespawnType?)null); } else { Object.Destroy((Object)(object)((Component)val2).gameObject); } } } catch { } } } catch { } } internal static void BroadcastChat(string text) { if ((Object)(object)MatchLogs.Instance == (Object)null || (Object)(object)InstanceFinder.NetworkManager == (Object)null || !InstanceFinder.NetworkManager.IsServer) { return; } try { _miMatchLogsSendToAll?.Invoke(MatchLogs.Instance, new object[1] { text }); } catch { } } private static string GetPlayerName(int playerId) { try { if (ClientInstance.playerInstances.TryGetValue(playerId, out var value) && (Object)(object)value != (Object)null) { return value.PlayerNameTag; } } catch { } return $"Player {playerId}"; } private static int GetPlayerTeam(int playerId) { if ((Object)(object)ScoreManager.Instance != (Object)null) { try { return ScoreManager.Instance.GetTeamId(playerId); } catch { } } return playerId; } } public static class GunGameWeaponManager { [CompilerGenerated] private sealed class <GiveWeaponCoroutine>d__24 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public int playerId; public int weaponIndex; public int seq; private NetworkManager <nm>5__2; private PlayerPickup <pickup>5__3; private GameObject <heldRight>5__4; private GameObject <heldLeft>5__5; private GameObject <playerGO>5__6; private GameObject <secondPrefab>5__7; private GameObject <rightWeapon>5__8; private GameObject <leftWeapon>5__9; private ItemBehaviour <rightIb>5__10; private ItemBehaviour <leftIb>5__11; private int <attempt>5__12; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <GiveWeaponCoroutine>d__24(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <nm>5__2 = null; <pickup>5__3 = null; <heldRight>5__4 = null; <heldLeft>5__5 = null; <playerGO>5__6 = null; <secondPrefab>5__7 = null; <rightWeapon>5__8 = null; <leftWeapon>5__9 = null; <rightIb>5__10 = null; <leftIb>5__11 = null; <>1__state = -2; } private bool MoveNext() { //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Expected O, but got Unknown //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Expected O, but got Unknown //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: { <>1__state = -1; <nm>5__2 = InstanceFinder.NetworkManager; if ((Object)(object)<nm>5__2 == (Object)null || !<nm>5__2.IsServer) { return false; } _givingInProgress.Add(playerId); bool flag = false; try { if ((Object)(object)GunGamePlugin.GetOrderedWeaponPrefab(weaponIndex) == (Object)null) { flag = true; } } finally { if (flag) { _givingInProgress.Remove(playerId); } } if (flag) { return false; } float num = (_initialSpawnDelayDone ? 0f : 2f); _initialSpawnDelayDone = true; <>2__current = (object)new WaitForSeconds(num); <>1__state = 1; return true; } case 1: { <>1__state = -1; if (GunGamePlugin.MatchOver) { _givingInProgress.Remove(playerId); return false; } if (_giveSequence.TryGetValue(playerId, out var value4) && value4 != seq) { _givingInProgress.Remove(playerId); return false; } <pickup>5__3 = null; <attempt>5__12 = 0; goto IL_0180; } case 2: <>1__state = -1; <attempt>5__12++; goto IL_0180; case 3: <>1__state = -1; <pickup>5__3 = GunGamePlugin.FindPickupForPlayerId(playerId); if ((Object)(object)<pickup>5__3 == (Object)null) { _givingInProgress.Remove(playerId); return false; } goto IL_024a; case 4: { <>1__state = -1; if (_giveSequence.TryGetValue(playerId, out var value2) && value2 != seq) { _givingInProgress.Remove(playerId); return false; } GameObject[] array = (GameObject[])(object)new GameObject[2] { <heldRight>5__4, <heldLeft>5__5 }; foreach (GameObject val in array) { if ((Object)(object)val == (Object)null) { continue; } NetworkObject componentInParent = val.GetComponentInParent<NetworkObject>(); if ((Object)(object)componentInParent != (Object)null) { try { InstanceFinder.ServerManager.Despawn(componentInParent, (DespawnType?)null); } catch { } } else { try { Object.Destroy((Object)(object)val); } catch { } } } try { <pickup>5__3 = GunGamePlugin.FindPickupForPlayerId(playerId); if ((Object)(object)<pickup>5__3 != (Object)null) { ItemBehaviour[] componentsInChildren = ((Component)((Component)<pickup>5__3).transform.root).GetComponentsInChildren<ItemBehaviour>(true); foreach (ItemBehaviour val2 in componentsInChildren) { if ((Object)(object)val2 == (Object)null) { continue; } NetworkObject component = ((Component)val2).GetComponent<NetworkObject>(); if ((Object)(object)component != (Object)null && component.IsSpawned) { try { InstanceFinder.ServerManager.Despawn(component, (DespawnType?)null); } catch { } } else { try { Object.Destroy((Object)(object)((Component)val2).gameObject); } catch { } } } } } catch { } <>2__current = (object)new WaitForSeconds(0.15f); <>1__state = 5; return true; } case 5: { <>1__state = -1; <pickup>5__3 = GunGamePlugin.FindPickupForPlayerId(playerId); if ((Object)(object)<pickup>5__3 == (Object)null) { _givingInProgress.Remove(playerId); return false; } <playerGO>5__6 = null; try { if (ClientInstance.playerInstances.TryGetValue(playerId, out var value3)) { PlayerManager val3 = ((value3 != null) ? ((Component)value3).GetComponent<PlayerManager>() : null); object obj6; if (val3 == null) { obj6 = null; } else { FirstPersonController player = val3.player; obj6 = ((player != null) ? ((Component)player).gameObject : null); } <playerGO>5__6 = (GameObject)obj6; } } catch { } if ((Object)(object)<playerGO>5__6 == (Object)null) { <playerGO>5__6 = ((Component)((Component)<pickup>5__3).transform.root).gameObject; } GameObject orderedWeaponPrefab = GunGamePlugin.GetOrderedWeaponPrefab(weaponIndex); <secondPrefab>5__7 = GunGamePlugin.GetSecondWeaponPrefab(weaponIndex); <rightWeapon>5__8 = null; <leftWeapon>5__9 = null; <rightIb>5__10 = null; <leftIb>5__11 = null; try { <rightWeapon>5__8 = SpawnWeaponPrefab(<nm>5__2, orderedWeaponPrefab, <playerGO>5__6, out <rightIb>5__10); if ((Object)(object)<secondPrefab>5__7 != (Object)null) { <leftWeapon>5__9 = SpawnWeaponPrefab(<nm>5__2, <secondPrefab>5__7, <playerGO>5__6, out <leftIb>5__11); } } catch (Exception) { DespawnOrDestroy(<rightWeapon>5__8); DespawnOrDestroy(<leftWeapon>5__9); _givingInProgress.Remove(playerId); return false; } <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 6; return true; } case 6: { <>1__state = -1; if ((Object)(object)<rightWeapon>5__8 == (Object)null || ((Object)(object)<secondPrefab>5__7 != (Object)null && (Object)(object)<leftWeapon>5__9 == (Object)null) || (Object)(object)<pickup>5__3 == (Object)null) { DespawnOrDestroy(<rightWeapon>5__8); DespawnOrDestroy(<leftWeapon>5__9); _givingInProgress.Remove(playerId); return false; } CacheMethods(); AssignWeaponToHand(<pickup>5__3, <rightWeapon>5__8, <rightIb>5__10, <playerGO>5__6, rightHand: true); if ((Object)(object)<secondPrefab>5__7 != (Object)null) { AssignWeaponToHand(<pickup>5__3, <leftWeapon>5__9, <leftIb>5__11, <playerGO>5__6, rightHand: false); } ProtectRecentGrant(playerId); _givingInProgress.Remove(playerId); return false; } IL_024a: if (HasUnplacedTeleportMine(<pickup>5__3)) { if (GunGamePlugin.MatchOver) { _givingInProgress.Remove(playerId); return false; } if (_giveSequence.TryGetValue(playerId, out var value) && value != seq) { _givingInProgress.Remove(playerId); return false; } <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 3; return true; } <heldRight>5__4 = <pickup>5__3.sync___get_value_objInHand(); <heldLeft>5__5 = (<pickup>5__3.sync___get_value_hasObjectInLeftHand() ? <pickup>5__3.sync___get_value_objInLeftHand() : null); <pickup>5__3.sync___set_value_hasObjectInHand(false, true); <pickup>5__3.sync___set_value_hasObjectInLeftHand(false, true); <pickup>5__3.sync___set_value_objInHand((GameObject)null, true); <pickup>5__3.sync___set_value_objInLeftHand((GameObject)null, true); <>2__current = (object)new WaitForSeconds(0.3f); <>1__state = 4; return true; IL_0180: if (<attempt>5__12 < 8) { <pickup>5__3 = GunGamePlugin.FindPickupForPlayerId(playerId); if (!((Object)(object)<pickup>5__3 != (Object)null)) { <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 2; return true; } } if ((Object)(object)<pickup>5__3 == (Object)null) { _givingInProgress.Remove(playerId); return false; } goto IL_024a; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <ReplaceWeaponInHandCoroutine>d__25 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public bool rightHand; public int weaponIndex; public int playerId; private NetworkManager <nm>5__2; private GameObject <prefab>5__3; private string <handKey>5__4; private PlayerPickup <pickup>5__5; private GameObject <playerGO>5__6; private GameObject <weapon>5__7; private ItemBehaviour <ib>5__8; private int <attempt>5__9; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ReplaceWeaponInHandCoroutine>d__25(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 3u) { try { } finally { <>m__Finally1(); } } <nm>5__2 = null; <prefab>5__3 = null; <handKey>5__4 = null; <pickup>5__5 = null; <playerGO>5__6 = null; <weapon>5__7 = null; <ib>5__8 = null; <>1__state = -2; } private bool MoveNext() { //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Expected O, but got Unknown //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Expected O, but got Unknown bool result; try { switch (<>1__state) { default: result = false; goto end_IL_0000; case 0: <>1__state = -1; <nm>5__2 = InstanceFinder.NetworkManager; if ((Object)(object)<nm>5__2 == (Object)null || !<nm>5__2.IsServer) { result = false; } else { <prefab>5__3 = (rightHand ? GunGamePlugin.GetOrderedWeaponPrefab(weaponIndex) : GunGamePlugin.GetSecondWeaponPrefab(weaponIndex)); if ((Object)(object)<prefab>5__3 == (Object)null) { result = false; } else { <handKey>5__4 = GetHandGiveKey(playerId, rightHand); if (_handGivingInProgress.Add(<handKey>5__4)) { <>1__state = -3; <pickup>5__5 = null; <attempt>5__9 = 0; goto IL_0134; } result = false; } } goto end_IL_0000; case 1: <>1__state = -3; <attempt>5__9++; goto IL_0134; case 2: <>1__state = -3; <pickup>5__5 = GunGamePlugin.FindPickupForPlayerId(playerId); if ((Object)(object)<pickup>5__5 == (Object)null) { result = false; break; } goto IL_01ac; case 3: <>1__state = -3; <pickup>5__5 = GunGamePlugin.FindPickupForPlayerId(playerId); if ((Object)(object)<pickup>5__5 == (Object)null) { result = false; break; } <playerGO>5__6 = null; try { if (ClientInstance.playerInstances.TryGetValue(playerId, out var value)) { PlayerManager val = ((value != null) ? ((Component)value).GetComponent<PlayerManager>() : null); object obj; if (val == null) { obj = null; } else { FirstPersonController player = val.player; obj = ((player != null) ? ((Component)player).gameObject : null); } <playerGO>5__6 = (GameObject)obj; } } catch { } if ((Object)(object)<playerGO>5__6 == (Object)null) { <playerGO>5__6 = ((Component)((Component)<pickup>5__5).transform.root).gameObject; } <weapon>5__7 = null; <ib>5__8 = null; try { <weapon>5__7 = SpawnWeaponPrefab(<nm>5__2, <prefab>5__3, <playerGO>5__6, out <ib>5__8); } catch { DespawnOrDestroy(<weapon>5__7); result = false; break; } <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 4; result = true; goto end_IL_0000; case 4: { <>1__state = -3; if ((Object)(object)<weapon>5__7 == (Object)null) { result = false; break; } CacheMethods(); AssignWeaponToHand(<pickup>5__5, <weapon>5__7, <ib>5__8, <playerGO>5__6, rightHand); ProtectRecentGrant(playerId); <pickup>5__5 = null; <playerGO>5__6 = null; <weapon>5__7 = null; <ib>5__8 = null; <>m__Finally1(); result = false; goto end_IL_0000; } IL_013d: if ((Object)(object)<pickup>5__5 == (Object)null) { result = false; break; } goto IL_01ac; IL_0134: if (<attempt>5__9 >= 8) { goto IL_013d; } <pickup>5__5 = GunGamePlugin.FindPickupForPlayerId(playerId); if ((Object)(object)<pickup>5__5 != (Object)null) { goto IL_013d; } <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; result = true; goto end_IL_0000; IL_01ac: if (HasUnplacedTeleportMineInHand(<pickup>5__5, rightHand)) { if (GunGamePlugin.MatchOver) { result = false; break; } <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 2; result = true; } else { GameObject weapon = (rightHand ? <pickup>5__5.sync___get_value_objInHand() : (<pickup>5__5.sync___get_value_hasObjectInLeftHand() ? <pickup>5__5.sync___get_value_objInLeftHand() : null)); if (rightHand) { <pickup>5__5.sync___set_value_hasObjectInHand(false, true); <pickup>5__5.sync___set_value_objInHand((GameObject)null, true); } else { <pickup>5__5.sync___set_value_hasObjectInLeftHand(false, true); <pickup>5__5.sync___set_value_objInLeftHand((GameObject)null, true); } DespawnOrDestroy(weapon); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 3; result = true; } goto end_IL_0000; } <>m__Finally1(); end_IL_0000:; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; _handGivingInProgress.Remove(<handKey>5__4); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static Dictionary<int, int> _pendingWeaponIndex = new Dictionary<int, int>(); private static MethodInfo _miSetObjectInHandRpcLogic; private static MethodInfo _miSetObjectInHandObserver; private static MethodInfo _miSetObjectInHandObserverLogic; private static bool _initialSpawnDelayDone = false; private static Dictionary<int, int> _giveSequence = new Dictionary<int, int>(); private static HashSet<int> _givingInProgress = new HashSet<int>(); private static HashSet<string> _handGivingInProgress = new HashSet<string>(); private static Dictionary<int, float> _dropProtectionUntil = new Dictionary<int, float>(); internal static MethodInfo SetObjectInHandObserverLogic { get { CacheMethods(); return _miSetObjectInHandObserverLogic; } } public static void QueueWeaponUpgrade(int playerId, int weaponIndex) { _pendingWeaponIndex[playerId] = weaponIndex; } public static int GetAndClearPendingWeapon(int playerId) { if (_pendingWeaponIndex.TryGetValue(playerId, out var value)) { _pendingWeaponIndex.Remove(playerId); return value; } return -1; } public static bool HasPendingWeapon(int playerId) { return _pendingWeaponIndex.ContainsKey(playerId); } public static void ClearPendingForPlayer(int playerId) { _pendingWeaponIndex.Remove(playerId); _giveSequence.Remove(playerId); _dropProtectionUntil.Remove(playerId); } public static void ClearAllPending() { _pendingWeaponIndex.Clear(); _giveSequence.Clear(); _givingInProgress.Clear(); _handGivingInProgress.Clear(); _dropProtectionUntil.Clear(); _initialSpawnDelayDone = false; } private static void CacheMethods() { if (!(_miSetObjectInHandRpcLogic != null)) { _miSetObjectInHandRpcLogic = typeof(PlayerPickup).GetMethod("RpcLogic___SetObjectInHandServer_46969756", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _miSetObjectInHandObserver = typeof(PlayerPickup).GetMethod("SetObjectInHandObserver", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _miSetObjectInHandObserverLogic = typeof(PlayerPickup).GetMethod("RpcLogic___SetObjectInHandObserver_46969756", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } } public static bool IsGivingWeapon(int playerId) { if (!_givingInProgress.Contains(playerId)) { return IsReplacingAnyHand(playerId); } return true; } public static bool IsGivingWeaponInHand(int playerId, bool rightHand) { if (!_givingInProgress.Contains(playerId)) { return _handGivingInProgress.Contains(GetHandGiveKey(playerId, rightHand)); } return true; } private static bool IsReplacingAnyHand(int playerId) { string value = playerId + ":"; foreach (string item in _handGivingInProgress) { if (item.StartsWith(value, StringComparison.Ordinal)) { return true; } } return false; } private static string GetHandGiveKey(int playerId, bool rightHand) { return playerId + (rightHand ? ":R" : ":L"); } public static int GetGiveSequence(int playerId) { if (!_giveSequence.TryGetValue(playerId, out var value)) { return 0; } return value; } public static void GiveWeaponToPlayer(int playerId, int weaponIndex) { if (!((Object)(object)InstanceFinder.NetworkManager == (Object)null) && InstanceFinder.NetworkManager.IsServer && !GunGam