Decompiled source of PlayerKillCounter v0.0.2

PlayerKillCounter.dll

Decompiled 6 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using PlayerKillCounter.Behaviours;
using PlayerKillCounter.Extensions;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("PlayerKillCounter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PlayerKillCounter")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7B499935-0339-454A-860B-CB0D2650A230")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PlayerKillCounter
{
	public interface ICausedBy
	{
		ulong GetCausingPlayerId();
	}
	[BepInPlugin("PlayerKillCounter", "Player Kill Counter", "0.0.2")]
	public class Mod : BaseUnityPlugin
	{
		private static ManualLogSource _logger;

		public static ManualLogSource Logger => _logger;

		public void Awake()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			_logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Loading harmony...");
			Harmony val = new Harmony(((object)this).GetType().FullName);
			try
			{
				Type[] nestedTypes = typeof(Patches).GetNestedTypes();
				foreach (Type type in nestedTypes)
				{
					if (type.IsClass && type.IsAbstract && type.IsSealed)
					{
						Logger.LogInfo((object)("Patching " + type.Name + "..."));
						val.PatchAll(type);
					}
				}
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Failed to patch: " + ex));
			}
		}
	}
	public static class Patches
	{
		public static class StartOfRoundPatches
		{
			[HarmonyPatch(typeof(StartOfRound), "Start")]
			[HarmonyPrefix]
			public static bool Start_Pre(StartOfRound __instance)
			{
				if ((Object)(object)((Component)__instance).GetComponent<KillCounter>() == (Object)null)
				{
					((Component)__instance).gameObject.AddComponent<KillCounter>();
				}
				if ((Object)(object)((Component)__instance).GetComponent<RPCHandler>() == (Object)null)
				{
					((Component)__instance).gameObject.AddComponent<RPCHandler>();
				}
				return true;
			}

			[HarmonyPatch(typeof(StartOfRound), "Start")]
			[HarmonyPostfix]
			public static void Start_Post(StartOfRound __instance)
			{
				PlayerStats[] allPlayerStats = __instance.gameStats.allPlayerStats;
				for (int i = 0; i < allPlayerStats.Length; i++)
				{
					allPlayerStats[i].playerNotes.Add("THIS IS DUMMY DATA");
				}
			}

			[HarmonyPatch(typeof(StartOfRound), "WritePlayerNotes")]
			[HarmonyPrefix]
			public static bool WritePlayerNotes(StartOfRound __instance)
			{
				KillCounter component = ((Component)StartOfRound.Instance).GetComponent<KillCounter>();
				Mod.Logger.LogInfo((object)$"killedByDict: [{component}]");
				for (int i = 0; i < __instance.gameStats.allPlayerStats.Length; i++)
				{
					ulong playerClientId = __instance.allPlayerScripts[i].playerClientId;
					if (component.ContainsPlayerClientId(playerClientId))
					{
						KillCounter.Info killedBy = component[playerClientId];
						PlayerControllerB val = __instance.allPlayerScripts.First((PlayerControllerB player) => player.playerClientId == killedBy.KillerClientId);
						__instance.gameStats.allPlayerStats[i].playerNotes.Add("Killed by " + (((Object)(object)val != (Object)null) ? val.playerUsername : "[UNKNOWN]") + " via '" + ((object)(CauseOfDeath)(ref killedBy.CauseOfDeath)).ToString() + "'");
					}
				}
				component.Clear();
				return true;
			}
		}

		public static class LandminePatches
		{
			[HarmonyPatch(typeof(Landmine), "Start")]
			[HarmonyPostfix]
			public static void Start(Landmine __instance)
			{
				__instance.LogInfo("Landmine found!");
			}

			[HarmonyPatch(typeof(Landmine), "TriggerOtherMineDelayed")]
			[HarmonyPrefix]
			public static bool TriggerOtherMineDelayed(Landmine __instance, Landmine mine)
			{
				try
				{
					Mod.Logger.LogInfo((object)$"instance: {__instance}, mine: {mine}");
					if (mine.hasExploded)
					{
						return true;
					}
					LandmineTriggeredBy component = ((Component)__instance).GetComponent<LandmineTriggeredBy>();
					if ((Object)(object)component == (Object)null)
					{
						__instance.LogWarning("Landmine was triggered without the LandmineTriggeredBy behaviour being added!");
					}
					LandmineTriggeredBy landmineTriggeredBy = ((Component)mine).gameObject.GetComponent<LandmineTriggeredBy>();
					if ((Object)(object)landmineTriggeredBy == (Object)null)
					{
						mine.LogWarning("No LandmineTriggeredBy behaviour on landmine!");
						landmineTriggeredBy = ((Component)mine).gameObject.AddComponent<LandmineTriggeredBy>();
						mine.LogWarning("Added LandmineTriggeredBy behaviour to landmine!");
					}
					__instance.LogInfo($"Setting clientIdTrigger on Landmine {mine}");
					landmineTriggeredBy.TriggeredByClientId = component.TriggeredByClientId;
				}
				catch (Exception ex)
				{
					__instance.LogError($"Failed to run Landmine 'SpawnExplosion' Prefixes! {ex} {new StackTrace(ex)}");
				}
				return true;
			}

			[HarmonyPatch(typeof(Landmine), "ExplodeMineClientRpc")]
			[HarmonyPrefix]
			public static bool ExplodeMineClientRpc(Landmine __instance)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_012b: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					IEnumerable<PlayerControllerB> killRadiusPlayers = GetKillRadiusPlayers(((Component)__instance).transform.position + Vector3.up);
					__instance.LogInfo("Found [" + GeneralExtensions.Join<PlayerControllerB>(killRadiusPlayers, (Func<PlayerControllerB, string>)((PlayerControllerB o) => o.playerUsername), ", ") + "] players in landmine radius");
					LandmineTriggeredBy landmineTriggeredBy = ((Component)__instance).GetComponent<LandmineTriggeredBy>();
					if ((Object)(object)landmineTriggeredBy == (Object)null)
					{
						__instance.LogWarning("No LandmineTriggeredBy behaviour on landmine!");
						landmineTriggeredBy = ((Component)__instance).gameObject.AddComponent<LandmineTriggeredBy>();
						__instance.LogWarning("Added LandmineTriggeredBy behaviour to landmine!");
					}
					foreach (PlayerControllerB item in killRadiusPlayers)
					{
						__instance.LogInfo($"Player [{landmineTriggeredBy.TriggeredByClientId}] killed [{item.playerClientId}] via Landmine");
						if (item.playerClientId == landmineTriggeredBy.TriggeredByClientId)
						{
							__instance.LogInfo($"Player [{landmineTriggeredBy.TriggeredByClientId}] killed themselves via Landmine, not noteworthy.");
							continue;
						}
						KillCounter component = ((Component)StartOfRound.Instance).GetComponent<KillCounter>();
						if (!component.ContainsPlayerClientId(item.playerClientId))
						{
							component.Add(item.playerClientId, new KillCounter.Info
							{
								KillerClientId = landmineTriggeredBy.TriggeredByClientId,
								CauseOfDeath = (CauseOfDeath)3
							});
						}
					}
				}
				catch (Exception ex)
				{
					__instance.LogError($"Failed to run Landmine 'ExplodeMineClientRpc' Prefixes! {ex} {new StackTrace(ex)}");
				}
				return true;
			}

			[HarmonyPatch(typeof(Landmine), "OnTriggerExit")]
			[HarmonyPrefix]
			public static bool OnTriggerExit(Landmine __instance, Collider other)
			{
				try
				{
					if (__instance.hasExploded)
					{
						return true;
					}
					if (((Component)other).CompareTag("Player"))
					{
						PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
						__instance.LogInfo($"Found Player {component.playerUsername} ({component.playerClientId})!");
						((Component)__instance).gameObject.GetComponent<LandmineTriggeredBy>().TriggeredByClientId = component.playerClientId;
					}
					else
					{
						__instance.LogInfo("Failed to find Player!");
					}
				}
				catch (Exception ex)
				{
					__instance.LogError($"Failed to run Landmine 'OnTriggerExit' Prefixes! {ex} {new StackTrace(ex)}");
				}
				return true;
			}

			[HarmonyPatch(typeof(Landmine), "IHittable.Hit")]
			[HarmonyPrefix]
			public static bool IHittable_Hit(Landmine __instance, int force, Vector3 hitDirection, PlayerControllerB playerWhoHit, bool playHitSFX)
			{
				try
				{
					__instance.LogInfo($"Player [{playerWhoHit.playerClientId}] triggered Landmine");
					LandmineTriggeredBy landmineTriggeredBy = ((Component)__instance).GetComponent<LandmineTriggeredBy>();
					if ((Object)(object)landmineTriggeredBy == (Object)null)
					{
						__instance.LogWarning("No LandmineTriggeredBy behaviour on landmine!");
						landmineTriggeredBy = ((Component)__instance).gameObject.AddComponent<LandmineTriggeredBy>();
						__instance.LogWarning("Added LandmineTriggeredBy behaviour to landmine!");
					}
					landmineTriggeredBy.TriggeredByClientId = playerWhoHit.playerClientId;
				}
				catch (Exception ex)
				{
					__instance.LogError($"Failed to run Landmine 'OnTriggerExit' Prefixes! {ex} {new StackTrace(ex)}");
				}
				return true;
			}

			private static bool PositionWithinExplosionRange(Vector3 explosionPos, Vector3 targetPos)
			{
				//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_0002: 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)
				return Physics.Linecast(explosionPos, targetPos + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1);
			}

			private static IEnumerable<PlayerControllerB> GetKillRadiusPlayers(Vector3 explosionPosition)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				Collider[] array = Physics.OverlapSphere(explosionPosition, 6f, 2621448, (QueryTriggerInteraction)2);
				Collider[] array2 = array;
				foreach (Collider val in array2)
				{
					if (((double)Vector3.Distance(explosionPosition, ((Component)val).transform.position) <= 4.0 || PositionWithinExplosionRange(explosionPosition, ((Component)val).transform.position)) && ((Component)val).gameObject.layer == 3)
					{
						yield return ((Component)val).gameObject.GetComponent<PlayerControllerB>();
					}
				}
			}
		}

		public static class PlayerControllerBPatches
		{
			[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayerFromOtherClientClientRpc")]
			[HarmonyPrefix]
			public static void DamagePlayerFromOtherClientClientRpc(PlayerControllerB __instance, int damageAmount, Vector3 hitDirection, int playerWhoHit, int newHealthAmount)
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				if (newHealthAmount <= 0)
				{
					KillCounter.Instance.Add(__instance.playerClientId, new KillCounter.Info
					{
						KillerClientId = (ulong)playerWhoHit,
						CauseOfDeath = (CauseOfDeath)1
					});
				}
			}
		}
	}
	public static class Statics
	{
		public const string GUID = "PlayerKillCounter";

		public const string NAME = "Player Kill Counter";

		public const string VERSION = "0.0.2";

		public const uint NETWORK_ID = 100000u;
	}
}
namespace PlayerKillCounter.Extensions
{
	public static class LandmineExtensions
	{
		public static void Log(this Landmine landmine, LogLevel level, string msg)
		{
			//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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.negativeInfinity;
			if ((Object)(object)landmine != (Object)null)
			{
				val = ((Component)landmine).transform.position;
			}
			Mod.Logger.Log(level, (object)($"[Landmine @ {val}] " + msg));
		}

		public static void LogFatal(this Landmine landmine, string msg)
		{
			landmine.Log((LogLevel)1, msg);
		}

		public static void LogError(this Landmine landmine, string msg)
		{
			landmine.Log((LogLevel)2, msg);
		}

		public static void LogWarning(this Landmine landmine, string msg)
		{
			landmine.Log((LogLevel)4, msg);
		}

		public static void LogMessage(this Landmine landmine, string msg)
		{
			landmine.Log((LogLevel)8, msg);
		}

		public static void LogInfo(this Landmine landmine, string msg)
		{
			landmine.Log((LogLevel)16, msg);
		}

		public static void LogDebug(this Landmine landmine, string msg)
		{
			landmine.Log((LogLevel)32, msg);
		}
	}
}
namespace PlayerKillCounter.Behaviours
{
	public class KillCounter : MonoBehaviour
	{
		public struct Info
		{
			public ulong KillerClientId;

			public CauseOfDeath CauseOfDeath;

			public byte[] Encode()
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected I4, but got Unknown
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, 12);
				BytePacker.WriteValueBitPacked(val, KillerClientId);
				BytePacker.WriteValueBitPacked(val, (uint)(int)CauseOfDeath);
				return ((FastBufferWriter)(ref val)).ToArray();
			}

			public Info Decode(byte[] data)
			{
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: 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)
				FastBufferReader val = new FastBufferReader(data, (Allocator)2, -1, 0);
				ByteUnpacker.ReadValueBitPacked(val, ref KillerClientId);
				uint num = default(uint);
				ByteUnpacker.ReadValueBitPacked(val, ref num);
				try
				{
					CauseOfDeath = (CauseOfDeath)num;
				}
				catch (InvalidCastException)
				{
					Mod.Logger.LogError((object)$"Unknown CauseOfDeath Id {num}");
					CauseOfDeath = (CauseOfDeath)0;
				}
				return this;
			}
		}

		private static KillCounter _instance;

		public static KillCounter Instance => _instance;

		private Dictionary<ulong, Info> KilledBy { get; set; }

		public Info this[ulong targetPlayerClientId] => KilledBy[targetPlayerClientId];

		public void Start()
		{
			_instance = this;
			KilledBy = new Dictionary<ulong, Info>();
		}

		public void Add(ulong targetPlayerClientId, Info info, bool broadcast = true)
		{
			if (broadcast)
			{
				RPCHandler.Instance.Send(RPCHandler.Action.UPDATE_KILL_COUNTER, targetPlayerClientId, info.Encode());
			}
			KilledBy.Add(targetPlayerClientId, info);
		}

		public bool ContainsPlayerClientId(ulong targetPlayerClientId)
		{
			return KilledBy.ContainsKey(targetPlayerClientId);
		}

		public void Clear()
		{
			KilledBy.Clear();
		}

		public override string ToString()
		{
			return GeneralExtensions.Join<ulong>((IEnumerable<ulong>)KilledBy.Keys, (Func<ulong, string>)((ulong o) => o.ToString()), ", ");
		}
	}
	public class LandmineTriggeredBy : MonoBehaviour, ICausedBy
	{
		public ulong TriggeredByClientId { get; set; }

		public ulong GetCausingPlayerId()
		{
			return TriggeredByClientId;
		}
	}
	public class RPCHandler : NetworkBehaviour
	{
		public enum Direction
		{
			UNKNOWN,
			TO_SERVER,
			TO_CLIENT
		}

		public enum Action
		{
			UNKNOWN,
			UPDATE_KILL_COUNTER
		}

		private static RPCHandler _instance;

		public static RPCHandler Instance => _instance;

		private bool IsClient
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Invalid comparison between Unknown and I4
				if ((int)base.__rpc_exec_stage != 2)
				{
					if (!((NetworkBehaviour)this).NetworkManager.IsServer)
					{
						return ((NetworkBehaviour)this).NetworkManager.IsHost;
					}
					return true;
				}
				return false;
			}
		}

		private bool IsServer
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Invalid comparison between Unknown and I4
				if ((int)base.__rpc_exec_stage != 1)
				{
					if (!((NetworkBehaviour)this).NetworkManager.IsClient)
					{
						return ((NetworkBehaviour)this).NetworkManager.IsHost;
					}
					return true;
				}
				return false;
			}
		}

		public void Send(Action action, params object[] args)
		{
			if (action == Action.UNKNOWN)
			{
				throw new ArgumentException("UNKNOWN passed as the action!", "action");
			}
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening)
			{
				if (IsClient)
				{
					SendToServer(action, args);
				}
				else if (IsServer)
				{
					SendToClient(action, args);
				}
			}
		}

		private void SendToServer(Action action, params object[] args)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			ServerRpcParams val = default(ServerRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(100000u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, 1u);
			BytePacker.WriteValueBitPacked(val2, (uint)action);
			if (action == Action.UPDATE_KILL_COUNTER && args.Length == 2)
			{
				ulong num = (ulong)args[0];
				byte[] array = (byte[])args[1];
				BytePacker.WriteValueBitPacked(val2, num);
				BytePacker.WriteValueBitPacked(val2, array.Length);
				((FastBufferWriter)(ref val2)).WriteBytes(array, -1, 0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 100000u, val, (RpcDelivery)0);
			}
			else
			{
				Mod.Logger.LogError((object)$"Unknown combination of {action} and {args}");
			}
		}

		private void SendToClient(Action action, params object[] args)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(100000u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, 2u);
			BytePacker.WriteValueBitPacked(val2, (uint)action);
			if (action == Action.UPDATE_KILL_COUNTER && args.Length == 2)
			{
				ulong num = (ulong)args[0];
				byte[] array = (byte[])args[1];
				BytePacker.WriteValueBitPacked(val2, num);
				BytePacker.WriteValueBitPacked(val2, array.Length);
				((FastBufferWriter)(ref val2)).WriteBytes(array, -1, 0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 100000u, val, (RpcDelivery)0);
			}
			else
			{
				Mod.Logger.LogError((object)$"Unknown combination of {action} and {args}");
			}
		}

		public void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			_instance = this;
			NetworkManager.__rpc_func_table.Add(100000u, new RpcReceiveHandler(RPCReceiveHandler));
		}

		private void RPCReceiveHandler(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002a: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening && ReadHeader(ref reader, out var direction, out var action))
			{
				HandleAction(target, reader, rpcParams, direction, action);
			}
		}

		private bool ReadHeader(ref FastBufferReader reader, out Direction direction, out Action action)
		{
			//IL_0001: 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)
			uint num = default(uint);
			ByteUnpacker.ReadValueBitPacked(reader, ref num);
			try
			{
				direction = (Direction)num;
			}
			catch (InvalidCastException)
			{
				Mod.Logger.LogError((object)$"Unknown message direction {num}");
				direction = Direction.UNKNOWN;
				action = Action.UNKNOWN;
				return false;
			}
			uint num2 = default(uint);
			ByteUnpacker.ReadValueBitPacked(reader, ref num2);
			try
			{
				action = (Action)num2;
			}
			catch (InvalidCastException)
			{
				Mod.Logger.LogError((object)$"Unknown action id {num2}");
				action = Action.UNKNOWN;
				return false;
			}
			return true;
		}

		private void HandleAction(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams, Direction direction, Action action)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (IsClient && direction == Direction.TO_CLIENT)
			{
				HandleClientAction(target, reader, rpcParams, action);
			}
			else if (IsServer && direction == Direction.TO_SERVER)
			{
				HandleServerAction(target, reader, rpcParams, action);
			}
		}

		private void HandleClientAction(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams, Action action)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (action == Action.UPDATE_KILL_COUNTER)
			{
				ulong targetPlayerClientId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref targetPlayerClientId);
				if (!KillCounter.Instance.ContainsPlayerClientId(targetPlayerClientId))
				{
					int num = default(int);
					ByteUnpacker.ReadValueBitPacked(reader, ref num);
					byte[] data = new byte[num];
					((FastBufferReader)(ref reader)).ReadBytes(ref data, num, 0);
					KillCounter.Info info = default(KillCounter.Info).Decode(data);
					KillCounter.Instance.Add(targetPlayerClientId, info, broadcast: false);
				}
			}
		}

		private void HandleServerAction(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams, Action action)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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)
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(100000u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, 2u);
			BytePacker.WriteValueBitPacked(val2, (uint)action);
			((FastBufferWriter)(ref val2)).WriteBytes(((FastBufferReader)(ref reader)).ToArray(), -1, 0);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 100000u, val, (RpcDelivery)0);
		}
	}
}