Decompiled source of M200 Sea Wings v1.0.4

M200_Sea_Wings.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using OpenScripts2;
using OtherLoader;
using Steamworks;
using UnityEngine;
using UnityEngine.UI;

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Niko666.M200_Sea_Wings
{
	[BepInPlugin("Niko666.M200_Sea_Wings", "M200_Sea_Wings", "1.0.4")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	[BepInDependency("h3vr.otherloader", "1.3.0")]
	public class M200_Sea_WingsPlugin : BaseUnityPlugin
	{
		private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

		internal static ManualLogSource Logger;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			LoadAssets();
		}

		private void LoadAssets()
		{
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "Niko666.M200_Sea_Wings");
			OtherLoader.RegisterDirectLoad(BasePath, "Niko666.M200_Sea_Wings", "", "", "m200holy", "");
		}
	}
}
public enum ControlMode
{
	simple = 1,
	touch
}
public class VehicleControl : MonoBehaviour
{
	[Serializable]
	public class CarWheels
	{
		public ConnectWheel wheels;
	}

	[Serializable]
	public class ConnectWheel
	{
		public bool frontWheelDrive = true;

		public Transform frontRight;

		public Transform frontLeft;

		public WheelSetting frontSetting;

		public bool backWheelDrive = true;

		public Transform backRight;

		public Transform backLeft;

		public WheelSetting rearSetting;
	}

	[Serializable]
	public class WheelSetting
	{
		public float Radius = 0.4f;

		public float Weight = 1000f;

		public float Distance = 0.2f;
	}

	[Serializable]
	public class CarLights
	{
		public Light[] brakeLights;

		public Light[] reverseLights;
	}

	[Serializable]
	public class CarSounds
	{
		public AudioSource IdleEngine;

		public AudioSource LowEngine;

		public AudioSource HighEngine;

		public float minPitch = 1f;

		public float maxPitch = 10f;

		public AudioSource nitro;

		public AudioSource switchGear;
	}

	[Serializable]
	public class CarParticles
	{
		public GameObject brakeParticlePerfab;

		public ParticleSystem shiftParticle1;

		public ParticleSystem shiftParticle2;

		private GameObject[] wheelParticle = (GameObject[])(object)new GameObject[4];
	}

	[Serializable]
	public class CarSetting
	{
		public bool showNormalGizmos = false;

		public Transform carSteer;

		public HitGround[] hitGround;

		public List<Transform> cameraSwitchView;

		public float springs = 25000f;

		public float dampers = 1500f;

		public float carPower = 120f;

		public float shiftPower = 150f;

		public float brakePower = 8000f;

		public Vector3 shiftCentre = new Vector3(0f, -0.8f, 0f);

		public float maxSteerAngle = 25f;

		public float shiftDownRPM = 1500f;

		public float shiftUpRPM = 2500f;

		public float idleRPM = 500f;

		public float stiffness = 2f;

		public bool automaticGear = true;

		public float[] gears = new float[6] { -10f, 9f, 6f, 4.5f, 3f, 2.5f };

		public float LimitBackwardSpeed = 60f;

		public float LimitForwardSpeed = 220f;
	}

	[Serializable]
	public class HitGround
	{
		public string tag = "street";

		public bool grounded = false;

		public AudioClip brakeSound;

		public AudioClip groundSound;

		public Color brakeColor;
	}

	private class WheelComponent
	{
		public Transform wheel;

		public WheelCollider collider;

		public Vector3 startPos;

		public float rotation = 0f;

		public float rotation2 = 0f;

		public float maxSteer;

		public bool drive;

		public float pos_y = 0f;

		public WheelSetting settings;
	}

	public ControlMode controlMode = ControlMode.simple;

	public bool activeControl = false;

	public CarWheels carWheels;

	public CarLights carLights;

	public CarSounds carSounds;

	public CarParticles carParticles;

	public CarSetting carSetting;

	[HideInInspector]
	public float steer = 0f;

	[HideInInspector]
	public float accel = 0f;

	[HideInInspector]
	public bool brake;

	private bool shifmotor;

	[HideInInspector]
	public float curTorque = 100f;

	[HideInInspector]
	public float powerShift = 100f;

	[HideInInspector]
	public bool shift;

	private float torque = 100f;

	[HideInInspector]
	public float speed = 0f;

	private float lastSpeed = -10f;

	private bool shifting = false;

	private float[] efficiencyTable = new float[22]
	{
		0.6f, 0.65f, 0.7f, 0.75f, 0.8f, 0.85f, 0.9f, 1f, 1f, 0.95f,
		0.8f, 0.7f, 0.6f, 0.5f, 0.45f, 0.4f, 0.36f, 0.33f, 0.3f, 0.2f,
		0.1f, 0.05f
	};

	private float efficiencyTableStep = 250f;

	private float Pitch;

	private float PitchDelay;

	private float shiftTime = 0f;

	private float shiftDelay = 0f;

	[HideInInspector]
	public int currentGear = 0;

	[HideInInspector]
	public bool NeutralGear = true;

	[HideInInspector]
	public float motorRPM = 0f;

	[HideInInspector]
	public bool Backward = false;

	[HideInInspector]
	public float accelFwd = 0f;

	[HideInInspector]
	public float accelBack = 0f;

	[HideInInspector]
	public float steerAmount = 0f;

	private float wantedRPM = 0f;

	private float w_rotate;

	private float slip;

	private float slip2 = 0f;

	private GameObject[] Particle = (GameObject[])(object)new GameObject[4];

	private Vector3 steerCurAngle;

	private Rigidbody myRigidbody;

	private WheelComponent[] wheels;

	public bool isOn = true;

	public bool isForciblyOff = false;

	private WheelComponent SetWheelComponent(Transform wheel, float maxSteer, bool drive, float pos_y, WheelSetting setting)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Expected O, but got Unknown
		//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)
		WheelComponent wheelComponent = new WheelComponent();
		GameObject val = new GameObject(((Object)wheel).name + "WheelCollider");
		val.transform.parent = ((Component)this).transform;
		val.transform.position = wheel.position;
		val.transform.eulerAngles = ((Component)this).transform.eulerAngles;
		pos_y = val.transform.localPosition.y;
		WheelCollider val2 = (WheelCollider)val.AddComponent(typeof(WheelCollider));
		wheelComponent.wheel = wheel;
		wheelComponent.collider = val.GetComponent<WheelCollider>();
		wheelComponent.drive = drive;
		wheelComponent.pos_y = pos_y;
		wheelComponent.maxSteer = maxSteer;
		wheelComponent.startPos = val.transform.localPosition;
		wheelComponent.settings = setting;
		return wheelComponent;
	}

	private void Awake()
	{
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0223: 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)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: 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_02fa: Unknown result type (might be due to invalid IL or missing references)
		if (carSetting.automaticGear)
		{
			NeutralGear = false;
		}
		myRigidbody = ((Component)((Component)this).transform).GetComponent<Rigidbody>();
		wheels = new WheelComponent[4];
		wheels[0] = SetWheelComponent(carWheels.wheels.frontRight, carSetting.maxSteerAngle, carWheels.wheels.frontWheelDrive, carWheels.wheels.frontRight.position.y, carWheels.wheels.frontSetting);
		wheels[1] = SetWheelComponent(carWheels.wheels.frontLeft, carSetting.maxSteerAngle, carWheels.wheels.frontWheelDrive, carWheels.wheels.frontLeft.position.y, carWheels.wheels.frontSetting);
		wheels[2] = SetWheelComponent(carWheels.wheels.backRight, 0f, carWheels.wheels.backWheelDrive, carWheels.wheels.backRight.position.y, carWheels.wheels.rearSetting);
		wheels[3] = SetWheelComponent(carWheels.wheels.backLeft, 0f, carWheels.wheels.backWheelDrive, carWheels.wheels.backLeft.position.y, carWheels.wheels.rearSetting);
		if (Object.op_Implicit((Object)(object)carSetting.carSteer))
		{
			steerCurAngle = carSetting.carSteer.localEulerAngles;
		}
		WheelComponent[] array = wheels;
		foreach (WheelComponent wheelComponent in array)
		{
			WheelCollider collider = wheelComponent.collider;
			collider.suspensionDistance = wheelComponent.settings.Distance;
			JointSpring suspensionSpring = collider.suspensionSpring;
			suspensionSpring.spring = carSetting.springs;
			suspensionSpring.damper = carSetting.dampers;
			collider.suspensionSpring = suspensionSpring;
			collider.radius = wheelComponent.settings.Radius;
			collider.mass = wheelComponent.settings.Weight;
			WheelFrictionCurve val = collider.forwardFriction;
			((WheelFrictionCurve)(ref val)).asymptoteValue = 5000f;
			((WheelFrictionCurve)(ref val)).extremumSlip = 2f;
			((WheelFrictionCurve)(ref val)).asymptoteSlip = 20f;
			((WheelFrictionCurve)(ref val)).stiffness = carSetting.stiffness;
			collider.forwardFriction = val;
			val = collider.sidewaysFriction;
			((WheelFrictionCurve)(ref val)).asymptoteValue = 7500f;
			((WheelFrictionCurve)(ref val)).asymptoteSlip = 2f;
			((WheelFrictionCurve)(ref val)).stiffness = carSetting.stiffness;
			collider.sidewaysFriction = val;
		}
	}

	public void TurnOnEngine(bool forcibly)
	{
		if (!isForciblyOff)
		{
			isOn = true;
		}
		else if (forcibly)
		{
			isForciblyOff = false;
			isOn = true;
		}
	}

	public void TurnOffEngine(bool forcibly)
	{
		isForciblyOff = forcibly;
		isOn = false;
	}

	public void ShiftTo(int newGear)
	{
		((Component)carSounds.switchGear).GetComponent<AudioSource>().Play();
		currentGear = newGear;
		if (currentGear == 0)
		{
			NeutralGear = true;
		}
		else
		{
			NeutralGear = false;
		}
		if (currentGear == -1)
		{
			currentGear = 0;
		}
	}

	public void ShiftUp(bool ignoreDelay)
	{
		float timeSinceLevelLoad = Time.timeSinceLevelLoad;
		if ((timeSinceLevelLoad < shiftDelay && !ignoreDelay) || currentGear >= carSetting.gears.Length - 1)
		{
			return;
		}
		((Component)carSounds.switchGear).GetComponent<AudioSource>().Play();
		if (!carSetting.automaticGear)
		{
			if (currentGear == 0)
			{
				if (NeutralGear)
				{
					currentGear++;
					NeutralGear = false;
				}
				else
				{
					NeutralGear = true;
				}
			}
			else
			{
				currentGear++;
			}
		}
		else
		{
			currentGear++;
		}
		shiftDelay = timeSinceLevelLoad + 1f;
		shiftTime = 1.5f;
	}

	public void ShiftDown(bool ignoreDelay)
	{
		float timeSinceLevelLoad = Time.timeSinceLevelLoad;
		if ((timeSinceLevelLoad < shiftDelay && !ignoreDelay) || (currentGear <= 0 && !NeutralGear))
		{
			return;
		}
		((Component)carSounds.switchGear).GetComponent<AudioSource>().Play();
		if (!carSetting.automaticGear)
		{
			if (currentGear == 1)
			{
				if (!NeutralGear)
				{
					currentGear--;
					NeutralGear = true;
				}
			}
			else if (currentGear == 0)
			{
				NeutralGear = false;
			}
			else
			{
				currentGear--;
			}
		}
		else
		{
			currentGear--;
		}
		shiftDelay = timeSinceLevelLoad + 0.1f;
		shiftTime = 2f;
	}

	private void OnCollisionEnter(Collision collision)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)((Component)collision.transform.root).GetComponent<VehicleControl>()))
		{
			VehicleControl component = ((Component)collision.transform.root).GetComponent<VehicleControl>();
			Vector3 relativeVelocity = collision.relativeVelocity;
			component.slip2 = Mathf.Clamp(((Vector3)(ref relativeVelocity)).magnitude, 0f, 10f);
			myRigidbody.angularVelocity = new Vector3((0f - myRigidbody.angularVelocity.x) * 0.5f, myRigidbody.angularVelocity.y * 0.5f, (0f - myRigidbody.angularVelocity.z) * 0.5f);
			myRigidbody.velocity = new Vector3(myRigidbody.velocity.x, myRigidbody.velocity.y * 0.5f, myRigidbody.velocity.z);
		}
	}

	private void OnCollisionStay(Collision collision)
	{
		if (Object.op_Implicit((Object)(object)((Component)collision.transform.root).GetComponent<VehicleControl>()))
		{
			((Component)collision.transform.root).GetComponent<VehicleControl>().slip2 = 5f;
		}
	}

	private void Update()
	{
	}

	private void FixedUpdate()
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0704: Unknown result type (might be due to invalid IL or missing references)
		//IL_0709: Unknown result type (might be due to invalid IL or missing references)
		//IL_0751: Unknown result type (might be due to invalid IL or missing references)
		//IL_075a: Unknown result type (might be due to invalid IL or missing references)
		//IL_075f: Unknown result type (might be due to invalid IL or missing references)
		//IL_079b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0acf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ae0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ae5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fca: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fd4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ee6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0eed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ef2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f0c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f17: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f1c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f25: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b3b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b40: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d23: Unknown result type (might be due to invalid IL or missing references)
		if (!isOn)
		{
			accel = 0f;
		}
		Vector3 velocity = myRigidbody.velocity;
		speed = ((Vector3)(ref velocity)).magnitude * 2.7f;
		if (speed < lastSpeed - 10f && slip < 10f)
		{
			slip = lastSpeed / 15f;
		}
		lastSpeed = speed;
		if (slip2 != 0f)
		{
			slip2 = Mathf.MoveTowards(slip2, 0f, 0.1f);
		}
		myRigidbody.centerOfMass = carSetting.shiftCentre;
		if (!carWheels.wheels.frontWheelDrive && !carWheels.wheels.backWheelDrive)
		{
			accel = 0f;
		}
		if (Object.op_Implicit((Object)(object)carSetting.carSteer))
		{
			carSetting.carSteer.localEulerAngles = new Vector3(steerCurAngle.x, steerCurAngle.y, steerCurAngle.z + steer * -120f);
		}
		if (carSetting.automaticGear && currentGear == 1 && accel < 0f)
		{
			if (speed < 5f)
			{
				ShiftDown(ignoreDelay: false);
			}
		}
		else if (carSetting.automaticGear && currentGear == 0 && accel > 0f)
		{
			if (speed < 5f)
			{
				ShiftUp(ignoreDelay: false);
			}
		}
		else if (carSetting.automaticGear && motorRPM > carSetting.shiftUpRPM && accel > 0f && speed > 10f && !brake)
		{
			ShiftUp(ignoreDelay: false);
		}
		else if (carSetting.automaticGear && motorRPM < carSetting.shiftDownRPM && currentGear > 1)
		{
			ShiftDown(ignoreDelay: false);
		}
		if (speed < 1f)
		{
			Backward = true;
		}
		if (currentGear != 0 || !Backward)
		{
			Backward = false;
		}
		Light[] brakeLights = carLights.brakeLights;
		foreach (Light val in brakeLights)
		{
			if (brake || accel < 0f || speed < 1f)
			{
				val.intensity = Mathf.MoveTowards(val.intensity, 8f, 0.5f);
			}
			else
			{
				val.intensity = Mathf.MoveTowards(val.intensity, 0f, 0.5f);
			}
			((Behaviour)val).enabled = val.intensity != 0f;
		}
		Light[] reverseLights = carLights.reverseLights;
		foreach (Light val2 in reverseLights)
		{
			if (speed > 2f && currentGear == 0)
			{
				val2.intensity = Mathf.MoveTowards(val2.intensity, 8f, 0.5f);
			}
			else
			{
				val2.intensity = Mathf.MoveTowards(val2.intensity, 0f, 0.5f);
			}
			((Behaviour)val2).enabled = val2.intensity != 0f;
		}
		wantedRPM = 5500f * accel * 0.1f + wantedRPM * 0.9f;
		float num = 0f;
		int num2 = 0;
		bool flag = false;
		int num3 = 0;
		WheelComponent[] array = wheels;
		WheelHit val4 = default(WheelHit);
		foreach (WheelComponent wheelComponent in array)
		{
			WheelCollider collider = wheelComponent.collider;
			if (wheelComponent.drive)
			{
				num = ((!NeutralGear && brake && currentGear < 2) ? (num + accel * carSetting.idleRPM) : (NeutralGear ? (num + carSetting.idleRPM * accel) : (num + collider.rpm)));
				num2++;
			}
			if (brake || accel < 0f)
			{
				if (accel < 0f || (brake && (wheelComponent == wheels[2] || wheelComponent == wheels[3])))
				{
					if (brake && accel > 0f)
					{
						slip = Mathf.Lerp(slip, 5f, accel * 0.01f);
					}
					else if (speed > 1f)
					{
						slip = Mathf.Lerp(slip, 1f, 0.002f);
					}
					else
					{
						slip = Mathf.Lerp(slip, 1f, 0.02f);
					}
					wantedRPM = 0f;
					collider.brakeTorque = carSetting.brakePower;
					wheelComponent.rotation = w_rotate;
				}
			}
			else
			{
				float brakeTorque;
				if (accel == 0f || NeutralGear)
				{
					float num5 = (collider.brakeTorque = 1000f);
					brakeTorque = num5;
				}
				else
				{
					float num5 = (collider.brakeTorque = 0f);
					brakeTorque = num5;
				}
				collider.brakeTorque = brakeTorque;
				slip = ((!(speed > 0f)) ? (slip = Mathf.Lerp(slip, 0.01f, 0.02f)) : ((!(speed > 100f)) ? (slip = Mathf.Lerp(slip, 1.5f, 0.02f)) : (slip = Mathf.Lerp(slip, 1f + Mathf.Abs(steer), 0.02f))));
				w_rotate = wheelComponent.rotation;
			}
			WheelFrictionCurve val3 = collider.forwardFriction;
			((WheelFrictionCurve)(ref val3)).asymptoteValue = 5000f;
			((WheelFrictionCurve)(ref val3)).extremumSlip = 2f;
			((WheelFrictionCurve)(ref val3)).asymptoteSlip = 20f;
			((WheelFrictionCurve)(ref val3)).stiffness = carSetting.stiffness / (slip + slip2);
			collider.forwardFriction = val3;
			val3 = collider.sidewaysFriction;
			((WheelFrictionCurve)(ref val3)).stiffness = carSetting.stiffness / (slip + slip2);
			((WheelFrictionCurve)(ref val3)).extremumSlip = 0.2f + Mathf.Abs(steer);
			collider.sidewaysFriction = val3;
			if (shift && currentGear > 1 && speed > 50f && shifmotor && Mathf.Abs(steer) < 0.2f)
			{
				if (powerShift == 0f)
				{
					shifmotor = false;
				}
				powerShift = Mathf.MoveTowards(powerShift, 0f, Time.deltaTime * 10f);
				carSounds.nitro.volume = Mathf.Lerp(carSounds.nitro.volume, 1f, Time.deltaTime * 10f);
				if (!carSounds.nitro.isPlaying)
				{
					((Component)carSounds.nitro).GetComponent<AudioSource>().Play();
				}
				curTorque = ((!(powerShift > 0f)) ? carSetting.carPower : carSetting.shiftPower);
				carParticles.shiftParticle1.emissionRate = Mathf.Lerp(carParticles.shiftParticle1.emissionRate, (float)((powerShift > 0f) ? 50 : 0), Time.deltaTime * 10f);
				carParticles.shiftParticle2.emissionRate = Mathf.Lerp(carParticles.shiftParticle2.emissionRate, (float)((powerShift > 0f) ? 50 : 0), Time.deltaTime * 10f);
			}
			else
			{
				if (powerShift > 20f)
				{
					shifmotor = true;
				}
				carSounds.nitro.volume = Mathf.MoveTowards(carSounds.nitro.volume, 0f, Time.deltaTime * 2f);
				if (carSounds.nitro.volume == 0f)
				{
					carSounds.nitro.Stop();
				}
				powerShift = Mathf.MoveTowards(powerShift, 100f, Time.deltaTime * 5f);
				curTorque = carSetting.carPower;
				carParticles.shiftParticle1.emissionRate = Mathf.Lerp(carParticles.shiftParticle1.emissionRate, 0f, Time.deltaTime * 10f);
				carParticles.shiftParticle2.emissionRate = Mathf.Lerp(carParticles.shiftParticle2.emissionRate, 0f, Time.deltaTime * 10f);
			}
			wheelComponent.rotation = Mathf.Repeat(wheelComponent.rotation + Time.deltaTime * collider.rpm * 360f / 60f, 360f);
			wheelComponent.rotation2 = Mathf.Lerp(wheelComponent.rotation2, collider.steerAngle, 0.1f);
			wheelComponent.wheel.localRotation = Quaternion.Euler(wheelComponent.rotation, wheelComponent.rotation2, 0f);
			Vector3 localPosition = wheelComponent.wheel.localPosition;
			if (collider.GetGroundHit(ref val4))
			{
				if (Object.op_Implicit((Object)(object)carParticles.brakeParticlePerfab))
				{
					if ((Object)(object)Particle[num3] == (Object)null)
					{
						Particle[num3] = Object.Instantiate<GameObject>(carParticles.brakeParticlePerfab, wheelComponent.wheel.position, Quaternion.identity);
						((Object)Particle[num3]).name = "WheelParticle";
						Particle[num3].transform.parent = ((Component)this).transform;
						Particle[num3].AddComponent<AudioSource>();
						Particle[num3].GetComponent<AudioSource>().maxDistance = 50f;
						Particle[num3].GetComponent<AudioSource>().spatialBlend = 1f;
						Particle[num3].GetComponent<AudioSource>().dopplerLevel = 5f;
						Particle[num3].GetComponent<AudioSource>().rolloffMode = (AudioRolloffMode)2;
					}
					ParticleSystem component = Particle[num3].GetComponent<ParticleSystem>();
					bool flag2 = false;
					for (int l = 0; l < carSetting.hitGround.Length; l++)
					{
						if (((Component)((WheelHit)(ref val4)).collider).CompareTag(carSetting.hitGround[l].tag))
						{
							flag2 = carSetting.hitGround[l].grounded;
							if ((brake || Mathf.Abs(((WheelHit)(ref val4)).sidewaysSlip) > 0.5f) && speed > 1f)
							{
								Particle[num3].GetComponent<AudioSource>().clip = carSetting.hitGround[l].brakeSound;
							}
							else if ((Object)(object)Particle[num3].GetComponent<AudioSource>().clip != (Object)(object)carSetting.hitGround[l].groundSound && !Particle[num3].GetComponent<AudioSource>().isPlaying)
							{
								Particle[num3].GetComponent<AudioSource>().clip = carSetting.hitGround[l].groundSound;
							}
							Particle[num3].GetComponent<ParticleSystem>().startColor = carSetting.hitGround[l].brakeColor;
						}
					}
					if (flag2 && speed > 5f && !brake)
					{
						component.enableEmission = true;
						Particle[num3].GetComponent<AudioSource>().volume = 0.5f;
						if (!Particle[num3].GetComponent<AudioSource>().isPlaying)
						{
							Particle[num3].GetComponent<AudioSource>().Play();
						}
					}
					else if ((brake || Mathf.Abs(((WheelHit)(ref val4)).sidewaysSlip) > 0.6f) && speed > 1f)
					{
						if (accel < 0f || ((brake || Mathf.Abs(((WheelHit)(ref val4)).sidewaysSlip) > 0.6f) && (wheelComponent == wheels[2] || wheelComponent == wheels[3])))
						{
							if (!Particle[num3].GetComponent<AudioSource>().isPlaying)
							{
								Particle[num3].GetComponent<AudioSource>().Play();
							}
							component.enableEmission = true;
							Particle[num3].GetComponent<AudioSource>().volume = 10f;
						}
					}
					else
					{
						component.enableEmission = false;
						Particle[num3].GetComponent<AudioSource>().volume = Mathf.Lerp(Particle[num3].GetComponent<AudioSource>().volume, 0f, Time.deltaTime * 10f);
					}
				}
				localPosition.y -= Vector3.Dot(wheelComponent.wheel.position - ((WheelHit)(ref val4)).point, ((Component)this).transform.TransformDirection(0f, 1f, 0f) / ((Component)this).transform.lossyScale.x) - collider.radius;
				localPosition.y = Mathf.Clamp(localPosition.y, -10f, wheelComponent.pos_y);
				flag = flag || wheelComponent.drive;
			}
			else
			{
				if ((Object)(object)Particle[num3] != (Object)null)
				{
					ParticleSystem component2 = Particle[num3].GetComponent<ParticleSystem>();
					component2.enableEmission = false;
				}
				localPosition.y = wheelComponent.startPos.y - wheelComponent.settings.Distance;
				myRigidbody.AddForce(Vector3.down * 5000f);
			}
			num3++;
			wheelComponent.wheel.localPosition = localPosition;
		}
		if (num2 > 1)
		{
			num /= (float)num2;
		}
		motorRPM = 0.95f * motorRPM + 0.05f * Mathf.Abs(num * carSetting.gears[currentGear]);
		if (motorRPM > 5500f)
		{
			motorRPM = 5200f;
		}
		int num7 = (int)(motorRPM / efficiencyTableStep);
		if (num7 >= efficiencyTable.Length)
		{
			num7 = efficiencyTable.Length - 1;
		}
		if (num7 < 0)
		{
			num7 = 0;
		}
		float num8 = curTorque * carSetting.gears[currentGear] * efficiencyTable[num7];
		WheelComponent[] array2 = wheels;
		foreach (WheelComponent wheelComponent2 in array2)
		{
			WheelCollider collider2 = wheelComponent2.collider;
			if (wheelComponent2.drive)
			{
				if (Mathf.Abs(collider2.rpm) > Mathf.Abs(wantedRPM))
				{
					collider2.motorTorque = 0f;
				}
				else
				{
					float motorTorque = collider2.motorTorque;
					if (!brake && accel != 0f && !NeutralGear)
					{
						if ((speed < carSetting.LimitForwardSpeed && currentGear > 0) || (speed < carSetting.LimitBackwardSpeed && currentGear == 0))
						{
							collider2.motorTorque = motorTorque * 0.9f + num8 * 1f;
						}
						else
						{
							collider2.motorTorque = 0f;
							collider2.brakeTorque = 2000f;
						}
					}
					else
					{
						collider2.motorTorque = 0f;
					}
				}
			}
			if (brake || slip2 > 2f)
			{
				collider2.steerAngle = Mathf.Lerp(collider2.steerAngle, steer * wheelComponent2.maxSteer, 0.02f);
				continue;
			}
			float num9 = Mathf.Clamp(speed / carSetting.maxSteerAngle, 1f, carSetting.maxSteerAngle);
			collider2.steerAngle = steer * (wheelComponent2.maxSteer / num9);
		}
		Pitch = Mathf.Clamp(1.2f + (motorRPM - carSetting.idleRPM) / (carSetting.shiftUpRPM - carSetting.idleRPM), 1f, 10f);
		shiftTime = Mathf.MoveTowards(shiftTime, 0f, 0.1f);
		if (Pitch == 1f)
		{
			carSounds.IdleEngine.volume = Mathf.Lerp(carSounds.IdleEngine.volume, 1f, 0.1f);
			carSounds.LowEngine.volume = Mathf.Lerp(carSounds.LowEngine.volume, 0.5f, 0.1f);
			carSounds.HighEngine.volume = Mathf.Lerp(carSounds.HighEngine.volume, 0f, 0.1f);
		}
		else
		{
			carSounds.IdleEngine.volume = Mathf.Lerp(carSounds.IdleEngine.volume, 1.8f - Pitch, 0.1f);
			if ((Pitch > PitchDelay || accel > 0f) && shiftTime == 0f)
			{
				carSounds.LowEngine.volume = Mathf.Lerp(carSounds.LowEngine.volume, 0f, 0.2f);
				carSounds.HighEngine.volume = Mathf.Lerp(carSounds.HighEngine.volume, 1f, 0.1f);
			}
			else
			{
				carSounds.LowEngine.volume = Mathf.Lerp(carSounds.LowEngine.volume, 0.5f, 0.1f);
				carSounds.HighEngine.volume = Mathf.Lerp(carSounds.HighEngine.volume, 0f, 0.2f);
			}
			carSounds.HighEngine.pitch = Pitch;
			carSounds.LowEngine.pitch = Pitch;
			PitchDelay = Pitch;
		}
		if (!isOn)
		{
			carSounds.IdleEngine.volume = 0f;
			carSounds.LowEngine.volume = 0f;
			carSounds.HighEngine.volume = 0f;
		}
	}

	private void OnDrawGizmos()
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: 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_00a9: 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)
		if (carSetting.showNormalGizmos && !Application.isPlaying)
		{
			Matrix4x4 matrix = Matrix4x4.TRS(((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform.lossyScale);
			Gizmos.matrix = matrix;
			Gizmos.color = new Color(1f, 0f, 0f, 0.5f);
			Gizmos.DrawCube(Vector3.up / 1.5f, new Vector3(2.5f, 2f, 6f));
			Gizmos.DrawSphere(carSetting.shiftCentre / ((Component)this).transform.lossyScale.x, 0.2f);
		}
	}
}
namespace AndrewFTW
{
	public class AttachableMagWell : FVRFireArmReloadTriggerWell
	{
		public FVRFireArmAttachment Attachment;

		public UniversalMagGrabTrigger MagGrabTrigger;

		public Transform MagMountPos;

		public Transform MagEjectPos;

		private float EjectDelay = 0f;

		private static Dictionary<FVRFireArm, List<AttachableMagWell>> _attachMagwelllDict = new Dictionary<FVRFireArm, List<AttachableMagWell>>();

		private int _index;

		private SecondaryMagazineSlot _mySlot;

		public void OnEnable()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			ref FVRFireArm fireArm = ref base.FireArm;
			FVRPhysicalObject myObject = Attachment.curMount.GetRootMount().MyObject;
			fireArm = (FVRFireArm)(object)((myObject is FVRFireArm) ? myObject : null);
			_index = base.FireArm.SecondaryMagazineSlots.Length;
			base.SecondaryMagSlotIndex = _index;
			_mySlot = new SecondaryMagazineSlot();
			_mySlot.MagazineMountPos = MagMountPos;
			_mySlot.MagazineEjectPos = MagEjectPos;
			_mySlot.m_ejectDelay = EjectDelay;
			Array.Resize(ref base.FireArm.SecondaryMagazineSlots, base.FireArm.SecondaryMagazineSlots.Length + 1);
			base.FireArm.SecondaryMagazineSlots[_index] = _mySlot;
			MagGrabTrigger.FireArm = base.FireArm;
			MagGrabTrigger.SecondaryGrabSlot = _index;
			if (_attachMagwelllDict.TryGetValue(base.FireArm, out var value))
			{
				value.Add(this);
			}
			else
			{
				List<AttachableMagWell> list = new List<AttachableMagWell>();
				list.Add(this);
				value = list;
				_attachMagwelllDict.Add(base.FireArm, value);
			}
			((Component)MagGrabTrigger).gameObject.SetActive(true);
		}

		public void OnDisable()
		{
			((Component)MagGrabTrigger).gameObject.SetActive(false);
			base.FireArm.EjectSecondaryMagFromSlot(_index, false);
			if (_attachMagwelllDict.TryGetValue(base.FireArm, out var value))
			{
				if (value.Count == 1)
				{
					Array.Resize(ref base.FireArm.SecondaryMagazineSlots, base.FireArm.SecondaryMagazineSlots.Length - 1);
					MagGrabTrigger.FireArm = null;
					MagGrabTrigger.SecondaryGrabSlot = 0;
					_attachMagwelllDict.Remove(base.FireArm);
					return;
				}
				foreach (AttachableMagWell item in value)
				{
					if (item._index > _index)
					{
						item._index--;
						((FVRFireArmReloadTriggerWell)item).SecondaryMagSlotIndex = ((FVRFireArmReloadTriggerWell)item).SecondaryMagSlotIndex - 1;
						UniversalMagGrabTrigger magGrabTrigger = item.MagGrabTrigger;
						magGrabTrigger.SecondaryGrabSlot--;
					}
				}
				for (int i = _index; i < base.FireArm.SecondaryMagazineSlots.Length - 1; i++)
				{
					base.FireArm.SecondaryMagazineSlots[i] = base.FireArm.SecondaryMagazineSlots[i + 1];
				}
				Array.Resize(ref base.FireArm.SecondaryMagazineSlots, base.FireArm.SecondaryMagazineSlots.Length - 1);
				value.Remove(this);
				MagGrabTrigger.FireArm = null;
				MagGrabTrigger.SecondaryGrabSlot = 0;
			}
			else
			{
				Debug.Log((object)("fuck somthing broke tell Andrew_FTW you broke his mag script: " + this));
			}
		}
	}
	public class AttachableSimpleFirearm : AttachableFirearm
	{
		public FVRFireArmChamber Chamber;

		[Header("Trigger Config")]
		public Transform Trigger;

		public float TriggerFiringThreshold = 0.8f;

		public float TriggerResetThreshold = 0.4f;

		public float Trigger_ForwardValue;

		public float Trigger_RearwardValue;

		public Axis TriggerAxis;

		public InterpStyle TriggerInterpStyle = (InterpStyle)1;

		[NonSerialized]
		[HideInInspector]
		public float m_triggerFloat;

		[NonSerialized]
		[HideInInspector]
		public bool m_hasTriggerReset;

		[Header("Fore Slide Stuff")]
		public MovableObjectPart MoveableComponent;

		public FVRFirearmAudioSet[] AudioSets;

		public bool isDebug = false;
	}
	public class BackBlast : MonoBehaviour
	{
		public FVRFireArm Firearm;

		public List<GameObject> SpawnOnSplode;
	}
	public class BetterCaseless : MonoBehaviour
	{
		private FVRFireArmRound Round;
	}
	public class BipodExtras : MonoBehaviour
	{
		public FVRFireArmBipod Bipod;

		public bool Rotatelegs;

		public GameObject LegHolder1;

		public GameObject LegHolder2;

		public Vector3 LegOpenAngles1;

		public Vector3 LegOpenAngles2;

		public bool MoveObj;

		public GameObject ObjToMove;

		public Vector3 ObjOpenLocalPos;

		private bool m_beenUpdated = false;
	}
	public class BlastJumpOnFire : MonoBehaviour
	{
		public FVRFireArm Firearm;

		public bool IsMinigun;

		public float lungeStrength = -2f;
	}
	public class Blaster : FVRFireArm
	{
		[Header("Blaster Parts")]
		public FVRFireArmChamber Chamber;

		public Transform Trigger;

		public float TriggerFiringThreshold = 0.8f;

		public float TriggerResetThreshold = 0.4f;

		public float Trigger_ForwardValue;

		public float Trigger_RearwardValue;

		public Axis TriggerAxis;

		public InterpStyle TriggerInterpStyle = (InterpStyle)1;

		[NonSerialized]
		[HideInInspector]
		public float m_triggerFloat;

		[NonSerialized]
		[HideInInspector]
		public bool m_hasTriggerReset;

		public bool UsesHeat = true;

		public float HeatPerShot = 0.1f;

		public float HeatDisipationRate = 0.3f;

		public float SecondsPerShot = 0.3f;

		public float TimeDisabledAfterOverheat = 2f;

		public bool UsesHeatingEffect;

		public List<Renderer> Renderers = new List<Renderer>();

		public bool isDebug = false;

		private float timeSinceLastShot = 0f;

		private bool isDisabled = false;

		private float heat = 0f;

		private float disipationTimer;

		private MaterialPropertyBlock PropertyBlock = new MaterialPropertyBlock();
	}
	public class ChangePhysWhenSpent : MonoBehaviour
	{
		public FVRFireArmRound Round;

		public GameObject UnfiredPhys;

		public GameObject FiredPhys;
	}
}
public class EnableOnSpecificUser : MonoBehaviour
{
	public enum action
	{
		Enable,
		Disable,
		ModifyFirearm
	}

	public action Action;

	public List<CSteamID> listofUsers;

	[Header("Object Enable")]
	public GameObject objectToEnable;

	[Header("Firearm Modify")]
	public Handgun Handgun;

	public bool HasMagReleaseButton;
}
namespace AndrewFTW
{
	public class FireAttachableFirearmFromMainHand : MonoBehaviour
	{
		public enum FireSelectorModeType
		{
			Single,
			FullAuto
		}

		public enum firearmActionMode
		{
			ClosedBolt,
			OpenBolt
		}

		public FVRFireArm FireArm;

		public AttachableFirearm AttachableFirearm;

		public firearmActionMode FirearmActionMode = firearmActionMode.ClosedBolt;

		public FireSelectorModeType MainWeponFireMode = FireSelectorModeType.Single;

		public AudioEvent SwitchSound;

		private float triggerFW;

		private float triggerRW;

		private bool selectorOnMain = true;

		private static Dictionary<FVRPhysicalObject, FireAttachableFirearmFromMainHand> fireAttachables = new Dictionary<FVRPhysicalObject, FireAttachableFirearmFromMainHand>();
	}
	public class FireSubprojAtDistance : MonoBehaviour
	{
		public BallisticProjectile parentRound;

		public float distanceToFire;

		[Header("Tangent Munitions")]
		public List<Submunition> TangentMunitions;

		public List<bool> usesParentSpeed;

		private bool m_hasFiredTangentMunitions;
	}
	public class FireSubprojAtTime : MonoBehaviour
	{
		[Serializable]
		public class c_TangentMunition
		{
			public enum SubmunitionType
			{
				GameObject,
				Projectile,
				Rigidbody,
				StickyBomb,
				MeleeThrown,
				Demonade
			}

			public enum SubmunitionTrajectoryType
			{
				Random,
				RicochetDir,
				Backwards,
				Forwards,
				ForwardsCone
			}

			public enum SubmunitionSpawnLogic
			{
				Outside,
				Inside,
				On
			}

			public List<GameObject> Prefabs;

			public int NumToSpawn;

			public SubmunitionTrajectoryType Trajectory;

			public SubmunitionType Type;

			public SubmunitionSpawnLogic SpawnLogic;

			public Vector2 Speed = default(Vector2);

			public bool usesParentSpeed;

			public float ConeLerp = 0.85f;
		}

		public BallisticProjectile parentRound;

		public float timeToFire;

		[Header("Tangent Munitions")]
		public List<c_TangentMunition> TangentMunitions;

		private bool m_hasFiredTangentMunitions;

		private float currLifeTime = 0f;
	}
	public class FireSubprojOnTimeOut : MonoBehaviour
	{
		public BallisticProjectile ParentRound;

		public Vector2 FuseTimer;

		private float _setFuseTimer;

		private float _fuseElapsedTime = 0f;
	}
	public class GrenadeLauncherRedDot : MonoBehaviour
	{
		[Header("Grenade Launcher Red Dot Config")]
		public FVRFireArmAttachment Attachment;

		public FVRInteractiveObject AttachmentInterface;

		public Transform TiltingOpticPart;

		public MeshRenderer ReticleMeshRenderer;

		[Header("Reticles")]
		[Tooltip("Index of the Array below, not the actual value. Starts at 0.")]
		public int CurrentSelectedTextureIndex = 0;

		public Texture2D[] ReticleTextures;

		[Tooltip("Switch that moves with the selected texture (optional).")]
		public Transform ButtonSwitch;

		public Vector3[] SwitchPositions;

		[Header("If you want a Screen above the scope that shows stuff, use this:")]
		public Transform TextFrame;

		public Text ReticleTextScreen;

		public Text ZeroTextScreen;

		public string ReticleTextPrefix = "Reticle: ";

		public string[] ReticleTextField;

		public string ZeroTextPrefix = "Zero Distance: ";

		[Tooltip("Index of the Array below, not the actual value. Starts at 0.")]
		public int CurrentZeroDistanceIndex = 0;

		[Tooltip("In meters. Miss me with that imperial shit!")]
		public float[] ZeroDistances = new float[7] { 50f, 100f, 150f, 200f, 300f, 500f, 1000f };

		[Header("Intergrated Sight configuration")]
		public bool IsIntegrated = false;

		public AttachableFirearm AttachableFirearm;

		[Header("Reticle Occlusion culling")]
		[Tooltip("Use this for extra performant reticle occlusion culling")]
		public Collider LensCollider;

		public bool DisableOcclusionCulling = false;

		private FVRViveHand m_hand;

		private int _currentMenu = 0;

		private bool _zeroOnlyMode = false;

		private string _nameOfTexture = "_RedDotTex";

		private string _nameOfDistanceVariable = "_RedDotDist";

		private string _nameOfXOffset = "_MuzzleOffsetX";

		private string _nameOfYOffset = "_MuzzleOffsetY";

		private List<Collider> _scopeColliders;

		private Transform _muzzlePos;

		private bool _attached = false;

		private Transform _head;

		private Vector3 _leftEye;

		private Vector3 _rightEye;

		public void Start()
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: 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_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: 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_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: 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)
			if (CurrentSelectedTextureIndex >= ReticleTextures.Length)
			{
				CurrentSelectedTextureIndex = 0;
			}
			if (CurrentZeroDistanceIndex >= ZeroDistances.Length)
			{
				CurrentZeroDistanceIndex = 0;
			}
			if (ReticleTextures.Length != 0)
			{
				((Renderer)ReticleMeshRenderer).material.SetTexture(_nameOfTexture, (Texture)(object)ReticleTextures[CurrentSelectedTextureIndex]);
			}
			((Renderer)ReticleMeshRenderer).material.SetFloat(_nameOfDistanceVariable, ZeroDistances[CurrentZeroDistanceIndex]);
			if ((Object)(object)ButtonSwitch != (Object)null)
			{
				ButtonSwitch.localPosition = SwitchPositions[CurrentSelectedTextureIndex];
			}
			if (ReticleTextures.Length <= 1)
			{
				_zeroOnlyMode = true;
				_currentMenu = 1;
			}
			_scopeColliders = new List<Collider>(((FVRInteractiveObject)Attachment).m_colliders);
			if (IsIntegrated)
			{
				_muzzlePos = AttachableFirearm.MuzzlePos;
				Vector3 val = _muzzlePos.InverseTransformPoint(((Component)ReticleMeshRenderer).transform.position);
				((Renderer)ReticleMeshRenderer).material.SetFloat(_nameOfXOffset, 0f - val.x);
				((Renderer)ReticleMeshRenderer).material.SetFloat(_nameOfYOffset, 0f - val.y);
			}
			StartScreen();
			_head = GM.CurrentPlayerBody.Head;
			_leftEye = _head.position + _head.right * -0.032f;
			_rightEye = _head.position + _head.right * 0.032f;
			Zero();
		}

		public void UseNextTexture()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			CurrentSelectedTextureIndex = (CurrentSelectedTextureIndex + 1) % ReticleTextures.Length;
			((Renderer)ReticleMeshRenderer).material.SetTexture(_nameOfTexture, (Texture)(object)ReticleTextures[CurrentSelectedTextureIndex]);
			if ((Object)(object)ButtonSwitch != (Object)null)
			{
				ButtonSwitch.localPosition = SwitchPositions[CurrentSelectedTextureIndex];
			}
			UpdateScreen();
		}

		public void UsePreviousTexture()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			CurrentSelectedTextureIndex = (CurrentSelectedTextureIndex + ReticleTextures.Length - 1) % ReticleTextures.Length;
			((Renderer)ReticleMeshRenderer).material.SetTexture(_nameOfTexture, (Texture)(object)ReticleTextures[CurrentSelectedTextureIndex]);
			if ((Object)(object)ButtonSwitch != (Object)null)
			{
				ButtonSwitch.localPosition = SwitchPositions[CurrentSelectedTextureIndex];
			}
			UpdateScreen();
		}

		private void ShowNextMenu()
		{
			if ((Object)(object)ReticleTextScreen == (Object)null && (Object)(object)ZeroTextScreen == (Object)null)
			{
				return;
			}
			_currentMenu++;
			if (_currentMenu > 2)
			{
				_currentMenu = 0;
			}
			switch (_currentMenu)
			{
			case 0:
				if ((Object)(object)ReticleTextScreen == (Object)null)
				{
					ShowNextMenu();
					return;
				}
				break;
			case 1:
				if ((Object)(object)ZeroTextScreen == (Object)null)
				{
					ShowNextMenu();
					return;
				}
				break;
			default:
				_currentMenu = 0;
				break;
			}
			UpdateScreen();
		}

		private void UpdateScreen()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ReticleTextScreen != (Object)null && _currentMenu == 0)
			{
				if ((Object)(object)TextFrame != (Object)null)
				{
					TextFrame.localPosition = ((Component)ReticleTextScreen).transform.localPosition;
				}
				ReticleTextScreen.text = ReticleTextPrefix + ReticleTextField[CurrentSelectedTextureIndex];
			}
			else if ((Object)(object)ReticleTextScreen == (Object)null)
			{
				_currentMenu = 1;
			}
			if ((Object)(object)ZeroTextScreen != (Object)null && _currentMenu == 1)
			{
				if ((Object)(object)TextFrame != (Object)null)
				{
					TextFrame.localPosition = ((Component)ZeroTextScreen).transform.localPosition;
				}
				ZeroTextScreen.text = ZeroTextPrefix + ZeroDistances[CurrentZeroDistanceIndex] + "m";
			}
		}

		private void StartScreen()
		{
			if ((Object)(object)ReticleTextScreen != (Object)null)
			{
				ReticleTextScreen.text = ReticleTextPrefix + ReticleTextField[CurrentSelectedTextureIndex];
			}
			if ((Object)(object)ZeroTextScreen != (Object)null)
			{
				ZeroTextScreen.text = ZeroTextPrefix + ZeroDistances[CurrentZeroDistanceIndex] + "m";
			}
		}

		public void UseNextZeroDistance()
		{
			if (CurrentZeroDistanceIndex > 0)
			{
				CurrentZeroDistanceIndex--;
			}
			((Renderer)ReticleMeshRenderer).material.SetFloat(_nameOfDistanceVariable, ZeroDistances[CurrentZeroDistanceIndex]);
			UpdateScreen();
			Zero();
		}

		public void UsePreviousZeroDistance()
		{
			if (CurrentZeroDistanceIndex < ZeroDistances.Length - 1)
			{
				CurrentZeroDistanceIndex++;
			}
			((Renderer)ReticleMeshRenderer).material.SetFloat(_nameOfDistanceVariable, ZeroDistances[CurrentZeroDistanceIndex]);
			UpdateScreen();
			Zero();
		}

		private void CheckReticleVisibility()
		{
			//IL_0265: 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_028c: 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_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: 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_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			if ((Object)(object)LensCollider == (Object)null && _scopeColliders.Count > 0)
			{
				float num = Vector3.Distance(((Component)this).gameObject.transform.position, GM.CurrentPlayerBody.Head.position) + 0.2f;
				Vector3 val = _muzzlePos.position + ((Component)this).transform.forward * ZeroDistances[CurrentZeroDistanceIndex] - _rightEye;
				bool flag2 = false;
				if (Vector3.Angle(GM.CurrentPlayerBody.Head.forward, ((Component)this).transform.forward) < 45f)
				{
					RaycastHit[] array = Physics.RaycastAll(_rightEye, val, num, LayerMask.NameToLayer("Environment"), (QueryTriggerInteraction)1);
					if (array.Length != 0)
					{
						RaycastHit[] array2 = array;
						for (int i = 0; i < array2.Length; i++)
						{
							RaycastHit val2 = array2[i];
							if (_scopeColliders.Contains(((RaycastHit)(ref val2)).collider))
							{
								((Component)ReticleMeshRenderer).gameObject.SetActive(true);
								flag = true;
							}
						}
					}
				}
				if (!flag)
				{
					flag2 = false;
					val = _muzzlePos.position + ((Component)this).transform.forward * ZeroDistances[CurrentZeroDistanceIndex] - _leftEye;
					if (Vector3.Angle(GM.CurrentPlayerBody.Head.forward, ((Component)this).transform.forward) < 45f)
					{
						RaycastHit[] array = Physics.RaycastAll(_leftEye, val, num, LayerMask.NameToLayer("Environment"), (QueryTriggerInteraction)1);
						if (array.Length != 0)
						{
							RaycastHit[] array3 = array;
							for (int j = 0; j < array3.Length; j++)
							{
								RaycastHit val3 = array3[j];
								if (_scopeColliders.Contains(((RaycastHit)(ref val3)).collider))
								{
									((Component)ReticleMeshRenderer).gameObject.SetActive(true);
									flag = true;
								}
							}
						}
					}
				}
				if (!flag)
				{
					((Component)ReticleMeshRenderer).gameObject.SetActive(false);
				}
			}
			else if ((Object)(object)LensCollider != (Object)null)
			{
				float num2 = Vector3.Distance(((Component)this).gameObject.transform.position, GM.CurrentPlayerBody.Head.position) + 0.2f;
				Vector3 val4 = _muzzlePos.position + ((Component)this).transform.forward * ZeroDistances[CurrentZeroDistanceIndex] - _rightEye;
				if (Vector3.Angle(GM.CurrentPlayerBody.Head.forward, ((Component)this).transform.forward) < 45f)
				{
					Ray val5 = default(Ray);
					((Ray)(ref val5))..ctor(_rightEye, val4);
					RaycastHit val6 = default(RaycastHit);
					if (LensCollider.Raycast(val5, ref val6, num2))
					{
						((Component)ReticleMeshRenderer).gameObject.SetActive(true);
						flag = true;
					}
				}
				if (!flag)
				{
					val4 = _muzzlePos.position + ((Component)this).transform.forward * ZeroDistances[CurrentZeroDistanceIndex] - _leftEye;
					if (Vector3.Angle(GM.CurrentPlayerBody.Head.forward, ((Component)this).transform.forward) < 45f)
					{
						Ray val7 = default(Ray);
						((Ray)(ref val7))..ctor(_leftEye, val4);
						RaycastHit val8 = default(RaycastHit);
						if (LensCollider.Raycast(val7, ref val8, num2))
						{
							((Component)ReticleMeshRenderer).gameObject.SetActive(true);
							flag = true;
						}
					}
				}
				if (!flag)
				{
					((Component)ReticleMeshRenderer).gameObject.SetActive(false);
				}
			}
			else
			{
				Debug.LogWarning((object)"No usable colliders for reticle occlusion found! If you are a modmaker, please add colliders or a lens collider, or disable occlusion culling with the checkbox!\n Disabling Occlusion culling now!");
				DisableOcclusionCulling = true;
			}
		}

		public void Zero()
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: 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_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: 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_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			if (IsIntegrated || ((Object)(object)Attachment != (Object)null && (Object)(object)Attachment.curMount != (Object)null && (Object)(object)Attachment.curMount.Parent != (Object)null && Attachment.curMount.Parent is FVRFireArm))
			{
				if (IsIntegrated && (Object)(object)AttachableFirearm == (Object)null)
				{
					Debug.LogError((object)"ScopeShaderZoom: FireArm not set on integrated Scope! Can't zero sight!");
				}
				FireArmRoundType roundType = AttachableFirearm.RoundType;
				float num = ZeroDistances[CurrentZeroDistanceIndex];
				float num2 = 0f;
				if (AM.SRoundDisplayDataDic.ContainsKey(roundType))
				{
					num2 = AM.SRoundDisplayDataDic[roundType].BulletDropCurve.Evaluate(num * 0.001f);
				}
				Vector3 val = AttachableFirearm.MuzzlePos.position + AttachableFirearm.GetMuzzle().forward * num + AttachableFirearm.GetMuzzle().up * num2;
				Vector3 val2 = Vector3.ProjectOnPlane(val - ((Component)this).transform.forward, ((Component)this).transform.right);
				Vector3 val3 = Vector3.ProjectOnPlane(val, ((Component)this).transform.right) + Vector3.Dot(((Component)this).transform.position, ((Component)this).transform.right) * ((Component)this).transform.right;
				TiltingOpticPart.LookAt(val3, ((Component)this).transform.up);
				TiltingOpticPart.localEulerAngles = new Vector3(TiltingOpticPart.localEulerAngles.x, TiltingOpticPart.localEulerAngles.y, 0f);
			}
			else
			{
				TiltingOpticPart.localRotation = Quaternion.identity;
			}
		}
	}
	public class KeepOnLayer : MonoBehaviour
	{
		public FVRPhysicalObject Object;

		public string LayerName;

		public Collider[] Colliders;

		private static Dictionary<FVRPhysicalObject, KeepOnLayer> _keepOnLayers = new Dictionary<FVRPhysicalObject, KeepOnLayer>();
	}
	public class LightSimpleAngleSwitch : FVRInteractiveObject
	{
		public Light Light;

		public float[] LightAngleVals;

		private int _lightIndexVal = 0;
	}
	public class LightSimpleBrightnessSwitch : FVRInteractiveObject
	{
		public Light Light;

		public float[] LightIntensityVals;

		public GameObject LightEffectGameObject;

		private int _lightIndexVal = 0;
	}
	public class MagazineQueueFeed : MonoBehaviour
	{
		public FVRFireArmMagazine Mag;

		public bool isDebug = false;

		private static Dictionary<FVRFireArmMagazine, MagazineQueueFeed> _magQueues = new Dictionary<FVRFireArmMagazine, MagazineQueueFeed>();
	}
	public class ObjectMountOnGround : FVRPhysicalObject
	{
		public Transform PlacementRayPoint;

		public LayerMask PlacementLayerMask;

		public float MaxPlacementAngle = 75f;

		public float DistToGroundFromOrigin;

		[NonSerialized]
		public RaycastHit m_hit;

		private bool m_OnGround;
	}
	public class PlayRandomSoundOnAwake : MonoBehaviour
	{
		public AudioClip[] AudioClips;

		public AudioSource AudioSource;
	}
	public class ReactiveTarget : ReactiveSteelTarget
	{
		public Vector2 BulletHoleSizeRange2 = new Vector2(0.075f, 0.12f);

		public Vector2 DamageScaleRange = new Vector2(400f, 2000f);
	}
	public class RotateUp : MonoBehaviour
	{
	}
	public class SimpleSwitch : FVRInteractiveObject
	{
		public bool OnOff = true;

		public GameObject[] ItemsToToggle;

		public AudioEvent AudEvent_OnClip;

		public AudioEvent AudEvent_OffClip;

		private bool _isItemToggled = false;

		public void Start()
		{
			((FVRInteractiveObject)this).Start();
			if (ItemsToToggle[0].activeSelf)
			{
				_isItemToggled = true;
			}
			else
			{
				_isItemToggled = false;
			}
		}

		public override void SimpleInteraction(FVRViveHand hand)
		{
			//IL_00af: 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)
			((FVRInteractiveObject)this).SimpleInteraction(hand);
			if (!OnOff)
			{
				return;
			}
			if (_isItemToggled)
			{
				GameObject[] itemsToToggle = ItemsToToggle;
				foreach (GameObject val in itemsToToggle)
				{
					val.SetActive(false);
				}
				SM.PlayCoreSound((FVRPooledAudioType)10, AudEvent_OffClip, ((Component)this).transform.position);
				_isItemToggled = false;
			}
			else
			{
				GameObject[] itemsToToggle2 = ItemsToToggle;
				foreach (GameObject val2 in itemsToToggle2)
				{
					val2.SetActive(true);
				}
				SM.PlayCoreSound((FVRPooledAudioType)10, AudEvent_OnClip, ((Component)this).transform.position);
				_isItemToggled = true;
			}
		}
	}
	public class SpringLoadedStockButton : FVRInteractiveObject
	{
		[Header("This only works for z axis movement")]
		public MovableObjectPart Stock;

		public float CollapseVal;

		public float ExtendedVal;

		public float TimeToExtend = 0.5f;

		public AudioEvent SwitchSound;

		public bool SpringsOpenWhenNotClosed = false;
	}
	public class SpringLoadedStockFirearmControl : MonoBehaviour
	{
		public FVRFireArm Firearm;

		public SpringLoadedStockButton StockButton;

		private bool IsDian;
	}
	public class SpringLoadedStockForOldProjs : MonoBehaviour
	{
		public FVRInteractiveObject InteractiveObject;

		[Header("This only works for z axis movement")]
		public GameObject Stock;

		public float CollapseVal;

		public float ExtendedVal;

		public float TimeToExtend = 0.5f;

		public AudioEvent SwitchSound;

		private static Dictionary<FVRInteractiveObject, SpringLoadedStockForOldProjs> _existingSpringStocks = new Dictionary<FVRInteractiveObject, SpringLoadedStockForOldProjs>();
	}
	public class StrobeController : MonoBehaviour
	{
		public GameObject LightToStrobe;

		public static float StrobeFlashTime = 0.02f;

		public LayerMask LM_TargetMask;

		public LayerMask LM_Blockers;

		public float BlindingFOV = 3f;

		public float BlindingRange = 11f;

		public float BlindingAtOneMeter;

		private Collider[] _targetArray = (Collider[])(object)new Collider[32];

		private float _overlapCapsulRadius;
	}
	[RequireComponent(typeof(Collider))]
	public class StunVolume : MonoBehaviour
	{
		public float StunValue;

		public float StunTick;

		public AudioEvent StunSound;

		private Dictionary<Collider, Coroutine> coroutines = new Dictionary<Collider, Coroutine>();
	}
	public class TransferRBtoParentOnAttach : MonoBehaviour
	{
		public FVRFireArmAttachment Attachment;

		public Joint Joint;

		public GameObject ProxyWaggleBit;

		private FVRPhysicalObject _attachedObj;

		private GameObject _waggleTransform;
	}
	public class TubeFedShotgunInteractableSelector : FVRInteractiveObject
	{
		public TubeFedShotgun Weapon;
	}
}