Decompiled source of M7A3 CS Gas v1.1.2

M7A3_CS_Gas.dll

Decompiled 11 hours ago
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 UnityEngine;

[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 JerrySmoke
{
	public class DamageSmoke : MonoBehaviour, IFVRDamageable
	{
		public PhysicalSmoke PS;

		public void Damage(Damage dam)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Invalid comparison between Unknown and I4
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			//IL_009c: 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)
			if ((Object)(object)PS != (Object)null && dam != null && PS.canBeDamaged && ((int)dam.Class == 1 || (int)dam.Class == 2))
			{
				PS.iskilled = true;
				if (PS.cdkill == -114f)
				{
					PS.cdkill = 1f;
				}
				if ((Object)(object)PS.smokep != (Object)null)
				{
					MainModule main = PS.smokep.main;
					((MainModule)(ref main)).simulationSpeed = 2f;
					PS.smokep.Stop();
				}
			}
		}

		public void Update()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)PS != (Object)null)
			{
				((Component)this).gameObject.transform.position = ((Component)PS).gameObject.transform.position;
			}
			if ((Object)(object)PS == (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
}
namespace JerryM7A3
{
	public class DynamicSmoke : MonoBehaviour
	{
		public ParticleSystem part;

		public float ss;

		public MainModule main;

		private void Start()
		{
			ss = 5f;
		}

		private void Update()
		{
			//IL_0028: 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)
			ss = Mathf.Lerp(ss, 0.25f, Time.deltaTime * 25f);
			MainModule val = part.main;
			((MainModule)(ref val)).simulationSpeed = ss;
		}
	}
}
namespace JerrySmoke
{
	public class LerpFollow : MonoBehaviour
	{
		public List<Vector3> points = new List<Vector3>();

		public float speed = 10f;

		public bool loop = false;

		private int index = 0;

		private float t = 0f;

		public bool arrived;

		public BallisticProjectile targ;

		public float cd = 5f;

		[Header("触发区扫掠(防止高速穿透)")]
		[Tooltip("0 = 射线检测;>0 = 球形扫掠(推荐 0.02~0.2)")]
		public float sweepRadius = 0.25f;

		[Tooltip("每次 SphereCast 的最大长度,越小越可靠但越耗性能")]
		public float maxSweepStep = 1f;

		private static readonly int TriggerLayerMask = 1024;

		private Collider selfCollider;

		private readonly HashSet<Collider> activeTriggers = new HashSet<Collider>();

		private readonly HashSet<Collider> frameHits = new HashSet<Collider>();

		public void Start()
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			selfCollider = ((Component)this).GetComponent<Collider>();
			if ((Object)(object)selfCollider == (Object)null)
			{
				selfCollider = ((Component)this).GetComponentInChildren<Collider>();
			}
			if ((Object)(object)selfCollider == (Object)null)
			{
				SphereCollider val = ((Component)this).gameObject.AddComponent<SphereCollider>();
				((Collider)val).isTrigger = true;
				val.radius = Mathf.Max(sweepRadius, 0.01f);
				selfCollider = (Collider)(object)val;
			}
			if (points != null && points.Count > 0)
			{
				((Component)this).transform.position = points[0];
			}
		}

		private void Update()
		{
			//IL_003e: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: 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_0194: 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_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: 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_025c: 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_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: 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_0210: 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_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: 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_0229: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)targ != (Object)null && points.Count <= 500)
			{
				points.Add(((Component)targ).gameObject.transform.position);
			}
			if ((Object)(object)targ == (Object)null || arrived)
			{
				cd -= Time.deltaTime;
				if (cd <= 0f)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
			}
			if (points == null || points.Count < 2)
			{
				return;
			}
			frameHits.Clear();
			Vector3 val = ((Component)this).transform.position;
			CollectOverlapAt(val);
			float num = speed * Time.deltaTime;
			while (num > 0f)
			{
				if (index >= points.Count - 1)
				{
					if (loop)
					{
						index = 0;
						t = 0f;
						((Component)this).transform.position = points[0];
						val = points[0];
						CollectOverlapAt(val);
						continue;
					}
					arrived = true;
					((Component)this).transform.position = points[points.Count - 1];
					break;
				}
				Vector3 val2 = points[index];
				Vector3 val3 = points[index + 1];
				float num2 = Vector3.Distance(val2, val3);
				if (num2 < 1E-06f)
				{
					index++;
					t = 0f;
					continue;
				}
				float num3 = (1f - t) * num2;
				if (num < num3)
				{
					t += num / num2;
					Vector3 val4 = Vector3.Lerp(val2, val3, t);
					SweepSegment(val, val4);
					val = val4;
					((Component)this).transform.position = val4;
					break;
				}
				num -= num3;
				index++;
				t = 0f;
				SweepSegment(val, val3);
				val = val3;
				((Component)this).transform.position = val3;
			}
			CollectOverlapAt(val);
			DispatchTriggers();
		}

		private void SweepSegment(Vector3 from, Vector3 to)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = to - from;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude < 1E-05f)
			{
				return;
			}
			Vector3 val2 = val / magnitude;
			int num = Mathf.Max(1, Mathf.CeilToInt(magnitude / Mathf.Max(maxSweepStep, 0.01f)));
			float num2 = magnitude / (float)num;
			Vector3 val3 = from;
			for (int i = 0; i < num; i++)
			{
				RaycastHit[] array = ((!(sweepRadius > 0f)) ? Physics.RaycastAll(val3, val2, num2, TriggerLayerMask, (QueryTriggerInteraction)2) : Physics.SphereCastAll(val3, sweepRadius, val2, num2, TriggerLayerMask, (QueryTriggerInteraction)2));
				for (int j = 0; j < array.Length; j++)
				{
					Collider collider = ((RaycastHit)(ref array[j])).collider;
					if ((Object)(object)collider != (Object)null && collider.isTrigger && (Object)(object)collider != (Object)(object)selfCollider)
					{
						frameHits.Add(collider);
					}
				}
				val3 += val2 * num2;
			}
		}

		private void CollectOverlapAt(Vector3 pos)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(sweepRadius, 0.01f);
			Collider[] array = Physics.OverlapSphere(pos, num, TriggerLayerMask, (QueryTriggerInteraction)2);
			foreach (Collider val in array)
			{
				if ((Object)(object)val != (Object)null && val.isTrigger && (Object)(object)val != (Object)(object)selfCollider)
				{
					frameHits.Add(val);
				}
			}
		}

		private void DispatchTriggers()
		{
			foreach (Collider frameHit in frameHits)
			{
				if (!((Object)(object)frameHit == (Object)null) && !activeTriggers.Contains(frameHit))
				{
					((Component)frameHit).SendMessage("OnTriggerEnter", (object)selfCollider, (SendMessageOptions)1);
				}
			}
			foreach (Collider activeTrigger in activeTriggers)
			{
				if (!((Object)(object)activeTrigger == (Object)null) && !frameHits.Contains(activeTrigger))
				{
					((Component)activeTrigger).SendMessage("OnTriggerExit", (object)selfCollider, (SendMessageOptions)1);
				}
			}
			activeTriggers.Clear();
			foreach (Collider frameHit2 in frameHits)
			{
				if ((Object)(object)frameHit2 != (Object)null)
				{
					activeTriggers.Add(frameHit2);
				}
			}
		}
	}
	public class PhysicalSmoke : MonoBehaviour
	{
		public GameObject LerpFollowObj;

		public bool isMain;

		public const float hitDetectionDistance = 0.15f;

		public bool canBeDamaged;

		[Header("引用")]
		public GameObject SubSmokeObj;

		public GameObject particle;

		public Rigidbody rig;

		public KillAfter ka1;

		public KillAfter ka2;

		public ParticleSystem smokep;

		public float cdkill = -114f;

		[Header("物理")]
		public bool isphys = true;

		public bool keepStatic = true;

		[Header("网格扩散")]
		public float cellSize = 0.5f;

		public float gridSpacing = 0.5f;

		public float cd = 0.12f;

		public int maxSpawnPerTick = 4;

		public float spawnChance = 0.75f;

		public LayerMask lm;

		public LayerMask smokeLayer;

		[Header("扩散层级")]
		public int generation = 0;

		public int maxGeneration = 12;

		public static int totalCount = 0;

		public static int maxTotalCount = 1000;

		public int max;

		[Header("生命周期")]
		public float lifeTime = 45f;

		private float lifeTimer;

		public float childLifeMin = 0.75f;

		public float childLifeMax = 1f;

		[Header("最大范围")]
		public float maxDistanceFromOrigin = 8f;

		public GameObject Origin;

		[Header("调试")]
		public bool debugLog = false;

		private int spawnedThisTick = 0;

		public bool iskilled;

		public bool isnormaldie;

		public float baseLifeTime = 0f;

		public bool hasExpanded;

		private int failedExpandAttempts = 0;

		private const int MAX_FAILED_ATTEMPTS = 8;

		private RaycastHit[] _buf = (RaycastHit[])(object)new RaycastHit[500];

		[RuntimeInitializeOnLoadMethod(/*Could not decode attribute arguments.*/)]
		private static void ResetCounters()
		{
			totalCount = 0;
		}

		private void OnEnable()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			if (isMain)
			{
				OpenScripts2_BasePlugin.ProjectileFiredEvent += new ProjectileFired(OnProjectileFired);
			}
		}

		public void OnTriggerStay(Collider other)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)((Component)other).gameObject.GetComponent<LerpFollow>()) && canBeDamaged)
			{
				iskilled = true;
				if (cdkill == -114f)
				{
					cdkill = 1f;
				}
				if ((Object)(object)smokep != (Object)null)
				{
					MainModule main = smokep.main;
					((MainModule)(ref main)).simulationSpeed = 2f;
					smokep.Stop();
				}
			}
		}

		public void OnTriggerEnter(Collider other)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)((Component)other).gameObject.GetComponent<LerpFollow>()) && canBeDamaged)
			{
				iskilled = true;
				if (cdkill == -114f)
				{
					cdkill = 1f;
				}
				if ((Object)(object)smokep != (Object)null)
				{
					MainModule main = smokep.main;
					((MainModule)(ref main)).simulationSpeed = 2f;
					smokep.Stop();
				}
			}
		}

		private void OnProjectileFired(FVRFireArm fireArm, ref BallisticProjectile projectile)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			if (!isMain)
			{
				return;
			}
			GameObject val = Object.Instantiate<GameObject>(LerpFollowObj, ((Component)fireArm.MuzzlePos).transform.position, ((Component)fireArm.MuzzlePos).transform.rotation);
			if ((Object)(object)val.GetComponent<LerpFollow>() == (Object)null)
			{
				val.AddComponent<LerpFollow>();
			}
			if ((Object)(object)val.GetComponent<LerpFollow>() != (Object)null)
			{
				val.GetComponent<LerpFollow>().targ = projectile;
			}
			val.gameObject.layer = 10;
			if ((Object)(object)val.gameObject.GetComponent<Rigidbody>() == (Object)null)
			{
				val.gameObject.AddComponent<Rigidbody>();
			}
			if ((Object)(object)val.gameObject.GetComponent<Rigidbody>() != (Object)null)
			{
				val.gameObject.GetComponent<Rigidbody>().useGravity = false;
				val.gameObject.GetComponent<Rigidbody>().collisionDetectionMode = (CollisionDetectionMode)2;
				val.gameObject.GetComponent<Rigidbody>().isKinematic = true;
			}
			if ((Object)(object)val.gameObject.GetComponent<SphereCollider>() == (Object)null)
			{
				val.gameObject.AddComponent<SphereCollider>();
			}
			if ((Object)(object)val.gameObject.GetComponent<SphereCollider>() != (Object)null)
			{
				val.gameObject.GetComponent<SphereCollider>().radius = 0.25f;
				val.gameObject.GetComponent<SphereCollider>().center = new Vector3(0f, 0f, 0f);
				if (!((Collider)val.gameObject.GetComponent<SphereCollider>()).isTrigger)
				{
					((Collider)val.gameObject.GetComponent<SphereCollider>()).isTrigger = true;
				}
			}
		}

		private void Start()
		{
			maxTotalCount = max;
			totalCount++;
			if (gridSpacing < cellSize)
			{
				gridSpacing = cellSize;
			}
			if ((Object)(object)ka1 != (Object)null)
			{
				((Behaviour)ka1).enabled = false;
			}
			if ((Object)(object)ka2 != (Object)null)
			{
				((Behaviour)ka2).enabled = false;
			}
			if (baseLifeTime <= 0f)
			{
				baseLifeTime = lifeTime;
			}
			lifeTimer = lifeTime;
			if ((Object)(object)Origin == (Object)null)
			{
				Origin = ((Component)this).gameObject;
			}
			if ((Object)(object)rig != (Object)null)
			{
				if (keepStatic)
				{
					rig.useGravity = false;
					rig.isKinematic = true;
					rig.constraints = (RigidbodyConstraints)126;
				}
				else
				{
					rig.useGravity = isphys;
					rig.isKinematic = !isphys;
					rig.constraints = (RigidbodyConstraints)112;
				}
			}
			if (debugLog && generation == 0)
			{
				Debug.Log((object)"[Smoke] Start gen");
			}
		}

		private void OnDestroy()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			if (isMain)
			{
				OpenScripts2_BasePlugin.ProjectileFiredEvent -= new ProjectileFired(OnProjectileFired);
			}
			totalCount = Mathf.Max(0, totalCount - 1);
		}

		private void Update()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (iskilled && (Object)(object)smokep != (Object)null && iskilled)
			{
				MainModule main = smokep.main;
				((MainModule)(ref main)).simulationSpeed = 2f;
				if (cdkill == -114f)
				{
					cdkill = 1f;
				}
			}
			if (iskilled || isnormaldie)
			{
				smokep.Stop();
				cdkill -= Time.deltaTime;
				if (cdkill <= 0f)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
			}
		}

		private void FixedUpdate()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: 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_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.eulerAngles = Vector3.zero;
			lifeTimer -= Time.deltaTime;
			if (lifeTimer <= 0f)
			{
				isnormaldie = true;
				if (cdkill == -114f)
				{
					cdkill = 10f;
				}
				return;
			}
			if ((Object)(object)Origin == (Object)null)
			{
				Origin = ((Component)this).gameObject;
			}
			if (Vector3.Distance(((Component)this).transform.position, Origin.transform.position) > maxDistanceFromOrigin)
			{
				isnormaldie = true;
				if (cdkill == -114f)
				{
					cdkill = 10f;
				}
			}
			else
			{
				if (hasExpanded || generation >= maxGeneration || totalCount >= maxTotalCount)
				{
					return;
				}
				cd -= Time.deltaTime;
				if (cd > 0f)
				{
					return;
				}
				spawnedThisTick = 0;
				TrySpawn(Vector3.up);
				TrySpawn(Vector3.down);
				TrySpawn(Vector3.left);
				TrySpawn(Vector3.right);
				TrySpawn(Vector3.forward);
				TrySpawn(Vector3.back);
				if (spawnedThisTick > 0)
				{
					hasExpanded = true;
					failedExpandAttempts = 0;
					return;
				}
				failedExpandAttempts++;
				if (failedExpandAttempts >= 8)
				{
					hasExpanded = true;
				}
				else
				{
					cd = Random.Range(0.5f, 1f);
				}
			}
		}

		private void TrySpawn(Vector3 dir)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)SubSmokeObj == (Object)null || totalCount >= maxTotalCount || spawnedThisTick >= maxSpawnPerTick || Random.value > spawnChance)
			{
				return;
			}
			((Vector3)(ref dir)).Normalize();
			Vector3 val = ((Component)this).transform.position + dir * gridSpacing;
			if (((LayerMask)(ref lm)).value != 0 && Physics.Raycast(((Component)this).transform.position, dir, gridSpacing * 0.95f, LayerMask.op_Implicit(lm), (QueryTriggerInteraction)1))
			{
				if (debugLog)
				{
					Debug.Log((object)"[Smoke] blocked by obstacle");
				}
				return;
			}
			if (HasOtherSmokeAt(val))
			{
				if (debugLog)
				{
					Debug.Log((object)"[Smoke] blocked by smoke");
				}
				return;
			}
			GameObject val2 = Object.Instantiate<GameObject>(SubSmokeObj, val, Quaternion.identity);
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			PhysicalSmoke component = val2.GetComponent<PhysicalSmoke>();
			if ((Object)(object)component == (Object)null)
			{
				Object.Destroy((Object)(object)val2);
				return;
			}
			component.Origin = Origin;
			component.generation = generation + 1;
			component.cd = Random.Range(0.25f, 0.5f);
			component.lifeTime = Random.Range(baseLifeTime * childLifeMin, baseLifeTime * childLifeMax);
			component.lifeTimer = component.lifeTime;
			component.baseLifeTime = baseLifeTime;
			spawnedThisTick++;
			if (debugLog)
			{
				Debug.Log((object)"[Smoke] spawn gen");
			}
		}

		private bool HasOtherSmokeAt(Vector3 pos)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			if (((LayerMask)(ref smokeLayer)).value == 0)
			{
				return false;
			}
			float num = gridSpacing * 0.9f;
			Collider[] array = Physics.OverlapSphere(pos, num, LayerMask.op_Implicit(smokeLayer), (QueryTriggerInteraction)2);
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				PhysicalSmoke componentInParent = ((Component)val).GetComponentInParent<PhysicalSmoke>();
				if (!((Object)(object)componentInParent == (Object)null) && !((Object)(object)componentInParent == (Object)(object)this))
				{
					float num2 = Vector3.Distance(((Component)componentInParent).transform.position, pos);
					if (num2 < gridSpacing * 0.5f)
					{
						return true;
					}
				}
			}
			return false;
		}
	}
}
namespace JerrySmokeer
{
	public class PhysicalSmokePlugin : MonoBehaviour
	{
		public static event ProjectileFired ProjectileFiredEvent;

		public static void ProjectileFired(FVRFireArm fireArm, ref BallisticProjectile projectile)
		{
			PhysicalSmokePlugin.ProjectileFiredEvent?.Invoke(fireArm, ref projectile);
		}
	}
	public delegate void ProjectileFired(FVRFireArm fireArm, ref BallisticProjectile projectile);
	public class SmokeParticleManager : MonoBehaviour
	{
		public Material Mat;

		public static ParticleSystem UserProvidedPS;

		private static SmokeParticleManager _instance;

		private ParticleSystem psNormal;

		private EmitParams epNormal;

		private ParticleSystem psFast;

		private EmitParams epFast;

		private float cd = 47.5f;

		public static SmokeParticleManager Instance
		{
			get
			{
				if ((Object)(object)_instance == (Object)null)
				{
					CreateNew();
				}
				return _instance;
			}
		}

		public static SmokeParticleManager EnsureExists()
		{
			return Instance;
		}

		private static void CreateNew()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			GameObject val = new GameObject("[SmokeParticleManager]");
			_instance = val.AddComponent<SmokeParticleManager>();
			_instance.Init();
		}

		private void Awake()
		{
			if ((Object)(object)_instance != (Object)null && (Object)(object)_instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			_instance = this;
			if ((Object)(object)psNormal == (Object)null)
			{
				Init();
			}
		}

		private void Init()
		{
			psNormal = CreateChildPS("Smoke_Normal", 0.25f);
			psFast = CreateChildPS("Smoke_Fast", 2.5f);
		}

		private ParticleSystem CreateChildPS(string childName, float simulationSpeed)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			GameObject val = new GameObject(childName);
			val.transform.SetParent(((Component)this).transform, false);
			ParticleSystem val2 = val.AddComponent<ParticleSystem>();
			ConfigureOnePS(val2, simulationSpeed);
			return val2;
		}

		private void ConfigureOnePS(ParticleSystem system, float simulationSpeed)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			//IL_00bc: 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_00cb: 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_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: 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_015c: Expected O, but got Unknown
			//IL_019b: 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_01ab: 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_01d4: Expected O, but got Unknown
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			MainModule main = system.main;
			((MainModule)(ref main)).loop = false;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).simulationSpeed = simulationSpeed;
			((MainModule)(ref main)).maxParticles = 10000;
			((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(0.5f);
			((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(1.25f);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Color.white);
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0f);
			EmissionModule emission = system.emission;
			((EmissionModule)(ref emission)).enabled = false;
			ShapeModule shape = system.shape;
			((ShapeModule)(ref shape)).enabled = false;
			ColorOverLifetimeModule colorOverLifetime = system.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val = new Gradient();
			val.SetKeys((GradientColorKey[])(object)new GradientColorKey[1]
			{
				new GradientColorKey(Color.gray, 0.4f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(0f, 0f),
				new GradientAlphaKey(255f, 0.4f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val);
			SizeOverLifetimeModule sizeOverLifetime = system.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = false;
			AnimationCurve val2 = new AnimationCurve();
			val2.AddKey(0f, 0.6f);
			val2.AddKey(0.5f, 1f);
			val2.AddKey(1f, 1.4f);
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, val2);
			TextureSheetAnimationModule textureSheetAnimation = system.textureSheetAnimation;
			((TextureSheetAnimationModule)(ref textureSheetAnimation)).enabled = true;
			((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesX = 8;
			((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesY = 8;
			((TextureSheetAnimationModule)(ref textureSheetAnimation)).animation = (ParticleSystemAnimationType)0;
			AnimationCurve val3 = new AnimationCurve();
			val3.AddKey(0f, 0f);
			val3.AddKey(1f, 1f);
			((TextureSheetAnimationModule)(ref textureSheetAnimation)).frameOverTime = new MinMaxCurve(1f, val3);
			((TextureSheetAnimationModule)(ref textureSheetAnimation)).startFrame = new MinMaxCurve(0f, 1f);
			ParticleSystemRenderer component = ((Component)system).GetComponent<ParticleSystemRenderer>();
			if ((Object)(object)component != (Object)null)
			{
				((Renderer)component).material = Mat;
			}
			system.Play();
		}

		public void EmitAt(Vector3 pos, float size, float lifetime, float speed)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			EmitAt(pos, size, lifetime, speed, urgent: false);
		}

		public void EmitAt(Vector3 pos, float size, float lifetime, float speed, bool urgent)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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)
			ParticleSystem val = ((!urgent) ? psNormal : psFast);
			if (!((Object)(object)val == (Object)null))
			{
				EmitParams val2 = ((!urgent) ? epNormal : epFast);
				((EmitParams)(ref val2)).position = pos;
				((EmitParams)(ref val2)).applyShapeToPosition = false;
				if (urgent)
				{
					((EmitParams)(ref val2)).startSize = size * Random.Range(1.1f, 1.4f);
					((EmitParams)(ref val2)).startLifetime = lifetime * Random.Range(0.5f, 0.75f);
				}
				else
				{
					((EmitParams)(ref val2)).startSize = size * Random.Range(0.85f, 1.15f);
					((EmitParams)(ref val2)).startLifetime = lifetime * Random.Range(0.85f, 1.15f);
				}
				Vector3 velocity = Random.insideUnitSphere * 0.05f;
				velocity.y += 0.03f;
				((EmitParams)(ref val2)).velocity = velocity;
				((EmitParams)(ref val2)).rotation = Random.Range(0f, 360f);
				((EmitParams)(ref val2)).angularVelocity = Random.Range(-15f, 15f);
				val.Emit(val2, 1);
			}
		}

		public void EmitBurst(Vector3 pos, int count, float size, float lifetime)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < count; i++)
			{
				Vector3 val = Random.insideUnitSphere * (size * 0.4f);
				EmitAt(pos + val, size, lifetime, 0.08f, urgent: true);
			}
		}

		public void FixedUpdate()
		{
			if ((Object)(object)psNormal != (Object)null && (Object)(object)((Component)psNormal).gameObject.GetComponent<ParticleSystemRenderer>() != (Object)null)
			{
				((Renderer)((Component)psNormal).gameObject.GetComponent<ParticleSystemRenderer>()).material = Mat;
				((Renderer)((Component)psNormal).gameObject.GetComponent<ParticleSystemRenderer>()).sharedMaterial = Mat;
			}
			if ((Object)(object)psFast != (Object)null && (Object)(object)((Component)psFast).gameObject.GetComponent<ParticleSystemRenderer>() != (Object)null)
			{
				((Renderer)((Component)psFast).gameObject.GetComponent<ParticleSystemRenderer>()).material = Mat;
				((Renderer)((Component)psFast).gameObject.GetComponent<ParticleSystemRenderer>()).sharedMaterial = Mat;
			}
			cd -= Time.deltaTime;
			if (cd <= 0f)
			{
				if ((Object)(object)psNormal != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)psNormal).gameObject);
				}
				if ((Object)(object)psFast != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)psFast).gameObject);
				}
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
}
namespace JerryAr.M7A3_CS_Gas
{
	[BepInPlugin("JerryAr.M7A3_CS_Gas", "M7A3_CS_Gas", "1.1.2")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	[BepInDependency("h3vr.otherloader", "1.3.0")]
	public class M7A3_CS_GasPlugin : 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(), "JerryAr.M7A3_CS_Gas");
			OtherLoader.RegisterDirectLoad(BasePath, "JerryAr.M7A3_CS_Gas", "", "", "m7a3cs", "");
		}
	}
}
public class SnapToPoint : MonoBehaviour
{
	public GameObject Obj;

	public GameObject Targ;

	private void Start()
	{
	}

	private void Update()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		Obj.transform.position = Targ.transform.position;
		Obj.transform.rotation = Targ.transform.rotation;
	}
}