Decompiled source of BuildingInspector v0.2.6

BuildingInspector.dll

Decompiled 15 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using Splatform;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("BuildingInspector")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6f7763a8e4b85a020c1a844c19548a13f613d258")]
[assembly: AssemblyProduct("BuildingInspector")]
[assembly: AssemblyTitle("BuildingInspector")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BuildingInspector
{
	[BepInPlugin("Lanoz.BuildingInspector", "Building Inspector", "0.2.6")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BuildingInspector : BaseUnityPlugin
	{
		private sealed class FlagVariant
		{
			public string DisplayName { get; }

			public string Description { get; }

			public string PrefabName { get; }

			public Color Color { get; }

			public FlagVariant(string displayName, string description, string prefabName, Color color)
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				DisplayName = displayName;
				Description = description;
				PrefabName = prefabName;
				Color = color;
			}
		}

		private sealed class FlagNoteReceiver : MonoBehaviour, TextReceiver, Hoverable
		{
			private ZNetView nview;

			private void Awake()
			{
				if (!FlagReceivers.Contains(this))
				{
					FlagReceivers.Add(this);
				}
				nview = ((Component)this).GetComponent<ZNetView>();
				if (Object.op_Implicit((Object)(object)nview))
				{
					nview.Register<string>("BuildingInspector_SetFlagNote", (Action<long, string>)SetNoteRpc);
				}
				ApplyPlayerCollisionIgnores();
			}

			private void OnDestroy()
			{
				FlagReceivers.Remove(this);
			}

			public void IgnoreCollisionWith(Player player)
			{
				if (!Object.op_Implicit((Object)(object)player))
				{
					return;
				}
				Collider component = ((Component)this).GetComponent<Collider>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					return;
				}
				Collider[] componentsInChildren = ((Component)player).GetComponentsInChildren<Collider>();
				Collider[] array = componentsInChildren;
				foreach (Collider val in array)
				{
					if (Object.op_Implicit((Object)(object)val) && (Object)(object)val != (Object)(object)component)
					{
						Physics.IgnoreCollision(component, val, true);
					}
				}
			}

			private void ApplyPlayerCollisionIgnores()
			{
				Player[] array = Object.FindObjectsOfType<Player>();
				Player[] array2 = array;
				foreach (Player player in array2)
				{
					IgnoreCollisionWith(player);
				}
			}

			public void Open(ZNetView target)
			{
				nview = target;
				Piece val = (Object.op_Implicit((Object)(object)nview) ? ((Component)nview).GetComponent<Piece>() : null);
				if (Object.op_Implicit((Object)(object)nview) && nview.GetZDO() != null && Object.op_Implicit((Object)(object)TextInput.instance) && Object.op_Implicit((Object)(object)val) && val.IsCreator())
				{
					TextInput.instance.RequestText((TextReceiver)(object)this, "Inspection flag note", 160);
				}
			}

			private long GetCreatorId()
			{
				Piece val = (Object.op_Implicit((Object)(object)nview) ? ((Component)nview).GetComponent<Piece>() : null);
				return Object.op_Implicit((Object)(object)val) ? val.GetCreator() : 0;
			}

			public string GetText()
			{
				return (Object.op_Implicit((Object)(object)nview) && nview.GetZDO() != null) ? nview.GetZDO().GetString("BuildingInspector_FlagNote", string.Empty) : string.Empty;
			}

			public string GetHoverText()
			{
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				Piece component = ((Component)this).GetComponent<Piece>();
				string text = (Object.op_Implicit((Object)(object)component) ? component.m_name : "Inspection Flag");
				string text2 = GetText();
				if (!string.IsNullOrWhiteSpace(text2))
				{
					text = text + "\n<color=#FFE080>Note:</color> " + text2;
				}
				long creatorId = GetCreatorId();
				return (Object.op_Implicit((Object)(object)nview) && nview.GetZDO() != null && Object.op_Implicit((Object)(object)component) && creatorId != 0L && component.IsCreator()) ? (text + $"\nPress [<color=yellow><b>{editNoteKey.Value}</b></color>] to edit note") : (text + "\n<color=#AAAAAA>Only the player who placed this flag can edit its note.</color>");
			}

			public string GetHoverName()
			{
				Piece component = ((Component)this).GetComponent<Piece>();
				return Object.op_Implicit((Object)(object)component) ? component.m_name : "Inspection Flag";
			}

			public float GetHoverOffset()
			{
				return 0f;
			}

			public void SetText(string text)
			{
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				Piece val = (Object.op_Implicit((Object)(object)nview) ? ((Component)nview).GetComponent<Piece>() : null);
				if (Object.op_Implicit((Object)(object)nview) && nview.GetZDO() != null && Object.op_Implicit((Object)(object)val) && val.IsCreator())
				{
					log.LogInfo((object)$"Submitting note update for flag {nview.GetZDO().m_uid}; creator={GetCreatorId()}.");
					nview.InvokeRPC("BuildingInspector_SetFlagNote", new object[1] { (text ?? string.Empty).Trim() });
				}
			}

			private void SetNoteRpc(long sender, string text)
			{
				Piece val = (Object.op_Implicit((Object)(object)nview) ? ((Component)nview).GetComponent<Piece>() : null);
				long creatorId = GetCreatorId();
				ZNetPeer val2 = (Object.op_Implicit((Object)(object)ZNet.instance) ? ZNet.instance.GetPeer(sender) : null);
				bool flag = Object.op_Implicit((Object)(object)nview) && nview.IsOwner();
				bool flag2 = Object.op_Implicit((Object)(object)val) && IsSenderPlayer(sender, val, creatorId);
				log.LogInfo((object)string.Format("Received note update for flag {0}; sender={1}, senderPlayer={2}, creator={3}, owner={4}, authorized={5}.", (Object.op_Implicit((Object)(object)nview) && nview.GetZDO() != null) ? ((object)Unsafe.As<ZDOID, ZDOID>(ref nview.GetZDO().m_uid)/*cast due to .constrained prefix*/).ToString() : "unknown", sender, (val2 != null) ? val2.m_playerID.ToString() : "unknown", creatorId, flag, flag2));
				if (flag && nview.GetZDO() != null && flag2)
				{
					nview.GetZDO().Set("BuildingInspector_FlagNote", text ?? string.Empty);
				}
				else
				{
					log.LogWarning((object)"Rejected inspection flag note update.");
				}
			}
		}

		[HarmonyPatch(typeof(Player), "Start")]
		private static class PlayerStartFlagCollisionPatch
		{
			[HarmonyPostfix]
			private static void Postfix(Player __instance)
			{
				foreach (FlagNoteReceiver flagReceiver in FlagReceivers)
				{
					if (Object.op_Implicit((Object)(object)flagReceiver))
					{
						flagReceiver.IgnoreCollisionWith(__instance);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Player), "UpdatePlacementGhost")]
		private static class PlacementGhostTiltPatch
		{
			[HarmonyPostfix]
			private static void Postfix(Player __instance)
			{
				AlignFlagToSurface(__instance);
			}
		}

		public const string PluginGUID = "Lanoz.BuildingInspector";

		public const string PluginName = "Building Inspector";

		public const string PluginVersion = "0.2.6";

		private const int FlagVariantCount = 6;

		private const string NoteRpcName = "BuildingInspector_SetFlagNote";

		private const string NoteZdoKey = "BuildingInspector_FlagNote";

		private static ManualLogSource log;

		private static readonly List<Texture2D> IconTextures = new List<Texture2D>();

		private static readonly List<FlagNoteReceiver> FlagReceivers = new List<FlagNoteReceiver>();

		private static Texture2D clothTexture;

		private static ConfigEntry<KeyboardShortcut> tiltForwardKey;

		private static ConfigEntry<KeyboardShortcut> tiltBackwardKey;

		private static ConfigEntry<KeyboardShortcut> tiltLeftKey;

		private static ConfigEntry<KeyboardShortcut> tiltRightKey;

		private static ConfigEntry<KeyboardShortcut> resetTiltKey;

		private static ConfigEntry<float> tiltStepDegrees;

		private static ConfigEntry<float> maxTiltDegrees;

		private static ConfigEntry<KeyboardShortcut> editNoteKey;

		private static ConfigEntry<float> flagBlockRadius;

		private static ConfigEntry<bool> testFlagEnabled;

		private static readonly List<ConfigEntry<string>> labelNames = new List<ConfigEntry<string>>();

		private static readonly List<ConfigEntry<string>> labelDescriptions = new List<ConfigEntry<string>>();

		private static readonly List<ConfigEntry<string>> labelColors = new List<ConfigEntry<string>>();

		private static FlagVariant[] flagVariants;

		private static FlagVariant testFlagVariant;

		private static FlagNoteReceiver noteInput;

		private static float tiltX;

		private static float tiltZ;

		private static float surfaceWheelRotation;

		private static GameObject lastTiltedGhost;

		private void Awake()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Expected O, but got Unknown
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			log = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Building Inspector loading...");
			tiltForwardKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Flag Rotation", "TiltForwardKey", new KeyboardShortcut((KeyCode)105, Array.Empty<KeyCode>()), "Tilt the flag forward.");
			tiltBackwardKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Flag Rotation", "TiltBackwardKey", new KeyboardShortcut((KeyCode)107, Array.Empty<KeyCode>()), "Tilt the flag backward.");
			tiltLeftKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Flag Rotation", "TiltLeftKey", new KeyboardShortcut((KeyCode)106, Array.Empty<KeyCode>()), "Tilt the flag to the left.");
			tiltRightKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Flag Rotation", "TiltRightKey", new KeyboardShortcut((KeyCode)108, Array.Empty<KeyCode>()), "Tilt the flag to the right.");
			resetTiltKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Flag Rotation", "ResetTiltKey", new KeyboardShortcut((KeyCode)277, Array.Empty<KeyCode>()), "Reset the flag tilt.");
			tiltStepDegrees = ((BaseUnityPlugin)this).Config.Bind<float>("Flag Rotation", "TiltStepDegrees", 15f, "Tilt change per key press in degrees.");
			maxTiltDegrees = ((BaseUnityPlugin)this).Config.Bind<float>("Flag Rotation", "MaxTiltDegrees", 60f, "Maximum tilt angle in either direction.");
			editNoteKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Flag Notes", "EditNoteKey", new KeyboardShortcut((KeyCode)110, Array.Empty<KeyCode>()), "Edit the note on the aimed inspection flag.");
			flagBlockRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Flag Placement", "BlockRadius", 0.2f, new ConfigDescription("Minimum spacing between placed inspection flags in meters.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 1f), Array.Empty<object>()));
			BindFlagVariants();
			noteInput = ((Component)this).gameObject.AddComponent<FlagNoteReceiver>();
			new Harmony("Lanoz.BuildingInspector").PatchAll(typeof(BuildingInspector).Assembly);
			PrefabManager.OnVanillaPrefabsAvailable += RegisterInspectionFlag;
		}

		private void BindFlagVariants()
		{
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			int[] array = new int[6] { 1, 2, 3, 4, 5, 6 };
			string[] array2 = new string[6] { "Problem", "Review", "Verified", "Other", "Structural", "Finish" };
			string[] array3 = new string[6] { "A building issue was found.", "This part needs review.", "This part was inspected.", "Another inspection category.", "Structural work needs attention.", "Finishing work needs attention." };
			string[] array4 = new string[6] { "#FA2E1F", "#FFE014", "#1FE633", "#1F80FF", "#A64DFF", "#F2F2F2" };
			string[] array5 = new string[6] { "InspectionFlagRed", "InspectionFlagYellow", "InspectionFlagGreen", "InspectionFlagBlue", "InspectionFlagCustom5", "InspectionFlagCustom8" };
			flagVariants = new FlagVariant[6];
			Color white = default(Color);
			for (int i = 0; i < 6; i++)
			{
				int num = array[i];
				labelNames.Add(((BaseUnityPlugin)this).Config.Bind<string>("Flag Labels", $"Label{num}Name", array2[i], "Display name for this flag category."));
				labelDescriptions.Add(((BaseUnityPlugin)this).Config.Bind<string>("Flag Labels", $"Label{num}Description", array3[i], "Description shown in the build menu."));
				labelColors.Add(((BaseUnityPlugin)this).Config.Bind<string>("Flag Labels", $"Label{num}Color", array4[i], "Flag color as a hex value, for example #FF0000."));
				if (!ColorUtility.TryParseHtmlString(labelColors[i].Value, ref white))
				{
					white = Color.white;
					((BaseUnityPlugin)this).Logger.LogWarning((object)$"Invalid color for Label{num}Color; using white.");
				}
				string text = (string.IsNullOrWhiteSpace(labelNames[i].Value) ? array2[i] : labelNames[i].Value.Trim());
				string description = labelDescriptions[i].Value ?? string.Empty;
				flagVariants[i] = new FlagVariant("Inspection Flag - " + text, description, array5[i], white);
			}
			testFlagEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Test Flag", "Enabled", false, "Register an isolated test flag for checking label configuration. Restart the game after changing this setting.");
			string value = ((BaseUnityPlugin)this).Config.Bind<string>("Test Flag", "Name", "Configuration Test", "Display name for the optional test flag.").Value;
			string value2 = ((BaseUnityPlugin)this).Config.Bind<string>("Test Flag", "Description", "Temporary flag for testing label settings.", "Description for the optional test flag.").Value;
			string value3 = ((BaseUnityPlugin)this).Config.Bind<string>("Test Flag", "Color", "#FF00FF", "Hex color for the optional test flag, for example #FF00FF.").Value;
			Color magenta = default(Color);
			if (!ColorUtility.TryParseHtmlString(value3, ref magenta))
			{
				magenta = Color.magenta;
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Invalid Test Flag Color '" + value3 + "'; using #FF00FF."));
			}
			value = (string.IsNullOrWhiteSpace(value) ? "Configuration Test" : value.Trim());
			testFlagVariant = new FlagVariant("[TEST] Inspection Flag - " + value, value2 ?? string.Empty, "InspectionFlagConfigTest", magenta);
		}

		private void RegisterInspectionFlag()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= RegisterInspectionFlag;
			try
			{
				int num = AddInspectionFlags();
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Inspection Flags registered: {num}.");
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Building Inspector loaded!");
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"Failed to register Inspection Flag: {arg}");
			}
		}

		private void Update()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			if (editNoteKey == null)
			{
				return;
			}
			KeyboardShortcut value = editNoteKey.Value;
			if (!((KeyboardShortcut)(ref value)).IsDown() || TextInput.IsVisible())
			{
				return;
			}
			Camera main = Camera.main;
			if (!Object.op_Implicit((Object)(object)main))
			{
				return;
			}
			Ray val = main.ScreenPointToRay(new Vector3((float)Screen.width * 0.5f, (float)Screen.height * 0.5f));
			float num = (Object.op_Implicit((Object)(object)Player.m_localPlayer) ? Vector3.Distance(((Component)main).transform.position, ((Component)Player.m_localPlayer).transform.position) : 0f);
			float num2 = 6f + num;
			RaycastHit[] array = Physics.RaycastAll(val, num2, -5, (QueryTriggerInteraction)1);
			Array.Sort(array, (RaycastHit first, RaycastHit second) => ((RaycastHit)(ref first)).distance.CompareTo(((RaycastHit)(ref second)).distance));
			RaycastHit[] array2 = array;
			for (int num3 = 0; num3 < array2.Length; num3++)
			{
				RaycastHit val2 = array2[num3];
				FlagNoteReceiver componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<FlagNoteReceiver>();
				if (Object.op_Implicit((Object)(object)componentInParent))
				{
					noteInput.Open(((Component)componentInParent).GetComponent<ZNetView>());
					break;
				}
				if (BlocksNoteRay(((RaycastHit)(ref val2)).collider))
				{
					break;
				}
			}
		}

		private static bool BlocksNoteRay(Collider collider)
		{
			if (!Object.op_Implicit((Object)(object)collider))
			{
				return false;
			}
			if (Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent<Piece>()) || Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent<WearNTear>()) || Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent<Heightmap>()) || Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent<Character>()) || Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent<TreeLog>()))
			{
				return true;
			}
			TreeBase componentInParent = ((Component)collider).GetComponentInParent<TreeBase>();
			return Object.op_Implicit((Object)(object)componentInParent) && (Object)(object)((Component)collider).gameObject == (Object)(object)((Component)componentInParent).gameObject;
		}

		private int AddInspectionFlags()
		{
			GameObject prefab = Cache.GetPrefab<GameObject>("wood_pole");
			Renderer val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponentInChildren<Renderer>() : null);
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.sharedMaterial))
			{
				throw new InvalidOperationException("Could not find the vanilla wood_pole material.");
			}
			Piece component = prefab.GetComponent<Piece>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				throw new InvalidOperationException("Could not find the Piece component on vanilla wood_pole.");
			}
			WearNTear component2 = prefab.GetComponent<WearNTear>();
			if (!Object.op_Implicit((Object)(object)component2))
			{
				throw new InvalidOperationException("Could not find the WearNTear component on vanilla wood_pole.");
			}
			Material sharedMaterial = val.sharedMaterial;
			int pieceLayer = LayerMask.NameToLayer("piece");
			int num = 0;
			FlagVariant[] array = flagVariants;
			foreach (FlagVariant variant in array)
			{
				if (AddInspectionFlag(variant, sharedMaterial, component.m_placeEffect, component2, pieceLayer))
				{
					num++;
				}
			}
			if (num != flagVariants.Length)
			{
				throw new InvalidOperationException($"Only {num} of {flagVariants.Length} Inspection Flags were registered.");
			}
			if (testFlagEnabled.Value && AddInspectionFlag(testFlagVariant, sharedMaterial, component.m_placeEffect, component2, pieceLayer))
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Optional configuration test flag registered.");
			}
			List<Piece> list = new List<Piece>();
			FlagVariant[] array2 = flagVariants;
			foreach (FlagVariant flagVariant in array2)
			{
				GameObject prefab2 = Cache.GetPrefab<GameObject>(flagVariant.PrefabName);
				Piece val2 = (Object.op_Implicit((Object)(object)prefab2) ? prefab2.GetComponent<Piece>() : null);
				if (Object.op_Implicit((Object)(object)val2))
				{
					list.Add(val2);
				}
			}
			foreach (Piece item in list)
			{
				item.m_blockingPieces = list;
				item.m_blockRadius = Mathf.Clamp(flagBlockRadius.Value, 0.05f, 1f);
			}
			return num;
		}

		private bool AddInspectionFlag(FlagVariant variant, Material woodMaterial, EffectList placeEffect, WearNTear sourceWearNTear, int pieceLayer)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Expected O, but got Unknown
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Expected O, but got Unknown
			GameObject val = PrefabManager.Instance.CreateEmptyPrefab(variant.PrefabName, true);
			if (!Object.op_Implicit((Object)(object)val))
			{
				throw new InvalidOperationException("Jotunn could not create the " + variant.PrefabName + " prefab.");
			}
			val.transform.localScale = Vector3.one * 0.5f;
			val.AddComponent<Piece>();
			val.AddComponent<FlagNoteReceiver>();
			BoxCollider component = val.GetComponent<BoxCollider>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				throw new InvalidOperationException("The InspectionFlag prefab has no root BoxCollider.");
			}
			MeshRenderer component2 = val.GetComponent<MeshRenderer>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				((Renderer)component2).enabled = false;
			}
			if (pieceLayer >= 0)
			{
				val.layer = pieceLayer;
			}
			component.center = new Vector3(0f, 0.68f, 0f);
			component.size = new Vector3(0.55f, 1.4f, 0.16f);
			((Collider)component).isTrigger = false;
			GameObject val2 = AddPrimitive(val, (PrimitiveType)2, "InspectionFlagPole", new Vector3(0f, 0.34f, 0f), new Vector3(0.027f, 0.68f, 0.027f), woodMaterial, pieceLayer);
			AddClothSprite(val2, woodMaterial, variant, pieceLayer);
			WearNTear val3 = val.AddComponent<WearNTear>();
			val3.m_new = val2;
			val3.m_worn = val2;
			val3.m_broken = val2;
			val3.m_noRoofWear = true;
			val3.m_noSupportWear = sourceWearNTear.m_noSupportWear;
			val3.m_supports = false;
			val3.m_staticPosition = sourceWearNTear.m_staticPosition;
			val3.m_materialType = sourceWearNTear.m_materialType;
			val3.m_health = sourceWearNTear.m_health;
			val3.m_autoCreateFragments = false;
			val3.m_fragmentRoots = Array.Empty<GameObject>();
			PieceConfig val4 = new PieceConfig
			{
				Name = variant.DisplayName,
				Description = variant.Description,
				PieceTable = "Hammer",
				Category = "Inspection"
			};
			val4.Icon = CreateFlagIcon(variant.Color, variant.PrefabName);
			if (!Object.op_Implicit((Object)(object)val4.Icon))
			{
				throw new InvalidOperationException("Could not create an icon for " + variant.PrefabName + ".");
			}
			CustomPiece val5 = new CustomPiece(val, false, val4);
			val5.Piece.m_resources = Array.Empty<Requirement>();
			val5.Piece.m_placeEffect = placeEffect;
			val5.Piece.m_canRotate = true;
			if (!PieceManager.Instance.AddPiece(val5))
			{
				throw new InvalidOperationException("Jotunn's PieceManager rejected " + variant.PrefabName + ".");
			}
			return true;
		}

		private static GameObject AddPrimitive(GameObject parent, PrimitiveType type, string name, Vector3 localPosition, Vector3 localScale, Material material, int pieceLayer)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.CreatePrimitive(type);
			((Object)val).name = name;
			val.transform.SetParent(parent.transform, false);
			val.transform.localPosition = localPosition;
			val.transform.localScale = localScale;
			if (pieceLayer >= 0)
			{
				val.layer = pieceLayer;
			}
			Collider component = val.GetComponent<Collider>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.enabled = false;
			}
			Renderer component2 = val.GetComponent<Renderer>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				component2.sharedMaterial = material;
			}
			return val;
		}

		private static void AddClothSprite(GameObject pole, Material woodMaterial, FlagVariant variant, int pieceLayer)
		{
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Expected O, but got Unknown
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Expected O, but got Unknown
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0510: Unknown result type (might be due to invalid IL or missing references)
			//IL_0515: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)clothTexture))
			{
				clothTexture = new Texture2D(16, 16, (TextureFormat)4, false);
				Color32[] array = (Color32[])(object)new Color32[256];
				for (int i = 0; i < 16; i++)
				{
					for (int j = 0; j < 16; j++)
					{
						bool flag = j % 4 == 0;
						bool flag2 = i % 4 == 0;
						byte b = (byte)((flag && flag2) ? 236 : ((flag || flag2) ? 246 : byte.MaxValue));
						array[i * 16 + j] = new Color32(b, b, b, byte.MaxValue);
					}
				}
				clothTexture.SetPixels32(array);
				clothTexture.Apply(false, true);
				((Texture)clothTexture).filterMode = (FilterMode)1;
			}
			Material val = new Material(woodMaterial);
			((Object)val).name = variant.PrefabName + "_ClothMaterial";
			val.mainTexture = (Texture)(object)clothTexture;
			Color color = variant.Color;
			color.a = Mathf.Min(color.a, 0.85f);
			val.color = color;
			if (val.HasProperty("_Mode"))
			{
				val.SetFloat("_Mode", 2f);
			}
			if (val.HasProperty("_SrcBlend"))
			{
				val.SetInt("_SrcBlend", 5);
			}
			if (val.HasProperty("_DstBlend"))
			{
				val.SetInt("_DstBlend", 10);
			}
			if (val.HasProperty("_ZWrite"))
			{
				val.SetInt("_ZWrite", 0);
			}
			if (val.HasProperty("_Cull"))
			{
				val.SetInt("_Cull", 0);
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", 0f);
			}
			if (val.HasProperty("_Glossiness"))
			{
				val.SetFloat("_Glossiness", 0f);
			}
			if (val.HasProperty("_EmissionColor"))
			{
				val.SetColor("_EmissionColor", Color.black);
			}
			val.DisableKeyword("_EMISSION");
			val.DisableKeyword("_ALPHATEST_ON");
			val.EnableKeyword("_ALPHABLEND_ON");
			val.DisableKeyword("_ALPHAPREMULTIPLY_ON");
			val.renderQueue = 3000;
			GameObject val2 = new GameObject("InspectionFlagCloth");
			val2.transform.SetParent(pole.transform, false);
			MeshFilter val3 = (Object.op_Implicit((Object)(object)pole) ? pole.GetComponent<MeshFilter>() : null);
			Vector3 localScale = pole.transform.localScale;
			float num = Mathf.Max(Mathf.Abs(localScale.x), 0.0001f);
			float num2 = Mathf.Max(Mathf.Abs(localScale.y), 0.0001f);
			Bounds val4 = (Bounds)((Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)val3.sharedMesh)) ? val3.sharedMesh.bounds : new Bounds(Vector3.zero, Vector3.one));
			float num3 = 0.39f / num;
			float num4 = 0.24f / num2;
			float num5 = num4 * 0.5f;
			val2.transform.localPosition = new Vector3(0f - ((Bounds)(ref val4)).extents.x, ((Bounds)(ref val4)).max.y - num5, 0f);
			if (pieceLayer >= 0)
			{
				val2.layer = pieceLayer;
			}
			Mesh val5 = new Mesh();
			((Object)val5).name = "InspectionFlagClothMesh";
			val5.vertices = (Vector3[])(object)new Vector3[8]
			{
				new Vector3(0f, 0f - num5, 0f),
				new Vector3(num3, 0f - num5, 0f),
				new Vector3(num3, num5, 0f),
				new Vector3(0f, num5, 0f),
				new Vector3(0f, 0f - num5, 0f),
				new Vector3(num3, 0f - num5, 0f),
				new Vector3(num3, num5, 0f),
				new Vector3(0f, num5, 0f)
			};
			val5.uv = (Vector2[])(object)new Vector2[8]
			{
				new Vector2(0f, 0f),
				new Vector2(1f, 0f),
				new Vector2(1f, 1f),
				new Vector2(0f, 1f),
				new Vector2(0f, 0f),
				new Vector2(1f, 0f),
				new Vector2(1f, 1f),
				new Vector2(0f, 1f)
			};
			val5.triangles = new int[12]
			{
				0, 1, 2, 0, 2, 3, 4, 6, 5, 4,
				7, 6
			};
			val5.RecalculateNormals();
			val5.RecalculateBounds();
			val2.AddComponent<MeshFilter>().sharedMesh = val5;
			MeshRenderer val6 = val2.AddComponent<MeshRenderer>();
			((Renderer)val6).sharedMaterial = val;
		}

		private static void AlignFlagToSurface(Player player)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			object? value = AccessTools.Field(typeof(Player), "m_placementGhost").GetValue(player);
			GameObject val = (GameObject)((value is GameObject) ? value : null);
			if (!Object.op_Implicit((Object)(object)val) || !((Object)val).name.StartsWith("InspectionFlag", StringComparison.Ordinal))
			{
				lastTiltedGhost = null;
				return;
			}
			Camera main = Camera.main;
			if (!Object.op_Implicit((Object)(object)main))
			{
				return;
			}
			Ray val2 = main.ScreenPointToRay(new Vector3((float)Screen.width * 0.5f, (float)Screen.height * 0.5f));
			FieldInfo fieldInfo = AccessTools.Field(typeof(Player), "m_placeRayMask");
			int num = ((fieldInfo != null) ? ((int)fieldInfo.GetValue(player)) : (-5));
			RaycastHit val3 = default(RaycastHit);
			if (!Physics.Raycast(val2, ref val3, 50f, num, (QueryTriggerInteraction)1) || Vector3.Distance(((RaycastHit)(ref val3)).point, val.transform.position) > 1.75f)
			{
				return;
			}
			if ((Object)(object)val != (Object)(object)lastTiltedGhost)
			{
				tiltX = 0f;
				tiltZ = 0f;
				surfaceWheelRotation = 0f;
			}
			float axis = Input.GetAxis("Mouse ScrollWheel");
			if (Mathf.Abs(axis) > 0.001f)
			{
				surfaceWheelRotation += Mathf.Sign(axis) * 22.5f;
			}
			Vector3 val4 = Vector3.ProjectOnPlane(((Component)main).transform.position - ((RaycastHit)(ref val3)).point, ((RaycastHit)(ref val3)).normal);
			if (((Vector3)(ref val4)).sqrMagnitude < 0.001f)
			{
				val4 = Vector3.ProjectOnPlane(-((Ray)(ref val2)).direction, ((RaycastHit)(ref val3)).normal);
			}
			if (((Vector3)(ref val4)).sqrMagnitude > 0.001f)
			{
				Quaternion val5 = Quaternion.LookRotation(((Vector3)(ref val4)).normalized, ((RaycastHit)(ref val3)).normal);
				val5 = Quaternion.AngleAxis(surfaceWheelRotation, ((RaycastHit)(ref val3)).normal) * val5;
				KeyboardShortcut value2 = tiltForwardKey.Value;
				if (((KeyboardShortcut)(ref value2)).IsDown())
				{
					tiltX = Mathf.Clamp(tiltX + tiltStepDegrees.Value, 0f - maxTiltDegrees.Value, maxTiltDegrees.Value);
				}
				value2 = tiltBackwardKey.Value;
				if (((KeyboardShortcut)(ref value2)).IsDown())
				{
					tiltX = Mathf.Clamp(tiltX - tiltStepDegrees.Value, 0f - maxTiltDegrees.Value, maxTiltDegrees.Value);
				}
				value2 = tiltLeftKey.Value;
				if (((KeyboardShortcut)(ref value2)).IsDown())
				{
					tiltZ = Mathf.Clamp(tiltZ - tiltStepDegrees.Value, 0f - maxTiltDegrees.Value, maxTiltDegrees.Value);
				}
				value2 = tiltRightKey.Value;
				if (((KeyboardShortcut)(ref value2)).IsDown())
				{
					tiltZ = Mathf.Clamp(tiltZ + tiltStepDegrees.Value, 0f - maxTiltDegrees.Value, maxTiltDegrees.Value);
				}
				value2 = resetTiltKey.Value;
				if (((KeyboardShortcut)(ref value2)).IsDown())
				{
					tiltX = 0f;
					tiltZ = 0f;
				}
				val.transform.rotation = val5 * Quaternion.Euler(tiltX, 0f, tiltZ);
				val.transform.position = ((RaycastHit)(ref val3)).point;
				lastTiltedGhost = val;
			}
		}

		private static Sprite CreateFlagIcon(Color flagColor, string iconName)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			Color32[] array = (Color32[])(object)new Color32[4096];
			Color32 color = default(Color32);
			((Color32)(ref color))..ctor((byte)112, (byte)75, (byte)42, byte.MaxValue);
			Color32 color2 = Color32.op_Implicit(flagColor);
			DrawRectangle(array, 64, 29, 13, 34, 54, color);
			DrawRectangle(array, 64, 19, 8, 44, 13, color);
			DrawRectangle(array, 64, 34, 43, 53, 55, color2);
			DrawRectangle(array, 64, 34, 39, 49, 43, color2);
			Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false);
			val.SetPixels32(array);
			val.Apply(false, true);
			IconTextures.Add(val);
			Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f);
			((Object)val2).name = iconName + "Icon";
			return val2;
		}

		private static void DrawRectangle(Color32[] pixels, int textureSize, int xMin, int yMin, int xMax, int yMax, Color32 color)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			for (int i = yMin; i < yMax; i++)
			{
				for (int j = xMin; j < xMax; j++)
				{
					pixels[i * textureSize + j] = color;
				}
			}
		}

		private static bool IsSenderPlayer(long sender, Piece piece, long playerId)
		{
			if (!Object.op_Implicit((Object)(object)piece) || playerId == 0L || !Object.op_Implicit((Object)(object)ZNet.instance))
			{
				return false;
			}
			ZNetPeer peer = ZNet.instance.GetPeer(sender);
			if (peer != null)
			{
				return peer.m_playerID == playerId || IsCreatorPlatformUser(peer, piece);
			}
			return sender == ZNet.GetUID() && piece.IsCreator();
		}

		private static bool IsCreatorPlatformUser(ZNetPeer peer, Piece piece)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			World val = (Object.op_Implicit((Object)(object)ZNet.instance) ? ZNet.instance.GetWorld() : null);
			int creatorPlatformUserIdIndex = piece.GetCreatorPlatformUserIdIndex();
			if (peer == null || val == null || creatorPlatformUserIdIndex < 0 || creatorPlatformUserIdIndex >= val.m_playerHistory.Count)
			{
				return false;
			}
			PlatformUserID id = val.m_playerHistory[creatorPlatformUserIdIndex].m_id;
			foreach (PlayerInfo player in ZNet.instance.GetPlayerList())
			{
				ZDOID characterID = player.m_characterID;
				if (((ZDOID)(ref characterID)).Equals(peer.m_characterID) && player.m_userInfo.m_id == id)
				{
					return true;
				}
			}
			return false;
		}
	}
}