Decompiled source of The Crewmate v1.0.7

plugins/CrewmateItems/ImposterItems.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Alexandria.ItemAPI;
using BepInEx;
using Gungeon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ImposterItems")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ImposterItems")]
[assembly: AssemblyCopyright("Copyright ©  2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("840a947f-ee72-47cf-8335-d5437a8b149b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ImposterItems
{
	public class ImpostersKnife : PlayerItem
	{
		[CompilerGenerated]
		private sealed class <HandleSwing>d__14 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public PlayerController user;

			public Vector2 aimVec;

			public float rayDamagePerSecond;

			public float rayLength;

			public ImpostersKnife <>4__this;

			private float <elapsed>5__1;

			private SpeculativeRigidbody <hitRigidbody>5__2;

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

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

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

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

			private bool MoveNext()
			{
				//IL_005f: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.isStabbing = true;
					<elapsed>5__1 = 0f;
					break;
				case 1:
					<>1__state = -1;
					<hitRigidbody>5__2 = null;
					break;
				}
				if (<elapsed>5__1 < 1f)
				{
					<elapsed>5__1 += BraveTime.DeltaTime;
					<hitRigidbody>5__2 = <>4__this.IterativeRaycast(((GameActor)user).CenterPosition, aimVec, rayLength, int.MaxValue, ((BraveBehaviour)user).specRigidbody);
					if (Object.op_Implicit((Object)(object)<hitRigidbody>5__2) && Object.op_Implicit((Object)(object)((BraveBehaviour)<hitRigidbody>5__2).aiActor) && ((BraveBehaviour)<hitRigidbody>5__2).aiActor.IsNormalEnemy)
					{
						((BraveBehaviour)((BraveBehaviour)<hitRigidbody>5__2).aiActor).healthHaver.ApplyDamage(rayDamagePerSecond * BraveTime.DeltaTime, aimVec, "Imposter's Knife", (CoreDamageTypes)0, (DamageCategory)0, false, (PixelCollider)null, false);
					}
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				<>4__this.isStabbing = false;
				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 Material m_material;

		public static int ImpostersKnifeId;

		public Shader DarknessEffectShader;

		public bool isStabbing;

		public VFXPool stabVfx;

		public static void Init()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Expected O, but got Unknown
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Expected O, but got Unknown
			string text = "Imposter's Knife";
			string text2 = "ImposterItems/Resources/imposter_knife";
			GameObject val = new GameObject(text);
			ImpostersKnife impostersKnife = val.AddComponent<ImpostersKnife>();
			ItemBuilder.AddSpriteToObject(text, text2, val, (Assembly)null);
			string text3 = "Wasn't me";
			string text4 = "On use, deliver a quick short range, high damage stab towards a direction of your choosing.\n\nSharp, quick, reliable, and most importantly never runs out of ammo. It's no wonder why the knife is such an effective killing device, held back only for it's short range..maybe there's some kind of workaround to that...";
			ItemBuilder.SetupItem((PickupObject)(object)impostersKnife, text3, text4, "spapi");
			ItemBuilder.SetCooldownType((PlayerItem)(object)impostersKnife, (CooldownType)1, 500f);
			((PlayerItem)impostersKnife).consumable = false;
			((PickupObject)impostersKnife).quality = (ItemQuality)(-50);
			impostersKnife.DarknessEffectShader = ShaderCache.Acquire("Hidden/DarknessChallengeShader");
			GameObject val2 = SpriteBuilder.SpriteFromResource("ImposterItems/Resources/imposter_knife_stab", new GameObject("ImposterKnifeStab"), (Assembly)null);
			val2.SetActive(false);
			FakePrefab.MarkAsFakePrefab(val2);
			Object.DontDestroyOnLoad((Object)(object)val2);
			tk2dSpriteAnimator val3 = val2.AddComponent<tk2dSpriteAnimator>();
			SpriteBuilder.AddAnimation(val3, val2.GetComponent<tk2dBaseSprite>().Collection, new List<int>(1) { val2.GetComponent<tk2dBaseSprite>().spriteId }, "stab", (WrapMode)2, 15f).fps = 1f;
			val3.playAutomatically = true;
			val3.DefaultClipId = val3.GetClipIdByName("stab");
			SpriteAnimatorKiller val4 = val2.AddComponent<SpriteAnimatorKiller>();
			val4.fadeTime = -1f;
			val4.delayDestructionTime = -1f;
			val4.animator = val3;
			ConstructOffsetsFromAnchor(val2.GetComponent<tk2dBaseSprite>().GetCurrentSpriteDef(), (Anchor)3);
			VFXPool val5 = new VFXPool();
			val5.type = (VFXPoolType)1;
			VFXComplex[] array = new VFXComplex[1];
			VFXComplex val6 = new VFXComplex();
			val6.effects = (VFXObject[])(object)new VFXObject[1]
			{
				new VFXObject
				{
					alignment = (VFXAlignment)0,
					attached = true,
					orphaned = false,
					persistsOnDeath = false,
					destructible = true,
					usesZHeight = true,
					zHeight = -0.25f,
					effect = val2
				}
			};
			array[0] = val6;
			val5.effects = (VFXComplex[])(object)array;
			impostersKnife.stabVfx = val5;
			ImpostersKnifeId = ((PickupObject)impostersKnife).PickupObjectId;
			Game.Items.Rename("spapi:imposter's_knife", "spapi:imposters_knife");
		}

		public static void ConstructOffsetsFromAnchor(tk2dSpriteDefinition def, Anchor anchor, Vector2? scale = null, bool fixesScale = false, bool changesCollider = true)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_004b: 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_0050: Expected I4, but got Unknown
			//IL_0031: 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_0041: 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_009a: 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_009f: Expected I4, but got Unknown
			//IL_007b: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			Vector2 valueOrDefault = scale.GetValueOrDefault();
			if (!scale.HasValue)
			{
				valueOrDefault = Vector2.op_Implicit(def.position3);
				scale = valueOrDefault;
			}
			if (fixesScale)
			{
				scale = scale.GetValueOrDefault() - Vector3Extensions.XY(def.position0);
			}
			int num = anchor % 3;
			if (1 == 0)
			{
			}
			float num2 = num switch
			{
				1 => 0f - scale.Value.x / 2f, 
				2 => 0f - scale.Value.x, 
				_ => 0f, 
			};
			if (1 == 0)
			{
			}
			float num3 = num2;
			int num4 = anchor / 3;
			if (1 == 0)
			{
			}
			num2 = num4 switch
			{
				1 => 0f - scale.Value.y / 2f, 
				2 => 0f - scale.Value.y, 
				_ => 0f, 
			};
			if (1 == 0)
			{
			}
			float num5 = num2;
			MakeOffset(def, new Vector2(num3, num5), changesCollider);
		}

		public static void MakeOffset(tk2dSpriteDefinition def, Vector2 offset, bool changesCollider = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0079: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			float x = offset.x;
			float y = offset.y;
			def.position0 += new Vector3(x, y, 0f);
			def.position1 += new Vector3(x, y, 0f);
			def.position2 += new Vector3(x, y, 0f);
			def.position3 += new Vector3(x, y, 0f);
			def.boundsDataCenter += new Vector3(x, y, 0f);
			def.boundsDataExtents += new Vector3(x, y, 0f);
			def.untrimmedBoundsDataCenter += new Vector3(x, y, 0f);
			def.untrimmedBoundsDataExtents += new Vector3(x, y, 0f);
			if (def.colliderVertices != null && def.colliderVertices.Length != 0 && changesCollider)
			{
				ref Vector3 reference = ref def.colliderVertices[0];
				reference += new Vector3(x, y, 0f);
			}
		}

		public Vector4 GetCenterPointInScreenUV(Vector2 centerPoint)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0021: 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_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_003f: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = GameManager.Instance.MainCameraController.Camera.WorldToViewportPoint(Vector2Extensions.ToVector3ZUp(centerPoint, 0f));
			return new Vector4(val.x, val.y, 0f, 0f);
		}

		public void LateUpdate()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_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_00a1: Invalid comparison between Unknown and I4
			//IL_0118: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)m_material == (Object)null || !base.m_isCurrentlyActive)
			{
				return;
			}
			float num = ((GameActor)GameManager.Instance.PrimaryPlayer).FacingDirection;
			if (num > 270f)
			{
				num -= 360f;
			}
			if (num < -270f)
			{
				num += 360f;
			}
			m_material.SetFloat("_ConeAngle", 0f);
			Vector4 centerPointInScreenUV = GetCenterPointInScreenUV(((GameActor)GameManager.Instance.PrimaryPlayer).CenterPosition);
			centerPointInScreenUV.z = num;
			Vector4 val = centerPointInScreenUV;
			if ((int)GameManager.Instance.CurrentGameType == 1)
			{
				float num2 = ((GameActor)GameManager.Instance.SecondaryPlayer).FacingDirection;
				if (num2 > 270f)
				{
					num2 -= 360f;
				}
				if (num2 < -270f)
				{
					num2 += 360f;
				}
				val = GetCenterPointInScreenUV(((GameActor)GameManager.Instance.SecondaryPlayer).CenterPosition);
				val.z = num2;
			}
			m_material.SetVector("_Player1ScreenPosition", centerPointInScreenUV);
			m_material.SetVector("_Player2ScreenPosition", val);
		}

		public override void OnPreDrop(PlayerController user)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			((MonoBehaviour)this).StopAllCoroutines();
			if (base.m_isCurrentlyActive)
			{
				if (Object.op_Implicit((Object)(object)Pixelator.Instance))
				{
					Pixelator.Instance.AdditionalCoreStackRenderPass = null;
				}
				((BraveBehaviour)user).specRigidbody.RemoveCollisionLayerIgnoreOverride(CollisionMask.LayerToMask((CollisionLayer)2, (CollisionLayer)3));
				user.ChangeSpecialShaderFlag(1, 0f);
				((GameActor)user).SetIsStealthed(false, "voting interface");
				user.SetCapableOfStealing(false, "VotingInterface", (float?)null);
			}
			EncounterTrackable.SuppressNextNotification = true;
			PlayerItem component = Object.Instantiate<GameObject>(((Component)PickupObjectDatabase.GetById(VotingInterface.VotingInterfaceId)).gameObject, Vector2.op_Implicit(Vector2.zero), Quaternion.identity).GetComponent<PlayerItem>();
			component.ForceAsExtant = true;
			((PickupObject)component).Pickup(user);
			EncounterTrackable.SuppressNextNotification = false;
			foreach (PlayerItem activeItem in user.activeItems)
			{
				if (!(activeItem is VotingInterface))
				{
					continue;
				}
				activeItem.ForceApplyCooldown(user);
				user.DropActiveItem(activeItem, 4f, false);
				break;
			}
			user.RemoveActiveItem(((PickupObject)this).PickupObjectId);
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		public override void DoEffect(PlayerController user)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			AkSoundEngine.PostEvent("Play_ENV_puddle_zap_01", ((Component)user).gameObject);
			m_material = new Material(DarknessEffectShader);
			Pixelator.Instance.AdditionalCoreStackRenderPass = m_material;
			user.ChangeSpecialShaderFlag(1, 1f);
			((GameActor)user).SetIsStealthed(true, "voting interface");
			user.SetCapableOfStealing(true, "VotingInterface", (float?)null);
			((BraveBehaviour)user).specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask((CollisionLayer)2, (CollisionLayer)3));
			((MonoBehaviour)this).StartCoroutine(ItemBuilder.HandleDuration((PlayerItem)(object)this, 6.5f, user, (Action<PlayerController>)EndEffect));
		}

		public void EndEffect(PlayerController user)
		{
			//IL_0080: 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)
			if (Object.op_Implicit((Object)(object)Pixelator.Instance))
			{
				Pixelator.Instance.AdditionalCoreStackRenderPass = null;
			}
			((BraveBehaviour)user).specRigidbody.RemoveCollisionLayerIgnoreOverride(CollisionMask.LayerToMask((CollisionLayer)2, (CollisionLayer)3));
			user.ChangeSpecialShaderFlag(1, 0f);
			((GameActor)user).SetIsStealthed(false, "voting interface");
			user.SetCapableOfStealing(false, "VotingInterface", (float?)null);
			user.RemoveActiveItem(((PickupObject)this).PickupObjectId);
			EncounterTrackable.SuppressNextNotification = true;
			PlayerItem component = Object.Instantiate<GameObject>(((Component)PickupObjectDatabase.GetById(VotingInterface.VotingInterfaceId)).gameObject, Vector2.op_Implicit(Vector2.zero), Quaternion.identity).GetComponent<PlayerItem>();
			component.ForceAsExtant = true;
			((PickupObject)component).Pickup(user);
			EncounterTrackable.SuppressNextNotification = false;
			foreach (PlayerItem activeItem in user.activeItems)
			{
				if (activeItem is VotingInterface)
				{
					activeItem.ForceApplyCooldown(user);
				}
			}
		}

		public override void DoActiveEffect(PlayerController user)
		{
			//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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			((PlayerItem)this).DoActiveEffect(user);
			if (!isStabbing)
			{
				Vector2 val = Vector3Extensions.XY(user.unadjustedAimPoint) - ((GameActor)user).CenterPosition;
				float num = Vector2Extensions.ToAngle(val);
				stabVfx.SpawnAtPosition(Vector2.op_Implicit(((GameActor)user).CenterPosition), num, ((BraveBehaviour)user).transform, (Vector2?)null, (Vector2?)null, (float?)1f, false, (SpawnMethod)null, ((BraveBehaviour)user).sprite, true);
				float rayDamagePerSecond = 300f;
				float rayLength = 1.6875f;
				((MonoBehaviour)user).StartCoroutine(HandleSwing(user, val, rayDamagePerSecond, rayLength));
			}
		}

		public IEnumerator HandleSwing(PlayerController user, Vector2 aimVec, float rayDamagePerSecond, float rayLength)
		{
			//IL_0015: 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)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <HandleSwing>d__14(0)
			{
				<>4__this = this,
				user = user,
				aimVec = aimVec,
				rayDamagePerSecond = rayDamagePerSecond,
				rayLength = rayLength
			};
		}

		public SpeculativeRigidbody IterativeRaycast(Vector2 rayOrigin, Vector2 rayDirection, float rayDistance, int collisionMask, SpeculativeRigidbody ignoreRigidbody)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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)
			int num = 0;
			RaycastResult val = default(RaycastResult);
			while (PhysicsEngine.Instance.Raycast(rayOrigin, rayDirection, rayDistance, ref val, true, true, collisionMask, (CollisionLayer?)(CollisionLayer)4, false, (Func<SpeculativeRigidbody, bool>)null, ignoreRigidbody))
			{
				num++;
				SpeculativeRigidbody speculativeRigidbody = val.SpeculativeRigidbody;
				if (num < 3 && (Object)(object)speculativeRigidbody != (Object)null)
				{
					MinorBreakable component = ((Component)speculativeRigidbody).GetComponent<MinorBreakable>();
					if ((Object)(object)component != (Object)null)
					{
						component.Break(((Vector2)(ref rayDirection)).normalized * 3f);
						RaycastResult.Pool.Free(ref val);
						continue;
					}
				}
				RaycastResult.Pool.Free(ref val);
				return speculativeRigidbody;
			}
			return null;
		}
	}
	public class ImpostersSidearm : GunBehaviour
	{
		public static List<IntVector2> fireOffsets = new List<IntVector2>
		{
			new IntVector2(-4, 1),
			new IntVector2(-3, 0),
			new IntVector2(-2, 0),
			new IntVector2(-1, 0),
			new IntVector2(0, 0)
		};

		public static List<IntVector2> reloadOffsets = new List<IntVector2>
		{
			new IntVector2(-4, 0),
			new IntVector2(-4, 2),
			new IntVector2(-4, 7),
			new IntVector2(-4, 8),
			new IntVector2(-4, -3),
			new IntVector2(-4, 0),
			new IntVector2(4, 0),
			new IntVector2(2, 0),
			new IntVector2(1, 0)
		};

		public static List<IntVector2> introOffsets = new List<IntVector2>
		{
			new IntVector2(0, 3),
			new IntVector2(-1, 0),
			new IntVector2(2, -2),
			new IntVector2(3, -8),
			new IntVector2(3, -3),
			new IntVector2(3, 6),
			new IntVector2(3, 5),
			new IntVector2(0, -5),
			new IntVector2(2, -7),
			new IntVector2(4, -6),
			new IntVector2(4, -7)
		};

		public static List<IntVector2> emptyOffsets = new List<IntVector2>
		{
			new IntVector2(-4, 0)
		};

		public static void Init()
		{
			//IL_00d8: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			Gun val = Databases.Items.NewGun("Impostor's Sidearm", "impgun");
			Game.Items.Rename("outdated_gun_mods:impostor's_sidearm", "spapi:impostors_sidearm");
			GunExt.SetShortDescription((PickupObject)(object)val, "No!! Please!");
			GunExt.SetLongDescription((PickupObject)(object)val, "\n\nNormally locked up in the weapons cache, This gun my be responsible for countless accounts of cold blooded murder. Now why would a mere crewmate need such a bulky, powerful weapon.. as one fellow crewmate once stated \"That's kind of sus\"");
			GunExt.SetupSprite(val, (tk2dSpriteCollectionData)null, "impgun_idle_001", 12);
			GunExt.AddProjectileModuleFrom(val, "klobb", true, false);
			PickupObject byId = PickupObjectDatabase.GetById(56);
			Projectile val2 = Object.Instantiate<Projectile>(((Gun)((byId is Gun) ? byId : null)).DefaultModule.projectiles[0]);
			((Component)val2).gameObject.SetActive(false);
			FakePrefab.MarkAsFakePrefab(((Component)val2).gameObject);
			Object.DontDestroyOnLoad((Object)(object)val2);
			val.DefaultModule.projectiles[0] = val2;
			val2.baseData.damage = 12f;
			((Object)val2).name = "ImposterGun_Projectile";
			val.DefaultModule.shootStyle = (ShootStyle)0;
			val.DefaultModule.angleVariance = 0f;
			val.DefaultModule.ammoType = (AmmoType)1;
			val.DefaultModule.cooldownTime = 0.5f;
			val.DefaultModule.numberOfShotsInClip = 8;
			((Component)val).gameObject.AddComponent<ImpostersSidearm>();
			val.reloadTime = 1.89f;
			val.InfiniteAmmo = true;
			((PickupObject)val).quality = (ItemQuality)(-50);
			ref VFXPool muzzleFlashEffects = ref val.muzzleFlashEffects;
			PickupObject byId2 = PickupObjectDatabase.GetById(56);
			muzzleFlashEffects = ((Gun)((byId2 is Gun) ? byId2 : null)).muzzleFlashEffects;
			((Component)val.barrelOffset).transform.localPosition = new Vector3(1.0625f, 0.5625f, 0f);
			val.gunClass = (GunClass)1;
			tk2dSpriteAnimator component = ((Component)val).GetComponent<tk2dSpriteAnimator>();
			tk2dSpriteAnimationClip clipByName = component.GetClipByName(val.shootAnimation);
			tk2dSpriteAnimationClip clipByName2 = component.GetClipByName(val.reloadAnimation);
			tk2dSpriteAnimationClip clipByName3 = component.GetClipByName(val.introAnimation);
			tk2dSpriteAnimationClip clipByName4 = component.GetClipByName(val.emptyAnimation);
			Vector2 offset = default(Vector2);
			for (int i = 0; i < clipByName.frames.Length; i++)
			{
				tk2dSpriteAnimationFrame val3 = clipByName.frames[i];
				tk2dSpriteDefinition def = val3.spriteCollection.spriteDefinitions[val3.spriteId];
				((Vector2)(ref offset))..ctor((float)fireOffsets[i].x / 16f, (float)fireOffsets[i].y / 16f);
				ImpostersKnife.MakeOffset(def, offset);
			}
			Vector2 offset2 = default(Vector2);
			for (int j = 0; j < clipByName2.frames.Length; j++)
			{
				tk2dSpriteAnimationFrame val4 = clipByName2.frames[j];
				tk2dSpriteDefinition def2 = val4.spriteCollection.spriteDefinitions[val4.spriteId];
				((Vector2)(ref offset2))..ctor((float)reloadOffsets[j].x / 16f, (float)reloadOffsets[j].y / 16f);
				ImpostersKnife.MakeOffset(def2, offset2);
			}
			Vector2 offset3 = default(Vector2);
			for (int k = 0; k < clipByName3.frames.Length; k++)
			{
				tk2dSpriteAnimationFrame val5 = clipByName3.frames[k];
				tk2dSpriteDefinition def3 = val5.spriteCollection.spriteDefinitions[val5.spriteId];
				((Vector2)(ref offset3))..ctor((float)introOffsets[k].x / 16f, (float)introOffsets[k].y / 16f);
				ImpostersKnife.MakeOffset(def3, offset3);
			}
			Vector2 offset4 = default(Vector2);
			for (int l = 0; l < clipByName4.frames.Length; l++)
			{
				tk2dSpriteAnimationFrame val6 = clipByName4.frames[l];
				tk2dSpriteDefinition def4 = val6.spriteCollection.spriteDefinitions[val6.spriteId];
				((Vector2)(ref offset4))..ctor((float)emptyOffsets[l].x / 16f, (float)emptyOffsets[l].y / 16f);
				ImpostersKnife.MakeOffset(def4, offset4);
			}
			Databases.Items.Add(val, (tk2dSpriteCollectionData)null, "ANY");
		}

		public override void Update()
		{
			if ((Object)(object)base.gun != (Object)null)
			{
				if (!base.gun.PreventNormalFireAudio)
				{
					base.gun.PreventNormalFireAudio = true;
				}
				if (base.gun.OverrideNormalFireAudioEvent != "Play_WPN_sniperrifle_shot_01")
				{
					base.gun.OverrideNormalFireAudioEvent = "Play_WPN_sniperrifle_shot_01";
				}
			}
		}
	}
	[HarmonyPatch]
	public class PetOffsetHolder : MonoBehaviour
	{
		public Vector2 petOffsetRight;

		public Vector2 petOffsetLeft;

		[HarmonyPatch(typeof(CompanionController), "DoPet")]
		[HarmonyPostfix]
		public static void ApplyOverridePetOffset_Postfix(CompanionController __instance, PlayerController player)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			PetOffsetHolder component = ((Component)__instance).GetComponent<PetOffsetHolder>();
			if (!((Object)(object)component == (Object)null))
			{
				if (((BraveBehaviour)__instance).specRigidbody.UnitCenter.x > ((BraveBehaviour)player).specRigidbody.UnitCenter.x)
				{
					__instance.m_petOffset = component.petOffsetRight;
				}
				else
				{
					__instance.m_petOffset = component.petOffsetLeft;
				}
			}
		}
	}
	public class VotingInterface : PlayerItem
	{
		public static int VotingInterfaceId;

		public static void Init()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			string text = "Voting Interface";
			string text2 = "ImposterItems/Resources/busted_interface";
			GameObject val = new GameObject(text);
			VotingInterface votingInterface = val.AddComponent<VotingInterface>();
			ItemBuilder.AddSpriteToObject(text, text2, val, (Assembly)null);
			string text3 = "Sabotage";
			string text4 = "Allows the user to remotely turn off the lights and slip into darkness. While the lights are dimmed gain stealth.\n\nThis tablet was issued to you and the rest of your crew in tact with multiple apps, most notably ones allowing you to anomalously vote in crew meetings, view your surroundings, and remotely control linked electronics. Luckily The Gungeon doesn't have a great firewall...";
			ItemBuilder.SetupItem((PickupObject)(object)votingInterface, text3, text4, "spapi");
			ItemBuilder.SetCooldownType((PlayerItem)(object)votingInterface, (CooldownType)1, 500f);
			((PlayerItem)votingInterface).consumable = false;
			((PickupObject)votingInterface).quality = (ItemQuality)(-50);
			VotingInterfaceId = ((PickupObject)votingInterface).PickupObjectId;
		}

		public override void DoEffect(PlayerController user)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			user.RemoveActiveItem(((PickupObject)this).PickupObjectId);
			EncounterTrackable.SuppressNextNotification = true;
			PlayerItem component = Object.Instantiate<GameObject>(((Component)PickupObjectDatabase.GetById(ImpostersKnife.ImpostersKnifeId)).gameObject, Vector2.op_Implicit(Vector2.zero), Quaternion.identity).GetComponent<PlayerItem>();
			component.ForceAsExtant = true;
			((PickupObject)component).Pickup(user);
			EncounterTrackable.SuppressNextNotification = false;
			float num = default(float);
			foreach (PlayerItem activeItem in user.activeItems)
			{
				if (!(activeItem is ImpostersKnife))
				{
					continue;
				}
				activeItem.Use(user, ref num);
				break;
			}
		}
	}
	public class LilCrewmate
	{
		public static GameObject prefab;

		public static void Init()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			string text = "Lil' Crewmate";
			string text2 = "ImposterItems/Resources/lilcrewmate";
			GameObject val = new GameObject(text);
			CompanionItem val2 = val.AddComponent<CompanionItem>();
			ItemBuilder.AddSpriteToObject(text, text2, val, (Assembly)null);
			string text3 = "Just look at him!";
			string text4 = "This little crewmate went with the imposter when they where both ejected off the ship.\n\nHe doesn’t talk, he doesn’t fight, he honestly doesn’t do much of anything aside from being cute. At least the company must be nice.";
			ItemBuilder.SetupItem((PickupObject)(object)val2, text3, text4, "spapi");
			Game.Items.Rename("spapi:lil'_crewmate", "spapi:lil_crewmate");
			((PickupObject)val2).quality = (ItemQuality)(-50);
			val2.CompanionGuid = "lil_crewmate";
			val2.Synergies = (CompanionTransformSynergy[])(object)new CompanionTransformSynergy[0];
			BuildPrefab();
		}

		public static void BuildPrefab()
		{
			//IL_003c: 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_0073: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_00a4: 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_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)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Expected O, but got Unknown
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Expected O, but got Unknown
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)prefab != (Object)null) && !CompanionBuilder.companionDictionary.ContainsKey("lil_crewmate"))
			{
				prefab = CompanionBuilder.BuildPrefab("Lil Crewmate", "lil_crewmate", "ImposterItems/Resources/Crewmate/IdleRight/lilguy_idle_right_001", new IntVector2(0, 0), new IntVector2(7, 9));
				CompanionController val = prefab.AddComponent<CompanionController>();
				val.CanBePet = true;
				val.CanInterceptBullets = true;
				SpeculativeRigidbody specRigidbody = ((BraveBehaviour)val).specRigidbody;
				PixelCollider item = new PixelCollider
				{
					ColliderGenerationMode = (PixelColliderGeneration)0,
					CollisionLayer = (CollisionLayer)3,
					ManualWidth = 7,
					ManualHeight = 9,
					ManualOffsetX = 0,
					ManualOffsetY = 0
				};
				PixelCollider item2 = new PixelCollider
				{
					ColliderGenerationMode = (PixelColliderGeneration)0,
					CollisionLayer = (CollisionLayer)0,
					ManualWidth = 7,
					ManualHeight = 9,
					ManualOffsetX = 0,
					ManualOffsetY = 0
				};
				specRigidbody.PixelColliders = new List<PixelCollider> { item, item2 };
				specRigidbody.CollideWithOthers = true;
				AIActor aiActor = ((BraveBehaviour)val).aiActor;
				aiActor.IsNormalEnemy = false;
				aiActor.CollisionDamage = 0f;
				aiActor.MovementSpeed = 7.2f;
				aiActor.CanDropCurrency = false;
				CompanionBuilder.AddAnimation(prefab, "idle_right", "ImposterItems/Resources/Crewmate/IdleRight", 5, (AnimationType)1, (DirectionType)2, (FlipType)0);
				CompanionBuilder.AddAnimation(prefab, "idle_left", "ImposterItems/Resources/Crewmate/IdleLeft", 5, (AnimationType)1, (DirectionType)2, (FlipType)0);
				CompanionBuilder.AddAnimation(prefab, "run_right", "ImposterItems/Resources/Crewmate/MoveRight", 16, (AnimationType)0, (DirectionType)2, (FlipType)0);
				CompanionBuilder.AddAnimation(prefab, "run_left", "ImposterItems/Resources/Crewmate/MoveLeft", 16, (AnimationType)0, (DirectionType)2, (FlipType)0);
				AIAnimator orAddComponent = GameObjectExtensions.GetOrAddComponent<AIAnimator>(((Component)val).gameObject);
				CompanionBuilder.BuildAnimation(orAddComponent, "pet_right", "ImposterItems/Resources/Crewmate/PetRight", 5, (Assembly)null);
				CompanionBuilder.BuildAnimation(orAddComponent, "pet_left", "ImposterItems/Resources/Crewmate/PetLeft", 5, (Assembly)null);
				DirectionalAnimation val2 = new DirectionalAnimation();
				val2.AnimNames = new string[2] { "pet_right", "pet_left" };
				val2.Flipped = (FlipType[])(object)new FlipType[2];
				val2.Type = (DirectionType)2;
				val2.Prefix = string.Empty;
				DirectionalAnimation val3 = val2;
				CompanionBuilder.AssignDirectionalAnimation(((BraveBehaviour)val).aiAnimator, "pet", val3, (AnimationType)6);
				BehaviorSpeculator component = prefab.GetComponent<BehaviorSpeculator>();
				List<MovementBehaviorBase> movementBehaviors = component.MovementBehaviors;
				CompanionFollowPlayerBehavior val4 = new CompanionFollowPlayerBehavior();
				val4.IdleAnimations = new string[1] { "idle" };
				val4.DisableInCombat = false;
				movementBehaviors.Add((MovementBehaviorBase)(object)val4);
				PetOffsetHolder petOffsetHolder = prefab.AddComponent<PetOffsetHolder>();
				petOffsetHolder.petOffsetLeft = new Vector2(-0.5f, -0.0625f);
				petOffsetHolder.petOffsetRight = new Vector2(0.5f, -0.0625f);
			}
		}
	}
	[BepInPlugin("spapi.etg.imposteritems", "Imposter Items", "1.0.7")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string MOD_GUID = "spapi.etg.imposteritems";

		public void Start()
		{
			ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
		}

		public void GMStart(GameManager game)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("spapi.etg.imposteritems").PatchAll();
			Assets.SetupSpritesFromAssembly(typeof(Plugin).Assembly, "ImposterItems/Resources/MTGAPISpriteRoot");
			LilCrewmate.Init();
			VotingInterface.Init();
			ImpostersKnife.Init();
			ImpostersSidearm.Init();
		}
	}
}