Decompiled source of LethalSmokes v1.0.0

BepInEx/plugins/LethalSmokes/LethalSmokes.dll

Decompiled 21 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using LethalNetworkAPI;
using LethalNetworkAPI.Utils;
using LethalSmokes.Patches;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("LethalSmokes.TestHarness")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("LethalSmokes")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalSmokes")]
[assembly: AssemblyTitle("LethalSmokes")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalSmokes
{
	public class CigaretteItem : GrabbableObject
	{
		private void Awake()
		{
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)0;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (!buttonDown || !((NetworkBehaviour)this).IsOwner || (Object)(object)base.playerHeldBy == (Object)null || base.deactivated)
			{
				return;
			}
			int num = (int)base.playerHeldBy.playerClientId;
			if (SmokingState.IsSmokingOrPending(num))
			{
				if ((Object)(object)HUDManager.Instance != (Object)null)
				{
					HUDManager.Instance.DisplayTip("Cigarette", "You are already smoking.", false, false, "LC_Tip1");
				}
			}
			else
			{
				LethalSmokesPlugin.Log.LogInfo((object)$"Lighting cigarette (player {num}, value {base.scrapValue})");
				SmokingState.MarkLocalLightPending();
				SmokingNetwork.RequestLight();
				base.playerHeldBy.DespawnHeldObject();
			}
		}
	}
	internal static class CigarettePrefab
	{
		private const int PropsLayer = 6;

		private const int ScanNodeLayer = 22;

		private const string PhysicsPropTag = "PhysicsProp";

		public static Item Item { get; private set; }

		public static GameObject Prefab { get; private set; }

		public static void Register()
		{
			Item = BuildItem();
			Prefab = BuildPrefab(Item);
			Item.spawnPrefab = Prefab;
			Dictionary<LevelTypes, int> dictionary = SpawnRarities();
			Items.RegisterScrap(Item, dictionary, (Dictionary<string, int>)null);
			LethalSmokesPlugin.Log.LogInfo((object)$"Registered scrap '{Item.itemName}' (rarity low/mid/high/modded {SmokesConfig.RarityLowTier.Value}/{SmokesConfig.RarityMidTier.Value}/{SmokesConfig.RarityHighTier.Value}/{SmokesConfig.RarityModded.Value}, raw value {Item.minValue}-{Item.maxValue})");
		}

		internal static Dictionary<LevelTypes, int> SpawnRarities()
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			(int, LevelTypes[])[] array = new(int, LevelTypes[])[4];
			int value = SmokesConfig.RarityLowTier.Value;
			LevelTypes[] array2 = new LevelTypes[3];
			RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			array[0] = (value, (LevelTypes[])(object)array2);
			int value2 = SmokesConfig.RarityMidTier.Value;
			LevelTypes[] array3 = new LevelTypes[3];
			RuntimeHelpers.InitializeArray(array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			array[1] = (value2, (LevelTypes[])(object)array3);
			int value3 = SmokesConfig.RarityHighTier.Value;
			LevelTypes[] array4 = new LevelTypes[5];
			RuntimeHelpers.InitializeArray(array4, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			array[2] = (value3, (LevelTypes[])(object)array4);
			array[3] = (SmokesConfig.RarityModded.Value, (LevelTypes[])(object)new LevelTypes[1] { (LevelTypes)1024 });
			Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>();
			(int, LevelTypes[])[] array5 = array;
			for (int i = 0; i < array5.Length; i++)
			{
				var (num, array6) = array5[i];
				if (num > 0)
				{
					LevelTypes[] array7 = array6;
					foreach (LevelTypes key in array7)
					{
						dictionary[key] = num;
					}
				}
			}
			return dictionary;
		}

		public static IEnumerator SpawnInShip(StartOfRound round, int count, List<CigaretteItem> spawned = null)
		{
			RoundManager roundManager = RoundManager.Instance;
			float num = (((Object)(object)roundManager != (Object)null) ? roundManager.scrapValueMultiplier : 1f);
			LethalSmokesPlugin.Log.LogInfo((object)$"Spawning {count} cigarette(s) in the ship (scrap value multiplier {num})");
			Random random = new Random();
			NetworkObjectReference[] references = (NetworkObjectReference[])(object)new NetworkObjectReference[count];
			int[] values = new int[count];
			Vector3 position = round.playerSpawnPositions[0].position;
			for (int i = 0; i < count; i++)
			{
				Vector3 val = position + new Vector3(Random.Range(-0.6f, 0.6f), 0.5f, Random.Range(0.8f, 1.4f));
				CigaretteItem component = Object.Instantiate<GameObject>(Item.spawnPrefab, val, Quaternion.Euler(Item.restingRotation), round.elevatorTransform).GetComponent<CigaretteItem>();
				((GrabbableObject)component).fallTime = 0f;
				((GrabbableObject)component).isInElevator = true;
				((GrabbableObject)component).isInShipRoom = true;
				values[i] = (int)((float)random.Next(Item.minValue, Item.maxValue) * num);
				((GrabbableObject)component).SetScrapValue(values[i]);
				((NetworkBehaviour)component).NetworkObject.Spawn(false);
				references[i] = NetworkObjectReference.op_Implicit(((NetworkBehaviour)component).NetworkObject);
				spawned?.Add(component);
				LethalSmokesPlugin.Log.LogInfo((object)$"Spawned cigarette worth {values[i]} in the ship");
			}
			yield return (object)new WaitForSeconds(1f);
			if ((Object)(object)roundManager != (Object)null)
			{
				roundManager.SyncScrapValuesClientRpc(references, values);
			}
		}

		private static Item BuildItem()
		{
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: 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_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			Item val = ScriptableObject.CreateInstance<Item>();
			((Object)val).name = "LethalSmokesCigarette";
			((Object)val).hideFlags = (HideFlags)32;
			val.itemName = "Cigarette";
			val.isScrap = true;
			val.minValue = SmokesConfig.MinValue.Value;
			val.maxValue = Mathf.Max(SmokesConfig.MinValue.Value + 1, SmokesConfig.MaxValue.Value);
			val.weight = 1.01f;
			val.twoHanded = false;
			val.twoHandedAnimation = false;
			val.isConductiveMetal = false;
			val.canBeGrabbedBeforeGameStart = true;
			val.itemSpawnsOnGround = true;
			val.itemIcon = CigaretteVisuals.Icon;
			val.requiresBattery = false;
			val.automaticallySetUsingPower = false;
			val.holdButtonUse = false;
			val.syncUseFunction = false;
			val.toolTips = new string[1] { "Light up : [LMB]" };
			val.meshVariants = (Mesh[])(object)new Mesh[0];
			val.materialVariants = (Material[])(object)new Material[0];
			val.clinkAudios = (AudioClip[])(object)new AudioClip[0];
			val.restingRotation = new Vector3(0f, 0f, 90f);
			val.rotationOffset = new Vector3(0f, 0f, 0f);
			val.positionOffset = new Vector3(0f, 0f, 0f);
			val.verticalOffset = 0.02f;
			return val;
		}

		private static GameObject BuildPrefab(Item item)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = NetworkPrefabs.CreateNetworkPrefab("LethalSmokesCigarette");
			obj.layer = 6;
			obj.tag = "PhysicsProp";
			obj.AddComponent<BoxCollider>().size = new Vector3(0.08f, 0.16f, 0.08f);
			Rigidbody obj2 = obj.AddComponent<Rigidbody>();
			obj2.isKinematic = true;
			obj2.useGravity = false;
			AudioSource obj3 = obj.AddComponent<AudioSource>();
			obj3.playOnAwake = false;
			obj3.spatialBlend = 1f;
			obj3.rolloffMode = (AudioRolloffMode)1;
			obj3.maxDistance = 15f;
			MeshRenderer val = CigaretteVisuals.AddModel(obj.transform, trackForMaterial: true);
			((Component)val).gameObject.layer = 6;
			AddScanNode(obj.transform);
			CigaretteItem cigaretteItem = obj.AddComponent<CigaretteItem>();
			((GrabbableObject)cigaretteItem).itemProperties = item;
			((GrabbableObject)cigaretteItem).grabbable = true;
			((GrabbableObject)cigaretteItem).grabbableToEnemies = true;
			((GrabbableObject)cigaretteItem).mainObjectRenderer = val;
			return obj;
		}

		private static void AddScanNode(Transform parent)
		{
			//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_0096: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			GameObject val;
			ScanNodeProperties val2;
			if ((Object)(object)Items.scanNodePrefab != (Object)null)
			{
				val = Object.Instantiate<GameObject>(Items.scanNodePrefab, parent);
				((Object)val).name = "ScanNode";
				val2 = val.GetComponent<ScanNodeProperties>();
				BoxCollider component = val.GetComponent<BoxCollider>();
				LethalSmokesPlugin.Log.LogInfo((object)string.Format("Scan node from LethalLib (layer {0}, collider {1})", val.layer, ((Object)(object)component != (Object)null) ? $"trigger={((Collider)component).isTrigger} size={component.size}" : "none"));
			}
			else
			{
				val = new GameObject("ScanNode")
				{
					layer = 22
				};
				val.transform.SetParent(parent, false);
				BoxCollider obj = val.AddComponent<BoxCollider>();
				((Collider)obj).isTrigger = true;
				obj.size = Vector3.one * 0.3f;
				val2 = null;
				LethalSmokesPlugin.Log.LogWarning((object)"LethalLib scan node prefab missing; built one by hand");
			}
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = val.AddComponent<ScanNodeProperties>();
			}
			Rigidbody val3 = val.GetComponent<Rigidbody>();
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = val.AddComponent<Rigidbody>();
			}
			val3.isKinematic = true;
			val3.useGravity = false;
			val.transform.localPosition = Vector3.zero;
			val2.headerText = "Cigarette";
			val2.subText = "Value: ";
			val2.nodeType = 2;
			val2.minRange = 1;
			val2.maxRange = 13;
			val2.requiresLineOfSight = true;
			val2.creatureScanID = -1;
		}
	}
	internal static class CigaretteVisuals
	{
		public sealed class MouthModel
		{
			public Transform Root;

			public Transform Paper;

			public Transform Tip;

			public Transform Ash;

			public MeshRenderer Ember;

			public MeshRenderer Char;

			public MeshRenderer[] Renderers;

			private float ashLength = 0.001f;

			public float CurrentLength => Tip.localPosition.y + 0.0061999997f + ashLength;

			public void SetLength(float fraction, float ash = 0.001f)
			{
				//IL_003c: 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_0073: 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_008e: Unknown result type (might be due to invalid IL or missing references)
				ashLength = ash;
				float num = Mathf.Max(0.0005f, fraction * 0.12f - 0.024f - 0.0061999997f - 0.001f);
				Paper.localScale = new Vector3(1f, num, 1f);
				Tip.localPosition = new Vector3(0f, 0.024f + num, 0f);
				Ash.localScale = new Vector3(Ash.localScale.x, ash, Ash.localScale.z);
			}
		}

		private static AudioClip flickClip;

		private static AudioClip igniteClip;

		private static AudioClip inhaleClip;

		private static AudioClip exhaleClip;

		private static AudioClip extinguishClip;

		public const float Length = 0.12f;

		public const float Radius = 0.006f;

		private const int Segments = 8;

		public const float FilterLength = 0.024f;

		private const float CharLength = 0.0012f;

		private const float EmberLength = 0.005f;

		private const float AshMinLength = 0.001f;

		private const float AshMaxLength = 0.009f;

		private const int AshDrops = 3;

		private const float TipBaseLength = 0.0061999997f;

		private static readonly string[] DonorItemNames = new string[5] { "Pill bottle", "Magnifying glass", "Toy cube", "Comedy", "Tragedy" };

		private static readonly string[] LightDonorItemNames = new string[3] { "Flashlight", "Pro-flashlight", "Walkie-talkie" };

		private static readonly string[] SmokeDonorItemNames = new string[3] { "Jetpack", "Weed killer", "Spray paint" };

		private static readonly Color PaperColor = new Color(0.93f, 0.91f, 0.86f);

		private static readonly Color FilterColor = new Color(0.78f, 0.48f, 0.2f);

		private static readonly Color AshColor = new Color(0.32f, 0.31f, 0.3f);

		private static readonly Color CharColor = new Color(0.1f, 0.07f, 0.05f);

		public static readonly Color EmberColor = new Color(1f, 0.32f, 0.05f);

		public static readonly Color EmberHotColor = new Color(1f, 0.62f, 0.22f);

		private static readonly Color LightColor = new Color(1f, 0.55f, 0.25f);

		public const float EmberGlow = 2.2f;

		public const float CharGlow = 0.25f;

		private const float FirstPersonGlow = 0.12f;

		private static readonly List<MeshRenderer> PrefabRenderers = new List<MeshRenderer>();

		private static Mesh itemMesh;

		private static Mesh partMesh;

		private static Sprite icon;

		private static Light lightDonor;

		private static ParticleSystem smokeDonor;

		private static Material smokeMaterial;

		private static Material ribbonMaterial;

		private const int SmokeTiles = 2;

		private const int SmokeTileSize = 64;

		public static string SoundDescription { get; private set; } = "none";

		public static AudioClip Flick
		{
			get
			{
				if (!((Object)(object)flickClip != (Object)null))
				{
					return flickClip = Clip("LethalSmokesFlick", SmokeSynth.Flick());
				}
				return flickClip;
			}
		}

		public static AudioClip Ignite
		{
			get
			{
				if (!((Object)(object)igniteClip != (Object)null))
				{
					return igniteClip = Clip("LethalSmokesIgnite", SmokeSynth.Ignite());
				}
				return igniteClip;
			}
		}

		public static AudioClip Inhale
		{
			get
			{
				if (!((Object)(object)inhaleClip != (Object)null))
				{
					return inhaleClip = Clip("LethalSmokesInhale", SmokeSynth.Inhale());
				}
				return inhaleClip;
			}
		}

		public static AudioClip Exhale
		{
			get
			{
				if (!((Object)(object)exhaleClip != (Object)null))
				{
					return exhaleClip = Clip("LethalSmokesExhale", SmokeSynth.Exhale());
				}
				return exhaleClip;
			}
		}

		public static AudioClip Extinguish
		{
			get
			{
				if (!((Object)(object)extinguishClip != (Object)null))
				{
					return extinguishClip = Clip("LethalSmokesExtinguish", SmokeSynth.Extinguish());
				}
				return extinguishClip;
			}
		}

		public static Material PaperMaterial { get; private set; }

		public static Material FilterMaterial { get; private set; }

		public static Material AshMaterial { get; private set; }

		public static Material CharMaterial { get; private set; }

		public static Material EmberMaterial { get; private set; }

		public static Material FirstPersonPaperMaterial { get; private set; }

		public static Material FirstPersonFilterMaterial { get; private set; }

		public static Material FirstPersonAshMaterial { get; private set; }

		public static string DonorName { get; private set; }

		public static string LightDonorDescription { get; private set; } = "none";

		public static string SmokeDonorDescription { get; private set; } = "none";

		public static string EmberDescription { get; private set; } = "none";

		public static Mesh Mesh
		{
			get
			{
				if (!((Object)(object)itemMesh != (Object)null))
				{
					return itemMesh = BuildCylinder("LethalSmokesCigarette", new float[3] { -0.06f, -0.036f, 0.06f });
				}
				return itemMesh;
			}
		}

		private static Mesh PartMesh
		{
			get
			{
				if (!((Object)(object)partMesh != (Object)null))
				{
					return partMesh = BuildCylinder("LethalSmokesCigarettePart", new float[2] { 0f, 1f });
				}
				return partMesh;
			}
		}

		public static Sprite Icon
		{
			get
			{
				if (!((Object)(object)icon != (Object)null))
				{
					return icon = BuildIcon();
				}
				return icon;
			}
		}

		private static Material[] ItemMaterials => (Material[])(object)new Material[2] { FilterMaterial, PaperMaterial };

		private static Material SmokeMaterial
		{
			get
			{
				if (!((Object)(object)smokeMaterial != (Object)null) && !((Object)(object)smokeDonor == (Object)null))
				{
					return smokeMaterial = CloneSmokeMaterial("LethalSmokesSmoke", BuildSmokeTexture);
				}
				return smokeMaterial;
			}
		}

		private static Material RibbonMaterial
		{
			get
			{
				if (!((Object)(object)ribbonMaterial != (Object)null) && !((Object)(object)smokeDonor == (Object)null))
				{
					return ribbonMaterial = CloneSmokeMaterial("LethalSmokesRibbon", BuildRibbonTexture);
				}
				return ribbonMaterial;
			}
		}

		private static void PrepareSounds()
		{
			SoundDescription = $"synthesized: flick {Flick.length:0.00}s, ignite {Ignite.length:0.00}s, inhale {Inhale.length:0.00}s, " + $"exhale {Exhale.length:0.00}s, extinguish {Extinguish.length:0.00}s";
		}

		public static AudioSource AddAudioSource(Transform parent, PlayerControllerB player)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Invalid comparison between Unknown and I4
			GameObject val = new GameObject("CigaretteAudio");
			val.transform.SetParent(parent, false);
			AudioSource val2 = val.AddComponent<AudioSource>();
			AudioSource itemAudio = player.itemAudio;
			if ((Object)(object)itemAudio != (Object)null)
			{
				val2.outputAudioMixerGroup = itemAudio.outputAudioMixerGroup;
				val2.rolloffMode = itemAudio.rolloffMode;
				if ((int)itemAudio.rolloffMode == 2)
				{
					val2.SetCustomCurve((AudioSourceCurveType)0, itemAudio.GetCustomCurve((AudioSourceCurveType)0));
				}
				val2.minDistance = itemAudio.minDistance;
				val2.maxDistance = itemAudio.maxDistance;
				val2.spread = itemAudio.spread;
				val2.dopplerLevel = itemAudio.dopplerLevel;
			}
			else
			{
				val2.rolloffMode = (AudioRolloffMode)1;
				val2.minDistance = 1f;
				val2.maxDistance = 20f;
				val2.dopplerLevel = 0f;
			}
			val2.spatialBlend = 1f;
			val2.playOnAwake = false;
			val2.loop = false;
			return val2;
		}

		private static AudioClip Clip(string name, float[] data)
		{
			AudioClip obj = AudioClip.Create(name, data.Length, 1, 44100, false);
			obj.SetData(data, 0);
			((Object)obj).hideFlags = (HideFlags)32;
			return obj;
		}

		public static MeshRenderer AddModel(Transform parent, bool trackForMaterial)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("CigaretteModel");
			val.transform.SetParent(parent, false);
			val.AddComponent<MeshFilter>().sharedMesh = Mesh;
			MeshRenderer val2 = val.AddComponent<MeshRenderer>();
			if ((Object)(object)PaperMaterial != (Object)null)
			{
				((Renderer)val2).sharedMaterials = ItemMaterials;
			}
			if (trackForMaterial)
			{
				PrefabRenderers.Add(val2);
			}
			return val2;
		}

		public static void BorrowFromVanilla(StartOfRound round, Item cigarette)
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_00fe: 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_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: 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_014f: 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_016e: 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_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: 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_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)PaperMaterial != (Object)null)
			{
				return;
			}
			List<Item> items = round.allItemsList.itemsList;
			Item val = DonorItemNames.Select((string name) => ((IEnumerable<Item>)items).FirstOrDefault((Func<Item, bool>)((Item i) => (Object)(object)i != (Object)null && i.itemName == name && (Object)(object)LitMaterialOf(i) != (Object)null))).FirstOrDefault<Item>((Func<Item, bool>)((Item i) => (Object)(object)i != (Object)null)) ?? ((IEnumerable<Item>)items).FirstOrDefault((Func<Item, bool>)((Item i) => (Object)(object)i != (Object)null && i.isScrap && (Object)(object)LitMaterialOf(i) != (Object)null));
			if ((Object)(object)val == (Object)null)
			{
				LethalSmokesPlugin.Log.LogError((object)"No vanilla item with an HDRP Lit material found; the cigarette will render without a material.");
				return;
			}
			Material val2 = LitMaterialOf(val);
			DonorName = val.itemName;
			PaperMaterial = CloneLit(val2, "LethalSmokesPaper", PaperColor);
			FilterMaterial = CloneLit(val2, "LethalSmokesFilter", FilterColor);
			AshMaterial = CloneLit(val2, "LethalSmokesAsh", AshColor);
			CharMaterial = CloneLit(val2, "LethalSmokesChar", CharColor);
			SetEmission(CharMaterial, EmberColor * 0.25f, 0f);
			EmberMaterial = CloneLit(val2, "LethalSmokesEmber", EmberColor * 0.5f);
			SetEmission(EmberMaterial, EmberColor * 2.2f, 0f);
			FirstPersonPaperMaterial = CloneLit(val2, "LethalSmokesPaperFirstPerson", PaperColor);
			SetEmission(FirstPersonPaperMaterial, PaperColor * 0.12f, 0f);
			FirstPersonFilterMaterial = CloneLit(val2, "LethalSmokesFilterFirstPerson", FilterColor);
			SetEmission(FirstPersonFilterMaterial, FilterColor * 0.12f, 0f);
			FirstPersonAshMaterial = CloneLit(val2, "LethalSmokesAshFirstPerson", AshColor);
			SetEmission(FirstPersonAshMaterial, AshColor * 0.12f, 0f);
			EmberDescription = $"emissive {2.2f} screen-relative; ember {DescribeEmission(EmberMaterial)}; " + "flashlight bulb " + DescribeBulb(items) + "; donor material " + DescribeEmission(val2);
			foreach (MeshRenderer prefabRenderer in PrefabRenderers)
			{
				if ((Object)(object)prefabRenderer != (Object)null)
				{
					((Renderer)prefabRenderer).sharedMaterials = ItemMaterials;
				}
			}
			if ((Object)(object)cigarette.grabSFX == (Object)null)
			{
				cigarette.grabSFX = val.grabSFX;
			}
			if ((Object)(object)cigarette.dropSFX == (Object)null)
			{
				cigarette.dropSFX = val.dropSFX;
			}
			if ((Object)(object)cigarette.pocketSFX == (Object)null)
			{
				cigarette.pocketSFX = val.pocketSFX;
			}
			LethalSmokesPlugin.Log.LogInfo((object)("Borrowed material '" + ((Object)val2).name + "' (shader " + ((Object)val2.shader).name + ") and sounds from vanilla item '" + val.itemName + "'"));
			FindLightDonor(items);
			FindSmokeDonor(items);
			PrepareSounds();
			LethalSmokesPlugin.Log.LogInfo((object)("Ember: " + EmberDescription));
			LethalSmokesPlugin.Log.LogInfo((object)("Sounds: " + SoundDescription));
			LethalSmokesPlugin.Log.LogInfo((object)("Ember light cloned from " + LightDonorDescription));
			LethalSmokesPlugin.Log.LogInfo((object)("Smoke cloned from " + SmokeDonorDescription));
		}

		private static Material LitMaterialOf(Item item)
		{
			if ((Object)(object)item.spawnPrefab == (Object)null)
			{
				return null;
			}
			MeshRenderer componentInChildren = item.spawnPrefab.GetComponentInChildren<MeshRenderer>(true);
			Material val = (((Object)(object)componentInChildren != (Object)null) ? ((Renderer)componentInChildren).sharedMaterial : null);
			if (!((Object)(object)val != (Object)null) || !((Object)(object)val.shader != (Object)null) || !((Object)val.shader).name.Contains("HDRP/Lit"))
			{
				return null;
			}
			return val;
		}

		private static Material CloneLit(Material source, string name, Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(source)
			{
				name = name,
				hideFlags = (HideFlags)32
			};
			if (val.HasProperty("_BaseColorMap"))
			{
				val.SetTexture("_BaseColorMap", (Texture)null);
			}
			if (val.HasProperty("_BaseColor"))
			{
				val.SetColor("_BaseColor", color);
			}
			SetEmission(val, Color.black);
			return val;
		}

		private static void SetEmission(Material material, Color color, float exposureWeight = 1f)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (material.HasProperty("_EmissiveColorMap"))
			{
				material.SetTexture("_EmissiveColorMap", (Texture)null);
			}
			if (material.HasProperty("_EmissiveColor"))
			{
				material.SetColor("_EmissiveColor", color);
			}
			if (material.HasProperty("_EmissiveExposureWeight"))
			{
				material.SetFloat("_EmissiveExposureWeight", exposureWeight);
			}
		}

		private static string DescribeEmission(Material material)
		{
			//IL_002c: 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)
			object obj;
			if (!material.HasProperty("_EmissiveColor"))
			{
				obj = "n/a";
			}
			else
			{
				Color color = material.GetColor("_EmissiveColor");
				obj = ((Color)(ref color)).ToString("0.###");
			}
			string text = (string)obj;
			return "'" + ((Object)material).name + "' _EmissiveColor " + text + " _EmissiveExposureWeight " + Float("_EmissiveExposureWeight") + " _UseEmissiveIntensity " + Float("_UseEmissiveIntensity") + " _EmissiveIntensity " + Float("_EmissiveIntensity");
			string Float(string name)
			{
				if (!material.HasProperty(name))
				{
					return "n/a";
				}
				return material.GetFloat(name).ToString("0.###");
			}
		}

		private static string DescribeBulb(List<Item> items)
		{
			FlashlightItem val = (from i in items
				where (Object)(object)i != (Object)null && (Object)(object)i.spawnPrefab != (Object)null
				select i.spawnPrefab.GetComponent<FlashlightItem>()).FirstOrDefault((Func<FlashlightItem, bool>)((FlashlightItem f) => (Object)(object)f != (Object)null && (Object)(object)f.bulbLight != (Object)null));
			if (!((Object)(object)val == (Object)null))
			{
				return "('" + ((GrabbableObject)val).itemProperties?.itemName + "') " + DescribeEmission(val.bulbLight);
			}
			return "none found";
		}

		public static float AshLengthAt(float progress)
		{
			return Mathf.Lerp(0.001f, 0.009f, Mathf.Repeat(progress * 3f, 1f));
		}

		public static int AshDropsAt(float progress)
		{
			return Mathf.FloorToInt(Mathf.Clamp01(progress) * 3f);
		}

		public static MouthModel BuildMouthModel(Transform parent, string name, int layer, ShadowCastingMode shadows, bool firstPerson = false)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: 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)
			Material material = (firstPerson ? FirstPersonFilterMaterial : FilterMaterial);
			Material material2 = (firstPerson ? FirstPersonPaperMaterial : PaperMaterial);
			Material material3 = (firstPerson ? FirstPersonAshMaterial : AshMaterial);
			GameObject val = new GameObject(name);
			val.AddComponent<MouthCigarettePart>();
			val.transform.SetParent(parent, false);
			val.layer = layer;
			List<MeshRenderer> list = new List<MeshRenderer>();
			AddPart(val.transform, "Filter", material, new Vector3(1f, 0.024f, 1f), Vector3.zero, layer, shadows, list);
			Transform paper = AddPart(val.transform, "Paper", material2, new Vector3(1f, 0.0888f, 1f), new Vector3(0f, 0.024f, 0f), layer, shadows, list);
			GameObject val2 = new GameObject("Tip");
			val2.layer = layer;
			val2.transform.SetParent(val.transform, false);
			Transform val3 = AddPart(val2.transform, "Char", CharMaterial, new Vector3(1.02f, 0.0012f, 1.02f), Vector3.zero, layer, shadows, list);
			Transform val4 = AddPart(val2.transform, "Ember", EmberMaterial, new Vector3(1.04f, 0.005f, 1.04f), new Vector3(0f, 0.0012f, 0f), layer, shadows, list);
			Transform ash = AddPart(val2.transform, "Ash", material3, new Vector3(0.85f, 0.001f, 0.85f), new Vector3(0f, 0.0061999997f, 0f), layer, shadows, list);
			MouthModel mouthModel = new MouthModel();
			mouthModel.Root = val.transform;
			mouthModel.Paper = paper;
			mouthModel.Tip = val2.transform;
			mouthModel.Ash = ash;
			mouthModel.Ember = ((Component)val4).GetComponent<MeshRenderer>();
			mouthModel.Char = ((Component)val3).GetComponent<MeshRenderer>();
			mouthModel.Renderers = list.ToArray();
			mouthModel.SetLength(1f);
			return mouthModel;
		}

		private static Transform AddPart(Transform parent, string name, Material material, Vector3 scale, Vector3 position, int layer, ShadowCastingMode shadows, List<MeshRenderer> renderers)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name)
			{
				layer = layer
			};
			val.transform.SetParent(parent, false);
			val.transform.localPosition = position;
			val.transform.localScale = scale;
			val.AddComponent<MeshFilter>().sharedMesh = PartMesh;
			MeshRenderer val2 = val.AddComponent<MeshRenderer>();
			if ((Object)(object)material != (Object)null)
			{
				((Renderer)val2).sharedMaterial = material;
			}
			((Renderer)val2).shadowCastingMode = shadows;
			renderers.Add(val2);
			return val.transform;
		}

		private static void FindLightDonor(List<Item> items)
		{
			string[] lightDonorItemNames = LightDonorItemNames;
			foreach (string name in lightDonorItemNames)
			{
				GameObject val = ((IEnumerable<Item>)items).FirstOrDefault((Func<Item, bool>)((Item val2) => (Object)(object)val2 != (Object)null && val2.itemName == name && (Object)(object)val2.spawnPrefab != (Object)null))?.spawnPrefab;
				if (!((Object)(object)val == (Object)null))
				{
					FlashlightItem component = val.GetComponent<FlashlightItem>();
					WalkieTalkie component2 = val.GetComponent<WalkieTalkie>();
					if (UseLightDonor(((Object)(object)component != (Object)null) ? component.flashlightBulbGlow : (((Object)(object)component2 != (Object)null) ? component2.walkieTalkieLight : null), "'" + name + "'"))
					{
						return;
					}
				}
			}
			foreach (Item item in items.Where((Item val2) => (Object)(object)val2 != (Object)null && (Object)(object)val2.spawnPrefab != (Object)null))
			{
				Light[] componentsInChildren = item.spawnPrefab.GetComponentsInChildren<Light>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					if (UseLightDonor(componentsInChildren[i], "'" + item.itemName + "'"))
					{
						return;
					}
				}
			}
			LethalSmokesPlugin.Log.LogWarning((object)"No vanilla light with HDAdditionalLightData found; the ember will not light its surroundings.");
		}

		private static bool UseLightDonor(Light candidate, string owner)
		{
			//IL_003e: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)candidate == (Object)null)
			{
				return false;
			}
			HDAdditionalLightData component = ((Component)candidate).GetComponent<HDAdditionalLightData>();
			if ((Object)(object)component == (Object)null)
			{
				return false;
			}
			lightDonor = candidate;
			LightDonorDescription = $"{owner} light '{((Object)candidate).name}' ({candidate.type}, {component.intensity:0.##} {component.lightUnit}, range {candidate.range:0.##}, shadows {candidate.shadows}, volumetric {component.affectsVolumetric})";
			return true;
		}

		public static EmberLight AddEmberLight(MouthModel model, float range, float intensityLumen)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			GameObject val;
			if ((Object)(object)lightDonor != (Object)null)
			{
				val = Object.Instantiate<GameObject>(((Component)lightDonor).gameObject, model.Tip, false);
				StripClone(val, (Component c) => c is Light || c is HDAdditionalLightData);
			}
			else
			{
				val = new GameObject();
				val.transform.SetParent(model.Tip, false);
			}
			((Object)val).name = "EmberLight";
			val.transform.localPosition = new Vector3(0f, 0.016199999f, 0f);
			val.transform.localRotation = Quaternion.identity;
			val.transform.localScale = Vector3.one;
			val.SetActive(true);
			Light component = val.GetComponent<Light>();
			HDAdditionalLightData component2 = val.GetComponent<HDAdditionalLightData>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.type = (HDLightType)2;
				component2.EnableShadows(false);
				component2.affectsVolumetric = false;
				component2.SetIntensity(intensityLumen, (LightUnit)0);
				component2.range = range;
				component2.color = LightColor;
				component2.lightDimmer = 1f;
				((Behaviour)component).enabled = true;
			}
			EmberLight emberLight = val.AddComponent<EmberLight>();
			emberLight.Init(component2, (Renderer)(object)model.Ember, (Renderer)(object)model.Char);
			return emberLight;
		}

		private static void FindSmokeDonor(List<Item> items)
		{
			string[] smokeDonorItemNames = SmokeDonorItemNames;
			foreach (string name in smokeDonorItemNames)
			{
				GameObject val = ((IEnumerable<Item>)items).FirstOrDefault((Func<Item, bool>)((Item val2) => (Object)(object)val2 != (Object)null && val2.itemName == name && (Object)(object)val2.spawnPrefab != (Object)null))?.spawnPrefab;
				if (!((Object)(object)val == (Object)null))
				{
					JetpackItem component = val.GetComponent<JetpackItem>();
					SprayPaintItem component2 = val.GetComponent<SprayPaintItem>();
					if (UseSmokeDonor(((Object)(object)component != (Object)null) ? component.smokeTrailParticle : (((Object)(object)component2 != (Object)null) ? component2.sprayParticle : null), "'" + name + "'"))
					{
						return;
					}
				}
			}
			foreach (Item item in items.Where((Item val2) => (Object)(object)val2 != (Object)null && (Object)(object)val2.spawnPrefab != (Object)null))
			{
				ParticleSystem[] componentsInChildren = item.spawnPrefab.GetComponentsInChildren<ParticleSystem>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					if (UseSmokeDonor(componentsInChildren[i], "'" + item.itemName + "'"))
					{
						return;
					}
				}
			}
			LethalSmokesPlugin.Log.LogWarning((object)"No vanilla particle system found; the cigarette will not smoke.");
		}

		private static bool UseSmokeDonor(ParticleSystem candidate, string owner)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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)
			ParticleSystemRenderer val = (((Object)(object)candidate != (Object)null) ? ((Component)candidate).GetComponent<ParticleSystemRenderer>() : null);
			if ((Object)(object)val == (Object)null || (Object)(object)((Renderer)val).sharedMaterial == (Object)null)
			{
				return false;
			}
			smokeDonor = candidate;
			MainModule main = candidate.main;
			EmissionModule emission = candidate.emission;
			string[] obj = new string[11]
			{
				owner,
				" particles '",
				((Object)candidate).name,
				"' (material '",
				((Object)((Renderer)val).sharedMaterial).name,
				"', shader ",
				((Object)((Renderer)val).sharedMaterial.shader).name,
				", ",
				null,
				null,
				null
			};
			MinMaxCurve val2 = ((EmissionModule)(ref emission)).rateOverTime;
			object arg = ((MinMaxCurve)(ref val2)).constantMax;
			val2 = ((EmissionModule)(ref emission)).rateOverDistance;
			obj[8] = $"rate {arg:0.##}/s + {((MinMaxCurve)(ref val2)).constantMax:0.##}/m, {((MainModule)(ref main)).simulationSpace} space, ";
			object arg2 = ((MainModule)(ref main)).scalingMode;
			val2 = ((MainModule)(ref main)).startLifetime;
			object arg3 = ((MinMaxCurve)(ref val2)).constantMax;
			val2 = ((MainModule)(ref main)).startSize;
			obj[9] = $"{arg2} scaling, lifetime {arg3:0.##}s, size {((MinMaxCurve)(ref val2)).constantMax:0.###}, ";
			TextureSheetAnimationModule textureSheetAnimation = candidate.textureSheetAnimation;
			obj[10] = $"texture sheet {((TextureSheetAnimationModule)(ref textureSheetAnimation)).enabled})";
			SmokeDonorDescription = string.Concat(obj);
			return true;
		}

		public static ParticleSystem AddWisp(Transform tip, int layer, bool firstPerson)
		{
			//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_0049: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_00b2: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: 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_016d: 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_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected O, but got Unknown
			//IL_0192: 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_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_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Expected O, but got Unknown
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: 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_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Expected O, but got Unknown
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)smokeDonor == (Object)null)
			{
				return null;
			}
			GameObject holder;
			ParticleSystem val = CloneSmoke("LethalSmokesWisp", layer, firstPerson, out holder);
			MainModule main = val.main;
			((MainModule)(ref main)).duration = 1f;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).playOnAwake = true;
			((MainModule)(ref main)).startDelay = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(2.6f);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.004f);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.78f, 0.78f, 0.77f, 0.55f));
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)1;
			((MainModule)(ref main)).maxParticles = 80;
			((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)0;
			EmissionModule emission = val.emission;
			((EmissionModule)(ref emission)).enabled = true;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(22f);
			((EmissionModule)(ref emission)).rateOverDistance = MinMaxCurve.op_Implicit(0f);
			((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[0]);
			ShapeModule shape = val.shape;
			((ShapeModule)(ref shape)).enabled = false;
			VelocityOverLifetimeModule velocityOverLifetime = val.velocityOverLifetime;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = MinMaxCurve.op_Implicit(0f);
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[2]
			{
				new Keyframe(0f, 0.11f),
				new Keyframe(1f, 0.05f)
			}));
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = MinMaxCurve.op_Implicit(0f);
			NoiseModule noise = val.noise;
			((NoiseModule)(ref noise)).enabled = true;
			((NoiseModule)(ref noise)).strength = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, 0f),
				new Keyframe(0.25f, 0.02f),
				new Keyframe(1f, 0.09f)
			}));
			((NoiseModule)(ref noise)).frequency = 1.1f;
			((NoiseModule)(ref noise)).octaveCount = 2;
			((NoiseModule)(ref noise)).scrollSpeed = MinMaxCurve.op_Implicit(0.35f);
			((NoiseModule)(ref noise)).damping = true;
			SizeOverLifetimeModule sizeOverLifetime = val.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, 1f),
				new Keyframe(0.4f, 2.5f),
				new Keyframe(1f, 8f)
			}));
			ColorOverLifetimeModule colorOverLifetime = val.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(Fade(0.05f, 0.35f, 0.55f));
			DisableExtras(val);
			TrailModule trails = val.trails;
			((TrailModule)(ref trails)).enabled = true;
			((TrailModule)(ref trails)).mode = (ParticleSystemTrailMode)1;
			((TrailModule)(ref trails)).ribbonCount = 1;
			((TrailModule)(ref trails)).textureMode = (ParticleSystemTrailTextureMode)0;
			((TrailModule)(ref trails)).sizeAffectsWidth = true;
			((TrailModule)(ref trails)).widthOverTrail = MinMaxCurve.op_Implicit(1f);
			((TrailModule)(ref trails)).inheritParticleColor = true;
			((TrailModule)(ref trails)).colorOverLifetime = MinMaxGradient.op_Implicit(Color.white);
			((TrailModule)(ref trails)).colorOverTrail = MinMaxGradient.op_Implicit(Color.white);
			((TrailModule)(ref trails)).dieWithParticles = true;
			((TrailModule)(ref trails)).generateLightingData = false;
			ParticleSystemRenderer component = ((Component)val).GetComponent<ParticleSystemRenderer>();
			component.trailMaterial = RibbonMaterial;
			component.renderMode = (ParticleSystemRenderMode)5;
			TextureSheetAnimationModule textureSheetAnimation = val.textureSheetAnimation;
			((TextureSheetAnimationModule)(ref textureSheetAnimation)).enabled = false;
			((Component)val).transform.SetParent(tip, false);
			((Component)val).transform.localPosition = new Vector3(0f, 0.0061999997f, 0f);
			((Component)val).transform.localRotation = Quaternion.identity;
			((Component)val).transform.localScale = Vector3.one;
			Object.Destroy((Object)(object)holder);
			val.Play(true);
			return val;
		}

		public static ParticleSystem AddHaze(Transform tip, int layer, bool firstPerson)
		{
			//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_0049: 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_0070: 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_009c: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: 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_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Expected O, but got Unknown
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)smokeDonor == (Object)null)
			{
				return null;
			}
			GameObject holder;
			ParticleSystem val = CloneSmoke("LethalSmokesHaze", layer, firstPerson, out holder);
			MainModule main = val.main;
			((MainModule)(ref main)).duration = 1f;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).playOnAwake = true;
			((MainModule)(ref main)).startDelay = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(2.6f, 3.4f);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.02f, 0.03f);
			((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f);
			((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0.72f, 0.72f, 0.72f, 0.12f), new Color(0.8f, 0.8f, 0.78f, 0.2f));
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)1;
			((MainModule)(ref main)).maxParticles = 50;
			((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)0;
			EmissionModule emission = val.emission;
			((EmissionModule)(ref emission)).enabled = true;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(10f);
			((EmissionModule)(ref emission)).rateOverDistance = MinMaxCurve.op_Implicit(0f);
			((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[0]);
			ShapeModule shape = val.shape;
			((ShapeModule)(ref shape)).enabled = true;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = 0.003f;
			VelocityOverLifetimeModule velocityOverLifetime = val.velocityOverLifetime;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(-0.012f, 0.012f);
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0.07f, 0.1f);
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(-0.012f, 0.012f);
			NoiseModule noise = val.noise;
			((NoiseModule)(ref noise)).enabled = true;
			((NoiseModule)(ref noise)).strength = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 0.02f, 1f, 0.1f));
			((NoiseModule)(ref noise)).frequency = 0.8f;
			((NoiseModule)(ref noise)).octaveCount = 2;
			((NoiseModule)(ref noise)).scrollSpeed = MinMaxCurve.op_Implicit(0.25f);
			((NoiseModule)(ref noise)).damping = true;
			SizeOverLifetimeModule sizeOverLifetime = val.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 1f, 1f, 6f));
			RotationOverLifetimeModule rotationOverLifetime = val.rotationOverLifetime;
			((RotationOverLifetimeModule)(ref rotationOverLifetime)).enabled = true;
			((RotationOverLifetimeModule)(ref rotationOverLifetime)).z = new MinMaxCurve(-0.5f, 0.5f);
			ColorOverLifetimeModule colorOverLifetime = val.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val2 = new Gradient();
			val2.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(Color.white, 0f),
				new GradientColorKey(Color.white, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[4]
			{
				new GradientAlphaKey(0f, 0f),
				new GradientAlphaKey(0f, 0.3f),
				new GradientAlphaKey(1f, 0.55f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val2);
			DisableExtras(val);
			((Component)val).transform.SetParent(tip, false);
			((Component)val).transform.localPosition = new Vector3(0f, 0.0061999997f, 0f);
			((Component)val).transform.localRotation = Quaternion.identity;
			((Component)val).transform.localScale = Vector3.one;
			Object.Destroy((Object)(object)holder);
			val.Play(true);
			return val;
		}

		public static ParticleSystem AddMouthPuff(Transform parent, Vector3 mouth, int layer, bool firstPerson)
		{
			//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_0049: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: 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_017d: 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_0199: 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_01cd: 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_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Expected O, but got Unknown
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)smokeDonor == (Object)null)
			{
				return null;
			}
			GameObject holder;
			ParticleSystem val = CloneSmoke("LethalSmokesMouthPuff", layer, firstPerson, out holder);
			MainModule main = val.main;
			((MainModule)(ref main)).duration = 1f;
			((MainModule)(ref main)).loop = false;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).startDelay = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(2f, 3f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.35f, 0.55f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.025f, 0.045f);
			((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f);
			((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0.72f, 0.72f, 0.72f, 0.16f), new Color(0.82f, 0.82f, 0.8f, 0.26f));
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)1;
			((MainModule)(ref main)).maxParticles = 120;
			((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)0;
			EmissionModule emission = val.emission;
			((EmissionModule)(ref emission)).enabled = false;
			ShapeModule shape = val.shape;
			((ShapeModule)(ref shape)).enabled = true;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
			((ShapeModule)(ref shape)).angle = 7f;
			((ShapeModule)(ref shape)).radius = 0.006f;
			((ShapeModule)(ref shape)).rotation = Vector3.zero;
			LimitVelocityOverLifetimeModule limitVelocityOverLifetime = val.limitVelocityOverLifetime;
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).enabled = true;
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).limit = MinMaxCurve.op_Implicit(0.05f);
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).dampen = 0.08f;
			VelocityOverLifetimeModule velocityOverLifetime = val.velocityOverLifetime;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(-0.02f, 0.02f);
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0.04f, 0.08f);
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(-0.02f, 0.02f);
			NoiseModule noise = val.noise;
			((NoiseModule)(ref noise)).enabled = true;
			((NoiseModule)(ref noise)).strength = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 0.01f, 1f, 0.07f));
			((NoiseModule)(ref noise)).frequency = 0.8f;
			((NoiseModule)(ref noise)).octaveCount = 2;
			((NoiseModule)(ref noise)).scrollSpeed = MinMaxCurve.op_Implicit(0.25f);
			SizeOverLifetimeModule sizeOverLifetime = val.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, 1f),
				new Keyframe(0.25f, 3.2f),
				new Keyframe(1f, 7f)
			}));
			RotationOverLifetimeModule rotationOverLifetime = val.rotationOverLifetime;
			((RotationOverLifetimeModule)(ref rotationOverLifetime)).enabled = true;
			((RotationOverLifetimeModule)(ref rotationOverLifetime)).z = new MinMaxCurve(-0.8f, 0.8f);
			ColorOverLifetimeModule colorOverLifetime = val.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(Fade(0.05f, 0.4f, 0.4f));
			DisableExtras(val);
			((Component)val).transform.SetParent(parent, false);
			((Component)val).transform.localPosition = mouth;
			((Component)val).transform.localRotation = Quaternion.identity;
			((Component)val).transform.localScale = Vector3.one;
			Object.Destroy((Object)(object)holder);
			return val;
		}

		public static ParticleSystem AddSparks(Transform tip, int layer)
		{
			//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_0049: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: 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_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: 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)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)smokeDonor == (Object)null)
			{
				return null;
			}
			GameObject holder;
			ParticleSystem val = CloneSmoke("LethalSmokesSparks", layer, firstPerson: false, out holder, smoke: false);
			MainModule main = val.main;
			((MainModule)(ref main)).duration = 1f;
			((MainModule)(ref main)).loop = false;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).startDelay = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.35f, 0.8f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.05f, 0.18f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.0025f, 0.005f);
			((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.55f, 0.15f, 1f), new Color(1f, 0.8f, 0.4f, 1f));
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0.25f);
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)1;
			((MainModule)(ref main)).maxParticles = 24;
			((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)0;
			EmissionModule emission = val.emission;
			((EmissionModule)(ref emission)).enabled = false;
			ShapeModule shape = val.shape;
			((ShapeModule)(ref shape)).enabled = true;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)2;
			((ShapeModule)(ref shape)).radius = 0.004f;
			((ShapeModule)(ref shape)).rotation = new Vector3(-90f, 0f, 0f);
			SizeOverLifetimeModule sizeOverLifetime = val.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 1f, 1f, 0.2f));
			ColorOverLifetimeModule colorOverLifetime = val.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val2 = new Gradient();
			val2.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(Color.white, 0f),
				new GradientColorKey(Color.white, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(1f, 0f),
				new GradientAlphaKey(0.8f, 0.5f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val2);
			DisableExtras(val);
			((Component)val).transform.SetParent(tip, false);
			((Component)val).transform.localPosition = new Vector3(0f, 0.0061999997f, 0f);
			((Component)val).transform.localRotation = Quaternion.identity;
			((Component)val).transform.localScale = Vector3.one;
			Object.Destroy((Object)(object)holder);
			return val;
		}

		public static void EmitAsh(ParticleSystem sparks, int count)
		{
			//IL_0002: 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)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			EmitParams val = default(EmitParams);
			((EmitParams)(ref val)).startColor = Color32.op_Implicit(new Color(0.45f, 0.44f, 0.42f, 0.9f));
			((EmitParams)(ref val)).startSize = 0.004f;
			((EmitParams)(ref val)).startLifetime = 0.9f;
			EmitParams val2 = val;
			for (int i = 0; i < count; i++)
			{
				((EmitParams)(ref val2)).velocity = new Vector3(Random.Range(-0.03f, 0.03f), Random.Range(-0.02f, 0.02f), Random.Range(-0.03f, 0.03f));
				sparks.Emit(val2, 1);
			}
		}

		private static Gradient Fade(float fullAt, float holdUntil, float holdAlpha)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			Gradient val = new Gradient();
			val.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(Color.white, 0f),
				new GradientColorKey(Color.white, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[4]
			{
				new GradientAlphaKey(0f, 0f),
				new GradientAlphaKey(1f, fullAt),
				new GradientAlphaKey(holdAlpha, holdUntil),
				new GradientAlphaKey(0f, 1f)
			});
			return val;
		}

		private static ParticleSystem CloneSmoke(string name, int layer, bool firstPerson, out GameObject holder, bool smoke = true)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			holder = new GameObject(name + "Holder");
			holder.SetActive(false);
			GameObject obj = Object.Instantiate<GameObject>(((Component)smokeDonor).gameObject, holder.transform, false);
			((Object)obj).name = name;
			StripClone(obj, (Component c) => c is ParticleSystem || c is ParticleSystemRenderer);
			obj.AddComponent<MouthCigarettePart>();
			obj.layer = layer;
			ParticleSystem component = obj.GetComponent<ParticleSystem>();
			component.Stop(true, (ParticleSystemStopBehavior)0);
			ParticleSystemRenderer component2 = obj.GetComponent<ParticleSystemRenderer>();
			if (smoke)
			{
				Material val = SmokeMaterial;
				if ((Object)(object)val != (Object)null)
				{
					((Renderer)component2).sharedMaterial = val;
					TextureSheetAnimationModule textureSheetAnimation = component.textureSheetAnimation;
					((TextureSheetAnimationModule)(ref textureSheetAnimation)).enabled = true;
					((TextureSheetAnimationModule)(ref textureSheetAnimation)).mode = (ParticleSystemAnimationMode)0;
					((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesX = 2;
					((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesY = 2;
					((TextureSheetAnimationModule)(ref textureSheetAnimation)).animation = (ParticleSystemAnimationType)0;
					((TextureSheetAnimationModule)(ref textureSheetAnimation)).startFrame = MinMaxCurve.op_Implicit(0f);
					((TextureSheetAnimationModule)(ref textureSheetAnimation)).frameOverTime = new MinMaxCurve(0f, 0.999f);
					((TextureSheetAnimationModule)(ref textureSheetAnimation)).cycleCount = 1;
				}
				component2.sortMode = (ParticleSystemSortMode)2;
			}
			if (firstPerson)
			{
				component2.maxParticleSize = 0.12f;
			}
			return component;
		}

		private static Material CloneSmokeMaterial(string name, Func<bool, Texture2D> texture)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			Material sharedMaterial = ((Renderer)((Component)smokeDonor).GetComponent<ParticleSystemRenderer>()).sharedMaterial;
			Shader val = Shader.Find("Legacy Shaders/Particles/Alpha Blended");
			bool flag = (Object)(object)val != (Object)null && val.isSupported;
			Material val2 = new Material(flag ? val : sharedMaterial.shader)
			{
				name = name,
				hideFlags = (HideFlags)32
			};
			if (!flag)
			{
				val2.CopyPropertiesFromMaterial(sharedMaterial);
			}
			if (val2.HasProperty("_TintColor"))
			{
				val2.SetColor("_TintColor", new Color(0.5f, 0.5f, 0.5f, 0.5f));
			}
			val2.mainTexture = (Texture)(object)texture(!flag);
			val2.renderQueue = sharedMaterial.renderQueue;
			string text = ((Object)val2.shader).name + " (" + (flag ? "straight" : "premultiplied") + " alpha)";
			SmokeDonorDescription = SmokeDonorDescription + "; " + name + " " + text;
			LethalSmokesPlugin.Log.LogInfo((object)("Smoke material '" + name + "': " + text));
			return val2;
		}

		private static Texture2D BuildRibbonTexture(bool premultiplied)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_0030: Expected O, but got Unknown
			//IL_00ee: 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)
			Texture2D val = new Texture2D(128, 32, (TextureFormat)4, true)
			{
				name = "LethalSmokesRibbon",
				hideFlags = (HideFlags)32,
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)2
			};
			Color[] array = (Color[])(object)new Color[4096];
			for (int i = 0; i < 32; i++)
			{
				float num = ((float)i + 0.5f) / 32f * 2f - 1f;
				for (int j = 0; j < 128; j++)
				{
					float num2 = ((float)j + 0.5f) / 128f;
					float num3 = Mathf.Lerp(0.6f, 1f, Fbm(num2 * 3f, num * 5f + 3.1f));
					float num4 = Mathf.Exp((0f - num) * num * 5f) * Mathf.Clamp01((1f - Mathf.Abs(num)) / 0.2f) * num3;
					float num5 = (premultiplied ? num4 : 1f);
					array[i * 128 + j] = new Color(num5, num5, num5, num4);
				}
			}
			val.SetPixels(array);
			val.Apply(true, false);
			return val;
		}

		private static Texture2D BuildSmokeTexture(bool premultiplied)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(128, 128, (TextureFormat)4, true)
			{
				name = "LethalSmokesSmoke",
				hideFlags = (HideFlags)32,
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)2
			};
			Color[] array = (Color[])(object)new Color[16384];
			for (int i = 0; i < 4; i++)
			{
				int num = i % 2 * 64;
				int num2 = i / 2 * 64;
				float num3 = 17.3f * (float)(i + 1);
				for (int j = 0; j < 64; j++)
				{
					for (int k = 0; k < 64; k++)
					{
						float num4 = ((float)k + 0.5f) / 64f - 0.5f;
						float num5 = ((float)j + 0.5f) / 64f - 0.5f;
						float num6 = Fbm(num4 * 4f + num3, num5 * 4f - num3);
						float num7 = Mathf.Sqrt(num4 * num4 + num5 * num5) / 0.46f + (num6 - 0.5f) * 0.4f;
						float num8 = Mathf.Clamp01(1f - num7);
						float num9 = num8 * num8 * (3f - 2f * num8) * Mathf.Lerp(0.65f, 1f, Fbm(num4 * 7f - num3, num5 * 7f + num3));
						float num10 = Mathf.Clamp01((0.5f - Mathf.Max(Mathf.Abs(num4), Mathf.Abs(num5))) / 0.06f);
						num9 *= num10 * num10 * (3f - 2f * num10);
						float num11 = (premultiplied ? num9 : 1f);
						array[(num2 + j) * 128 + num + k] = new Color(num11, num11, num11, num9);
					}
				}
			}
			val.SetPixels(array);
			val.Apply(true, false);
			return val;
		}

		private static float Fbm(float x, float y)
		{
			float num = 0f;
			float num2 = 0.5f;
			for (int i = 0; i < 3; i++)
			{
				num += num2 * Mathf.PerlinNoise(x, y);
				x *= 2.03f;
				y *= 2.03f;
				num2 *= 0.5f;
			}
			return num / 0.875f;
		}

		private static void DisableExtras(ParticleSystem system)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			CollisionModule collision = system.collision;
			((CollisionModule)(ref collision)).enabled = false;
			SubEmittersModule subEmitters = system.subEmitters;
			((SubEmittersModule)(ref subEmitters)).enabled = false;
			LightsModule lights = system.lights;
			((LightsModule)(ref lights)).enabled = false;
			TrailModule trails = system.trails;
			((TrailModule)(ref trails)).enabled = false;
			InheritVelocityModule inheritVelocity = system.inheritVelocity;
			((InheritVelocityModule)(ref inheritVelocity)).enabled = false;
			ForceOverLifetimeModule forceOverLifetime = system.forceOverLifetime;
			((ForceOverLifetimeModule)(ref forceOverLifetime)).enabled = false;
			ParticleSystemRenderer component = ((Component)system).GetComponent<ParticleSystemRenderer>();
			component.renderMode = (ParticleSystemRenderMode)0;
			((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)component).receiveShadows = false;
		}

		private static void StripClone(GameObject clone, Func<Component, bool> keep)
		{
			foreach (Transform item in ((IEnumerable)clone.transform).Cast<Transform>().ToList())
			{
				Object.DestroyImmediate((Object)(object)((Component)item).gameObject);
			}
			foreach (Component item2 in from c in clone.GetComponents<Component>()
				where !(c is Transform) && !keep(c)
				orderby (!(c is Behaviour)) ? 1 : 0
				select c)
			{
				Object.DestroyImmediate((Object)(object)item2);
			}
		}

		private static Mesh BuildCylinder(string name, float[] edges)
		{
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			List<Vector3> list2 = new List<Vector3>();
			List<Vector2> list3 = new List<Vector2>();
			List<List<int>> list4 = new List<List<int>>();
			float num = edges[0];
			float num2 = edges[^1];
			Vector3 val = default(Vector3);
			for (int i = 0; i < edges.Length - 1; i++)
			{
				List<int> list5 = new List<int>();
				float num3 = edges[i];
				float num4 = edges[i + 1];
				int count = list.Count;
				for (int j = 0; j <= 8; j++)
				{
					float num5 = (float)Math.PI * 2f * (float)j / 8f;
					((Vector3)(ref val))..ctor(Mathf.Cos(num5), 0f, Mathf.Sin(num5));
					list.Add(val * 0.006f + Vector3.up * num3);
					list.Add(val * 0.006f + Vector3.up * num4);
					list2.Add(val);
					list2.Add(val);
					list3.Add(new Vector2((float)j / 8f, (num3 - num) / (num2 - num)));
					list3.Add(new Vector2((float)j / 8f, (num4 - num) / (num2 - num)));
				}
				for (int k = 0; k < 8; k++)
				{
					int num6 = count + k * 2;
					list5.AddRange(new int[6]
					{
						num6,
						num6 + 1,
						num6 + 2,
						num6 + 2,
						num6 + 1,
						num6 + 3
					});
				}
				if (i == 0)
				{
					AddCap(list, list2, list3, list5, num, Vector3.down);
				}
				if (i == edges.Length - 2)
				{
					AddCap(list, list2, list3, list5, num2, Vector3.up);
				}
				list4.Add(list5);
			}
			Mesh val2 = new Mesh
			{
				name = name,
				hideFlags = (HideFlags)32
			};
			val2.SetVertices(list);
			val2.SetNormals(list2);
			val2.SetUVs(0, list3);
			val2.subMeshCount = list4.Count;
			for (int l = 0; l < list4.Count; l++)
			{
				val2.SetTriangles(list4[l], l);
			}
			val2.RecalculateBounds();
			val2.RecalculateTangents();
			return val2;
		}

		private static void AddCap(List<Vector3> vertices, List<Vector3> normals, List<Vector2> uvs, List<int> triangles, float y, Vector3 normal)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			int count = vertices.Count;
			vertices.Add(new Vector3(0f, y, 0f));
			normals.Add(normal);
			uvs.Add(new Vector2(0.5f, 0.5f));
			for (int i = 0; i < 8; i++)
			{
				float num = (float)Math.PI * 2f * (float)i / 8f;
				vertices.Add(new Vector3(Mathf.Cos(num) * 0.006f, y, Mathf.Sin(num) * 0.006f));
				normals.Add(normal);
				uvs.Add(new Vector2(0.5f + Mathf.Cos(num) / 2f, 0.5f + Mathf.Sin(num) / 2f));
			}
			for (int j = 0; j < 8; j++)
			{
				int num2 = count + 1 + j;
				int num3 = count + 1 + (j + 1) % 8;
				if (normal.y > 0f)
				{
					triangles.AddRange(new int[3] { count, num3, num2 });
				}
				else
				{
					triangles.AddRange(new int[3] { count, num2, num3 });
				}
			}
		}

		private static Sprite BuildIcon()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: 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_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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: 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_0149: 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)
			Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false)
			{
				name = "LethalSmokesIcon",
				hideFlags = (HideFlags)32,
				filterMode = (FilterMode)1
			};
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0.95f, 0.95f, 0.93f, 1f);
			Color val3 = default(Color);
			((Color)(ref val3))..ctor(0.85f, 0.55f, 0.25f, 1f);
			Color val4 = default(Color);
			((Color)(ref val4))..ctor(1f, 0.35f, 0.05f, 1f);
			Vector2 val5 = default(Vector2);
			((Vector2)(ref val5))..ctor(20f, 20f);
			Vector2 val6 = default(Vector2);
			((Vector2)(ref val6))..ctor(108f, 108f);
			Color[] array = (Color[])(object)new Color[16384];
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					Vector2 val7 = new Vector2((float)j + 0.5f, (float)i + 0.5f);
					Vector2 val8 = val6 - val5;
					float num = Vector2.Dot(val7 - val5, val8) / ((Vector2)(ref val8)).sqrMagnitude;
					float num2 = Vector2.Distance(val7, val5 + val8 * Mathf.Clamp01(num));
					Color val9 = Color.clear;
					if (num >= 0f && num <= 1f && num2 <= 7f)
					{
						val9 = ((num < 0.3f) ? val3 : ((num > 0.94f) ? val4 : val2));
					}
					array[i * 128 + j] = val9;
				}
			}
			val.SetPixels(array);
			val.Apply();
			Sprite obj = Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f));
			((Object)obj).name = "LethalSmokesIcon";
			((Object)obj).hideFlags = (HideFlags)32;
			return obj;
		}
	}
	internal class MouthCigarettePart : MonoBehaviour
	{
	}
	internal class EmberLight : MonoBehaviour
	{
		private const float FlickerDepth = 0.12f;

		private const float FlickerSpeed = 7f;

		private const float SmoulderDepth = 0.2f;

		private const float SmoulderSpeed = 0.5f;

		private const float BrightenBoost = 0.9f;

		private const float GlowBoost = 2.2f;

		private static readonly int EmissiveColor = Shader.PropertyToID("_EmissiveColor");

		private HDAdditionalLightData data;

		private Renderer ember;

		private Renderer charRing;

		private MaterialPropertyBlock block;

		private float seed;

		private float brightenStart = -1f;

		private float brightenDuration;

		private float fadeStart = -1f;

		private float fadeDuration;

		public HDAdditionalLightData Data => data;

		public float Heat { get; private set; }

		public void Init(HDAdditionalLightData lightData, Renderer emberRenderer, Renderer charRenderer)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			data = lightData;
			ember = emberRenderer;
			charRing = charRenderer;
			block = new MaterialPropertyBlock();
			seed = Random.value * 100f;
		}

		public void Brighten(float duration)
		{
			brightenStart = Time.time;
			brightenDuration = Mathf.Max(0.01f, duration);
		}

		public void FadeOut(float duration)
		{
			fadeStart = Time.time;
			fadeDuration = Mathf.Max(0.01f, duration);
		}

		private void Update()
		{
			//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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			float num = Time.time * 7f + seed;
			float num2 = 1f - 0.12f * (0.7f * Mathf.PerlinNoise(num, 0f) + 0.3f * Mathf.PerlinNoise(num * 2.7f, 5f));
			float num3 = 1f - 0.2f * Mathf.PerlinNoise(Time.time * 0.5f + seed, 9f);
			float num4 = 0f;
			if (brightenStart >= 0f)
			{
				float num5 = (Time.time - brightenStart) / brightenDuration;
				if (num5 >= 1f)
				{
					brightenStart = -1f;
				}
				else
				{
					num4 = Mathf.Sin(Mathf.Pow(num5, 0.8f) * (float)Math.PI);
				}
			}
			Heat = num4;
			float num6 = ((fadeStart >= 0f) ? (1f - Mathf.Clamp01((Time.time - fadeStart) / fadeDuration)) : 1f);
			if ((Object)(object)data != (Object)null)
			{
				data.lightDimmer = num2 * num3 * (1f + 0.9f * num4) * num6;
			}
			float num7 = num2 * num3 * (1f + 2.2f * num4) * num6;
			Color val = Color.Lerp(CigaretteVisuals.EmberColor, CigaretteVisuals.EmberHotColor, num4);
			SetGlow(ember, val * (2.2f * num7));
			SetGlow(charRing, CigaretteVisuals.EmberColor * (0.25f * num7 * (1f + 2f * num4)));
		}

		private void SetGlow(Renderer target, Color emission)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)target == (Object)null))
			{
				target.GetPropertyBlock(block);
				block.SetColor(EmissiveColor, emission);
				target.SetPropertyBlock(block);
			}
		}
	}
	internal class MouthCigarette : MonoBehaviour
	{
		private static readonly Vector3 ThirdPersonPosition = new Vector3(0f, -0.1f, 0.07f);

		private static readonly Vector3 ThirdPersonRotation = new Vector3(95f, 0f, 0f);

		private static readonly Vector3 FirstPersonPosition = new Vector3(0.02f, -0.09f, 0.16f);

		private static readonly Vector3 FirstPersonRotation = new Vector3(93f, -4f, 0f);

		public const float FadeSeconds = 1.2f;

		private const int TipPuffParticles = 6;

		private const int MouthPuffParticles = 60;

		private const float ExhaleStreamSeconds = 0.9f;

		private const float SparksAt = 0.6f;

		private const int DragSparks = 3;

		private const int AshFlakes = 5;

		private const float InhaleAt = 0.5f;

		private const float InhaleSeconds = 1.4f;

		private const float ArmsDownAt = 1.9f;

		private const float ExhaleAt = 2.3f;

		public const float DragSeconds = 4f;

		public const string DragAnimatorBool = "useTZPItem";

		public cons