Decompiled source of SpiderInfestation v1.1.0

plugins/SpiderInfestation.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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 ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PEAKLib.Core;
using Photon.Pun;
using Photon.Realtime;
using SpiderInfestation;
using Unity.Mathematics;
using UnityEngine;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SpiderInfestation")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("SpiderInfestation")]
[assembly: AssemblyTitle("Spider Infestation")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class NonItemPhysicsSyncer : PhotonBinaryStreamSerializer<ItemPhysicsSyncData>
{
	private PhotonView m_photonView;

	private Optionable<Vector3> m_lastPos;

	private Coroutine m_fadeRoutine;

	public bool debug;

	[SerializeField]
	internal bool shouldSync = true;

	private int forceSyncFrames;

	[SerializeField]
	private Vector3 lastRecievedLinearVelocity;

	[SerializeField]
	private Vector3 lastRecievedAngularVelocity;

	[SerializeField]
	private Vector3 lastRecievedPosition;

	protected virtual float maxAngleChangePerSecond => 90f;

	public override void Awake()
	{
		base.Awake();
		m_photonView = ((Component)this).GetComponent<PhotonView>();
	}

	public void ForceSyncForFrames(int frames = 10)
	{
		forceSyncFrames = frames;
	}

	private void FixedUpdate()
	{
		//IL_00bd: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: 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_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		Rigidbody component = ((Component)this).GetComponent<Rigidbody>();
		if ((Object)(object)component == (Object)null || !PhotonNetwork.InRoom || m_photonView.IsMine)
		{
			return;
		}
		if (base.RemoteValue.IsNone)
		{
			if (debug)
			{
				Debug.Log((object)"NO REMOTE VALUE");
			}
			return;
		}
		if (!shouldSync)
		{
			if (debug)
			{
				Debug.Log((object)"NOT SYNCING");
			}
			return;
		}
		if (m_lastPos.IsNone)
		{
			if (debug)
			{
				Debug.Log((object)"NO LAST POSITION");
			}
			return;
		}
		double num = 1f / (float)PhotonNetwork.SerializationRate;
		base.sinceLastPackage += Time.fixedDeltaTime * 0.6f;
		float num2 = (float)((double)base.sinceLastPackage / num);
		ItemPhysicsSyncData value = base.RemoteValue.Value;
		Vector3 val = float3.op_Implicit(value.position);
		Vector3 val2 = Vector3.Lerp(m_lastPos.Value, val, num2);
		Vector3 val3 = val2 - component.position;
		lastRecievedPosition = val2;
		component.MovePosition(component.position + val3 * 0.5f);
		component.MoveRotation(Quaternion.RotateTowards(component.rotation, value.rotation, Time.fixedDeltaTime * maxAngleChangePerSecond));
		if (debug)
		{
			Vector3 val4 = val2;
			Debug.Log((object)("MOVING TO POSITION " + ((object)(Vector3)(ref val4)).ToString()));
		}
	}

	public void ResetRecievedData()
	{
		//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_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)
		lastRecievedPosition = ((Component)this).transform.position;
		base.RemoteValue = Optionable<ItemPhysicsSyncData>.None;
	}

	public override ItemPhysicsSyncData GetDataToWrite()
	{
		//IL_0002: 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_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: 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)
		//IL_0032: 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_003f: 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_0049: 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_0056: 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_0064: 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)
		ItemPhysicsSyncData val = default(ItemPhysicsSyncData);
		Rigidbody component = ((Component)this).GetComponent<Rigidbody>();
		if ((Object)(object)component != (Object)null)
		{
			val.linearVelocity = float3.op_Implicit(component.linearVelocity);
			val.angularVelocity = float3.op_Implicit(component.angularVelocity);
			val.position = float3.op_Implicit(component.position);
			val.rotation = component.rotation;
			if (debug)
			{
				float3 position = val.position;
				Debug.Log((object)("SENDING POSITION " + ((object)(float3)(ref position)).ToString()));
			}
		}
		return val;
	}

	public override bool ShouldSendData()
	{
		if (forceSyncFrames > 0)
		{
			forceSyncFrames--;
			return true;
		}
		if (!shouldSync)
		{
			return false;
		}
		Rigidbody component = ((Component)this).GetComponent<Rigidbody>();
		if ((Object)(object)component == (Object)null)
		{
			return false;
		}
		if (!component.isKinematic && !component.IsSleeping())
		{
			return true;
		}
		return false;
	}

	public override void OnDataReceived(ItemPhysicsSyncData data)
	{
		//IL_0013: 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_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)
		//IL_006b: 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_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: 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_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: 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_0098: 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_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_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
		if (debug)
		{
			Debug.Log((object)"RECIEVED DATA 1");
		}
		base.OnDataReceived(data);
		Rigidbody component = ((Component)this).GetComponent<Rigidbody>();
		if ((Object)(object)component == (Object)null)
		{
			return;
		}
		if (!shouldSync)
		{
			if (debug)
			{
				Debug.Log((object)"SHOULDSYNC OFF");
			}
		}
		else if (!component.isKinematic)
		{
			if (debug)
			{
				Debug.Log((object)"RECIEVED DATA 2");
			}
			m_lastPos = Optionable<Vector3>.Some(float3.op_Implicit(data.position));
			component.linearVelocity = float3.op_Implicit(data.linearVelocity);
			component.angularVelocity = float3.op_Implicit(data.angularVelocity);
			lastRecievedLinearVelocity = float3.op_Implicit(data.linearVelocity);
			lastRecievedAngularVelocity = float3.op_Implicit(data.angularVelocity);
		}
	}
}
public class Spider : MonoBehaviour, IInteractible
{
	[CompilerGenerated]
	private sealed class <MultiplayerCheck>d__31 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public Spider <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <MultiplayerCheck>d__31(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			int num = <>1__state;
			Spider spider = <>4__this;
			if (num != 0)
			{
				if (num != 1)
				{
					return false;
				}
				<>1__state = -1;
			}
			else
			{
				<>1__state = -1;
			}
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if (!allCharacter.data.dead && Plugin.helpFriendsMaster)
				{
					Debug.Log((object)"needFriendHelp = true");
					spider.needFriendHelp = true;
					spider.leaveTimer = Plugin.spiderSecondsMaster;
					break;
				}
				Debug.Log((object)"needFriendHelp = false");
				spider.needFriendHelp = false;
			}
			<>2__current = (object)new WaitForSeconds(5f);
			<>1__state = 1;
			return true;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <ShrinkAndRemove>d__32 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public Spider <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <ShrinkAndRemove>d__32(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0063: 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_002d: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			int num = <>1__state;
			Spider spider = <>4__this;
			switch (num)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if (((Component)spider).transform.localScale.x > spider.scaleDecreasePerSecond * Time.deltaTime)
			{
				Transform transform = ((Component)spider).transform;
				transform.localScale -= spider.scaleDecreaseVector3 * Time.deltaTime;
				<>2__current = null;
				<>1__state = 1;
				return true;
			}
			if (((Component)spider).transform.localScale.x <= spider.scaleDecreasePerSecond * Time.deltaTime && spider.photonView.IsMine)
			{
				PhotonNetwork.Destroy(((Component)spider).gameObject);
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private PhotonView photonView;

	public AudioSource audioSource;

	public Character grabbedCharacter;

	public Transform characterFace;

	public Vector3 initialPosition;

	private Vector3 localPosition;

	private Vector3 initialRotation = new Vector3(0f, 180f, 0f);

	private Vector3 finalRotation;

	public float randomXOffset;

	public float randomYOffset;

	public float zOffset = 1.15f;

	public float randomXRotation;

	public float animationSpeedMultiplier = 3f;

	public float currentDuration;

	public bool isGrabbed;

	public bool needFriendHelp;

	public float leaveTimer;

	public bool isShrinking;

	public float scaleDecreasePerSecond = 0.5f;

	public Vector3 scaleDecreaseVector3;

	private void Awake()
	{
		//IL_002e: 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_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		photonView = ((Component)this).GetComponent<PhotonView>();
		audioSource = ((Component)((Component)this).transform.Find("Audio_Source")).GetComponent<AudioSource>();
		initialPosition = ((Component)this).transform.position;
		if (!PhotonNetwork.OfflineMode)
		{
			needFriendHelp = Plugin.helpFriendsMaster;
		}
		leaveTimer = Plugin.spiderSecondsMaster;
		scaleDecreaseVector3 = new Vector3(scaleDecreasePerSecond, scaleDecreasePerSecond, scaleDecreasePerSecond);
		if (!LocalizedText.MAIN_TABLE.ContainsKey("SPIDER"))
		{
			LocalizedText.MAIN_TABLE.Add("SPIDER", new List<string>(15)
			{
				"SPIDER", "ARAIGNÉE", "RAGNO", "SPINNE", "ARAÑA", "ARAÑA", "ARANHA", "ПАУК", "ПАВУК", "蜘蛛",
				"蜘蛛", "スパイダー", "거미", "PAJĄK", "ÖRÜMCEK"
			});
		}
		if (!LocalizedText.MAIN_TABLE.ContainsKey("INTERACT_SPIDER"))
		{
			LocalizedText.MAIN_TABLE.Add("INTERACT_SPIDER", new List<string>(15)
			{
				"remove spider", "enlever l'araignée", "rimuovere il ragno", "spinne entfernen", "quitar araña", "quitar araña", "remover aranha", "удалить паука", "видалити павука", "删除蜘蛛",
				"刪除蜘蛛", "クモを取り除く", "거미를 제거하다", "usuń pająka", "örümceği kaldır"
			});
		}
	}

	private void Update()
	{
		if (!isGrabbed && currentDuration == 1f)
		{
			isGrabbed = true;
			if (!PhotonNetwork.OfflineMode)
			{
				((MonoBehaviour)this).StartCoroutine(MultiplayerCheck());
			}
		}
		if (!needFriendHelp)
		{
			leaveTimer -= Time.deltaTime;
			if (!isShrinking && leaveTimer <= 0f)
			{
				photonView.RPC("RPC_RemoveSpider", (RpcTarget)0, Array.Empty<object>());
			}
		}
	}

	private void LateUpdate()
	{
		//IL_00c9: 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_0058: 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_0069: 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_0085: 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_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: 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_00b0: 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_00ea: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)characterFace))
		{
			if (currentDuration < 1f)
			{
				currentDuration = Math.Clamp(currentDuration += Time.deltaTime * animationSpeedMultiplier, 0f, 1f);
				((Component)this).transform.position = Vector3.Lerp(initialPosition, characterFace.TransformPoint(localPosition), currentDuration);
				((Component)this).transform.rotation = Quaternion.Lerp(Quaternion.Euler(initialRotation), characterFace.rotation * Quaternion.Euler(finalRotation), currentDuration);
			}
			else
			{
				((Component)this).transform.position = characterFace.TransformPoint(localPosition);
			}
			((Component)this).transform.rotation = characterFace.rotation * Quaternion.Euler(finalRotation);
		}
	}

	bool IInteractible.IsInteractible(Character interactor)
	{
		if (!isGrabbed || (Object)(object)grabbedCharacter == (Object)(object)Character.localCharacter || !needFriendHelp || isShrinking)
		{
			return false;
		}
		return true;
	}

	void IInteractible.Interact(Character interactor)
	{
		photonView.RPC("RPC_RemoveSpider", (RpcTarget)0, Array.Empty<object>());
	}

	Vector3 IInteractible.Center()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		return ((Component)this).transform.position;
	}

	Transform IInteractible.GetTransform()
	{
		return ((Component)this).transform;
	}

	string IInteractible.GetInteractionText()
	{
		return LocalizedText.GetText("INTERACT_SPIDER", true);
	}

	string IInteractible.GetName()
	{
		return LocalizedText.GetText("SPIDER", true);
	}

	void IInteractible.HoverEnter()
	{
	}

	void IInteractible.HoverExit()
	{
	}

	[IteratorStateMachine(typeof(<MultiplayerCheck>d__31))]
	private IEnumerator MultiplayerCheck()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <MultiplayerCheck>d__31(0)
		{
			<>4__this = this
		};
	}

	[IteratorStateMachine(typeof(<ShrinkAndRemove>d__32))]
	private IEnumerator ShrinkAndRemove()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <ShrinkAndRemove>d__32(0)
		{
			<>4__this = this
		};
	}

	[PunRPC]
	public void RPC_GrabCharacter(int targetID, float generatedXOffset, float generatedYOffset, float generatedXRotation)
	{
		//IL_00d3: 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_00ea: 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)
		PhotonView val = PhotonView.Find(targetID);
		grabbedCharacter = ((Component)val).GetComponent<Character>();
		randomXOffset = generatedXOffset;
		randomYOffset = generatedYOffset;
		randomXRotation = generatedXRotation;
		if ((Object)(object)grabbedCharacter == (Object)(object)Character.localCharacter)
		{
			characterFace = ((Component)Camera.main).transform;
			randomYOffset -= 1.15f;
			zOffset = 0.25f;
			audioSource.Play();
			photonView.RPC("RPC_AddStatus", (RpcTarget)0, new object[1] { PunExtensions.GetPhotonView(((Component)((Component)grabbedCharacter).transform.root).gameObject) });
		}
		else
		{
			characterFace = ((Component)grabbedCharacter.GetBodypart((BodypartType)4)).transform;
		}
		localPosition = new Vector3(randomXOffset, randomYOffset, zOffset);
		finalRotation = new Vector3(generatedXRotation, 90f, 90f);
	}

	[PunRPC]
	private void RPC_AddStatus(PhotonView characterView)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		Player owner = characterView.Owner;
		if (owner != null)
		{
			Character.localCharacter.refs.afflictions.AddStatus(Plugin.statusTypeMaster, Plugin.statusUnitsMaster / 40f, false);
		}
	}

	[PunRPC]
	private void RPC_RemoveSpider()
	{
		isShrinking = true;
		((MonoBehaviour)this).StartCoroutine(ShrinkAndRemove());
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace SpiderInfestation
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("SpiderInfestation", "Spider Infestation", "1.1.0")]
	public class Plugin : BaseUnityPlugin, IMatchmakingCallbacks, IInRoomCallbacks
	{
		internal static ModDefinition modDefinition;

		internal static ConfigEntry<int> spiderChance;

		internal static ConfigEntry<string> statusType;

		internal static ConfigEntry<int> statusUnits;

		internal static ConfigEntry<int> spiderSeconds;

		internal static ConfigEntry<bool> helpFriends;

		internal static int spiderChanceMaster;

		internal static STATUSTYPE statusTypeMaster;

		internal static float statusUnitsMaster;

		internal static int spiderSecondsMaster;

		internal static bool helpFriendsMaster;

		internal static bool disableMod;

		internal static GameObject spiderPrefab;

		internal static SFX_Instance SFXISpiderScream;

		private static Dictionary<string, Shader> _peakShaders;

		public const string Id = "SpiderInfestation";

		internal static ManualLogSource Log { get; private set; }

		internal static Dictionary<string, Shader> PeakShaders
		{
			get
			{
				if (_peakShaders == null)
				{
					List<string> list = new List<string>
					{
						"W/Peak_Standard", "W/Character", "W/Peak_Transparent", "W/Peak_Glass", "W/Peak_Clip", "W/Peak_glass_liquid", "W/Peak_GroundTransition", "W/Peak_Guidebook", "W/Peak_Honey", "W/Peak_Ice",
						"W/Peak_Rock", "W/Peak_Rope", "W/Peak_Splash", "W/Peak_Waterfall", "W/Vine"
					};
					_peakShaders = new Dictionary<string, Shader>();
					foreach (string item in list)
					{
						Shader val = Shader.Find(item);
						if (!((Object)(object)val == (Object)null))
						{
							_peakShaders[item] = val;
						}
					}
				}
				return _peakShaders;
			}
		}

		public static string Name => "Spider Infestation";

		public static string Version => "1.1.0";

		private void Awake()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			modDefinition = ModDefinition.GetOrCreate(((BaseUnityPlugin)this).Info.Metadata);
			Log.LogInfo((object)"Plugin SpiderInfestation is loaded!");
			new Harmony("com.github.DaxxPurpura.SpiderInfestation").PatchAll();
			PhotonNetwork.AddCallbackTarget((object)this);
			spiderChance = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Spider Chance", 10, "Chance (%) for an item to have a spider on it.");
			statusType = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Status Type", "Injury", "Type of status effect inflicted. Possible values: Injury, Hunger, Cold, Poison, Curse, Drowsy, Hot (Any other value will set this to Injury)");
			statusUnits = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Status Units", 2, "Amount of status effect inflicted. 1 unit = 2.5%");
			spiderSeconds = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Spider Seconds", 5, "Seconds that the spiders obstruct the player's vision.");
			helpFriends = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Help Friends", true, "If true, spiders won't leave unless a friend helps you (as long as at least one friend is still alive).");
			BundleLoader.LoadBundleAndContentsWithName((BaseUnityPlugin)(object)this, "spider_infestation_bundle.peakbundle", (Action<PeakBundle>)delegate(PeakBundle bundle)
			{
				spiderPrefab = bundle.LoadAsset<GameObject>("Spider");
				spiderPrefab.AddComponent<Spider>();
				spiderPrefab.AddComponent<NonItemPhysicsSyncer>();
				spiderPrefab.GetComponent<PhotonView>().ObservedComponents = new List<Component> { (Component)(object)spiderPrefab.GetComponent<NonItemPhysicsSyncer>() };
				Renderer[] componentsInChildren = spiderPrefab.GetComponentsInChildren<Renderer>();
				foreach (Renderer val in componentsInChildren)
				{
					Material[] materials = val.materials;
					foreach (Material val2 in materials)
					{
						if (PeakShaders.TryGetValue(((Object)val2.shader).name, out Shader value))
						{
							val2.shader = value;
						}
					}
				}
				NetworkPrefabManager.RegisterNetworkPrefab(modDefinition, spiderPrefab);
				SFXISpiderScream = bundle.LoadAsset<SFX_Instance>("SFXI_Spider_Scream");
			});
		}

		private void OnDestroy()
		{
			PhotonNetwork.RemoveCallbackTarget((object)this);
		}

		private bool ShouldSpiderInfestationEnable()
		{
			Player[] playerList = PhotonNetwork.PlayerList;
			foreach (Player val in playerList)
			{
				if (!((Dictionary<object, object>)(object)val.CustomProperties).TryGetValue((object)"hasSpiderInfestation", out object value) || value == null || !Convert.ToBoolean(value))
				{
					return false;
				}
			}
			return true;
		}

		private void SpiderInfestationCheck()
		{
			//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_005f: Expected O, but got Unknown
			//IL_0066: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00a0: Expected O, but got Unknown
			if (PhotonNetwork.IsMasterClient)
			{
				Room currentRoom = PhotonNetwork.CurrentRoom;
				bool flag = true;
				if (((Dictionary<object, object>)(object)((RoomInfo)currentRoom).CustomProperties).TryGetValue((object)"spiderInfestationIsDisabled", out object value) && value != null)
				{
					flag = Convert.ToBoolean(value);
				}
				if (flag && !ShouldSpiderInfestationEnable())
				{
					Log.LogError((object)"Player doesn't have SpiderInfestation. Disabling mod...");
					Hashtable val = new Hashtable();
					((Dictionary<object, object>)val).Add((object)"spiderInfestationIsDisabled", (object)true);
					currentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
				}
				else if (!flag && ShouldSpiderInfestationEnable())
				{
					Log.LogInfo((object)"All players have SpiderInfestation. Enabling mod...");
					Hashtable val2 = new Hashtable();
					((Dictionary<object, object>)val2).Add((object)"spiderInfestationIsDisabled", (object)false);
					currentRoom.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null);
				}
			}
		}

		private STATUSTYPE statusTypeConverter(string statusString)
		{
			return (STATUSTYPE)(statusString switch
			{
				"Hunger" => 1, 
				"Cold" => 2, 
				"Poison" => 3, 
				"Curse" => 5, 
				"Drowsy" => 6, 
				"Hot" => 8, 
				_ => 0, 
			});
		}

		public void OnJoinedRoom()
		{
			//IL_0011: 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_0027: Expected O, but got Unknown
			//IL_002e: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_00f1: Expected O, but got Unknown
			//IL_011d: 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)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			disableMod = false;
			Room currentRoom = PhotonNetwork.CurrentRoom;
			Player localPlayer = PhotonNetwork.LocalPlayer;
			Hashtable val = new Hashtable();
			((Dictionary<object, object>)val).Add((object)"hasSpiderInfestation", (object)true);
			localPlayer.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
			if (PhotonNetwork.IsMasterClient)
			{
				Log.LogInfo((object)"Setting custom properties...");
				Hashtable val2 = new Hashtable();
				((Dictionary<object, object>)val2).Add((object)"spiderInfestationIsDisabled", (object)false);
				((Dictionary<object, object>)val2).Add((object)"spiderChance", (object)Math.Clamp(spiderChance.Value, 0, 100));
				((Dictionary<object, object>)val2).Add((object)"statusType", (object)statusType.Value);
				((Dictionary<object, object>)val2).Add((object)"statusUnits", (object)Math.Clamp(statusUnits.Value, 0, 50));
				((Dictionary<object, object>)val2).Add((object)"spiderSeconds", (object)Math.Abs(spiderSeconds.Value));
				((Dictionary<object, object>)val2).Add((object)"helpFriends", (object)helpFriends.Value);
				Hashtable val3 = val2;
				currentRoom.SetCustomProperties(val3, (Hashtable)null, (WebFlags)null);
				spiderChanceMaster = Math.Clamp(spiderChance.Value, 0, 100);
				statusTypeMaster = statusTypeConverter(statusType.Value);
				statusUnitsMaster = Math.Clamp(statusUnits.Value, 0, 50);
				spiderSecondsMaster = Math.Abs(spiderSeconds.Value);
				helpFriendsMaster = helpFriends.Value;
				return;
			}
			if (!((Dictionary<object, object>)(object)((RoomInfo)currentRoom).CustomProperties).TryGetValue((object)"spiderInfestationIsDisabled", out object _) || (((Dictionary<object, object>)(object)((RoomInfo)currentRoom).CustomProperties).TryGetValue((object)"spiderInfestationIsDisabled", out object value2) && Convert.ToBoolean(value2)))
			{
				Log.LogError((object)"SpiderInfestation is disabled in this room. Disabling mod...");
				disableMod = true;
				return;
			}
			Log.LogInfo((object)"Getting custom properties...");
			Hashtable customProperties = ((RoomInfo)currentRoom).CustomProperties;
			if (((Dictionary<object, object>)(object)customProperties).TryGetValue((object)"spiderChance", out object value3) && value3 != null)
			{
				spiderChanceMaster = Convert.ToInt32(value3);
			}
			if (((Dictionary<object, object>)(object)customProperties).TryGetValue((object)"statusType", out object value4) && value4 != null)
			{
				statusTypeMaster = statusTypeConverter(value4.ToString());
			}
			if (((Dictionary<object, object>)(object)customProperties).TryGetValue((object)"statusUnits", out object value5) && value5 != null)
			{
				statusUnitsMaster = Convert.ToInt32(value5);
			}
			if (((Dictionary<object, object>)(object)customProperties).TryGetValue((object)"spiderSeconds", out object value6) && value6 != null)
			{
				spiderSecondsMaster = Convert.ToInt32(value6);
			}
			if (((Dictionary<object, object>)(object)customProperties).TryGetValue((object)"helpFriends", out object value7) && value7 != null)
			{
				helpFriendsMaster = Convert.ToBoolean(value7);
			}
		}

		public void OnFriendListUpdate(List<FriendInfo> friendList)
		{
		}

		public void OnCreatedRoom()
		{
		}

		public void OnCreateRoomFailed(short returnCode, string Message)
		{
		}

		public void OnJoinRoomFailed(short returnCode, string message)
		{
		}

		public void OnJoinRandomFailed(short returnCode, string message)
		{
		}

		public void OnLeftRoom()
		{
		}

		void IInRoomCallbacks.OnPlayerEnteredRoom(Player newPlayer)
		{
			SpiderInfestationCheck();
		}

		void IInRoomCallbacks.OnPlayerLeftRoom(Player otherPlayer)
		{
			SpiderInfestationCheck();
		}

		void IInRoomCallbacks.OnRoomPropertiesUpdate(Hashtable propertiesThatChanged)
		{
			//IL_0098: 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)
			if (propertiesThatChanged == null || !((Dictionary<object, object>)(object)propertiesThatChanged).ContainsKey((object)"spiderInfestationIsDisabled"))
			{
				return;
			}
			if (((Dictionary<object, object>)(object)propertiesThatChanged).TryGetValue((object)"spiderInfestationIsDisabled", out object value) && !Convert.ToBoolean(value))
			{
				Log.LogInfo((object)"SpiderInfestation is enabled in this room. Enabling mod...");
				disableMod = false;
				Log.LogInfo((object)"Getting custom properties...");
				Hashtable customProperties = ((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties;
				if (((Dictionary<object, object>)(object)customProperties).TryGetValue((object)"spiderChance", out object value2) && value2 != null)
				{
					spiderChanceMaster = Convert.ToInt32(value2);
				}
				if (((Dictionary<object, object>)(object)customProperties).TryGetValue((object)"statusType", out object value3) && value3 != null)
				{
					statusTypeMaster = statusTypeConverter(value3.ToString());
				}
				if (((Dictionary<object, object>)(object)customProperties).TryGetValue((object)"statusUnits", out object value4) && value4 != null)
				{
					statusUnitsMaster = Convert.ToInt32(value4);
				}
				if (((Dictionary<object, object>)(object)customProperties).TryGetValue((object)"spiderSeconds", out object value5) && value5 != null)
				{
					spiderSecondsMaster = Convert.ToInt32(value5);
				}
				if (((Dictionary<object, object>)(object)customProperties).TryGetValue((object)"helpFriends", out object value6) && value6 != null)
				{
					helpFriendsMaster = Convert.ToBoolean(value6);
				}
			}
			else
			{
				Log.LogError((object)"SpiderInfestation is disabled in this room. Disabling mod...");
				disableMod = true;
			}
		}

		void IInRoomCallbacks.OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps)
		{
			if (targetPlayer != PhotonNetwork.MasterClient && ((Dictionary<object, object>)(object)changedProps).ContainsKey((object)"hasSpiderInfestation"))
			{
				SpiderInfestationCheck();
			}
		}

		void IInRoomCallbacks.OnMasterClientSwitched(Player newMasterClient)
		{
		}
	}
}
namespace SpiderInfestation.Patches
{
	[HarmonyPatch(typeof(Item), "RequestPickup")]
	public class RequestPickupPatch
	{
		private static void Postfix(Item __instance, PhotonView characterView)
		{
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.disableMod || !((Object)(object)__instance.lastThrownCharacter == (Object)null))
			{
				return;
			}
			Plugin.Log.LogInfo((object)"Grabbed new item!");
			string name = ((Object)((Component)__instance).gameObject).name;
			if (!name.Contains("Berrynana Peel"))
			{
				switch (name)
				{
				default:
					if (name.Contains("GuidebookPage_"))
					{
						break;
					}
					switch (name)
					{
					case "Item_Coconut_half(Clone)":
					case "Item_Honeycomb(Clone)":
					case "Passport(Clone)":
					case "Scorpion(Clone)":
						break;
					default:
						if (Random.Range(100, 0) <= Plugin.spiderChanceMaster)
						{
							GameObject val = NetworkPrefabManager.SpawnNetworkPrefab(Plugin.modDefinition.Id + ":Spider", ((Component)__instance).transform.position, Quaternion.identity, (byte)0, (object[])null);
							float num = Random.Range(-0.5f, 0.5f);
							float num2 = Random.Range(0.9f, 1.4f);
							float num3 = Random.Range(-135f, -45f);
							val.GetComponent<PhotonView>().RPC("RPC_GrabCharacter", (RpcTarget)0, new object[4] { characterView.ViewID, num, num2, num3 });
							Plugin.Log.LogInfo((object)"SSSPOOKY SSSPIDER!");
						}
						return;
					}
					break;
				case "Bugfix(Clone)":
				case "Egg(Clone)":
				case "EggTurkey(Clone)":
				case "FireWood(Clone)":
					break;
				}
			}
			Plugin.Log.LogInfo((object)"No spider chance because it could be a non-natural spawned item.");
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}