Decompiled source of Shaqible v1.0.3

plugins/Shaqible/aj.Shaqible.dll

Decompiled 2 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Shaqible.Configuration;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using aj.Shaqible.NetcodePatcher;

[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("aj.Shaqible")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3")]
[assembly: AssemblyProduct("Shaqible")]
[assembly: AssemblyTitle("aj.Shaqible")]
[assembly: AssemblyMetadata("AI_Assisted_Creation", "This assembly was created with the assistance of generative AI (code); see the README credits for which assets.")]
[assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic")]
[assembly: AssemblyVersion("1.0.3.0")]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 Shaqible
{
	[BepInPlugin("aj.Shaqible", "Shaqible", "1.0.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		internal static Item? ShaqibleItemType;

		private const float ScrapValueMultiplier = 0.4f;

		internal static PluginConfig BoundConfig { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
			InitializeNetworkBehaviours();
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "shaqibleassets"));
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)"Failed to load the shaqibleassets bundle.");
				return;
			}
			Item val2 = val.LoadAsset<Item>("Shaqible");
			ReviveClip.Load(val.LoadAsset<TextAsset>("ShaqibleRevive").bytes);
			int num = Mathf.Max(1, BoundConfig.MinValue.Value);
			int num2 = Mathf.Max(num, BoundConfig.MaxValue.Value);
			val2.minValue = Mathf.RoundToInt((float)num / 0.4f);
			val2.maxValue = Mathf.RoundToInt((float)num2 / 0.4f);
			ShaqibleItemType = val2;
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterScrap(val2, BoundConfig.SpawnWeight.Value, (LevelTypes)(-1));
			if (BoundConfig.TestKeys.Value)
			{
				ShaqibleTestKeys.Install();
			}
			Logger.LogInfo((object)"Plugin aj.Shaqible is loaded!");
		}

		private static void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			foreach (Type type in types)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	internal static class Revive
	{
		internal enum Refusal
		{
			None,
			NoBody,
			Carried,
			OnShip,
			TooFar,
			NoRoom
		}

		internal const int Chest = 5;

		internal const int Hips = 6;

		private static readonly float[] SidesToTry = new float[4] { 0f, 90f, -90f, 180f };

		private const float ChestClearance = 0.4f;

		internal static string Explain(Refusal r)
		{
			return r switch
			{
				Refusal.NoBody => "No one to revive nearby.", 
				Refusal.Carried => "Someone's carrying that body.", 
				Refusal.OnShip => "Bodies on the ship can't be revived.", 
				Refusal.TooFar => "Get closer to the body.", 
				Refusal.NoRoom => "Can't reach the body from here.", 
				_ => "", 
			};
		}

		internal static Refusal CheckBody(PlayerControllerB dead)
		{
			DeadBodyInfo val = (((Object)(object)dead != (Object)null && dead.isPlayerDead) ? dead.deadBody : null);
			if ((Object)(object)val == (Object)null || val.deactivated || !((Component)val).gameObject.activeSelf || val.bodyParts.Length <= 6)
			{
				return Refusal.NoBody;
			}
			if (val.isInShip)
			{
				return Refusal.OnShip;
			}
			if (((Object)(object)val.grabBodyObject != (Object)null && val.grabBodyObject.isHeld) || (Object)(object)val.attachedTo != (Object)null)
			{
				return Refusal.Carried;
			}
			return Refusal.None;
		}

		internal static PlayerControllerB? FindBody(PlayerControllerB reviver, float range, out Refusal why)
		{
			//IL_003d: 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)
			PlayerControllerB val = null;
			float num = float.MaxValue;
			why = Refusal.NoBody;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val2 in allPlayerScripts)
			{
				if ((Object)(object)val2 == (Object)(object)reviver)
				{
					continue;
				}
				Refusal refusal = CheckBody(val2);
				if (refusal == Refusal.NoBody)
				{
					continue;
				}
				float num2 = Vector3.Distance(((Component)reviver).transform.position, val2.deadBody.bodyParts[5].position);
				if (refusal != Refusal.None)
				{
					if (num2 <= range)
					{
						why = refusal;
					}
				}
				else if (num2 > range)
				{
					if (num2 <= range * 2f && why == Refusal.NoBody)
					{
						why = Refusal.TooFar;
					}
				}
				else if (num2 < num)
				{
					val = val2;
					num = num2;
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				why = Refusal.None;
			}
			return val;
		}

		internal static bool FindKneelSpot(PlayerControllerB reviver, DeadBodyInfo body, out Vector3 spot, out float yaw)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = body.bodyParts[5].position;
			Vector3 val = ((Component)reviver).transform.position - position;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
			{
				val = -((Component)reviver).transform.forward;
			}
			Quaternion val2 = Quaternion.LookRotation(-val);
			float y = ((Quaternion)(ref val2)).eulerAngles.y;
			float[] sidesToTry = SidesToTry;
			foreach (float num in sidesToTry)
			{
				yaw = y + num;
				if (TryKneelSpot(position, yaw, out spot))
				{
					return true;
				}
			}
			spot = default(Vector3);
			yaw = y;
			return false;
		}

		private static bool TryKneelSpot(Vector3 chest, float yaw, out Vector3 spot)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_005a: 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_0081: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ReviveClip.Instance.BodyChest(16f).position;
			position.y = 0f;
			spot = chest - Quaternion.Euler(0f, yaw, 0f) * position;
			NavMeshHit val = default(NavMeshHit);
			if (!NavMesh.SamplePosition(spot, ref val, 1f, -1) || Mathf.Abs(((NavMeshHit)(ref val)).position.y - spot.y) > 1.2f)
			{
				return false;
			}
			spot = ((NavMeshHit)(ref val)).position;
			return !Physics.Linecast(spot + Vector3.up * 1f, chest + Vector3.up * 0.4f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1);
		}

		internal static void Bring(PlayerControllerB p, PlayerControllerB reviver, Vector3 position, int health)
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound instance = StartOfRound.Instance;
			int num = (int)p.playerClientId;
			p.ResetPlayerBloodObjects(true);
			p.isClimbingLadder = false;
			p.clampLooking = false;
			p.inVehicleAnimation = false;
			p.overridePoisonValue = false;
			p.disableMoveInput = false;
			p.ResetZAndXRotation();
			((Collider)p.thisController).enabled = true;
			p.health = health;
			p.hasBeenCriticallyInjured = false;
			p.disableLookInput = false;
			p.disableInteract = false;
			((Behaviour)p.nightVisionRadar).enabled = false;
			p.isPlayerDead = false;
			p.enemyWaitingForBodyRagdoll = null;
			p.isPlayerControlled = true;
			p.isInElevator = reviver.isInElevator;
			p.isInHangarShipRoom = reviver.isInHangarShipRoom;
			p.isInsideFactory = reviver.isInsideFactory;
			p.parentedToElevatorLastFrame = false;
			p.overrideGameOverSpectatePivot = null;
			p.TeleportPlayer(position, false, 0f, false, true);
			p.setPositionOfDeadPlayer = false;
			p.DisablePlayerModel(((Component)p).gameObject, true, true);
			((Behaviour)p.helmetLight).enabled = false;
			p.Crouch(false);
			p.criticallyInjured = false;
			if ((Object)(object)p.playerBodyAnimator != (Object)null)
			{
				p.playerBodyAnimator.SetBool("Limp", false);
				if (!((NetworkBehaviour)p).IsOwner)
				{
					p.playerBodyAnimator.SetTrigger("SpawnPlayer");
				}
			}
			p.bleedingHeavily = false;
			p.activatingItem = false;
			p.twoHanded = false;
			p.inShockingMinigame = false;
			p.inSpecialInteractAnimation = false;
			p.freeRotationInInteractAnimation = false;
			p.disableSyncInAnimation = false;
			p.inAnimationWithEnemy = null;
			p.holdingWalkieTalkie = false;
			p.speakingToWalkieTalkie = false;
			p.isSinking = false;
			p.isUnderwater = false;
			p.sinkingValue = 0f;
			p.statusEffectAudio.Stop();
			p.DisableJetpackControlsLocally();
			p.mapRadarDotAnimator.SetBool("dead", false);
			p.externalForceAutoFade = Vector3.zero;
			p.carryWeight = 1f;
			p.voiceMuffledByEnemy = false;
			SoundManager.Instance.playerVoicePitchTargets[num] = 1f;
			SoundManager.Instance.SetPlayerPitch(1f, num);
			PlayerVoiceIngameSettings currentVoiceChatIngameSettings = p.currentVoiceChatIngameSettings;
			OccludeAudio val = default(OccludeAudio);
			if ((Object)(object)currentVoiceChatIngameSettings != (Object)null && (Object)(object)currentVoiceChatIngameSettings.voiceAudio != (Object)null && ((Component)currentVoiceChatIngameSettings.voiceAudio).TryGetComponent<OccludeAudio>(ref val))
			{
				val.overridingLowPass = false;
			}
			if (((NetworkBehaviour)p).IsOwner)
			{
				HUDManager instance2 = HUDManager.Instance;
				instance2.SetCracksOnVisor((float)health);
				instance2.gasHelmetAnimator.SetBool("gasEmitting", false);
				p.hasBegunSpectating = false;
				instance2.RemoveSpectateUI();
				instance2.gameOverAnimator.SetTrigger("revive");
				p.hinderedMultiplier = 1f;
				p.isMovementHindered = 0;
				p.sourcesCausingSinking = 0;
				instance.SendChangedWeightEvent();
				instance2.HideHUD(false);
				instance2.UpdateHealthUI(health, false);
				((Behaviour)instance2.audioListenerLowPass).enabled = false;
				instance2.cadaverFilter = 0f;
				p.spectatedPlayerScript = null;
				instance.SetSpectateCameraToGameOverMode(false, p);
				instance2.DisplayTip("Revived", "Someone fed you Shaqibles.", false, false, "LC_Tip1");
			}
			instance.livingPlayers++;
			instance.allPlayersDead = false;
			instance.UpdatePlayerVoiceEffects();
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController != (Object)null && localPlayerController.isPlayerDead)
			{
				HUDManager.Instance.UpdateBoxesSpectateUI();
			}
		}

		internal static void Attach(DeadBodyInfo body, Transform guide)
		{
			body.attachedLimb = body.bodyParts[5];
			body.attachedTo = guide;
			body.matchPositionExactly = true;
			body.lerpBeforeMatchingPosition = false;
			body.canBeGrabbedBackByPlayers = false;
		}

		internal static void Release(DeadBodyInfo? body, bool canBeGrabbed)
		{
			if (!((Object)(object)body == (Object)null))
			{
				body.attachedTo = null;
				body.attachedLimb = null;
				body.canBeGrabbedBackByPlayers = canBeGrabbed;
			}
		}
	}
	[DefaultExecutionOrder(10000)]
	internal class ReviveAnimation : MonoBehaviour
	{
		private const float BlendInFrames = 6f;

		private const float BlendOutFrames = 10f;

		private const string HandPath = "spine/spine.001/spine.002/spine.003/shoulder.R/arm.R_upper/arm.R_lower/hand.R";

		private static readonly Vector3 GripPosition = new Vector3(0.0711f, 0.0951f, -0.0232f);

		private static readonly Quaternion GripRotation = new Quaternion(0.1688f, 0.32039f, 0.69078f, 0.62584f);

		private ReviveClip clip;

		private Transform[] bones;

		private Transform pelvis;

		private Transform hand;

		private Transform? carried;

		private float startTime;

		public float Frame => (Time.time - startTime) * (float)clip.Fps;

		public static ReviveAnimation Play(PlayerControllerB player, Transform? carried)
		{
			Transform transform = ((Component)player.playerBodyAnimator).transform;
			ReviveAnimation reviveAnimation = ((Component)transform).gameObject.AddComponent<ReviveAnimation>();
			reviveAnimation.clip = ReviveClip.Instance;
			reviveAnimation.bones = (Transform[])(object)new Transform[reviveAnimation.clip.Paths.Length];
			for (int i = 0; i < reviveAnimation.bones.Length; i++)
			{
				reviveAnimation.bones[i] = transform.Find(reviveAnimation.clip.Paths[i]);
				if ((Object)(object)reviveAnimation.bones[i] == (Object)null)
				{
					Plugin.Logger.LogWarning((object)("Revive animation: no bone at " + reviveAnimation.clip.Paths[i]));
				}
			}
			reviveAnimation.pelvis = transform.Find("spine");
			reviveAnimation.hand = transform.Find("spine/spine.001/spine.002/spine.003/shoulder.R/arm.R_upper/arm.R_lower/hand.R");
			reviveAnimation.carried = carried;
			reviveAnimation.startTime = Time.time;
			return reviveAnimation;
		}

		private void LateUpdate()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_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)
			//IL_00f9: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			float frame = Frame;
			float num = Mathf.Clamp01(Mathf.Min(frame / 6f, ((float)clip.End - frame) / 10f));
			if (num <= 0f)
			{
				return;
			}
			for (int i = 0; i < bones.Length; i++)
			{
				if ((Object)(object)bones[i] != (Object)null)
				{
					bones[i].localRotation = Quaternion.Slerp(bones[i].localRotation, clip.Rotation(i, frame), num);
				}
			}
			if ((Object)(object)pelvis != (Object)null)
			{
				pelvis.localPosition = Vector3.Lerp(pelvis.localPosition, clip.Pelvis(frame), num);
			}
			if ((Object)(object)carried != (Object)null && (Object)(object)hand != (Object)null)
			{
				carried.SetPositionAndRotation(hand.position + hand.rotation * GripPosition, hand.rotation * GripRotation);
			}
		}
	}
	[DefaultExecutionOrder(-10000)]
	internal class ReviveCamera : MonoBehaviour
	{
		private static readonly Vector3 LookAt = new Vector3(0.2f, 0.5f, 0.8f);

		private const float StartYaw = 35f;

		private const float StartPitch = 33f;

		private const float Distance = 4f;

		private const float MinPitch = 5f;

		private const float MaxPitch = 80f;

		private const float EaseFrames = 12f;

		private const float WallPadding = 0.25f;

		private static ReviveCamera? active;

		private PlayerControllerB player;

		private Transform frame;

		private ReviveAnimation anim;

		private Transform cam;

		private ShadowCastingMode savedShadows;

		private bool savedVisor;

		private bool savedLookLock;

		private Renderer[] visorMeshes;

		private bool[] visorMeshesShown;

		private float yaw = 35f;

		private float pitch = 33f;

		private bool moved;

		private Vector3 savedPosition;

		private Quaternion savedRotation;

		public static void Begin(PlayerControllerB local, Transform reviveFrame, ReviveAnimation animation)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			End();
			active = new GameObject("ShaqibleReviveCamera").AddComponent<ReviveCamera>();
			active.player = local;
			active.frame = reviveFrame;
			active.anim = animation;
			active.cam = ((Component)local.gameplayCamera).transform;
			active.savedShadows = ((Renderer)local.thisPlayerModel).shadowCastingMode;
			((Renderer)local.thisPlayerModel).shadowCastingMode = (ShadowCastingMode)1;
			((Renderer)local.thisPlayerModelArms).enabled = false;
			active.savedVisor = ((Behaviour)local.visorCamera).enabled;
			((Behaviour)local.visorCamera).enabled = false;
			active.visorMeshes = ((Component)local.localVisor).GetComponentsInChildren<Renderer>();
			active.visorMeshesShown = new bool[active.visorMeshes.Length];
			for (int i = 0; i < active.visorMeshes.Length; i++)
			{
				active.visorMeshesShown[i] = active.visorMeshes[i].enabled;
				active.visorMeshes[i].enabled = false;
			}
			active.savedLookLock = local.disableLookInput;
			local.disableLookInput = true;
			Application.onBeforeRender += new UnityAction(active.Apply);
		}

		public static void End()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)active == (Object)null)
			{
				return;
			}
			Application.onBeforeRender -= new UnityAction(active.Apply);
			active.Restore();
			PlayerControllerB val = active.player;
			if ((Object)(object)val != (Object)null)
			{
				val.disableLookInput = active.savedLookLock;
				for (int i = 0; i < active.visorMeshes.Length; i++)
				{
					if ((Object)(object)active.visorMeshes[i] != (Object)null)
					{
						active.visorMeshes[i].enabled = active.visorMeshesShown[i];
					}
				}
				if (!val.isPlayerDead)
				{
					((Renderer)val.thisPlayerModel).shadowCastingMode = active.savedShadows;
					((Renderer)val.thisPlayerModelArms).enabled = true;
					((Behaviour)val.visorCamera).enabled = active.savedVisor;
				}
			}
			Object.Destroy((Object)(object)((Component)active).gameObject);
			active = null;
		}

		private void OnDestroy()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			Application.onBeforeRender -= new UnityAction(Apply);
			if ((Object)(object)active == (Object)(object)this)
			{
				active = null;
			}
		}

		private void Update()
		{
			Restore();
			Orbit();
		}

		private void Restore()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (moved && (Object)(object)cam != (Object)null)
			{
				cam.localPosition = savedPosition;
				cam.localRotation = savedRotation;
			}
			moved = false;
		}

		private void Orbit()
		{
			//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_004c: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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)
			if (!((Object)(object)player == (Object)null) && !player.quickMenuManager.isMenuOpen && !player.isTypingChat)
			{
				IngamePlayerSettings instance = IngamePlayerSettings.Instance;
				MovementActions movement = player.playerActions.Movement;
				Vector2 val = ((MovementActions)(ref movement)).Look.ReadValue<Vector2>() * 0.008f * (float)instance.settings.lookSensitivity;
				if (instance.flipCamera)
				{
					val.x = 0f - val.x;
				}
				if (instance.settings.invertYAxis)
				{
					val.y = 0f - val.y;
				}
				yaw += val.x;
				pitch = Mathf.Clamp(pitch - val.y, 5f, 80f);
			}
		}

		private void Apply()
		{
			//IL_0072: 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_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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00ac: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: 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_00e0: 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_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_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_00ef: 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_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_0140: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)cam == (Object)null) && !((Object)(object)frame == (Object)null) && !((Object)(object)anim == (Object)null))
			{
				float num = anim.Frame;
				float num2 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(Mathf.Min(num / 12f, ((float)ReviveClip.Instance.End - num) / 12f)));
				savedPosition = cam.localPosition;
				savedRotation = cam.localRotation;
				moved = true;
				Vector3 val = frame.TransformPoint(LookAt);
				Vector3 val2 = val + frame.rotation * (Quaternion.Euler(pitch, yaw, 0f) * Vector3.back) * 4f;
				Vector3 val3 = val2 - val;
				RaycastHit val4 = default(RaycastHit);
				if (Physics.SphereCast(val, 0.2f, ((Vector3)(ref val3)).normalized, ref val4, ((Vector3)(ref val3)).magnitude, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
				{
					val2 = val + ((Vector3)(ref val3)).normalized * Mathf.Max(0.5f, ((RaycastHit)(ref val4)).distance - 0.25f);
				}
				cam.position = Vector3.Lerp(cam.position, val2, num2);
				cam.rotation = Quaternion.Slerp(cam.rotation, Quaternion.LookRotation(val - val2, Vector3.up), num2);
			}
		}
	}
	internal class ReviveClip
	{
		internal static ReviveClip Instance;

		public int Fps;

		public int Frames;

		public int Pour;

		public int Spank;

		public int End;

		public string[] Paths;

		private Quaternion[][] rotations;

		private Vector3[] pelvis;

		private Pose[] bodyHips;

		private Pose[] bodyChest;

		public static void Load(byte[] data)
		{
			//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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			ReviveClip reviveClip = new ReviveClip();
			using BinaryReader binaryReader = new BinaryReader(new MemoryStream(data));
			binaryReader.ReadInt32();
			reviveClip.Fps = binaryReader.ReadInt32();
			reviveClip.Frames = binaryReader.ReadInt32();
			reviveClip.Pour = binaryReader.ReadInt32();
			binaryReader.ReadInt32();
			binaryReader.ReadInt32();
			reviveClip.Spank = binaryReader.ReadInt32();
			reviveClip.End = binaryReader.ReadInt32();
			int num = binaryReader.ReadInt32();
			reviveClip.Paths = new string[num];
			reviveClip.rotations = new Quaternion[num][];
			for (int i = 0; i < num; i++)
			{
				reviveClip.Paths[i] = Encoding.UTF8.GetString(binaryReader.ReadBytes(binaryReader.ReadInt32()));
				reviveClip.rotations[i] = (Quaternion[])(object)new Quaternion[reviveClip.Frames];
				for (int j = 0; j < reviveClip.Frames; j++)
				{
					reviveClip.rotations[i][j] = new Quaternion(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
				}
			}
			reviveClip.pelvis = (Vector3[])(object)new Vector3[reviveClip.Frames];
			for (int k = 0; k < reviveClip.Frames; k++)
			{
				reviveClip.pelvis[k] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
			}
			reviveClip.bodyHips = ReadPoses(binaryReader, reviveClip.Frames);
			reviveClip.bodyChest = ReadPoses(binaryReader, reviveClip.Frames);
			Instance = reviveClip;
		}

		private static Pose[] ReadPoses(BinaryReader r, int frames)
		{
			//IL_0026: 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)
			Pose[] array = (Pose[])(object)new Pose[frames];
			Vector3 val = default(Vector3);
			for (int i = 0; i < frames; i++)
			{
				((Vector3)(ref val))..ctor(r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
				array[i] = new Pose(val, new Quaternion(r.ReadSingle(), r.ReadSingle(), r.ReadSingle(), r.ReadSingle()));
			}
			return array;
		}

		private void Sample(float frame, out int a, out int b, out float t)
		{
			frame = Mathf.Clamp(frame, 0f, (float)(Frames - 1));
			a = Mathf.FloorToInt(frame);
			b = Mathf.Min(a + 1, Frames - 1);
			t = frame - (float)a;
		}

		public Quaternion Rotation(int bone, float frame)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			Sample(frame, out var a, out var b, out var t);
			return Quaternion.Slerp(rotations[bone][a], rotations[bone][b], t);
		}

		public Vector3 Pelvis(float frame)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			Sample(frame, out var a, out var b, out var t);
			return Vector3.Lerp(pelvis[a], pelvis[b], t);
		}

		public Pose BodyChest(float frame)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return Blend(bodyChest, frame);
		}

		public Pose BodyHips(float frame)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return Blend(bodyHips, frame);
		}

		private Pose Blend(Pose[] poses, float frame)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Sample(frame, out var a, out var b, out var t);
			return new Pose(Vector3.Lerp(poses[a].position, poses[b].position, t), Quaternion.Slerp(poses[a].rotation, poses[b].rotation, t));
		}
	}
	public class ShaqibleItem : GrabbableObject
	{
		public ParticleSystem gummies;

		public AudioSource sfx;

		public AudioClip pourClip;

		public AudioClip spankClip;

		public AudioClip gaspClip;

		private const float SpankImpulse = 2.5f;

		private Coroutine? running;

		private PlayerControllerB? reviveBy;

		private ReviveAnimation? reviveAnim;

		private Transform? reviveFrame;

		private DeadBodyInfo? reviveBody;

		private bool reviveBodyCouldBeGrabbed;

		private bool revived;

		private bool cancelled;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (((NetworkBehaviour)this).IsOwner && !((Object)(object)base.playerHeldBy == (Object)null) && running == null)
			{
				Revive.Refusal why;
				PlayerControllerB val = Revive.FindBody(base.playerHeldBy, Plugin.BoundConfig.ReviveRange.Value, out why);
				if ((Object)(object)val == (Object)null)
				{
					Tip(why);
				}
				else
				{
					RequestReviveServerRpc((int)base.playerHeldBy.playerClientId, (int)val.playerClientId);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void RequestReviveServerRpc(int reviverId, int deadId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3557230986u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, reviverId);
				BytePacker.WriteValueBitPacked(val, deadId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 3557230986u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			StartOfRound instance = StartOfRound.Instance;
			PlayerControllerB val3 = instance.allPlayerScripts[reviverId];
			PlayerControllerB val4 = instance.allPlayerScripts[deadId];
			Revive.Refusal refusal = Revive.CheckBody(val4);
			if (refusal != Revive.Refusal.None || (running == null && !val3.isPlayerDead && !((Object)(object)val3.currentlyHeldObjectServer != (Object)(object)this)))
			{
				if (refusal == Revive.Refusal.None && Vector3.Distance(((Component)val3).transform.position, val4.deadBody.bodyParts[5].position) > Plugin.BoundConfig.ReviveRange.Value * 1.5f)
				{
					refusal = Revive.Refusal.TooFar;
				}
				Vector3 spot = default(Vector3);
				float yaw = 0f;
				if (refusal == Revive.Refusal.None && !Revive.FindKneelSpot(val3, val4.deadBody, out spot, out yaw))
				{
					refusal = Revive.Refusal.NoRoom;
				}
				if (refusal != Revive.Refusal.None)
				{
					RefusedClientRpc(reviverId, (int)refusal);
				}
				else
				{
					PlayReviveClientRpc(reviverId, deadId, spot, yaw, Mathf.Clamp(Plugin.BoundConfig.ReviveHealth.Value, 1, 100));
				}
			}
		}

		[ClientRpc]
		public void RefusedClientRpc(int reviverId, int why)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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(133335847u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, reviverId);
				BytePacker.WriteValueBitPacked(val, why);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 133335847u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if ((Object)(object)StartOfRound.Instance.allPlayerScripts[reviverId] == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					Tip((Revive.Refusal)why);
				}
			}
		}

		[ClientRpc]
		public void PlayReviveClientRpc(int reviverId, int deadId, Vector3 spot, float yaw, int health)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_007e: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_0148: 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(123894390u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, reviverId);
				BytePacker.WriteValueBitPacked(val, deadId);
				((FastBufferWriter)(ref val)).WriteValueSafe(ref spot);
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref yaw, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val, health);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 123894390u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				StartOfRound instance = StartOfRound.Instance;
				if (running != null)
				{
					((MonoBehaviour)this).StopCoroutine(running);
					EndSequence();
				}
				running = ((MonoBehaviour)this).StartCoroutine(Sequence(instance.allPlayerScripts[reviverId], instance.allPlayerScripts[deadId], spot, yaw, health));
			}
		}

		private IEnumerator Sequence(PlayerControllerB reviver, PlayerControllerB dead, Vector3 spot, float yaw, int health)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			ReviveClip clip = ReviveClip.Instance;
			DeadBodyInfo body = (reviveBody = dead.deadBody);
			reviveBodyCouldBeGrabbed = (Object)(object)body != (Object)null && body.canBeGrabbedBackByPlayers;
			ShaqibleItem shaqibleItem = this;
			ShaqibleItem shaqibleItem2 = this;
			bool flag = false;
			shaqibleItem2.cancelled = false;
			shaqibleItem.revived = flag;
			Transform frame = (reviveFrame = new GameObject("ShaqibleRevive").transform);
			frame.SetPositionAndRotation(spot, Quaternion.Euler(0f, yaw, 0f));
			reviveBy = reviver;
			reviver.TeleportPlayer(spot, true, yaw, false, true);
			reviver.inSpecialInteractAnimation = true;
			if (((NetworkBehaviour)reviver).IsOwner)
			{
				reviver.disableMoveInput = true;
				reviver.disableInteract = true;
			}
			ReviveAnimation anim = (reviveAnim = ReviveAnimation.Play(reviver, ((Component)this).transform));
			if (((NetworkBehaviour)reviver).IsOwner)
			{
				ReviveCamera.Begin(reviver, frame, anim);
			}
			Transform guide = new GameObject("ShaqibleBodyGuide").transform;
			guide.SetParent(frame, false);
			Pose fell = default(Pose);
			if ((Object)(object)body != (Object)null)
			{
				fell = new Pose(body.bodyParts[5].position, body.bodyParts[5].rotation);
				Revive.Attach(body, guide);
			}
			bool poured = false;
			bool smacked = false;
			bool decided = false;
			NavMeshHit val3 = default(NavMeshHit);
			while (anim.Frame < (float)clip.End && !cancelled)
			{
				float frame2 = anim.Frame;
				if (((NetworkBehaviour)this).IsServer && !decided && frame2 < (float)clip.Spank && Interrupted(reviver, dead, body))
				{
					decided = true;
					CancelReviveClientRpc();
				}
				if (!revived && (Object)(object)body != (Object)null)
				{
					Pose val = clip.BodyChest(frame2);
					float num = Mathf.SmoothStep(0f, 1f, frame2 / 16f);
					guide.position = Vector3.Lerp(fell.position, frame.TransformPoint(val.position), num);
					guide.rotation = Quaternion.Slerp(fell.rotation, frame.rotation * val.rotation, num);
				}
				if (!poured && frame2 >= (float)clip.Pour)
				{
					poured = true;
					gummies.Play();
					sfx.PlayOneShot(pourClip);
				}
				if (!smacked && frame2 >= (float)clip.Spank)
				{
					smacked = true;
					sfx.PlayOneShot(spankClip);
					if ((Object)(object)body != (Object)null)
					{
						body.bodyParts[6].AddForce(Vector3.down * 2.5f, (ForceMode)2);
					}
					if (((NetworkBehaviour)this).IsServer && !decided)
					{
						decided = true;
						Vector3 val2 = frame.TransformPoint(clip.BodyHips(frame2).position);
						if (NavMesh.SamplePosition(val2, ref val3, 1.5f, -1))
						{
							val2 = ((NavMeshHit)(ref val3)).position;
						}
						RevivedClientRpc((int)dead.playerClientId, (int)reviver.playerClientId, val2, health);
						if ((Object)(object)body != (Object)null && (Object)(object)body.grabBodyObject != (Object)null && ((NetworkBehaviour)body.grabBodyObject).NetworkObject.IsSpawned)
						{
							((NetworkBehaviour)body.grabBodyObject).NetworkObject.Despawn(true);
						}
					}
				}
				yield return null;
			}
			EndSequence();
			if (revived && ((NetworkBehaviour)reviver).IsOwner && (Object)(object)reviver.currentlyHeldObjectServer == (Object)(object)this)
			{
				reviver.DespawnHeldObject();
			}
		}

		private void EndSequence()
		{
			running = null;
			PlayerControllerB val = reviveBy;
			reviveBy = null;
			if ((Object)(object)val != (Object)null)
			{
				if (((NetworkBehaviour)val).IsOwner)
				{
					ReviveCamera.End();
					val.disableMoveInput = false;
					val.disableInteract = false;
				}
				val.inSpecialInteractAnimation = false;
			}
			if ((Object)(object)reviveAnim != (Object)null)
			{
				Object.Destroy((Object)(object)reviveAnim);
			}
			if ((Object)(object)reviveFrame != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)reviveFrame).gameObject);
			}
			reviveAnim = null;
			reviveFrame = null;
			if (!revived)
			{
				Revive.Release(reviveBody, reviveBodyCouldBeGrabbed);
			}
		}

		public override void OnDestroy()
		{
			if (running != null)
			{
				EndSequence();
			}
			((GrabbableObject)this).OnDestroy();
		}

		[ClientRpc]
		public void RevivedClientRpc(int deadId, int reviverId, Vector3 stand, int health)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_007e: 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_00b0: 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_014a: 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(3786802215u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, deadId);
				BytePacker.WriteValueBitPacked(val, reviverId);
				((FastBufferWriter)(ref val)).WriteValueSafe(ref stand);
				BytePacker.WriteValueBitPacked(val, health);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 3786802215u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				StartOfRound instance = StartOfRound.Instance;
				PlayerControllerB val3 = instance.allPlayerScripts[deadId];
				revived = true;
				DeadBodyInfo val4 = (DeadBodyInfo)(((Object)(object)reviveBody != (Object)null) ? ((object)reviveBody) : ((object)val3.deadBody));
				Revive.Release(val4, reviveBodyCouldBeGrabbed);
				if (val3.isPlayerDead)
				{
					Revive.Bring(val3, instance.allPlayerScripts[reviverId], stand, health);
				}
				sfx.PlayOneShot(gaspClip);
				if ((Object)(object)val4 != (Object)null && (Object)(object)val4.grabBodyObject == (Object)null)
				{
					Object.Destroy((Object)(object)((Component)val4).gameObject);
				}
			}
		}

		[ClientRpc]
		public void CancelReviveClientRpc()
		{
			//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.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2755842765u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 2755842765u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					cancelled = true;
				}
			}
		}

		private bool Interrupted(PlayerControllerB reviver, PlayerControllerB dead, DeadBodyInfo? body)
		{
			if (!((Object)(object)reviver == (Object)null) && !reviver.isPlayerDead && reviver.isPlayerControlled && !((Object)(object)reviver.currentlyHeldObjectServer != (Object)(object)this) && !((Object)(object)dead == (Object)null) && dead.isPlayerDead && !((Object)(object)body == (Object)null) && !body.deactivated)
			{
				return !((Component)body).gameObject.activeSelf;
			}
			return true;
		}

		private static void Tip(Revive.Refusal why)
		{
			HUDManager.Instance.DisplayTip("Shaqible", Revive.Explain(why), false, false, "LC_Tip1");
		}

		protected override void __initializeVariables()
		{
			((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
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3557230986u, new RpcReceiveHandler(__rpc_handler_3557230986), "RequestReviveServerRpc");
			((NetworkBehaviour)this).__registerRpc(133335847u, new RpcReceiveHandler(__rpc_handler_133335847), "RefusedClientRpc");
			((NetworkBehaviour)this).__registerRpc(123894390u, new RpcReceiveHandler(__rpc_handler_123894390), "PlayReviveClientRpc");
			((NetworkBehaviour)this).__registerRpc(3786802215u, new RpcReceiveHandler(__rpc_handler_3786802215), "RevivedClientRpc");
			((NetworkBehaviour)this).__registerRpc(2755842765u, new RpcReceiveHandler(__rpc_handler_2755842765), "CancelReviveClientRpc");
			((GrabbableObject)this).__initializeRpcs();
		}

		private static void __rpc_handler_3557230986(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0043: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int reviverId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref reviverId);
				int deadId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref deadId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ShaqibleItem)(object)target).RequestReviveServerRpc(reviverId, deadId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_133335847(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0043: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int reviverId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref reviverId);
				int why = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref why);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ShaqibleItem)(object)target).RefusedClientRpc(reviverId, why);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_123894390(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0056: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int reviverId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref reviverId);
				int deadId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref deadId);
				Vector3 spot = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref spot);
				float yaw = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref yaw, default(ForPrimitives));
				int health = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref health);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ShaqibleItem)(object)target).PlayReviveClientRpc(reviverId, deadId, spot, yaw, health);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3786802215(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int deadId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref deadId);
				int reviverId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref reviverId);
				Vector3 stand = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref stand);
				int health = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref health);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ShaqibleItem)(object)target).RevivedClientRpc(deadId, reviverId, stand, health);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2755842765(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;
				((ShaqibleItem)(object)target).CancelReviveClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ShaqibleItem";
		}
	}
	internal class ShaqibleTestKeys : MonoBehaviour
	{
		private const Key SpawnKey = (Key)100;

		private const Key DieKey = (Key)99;

		public static void Install()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			GameObject val = new GameObject("ShaqibleTestKeys");
			((Object)val).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)val);
			val.AddComponent<ShaqibleTestKeys>();
			Plugin.Logger.LogInfo((object)"Test keys on: F7 (host) drops a Shaqible box, F6 drops you dead.");
		}

		private void Update()
		{
			//IL_005a: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			Keyboard current = Keyboard.current;
			if (current == null)
			{
				return;
			}
			if (((ButtonControl)current[(Key)100]).wasPressedThisFrame)
			{
				SpawnBox();
			}
			else if (((ButtonControl)current[(Key)99]).wasPressedThisFrame)
			{
				PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
				if ((Object)(object)val != (Object)null && !val.isPlayerDead && val.isPlayerControlled)
				{
					val.KillPlayer(Vector3.up, true, (CauseOfDeath)0, 0, default(Vector3), false);
				}
			}
		}

		private static void SpawnBox()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
			if ((Object)(object)val == (Object)null || (Object)(object)Plugin.ShaqibleItemType == (Object)null || !NetworkManager.Singleton.IsServer)
			{
				HUDManager instance = HUDManager.Instance;
				if (instance != null)
				{
					instance.DisplayTip("Shaqible test", "Only the host can spawn a box.", false, false, "LC_Tip1");
				}
				return;
			}
			Item shaqibleItemType = Plugin.ShaqibleItemType;
			Vector3 val2 = ((Component)val).transform.position + ((Component)val).transform.forward * 1f + Vector3.up * 0.5f;
			GameObject val3 = Object.Instantiate<GameObject>(shaqibleItemType.spawnPrefab, val2, Quaternion.identity, RoundManager.Instance.spawnedScrapContainer);
			GrabbableObject component = val3.GetComponent<GrabbableObject>();
			component.fallTime = 0f;
			int num = (int)((float)Random.Range(shaqibleItemType.minValue, shaqibleItemType.maxValue) * RoundManager.Instance.scrapValueMultiplier);
			NetworkObject component2 = val3.GetComponent<NetworkObject>();
			component2.Spawn(false);
			RoundManager.Instance.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(component2) }, new int[1] { num });
			HUDManager.Instance.DisplayTip("Shaqible test", "Dropped a Shaqible box.", false, false, "LC_Tip1");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "aj.Shaqible";

		public const string PLUGIN_NAME = "Shaqible";

		public const string PLUGIN_VERSION = "1.0.3";
	}
}
namespace Shaqible.Configuration
{
	public class PluginConfig
	{
		public ConfigEntry<int> SpawnWeight;

		public ConfigEntry<int> MinValue;

		public ConfigEntry<int> MaxValue;

		public ConfigEntry<float> ReviveRange;

		public ConfigEntry<int> ReviveHealth;

		public ConfigEntry<bool> TestKeys;

		public PluginConfig(ConfigFile cfg)
		{
			SpawnWeight = cfg.Bind<int>("General", "Spawn weight", 40, "How often a Shaqible box turns up as scrap inside the facility, relative to other scrap on that moon.\nVanilla scrap runs from about 1 (very rare) to 100 (very common). Several can spawn in one round.");
			MinValue = cfg.Bind<int>("General", "Minimum value", 150, "Lowest sell value of a box, in credits (what you get at the company at 100%).");
			MaxValue = cfg.Bind<int>("General", "Maximum value", 250, "Highest sell value of a box, in credits.");
			ReviveRange = cfg.Bind<float>("Revive", "Revive range", 2.5f, "How close (metres) you have to be to a dead body's chest to feed it Shaqibles.");
			ReviveHealth = cfg.Bind<int>("Revive", "Revive health", 50, "Health the revived player comes back with (out of 100). The host's setting is used.");
			TestKeys = cfg.Bind<bool>("Testing", "Test keys", false, "For testing only. When on, the host can press F7 to drop a Shaqible box at their feet, and anyone can press F6 to drop dead (to have something to revive). Takes effect after restarting the game.");
			ClearUnusedEntries(cfg);
		}

		private void ClearUnusedEntries(ConfigFile cfg)
		{
			PropertyInfo property = ((object)cfg).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(cfg, null);
			dictionary.Clear();
			cfg.Save();
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace aj.Shaqible.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}