Decompiled source of DuckMod v1.5.0

plugins/DuckMod/DuckMod.dll

Decompiled a week ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DuckMod.Behaviors;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.Rendering.HighDefinition;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DuckMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DuckMod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("63ea62a8-9147-4f70-b5bf-9933a39b3e9b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace DuckMod
{
	[BepInPlugin("Dio93.DuckMod", "DuckMod", "1.5.0.0")]
	public class DuckMod : BaseUnityPlugin
	{
		private const string modGUID = "Dio93.DuckMod";

		private const string modName = "DuckMod";

		private const string modVersion = "1.5.0.0";

		private readonly Harmony harmony = new Harmony("Dio93.DuckMod");

		private static DuckMod instance;

		internal ManualLogSource mls;

		private ConfigEntry<bool> configDebug;

		private ConfigEntry<int> configMaxDucks;

		private ConfigEntry<int> configCarryAmount;

		private ConfigEntry<bool> configCanGrabTwoHanded;

		private ConfigEntry<bool> configCanGrabPlayer;

		private ConfigEntry<bool> configCanGrabHive;

		private ConfigEntry<bool> configCanUseItem;

		private ConfigEntry<int> configDuckPrice;

		private ConfigEntry<float> configSpeed;

		private ConfigEntry<bool> configHittable;

		private ConfigEntry<int> configHp;

		private ConfigEntry<bool> configCanOpenDoors;

		private ConfigEntry<float> configTextureWhite;

		private ConfigEntry<float> configTextureGreen;

		private ConfigEntry<float> configTextureGold;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			configDebug = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Debugging", false, "Enable logging in Console?");
			configMaxDucks = ((BaseUnityPlugin)this).Config.Bind<int>("Duck", "Max Duck Count", -1, "Maximal number of ducks. -1 = infinite");
			configDuckPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Duck", "Duck Price", 25, "Price of a duck");
			configCarryAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Duck.Items", "Carry Amount", 1, "The amount of items the duck can carry");
			configCanGrabPlayer = ((BaseUnityPlugin)this).Config.Bind<bool>("Duck.Items", "Can grab players", true, "Can the duck grab dead players?");
			configCanGrabTwoHanded = ((BaseUnityPlugin)this).Config.Bind<bool>("Duck.Items", "Can grab two handed", true, "Can the duck grab two handed items?");
			configCanGrabHive = ((BaseUnityPlugin)this).Config.Bind<bool>("Duck.Items", "Can grab hive", false, "Can the duck grab hives?");
			configCanUseItem = ((BaseUnityPlugin)this).Config.Bind<bool>("Duck.Items", "Can use item", false, "Can the duck use items?");
			configCanOpenDoors = ((BaseUnityPlugin)this).Config.Bind<bool>("Duck", "Can open doors", true, "Can ducks open doors?");
			configSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Duck", "Speed", 0.8f, "The speed of the duck proportional to the player");
			configHittable = ((BaseUnityPlugin)this).Config.Bind<bool>("Duck", "Hittable", false, "Is the duck hittable");
			configHp = ((BaseUnityPlugin)this).Config.Bind<int>("Duck", "Hp", 10, "Health points of the duck");
			configTextureWhite = ((BaseUnityPlugin)this).Config.Bind<float>("Duck.Textures", "White Texture", 0.5f, "Probability of white texture");
			configTextureGreen = ((BaseUnityPlugin)this).Config.Bind<float>("Duck.Textures", "Green Texture", 0.5f, "Probability of green texture");
			configTextureGold = ((BaseUnityPlugin)this).Config.Bind<float>("Duck.Textures", "Gold Texture", 0.01f, "Probability of gold texture");
			mls = Logger.CreateLogSource("Dio93.DuckMod");
			PetAI.mls = (configDebug.Value ? mls : null);
			PetDuckAI.InitializeRPCS_PetDuckAI();
			PetAI.InitializeRPCS_PetAI();
			PetAI.maxPets = configMaxDucks.Value;
			int value = configDuckPrice.Value;
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string text = Path.Combine(directoryName, "duckmod");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Material item = val.LoadAsset<Material>("Assets/Items/PetDuck/DuckShader White.mat");
			Material item2 = val.LoadAsset<Material>("Assets/Items/PetDuck/DuckShader Green.mat");
			Material item3 = val.LoadAsset<Material>("Assets/Items/PetDuck/DuckShader Gold.mat");
			PetDuckAI.materials.Add((configTextureGold.Value, item3));
			PetDuckAI.materials.Add((configTextureGreen.Value, item2));
			PetDuckAI.materials.Add((configTextureWhite.Value, item));
			PetAI.canGrabPlayers = configCanGrabPlayer.Value;
			PetAI.canGrabTwoHanded = configCanGrabTwoHanded.Value;
			PetAI.canGrabHive = configCanGrabHive.Value;
			PetAI.canUseItem = configCanUseItem.Value;
			PetAI.canOpenDoors = configCanOpenDoors.Value;
			Item val2 = val.LoadAsset<Item>("Assets/Items/PetDuck/PetDuckItem.asset");
			PetDuckAI petDuckAI = val2.spawnPrefab.AddComponent<PetDuckAI>();
			petDuckAI.itemCapacity = configCarryAmount.Value;
			petDuckAI.speedFactor = configSpeed.Value;
			petDuckAI.hittable = configHittable.Value;
			petDuckAI.maxHp = configHp.Value;
			petDuckAI.SetScrapValue((float)value / 2f);
			Item val3 = val.LoadAsset<Item>("Assets/Items/PetDuck/PetDuckHatItem.asset");
			PetDuckAI petDuckAI2 = val3.spawnPrefab.AddComponent<PetDuckAI>();
			petDuckAI2.itemCapacity = configCarryAmount.Value;
			petDuckAI2.speedFactor = configSpeed.Value;
			petDuckAI2.hittable = configHittable.Value;
			petDuckAI2.maxHp = configHp.Value;
			petDuckAI2.SetScrapValue((float)value / 2f);
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			TerminalNode val4 = ScriptableObject.CreateInstance<TerminalNode>();
			val4.clearPreviousText = true;
			val4.displayText = "You have requested to order mighty pet ducks. Amount: [variableAmount].\nTotal cost of items: [totalCost]\n\nPlease CONFIRM or DENY.\n\n";
			Items.RegisterShopItem(val2, val4, (TerminalNode)null, (TerminalNode)null, value);
			NetworkPrefabs.RegisterNetworkPrefab(val3.spawnPrefab);
			Utilities.FixMixerGroups(val3.spawnPrefab);
			TerminalNode val5 = ScriptableObject.CreateInstance<TerminalNode>();
			val5.clearPreviousText = true;
			val5.displayText = "You have requested to order gentle ducks with hats. Amount: [variableAmount].\nTotal cost of items: [totalCost]\n\nPlease CONFIRM or DENY.\n\n";
			Items.RegisterShopItem(val3, val5, (TerminalNode)null, (TerminalNode)null, value);
			mls.LogInfo((object)"The duck mod 1.4.0 has awaken :)");
			harmony.PatchAll(typeof(DuckMod));
		}
	}
}
namespace DuckMod.Behaviors
{
	internal class DuckEggBehavior : MonoBehaviour
	{
		public static PetDuckAI petDuckPrefab;

		private int startDay;

		public void Start()
		{
			startDay = StartOfRound.Instance.daysPlayersSurvivedInARow;
		}

		public void Update()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if (StartOfRound.Instance.daysPlayersSurvivedInARow - startDay == 2 && (Object)(object)petDuckPrefab != (Object)null)
			{
				Object.Instantiate<PetDuckAI>(petDuckPrefab, ((Component)this).transform.position, ((Component)this).transform.rotation);
			}
		}
	}
	internal abstract class PetAI : NetworkBehaviour, IHittable, INoiseListener
	{
		public enum ShipState
		{
			None,
			InSpace,
			OnMoon
		}

		private static PetAI petAI;

		public static int maxPets;

		public static int petCount;

		public static ManualLogSource mls;

		protected NavMeshAgent agent;

		protected AudioSource audioQuacking;

		protected AudioSource audioWalking;

		protected PhysicsProp physicsProp;

		protected NetworkObject networkObject;

		protected Animator animator;

		protected Transform itemHolder;

		protected Transform interactPatter;

		protected InteractTrigger interactTrigger;

		protected SkinnedMeshRenderer[] meshRenderers;

		private float scrapValue;

		public int maxHp = 10;

		protected int hp;

		public bool hittable;

		protected bool isInsideShip;

		protected bool isInFactory;

		protected float checkForBoombox = 0f;

		protected float checkEnemyCooldown = 10f;

		protected float lastCheckEnemy = -1f;

		protected ShipState shipState;

		protected DoorLock[] doors;

		protected static ItemDropship dropShip;

		protected float nextItemInteract;

		protected static float grabbingCooldown = 0f;

		protected GrabbableObject targetItem;

		protected static IList<GrabbableObject> grabbableItems = new List<GrabbableObject>();

		protected IList<GrabbableObject> grabbedItems = new List<GrabbableObject>();

		public int itemCapacity = 1;

		public static bool canUseItem = false;

		public static bool canGrabPlayers = true;

		public static bool canGrabHive = false;

		public static bool canGrabTwoHanded = false;

		public static bool canOpenDoors = false;

		protected static float nextItemCheck = 0f;

		protected static float nextItemCheckCooldown = 10f;

		public float speedFactor = 0.8f;

		private float nextSpeedCheck = 0f;

		private float nextSpeedCheckCooldown = 30f;

		protected PlayerControllerB targetPlayer;

		protected float findTargetPlayerIn = 0f;

		protected Vector3 destination;

		protected float minPlayerDist = 4f;

		protected float maxPlayerDist = float.PositiveInfinity;

		protected RaycastHit[] hits;

		protected float sprintMultiplier = 2.25f;

		protected float speed;

		protected float curSpeed;

		private Vector3 serverPosition;

		private float updatePositionThreshold = 0.01f;

		private float previousYRotation;

		private short targetYRotation;

		private Vector3 tempVelocity = Vector3.zero;

		private float syncMovementSpeed = 0.1f;

		private bool freeze = false;

		public virtual void Start()
		{
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Expected O, but got Unknown
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Expected O, but got Unknown
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			if (petCount >= maxPets && maxPets > -1)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			petCount++;
			meshRenderers = ((Component)((Component)this).transform).GetComponentsInChildren<SkinnedMeshRenderer>();
			dropShip = Object.FindObjectOfType<ItemDropship>();
			hp = maxHp;
			agent = ((Component)this).GetComponent<NavMeshAgent>();
			networkObject = ((Component)this).GetComponent<NetworkObject>();
			AudioSource[] components = ((Component)this).GetComponents<AudioSource>();
			foreach (AudioSource val in components)
			{
				if (((Object)val.clip).name == "duck_quacking")
				{
					Log("Quacking Audio Clip found.");
					audioQuacking = val;
					audioQuacking.Play();
				}
				else if (((Object)val.clip).name == "duck_walking")
				{
					Log("Walking Audio Clip found.");
					audioWalking = val;
				}
			}
			audioQuacking = ((Component)this).GetComponent<AudioSource>();
			physicsProp = ((Component)this).GetComponent<PhysicsProp>();
			((GrabbableObject)physicsProp).EnablePhysics(false);
			((GrabbableObject)physicsProp).isHeld = true;
			animator = ((Component)this).GetComponentInChildren<Animator>();
			itemHolder = ((Component)this).transform.GetChild(1);
			interactTrigger = ((Component)itemHolder).gameObject.GetComponent<InteractTrigger>();
			interactTrigger.onInteract = new InteractEvent();
			((UnityEvent<PlayerControllerB>)(object)interactTrigger.onInteract).AddListener((UnityAction<PlayerControllerB>)Interact);
			interactPatter = ((Component)this).transform.GetChild(2);
			InteractTrigger component = ((Component)interactPatter).GetComponent<InteractTrigger>();
			component.onInteract = new InteractEvent();
			((UnityEvent<PlayerControllerB>)(object)component.onInteract).AddListener((UnityAction<PlayerControllerB>)InteractPat);
			if ((Object)(object)itemHolder == (Object)null)
			{
				itemHolder = ((Component)this).transform;
			}
			else
			{
				itemHolder.rotation = Quaternion.Euler(90f, 0f, 0f);
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				Init();
				SyncPosition();
				SyncRotation();
			}
		}

		public virtual void Update()
		{
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			Init();
			if (((NetworkBehaviour)this).IsOwner)
			{
				if (((Behaviour)agent).enabled)
				{
					nextItemCheck -= Time.deltaTime;
					if (nextItemCheck < 0f)
					{
						nextItemCheck = 0f;
					}
					if (nextItemCheck <= 0f)
					{
						UpdateGrabbableItems();
					}
					if ((Object)(object)targetPlayer != (Object)null)
					{
						if (nextSpeedCheck <= 0f)
						{
							speed = targetPlayer.movementSpeed * speedFactor;
							nextSpeedCheck = nextSpeedCheckCooldown;
						}
						else
						{
							nextSpeedCheck -= Time.deltaTime;
							if (nextSpeedCheck < 0f)
							{
								nextSpeedCheck = 0f;
							}
						}
					}
					DoAI();
				}
				SyncPosition();
				SyncRotation();
				Vector3 velocity = agent.velocity;
				SyncSpeedServerRpc(((Vector3)(ref velocity)).magnitude);
			}
			else
			{
				Vector3 position = ((Component)this).transform.position;
				float num = 1f;
				((Component)this).transform.position = new Vector3(Mathf.Lerp(position.x, serverPosition.x, num), Mathf.Lerp(position.y, serverPosition.y, num), Mathf.Lerp(position.z, serverPosition.z, num));
				Transform transform = ((Component)this).transform;
				Quaternion rotation = ((Component)this).transform.rotation;
				float x = ((Quaternion)(ref rotation)).eulerAngles.x;
				float num2 = targetYRotation;
				rotation = ((Component)this).transform.rotation;
				transform.rotation = Quaternion.Euler(x, num2, ((Quaternion)(ref rotation)).eulerAngles.z);
			}
		}

		public void TurnOnRendering()
		{
			SkinnedMeshRenderer[] array = meshRenderers;
			foreach (SkinnedMeshRenderer val in array)
			{
				if (((Renderer)val).forceRenderingOff)
				{
					((Renderer)val).forceRenderingOff = false;
				}
			}
			foreach (GrabbableObject grabbedItem in grabbedItems)
			{
				MeshRenderer component = ((Component)grabbedItem).GetComponent<MeshRenderer>();
				if ((Object)(object)component != (Object)null && ((Renderer)component).forceRenderingOff)
				{
					((Renderer)component).forceRenderingOff = false;
				}
			}
		}

		public abstract void DoAI();

		protected void StartQuacking()
		{
			if ((Object)(object)audioQuacking != (Object)null && !audioQuacking.isPlaying)
			{
				audioQuacking.Play();
			}
		}

		protected bool IsInsideShip()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit[] array = Physics.RaycastAll(((Component)this).transform.position, Vector3.down, 0.2f);
			RaycastHit[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val = array2[i];
				if (((Object)((RaycastHit)(ref val)).transform).name == "ShipInside")
				{
					return true;
				}
			}
			return false;
		}

		protected void Init()
		{
			switch (shipState)
			{
			case ShipState.None:
				if (StartOfRound.Instance.shipHasLanded)
				{
					shipState = ShipState.OnMoon;
					Log("Init on Moon!");
					StartRound(((NetworkBehaviour)this).IsOwner);
				}
				else
				{
					isInsideShip = true;
					shipState = ShipState.InSpace;
					Log("Init in space!");
					EndRound();
				}
				break;
			case ShipState.InSpace:
				if (StartOfRound.Instance.shipHasLanded)
				{
					shipState = ShipState.OnMoon;
					Log("Ship has landed!");
					StartRound(((NetworkBehaviour)this).IsOwner);
				}
				break;
			case ShipState.OnMoon:
				if (StartOfRound.Instance.shipIsLeaving)
				{
					shipState = ShipState.InSpace;
					Log("Ship is leaving!");
					EndRound();
				}
				break;
			}
			NextToBoomBox();
			if (freeze)
			{
				return;
			}
			grabbingCooldown -= Time.deltaTime;
			if (grabbingCooldown < 0f)
			{
				grabbingCooldown = 0f;
			}
			UpdateCollisions();
			isInsideShip = IsInsideShip();
			agent.speed = speed;
			if (isInsideShip && (Object)(object)((Component)this).transform.parent == (Object)null)
			{
				EnterShip();
			}
			else if (!isInsideShip && (Object)(object)((Component)this).transform.parent != (Object)null)
			{
				LeaveShip();
			}
			if (Time.time - lastCheckEnemy >= checkEnemyCooldown)
			{
				lastCheckEnemy = Time.time;
				if (CheckForEnemies())
				{
					StartQuacking();
					lastCheckEnemy = Time.time + 10f;
				}
			}
		}

		protected void EnterShip()
		{
			((Component)this).transform.SetParent(StartOfRound.Instance.elevatorTransform, true);
			Log("Enters ship!");
			OnEnterShip();
		}

		protected void LeaveShip()
		{
			Log("Leaves ship!");
			((Component)this).transform.SetParent((Transform)null, true);
			OnLeaveShip();
		}

		protected void StartRound(bool enableAgent)
		{
			freeze = false;
			((Behaviour)agent).enabled = enableAgent;
			((Behaviour)physicsProp).enabled = false;
			networkObject.SynchronizeTransform = false;
			dropShip = Object.FindObjectOfType<ItemDropship>();
			Log("Start Round!");
			doors = Object.FindObjectsOfType<DoorLock>();
			OnStartRound();
		}

		protected void EndRound()
		{
			Log("End Round!");
			if (isInsideShip)
			{
				freeze = true;
				((Behaviour)agent).enabled = false;
				((Behaviour)physicsProp).enabled = true;
				networkObject.SynchronizeTransform = true;
				OnEndRound();
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		protected virtual void OnEnterShip()
		{
		}

		protected virtual void OnLeaveShip()
		{
		}

		protected virtual void OnStartRound()
		{
		}

		protected virtual void OnEndRound()
		{
		}

		protected bool IsInSight(Transform target)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			bool flag = Physics.Linecast(itemHolder.position, target.position, StartOfRound.Instance.collidersAndRoomMask);
			return !flag;
		}

		protected PlayerControllerB GetClosestPlayer()
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			if (findTargetPlayerIn > 0f && (Object)(object)targetPlayer != (Object)null)
			{
				findTargetPlayerIn -= Time.deltaTime;
				if (findTargetPlayerIn < 0f)
				{
					findTargetPlayerIn = 0f;
				}
				return targetPlayer;
			}
			float num = float.PositiveInfinity;
			PlayerControllerB result = null;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
				if (num2 < num)
				{
					result = val;
					num = num2;
				}
			}
			return result;
		}

		public void UpdateGrabbableItems()
		{
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			nextItemCheck = nextItemCheckCooldown;
			if (grabbableItems == null)
			{
				return;
			}
			grabbableItems.Clear();
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			foreach (GrabbableObject val in array)
			{
				if (!((Object)(object)((Component)val).GetComponent<PetAI>() == (Object)null) || ((Object)val).name.Contains("Apparatus") || (val.itemProperties.twoHanded && !canGrabTwoHanded))
				{
					continue;
				}
				if (((Object)val).name.Contains("RedLocustHive") && !canGrabHive)
				{
					Log("Can't grab Hive");
					continue;
				}
				if ((Object)(object)((Component)val).GetComponent<RagdollGrabbableObject>() != (Object)null && !canGrabPlayers)
				{
					Log("Can't grab Players");
					continue;
				}
				if ((Object)(object)dropShip != (Object)null && !val.isInShipRoom)
				{
					Log("Drop ship: " + ((Object)dropShip).name);
					if (Vector3.Distance(((Component)dropShip).transform.position, ((Component)val).transform.position) <= 5f)
					{
						Log("Skip Item: " + ((Object)val).name);
						continue;
					}
				}
				grabbableItems.Add(val);
			}
		}

		public void UpdateCollisions()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			hits = Physics.BoxCastAll(((Component)this).transform.position, Vector3.one * 2f, ((Component)this).transform.forward, ((Component)this).transform.rotation, 10f);
		}

		public bool CheckForEnemies()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit[] array = hits;
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val = array[i];
				if ((Object)(object)((Component)((RaycastHit)(ref val)).collider).gameObject.GetComponent<EnemyAI>() != (Object)null && (Object)(object)((Component)((RaycastHit)(ref val)).collider).gameObject.GetComponent<PetDuckAI>() == (Object)null)
				{
					return true;
				}
			}
			return false;
		}

		protected GrabbableObject GetClosestItem()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			if (grabbingCooldown > 0f)
			{
				return null;
			}
			GrabbableObject result = null;
			float num = 10f;
			foreach (GrabbableObject grabbableItem in grabbableItems)
			{
				Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(((Component)grabbableItem).transform.position, default(NavMeshHit), 5f, -1);
				if ((Object)(object)grabbableItem != (Object)null && (Object)(object)((Component)grabbableItem).GetComponent<PetDuckAI>() == (Object)null && RoundManager.Instance.GotNavMeshPositionResult && !grabbableItem.isInShipRoom)
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)grabbableItem).transform.position);
					if (num2 <= num && grabbableItem.grabbable && !grabbableItem.isHeld && IsInSight(((Component)grabbableItem).transform))
					{
						num = num2;
						result = grabbableItem;
					}
				}
			}
			return result;
		}

		internal bool IsDoorOpen(DoorLock door)
		{
			FieldInfo field = typeof(DoorLock).GetField("isDoorOpened", BindingFlags.Instance | BindingFlags.NonPublic);
			return (bool)field.GetValue(door);
		}

		public float Angle2D(Plane plane, Vector3 from, Vector3 to, bool signed = false)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = Vector2.op_Implicit(((Plane)(ref plane)).ClosestPointOnPlane(from));
			Vector2 val2 = Vector2.op_Implicit(((Plane)(ref plane)).ClosestPointOnPlane(to));
			float num = Vector2.Angle(val, val2);
			if (signed)
			{
				return num;
			}
			return Mathf.Abs(num);
		}

		public DoorLock GetNextDoor()
		{
			//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)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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)
			if (!canOpenDoors)
			{
				return null;
			}
			DoorLock[] array = doors;
			foreach (DoorLock val in array)
			{
				Vector3 to = ((Component)val).transform.position - ((Component)this).transform.position;
				if (Angle2D(new Plane(Vector3.up, Vector3.zero), ((Component)this).transform.forward, to) <= 45f && Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) <= 2f && !IsDoorOpen(val))
				{
					return val;
				}
			}
			return null;
		}

		public void OpenDoor(DoorLock door)
		{
			Log("Try to open door");
			if (door.isLocked && !door.isPickingLock)
			{
				Log("Door is locked");
				KeyItem val = null;
				foreach (GrabbableObject grabbedItem in grabbedItems)
				{
					val = ((Component)grabbedItem).GetComponent<KeyItem>();
					if ((Object)(object)val != (Object)null)
					{
						Log("Key found");
						break;
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				Log("Door unlocked");
				door.UnlockDoorSyncWithServer();
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
			AnimatedObjectTrigger component = ((Component)door).GetComponent<AnimatedObjectTrigger>();
			component.TriggerAnimationNonPlayer(false, true, false);
			door.OpenDoorAsEnemyServerRpc();
		}

		public void NextToBoomBox()
		{
			//IL_009f: 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)
			if (animator.GetBool("IsWalking"))
			{
				animator.SetBool("IsDancing", false);
				return;
			}
			if (checkForBoombox > 0f)
			{
				checkForBoombox -= Time.deltaTime;
				if (checkForBoombox < 0f)
				{
					checkForBoombox = 0f;
				}
				return;
			}
			checkForBoombox = 2f;
			BoomboxItem[] array = Object.FindObjectsOfType<BoomboxItem>();
			BoomboxItem[] array2 = array;
			foreach (BoomboxItem val in array2)
			{
				float num = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
				Log("Boombox distance: " + num);
				Log("Is Boombox playing? " + val.isPlayingMusic);
				if (val.isPlayingMusic && num <= 5f)
				{
					animator.SetBool("IsDancing", true);
					return;
				}
			}
			animator.SetBool("IsDancing", false);
		}

		protected void Teleport()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val;
			Vector3 val2;
			if (isInFactory)
			{
				val = RoundManager.FindMainEntrancePosition(false, false);
				val2 = RoundManager.FindMainEntrancePosition(false, true);
			}
			else
			{
				val = RoundManager.FindMainEntrancePosition(false, true);
				val2 = RoundManager.FindMainEntrancePosition(false, false);
			}
			if (Vector3.Distance(((Component)this).transform.position, val) > 2f)
			{
				agent.SetDestination(val);
				return;
			}
			Log("Duck is teleporting");
			val = RoundManager.Instance.GetNavMeshPosition(val, default(NavMeshHit), 5f, -1);
			val2 = RoundManager.Instance.GetNavMeshPosition(val2, default(NavMeshHit), 5f, -1);
			((Behaviour)agent).enabled = false;
			((Component)this).transform.position = RoundManager.Instance.GetNavMeshPosition(val2, default(NavMeshHit), 5f, -1);
			((Behaviour)agent).enabled = true;
			isInFactory = !isInFactory;
			targetItem = null;
			TurnOnRendering();
		}

		protected void ChangeParent(NetworkObject networkObject)
		{
			((Component)this).transform.parent = ((Component)networkObject).transform;
		}

		public void SetHP(int hp)
		{
			this.hp = Mathf.Clamp(hp, 0, maxHp);
			if (this.hp <= 0)
			{
				Destroy();
			}
		}

		public void AddHP(int value)
		{
			hp = Mathf.Clamp(hp + value, 0, maxHp);
			if (hp <= 0)
			{
				Destroy();
			}
		}

		public void Destroy()
		{
			OnDying();
			networkObject.Despawn(true);
		}

		public override void OnDestroy()
		{
			petCount--;
		}

		protected virtual void OnDying()
		{
		}

		public void SyncPosition()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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)
			if (Vector3.Distance(serverPosition, ((Component)this).transform.position) > updatePositionThreshold || shipState == ShipState.InSpace)
			{
				serverPosition = ((Component)this).transform.position;
				if (((NetworkBehaviour)this).IsServer)
				{
					UpdatePositionClientRpc(serverPosition);
				}
				else
				{
					UpdatePositionServerRpc(serverPosition);
				}
			}
		}

		[ServerRpc]
		private void UpdatePositionServerRpc(Vector3 newPos)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Invalid comparison between Unknown and I4
			//IL_007e: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Invalid comparison between Unknown and I4
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4287979890u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref newPos);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4287979890u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				UpdatePositionClientRpc(newPos);
			}
		}

		[ClientRpc]
		private void UpdatePositionClientRpc(Vector3 newPos)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Invalid comparison between Unknown and I4
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4287979891u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref newPos);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4287979891u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsOwner)
				{
					serverPosition = newPos;
					OnSyncPositionFromServer(newPos);
				}
			}
		}

		protected virtual void OnSyncPositionFromServer(Vector3 newPos)
		{
		}

		public void SyncRotation()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Quaternion rotation = ((Component)this).transform.rotation;
			targetYRotation = (short)((Quaternion)(ref rotation)).eulerAngles.y;
			if (((NetworkBehaviour)this).IsServer)
			{
				UpdateRotationClientRpc(targetYRotation);
			}
			else
			{
				UpdateRotationServerRpc(targetYRotation);
			}
		}

		[ServerRpc]
		private void UpdateRotationServerRpc(short rotationY)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Invalid comparison between Unknown and I4
			//IL_007e: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3079913700u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, rotationY);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3079913700u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				UpdateRotationClientRpc(rotationY);
			}
		}

		[ClientRpc]
		private void UpdateRotationClientRpc(short rotationY)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Invalid comparison between Unknown and I4
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3079913701u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, rotationY);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3079913701u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					previousYRotation = ((Component)this).transform.eulerAngles.y;
					targetYRotation = rotationY;
					OnSyncRotationFromServer(rotationY);
				}
			}
		}

		protected virtual void OnSyncRotationFromServer(short newYRot)
		{
		}

		protected void GrabItem(NetworkObject networkObject)
		{
			Log("Grabbing " + ((Object)networkObject).name);
			GrabbableObject component = ((Component)networkObject).GetComponent<GrabbableObject>();
			grabbedItems.Add(component);
			targetItem = null;
			component.parentObject = itemHolder;
			component.EnablePhysics(false);
			component.isHeld = true;
			component.hasHitGround = false;
			component.isInFactory = isInFactory;
			interactTrigger.interactable = true;
		}

		protected bool GrabAndSync()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsOwner)
			{
				return false;
			}
			if ((Object)(object)targetItem != (Object)null && grabbedItems.Count < itemCapacity && Vector3.Distance(((Component)this).transform.position, ((Component)targetItem).transform.position) < 0.75f)
			{
				NetworkObject component = ((Component)targetItem).GetComponent<NetworkObject>();
				GrabItemServerRpc(NetworkObjectReference.op_Implicit(component));
				return true;
			}
			return false;
		}

		[ServerRpc]
		private void GrabItemServerRpc(NetworkObjectReference objectRef)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Invalid comparison between Unknown and I4
			//IL_007e: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Invalid comparison between Unknown and I4
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2358561450u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2358561450u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				GrabItemClientRpc(objectRef);
			}
		}

		[ClientRpc]
		private void GrabItemClientRpc(NetworkObjectReference objectRef)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Invalid comparison between Unknown and I4
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(847487220u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 847487220u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkObject val3 = default(NetworkObject);
				if (((NetworkObjectReference)(ref objectRef)).TryGet(ref val3, (NetworkManager)null))
				{
					GrabItem(val3);
				}
				else
				{
					Debug.LogError((object)(((Object)((Component)this).gameObject).name + ": Failed to get network object from network object reference (Grab item RPC)"));
				}
			}
		}

		public void UseItem()
		{
			foreach (GrabbableObject grabbedItem in grabbedItems)
			{
				FlashlightItem component = ((Component)grabbedItem).GetComponent<FlashlightItem>();
				if ((Object)(object)component != (Object)null)
				{
					bool enabled = (((GrabbableObject)component).isBeingUsed = !((GrabbableObject)component).isBeingUsed);
					((Behaviour)component.flashlightBulb).enabled = enabled;
					((Behaviour)component.flashlightBulbGlow).enabled = enabled;
				}
				else
				{
					grabbedItem.UseItemOnClient(true);
				}
			}
			nextItemInteract = Random.Range(30f, 300f);
		}

		[ServerRpc]
		public void UseItemServerRpc()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Invalid comparison between Unknown and I4
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(235856144u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 235856144u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost) || !canUseItem)
			{
				return;
			}
			if (nextItemInteract > 0f)
			{
				nextItemInteract -= Time.deltaTime;
				if (nextItemInteract < 0f)
				{
					nextItemInteract = 0f;
				}
			}
			else
			{
				UseItemClientRpc();
				nextItemInteract = Random.Range(30f, 300f);
			}
		}

		[ClientRpc]
		public void UseItemClientRpc()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Invalid comparison between Unknown and I4
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(235856145u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 235856145u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					UseItem();
				}
			}
		}

		protected void DropItem(NetworkObject networkObject)
		{
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			Log("Dropping " + ((Object)networkObject).name);
			GrabbableObject component = ((Component)networkObject).GetComponent<GrabbableObject>();
			component.parentObject = null;
			if (isInsideShip)
			{
				((Component)component).transform.SetParent(StartOfRound.Instance.elevatorTransform, true);
				component.scrapPersistedThroughRounds = true;
				component.isInShipRoom = true;
				component.isInFactory = false;
				RoundManager instance = RoundManager.Instance;
				instance.scrapCollectedInLevel += component.scrapValue;
				RoundManager.Instance.CollectNewScrapForThisRound(component);
				component.OnBroughtToShip();
				StartOfRound instance2 = StartOfRound.Instance;
				instance2.currentShipItemCount++;
			}
			else
			{
				((Component)component).transform.SetParent(StartOfRound.Instance.propsContainer, true);
				component.scrapPersistedThroughRounds = false;
				component.isInShipRoom = false;
				if (isInFactory)
				{
					component.isInFactory = true;
				}
				else
				{
					component.isInShipRoom = false;
				}
			}
			component.EnablePhysics(true);
			component.fallTime = 0f;
			component.startFallingPosition = ((Component)component).transform.parent.InverseTransformPoint(((Component)component).transform.position);
			Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(((Component)itemHolder).transform.position, default(NavMeshHit), 5f, -1);
			component.targetFloorPosition = ((Component)component).transform.parent.InverseTransformPoint(navMeshPosition);
			component.floorYRot = -1;
			component.EnableItemMeshes(true);
			component.isHeld = false;
			component.isPocketed = false;
			component.heldByPlayerOnServer = false;
			grabbedItems.Remove(component);
			grabbingCooldown = 5f;
			if (grabbedItems.Count == 0)
			{
				interactTrigger.interactable = false;
			}
		}

		protected void DropAndSync(GrabbableObject item)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			NetworkObject component = ((Component)item).GetComponent<NetworkObject>();
			if (!((Object)(object)component == (Object)null))
			{
				DropItemServerRpc(NetworkObjectReference.op_Implicit(component));
			}
		}

		[ServerRpc]
		public void DropItemServerRpc(NetworkObjectReference objectRef)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Invalid comparison between Unknown and I4
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(847487222u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 847487222u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					DropItemClientRpc(objectRef);
				}
			}
		}

		[ClientRpc]
		public void DropItemClientRpc(NetworkObjectReference objectRef)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Invalid comparison between Unknown and I4
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(847487223u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 847487223u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkObject val3 = default(NetworkObject);
				if (((NetworkObjectReference)(ref objectRef)).TryGet(ref val3, (NetworkManager)null))
				{
					DropItem(val3);
				}
				else
				{
					Debug.LogError((object)(((Object)((Component)this).gameObject).name + ": Failed to get network object from network object reference (Drop item RPC)"));
				}
			}
		}

		public void UpdateAnim()
		{
			if (curSpeed == 0f)
			{
				animator.SetBool("IsWalking", false);
				animator.speed = 1f;
				if ((Object)(object)audioWalking != (Object)null && audioWalking.isPlaying)
				{
					audioWalking.Stop();
				}
				return;
			}
			float num = curSpeed / 4.5f;
			audioWalking.pitch = Mathf.Clamp(num, 1f, 2f);
			animator.SetBool("IsWalking", true);
			animator.speed = Mathf.Clamp(num, 1f, num);
			if ((Object)(object)audioWalking != (Object)null && !audioWalking.isPlaying)
			{
				audioWalking.Play();
			}
		}

		[ServerRpc]
		public void SyncSpeedServerRpc(float speed)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Invalid comparison between Unknown and I4
			//IL_007e: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2358561458u, val, (RpcDelivery)0);
				BytePacker.WriteValuePacked(val2, speed);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2358561458u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SyncSpeedClientRpc(speed);
			}
		}

		[ClientRpc]
		public void SyncSpeedClientRpc(float speed)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Invalid comparison between Unknown and I4
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(847487229u, val, (RpcDelivery)0);
					BytePacker.WriteValuePacked(val2, speed);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 847487229u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					curSpeed = speed;
					UpdateAnim();
				}
			}
		}

		public void Pat(PlayerControllerB player)
		{
			animator.SetTrigger("Pat");
			audioQuacking.Play();
			targetPlayer = player;
			findTargetPlayerIn = 30f;
		}

		[ServerRpc]
		public void PatServerRpc(NetworkObjectReference objectRef)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Invalid comparison between Unknown and I4
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2358561456u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2358561456u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					PatClientRpc(objectRef);
				}
			}
		}

		[ClientRpc]
		public void PatClientRpc(NetworkObjectReference objectRef)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Invalid comparison between Unknown and I4
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(847487227u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 847487227u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkObject val3 = default(NetworkObject);
				if (((NetworkObjectReference)(ref objectRef)).TryGet(ref val3, (NetworkManager)null))
				{
					Pat(((Component)val3).GetComponent<PlayerControllerB>());
				}
				else
				{
					Debug.LogError((object)(((Object)((Component)this).gameObject).name + ": Failed to get network object from network object reference (Grab item RPC)"));
				}
			}
		}

		public virtual void OnHit(int newHP)
		{
			hp = newHP;
			animator.SetTrigger("Hit");
			if (hp <= 0)
			{
				animator.SetBool("IsDead", true);
				((Component)itemHolder).gameObject.SetActive(false);
				((Component)interactPatter).gameObject.SetActive(false);
				Object.Destroy((Object)(object)this);
			}
		}

		public bool Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			Log("Duck got hit.");
			HitServerRpc(force);
			return true;
		}

		[ServerRpc(RequireOwnership = false)]
		public void HitServerRpc(int force)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Invalid comparison between Unknown and I4
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(847487300u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, force);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 847487300u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					int num = (hittable ? (hp - force) : hp);
					HitClientRpc(Mathf.Clamp(num, 0, maxHp));
				}
			}
		}

		[ClientRpc]
		public void HitClientRpc(int newHP)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Invalid comparison between Unknown and I4
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(847487301u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, newHP);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 847487301u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					OnHit(newHP);
				}
			}
		}

		public virtual void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot, int noiseID)
		{
		}

		public virtual void Interact(PlayerControllerB player)
		{
			DropAndSync(grabbedItems[grabbedItems.Count - 1]);
		}

		public virtual void InteractPat(PlayerControllerB player)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			PatServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)player).NetworkObject));
		}

		public void SetScrapValue(float value)
		{
			scrapValue = value;
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_PetAI()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Expected O, but got Unknown
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(4287979890u, new RpcReceiveHandler(__rpc_handler_4287979890));
			NetworkManager.__rpc_func_table.Add(4287979891u, new RpcReceiveHandler(__rpc_handler_4287979891));
			NetworkManager.__rpc_func_table.Add(3079913700u, new RpcReceiveHandler(__rpc_handler_3079913700));
			NetworkManager.__rpc_func_table.Add(3079913701u, new RpcReceiveHandler(__rpc_handler_3079913701));
			NetworkManager.__rpc_func_table.Add(2358561450u, new RpcReceiveHandler(__rpc_handler_2358561450));
			NetworkManager.__rpc_func_table.Add(847487220u, new RpcReceiveHandler(__rpc_handler_847487220));
			NetworkManager.__rpc_func_table.Add(847487222u, new RpcReceiveHandler(__rpc_handler_847487222));
			NetworkManager.__rpc_func_table.Add(847487223u, new RpcReceiveHandler(__rpc_handler_847487223));
			NetworkManager.__rpc_func_table.Add(2358561458u, new RpcReceiveHandler(__rpc_handler_2358561458));
			NetworkManager.__rpc_func_table.Add(847487229u, new RpcReceiveHandler(__rpc_handler_847487229));
			NetworkManager.__rpc_func_table.Add(2358561456u, new RpcReceiveHandler(__rpc_handler_2358561456));
			NetworkManager.__rpc_func_table.Add(847487227u, new RpcReceiveHandler(__rpc_handler_847487227));
			NetworkManager.__rpc_func_table.Add(847487300u, new RpcReceiveHandler(__rpc_handler_847487300));
			NetworkManager.__rpc_func_table.Add(847487301u, new RpcReceiveHandler(__rpc_handler_847487301));
			NetworkManager.__rpc_func_table.Add(235856144u, new RpcReceiveHandler(__rpc_handler_235856144));
			NetworkManager.__rpc_func_table.Add(235856145u, new RpcReceiveHandler(__rpc_handler_235856145));
		}

		private static void __rpc_handler_4287979890(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				Vector3 newPos = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref newPos);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)1;
				((PetAI)(object)target).UpdatePositionServerRpc(newPos);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4287979891(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 newPos = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref newPos);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)2;
				((PetAI)(object)target).UpdatePositionClientRpc(newPos);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3079913700(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//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_005f: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				short rotationY = default(short);
				ByteUnpacker.ReadValueBitPacked(reader, ref rotationY);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)1;
				((PetAI)(object)target).UpdateRotationServerRpc(rotationY);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3079913701(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0019: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				short rotationY = default(short);
				ByteUnpacker.ReadValueBitPacked(reader, ref rotationY);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)2;
				((PetAI)(object)target).UpdateRotationClientRpc(rotationY);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2358561450(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				NetworkObjectReference objectRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)1;
				((PetAI)(object)target).GrabItemServerRpc(objectRef);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_847487220(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference objectRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)2;
				((PetAI)(object)target).GrabItemClientRpc(objectRef);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_847487222(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference objectRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)1;
				((PetAI)(object)target).DropItemServerRpc(objectRef);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_847487223(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference objectRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)2;
				((PetAI)(object)target).DropItemClientRpc(objectRef);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2358561458(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//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_005f: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				float num = default(float);
				ByteUnpacker.ReadValuePacked(reader, ref num);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)1;
				((PetAI)(object)target).SyncSpeedServerRpc(num);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_847487229(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0019: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float num = default(float);
				ByteUnpacker.ReadValuePacked(reader, ref num);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)2;
				((PetAI)(object)target).SyncSpeedClientRpc(num);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2358561456(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference objectRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValue<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)1;
				((PetAI)(object)target).PatServerRpc(objectRef);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_847487227(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference objectRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValue<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)2;
				((PetAI)(object)target).PatClientRpc(objectRef);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_847487300(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int force = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref force);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)1;
				((PetAI)(object)target).HitServerRpc(force);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_847487301(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0019: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int newHP = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref newHP);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)2;
				((PetAI)(object)target).HitClientRpc(newHP);
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_235856144(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)1;
				((PetAI)(object)target).UseItemServerRpc();
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_235856145(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0020: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)2;
				((PetAI)(object)target).UseItemClientRpc();
				((NetworkBehaviour)(PetAI)(object)target).__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		public virtual void Log(string message)
		{
			if (mls != null)
			{
				mls.LogInfo((object)("[PetAI] " + message));
			}
		}
	}
	[RequireComponent(typeof(NavMeshAgent))]
	internal class PetDuckAI : PetAI
	{
		protected enum DuckState
		{
			LookingAround,
			Following,
			MovingToItem,
			MovingToEntrance,
			Searching
		}

		public static List<(float, Material)> materials = new List<(float, Material)>();

		private int shaderID;

		private float nextFlipCooldown = 60f;

		private float nextFlip = 120f;

		protected DuckState duckState;

		public override void Start()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			base.Start();
			string[] obj = new string[8]
			{
				"Is pet duck owner: ",
				((NetworkBehaviour)this).IsOwner.ToString(),
				"\nSpeed: ",
				agent.speed.ToString(),
				"\nVelocity: ",
				null,
				null,
				null
			};
			Vector3 velocity = agent.velocity;
			obj[5] = ((object)(Vector3)(ref velocity)).ToString();
			obj[6] = "\nAcceleration: ";
			obj[7] = agent.acceleration.ToString();
			Log(string.Concat(obj));
			if (((NetworkBehaviour)this).IsServer)
			{
				float num = 0f;
				foreach (var material in materials)
				{
					num += material.Item1;
				}
				int num2 = -1;
				float num3 = 0f;
				float num4 = Random.Range(0f, 1f);
				foreach (var material2 in materials)
				{
					num2++;
					float num5 = material2.Item1 / num;
					if (num4 < num5 + num3)
					{
						break;
					}
					num3 += num5;
				}
				Log("Shader count: " + materials.Count);
				Log("sum: " + num);
				Log("r: " + num4);
				Log("i: " + num2);
				shaderID = num2;
				Log("sumP: " + num3);
			}
			ChangeShaderServerRpc();
		}

		public override void Update()
		{
			base.Update();
			if (nextFlip <= 0f)
			{
				DoFlip();
				nextFlip = nextFlipCooldown;
			}
			else
			{
				nextFlip -= Time.deltaTime;
			}
		}

		public override void DoAI()
		{
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: 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_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)GameNetworkManager.Instance == (Object)null)
			{
				return;
			}
			if (grabbedItems.Count > 0 && isInsideShip)
			{
				DropAndSync(grabbedItems[grabbedItems.Count - 1]);
			}
			targetPlayer = GetClosestPlayer();
			if ((grabbedItems.Count < itemCapacity) & ((Object)(object)targetItem == (Object)null))
			{
				targetItem = GetClosestItem();
				if (!((Object)(object)targetItem != (Object)null))
				{
				}
			}
			if ((Object)(object)targetPlayer == (Object)null)
			{
				return;
			}
			DoorLock nextDoor = GetNextDoor();
			if ((Object)(object)nextDoor != (Object)null)
			{
				OpenDoor(nextDoor);
			}
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)targetPlayer).transform.position);
			if ((Object)(object)targetItem != (Object)null)
			{
				duckState = DuckState.MovingToItem;
			}
			else if ((targetPlayer.isInsideFactory && !isInFactory) || (!targetPlayer.isInsideFactory && isInFactory))
			{
				duckState = DuckState.MovingToEntrance;
			}
			else if (num <= minPlayerDist)
			{
				duckState = DuckState.LookingAround;
			}
			else if (num <= maxPlayerDist)
			{
				duckState = DuckState.Following;
			}
			else
			{
				duckState = DuckState.Searching;
			}
			switch (duckState)
			{
			case DuckState.LookingAround:
				agent.destination = ((Component)this).transform.position;
				break;
			case DuckState.Following:
				if (agent.isOnNavMesh)
				{
					if (Vector3.Distance(((Component)this).transform.position, ((Component)targetPlayer).transform.position) > 3f)
					{
						Vector3 val = ((Component)targetPlayer).transform.position - ((Component)this).transform.position;
						Vector3 normalized = ((Vector3)(ref val)).normalized;
						destination = ((Component)targetPlayer).transform.position - normalized * 1.5f;
					}
					else
					{
						destination = ((Component)this).transform.position;
					}
					if (Vector3.Distance(((Component)this).transform.position, destination) >= 10f)
					{
						agent.speed = speed * sprintMultiplier;
					}
					agent.SetDestination(destination);
				}
				break;
			case DuckState.MovingToItem:
				if (targetItem.isHeld)
				{
					targetItem = null;
					return;
				}
				if (!GrabAndSync())
				{
					agent.SetDestination(((Component)targetItem).transform.position);
				}
				break;
			case DuckState.MovingToEntrance:
				Teleport();
				break;
			}
			UseItemServerRpc();
		}

		public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot, int noiseID)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = noisePosition;
			Log("Noise position: " + ((object)(Vector3)(ref val)).ToString());
			audioQuacking.Play();
			if (((NetworkBehaviour)this).IsOwner && ((Behaviour)agent).enabled && agent.isOnNavMesh)
			{
				agent.SetDestination(noisePosition);
			}
		}

		public void DoFlip()
		{
			animator.SetTrigger("Flip");
		}

		public void ChangeShader(int shaderID)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			this.shaderID = shaderID;
			Log("ShaderID: " + shaderID);
			Material item = materials[shaderID].Item2;
			((Renderer)meshRenderers[0]).material = item;
			if (((Object)item).name == "DuckShader Gold")
			{
				Log("Golden Duck!!!");
				HDAdditionalLightData val = ((Component)this).gameObject.AddComponent<HDAdditionalLightData>();
				Light component = ((Component)this).gameObject.GetComponent<Light>();
				component.intensity = 100f;
				component.color = new Color(1f, 0.75f, 0.5f, 1f);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void ChangeShaderServerRpc()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Invalid comparison between Unknown and I4
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(Ser