Decompiled source of CozyCats v1.1.0

CozyCats.dll

Decompiled 9 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CozyCats.NetcodePatcher;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CozyCats")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+08f2fecca32f247a8052bf8477cf4a8240d31656")]
[assembly: AssemblyProduct("CozyCats")]
[assembly: AssemblyTitle("CozyCats")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CozyCats
{
	internal static class CatAssets
	{
		public static GameObject CatModel;

		public static AudioClip[] Meows = (AudioClip[])(object)new AudioClip[0];

		public static AudioClip[] Purrs = (AudioClip[])(object)new AudioClip[0];

		public static bool Load(string path)
		{
			if (!File.Exists(path))
			{
				return false;
			}
			AssetBundle val = AssetBundle.LoadFromFile(path);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			CatModel = val.LoadAsset<GameObject>("CatModel");
			AudioClip[] source = val.LoadAllAssets<AudioClip>();
			Meows = source.Where((AudioClip c) => ((Object)c).name.StartsWith("meow")).ToArray();
			Purrs = source.Where((AudioClip c) => ((Object)c).name.StartsWith("purr")).ToArray();
			Plugin.Log.LogInfo((object)$"Loaded cat model: {(Object)(object)CatModel != (Object)null}, {Meows.Length} meows, {Purrs.Length} purrs");
			return (Object)(object)CatModel != (Object)null;
		}
	}
	internal class CatConfig
	{
		public readonly ConfigEntry<int> MaxCatsPerMoon;

		public readonly ConfigEntry<float> FirstCatChance;

		public readonly ConfigEntry<float> SecondCatChance;

		public readonly ConfigEntry<float> ModelScale;

		public readonly ConfigEntry<bool> AmbientMeows;

		public readonly ConfigEntry<string> SpecialCats;

		public readonly ConfigEntry<int> RescueBounty;

		public CatConfig(ConfigFile cfg)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			MaxCatsPerMoon = cfg.Bind<int>("Spawning", "MaxCatsPerMoon", 2, new ConfigDescription("Most cats that can show up in one facility.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 5), Array.Empty<object>()));
			FirstCatChance = cfg.Bind<float>("Spawning", "FirstCatChance", 0.6f, new ConfigDescription("Chance (0-1) that at least one cat is hiding in the facility.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			SecondCatChance = cfg.Bind<float>("Spawning", "ExtraCatChance", 0.25f, new ConfigDescription("Chance (0-1) for each additional cat after the first.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			ModelScale = cfg.Bind<float>("Visuals", "ModelScale", 1f, new ConfigDescription("Size multiplier for cats. Requires restart.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>()));
			SpecialCats = cfg.Bind<string>("Cats", "SpecialCats", "Strider, Black, Yellow; Peaches, Peach, Olive", "Your own named cats, each as rare as any other name. Separate cats with ';' and fields with ','.\nFormat: Name, FurColour, EyeColour[, CoatLabel shown when scanned]\nColours: #RRGGBB or a preset: Ginger, Black, White, Grey, Cream, Chocolate, Silver, Blue, Fawn, Peach, Green, Yellow, Amber, Copper, Hazel, Olive.\nOnly the host's list matters in multiplayer. Strider and Peaches are the original two; keep them if you like.");
			RescueBounty = cfg.Bind<int>("Rewards", "RescueBounty", 100, new ConfigDescription("Credits paid to the crew, once per cat, the first time it's brought into the ship. 0 turns it off.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>()));
			AmbientMeows = cfg.Bind<bool>("Sounds", "AmbientMeows", true, "Cats that are set down meow softly every few minutes. Monsters can never hear them.");
		}
	}
	public class CatItem : GrabbableObject
	{
		private const byte PoseIdle = 0;

		private const byte PoseSit = 1;

		private const byte PoseLoaf = 2;

		private const byte PoseHeld = 3;

		private static readonly int PoseHash = Animator.StringToHash("Pose");

		private static readonly int BlinkHash = Animator.StringToHash("Blink");

		private static readonly int TwitchLHash = Animator.StringToHash("TwitchL");

		private static readonly int TwitchRHash = Animator.StringToHash("TwitchR");

		private static readonly int MeowHash = Animator.StringToHash("Meow");

		private static Shader litShader;

		private static Material pupilMat;

		private static Material pinkMat;

		private readonly NetworkVariable<int> netSeed = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private readonly NetworkVariable<byte> netPose = new NetworkVariable<byte>((byte)2, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private readonly NetworkVariable<FixedString128Bytes> netIdentity = new NetworkVariable<FixedString128Bytes>(default(FixedString128Bytes), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private readonly NetworkVariable<bool> netRescued = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private Animator animator;

		private AudioSource audioSource;

		private ScanNodeProperties scanNode;

		private Material furMat;

		private Material eyeMat;

		private Transform model;

		private BoxCollider bodyCollider;

		private Vector3 modelBaseScale;

		private Vector3 colliderBaseCenter;

		private Vector3 colliderBaseSize;

		private Vector3 modelBasePos;

		private Quaternion modelBaseRot;

		private float size = 1f;

		private AudioClip grabClip;

		private AudioClip dropClip;

		private AudioClip purrClip;

		private AudioSource purrSource;

		private const float HeldMeowVolume = 0.27f;

		private const float AmbientMeowVolume = 0.18f;

		private const float HeldPurrVolume = 0.156f;

		public static Quaternion HeldRot = Quaternion.Euler(312.4f, 12.8f, 321.4f);

		public static Vector3 HeldShift = new Vector3(-0.034f, -0.039f, -0.166f);

		private bool visualsReady;

		private bool hasMeowTrigger;

		private int pendingSeed;

		private bool loadedFromSave;

		private float poseTimer;

		private float blinkTimer;

		private float twitchTimer;

		private float ambientMeowTimer;

		private float meowCooldown;

		public Vector3 HeldPivot => new Vector3(0f, 0.2f * modelBaseScale.y * size, 0f);

		public string CatName { get; private set; } = "your cat";

		public int PendingBountyDisplay { get; set; }

		private void Awake()
		{
			Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Object)((Component)componentsInChildren[i]).gameObject).hideFlags = (HideFlags)0;
			}
		}

		public override void Start()
		{
			((GrabbableObject)this).Start();
			EnsureVisuals();
			poseTimer = Random.Range(10f, 30f);
			blinkTimer = Random.Range(1f, 5f);
			twitchTimer = Random.Range(8f, 30f);
			ambientMeowTimer = Random.Range(60f, 180f);
			ApplyLooks(netSeed.Value);
		}

		public override void OnNetworkSpawn()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			((NetworkBehaviour)this).OnNetworkSpawn();
			if (((NetworkBehaviour)this).IsServer)
			{
				if (netSeed.Value == 0)
				{
					netSeed.Value = ((pendingSeed != 0) ? pendingSeed : CatLooks.NewSeed());
				}
				netIdentity.Value = new FixedString128Bytes(CatLooks.ResolveIdentity(netSeed.Value));
				if (loadedFromSave)
				{
					netRescued.Value = true;
				}
			}
			NetworkVariable<int> obj = netSeed;
			obj.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<int>(OnSeedChanged));
			NetworkVariable<FixedString128Bytes> obj2 = netIdentity;
			obj2.OnValueChanged = (OnValueChangedDelegate<FixedString128Bytes>)(object)Delegate.Combine((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<FixedString128Bytes>(OnIdentityChanged));
			ApplyLooks(netSeed.Value);
		}

		public override void OnNetworkDespawn()
		{
			NetworkVariable<int> obj = netSeed;
			obj.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Remove((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<int>(OnSeedChanged));
			NetworkVariable<FixedString128Bytes> obj2 = netIdentity;
			obj2.OnValueChanged = (OnValueChangedDelegate<FixedString128Bytes>)(object)Delegate.Remove((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<FixedString128Bytes>(OnIdentityChanged));
			((NetworkBehaviour)this).OnNetworkDespawn();
		}

		private void OnSeedChanged(int _, int seed)
		{
			ApplyLooks(seed);
		}

		private void OnIdentityChanged(FixedString128Bytes _, FixedString128Bytes __)
		{
			ApplyLooks(netSeed.Value);
		}

		private void EnsureVisuals()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			if (visualsReady)
			{
				return;
			}
			visualsReady = true;
			animator = ((Component)this).GetComponentInChildren<Animator>();
			audioSource = ((Component)this).GetComponent<AudioSource>();
			Transform obj = ((Component)this).transform.Find("Purr");
			purrSource = ((obj != null) ? ((Component)obj).GetComponent<AudioSource>() : null);
			scanNode = ((Component)this).GetComponentInChildren<ScanNodeProperties>();
			model = ((Component)this).transform.Find("Model");
			if ((Object)(object)model != (Object)null)
			{
				modelBaseScale = model.localScale;
				modelBasePos = model.localPosition;
				modelBaseRot = model.localRotation;
			}
			bodyCollider = ((Component)this).GetComponent<BoxCollider>();
			if ((Object)(object)bodyCollider != (Object)null)
			{
				colliderBaseCenter = bodyCollider.center;
				colliderBaseSize = bodyCollider.size;
			}
			if ((Object)(object)animator != (Object)null)
			{
				animator.cullingMode = (AnimatorCullingMode)1;
				AnimatorControllerParameter[] parameters = animator.parameters;
				for (int i = 0; i < parameters.Length; i++)
				{
					if (parameters[i].nameHash == MeowHash)
					{
						hasMeowTrigger = true;
					}
				}
			}
			if (litShader == null)
			{
				litShader = Shader.Find("HDRP/Lit");
			}
			if ((Object)(object)litShader == (Object)null)
			{
				return;
			}
			if (pupilMat == null)
			{
				pupilMat = MakeMat(new Color(0.02f, 0.02f, 0.02f), 0.7f);
			}
			if (pinkMat == null)
			{
				pinkMat = MakeMat(new Color(0.95f, 0.55f, 0.6f), 0.2f);
			}
			furMat = MakeMat(Color.white, 0f);
			eyeMat = MakeMat(Color.green, 0.75f);
			SkinnedMeshRenderer componentInChildren = ((Component)this).GetComponentInChildren<SkinnedMeshRenderer>();
			if (!((Object)(object)componentInChildren == (Object)null))
			{
				Material[] sharedMaterials = ((Renderer)componentInChildren).sharedMaterials;
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					string text = (((Object)(object)sharedMaterials[j] != (Object)null) ? ((Object)sharedMaterials[j]).name : "");
					sharedMaterials[j] = (text.Contains("Eye") ? eyeMat : (text.Contains("Pupil") ? pupilMat : (text.Contains("Pink") ? pinkMat : furMat)));
				}
				((Renderer)componentInChildren).sharedMaterials = sharedMaterials;
			}
		}

		private static Material MakeMat(Color c, float smoothness)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			Material val = new Material(litShader);
			val.SetColor("_BaseColor", c);
			val.SetFloat("_Smoothness", smoothness);
			return val;
		}

		private void ApplyLooks(int seed)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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_012f: 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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			if (seed != 0)
			{
				EnsureVisuals();
				CatLooks catLooks = new CatLooks(seed, ((object)netIdentity.Value/*cast due to .constrained prefix*/).ToString());
				CatName = catLooks.Name;
				size = catLooks.Size;
				Item[] soundSources = CatRegistry.SoundSources;
				Item val = ((soundSources.Length != 0) ? soundSources[catLooks.SoundRoll % soundSources.Length] : null);
				grabClip = val?.grabSFX;
				dropClip = val?.dropSFX;
				purrClip = ((CatAssets.Purrs.Length != 0) ? CatAssets.Purrs[catLooks.SoundRoll / 7 % CatAssets.Purrs.Length] : null);
				if ((Object)(object)furMat != (Object)null)
				{
					furMat.SetColor("_BaseColor", catLooks.Fur);
				}
				if ((Object)(object)eyeMat != (Object)null)
				{
					eyeMat.SetColor("_BaseColor", catLooks.Eye);
				}
				if ((Object)(object)model != (Object)null)
				{
					model.localScale = modelBaseScale * catLooks.Size;
				}
				if ((Object)(object)bodyCollider != (Object)null)
				{
					bodyCollider.center = colliderBaseCenter * catLooks.Size;
					bodyCollider.size = colliderBaseSize * catLooks.Size;
				}
				if ((Object)(object)scanNode != (Object)null)
				{
					scanNode.headerText = CatName;
					scanNode.subText = catLooks.FurName + " cat - not for sale";
				}
				base.customGrabTooltip = "Pick up " + CatName + " : [E]";
			}
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			float deltaTime = Time.deltaTime;
			meowCooldown -= deltaTime;
			if (((NetworkBehaviour)this).IsServer && !base.isHeld && !base.isHeldByEnemy && base.reachedFloorTarget)
			{
				poseTimer -= deltaTime;
				if (poseTimer <= 0f)
				{
					poseTimer = Random.Range(25f, 70f);
					netPose.Value = PickRestingPose(netPose.Value);
				}
				if (Plugin.Cfg.AmbientMeows.Value)
				{
					ambientMeowTimer -= deltaTime;
					if (ambientMeowTimer <= 0f)
					{
						ambientMeowTimer = Random.Range(60f, 180f);
						if (CatAssets.Meows.Length != 0)
						{
							MeowClientRpc(Random.Range(0, CatAssets.Meows.Length), 0.18f);
						}
					}
				}
			}
			UpdatePurr(deltaTime);
			if (!((Object)(object)animator == (Object)null))
			{
				animator.SetInteger(PoseHash, (base.isHeld || base.isHeldByEnemy) ? 3 : netPose.Value);
				blinkTimer -= deltaTime;
				if (blinkTimer <= 0f)
				{
					blinkTimer = Random.Range(2.5f, 7f);
					animator.SetTrigger(BlinkHash);
				}
				twitchTimer -= deltaTime;
				if (twitchTimer <= 0f)
				{
					twitchTimer = Random.Range(10f, 40f);
					animator.SetTrigger((Random.value < 0.5f) ? TwitchLHash : TwitchRHash);
				}
			}
		}

		private void UpdatePurr(float dt)
		{
			if (!((Object)(object)purrSource == (Object)null) && !((Object)(object)purrClip == (Object)null))
			{
				float num = (base.isHeld ? 0.156f : 0f);
				purrSource.volume = Mathf.MoveTowards(purrSource.volume, num, dt * 0.156f / 1.5f);
				if (num > 0f && !purrSource.isPlaying)
				{
					purrSource.clip = purrClip;
					purrSource.time = Random.Range(0f, purrClip.length * 0.5f);
					purrSource.Play();
				}
				else if (num == 0f && purrSource.isPlaying && purrSource.volume <= 0f)
				{
					purrSource.Stop();
				}
			}
		}

		private static byte PickRestingPose(byte current)
		{
			byte b;
			do
			{
				b = (byte)Random.Range(0, 3);
			}
			while (b == current && Random.value < 0.7f);
			return b;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown && !(meowCooldown > 0f) && CatAssets.Meows.Length != 0)
			{
				meowCooldown = 1.2f;
				MeowServerRpc(Random.Range(0, CatAssets.Meows.Length));
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void MeowServerRpc(int clip)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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 val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1054263291u, val2, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, clip);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 1054263291u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					MeowClientRpc(clip, 0.27f);
				}
			}
		}

		[ClientRpc]
		private void MeowClientRpc(int clip, float volume)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_008a: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2810453604u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, clip);
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref volume, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 2810453604u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (CatAssets.Meows.Length != 0 && !((Object)(object)audioSource == (Object)null))
			{
				audioSource.pitch = Random.Range(0.92f, 1.1f);
				audioSource.PlayOneShot(CatAssets.Meows[clip % CatAssets.Meows.Length], volume);
				if (hasMeowTrigger)
				{
					animator.SetTrigger(MeowHash);
				}
			}
		}

		public override void LateUpdate()
		{
			//IL_0078: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_0030: 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_0045: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_0061: 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)
			((GrabbableObject)this).LateUpdate();
			if (!((Object)(object)model == (Object)null))
			{
				if (base.isHeld)
				{
					Vector3 heldPivot = HeldPivot;
					model.localRotation = HeldRot * modelBaseRot;
					model.localPosition = heldPivot + HeldRot * (modelBasePos - heldPivot) + HeldShift;
				}
				else
				{
					model.localRotation = modelBaseRot;
					model.localPosition = modelBasePos;
				}
			}
		}

		public override void PlayDropSFX()
		{
			if ((Object)(object)dropClip != (Object)null && (Object)(object)audioSource != (Object)null)
			{
				audioSource.PlayOneShot(dropClip);
				WalkieTalkie.TransmitOneShotAudio(audioSource, dropClip, 1f);
			}
			base.hasHitGround = true;
		}

		public override void OnBroughtToShip()
		{
			((GrabbableObject)this).OnBroughtToShip();
			if (!netRescued.Value)
			{
				if (((NetworkBehaviour)this).IsServer)
				{
					TryRescue();
				}
				else
				{
					RescueServerRpc();
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void RescueServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3129776640u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 3129776640u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					TryRescue();
				}
			}
		}

		private void TryRescue()
		{
			if (netRescued.Value || StartOfRound.Instance.inShipPhase || !InShip())
			{
				return;
			}
			netRescued.Value = true;
			int value = Plugin.Cfg.RescueBounty.Value;
			if (value > 0)
			{
				Terminal val = Object.FindObjectOfType<Terminal>();
				if (!((Object)(object)val == (Object)null))
				{
					val.groupCredits += value;
					val.SyncGroupCreditsClientRpc(val.groupCredits, val.numberOfItemsInDropship);
					Plugin.Log.LogInfo((object)$"{CatName} rescued: +${value} (credits now {val.groupCredits})");
					RescuedClientRpc(value);
				}
			}
		}

		private bool InShip()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			if (base.isInShipRoom || ((Object)(object)base.playerHeldBy != (Object)null && base.playerHeldBy.isInHangarShipRoom))
			{
				return true;
			}
			Bounds bounds = StartOfRound.Instance.shipInnerRoomBounds.bounds;
			return ((Bounds)(ref bounds)).Contains(((Component)this).transform.position);
		}

		[ClientRpc]
		private void RescuedClientRpc(int bounty)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1878939114u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, bounty);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 1878939114u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				PendingBountyDisplay = bounty;
				HUDManager instance = HUDManager.Instance;
				if (instance != null)
				{
					instance.AddNewScrapFoundToDisplay((GrabbableObject)(object)this);
				}
			}
		}

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			if ((Object)(object)grabClip != (Object)null && (Object)(object)audioSource != (Object)null)
			{
				audioSource.PlayOneShot(grabClip, 0.8f);
			}
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
			if (((NetworkBehaviour)this).IsServer)
			{
				poseTimer = Random.Range(1.5f, 4f);
			}
		}

		public override int GetItemDataToSave()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.RoundToInt(Mathf.Repeat(((Component)this).transform.eulerAngles.y, 360f) / 2f) % 180;
			return (netSeed.Value & 0x3FFFFF) | (num << 22);
		}

		public override void LoadItemSaveData(int saveData)
		{
			((GrabbableObject)this).LoadItemSaveData(saveData);
			pendingSeed = saveData & 0x3FFFFF;
			loadedFromSave = true;
			float num = (float)((saveData >> 22) & 0xFF) * 2f;
			base.floorYRot = Mathf.RoundToInt(Mathf.Repeat(num - 90f - (float)base.itemProperties.floorYOffset, 360f));
		}

		protected override void __initializeVariables()
		{
			if (netSeed == null)
			{
				throw new Exception("CatItem.netSeed cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)netSeed).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)netSeed, "netSeed");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)netSeed);
			if (netPose == null)
			{
				throw new Exception("CatItem.netPose cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)netPose).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)netPose, "netPose");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)netPose);
			if (netIdentity == null)
			{
				throw new Exception("CatItem.netIdentity cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)netIdentity).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)netIdentity, "netIdentity");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)netIdentity);
			if (netRescued == null)
			{
				throw new Exception("CatItem.netRescued cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)netRescued).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)netRescued, "netRescued");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)netRescued);
			((GrabbableObject)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1054263291u, new RpcReceiveHandler(__rpc_handler_1054263291), "MeowServerRpc");
			((NetworkBehaviour)this).__registerRpc(2810453604u, new RpcReceiveHandler(__rpc_handler_2810453604), "MeowClientRpc");
			((NetworkBehaviour)this).__registerRpc(3129776640u, new RpcReceiveHandler(__rpc_handler_3129776640), "RescueServerRpc");
			((NetworkBehaviour)this).__registerRpc(1878939114u, new RpcReceiveHandler(__rpc_handler_1878939114), "RescuedClientRpc");
			((GrabbableObject)this).__initializeRpcs();
		}

		private static void __rpc_handler_1054263291(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int clip = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref clip);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CatItem)(object)target).MeowServerRpc(clip);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2810453604(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0042: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int clip = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref clip);
				float volume = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref volume, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CatItem)(object)target).MeowClientRpc(clip, volume);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3129776640(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CatItem)(object)target).RescueServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1878939114(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int bounty = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref bounty);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CatItem)(object)target).RescuedClientRpc(bounty);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "CatItem";
		}
	}
	internal readonly struct CatLooks
	{
		private class SpecialCat
		{
			public string Name;

			public string CoatLabel;

			public Color Fur;

			public Color Eye;

			public string Encode()
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				return Name + "|" + ColorUtility.ToHtmlStringRGB(Fur) + "|" + ColorUtility.ToHtmlStringRGB(Eye) + "|" + CoatLabel;
			}
		}

		public const int SeedBits = 22;

		public const int SeedMask = 4194303;

		private static readonly (string name, Color color)[] Furs = new(string, Color)[9]
		{
			("Ginger", new Color(0.85f, 0.45f, 0.15f)),
			("Black", new Color(0.07f, 0.07f, 0.08f)),
			("White", new Color(0.8f, 0.79f, 0.76f)),
			("Grey", new Color(0.46f, 0.47f, 0.5f)),
			("Cream", new Color(0.82f, 0.7f, 0.52f)),
			("Chocolate", new Color(0.38f, 0.24f, 0.15f)),
			("Silver", new Color(0.62f, 0.64f, 0.67f)),
			("Blue", new Color(0.38f, 0.43f, 0.51f)),
			("Fawn", new Color(0.78f, 0.62f, 0.45f))
		};

		private static readonly (string name, Color color)[] Eyes = new(string, Color)[6]
		{
			("Green", new Color(0.45f, 0.8f, 0.2f)),
			("Yellow", new Color(0.95f, 0.8f, 0.15f)),
			("Amber", new Color(0.95f, 0.55f, 0.1f)),
			("Blue", new Color(0.3f, 0.6f, 0.95f)),
			("Copper", new Color(0.8f, 0.4f, 0.15f)),
			("Hazel", new Color(0.6f, 0.62f, 0.25f))
		};

		private static readonly (string name, Color color)[] ExtraColors = new(string, Color)[2]
		{
			("Peach", new Color(0.86f, 0.63f, 0.45f)),
			("Olive", new Color(0.5f, 0.6f, 0.22f))
		};

		private static readonly string[] BuiltInNames = new string[58]
		{
			"Mittens", "Biscuit", "Pumpkin", "Mochi", "Noodle", "Beans", "Waffles", "Tofu", "Pepper", "Socks",
			"Muffin", "Ziggy", "Olive", "Gizmo", "Nugget", "Clover", "Pudding", "Sprout", "Marbles", "Toast",
			"Bean", "Whiskers", "Luna", "Milo", "Cleo", "Oreo", "Salem", "Tater", "Dumpling", "Scrap",
			"Bolt", "Quota", "Gordion", "Rivet", "Sprocket", "Fuse", "Ducky", "Apparatus", "Biscotti", "Nimbus",
			"Pebble", "Juniper", "Maple", "Sushi", "Paprika", "Wasabi", "Bramble", "Cosmo", "Hazel", "Fig",
			"Pistachio", "Turnip", "Butters", "Kiwi", "Smudge", "Tinsel", "Mabel", "Ravioli"
		};

		private static List<SpecialCat> specials = new List<SpecialCat>();

		private static string[] namePool = BuiltInNames;

		public readonly string Name;

		public readonly string FurName;

		public readonly Color Fur;

		public readonly Color Eye;

		public readonly float Size;

		public readonly int SoundRoll;

		public CatLooks(int seed, string identity)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			Random random = new Random(seed);
			(string, Color) tuple = Furs[random.Next(Furs.Length)];
			FurName = tuple.Item1;
			Fur = tuple.Item2;
			Eye = Eyes[random.Next(Eyes.Length)].color;
			Name = BuiltInNames[random.Next(BuiltInNames.Length)];
			Size = 1.25f + (float)random.NextDouble() * 0.2f;
			SoundRoll = random.Next();
			if (string.IsNullOrEmpty(identity))
			{
				return;
			}
			string[] array = identity.Split('|');
			Name = array[0];
			Color fur = default(Color);
			Color eye = default(Color);
			if (array.Length >= 3 && ColorUtility.TryParseHtmlString("#" + array[1], ref fur) && ColorUtility.TryParseHtmlString("#" + array[2], ref eye))
			{
				Fur = fur;
				Eye = eye;
				if (array.Length >= 4 && array[3].Length > 0)
				{
					FurName = array[3];
				}
			}
		}

		public static string ResolveIdentity(int seed)
		{
			Random random = new Random(seed);
			random.Next(Furs.Length);
			random.Next(Eyes.Length);
			string name = namePool[random.Next(namePool.Length)];
			SpecialCat specialCat = specials.FirstOrDefault((SpecialCat s) => s.Name == name);
			if (specialCat == null)
			{
				return name;
			}
			return specialCat.Encode();
		}

		public static int NewSeed()
		{
			return Random.Range(1, 4194304);
		}

		public static void LoadSpecials(string config)
		{
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			specials = new List<SpecialCat>();
			string[] array = (config ?? "").Split(';');
			foreach (string text in array)
			{
				string[] f = (from s in text.Split(',')
					select s.Trim()).ToArray();
				if (f.Length < 3 || f[0].Length == 0)
				{
					continue;
				}
				if (f[0].Contains("|") || !TryColor(f[1], eye: false, out var c) || !TryColor(f[2], eye: true, out var c2))
				{
					Plugin.Log.LogWarning((object)("Couldn't read special cat '" + text.Trim() + "'. Expected: Name, FurColour, EyeColour[, CoatLabel]"));
					continue;
				}
				string text2 = ((f.Length >= 4 && f[3].Length > 0) ? f[3] : (f[1].StartsWith("#") ? "Special" : f[1]));
				specials.RemoveAll((SpecialCat s) => s.Name == f[0]);
				specials.Add(new SpecialCat
				{
					Name = f[0],
					Fur = c,
					Eye = c2,
					CoatLabel = text2.Replace("|", "")
				});
			}
			namePool = BuiltInNames.Where((string n) => specials.All((SpecialCat s) => s.Name != n)).Concat(specials.Select((SpecialCat s) => s.Name)).ToArray();
			Plugin.Log.LogInfo((object)("Special cats: " + ((specials.Count == 0) ? "none" : string.Join(", ", specials.Select((SpecialCat s) => s.Name)))));
		}

		private static bool TryColor(string s, bool eye, out Color c)
		{
			//IL_0057: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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)
			if (s.StartsWith("#"))
			{
				return ColorUtility.TryParseHtmlString(s, ref c);
			}
			foreach (var (a, val) in (eye ? Eyes.Concat(Furs) : Furs.Concat(Eyes)).Concat(ExtraColors))
			{
				if (string.Equals(a, s, StringComparison.OrdinalIgnoreCase))
				{
					c = val;
					return true;
				}
			}
			c = default(Color);
			return false;
		}
	}
	internal static class CatRegistry
	{
		public static Item CatItemDef;

		public static GameObject Prefab;

		public static Item[] SoundSources = (Item[])(object)new Item[0];

		private static readonly string[] SoftItemNames = new string[1] { "Soccer ball" };

		private const int PropsLayer = 6;

		private const int ScanNodeLayer = 22;

		public static void Register()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			float value = Plugin.Cfg.ModelScale.Value;
			Prefab = NetworkPrefabs.CreateNetworkPrefab("CozyCat");
			Prefab.tag = "PhysicsProp";
			Prefab.layer = 6;
			GameObject obj = Object.Instantiate<GameObject>(CatAssets.CatModel, Prefab.transform);
			((Object)obj).name = "Model";
			obj.transform.localScale = Vector3.one * value;
			obj.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);
			Transform[] componentsInChildren = obj.GetComponentsInChildren<Transform>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Component)componentsInChildren[i]).gameObject.layer = 6;
			}
			BoxCollider obj2 = Prefab.AddComponent<BoxCollider>();
			obj2.center = new Vector3(0f, 0.2f, 0f) * value;
			obj2.size = new Vector3(0.25f, 0.4f, 0.5f) * value;
			AudioSource obj3 = Prefab.AddComponent<AudioSource>();
			obj3.playOnAwake = false;
			obj3.spatialBlend = 1f;
			obj3.rolloffMode = (AudioRolloffMode)1;
			obj3.minDistance = 1f;
			obj3.maxDistance = 15f;
			GameObject val = new GameObject("Purr");
			val.transform.SetParent(Prefab.transform, false);
			AudioSource obj4 = val.AddComponent<AudioSource>();
			obj4.playOnAwake = false;
			obj4.loop = true;
			obj4.volume = 0f;
			obj4.spatialBlend = 1f;
			obj4.rolloffMode = (AudioRolloffMode)1;
			obj4.minDistance = 0.5f;
			obj4.maxDistance = 5f;
			GameObject val2 = new GameObject("ScanNode")
			{
				layer = 22
			};
			val2.transform.SetParent(Prefab.transform, false);
			val2.transform.localPosition = new Vector3(0f, 0.3f, 0f) * value;
			BoxCollider obj5 = val2.AddComponent<BoxCollider>();
			((Collider)obj5).isTrigger = true;
			obj5.size = Vector3.one * 0.5f;
			ScanNodeProperties obj6 = val2.AddComponent<ScanNodeProperties>();
			obj6.maxRange = 13;
			obj6.minRange = 1;
			obj6.requiresLineOfSight = true;
			obj6.headerText = "Cat";
			obj6.subText = "Not for sale";
			obj6.nodeType = 0;
			Item val3 = ScriptableObject.CreateInstance<Item>();
			((Object)val3).name = "CozyCatItem";
			val3.itemName = "Cat";
			val3.spawnPrefab = Prefab;
			val3.isScrap = false;
			val3.minValue = (val3.maxValue = 0);
			val3.creditsWorth = 0;
			val3.weight = 1.08f;
			val3.twoHanded = true;
			val3.twoHandedAnimation = true;
			val3.canBeGrabbedBeforeGameStart = true;
			val3.itemSpawnsOnGround = true;
			val3.requiresBattery = false;
			val3.saveItemVariable = true;
			val3.syncUseFunction = false;
			val3.isConductiveMetal = false;
			val3.canBeInspected = false;
			val3.restingRotation = Vector3.zero;
			val3.verticalOffset = 0f;
			val3.positionOffset = Vector3.zero;
			val3.rotationOffset = Vector3.zero;
			val3.toolTips = ((CatAssets.Meows.Length == 0) ? new string[0] : new string[1] { "Meow : [LMB]" });
			val3.meshVariants = (Mesh[])(object)new Mesh[0];
			val3.materialVariants = (Material[])(object)new Material[0];
			val3.clinkAudios = (AudioClip[])(object)new AudioClip[0];
			CatItemDef = val3;
			CatItem catItem = Prefab.AddComponent<CatItem>();
			((GrabbableObject)catItem).itemProperties = val3;
			((GrabbableObject)catItem).grabbable = true;
			((GrabbableObject)catItem).grabbableToEnemies = false;
			Items.RegisterItem(val3);
		}

		public static void FixupFromGame(StartOfRound sor)
		{
			List<Item> items = sor.allItemsList.itemsList;
			Item val = ((IEnumerable<Item>)items).FirstOrDefault((Func<Item, bool>)((Item i) => (Object)(object)i != (Object)null && i.isScrap && i.twoHanded && i.twoHandedAnimation && !string.IsNullOrEmpty(i.grabAnim))) ?? ((IEnumerable<Item>)items).FirstOrDefault((Func<Item, bool>)((Item i) => (Object)(object)i != (Object)null && i.twoHanded));
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)"No two-handed template item found; cat will use default hold animation.");
				return;
			}
			Item catItemDef = CatItemDef;
			catItemDef.grabAnim = val.grabAnim;
			catItemDef.grabAnimationTime = val.grabAnimationTime;
			Item val2 = catItemDef;
			if (val2.itemIcon == null)
			{
				val2.itemIcon = val.itemIcon;
			}
			SoundSources = (from n in SoftItemNames
				select ((IEnumerable<Item>)items).FirstOrDefault((Func<Item, bool>)((Item i) => (Object)(object)i != (Object)null && i.itemName == n && (Object)(object)i.dropSFX != (Object)null)) into i
				where (Object)(object)i != (Object)null
				select i).ToArray();
			catItemDef.grabSFX = null;
			catItemDef.dropSFX = null;
			catItemDef.pocketSFX = null;
			Plugin.Log.LogInfo((object)("Cat sound sources: " + string.Join(", ", SoundSources.Select((Item i) => i.itemName))));
			AudioSource val3 = (((Object)(object)val.spawnPrefab != (Object)null) ? val.spawnPrefab.GetComponent<AudioSource>() : null);
			if ((Object)(object)val3 != (Object)null)
			{
				AudioSource[] componentsInChildren = Prefab.GetComponentsInChildren<AudioSource>(true);
				for (int num = 0; num < componentsInChildren.Length; num++)
				{
					componentsInChildren[num].outputAudioMixerGroup = val3.outputAudioMixerGroup;
				}
			}
			Plugin.Log.LogInfo((object)("Cat hold animation borrowed from '" + val.itemName + "' (" + val.grabAnim + ")"));
		}
	}
	[HarmonyPatch]
	internal static class Patches
	{
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		private static void AfterStartOfRoundAwake(StartOfRound __instance)
		{
			CatRegistry.FixupFromGame(__instance);
		}

		[HarmonyPatch(typeof(DepositItemsDesk), "PlaceItemOnCounter")]
		[HarmonyPrefix]
		private static bool KeepCatsOffCounter(PlayerControllerB playerWhoTriggered)
		{
			if ((Object)(object)playerWhoTriggered == (Object)null || !(playerWhoTriggered.currentlyHeldObjectServer is CatItem catItem))
			{
				return true;
			}
			HUDManager.Instance.DisplayTip("Absolutely not.", "The Company can't have " + catItem.CatName + ".", true, false, "LC_Tip1");
			return false;
		}

		[HarmonyPatch(typeof(HUDManager), "DisplayNewScrapFound")]
		[HarmonyPrefix]
		private static void BeforeDisplayScrap(HUDManager __instance, int ___nextBoxIndex, out (CatItem cat, int box) __state)
		{
			__state = default((CatItem, int));
			if (__instance.itemsToBeDisplayed.Count > 0 && __instance.itemsToBeDisplayed[0] is CatItem item)
			{
				__state = (cat: item, box: ___nextBoxIndex);
			}
		}

		[HarmonyPatch(typeof(HUDManager), "DisplayNewScrapFound")]
		[HarmonyPostfix]
		private static void AfterDisplayScrap(HUDManager __instance, (CatItem cat, int box) __state)
		{
			if (!((Object)(object)__state.cat == (Object)null))
			{
				ScrapItemHUDDisplay obj = __instance.ScrapItemBoxes[__state.box];
				((TMP_Text)obj.headerText).text = __state.cat.CatName + " rescued!";
				((TMP_Text)obj.valueText).text = $"Bounty: ${__state.cat.PendingBountyDisplay}";
			}
		}

		[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
		[HarmonyPostfix]
		private static void SpawnCats(RoundManager __instance)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)__instance).IsServer || (Object)(object)CatRegistry.Prefab == (Object)null)
			{
				return;
			}
			CatConfig cfg = Plugin.Cfg;
			int i = 0;
			if (cfg.MaxCatsPerMoon.Value > 0 && Random.value < cfg.FirstCatChance.Value)
			{
				for (i = 1; i < cfg.MaxCatsPerMoon.Value; i++)
				{
					if (!(Random.value < cfg.SecondCatChance.Value))
					{
						break;
					}
				}
			}
			if (i == 0)
			{
				return;
			}
			RandomScrapSpawn[] array = Object.FindObjectsOfType<RandomScrapSpawn>();
			if (array.Length != 0)
			{
				for (int j = 0; j < i; j++)
				{
					RandomScrapSpawn val = array[Random.Range(0, array.Length)];
					Vector3 randomNavMeshPositionInRadiusSpherical = __instance.GetRandomNavMeshPositionInRadiusSpherical(((Component)val).transform.position, Mathf.Max(val.itemSpawnRange, 1f), default(NavMeshHit));
					GameObject obj = Object.Instantiate<GameObject>(CatRegistry.Prefab, randomNavMeshPositionInRadiusSpherical, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), __instance.spawnedScrapContainer);
					obj.GetComponent<GrabbableObject>().fallTime = 0f;
					obj.GetComponent<NetworkObject>().Spawn(false);
					Plugin.Log.LogInfo((object)$"Cat hiding in the facility at {randomNavMeshPositionInRadiusSpherical} (spawner {((Object)val).name} at {((Component)val).transform.position})");
				}
			}
		}
	}
	[BepInPlugin("CozyCats", "CozyCats", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static CatConfig Cfg;

		private void Awake()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Cfg = new CatConfig(((BaseUnityPlugin)this).Config);
			CatLooks.LoadSpecials(Cfg.SpecialCats.Value);
			InitNetcodePatcher();
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "cozycats");
			if (!CatAssets.Load(text))
			{
				Log.LogError((object)("Asset bundle missing at " + text + "; cats disabled."));
				return;
			}
			CatRegistry.Register();
			new Harmony("CozyCats").PatchAll();
			Log.LogInfo((object)"CozyCats 1.1.0 loaded. Meow.");
		}

		private static void InitNetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].GetMethods(BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "CozyCats";

		public const string PLUGIN_NAME = "CozyCats";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
			NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<byte>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<byte>();
			NetworkVariableSerializationTypes.InitializeSerializer_FixedString<FixedString128Bytes>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<FixedString128Bytes>();
			NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
		}
	}
}
namespace CozyCats.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}