Decompiled source of sonicgun v1.0.21

SonicGun.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using SonicGun;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Serialization;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("slenered")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0cf2ee12f97c7be011b895bba9e1f6d25d184e2c")]
[assembly: AssemblyProduct("SonicGun")]
[assembly: AssemblyTitle("SonicGun")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class ItemGunSonicBullet : MonoBehaviour
{
	private Transform hitEffectTransform;

	private ParticleSystem particleSparks;

	private ParticleSystem particleSmoke;

	private ParticleSystem particleImpact;

	private Light hitLight;

	private LineRenderer shootLine;

	public bool hasHurtCollider = false;

	public SonicCollider sonicCollider;

	public float investigateRadius = 15f;

	internal bool bulletHit;

	internal Vector3 hitPosition;

	internal bool hypersonic;

	public float hurtColliderTimer = 0.25f;

	private bool shootLineActive;

	private float shootLineLerp;

	internal AnimationCurve shootLineWidthCurve;

	public GameObject hitGameObject;

	public float hitGameObjectDestroyTime = 2f;

	public bool hasExtraParticles;

	public GameObject extraParticles;

	public void ActivateAll()
	{
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: 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_00ee: 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_0110: 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_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		((Component)this).gameObject.SetActive(true);
		hitEffectTransform = ((Component)this).transform.Find("Hit Effect");
		particleSparks = ((Component)hitEffectTransform.Find("Particle Sparks")).GetComponent<ParticleSystem>();
		particleSmoke = ((Component)hitEffectTransform.Find("Particle Smoke")).GetComponent<ParticleSystem>();
		particleImpact = ((Component)hitEffectTransform.Find("Particle Impact")).GetComponent<ParticleSystem>();
		hitLight = ((Component)hitEffectTransform.Find("Hit Light")).GetComponent<Light>();
		shootLine = ((Component)this).GetComponentInChildren<LineRenderer>();
		Vector3 position = ((Component)this).transform.position;
		Vector3 val = hitPosition - position;
		((Renderer)shootLine).enabled = true;
		shootLine.SetPosition(0, ((Component)this).transform.position);
		shootLine.SetPosition(1, ((Component)this).transform.position + ((Vector3)(ref val)).normalized * 0.5f);
		shootLine.SetPosition(2, hitPosition - ((Vector3)(ref val)).normalized * 0.5f);
		shootLine.SetPosition(3, hitPosition);
		shootLineActive = true;
		shootLineLerp = 0f;
		if (bulletHit)
		{
			((Component)hitEffectTransform).gameObject.SetActive(true);
			((Component)particleSparks).gameObject.SetActive(true);
			((Component)particleSmoke).gameObject.SetActive(true);
			((Component)particleImpact).gameObject.SetActive(true);
			((Behaviour)hitLight).enabled = true;
			GameObject gameObject = hitGameObject;
			if (hasHurtCollider)
			{
				gameObject = ((Component)sonicCollider).gameObject;
			}
			gameObject.gameObject.SetActive(true);
			gameObject.GetComponent<ItemSoundwave>().hypersonic = hypersonic;
			Quaternion rotation = Quaternion.LookRotation(val);
			gameObject.transform.rotation = rotation;
			gameObject.transform.position = hitPosition;
			hitEffectTransform.position = hitPosition;
			hitEffectTransform.rotation = rotation;
			if (hasExtraParticles)
			{
				extraParticles.SetActive(true);
				extraParticles.transform.position = hitPosition;
				extraParticles.transform.rotation = rotation;
			}
			if (investigateRadius > 0f)
			{
				EnemyDirector.instance.SetInvestigate(gameObject.transform.position, hypersonic ? (investigateRadius * 10f) : investigateRadius, false);
			}
		}
		((MonoBehaviour)this).StartCoroutine(BulletDestroy());
	}

	private IEnumerator BulletDestroy()
	{
		yield return (object)new WaitForSeconds(0.2f);
		while (particleSparks.isPlaying || particleSmoke.isPlaying || particleImpact.isPlaying || ((Behaviour)hitLight).enabled || ((Renderer)shootLine).enabled || (hasHurtCollider && Object.op_Implicit((Object)(object)sonicCollider) && ((Component)sonicCollider).gameObject.activeSelf) || (!hasHurtCollider && Object.op_Implicit((Object)(object)hitGameObject) && hitGameObject.activeSelf))
		{
			yield return null;
		}
		Object.Destroy((Object)(object)((Component)this).gameObject);
	}

	private void LineRendererLogic()
	{
		if (shootLineActive)
		{
			shootLine.widthMultiplier = shootLineWidthCurve.Evaluate(shootLineLerp);
			shootLineLerp += Time.deltaTime * 5f;
			if (shootLineLerp >= 1f)
			{
				((Renderer)shootLine).enabled = false;
				((Component)shootLine).gameObject.SetActive(false);
				shootLineActive = false;
			}
		}
	}

	private void Update()
	{
		LineRendererLogic();
		if (!bulletHit)
		{
			return;
		}
		if (hasHurtCollider)
		{
			if (hurtColliderTimer > 0f)
			{
				hurtColliderTimer -= Time.deltaTime;
				if (Object.op_Implicit((Object)(object)sonicCollider))
				{
					((Component)sonicCollider).gameObject.SetActive(true);
				}
			}
			else if (Object.op_Implicit((Object)(object)sonicCollider))
			{
				((Component)sonicCollider).gameObject.SetActive(false);
			}
		}
		else
		{
			hitGameObjectDestroyTime -= Time.deltaTime;
			if (hitGameObjectDestroyTime <= 0f && Object.op_Implicit((Object)(object)hitGameObject))
			{
				hitGameObject.SetActive(false);
			}
		}
		if (Object.op_Implicit((Object)(object)hitLight))
		{
			hitLight.intensity = Mathf.Lerp(hitLight.intensity, 0f, Time.deltaTime * 10f);
			if (hitLight.intensity < 0.01f)
			{
				((Behaviour)hitLight).enabled = false;
			}
		}
	}
}
public class ItemSonicGun : MonoBehaviour
{
	public enum State
	{
		Idle,
		OutOfAmmo,
		Buildup,
		Shooting,
		Reloading
	}

	private PhysGrabObject physGrabObject;

	internal Color ChargeColor = new Color(118f, 118f, 118f, 1f);

	private bool itemHold;

	private bool itemHeld;

	private int charge;

	public int MaxCharges = 3;

	private int Charges;

	public Sound ChargeSound;

	public Sound OverChargeSound;

	private bool Overheated;

	private float stateRecharge = 0f;

	public float RechargeTime = 1f;

	private float RechargeTimeFlash;

	public bool hasOneShot = true;

	public float shootTime = 1f;

	public bool hasBuildUp;

	public float buildUpTime = 1f;

	private float stateCharge;

	public float ChargeUpTime = 0.75f;

	public float FinalChargeUpTime = 0.5f;

	private float FifthFinalChargeTime;

	public int FinalCharge = 3;

	public int numberOfBullets = 1;

	[Range(0f, 65f)]
	public float gunRandomSpread;

	public float gunRange = 50f;

	public float distanceKeep = 0.8f;

	public float gunRecoilForce = 1f;

	public float cameraShakeMultiplier = 1f;

	public float torqueMultiplier = 1f;

	public float grabStrengthMultiplier = 1f;

	public float shootCooldown = 1f;

	public float batteryDrain = 0.1f;

	public bool batteryDrainFullBar;

	public int batteryDrainFullBars = 1;

	[Range(0f, 100f)]
	public float misfirePercentageChange = 50f;

	public AnimationCurve shootLineWidthCurve;

	public float grabVerticalOffset = -0.2f;

	public float aimVerticalOffset = -5f;

	public float investigateRadius = 20f;

	private float investigateCooldown;

	public Transform gunMuzzle;

	public GameObject bulletPrefab;

	public GameObject muzzleFlashPrefab;

	public Transform gunTrigger;

	public RawImage ChargeBorder;

	public RawImage ChargeBar1;

	public RawImage ChargeBar2;

	public RawImage ChargeBar3;

	internal SonicCollider SonicCollider;

	public Sound soundShoot;

	public Sound soundShootGlobal;

	public Sound soundNoAmmoClick;

	public Sound soundHit;

	private ItemBattery itemBattery;

	private PhotonView photonView;

	private PhysGrabObjectImpactDetector impactDetector;

	private AnimationCurve triggerAnimationCurve;

	private float triggerAnimationEval;

	private bool triggerAnimationActive;

	public UnityEvent onStateIdleStart;

	public UnityEvent onStateIdleUpdate;

	public UnityEvent onStateIdleFixedUpdate;

	[Space(20f)]
	public UnityEvent onStateOutOfAmmoStart;

	public UnityEvent onStateOutOfAmmoUpdate;

	public UnityEvent onStateOutOfAmmoFixedUpdate;

	[Space(20f)]
	public UnityEvent onStateBuildupStart;

	public UnityEvent onStateBuildupUpdate;

	public UnityEvent onStateBuildupFixedUpdate;

	[Space(20f)]
	public UnityEvent onStateShootingStart;

	public UnityEvent onStateShootingUpdate;

	public UnityEvent onStateShootingFixedUpdate;

	[Space(20f)]
	public UnityEvent onStateReloadingStart;

	public UnityEvent onStateReloadingUpdate;

	public UnityEvent onStateReloadingFixedUpdate;

	private bool hasIdleUpdate = true;

	private bool hasIdleFixedUpdate = true;

	private bool hasOutOfAmmoUpdate = true;

	private bool hasOutOfAmmoFixedUpdate = true;

	private bool hasBuildupUpdate = true;

	private bool hasBuildupFixedUpdate = true;

	private bool hasShootingUpdate = true;

	private bool hasShootingFixedUpdate = true;

	private bool hasReloadingUpdate = true;

	private bool hasReloadingFixedUpdate = true;

	private RoomVolumeCheck roomVolumeCheck;

	internal float stateTimer;

	internal float stateTimeMax;

	internal State stateCurrent;

	private State statePrev;

	private bool stateStart;

	private ItemEquippable itemEquippable;

	private void Start()
	{
		FifthFinalChargeTime = FinalChargeUpTime / 5f;
		RechargeTimeFlash = RechargeTime / 6f;
		Charges = MaxCharges;
		roomVolumeCheck = ((Component)this).GetComponent<RoomVolumeCheck>();
		itemEquippable = ((Component)this).GetComponent<ItemEquippable>();
		physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
		itemBattery = ((Component)this).GetComponent<ItemBattery>();
		photonView = ((Component)this).GetComponent<PhotonView>();
		impactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
		triggerAnimationCurve = AssetManager.instance.animationCurveClickInOut;
		if (onStateIdleUpdate == null)
		{
			hasIdleUpdate = false;
		}
		if (onStateIdleFixedUpdate == null)
		{
			hasIdleFixedUpdate = false;
		}
		if (onStateOutOfAmmoUpdate == null)
		{
			hasOutOfAmmoUpdate = false;
		}
		if (onStateOutOfAmmoFixedUpdate == null)
		{
			hasOutOfAmmoFixedUpdate = false;
		}
		if (onStateBuildupUpdate == null)
		{
			hasBuildupUpdate = false;
		}
		if (onStateBuildupFixedUpdate == null)
		{
			hasBuildupFixedUpdate = false;
		}
		if (onStateShootingUpdate == null)
		{
			hasShootingUpdate = false;
		}
		if (onStateShootingFixedUpdate == null)
		{
			hasShootingFixedUpdate = false;
		}
		if (onStateReloadingUpdate == null)
		{
			hasReloadingUpdate = false;
		}
		if (onStateReloadingFixedUpdate == null)
		{
			hasReloadingFixedUpdate = false;
		}
	}

	private void FixedUpdate()
	{
		StateMachine(_fixedUpdate: true);
	}

	private void Update()
	{
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: 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_0179: 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_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		StateMachine(_fixedUpdate: false);
		if (physGrabObject.grabbed && physGrabObject.grabbedLocal)
		{
			PhysGrabber.instance.OverrideGrabDistance(distanceKeep);
		}
		if (triggerAnimationActive)
		{
			float num = 45f;
			triggerAnimationEval += Time.deltaTime * 4f;
			gunTrigger.localRotation = Quaternion.Euler(num * triggerAnimationCurve.Evaluate(triggerAnimationEval), 0f, 0f);
			if (triggerAnimationEval >= 1f)
			{
				gunTrigger.localRotation = Quaternion.Euler(0f, 0f, 0f);
				triggerAnimationActive = false;
				triggerAnimationEval = 1f;
			}
		}
		((Behaviour)ChargeBar1).enabled = Charges >= MaxCharges;
		((Behaviour)ChargeBar2).enabled = Charges >= MaxCharges - 1;
		((Behaviour)ChargeBar3).enabled = Charges >= MaxCharges - 2;
		((Graphic)ChargeBar1).color = ((charge >= 1) ? Color.red : ChargeColor);
		((Graphic)ChargeBar2).color = ((charge >= 2 - (MaxCharges - Charges)) ? Color.red : ChargeColor);
		((Graphic)ChargeBar3).color = ((charge >= 3 - (MaxCharges - Charges)) ? Color.red : ChargeColor);
		if (itemHeld && charge == FinalCharge)
		{
			bool flag = FifthFinalChargeTime > stateCharge % (FifthFinalChargeTime * 2f);
			((Graphic)ChargeBorder).color = (flag ? Color.red : Color.white);
			if (flag)
			{
				EnemyDirector.instance.SetInvestigate(((Component)this).transform.position, 5f, false);
			}
		}
		else
		{
			((Graphic)ChargeBorder).color = (Overheated ? Color.black : Color.white);
		}
		if (Charges < MaxCharges || Overheated)
		{
			stateCharge += Time.deltaTime;
			RestoreCharges(stateCharge);
		}
		UpdateMaster();
	}

	private void UpdateMaster()
	{
		//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)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: 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_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: 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 (!SemiFunc.IsMasterClientOrSingleplayer() || physGrabObject.playerGrabbing.Count <= 0)
		{
			return;
		}
		Quaternion val = Quaternion.Euler(aimVerticalOffset, 0f, 0f);
		Quaternion val2 = Quaternion.Euler(0f, 0f, 0f);
		Quaternion identity = Quaternion.identity;
		bool flag = false;
		bool flag2 = false;
		bool flag3 = false;
		bool flag4 = true;
		foreach (PhysGrabber item in physGrabObject.playerGrabbing)
		{
			if (flag4)
			{
				if (item.playerAvatar.isCrouching)
				{
					flag2 = true;
				}
				if (item.playerAvatar.isCrawling)
				{
					flag3 = true;
				}
				flag4 = false;
			}
			if (item.isRotating)
			{
				flag = true;
			}
		}
		if (!flag)
		{
			physGrabObject.TurnXYZ(val, val2, identity);
		}
		float num = grabVerticalOffset;
		if (flag2)
		{
			num += 0.5f;
		}
		if (flag3)
		{
			num -= 0.5f;
		}
		physGrabObject.OverrideGrabVerticalPosition(num);
		if (!flag)
		{
			if (stateCurrent == State.OutOfAmmo)
			{
				physGrabObject.OverrideTorqueStrength(0.01f, 0.1f);
				physGrabObject.OverrideExtraTorqueStrengthDisable(0.1f);
				physGrabObject.OverrideExtraGrabStrengthDisable(0.1f);
			}
			else if (physGrabObject.grabbed)
			{
				physGrabObject.OverrideTorqueStrength(12f, 0.1f);
				physGrabObject.OverrideAngularDrag(20f, 0.1f);
			}
		}
		else
		{
			physGrabObject.OverrideTorqueStrength(2f, 0.1f);
			physGrabObject.OverrideAngularDrag(20f, 0.1f);
		}
	}

	public void Misfire()
	{
		if (!roomVolumeCheck.inTruck && !physGrabObject.grabbed && !physGrabObject.hasNeverBeenGrabbed && SemiFunc.IsMasterClientOrSingleplayer() && (float)Random.Range(0, 100) < misfirePercentageChange)
		{
			Shoot();
		}
	}

	public void Shoot()
	{
		//IL_0034: 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)
		if (hasOneShot)
		{
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("SonicShootRPC", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				SonicShootRPC();
			}
			StateSet(State.Reloading);
		}
		else if (hasBuildUp)
		{
			StateSet(State.Buildup);
		}
		else
		{
			StateSet(State.Shooting);
		}
	}

	private void MuzzleFlash()
	{
		//IL_000d: 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)
		Object.Instantiate<GameObject>(muzzleFlashPrefab, gunMuzzle.position, gunMuzzle.rotation, gunMuzzle).GetComponent<ItemGunMuzzleFlash>().ActivateAllEffects();
	}

	private void StartTriggerAnimation()
	{
		triggerAnimationActive = true;
		triggerAnimationEval = 0f;
	}

	[PunRPC]
	public void SonicShootRPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		//IL_0001: 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_00c8: 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_0124: 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_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_029a: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_025b: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0273: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0281: Unknown result type (might be due to invalid IL or missing references)
		//IL_0283: 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_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)
		//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02da: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0300: Unknown result type (might be due to invalid IL or missing references)
		//IL_030b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0310: Unknown result type (might be due to invalid IL or missing references)
		//IL_0315: Unknown result type (might be due to invalid IL or missing references)
		if (!SemiFunc.MasterOnlyRPC(_info))
		{
			return;
		}
		bool flag = charge > FinalCharge && itemBattery.batteryLifeInt > 0;
		stateCharge = 0f;
		if (flag)
		{
			Charges = 0;
			charge = 0;
		}
		else
		{
			Charges = Math.Max(0, Charges - 1);
			charge = Math.Max(0, charge - 1);
		}
		float num = 3f * cameraShakeMultiplier;
		float num2 = 16f * cameraShakeMultiplier;
		SemiFunc.CameraShakeImpactDistance(gunMuzzle.position, 5f * cameraShakeMultiplier, 0.1f, num, num2);
		SemiFunc.CameraShakeDistance(gunMuzzle.position, 0.1f * cameraShakeMultiplier, 0.1f * cameraShakeMultiplier, num, num2);
		soundShoot.Play(gunMuzzle.position, 1f, 1f, 1f, 1f);
		soundShootGlobal.Play(gunMuzzle.position, 1f, 1f, 1f, 1f);
		MuzzleFlash();
		StartTriggerAnimation();
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			if (investigateRadius > 0f)
			{
				EnemyDirector.instance.SetInvestigate(((Component)this).transform.position, investigateRadius, false);
			}
			physGrabObject.rb.AddForceAtPosition(-gunMuzzle.forward * gunRecoilForce, gunMuzzle.position, (ForceMode)1);
			itemHold = false;
			itemHeld = false;
			if (flag)
			{
				itemBattery.RemoveFullBar(1);
			}
			Vector3 endPosition = gunMuzzle.position;
			bool hit = false;
			bool flag2 = false;
			Vector3 val = gunMuzzle.forward;
			if (gunRandomSpread > 0f)
			{
				float num3 = Random.Range(0f, gunRandomSpread / 2f);
				float num4 = Random.Range(0f, 360f);
				Vector3 val2 = Vector3.Cross(val, Random.onUnitSphere);
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				Quaternion val3 = Quaternion.AngleAxis(num3, normalized);
				val2 = Quaternion.AngleAxis(num4, val) * val3 * val;
				val = ((Vector3)(ref val2)).normalized;
			}
			RaycastHit val4 = default(RaycastHit);
			if (Physics.Raycast(gunMuzzle.position, val, ref val4, gunRange, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) + LayerMask.GetMask(new string[1] { "Enemy" })))
			{
				endPosition = ((RaycastHit)(ref val4)).point;
				hit = true;
			}
			else
			{
				flag2 = true;
			}
			if (flag2)
			{
				endPosition = gunMuzzle.position + gunMuzzle.forward * gunRange;
				hit = true;
			}
			ShootBullet(endPosition, hit, flag);
		}
	}

	private void ShootBullet(Vector3 _endPosition, bool _hit, bool hypersonic)
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: 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)
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("SonicShootBulletRPC", (RpcTarget)0, new object[3] { _endPosition, _hit, hypersonic });
			}
			else
			{
				SonicShootBulletRPC(_endPosition, _hit, hypersonic);
			}
		}
	}

	[PunRPC]
	public void SonicShootBulletRPC(Vector3 _endPosition, bool _hit, bool hypersonic, PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		//IL_0001: 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_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		if (!SemiFunc.MasterOnlyRPC(_info))
		{
			return;
		}
		if (physGrabObject.playerGrabbing.Count > 1)
		{
			foreach (PhysGrabber item in physGrabObject.playerGrabbing)
			{
				item.OverrideGrabRelease();
			}
		}
		ItemGunSonicBullet component = Object.Instantiate<GameObject>(bulletPrefab, gunMuzzle.position, gunMuzzle.rotation).GetComponent<ItemGunSonicBullet>();
		component.hitPosition = _endPosition;
		component.bulletHit = _hit;
		component.hypersonic = hypersonic;
		SonicCollider = ((Component)component).GetComponentInChildren<SonicCollider>();
		soundHit.Play(_endPosition, 1f, 1f, 1f, 1f);
		component.shootLineWidthCurve = shootLineWidthCurve;
		component.ActivateAll();
	}

	private void StateSet(State _state)
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		if (_state == stateCurrent)
		{
			return;
		}
		if (SemiFunc.IsMultiplayer())
		{
			if (SemiFunc.IsMasterClient())
			{
				photonView.RPC("SonicStateSetRPC", (RpcTarget)0, new object[1] { (int)_state });
			}
		}
		else
		{
			SonicStateSetRPC((int)_state);
		}
	}

	private void ShootLogic()
	{
		//IL_004b: 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_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		if (physGrabObject.heldByLocalPlayer)
		{
			bool flag = SemiFunc.InputHold((InputKey)2);
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("InputHoldRPC", (RpcTarget)0, new object[1] { flag });
			}
			else
			{
				InputHoldRPC(flag);
			}
		}
		else if (physGrabObject.playerGrabbing.Count == 0)
		{
			itemHeld = false;
			itemHold = false;
		}
		if (Overheated || Charges <= 0)
		{
			itemHeld = itemHold;
			return;
		}
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			if (itemHold != itemHeld)
			{
				if (!itemHold && itemHeld)
				{
					ChargeSound.PlayLoop(false, 1f, 1f, 1f);
					ChargeSound.Source.volume = 0f;
					Shoot();
				}
			}
			else if (itemHold)
			{
				float num = ChargeUpTime * (float)FinalCharge + FinalChargeUpTime;
				float num2 = (ChargeUpTime * (float)charge + stateCharge) / num;
				stateCharge += Time.deltaTime;
				ChargeSound.PlayLoop(true, 1f, 1f, 1f);
				ChargeSound.Source.volume = num2 * 2f;
				if (SemiFunc.IsMultiplayer())
				{
					photonView.RPC("SonicStateRPC", (RpcTarget)0, new object[1] { stateCharge });
				}
				else
				{
					SonicStateRPC(stateCharge);
				}
				if (stateCharge >= ChargeUpTime && charge < FinalCharge && Charges > charge)
				{
					stateCharge -= ChargeUpTime;
					Changecharge(1);
					if (charge >= FinalCharge)
					{
						OverChargeSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
					}
				}
				else if (stateCharge >= FinalChargeUpTime && charge == FinalCharge)
				{
					stateCharge = 0f;
					Changecharge(1);
				}
				else if (charge > FinalCharge)
				{
					ChargeSound.PlayLoop(false, 1f, 1f, 1f);
					ChargeSound.Source.volume = 0f;
					Shoot();
					stateCharge = 0f;
					SetOverheat(c: true);
				}
			}
		}
		itemHeld = itemHold;
	}

	[PunRPC]
	private void InputHoldRPC(bool inputHold, PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		itemHold = inputHold;
	}

	[PunRPC]
	private void SonicStateRPC(float stateCh, PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: 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_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)
		stateCharge = stateCh;
		float num = ChargeUpTime * (float)FinalCharge + FinalChargeUpTime;
		float num2 = (ChargeUpTime * (float)charge + stateCh) / num;
		physGrabObject.rb.AddForceAtPosition(Random.insideUnitSphere * (num2 * 0.25f), physGrabObject.rb.position + Random.insideUnitSphere * 0.05f, (ForceMode)1);
	}

	private void Changecharge(int c)
	{
		//IL_0034: 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)
		if (SemiFunc.IsMultiplayer())
		{
			photonView.RPC("ChangechargeRPC", (RpcTarget)0, new object[1] { c });
		}
		else
		{
			ChangechargeRPC(c);
		}
	}

	[PunRPC]
	private void ChangechargeRPC(int c, PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		charge = Math.Max(0, charge + c);
	}

	private void ChangeCharges(int c)
	{
		//IL_0034: 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)
		if (SemiFunc.IsMultiplayer())
		{
			photonView.RPC("ChangeChargesRPC", (RpcTarget)0, new object[1] { c });
		}
		else
		{
			ChangeChargesRPC(c);
		}
	}

	[PunRPC]
	private void ChangeChargesRPC(int c, PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		Charges = Math.Max(0, Charges + c);
	}

	private void RestoreCharges(float c)
	{
		//IL_0034: 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)
		if (SemiFunc.IsMultiplayer())
		{
			photonView.RPC("RestoreChargesRPC", (RpcTarget)0, new object[1] { c });
		}
		else
		{
			RestoreChargesRPC(c);
		}
	}

	[PunRPC]
	private void RestoreChargesRPC(float c, PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		if (stateCharge >= RechargeTime && Charges < MaxCharges)
		{
			stateCharge -= RechargeTime;
			Charges++;
		}
		else if (Overheated && Charges >= MaxCharges && stateCharge >= RechargeTime * 2f)
		{
			stateCharge = 0f;
			Overheated = false;
		}
	}

	private void SetOverheat(bool c)
	{
		//IL_0034: 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)
		if (SemiFunc.IsMultiplayer())
		{
			photonView.RPC("SetOverheatRPC", (RpcTarget)0, new object[1] { c });
		}
		else
		{
			SetOverheatRPC(c);
		}
	}

	[PunRPC]
	private void SetOverheatRPC(bool c, PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		Overheated = c;
	}

	[PunRPC]
	private void SonicStateSetRPC(int state, PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.MasterOnlyRPC(_info))
		{
			stateStart = true;
			statePrev = stateCurrent;
			stateCurrent = (State)state;
		}
	}

	private void StateMachine(bool _fixedUpdate)
	{
		switch (stateCurrent)
		{
		case State.Idle:
			StateIdle(_fixedUpdate);
			break;
		case State.OutOfAmmo:
			StateOutOfAmmo(_fixedUpdate);
			break;
		case State.Buildup:
			StateBuildup(_fixedUpdate);
			break;
		case State.Shooting:
			StateShooting(_fixedUpdate);
			break;
		case State.Reloading:
			StateReloading(_fixedUpdate);
			break;
		}
	}

	private void StateIdle(bool _fixedUpdate)
	{
		if (stateStart && !_fixedUpdate)
		{
			if (onStateIdleStart != null)
			{
				onStateIdleStart.Invoke();
			}
			stateStart = false;
		}
		if (!_fixedUpdate)
		{
			ShootLogic();
			if (hasIdleUpdate)
			{
				onStateIdleUpdate.Invoke();
			}
		}
		if (_fixedUpdate && hasIdleFixedUpdate)
		{
			onStateIdleFixedUpdate.Invoke();
		}
	}

	private void StateOutOfAmmo(bool _fixedUpdate)
	{
		if (stateStart && !_fixedUpdate)
		{
			if (onStateOutOfAmmoStart != null)
			{
				onStateOutOfAmmoStart.Invoke();
			}
			stateStart = false;
		}
		if (!_fixedUpdate)
		{
			if (itemBattery.batteryLifeInt > 0)
			{
				StateSet(State.Idle);
				return;
			}
			ShootLogic();
			if (hasOutOfAmmoUpdate)
			{
				onStateOutOfAmmoUpdate.Invoke();
			}
		}
		if (_fixedUpdate && hasOutOfAmmoFixedUpdate)
		{
			onStateOutOfAmmoFixedUpdate.Invoke();
		}
	}

	private void StateBuildup(bool _fixedUpdate)
	{
		if (stateStart && !_fixedUpdate)
		{
			if (onStateBuildupStart != null)
			{
				onStateBuildupStart.Invoke();
			}
			stateTimer = 0f;
			stateTimeMax = buildUpTime;
			stateStart = false;
		}
		if (!_fixedUpdate)
		{
			if (hasBuildupUpdate)
			{
				onStateBuildupUpdate.Invoke();
			}
			stateTimer += Time.deltaTime;
			if (Object.op_Implicit((Object)(object)itemEquippable) && itemEquippable.isEquipped)
			{
				StateSet(State.Idle);
			}
			if (stateTimer >= stateTimeMax && itemBattery.batteryLifeInt > 0)
			{
				StateSet(State.Shooting);
			}
		}
		if (_fixedUpdate && hasBuildupFixedUpdate)
		{
			onStateBuildupFixedUpdate.Invoke();
		}
	}

	private void StateShooting(bool _fixedUpdate)
	{
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		if (stateStart && !_fixedUpdate)
		{
			stateStart = false;
			if (onStateShootingStart != null)
			{
				onStateShootingStart.Invoke();
			}
			if (!hasOneShot)
			{
				stateTimeMax = shootTime;
				stateTimer = stateTimeMax;
				investigateCooldown = 0f;
			}
			else
			{
				stateTimer = 0.001f;
			}
		}
		if (_fixedUpdate)
		{
			return;
		}
		stateTimer += Time.deltaTime;
		if (stateTimer >= stateTimeMax)
		{
			stateTimer = 0f;
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("SonicShootRPC", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				SonicShootRPC();
			}
			if (charge <= 0)
			{
				StateSet(State.Reloading);
			}
		}
	}

	private void StateReloading(bool _fixedUpdate)
	{
		if (stateStart && !_fixedUpdate)
		{
			stateStart = false;
			if (onStateReloadingStart != null)
			{
				onStateReloadingStart.Invoke();
			}
			stateTimeMax = shootCooldown;
			stateTimer = 0f;
		}
		if (!_fixedUpdate)
		{
			stateTimer += Time.deltaTime;
			if (stateTimer >= stateTimeMax)
			{
				StateSet(State.Idle);
			}
			if (hasReloadingUpdate)
			{
				onStateReloadingUpdate.Invoke();
			}
		}
		if (_fixedUpdate && hasReloadingFixedUpdate)
		{
			onStateReloadingFixedUpdate.Invoke();
		}
	}
}
public class ItemSoundwave : MonoBehaviour
{
	public MeshRenderer meshRenderer;

	private float startScale = 1f;

	private bool finalScale;

	internal bool hypersonic = false;

	public ParticleSystem particleSystemWave;

	public ParticleSystem particleSystemSparks;

	public ParticleSystem particleSystemLightning;

	private SonicCollider _sonicCollider;

	[FormerlySerializedAs("soundExplosion")]
	public Sound soundSonic;

	public Sound soundHypersonic;

	public Sound soundExplosionGlobal;

	public AudioClip tinnitusSound;

	private void Start()
	{
		//IL_002d: 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_0070: 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_00d3: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		EarSound.tinnitusSound = tinnitusSound;
		startScale = (hypersonic ? (((Component)this).transform.localScale.x * 6f) : ((Component)this).transform.localScale.x);
		_sonicCollider = ((Component)this).GetComponentInChildren<SonicCollider>();
		((Component)_sonicCollider).gameObject.SetActive(hypersonic);
		((Renderer)meshRenderer).material.color = Color.white;
		((Component)this).transform.localScale = Vector3.zero;
		if (!hypersonic)
		{
			soundSonic.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
		}
		else
		{
			soundHypersonic.Play(((Component)this).transform.position, 0.75f, 1f, 1f, 1f);
			soundExplosionGlobal.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
		}
		particleSystemSparks.Play();
		particleSystemLightning.Play();
		GameDirector.instance.CameraShake.ShakeDistance(8f, 3f, 8f, ((Component)this).transform.position, 0.1f);
		GameDirector.instance.CameraImpact.ShakeDistance(20f, 3f, 8f, ((Component)this).transform.position, 0.1f);
	}

	private void Update()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: 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_00cb: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: 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_0090: Unknown result type (might be due to invalid IL or missing references)
		((Component)this).transform.Rotate(Vector3.up, 100f * Time.deltaTime);
		if (((Component)this).transform.localScale.x < startScale)
		{
			Transform transform = ((Component)this).transform;
			transform.localScale += Vector3.one * Time.deltaTime * 20f;
			return;
		}
		if (!finalScale)
		{
			((Component)this).transform.localScale = Vector3.one * startScale;
			if (hypersonic)
			{
				((Component)_sonicCollider).gameObject.SetActive(false);
			}
			finalScale = true;
			return;
		}
		float num = Mathf.Lerp(((Component)this).transform.localScale.x, startScale * 1.2f, Time.deltaTime * 2f);
		((Component)this).transform.localScale = Vector3.one * num;
		float num2 = Mathf.InverseLerp(startScale, startScale * 1.2f, num);
		Color color = ((Renderer)meshRenderer).material.color;
		color.a = Mathf.Lerp(1f, 0f, num2);
		((Renderer)meshRenderer).material.color = color;
		if (num2 > 0.998f)
		{
			if (Object.op_Implicit((Object)(object)particleSystemSparks))
			{
				((Component)particleSystemSparks).transform.parent = null;
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}
public class SonicCollider : MonoBehaviour
{
	public enum BreakImpact
	{
		None,
		Light,
		Medium,
		Heavy
	}

	public enum TorqueAxis
	{
		up,
		down,
		left,
		right,
		forward,
		back
	}

	public enum HitType
	{
		Player,
		PhysObject,
		Enemy
	}

	public class Hit
	{
		public HitType hitType;

		public GameObject hitObject;

		public float cooldown;
	}

	public bool playerLogic = true;

	[Space]
	private bool playerKill = false;

	private int playerDamage = 0;

	private float playerDamageCooldown = 0.25f;

	public float playerHitForce;

	public bool playerRayCast;

	public float playerTumbleForce;

	public float playerTumbleTorque;

	public TorqueAxis playerTumbleTorqueAxis = TorqueAxis.down;

	public float playerTumbleTime;

	public float playerTumbleImpactHurtTime;

	public int playerTumbleImpactHurtDamage;

	public bool physLogic = true;

	[Space]
	private bool physDestroy = false;

	private bool physHingeDestroy = false;

	private bool physHingeBreak = false;

	private BreakImpact physImpact = BreakImpact.None;

	private float physDamageCooldown = 0.25f;

	public float physHitForce;

	public float physHitTorque;

	public bool physRayCast;

	public bool enemyLogic = true;

	public Enemy enemyHost;

	[Space]
	[FormerlySerializedAs("enemyDespawn")]
	private bool enemyKill = false;

	public bool enemyStun = true;

	public float enemyStunTime = 2f;

	public EnemyType enemyStunType = (EnemyType)2;

	public float enemyFreezeTime = 0.1f;

	[Space]
	public BreakImpact enemyImpact = BreakImpact.Medium;

	private int enemyDamage = 0;

	private float enemyDamageCooldown = 0.25f;

	public float enemyHitForce;

	public float enemyHitTorque;

	public bool enemyRayCast;

	public bool enemyHitTriggers = true;

	public bool deathPit;

	[Range(0f, 180f)]
	public float hitSpread = 180f;

	public List<PhysGrabObject> ignoreObjects = new List<PhysGrabObject>();

	internal bool ignoreLocalPlayer;

	public bool hasTimer;

	public float timer = 0.2f;

	public bool destroyOnTimerEnd;

	public bool hasCustomRaycastPosition;

	public Vector3 customRaycastPosition;

	private float timerOriginal;

	public UnityEvent onImpactAny;

	public UnityEvent onImpactPlayer;

	internal PlayerAvatar onImpactPlayerAvatar;

	public UnityEvent onImpactPhysObject;

	public UnityEvent onImpactEnemy;

	internal Enemy onImpactEnemyEnemy;

	private Collider Collider;

	private BoxCollider BoxCollider;

	private SphereCollider SphereCollider;

	private bool ColliderIsBox = true;

	private LayerMask LayerMask;

	private LayerMask RayMask;

	internal List<Hit> hits = new List<Hit>();

	private bool colliderCheckRunning;

	private bool cooldownLogicRunning;

	private Vector3 applyForce;

	private Vector3 applyTorque;

	private void Awake()
	{
		//IL_006a: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		BoxCollider = ((Component)this).GetComponent<BoxCollider>();
		if (!Object.op_Implicit((Object)(object)BoxCollider))
		{
			SphereCollider = ((Component)this).GetComponent<SphereCollider>();
			Collider = (Collider)(object)SphereCollider;
			ColliderIsBox = false;
		}
		else
		{
			Collider = (Collider)(object)BoxCollider;
		}
		Collider.isTrigger = true;
		timerOriginal = timer;
		LayerMask = LayerMask.op_Implicit(LayerMask.op_Implicit(SemiFunc.LayerMaskGetPhysGrabObject()) + LayerMask.GetMask(new string[1] { "Player" }) + LayerMask.GetMask(new string[1] { "Default" }) + LayerMask.GetMask(new string[1] { "Enemy" }));
		RayMask = LayerMask.op_Implicit(LayerMask.GetMask(new string[2] { "Default", "PhysGrabObjectHinge" }));
	}

	private void OnEnable()
	{
		if (!colliderCheckRunning)
		{
			colliderCheckRunning = true;
			((MonoBehaviour)this).StartCoroutine(ColliderCheck());
		}
	}

	private void OnDisable()
	{
		((MonoBehaviour)this).StopAllCoroutines();
		colliderCheckRunning = false;
		cooldownLogicRunning = false;
		hits.Clear();
	}

	private void HasTimerLogic()
	{
		if (!hasTimer)
		{
			return;
		}
		if (timer <= 0f)
		{
			if (destroyOnTimerEnd)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else
			{
				((Component)this).gameObject.SetActive(false);
				timer = timerOriginal;
			}
		}
		if (timer > 0f)
		{
			timer -= Time.deltaTime;
		}
	}

	private IEnumerator CooldownLogic()
	{
		while (hits.Count > 0)
		{
			for (int i = 0; i < hits.Count; i++)
			{
				Hit hit = hits[i];
				hit.cooldown -= Time.deltaTime;
				if (hit.cooldown <= 0f)
				{
					hits.RemoveAt(i);
					i--;
				}
			}
			yield return null;
		}
		cooldownLogicRunning = false;
	}

	private bool CanHit(GameObject hitObject, float cooldown, bool raycast, Vector3 hitPosition, HitType hitType)
	{
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: 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)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		foreach (Hit hit2 in hits)
		{
			if ((Object)(object)hit2.hitObject == (Object)(object)hitObject)
			{
				return false;
			}
		}
		Hit hit = new Hit();
		hit.hitObject = hitObject;
		hit.cooldown = cooldown;
		hit.hitType = hitType;
		hits.Add(hit);
		if (!cooldownLogicRunning)
		{
			((MonoBehaviour)this).StartCoroutine(CooldownLogic());
			cooldownLogicRunning = true;
		}
		if (raycast)
		{
			Bounds bounds = Collider.bounds;
			Vector3 val = ((Bounds)(ref bounds)).center;
			if (hasCustomRaycastPosition)
			{
				val = ((Component)this).transform.TransformPoint(customRaycastPosition);
			}
			Vector3 val2 = hitPosition - val;
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			float num = Vector3.Distance(hitPosition, val);
			RaycastHit[] array = Physics.RaycastAll(val, normalized, num, LayerMask.op_Implicit(RayMask), (QueryTriggerInteraction)2);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val3 = array[i];
				if (((Component)((RaycastHit)(ref val3)).collider).gameObject.CompareTag("Wall"))
				{
					PhysGrabObject componentInParent = hitObject.GetComponentInParent<PhysGrabObject>();
					PhysGrabObject componentInParent2 = ((Component)((RaycastHit)(ref val3)).collider).gameObject.GetComponentInParent<PhysGrabObject>();
					if (!Object.op_Implicit((Object)(object)componentInParent) || (Object)(object)componentInParent != (Object)(object)componentInParent2)
					{
						return false;
					}
				}
			}
		}
		return true;
	}

	private IEnumerator ColliderCheck()
	{
		yield return null;
		while (!Object.op_Implicit((Object)(object)LevelGenerator.Instance) || !LevelGenerator.Instance.Generated)
		{
			yield return (object)new WaitForSeconds(0.1f);
		}
		while (true)
		{
			Collider[] array;
			if (ColliderIsBox)
			{
				Vector3 center = ((Component)this).transform.TransformPoint(BoxCollider.center);
				Vector3 vector = new Vector3(((Component)this).transform.lossyScale.x * BoxCollider.size.x, ((Component)this).transform.lossyScale.y * BoxCollider.size.y, ((Component)this).transform.lossyScale.z * BoxCollider.size.z);
				array = Physics.OverlapBox(center, vector * 0.5f, ((Component)this).transform.rotation, LayerMask.op_Implicit(LayerMask), (QueryTriggerInteraction)2);
			}
			else
			{
				Bounds bounds = Collider.bounds;
				Vector3 center2 = ((Bounds)(ref bounds)).center;
				float radius = ((Component)this).transform.lossyScale.x * SphereCollider.radius;
				array = Physics.OverlapSphere(center2, radius, LayerMask.op_Implicit(LayerMask), (QueryTriggerInteraction)2);
			}
			if (array.Length != 0)
			{
				Collider[] array2 = array;
				Collider[] array3 = array2;
				foreach (Collider collider in array3)
				{
					if (playerLogic && playerDamageCooldown > 0f && ((Component)collider).gameObject.CompareTag("Player"))
					{
						PlayerAvatar playerAvatar = ((Component)collider).gameObject.GetComponentInParent<PlayerAvatar>();
						if (!Object.op_Implicit((Object)(object)playerAvatar))
						{
							PlayerController componentInParent = ((Component)collider).gameObject.GetComponentInParent<PlayerController>();
							if (Object.op_Implicit((Object)(object)componentInParent))
							{
								playerAvatar = componentInParent.playerAvatarScript;
							}
						}
						if (Object.op_Implicit((Object)(object)playerAvatar))
						{
							PlayerHurt(playerAvatar);
						}
					}
					if (!(enemyDamageCooldown > 0f) && !(physDamageCooldown > 0f) && !(playerDamageCooldown > 0f))
					{
						continue;
					}
					if (((Component)collider).gameObject.CompareTag("Phys Grab Object"))
					{
						PhysGrabObject componentInParent2 = ((Component)collider).gameObject.GetComponentInParent<PhysGrabObject>();
						if (ignoreObjects.Contains(componentInParent2) || !Object.op_Implicit((Object)(object)componentInParent2) || (componentInParent2.impactDetector.isCart && ((Object)((Component)((Component)collider).transform.parent).gameObject).name != "Phys Object Collider"))
						{
							continue;
						}
						bool flag = false;
						PlayerTumble componentInParent3 = ((Component)collider).gameObject.GetComponentInParent<PlayerTumble>();
						if (Object.op_Implicit((Object)(object)componentInParent3))
						{
							flag = true;
						}
						if (playerLogic && playerDamageCooldown > 0f && flag)
						{
							PlayerHurt(componentInParent3.playerAvatar);
						}
						if (!SemiFunc.IsMasterClientOrSingleplayer())
						{
							continue;
						}
						EnemyRigidbody enemyRigidbody = null;
						if (enemyLogic && !flag)
						{
							enemyRigidbody = ((Component)collider).gameObject.GetComponentInParent<EnemyRigidbody>();
							EnemyHurtRigidbody(enemyRigidbody, componentInParent2);
						}
						if (!physLogic || Object.op_Implicit((Object)(object)enemyRigidbody) || flag || !(physDamageCooldown > 0f) || !CanHit(((Component)componentInParent2).gameObject, physDamageCooldown, physRayCast, componentInParent2.centerPoint, HitType.PhysObject))
						{
							continue;
						}
						bool flag2 = false;
						PhysGrabObjectImpactDetector componentInParent4 = ((Component)collider).gameObject.GetComponentInParent<PhysGrabObjectImpactDetector>();
						if (Object.op_Implicit((Object)(object)componentInParent4))
						{
							if (physHingeDestroy)
							{
								PhysGrabHinge component = ((Component)componentInParent2).GetComponent<PhysGrabHinge>();
								if (Object.op_Implicit((Object)(object)component))
								{
									component.DestroyHinge();
									flag2 = true;
								}
							}
							else if (physHingeBreak)
							{
								PhysGrabHinge component2 = ((Component)componentInParent2).GetComponent<PhysGrabHinge>();
								if (Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)component2.joint))
								{
									((Joint)component2.joint).breakForce = 0f;
									((Joint)component2.joint).breakTorque = 0f;
									flag2 = true;
								}
							}
							if (!flag2)
							{
								if (physDestroy)
								{
									if (!componentInParent4.destroyDisable)
									{
										PhysGrabHinge component3 = ((Component)componentInParent2).GetComponent<PhysGrabHinge>();
										if (Object.op_Implicit((Object)(object)component3))
										{
											component3.DestroyHinge();
										}
										else
										{
											componentInParent4.DestroyObject(true);
										}
									}
									else
									{
										PhysObjectHurt(componentInParent2, BreakImpact.Heavy, 50f, 30f, apply: true, destroyLaunch: true);
									}
									flag2 = true;
								}
								else if (Object.op_Implicit((Object)(object)componentInParent2) && PhysObjectHurt(componentInParent2, physImpact, physHitForce, physHitTorque, apply: true, destroyLaunch: false))
								{
									flag2 = true;
								}
							}
						}
						if (flag2)
						{
							onImpactAny.Invoke();
							onImpactPhysObject.Invoke();
						}
					}
					else
					{
						if (!SemiFunc.IsMasterClientOrSingleplayer() || !enemyLogic)
						{
							continue;
						}
						Enemy componentInParent5 = ((Component)collider).gameObject.GetComponentInParent<Enemy>();
						if (Object.op_Implicit((Object)(object)componentInParent5) && !componentInParent5.HasRigidbody && CanHit(((Component)componentInParent5).gameObject, enemyDamageCooldown, enemyRayCast, ((Component)componentInParent5).transform.position, HitType.Enemy) && EnemyHurt(componentInParent5))
						{
							onImpactAny.Invoke();
							onImpactEnemyEnemy = componentInParent5;
							onImpactEnemy.Invoke();
						}
						if (!enemyHitTriggers)
						{
							continue;
						}
						EnemyParent componentInParent6 = ((Component)collider).gameObject.GetComponentInParent<EnemyParent>();
						if (Object.op_Implicit((Object)(object)componentInParent6))
						{
							EnemyRigidbody componentInChildren = ((Component)componentInParent6).GetComponentInChildren<EnemyRigidbody>();
							if (Object.op_Implicit((Object)(object)componentInChildren))
							{
								EnemyHurtRigidbody(componentInChildren, componentInChildren.physGrabObject);
							}
						}
					}
				}
			}
			yield return (object)new WaitForSeconds(0.05f);
		}
	}

	private void EnemyHurtRigidbody(EnemyRigidbody _enemyRigidbody, PhysGrabObject _physGrabObject)
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		if (enemyDamageCooldown > 0f && Object.op_Implicit((Object)(object)_enemyRigidbody) && CanHit(((Component)_physGrabObject).gameObject, enemyDamageCooldown, enemyRayCast, _physGrabObject.centerPoint, HitType.Enemy) && EnemyHurt(_enemyRigidbody.enemy))
		{
			onImpactAny.Invoke();
			onImpactEnemyEnemy = _enemyRigidbody.enemy;
			onImpactEnemy.Invoke();
		}
	}

	private bool EnemyHurt(Enemy _enemy)
	{
		//IL_00a6: 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_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_enemy == (Object)(object)enemyHost)
		{
			return false;
		}
		if (!enemyLogic)
		{
			return false;
		}
		if (_enemy.HasStateInvestigate)
		{
			_enemy.StateInvestigate.rangeMultiplier = 0f;
			NewValues orCreate = ValueStorage.GetOrCreate((MonoBehaviour)(object)_enemy);
			if (_enemy.EnemyParent.enemyName == "Huntsman")
			{
				orCreate.InvestigateRangeMultiplier /= 4f;
			}
			else
			{
				orCreate.InvestigateRangeMultiplier /= 2f;
			}
		}
		if (enemyStun && _enemy.HasStateStunned && _enemy.Type <= enemyStunType)
		{
			_enemy.StateStunned.Set(enemyStunTime);
		}
		if (enemyFreezeTime > 0f)
		{
			_enemy.Freeze(enemyFreezeTime);
		}
		if (_enemy.HasRigidbody)
		{
			bool apply = !(enemyFreezeTime > 0f);
			PhysObjectHurt(_enemy.Rigidbody.physGrabObject, enemyImpact, enemyHitForce, enemyHitTorque, apply, destroyLaunch: false);
			if (enemyFreezeTime > 0f)
			{
				_enemy.Rigidbody.FreezeForces(applyForce, applyTorque);
			}
		}
		return true;
	}

	private void Update()
	{
		HasTimerLogic();
	}

	private void tinnitus(PlayerAvatar _player)
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.IsMultiplayer())
		{
			MonoBehaviour.print((object)"Multiplayer");
			global::SonicGun.SonicGun.tinnitusEvent.RaiseEvent((object)_player.photonView.ViewID, NetworkingEvents.RaiseAll, SendOptions.SendReliable);
		}
		else
		{
			MonoBehaviour.print((object)"singleplayer");
			ValueStorage.tinnitusVolume = 1f;
		}
	}

	private void PlayerHurt(PlayerAvatar _player)
	{
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: 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)
		//IL_0115: 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_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: 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)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0218: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_035f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//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_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_029e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02da: Unknown result type (might be due to invalid IL or missing references)
		//IL_02df: Unknown result type (might be due to invalid IL or missing references)
		//IL_0306: Unknown result type (might be due to invalid IL or missing references)
		//IL_030b: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0312: Unknown result type (might be due to invalid IL or missing references)
		//IL_0316: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		//IL_031d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0328: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0335: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0302: Unknown result type (might be due to invalid IL or missing references)
		if (ignoreLocalPlayer && _player.isLocal)
		{
			ignoreLocalPlayer = false;
		}
		else
		{
			if (GameManager.Multiplayer() && !_player.photonView.IsMine)
			{
				return;
			}
			tinnitus(_player);
			int num = SemiFunc.EnemyGetIndex(enemyHost);
			if (playerKill)
			{
				onImpactAny.Invoke();
				onImpactPlayer.Invoke();
				_player.playerHealth.Hurt(_player.playerHealth.health, true, num);
			}
			else
			{
				if (!CanHit(((Component)_player).gameObject, playerDamageCooldown, playerRayCast, _player.PlayerVisionTarget.VisionTransform.position, HitType.Player))
				{
					return;
				}
				_player.playerHealth.Hurt(playerDamage, true, num);
				bool flag = false;
				Bounds bounds = Collider.bounds;
				Vector3 center = ((Bounds)(ref bounds)).center;
				Vector3 val = _player.PlayerVisionTarget.VisionTransform.position - center;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				normalized = SemiFunc.ClampDirection(normalized, ((Component)this).transform.forward, hitSpread);
				bool flag2 = _player.tumble.isTumbling;
				if (playerTumbleTime > 0f && _player.playerHealth.health > 0)
				{
					_player.tumble.TumbleRequest(true, false);
					_player.tumble.TumbleOverrideTime(playerTumbleTime);
					if (playerTumbleImpactHurtTime > 0f)
					{
						_player.tumble.ImpactHurtSet(playerTumbleImpactHurtTime, playerTumbleImpactHurtDamage);
					}
					flag2 = true;
					flag = true;
				}
				if (flag2 && (playerTumbleForce > 0f || playerTumbleTorque > 0f))
				{
					flag = true;
					if (playerTumbleForce > 0f)
					{
						_player.tumble.TumbleForce(normalized * playerTumbleForce);
					}
					if (playerTumbleTorque > 0f)
					{
						Vector3 val2 = Vector3.zero;
						if (playerTumbleTorqueAxis == TorqueAxis.up)
						{
							val2 = ((Component)_player).transform.up;
						}
						if (playerTumbleTorqueAxis == TorqueAxis.down)
						{
							val2 = -((Component)_player).transform.up;
						}
						if (playerTumbleTorqueAxis == TorqueAxis.right)
						{
							val2 = ((Component)_player).transform.right;
						}
						if (playerTumbleTorqueAxis == TorqueAxis.left)
						{
							val2 = -((Component)_player).transform.right;
						}
						if (playerTumbleTorqueAxis == TorqueAxis.forward)
						{
							val2 = ((Component)_player).transform.forward;
						}
						if (playerTumbleTorqueAxis == TorqueAxis.back)
						{
							val2 = -((Component)_player).transform.forward;
						}
						val = _player.localCameraPosition - center;
						Vector3 val3 = Vector3.Cross(((Vector3)(ref val)).normalized, val2) * playerTumbleTorque;
						_player.tumble.TumbleTorque(val3);
					}
				}
				if (!flag2 && playerHitForce > 0f)
				{
					PlayerController.instance.ForceImpulse(normalized * playerHitForce);
				}
				if (playerHitForce > 0f || playerDamage > 0 || flag)
				{
					onImpactPlayerAvatar = _player;
					onImpactAny.Invoke();
					onImpactPlayer.Invoke();
				}
			}
		}
	}

	private bool PhysObjectHurt(PhysGrabObject physGrabObject, BreakImpact impact, float hitForce, float hitTorque, bool apply, bool destroyLaunch, Enemy enemy = null)
	{
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: 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_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_0178: 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_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: 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_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: 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_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: 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_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_0343: Unknown result type (might be due to invalid IL or missing references)
		//IL_0356: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: Unknown result type (might be due to invalid IL or missing references)
		//IL_029c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0303: Unknown result type (might be due to invalid IL or missing references)
		//IL_0307: Unknown result type (might be due to invalid IL or missing references)
		//IL_0311: Unknown result type (might be due to invalid IL or missing references)
		//IL_0321: Unknown result type (might be due to invalid IL or missing references)
		//IL_0326: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		bool result = false;
		switch (impact)
		{
		case BreakImpact.Light:
			physGrabObject.lightBreakImpulse = true;
			result = true;
			break;
		case BreakImpact.Medium:
			physGrabObject.mediumBreakImpulse = true;
			result = true;
			break;
		case BreakImpact.Heavy:
			physGrabObject.heavyBreakImpulse = true;
			result = true;
			break;
		}
		if (Object.op_Implicit((Object)(object)enemyHost) && impact != 0 && physGrabObject.playerGrabbing.Count <= 0 && !physGrabObject.impactDetector.isEnemy)
		{
			physGrabObject.impactDetector.enemyInteractionTimer = 2f;
		}
		if (hitForce > 0f)
		{
			if (hitForce >= 5f && physGrabObject.playerGrabbing.Count > 0 && !physGrabObject.overrideKnockOutOfGrabDisable)
			{
				foreach (PhysGrabber item in physGrabObject.playerGrabbing.ToList())
				{
					if (!SemiFunc.IsMultiplayer())
					{
						item.ReleaseObjectRPC(true, 2f);
						continue;
					}
					item.photonView.RPC("ReleaseObjectRPC", (RpcTarget)0, new object[2] { false, 1f });
				}
			}
			Bounds bounds = Collider.bounds;
			Vector3 center = ((Bounds)(ref bounds)).center;
			Vector3 val = physGrabObject.centerPoint - center;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			normalized = SemiFunc.ClampDirection(normalized, ((Component)this).transform.forward, hitSpread);
			applyForce = normalized * hitForce;
			val = physGrabObject.centerPoint - center;
			Vector3 normalized2 = ((Vector3)(ref val)).normalized;
			Vector3 val2 = -((Component)physGrabObject).transform.up;
			applyTorque = Vector3.Cross(normalized2, val2) * hitTorque;
			if (destroyLaunch && !physGrabObject.rb.isKinematic)
			{
				physGrabObject.rb.velocity = Vector3.zero;
				physGrabObject.rb.angularVelocity = Vector3.zero;
				PhysGrabObjectImpactDetector impactDetector = physGrabObject.impactDetector;
				impactDetector.destroyDisableLaunches++;
				physGrabObject.impactDetector.destroyDisableLaunchesTimer = 10f;
				float num = 20f;
				if (Object.op_Implicit((Object)(object)enemy))
				{
					num = 3f;
				}
				val = Random.insideUnitSphere;
				Vector3 val3 = ((Vector3)(ref val)).normalized * 4f;
				if (physGrabObject.impactDetector.destroyDisableLaunches >= 3)
				{
					val3 *= num;
					physGrabObject.impactDetector.destroyDisableLaunches = 0;
				}
				val3.y = 0f;
				if (Object.op_Implicit((Object)(object)enemy))
				{
					val3 *= 0.25f;
				}
				applyForce = (Vector3.up * num + val3) * physGrabObject.rb.mass;
				val = Random.insideUnitSphere;
				applyTorque = ((Vector3)(ref val)).normalized * 0.25f * physGrabObject.rb.mass;
				physGrabObject.DeathPitEffectCreate();
			}
			if (apply)
			{
				physGrabObject.rb.AddForce(applyForce, (ForceMode)1);
				physGrabObject.rb.AddTorque(applyTorque, (ForceMode)1);
				result = true;
			}
		}
		return result;
	}

	private void OnDrawGizmos()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: 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_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_00df: 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_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: 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_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: 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_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: 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_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: 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_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0294: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0301: Unknown result type (might be due to invalid IL or missing references)
		//IL_0306: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0314: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Unknown result type (might be due to invalid IL or missing references)
		//IL_0327: Unknown result type (might be due to invalid IL or missing references)
		//IL_032c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0337: Unknown result type (might be due to invalid IL or missing references)
		//IL_033c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0341: Unknown result type (might be due to invalid IL or missing references)
		//IL_0345: Unknown result type (might be due to invalid IL or missing references)
		//IL_034f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0354: Unknown result type (might be due to invalid IL or missing references)
		//IL_0368: Unknown result type (might be due to invalid IL or missing references)
		//IL_036d: 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_037d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0382: Unknown result type (might be due to invalid IL or missing references)
		//IL_0386: 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_0395: Unknown result type (might be due to invalid IL or missing references)
		//IL_0397: Unknown result type (might be due to invalid IL or missing references)
		//IL_0398: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03da: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0439: Unknown result type (might be due to invalid IL or missing references)
		//IL_044b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0450: Unknown result type (might be due to invalid IL or missing references)
		BoxCollider component = ((Component)this).GetComponent<BoxCollider>();
		SphereCollider component2 = ((Component)this).GetComponent<SphereCollider>();
		Vector3 val;
		if (Object.op_Implicit((Object)(object)component2) && (((Component)this).transform.localScale.z != ((Component)this).transform.localScale.x || ((Component)this).transform.localScale.z != ((Component)this).transform.localScale.y))
		{
			val = ((Component)this).transform.localScale;
			Debug.LogError((object)("Sphere Collider must be uniform scale: " + ((object)(Vector3)(ref val)).ToString()), (Object)(object)((Component)((Component)this).transform).gameObject);
		}
		Gizmos.color = new Color(1f, 0f, 0.39f, 6f);
		Gizmos.matrix = ((Component)this).transform.localToWorldMatrix;
		if (Object.op_Implicit((Object)(object)component))
		{
			Gizmos.DrawWireCube(component.center, component.size);
		}
		if (Object.op_Implicit((Object)(object)component2))
		{
			Gizmos.DrawWireSphere(component2.center, component2.radius);
		}
		Gizmos.color = new Color(1f, 0f, 0.39f, 0.2f);
		if (Object.op_Implicit((Object)(object)component))
		{
			Gizmos.DrawCube(component.center, component.size);
		}
		if (Object.op_Implicit((Object)(object)component2))
		{
			Gizmos.DrawSphere(component2.center, component2.radius);
		}
		Gizmos.color = Color.white;
		Gizmos.matrix = Matrix4x4.identity;
		Vector3 val2 = Vector3.zero;
		Bounds bounds;
		if (Object.op_Implicit((Object)(object)component))
		{
			bounds = ((Collider)component).bounds;
			val2 = ((Bounds)(ref bounds)).center;
		}
		if (Object.op_Implicit((Object)(object)component2))
		{
			bounds = ((Collider)component2).bounds;
			val2 = ((Bounds)(ref bounds)).center;
		}
		Vector3 val3 = val2 + ((Component)this).transform.forward * 0.5f;
		Gizmos.DrawLine(val2, val3);
		Gizmos.DrawLine(val3, val3 + Vector3.LerpUnclamped(-((Component)this).transform.forward, -((Component)this).transform.right, 0.5f) * 0.25f);
		Gizmos.DrawLine(val3, val3 + Vector3.LerpUnclamped(-((Component)this).transform.forward, ((Component)this).transform.right, 0.5f) * 0.25f);
		if (hitSpread < 180f)
		{
			Gizmos.color = new Color(1f, 1f, 1f, 0.2f);
			val = Quaternion.AngleAxis(hitSpread, ((Component)this).transform.right) * ((Component)this).transform.forward;
			Vector3 val4 = ((Vector3)(ref val)).normalized * 1.5f;
			val = Quaternion.AngleAxis(0f - hitSpread, ((Component)this).transform.right) * ((Component)this).transform.forward;
			Vector3 val5 = ((Vector3)(ref val)).normalized * 1.5f;
			val = Quaternion.AngleAxis(hitSpread, ((Component)this).transform.up) * ((Component)this).transform.forward;
			Vector3 val6 = ((Vector3)(ref val)).normalized * 1.5f;
			val = Quaternion.AngleAxis(0f - hitSpread, ((Component)this).transform.up) * ((Component)this).transform.forward;
			Vector3 val7 = ((Vector3)(ref val)).normalized * 1.5f;
			Gizmos.DrawRay(val2, val4);
			Gizmos.DrawRay(val2, val5);
			Gizmos.DrawRay(val2, val6);
			Gizmos.DrawRay(val2, val7);
			Gizmos.DrawLineStrip((ReadOnlySpan<Vector3>)(Vector3[]?)(object)new Vector3[4]
			{
				val2 + val4,
				val2 + val6,
				val2 + val5,
				val2 + val7
			}, true);
		}
		else if (hitSpread > 180f)
		{
			Debug.LogError((object)"Hit Spread cannot be greater than 180 degrees");
		}
		if (hasCustomRaycastPosition)
		{
			Gizmos.color = Color.blue;
			Gizmos.DrawWireSphere(((Component)this).transform.TransformPoint(customRaycastPosition), 0.2f);
		}
	}
}
namespace SonicGun
{
	public class EarSound
	{
		private static GameObject audioObject;

		private static AudioSource source;

		public static AudioClip tinnitusSound;

		public static AudioSource PrepareSound(AudioClip clip)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			if ((Object)(object)audioObject == (Object)null)
			{
				audioObject = new GameObject("AudioSource");
				Object.DontDestroyOnLoad((Object)(object)audioObject);
				source = audioObject.AddComponent<AudioSource>();
				source.spatialBlend = 0f;
				source.loop = false;
				source.playOnAwake = false;
				source.volume = 0f;
			}
			source.clip = clip;
			return source;
		}
	}
	public class NewValues
	{
		public float MaxInvestigateRangeMultiplier = 0f;

		public float InvestigateRangeMultiplier;

		public override string ToString()
		{
			return "MaxInvestigateRangeMultiplier=" + MaxInvestigateRangeMultiplier + " InvestigateRangeMultiplier=" + InvestigateRangeMultiplier;
		}
	}
	[BepInPlugin("slenered.SonicGun", "SonicGun", "1.0")]
	public class SonicGun : BaseUnityPlugin
	{
		internal static class Patch
		{
			private static AudioSource audio;

			[HarmonyPatch(typeof(GameDirector), "OutroStart")]
			[HarmonyPostfix]
			private static void PatchGameDirectorOutroStart(GameDirector __instance)
			{
				ValueStorage.tinnitusVolume = 0f;
			}

			[HarmonyPatch(typeof(PlayerAvatar), "PlayerDeath")]
			[HarmonyPostfix]
			private static void PatchPlayerDeath(PlayerAvatar __instance)
			{
				ValueStorage.tinnitusVolume = 0f;
			}

			[HarmonyPatch(typeof(AudioManager), "Update")]
			[HarmonyPrefix]
			private static bool PatchAudioManagerUpdate(AudioManager __instance)
			{
				if (ValueStorage.tinnitusVolume <= 0f)
				{
					if ((Object)(object)audio != (Object)null && audio.isPlaying)
					{
						audio.Stop();
					}
					return true;
				}
				ValueStorage.tinnitusVolume -= Time.deltaTime / 20f;
				if ((Object)(object)audio == (Object)null)
				{
					audio = EarSound.PrepareSound(EarSound.tinnitusSound);
				}
				if (!audio.isPlaying)
				{
					audio.Play();
				}
				audio.volume = ValueStorage.tinnitusVolume * 0.5f;
				float num = Mathf.Lerp(-80f, 0f, __instance.VolumeCurve.Evaluate((float)DataDirector.instance.SettingValueFetch((Setting)0) * 0.01f * (1.2f - ValueStorage.tinnitusVolume)));
				float num2 = Mathf.Lerp(-80f, 0f, __instance.VolumeCurve.Evaluate((float)DataDirector.instance.SettingValueFetch((Setting)1) * 0.01f * (1.2f - ValueStorage.tinnitusVolume)));
				float num3 = Mathf.Lerp(-80f, 0f, __instance.VolumeCurve.Evaluate((float)DataDirector.instance.SettingValueFetch((Setting)4) * 0.01f * (1.2f - ValueStorage.tinnitusVolume)));
				float num4 = Mathf.Lerp(-80f, 0f, __instance.VolumeCurve.Evaluate((float)DataDirector.instance.SettingValueFetch((Setting)8) * 0.01f * (1.2f - ValueStorage.tinnitusVolume)));
				__instance.MusicMasterGroup.audioMixer.SetFloat("MusicVolume", num);
				__instance.SoundMasterGroup.audioMixer.SetFloat("SoundVolume", num2);
				__instance.MicrophoneSoundGroup.audioMixer.SetFloat("MicrophoneVolume", num3);
				__instance.TTSSoundGroup.audioMixer.SetFloat("TTSVolume", num4);
				return false;
			}

			[HarmonyPatch(typeof(ReverbDirector), "Update")]
			[HarmonyPrefix]
			private static bool PatchReverbDirectorUpdate(ReverbDirector __instance)
			{
				if (ValueStorage.tinnitusVolume <= 0f)
				{
					return true;
				}
				if (PlayerController.instance.playerAvatarScript.RoomVolumeCheck.CurrentRooms.Count > 0)
				{
					ReverbPreset val = ScriptableObject.CreateInstance<ReverbPreset>();
					ReverbPreset reverbPreset = PlayerController.instance.playerAvatarScript.RoomVolumeCheck.CurrentRooms[0].ReverbPreset;
					val.dryLevel = Mathf.Lerp(reverbPreset.dryLevel, 0f, ValueStorage.tinnitusVolume);
					val.room = Mathf.Lerp(reverbPreset.room, -100f, ValueStorage.tinnitusVolume);
					val.roomHF = Mathf.Lerp(reverbPreset.roomHF, -1000f, ValueStorage.tinnitusVolume);
					val.decayTime = Mathf.Lerp(reverbPreset.decayTime, 1f, ValueStorage.tinnitusVolume);
					val.decayHFRatio = Mathf.Lerp(reverbPreset.decayHFRatio, 0.83f, ValueStorage.tinnitusVolume);
					val.reflections = Mathf.Lerp(reverbPreset.reflections, 1646f, ValueStorage.tinnitusVolume);
					val.reflectDelay = Mathf.Lerp(reverbPreset.reflectDelay, 0.3f, ValueStorage.tinnitusVolume);
					val.reverb = Mathf.Lerp(reverbPreset.reverb, 2000f, ValueStorage.tinnitusVolume);
					val.reverbDelay = Mathf.Lerp(reverbPreset.reverbDelay, 0.1f, ValueStorage.tinnitusVolume);
					val.diffusion = Mathf.Lerp(reverbPreset.diffusion, 10f, ValueStorage.tinnitusVolume);
					val.density = Mathf.Lerp(reverbPreset.density, 100f, ValueStorage.tinnitusVolume);
					val.hfReference = Mathf.Lerp(reverbPreset.hfReference, 5000f, ValueStorage.tinnitusVolume);
					val.roomLF = Mathf.Lerp(reverbPreset.roomLF, -28f, ValueStorage.tinnitusVolume);
					val.lfReference = Mathf.Lerp(reverbPreset.lfReference, 250f, ValueStorage.tinnitusVolume);
					if (Object.op_Implicit((Object)(object)val) && (Object)(object)val != (Object)(object)__instance.currentPreset)
					{
						__instance.currentPreset = val;
						__instance.NewPreset();
					}
				}
				if (__instance.lerpAmount < 1f)
				{
					__instance.lerpAmount += __instance.lerpSpeed * Time.deltaTime;
					float num = __instance.reverbCurve.Evaluate(__instance.lerpAmount);
					__instance.dryLevel = Mathf.Lerp(__instance.dryLevelOld, __instance.dryLevelNew, num);
					__instance.mixer.SetFloat("ReverbDryLevel", __instance.dryLevel);
					__instance.room = Mathf.Lerp(__instance.roomOld, __instance.roomNew, num);
					__instance.mixer.SetFloat("ReverbRoom", __instance.room);
					__instance.roomHF = Mathf.Lerp(__instance.roomHFOld, __instance.roomHFNew, num);
					__instance.mixer.SetFloat("ReverbRoomHF", __instance.roomHF);
					__instance.decayTime = Mathf.Lerp(__instance.decayTimeOld, __instance.decayTimeNew, num);
					__instance.mixer.SetFloat("ReverbDecayTime", __instance.decayTime);
					__instance.decayHFRatio = Mathf.Lerp(__instance.decayHFRatioOld, __instance.decayHFRatioNew, num);
					__instance.mixer.SetFloat("ReverbDecayHFRatio", __instance.decayHFRatio);
					__instance.reflections = Mathf.Lerp(__instance.reflectionsOld, __instance.reflectionsNew, num);
					__instance.mixer.SetFloat("ReverbReflections", __instance.reflections);
					__instance.reflectDelay = Mathf.Lerp(__instance.reflectDelayOld, __instance.reflectDelayNew, num);
					__instance.mixer.SetFloat("ReverbReflectDelay", __instance.reflectDelay);
					__instance.reverb = Mathf.Lerp(__instance.reverbOld, __instance.reverbNew, num);
					__instance.mixer.SetFloat("ReverbReverb", __instance.reverb);
					__instance.reverbDelay = Mathf.Lerp(__instance.reverbDelayOld, __instance.reverbDelayNew, num);
					__instance.mixer.SetFloat("ReverbReverbDelay", __instance.reverbDelay);
					__instance.diffusion = Mathf.Lerp(__instance.diffusionOld, __instance.diffusionNew, num);
					__instance.mixer.SetFloat("ReverbDiffusion", __instance.diffusion);
					__instance.density = Mathf.Lerp(__instance.densityOld, __instance.densityNew, num);
					__instance.mixer.SetFloat("ReverbDensity", __instance.density);
					__instance.hfReference = Mathf.Lerp(__instance.hfReferenceOld, __instance.hfReferenceNew, num);
					__instance.mixer.SetFloat("ReverbHFReference", __instance.hfReference);
					__instance.roomLF = Mathf.Lerp(__instance.roomLFOld, __instance.roomLFNew, num);
					__instance.mixer.SetFloat("ReverbRoomLF", __instance.roomLF);
					__instance.lfReference = Mathf.Lerp(__instance.lfReferenceOld, __instance.lfReferenceNew, num);
					__instance.mixer.SetFloat("ReverbLFReference", __instance.lfReference);
				}
				return false;
			}

			[HarmonyPatch(typeof(Enemy), "Start")]
			[HarmonyPostfix]
			private static void PatchStart(Enemy __instance)
			{
				if (__instance.HasStateInvestigate)
				{
					NewValues orCreate = ValueStorage.GetOrCreate((MonoBehaviour)(object)__instance);
					orCreate.MaxInvestigateRangeMultiplier = __instance.StateInvestigate.rangeMultiplier;
					orCreate.InvestigateRangeMultiplier = orCreate.MaxInvestigateRangeMultiplier;
				}
			}

			[HarmonyPatch(typeof(Enemy), "Update")]
			[HarmonyPostfix]
			private static void PatchUpdate(Enemy __instance)
			{
				if (__instance.HasStateInvestigate)
				{
					NewValues orCreate = ValueStorage.GetOrCreate((MonoBehaviour)(object)__instance);
					if (__instance.StateInvestigate.rangeMultiplier < orCreate.InvestigateRangeMultiplier)
					{
						EnemyStateInvestigate stateInvestigate = __instance.StateInvestigate;
						stateInvestigate.rangeMultiplier += orCreate.InvestigateRangeMultiplier / 180f * Time.deltaTime;
					}
					else if (__instance.StateInvestigate.rangeMultiplier > orCreate.InvestigateRangeMultiplier)
					{
						EnemyStateInvestigate stateInvestigate2 = __instance.StateInvestigate;
						stateInvestigate2.rangeMultiplier += orCreate.InvestigateRangeMultiplier;
					}
				}
			}

			[HarmonyPatch(typeof(EnemyParent), "SpawnRPC")]
			[HarmonyPostfix]
			private static void PatchSpawnRPC(EnemyParent __instance, PhotonMessageInfo _info)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				if (SemiFunc.MasterOnlyRPC(_info) && __instance.Enemy.HasStateInvestigate)
				{
					NewValues orCreate = ValueStorage.GetOrCreate((MonoBehaviour)(object)__instance.Enemy);
					orCreate.InvestigateRangeMultiplier = orCreate.MaxInvestigateRangeMultiplier;
					__instance.Enemy.StateInvestigate.rangeMultiplier = orCreate.MaxInvestigateRangeMultiplier;
				}
			}
		}

		public static NetworkedEvent tinnitusEvent;

		internal static SonicGun Instance { get; set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			tinnitusEvent = new NetworkedEvent("tinnitus", (Action<EventData>)tinnitusEventHandler);
			PatchHarmony();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		private static void tinnitusEventHandler(EventData eventData)
		{
			if (SemiFunc.PhotonViewIDPlayerAvatarLocal() == (int)eventData.CustomData)
			{
				ValueStorage.tinnitusVolume = 1f;
			}
		}

		internal void PatchHarmony()
		{
			//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_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			try
			{
				Harmony.PatchAll(typeof(Patch));
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Failed to patch; '" + ex.Message + "'\n" + ex.StackTrace));
			}
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	public static class ValueStorage
	{
		private static readonly ConditionalWeakTable<MonoBehaviour, NewValues> Data = new ConditionalWeakTable<MonoBehaviour, NewValues>();

		public static float tinnitusVolume = 0f;

		public static NewValues GetOrCreate(MonoBehaviour instance)
		{
			return Data.GetOrCreateValue(instance);
		}
	}
}