Decompiled source of PyroOverdrive v1.0.2

PyroOverdrive.dll

Decompiled 44 minutes ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.Audio;

[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace PyroOverdrive;

public enum Kind
{
	Heuler,
	Dart,
	Rocket,
	Shell,
	Battery,
	Candle,
	Smoke
}
public class Def
{
	public string Name;

	public string File;

	public Kind Kind;

	public int Price;

	public float Mass;

	public float Drag;

	public float Ang;

	public float Sphere;

	public Vector3 FuseA;

	public Vector3 FuseB;

	public Vector3 Com;

	public float Size;

	public int Dmg;

	public int EnemyDmg;

	public float Force;

	public float Shake;

	public float Inv;

	public int Clip;

	public float Vol;

	public int Shots;

	public Color Col;
}
public static class DefTable
{
	private static Def D(string n, string file, Kind k, int price, float mass, float drag, float ang, float sph, float ax, float ay, float az, float bx, float by, float bz, float comY, float size, int dmg, int edmg, float force, float shake, float inv, int clip, float vol, int shots, float r, float g, float b)
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: 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)
		Def def = new Def();
		def.Name = n;
		def.File = file;
		def.Kind = k;
		def.Price = price;
		def.Mass = mass;
		def.Drag = drag;
		def.Ang = ang;
		def.Sphere = sph;
		def.FuseA = new Vector3(ax, ay, az);
		def.FuseB = new Vector3(bx, by, bz);
		def.Com = new Vector3(0f, comY, 0f);
		def.Size = size;
		def.Dmg = dmg;
		def.EnemyDmg = edmg;
		def.Force = force;
		def.Shake = shake;
		def.Inv = inv;
		def.Clip = clip;
		def.Vol = vol;
		def.Shots = shots;
		def.Col = new Color(r, g, b, 1f);
		return def;
	}

	public static Def[] All()
	{
		return new Def[17]
		{
			D("Heuler 100", "Heuler_100", Kind.Heuler, 220, 0.5f, 0.05f, 0.4f, 0f, 0.03f, 0.185f, 0.012f, -0.0135f, 0.12f, -0f, 0f, 3.2f, 50, 220, 2.5f, 1.5f, 25f, 0, 0.7f, 0, 1f, 0.9f, 0.5f),
			D("Dart 250", "Dart_250", Kind.Dart, 180, 0.3f, 0.05f, 0.4f, 0f, -0.02f, -0.1988f, 0.012f, -0f, -0.1408f, -0f, 0f, 2f, 40, 260, 2f, 1f, 15f, 0, 0.6f, 0, 1f, 0.6f, 0.3f),
			D("Dart 500", "Dart_500", Kind.Dart, 320, 0.45f, 0.05f, 0.4f, 0f, -0.025f, -0.2485f, 0.015f, -0f, -0.178f, -0f, 0f, 2.6f, 50, 340, 2.5f, 1.3f, 20f, 0, 0.7f, 0, 1f, 0.6f, 0.3f),
			D("Dart 750", "Dart_750", Kind.Dart, 460, 0.6f, 0.05f, 0.4f, 0f, -0.03f, -0.2982f, 0.018f, -0f, -0.2152f, -0f, 0f, 3.2f, 60, 420, 3f, 1.6f, 25f, 1, 0.7f, 0, 1f, 0.6f, 0.3f),
			D("Dart 1000", "Dart_1000", Kind.Dart, 600, 0.75f, 0.05f, 0.4f, 0f, -0.035f, -0.3479f, 0.021f, -0f, -0.2524f, -0f, 0f, 3.8f, 70, 500, 3.5f, 2f, 30f, 1, 0.8f, 0, 1f, 0.6f, 0.3f),
			D("Rakete Rot", "Rocket_Red", Kind.Rocket, 250, 0.35f, 0.1f, 0.4f, 0f, -0.012f, -0.25f, 0.003f, -0f, -0.147f, -0f, 0f, 2.2f, 20, 90, 1.5f, 0.8f, 15f, 0, 0.6f, 0, 1f, 0.15f, 0.1f),
			D("Rakete Blau", "Rocket_Blue", Kind.Rocket, 250, 0.35f, 0.1f, 0.4f, 0f, -0.012f, -0.25f, 0.003f, -0f, -0.147f, -0f, 0f, 2.2f, 20, 90, 1.5f, 0.8f, 15f, 0, 0.6f, 0, 0.2f, 0.45f, 1f),
			D("Rakete Gruen", "Rocket_Green", Kind.Rocket, 250, 0.35f, 0.1f, 0.4f, 0f, -0.012f, -0.25f, 0.003f, -0f, -0.147f, -0f, 0f, 2.2f, 20, 90, 1.5f, 0.8f, 15f, 0, 0.6f, 0, 0.3f, 1f, 0.2f),
			D("Rakete Gold", "Rocket_Gold", Kind.Rocket, 250, 0.35f, 0.1f, 0.4f, 0f, -0.012f, -0.25f, 0.003f, -0f, -0.147f, -0f, 0f, 2.2f, 20, 90, 1.5f, 0.8f, 15f, 0, 0.6f, 0, 1f, 0.8f, 0.25f),
			D("Kugelbombe 500", "Shell_500", Kind.Shell, 450, 1.2f, 0.05f, 0.2f, 0.08f, -0.04f, 0.1153f, 0.028f, -0f, 0.0873f, -0f, 0f, 5f, 80, 550, 4f, 2.5f, 35f, 1, 0.9f, 0, 0.9f, 0.9f, 1f),
			D("Kugelbombe 2500", "Shell_2500", Kind.Shell, 1100, 3.5f, 0.05f, 0.2f, 0.14f, -0.07f, 0.2018f, 0.049f, -0f, 0.1558f, -0f, 0f, 8f, 100, 1800, 6f, 4f, 60f, 2, 1f, 0, 1f, 0.8f, 0.3f),
			D("Kugelbombe 5000", "Shell_5000", Kind.Shell, 2200, 7f, 0.05f, 0.2f, 0.21f, -0.105f, 0.3027f, 0.0735f, -0f, 0.2357f, -0f, 0f, 12.5f, 150, 9999, 8f, 6f, 90f, 2, 1f, 0, 1f, 0.95f, 0.7f),
			D("Batterie 250", "Battery_250", Kind.Battery, 400, 1.5f, 0.05f, 0.6f, 0f, -0.086f, 0.03f, 0.13f, -0.056f, -0.045f, 0.096f, -0.016f, 1.6f, 15, 80, 1f, 0.3f, 8f, 0, 0.5f, 9, 1f, 1f, 1f),
			D("Batterie 500", "Battery_500", Kind.Battery, 650, 3f, 0.05f, 0.6f, 0f, -0.114f, 0f, 0.18f, -0.084f, -0.075f, 0.146f, -0.022f, 1.75f, 15, 95, 1f, 0.3f, 8f, 0, 0.5f, 16, 1f, 1f, 1f),
			D("Batterie 750", "Battery_750", Kind.Battery, 900, 4.5f, 0.05f, 0.6f, 0f, -0.1364f, -0.02f, 0.22f, -0.1064f, -0.095f, 0.186f, -0.026f, 1.9f, 18, 110, 1f, 0.3f, 8f, 0, 0.5f, 25, 1f, 1f, 1f),
			D("Roemisches Licht", "RomanCandle", Kind.Candle, 350, 0.4f, 0.05f, 0.4f, 0f, -0.0475f, 0.375f, 0.012f, -0.0145f, 0.295f, -0f, 0f, 1f, 10, 60, 0.5f, 0.2f, 5f, 0, 0.4f, 8, 1f, 0.5f, 0.9f),
			D("Rauchtopf Blackout", "SmokeGrenade", Kind.Smoke, 200, 0.6f, 0.05f, 0.4f, 0f, -0.06f, 0.145f, 0.015f, -0.027f, 0.085f, -0f, 0f, 0f, 0, 0, 0f, 0f, 0f, 0, 0f, 0, 0.2f, 0.2f, 0.22f)
		};
	}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("ThomasPlays.PyroOverdrive", "PyroOverdrive", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
	internal static ManualLogSource Log;

	internal static ConfigEntry<float> FuseMin;

	internal static ConfigEntry<float> FuseMax;

	internal static ConfigEntry<float> DamageMult;

	internal static ConfigEntry<float> SmokeTime;

	internal static ConfigEntry<float> BurnDps;

	internal static ConfigEntry<bool> SmokeInvincible;

	internal static AudioClip Hiss;

	internal static AudioClip Whistle;

	internal static AudioClip Piu;

	internal static AudioClip Thump;

	internal static AudioClip[] Booms = (AudioClip[])(object)new AudioClip[3];

	internal static Def[] Defs;

	private void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
		FuseMin = ((BaseUnityPlugin)this).Config.Bind<float>("Fuse", "FuseMin", 5f, "Shortest fuse time in seconds");
		FuseMax = ((BaseUnityPlugin)this).Config.Bind<float>("Fuse", "FuseMax", 7f, "Longest fuse time in seconds");
		DamageMult = ((BaseUnityPlugin)this).Config.Bind<float>("Balance", "DamageMultiplier", 1f, "Multiplies every damage value");
		SmokeTime = ((BaseUnityPlugin)this).Config.Bind<float>("Balance", "SmokeDuration", 25f, "Smoke duration in seconds");
		BurnDps = ((BaseUnityPlugin)this).Config.Bind<float>("Balance", "BurnDamagePerSecond", 25f, "Roman candle burn damage per second (5 s)");
		SmokeInvincible = ((BaseUnityPlugin)this).Config.Bind<bool>("Balance", "SmokeInvincible", true, "Players inside the smoke take no damage");
		Defs = DefTable.All();
		Hiss = Wav.Load("fuse_hiss.wav");
		Booms[0] = Wav.Load("explode_50.wav");
		Booms[1] = Wav.Load("explode_250.wav");
		Booms[2] = Wav.Load("explode_5000.wav");
		Whistle = Synth.Whistle();
		Piu = Synth.Piu();
		Thump = Synth.Thump();
		((Component)this).gameObject.AddComponent<Bootstrap>();
		Log.LogInfo((object)("PyroOverdrive 1.0.2 loaded (" + Defs.Length + " items)"));
	}

	internal static byte[] Bytes(string file)
	{
		try
		{
			Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(file);
			if (manifestResourceStream == null)
			{
				Log.LogWarning((object)("Asset missing: " + file));
				return null;
			}
			using MemoryStream memoryStream = new MemoryStream();
			byte[] array = new byte[81920];
			int count;
			while ((count = manifestResourceStream.Read(array, 0, array.Length)) > 0)
			{
				memoryStream.Write(array, 0, count);
			}
			return memoryStream.ToArray();
		}
		catch (Exception ex)
		{
			Log.LogError((object)("Asset error " + file + ": " + ex.Message));
			return null;
		}
	}
}
public class Bootstrap : MonoBehaviour
{
	private bool done;

	private float retry;

	private static readonly List<Object> keep = new List<Object>();

	private static readonly string[] TexProps = new string[4] { "_MainTex", "_BaseMap", "_BaseColorMap", "_AlbedoTex" };

	private static readonly string[] ColProps = new string[3] { "_Color", "_BaseColor", "_Tint" };

	private static readonly string[] FallbackShaders = new string[7] { "Standard", "Universal Render Pipeline/Lit", "Universal Render Pipeline/Simple Lit", "Universal Render Pipeline/Unlit", "Unlit/Texture", "Sprites/Default", "UI/Default" };

	private void Update()
	{
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Invalid comparison between Unknown and I4
		if (done)
		{
			return;
		}
		retry -= Time.deltaTime;
		if (retry > 0f)
		{
			return;
		}
		retry = 1f;
		StatsManager instance = StatsManager.instance;
		if ((Object)(object)instance == (Object)null || instance.itemDictionary == null || instance.itemDictionary.Count == 0)
		{
			return;
		}
		Item val = null;
		int num = -1;
		foreach (KeyValuePair<string, Item> item in instance.itemDictionary)
		{
			Item value = item.Value;
			if (!((Object)(object)value == (Object)null) && (int)value.itemType == 6)
			{
				string text = ((value.itemName != null) ? value.itemName.ToLower() : "");
				int num2 = 0;
				if (!text.Contains("duct") && !text.Contains("human") && !text.Contains("stun"))
				{
					num2 = 1;
				}
				if (text.Contains("explosive"))
				{
					num2 = 2;
				}
				if (num2 > num)
				{
					num = num2;
					val = value;
				}
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		GameObject val2 = null;
		try
		{
			if (val.prefab != null)
			{
				val2 = ((PrefabRef<GameObject>)(object)val.prefab).Prefab;
			}
		}
		catch (Exception)
		{
			return;
		}
		if ((Object)(object)val2 == (Object)null)
		{
			return;
		}
		done = true;
		int num3 = 0;
		for (int i = 0; i < Plugin.Defs.Length; i++)
		{
			try
			{
				BuildOne(val, val2, Plugin.Defs[i], i);
				num3++;
			}
			catch (Exception ex2)
			{
				Plugin.Log.LogError((object)("PyroOverdrive build error (" + Plugin.Defs[i].Name + "): " + ex2));
			}
		}
		Plugin.Log.LogInfo((object)("PyroOverdrive: " + num3 + "/" + Plugin.Defs.Length + " items registered (source: " + val.itemName + ")"));
	}

	private static void BuildOne(Item src, GameObject srcPrefab, Def d, int index)
	{
		//IL_0108: 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_01b5: 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_01e2: Expected O, but got Unknown
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		Item val = Object.Instantiate<Item>(src);
		((Object)val).name = "Item " + d.Name;
		val.itemName = d.Name;
		val.itemNameLocalized = null;
		val.value = Object.Instantiate<Value>(src.value);
		val.value.valueMin = d.Price;
		val.value.valueMax = d.Price;
		val.maxAmount = 6;
		val.maxAmountInShop = 2;
		val.maxPurchase = false;
		val.disabled = false;
		keep.Add((Object)(object)val);
		GameObject val2 = Object.Instantiate<GameObject>(srcPrefab);
		((Object)val2).name = "Item " + d.Name;
		val2.SetActive(false);
		Object.DontDestroyOnLoad((Object)(object)val2);
		keep.Add((Object)(object)val2);
		ItemAttributes component = val2.GetComponent<ItemAttributes>();
		component.item = val;
		Texture2D val3 = LoadTex(d.File + "_icon.png");
		if ((Object)(object)val3 != (Object)null)
		{
			component.icon = Sprite.Create(val3, new Rect(0f, 0f, (float)((Texture)val3).width, (float)((Texture)val3).height), new Vector2(0.5f, 0.5f), 100f);
		}
		ItemGrenade componentInChildren = val2.GetComponentInChildren<ItemGrenade>(true);
		if ((Object)(object)componentInChildren != (Object)null)
		{
			Object.DestroyImmediate((Object)(object)componentInChildren);
		}
		Material val4 = null;
		MeshRenderer[] componentsInChildren = val2.GetComponentsInChildren<MeshRenderer>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			if ((Object)(object)val4 == (Object)null && (Object)(object)((Renderer)componentsInChildren[i]).sharedMaterial != (Object)null)
			{
				val4 = ((Renderer)componentsInChildren[i]).sharedMaterial;
			}
			((Renderer)componentsInChildren[i]).enabled = false;
		}
		Dictionary<string, Mesh> dictionary = Obj.Load(Plugin.Bytes(d.File + ".obj"));
		Material mat = MakeMat(val4, Color.white, LoadTex(d.File + ".jpg"));
		GameObject val5 = new GameObject("PyroVisual");
		val5.transform.SetParent(val2.transform, false);
		float x = val2.transform.localScale.x;
		if (x > 0.0001f)
		{
			val5.transform.localScale = Vector3.one / x;
		}
		Collider[] componentsInChildren2 = val2.GetComponentsInChildren<Collider>(true);
		int num = -1;
		for (int j = 0; j < componentsInChildren2.Length; j++)
		{
			if (!componentsInChildren2[j].isTrigger)
			{
				num = j;
				break;
			}
		}
		string tag = ((num >= 0) ? ((Component)componentsInChildren2[num]).gameObject.tag : val2.tag);
		int layer = ((num >= 0) ? ((Component)componentsInChildren2[num]).gameObject.layer : val2.layer);
		PhysicsMaterial sharedMaterial = ((num >= 0) ? componentsInChildren2[num].sharedMaterial : null);
		int num2 = 0;
		foreach (KeyValuePair<string, Mesh> item in dictionary)
		{
			if (!item.Key.StartsWith("Col_"))
			{
				AddMesh(val5, item.Value, mat, item.Key);
				continue;
			}
			GameObject val6 = NewCol(val5, tag, layer);
			MeshCollider val7 = val6.AddComponent<MeshCollider>();
			val7.sharedMesh = item.Value;
			val7.convex = true;
			((Collider)val7).sharedMaterial = sharedMaterial;
			num2++;
		}
		if (d.Sphere > 0f)
		{
			SphereCollider val8 = NewCol(val5, tag, layer).AddComponent<SphereCollider>();
			val8.radius = d.Sphere;
			((Collider)val8).sharedMaterial = sharedMaterial;
			num2++;
		}
		if (num2 > 0)
		{
			for (int k = 0; k < componentsInChildren2.Length; k++)
			{
				if (!componentsInChildren2[k].isTrigger)
				{
					PhysGrabObjectCollider component2 = ((Component)componentsInChildren2[k]).GetComponent<PhysGrabObjectCollider>();
					Object.DestroyImmediate((Object)(object)componentsInChildren2[k]);
					if ((Object)(object)component2 != (Object)null)
					{
						Object.DestroyImmediate((Object)(object)component2);
					}
				}
			}
		}
		else
		{
			Plugin.Log.LogWarning((object)("PyroOverdrive: no colliders for " + d.Name + ", keeping grenade collider"));
		}
		Rigidbody component3 = val2.GetComponent<Rigidbody>();
		if ((Object)(object)component3 != (Object)null)
		{
			component3.mass = d.Mass;
			component3.drag = d.Drag;
			component3.angularDrag = d.Ang;
		}
		PyroItem pyroItem = val2.AddComponent<PyroItem>();
		pyroItem.defIndex = index;
		Items.RegisterItem(component);
	}

	private static GameObject NewCol(GameObject vis, string tag, int layer)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		GameObject val = new GameObject("PyroCol");
		val.transform.SetParent(vis.transform, false);
		val.tag = tag;
		val.layer = layer;
		val.AddComponent<PhysGrabObjectCollider>();
		return val;
	}

	private static Material MakeMat(Material baseMat, Color c, Texture2D tex)
	{
		//IL_000d: 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_00f1: Expected O, but got Unknown
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		Material val = ((!((Object)(object)baseMat != (Object)null)) ? ((Material)null) : new Material(baseMat));
		bool flag = (Object)(object)tex == (Object)null;
		bool flag2 = false;
		if ((Object)(object)val != (Object)null)
		{
			if ((Object)(object)tex != (Object)null)
			{
				for (int i = 0; i < TexProps.Length; i++)
				{
					if (val.HasProperty(TexProps[i]))
					{
						val.SetTexture(TexProps[i], (Texture)(object)tex);
						flag = true;
						break;
					}
				}
			}
			for (int j = 0; j < ColProps.Length; j++)
			{
				if (val.HasProperty(ColProps[j]))
				{
					val.SetColor(ColProps[j], c);
					flag2 = true;
					break;
				}
			}
		}
		if ((Object)(object)val == (Object)null || !flag || !flag2)
		{
			Shader val2 = null;
			for (int k = 0; k < FallbackShaders.Length; k++)
			{
				if (!((Object)(object)val2 == (Object)null))
				{
					break;
				}
				val2 = Shader.Find(FallbackShaders[k]);
			}
			if ((Object)(object)val2 != (Object)null)
			{
				val = new Material(val2);
				if ((Object)(object)tex != (Object)null)
				{
					val.mainTexture = (Texture)(object)tex;
				}
				for (int l = 0; l < ColProps.Length; l++)
				{
					if (val.HasProperty(ColProps[l]))
					{
						val.SetColor(ColProps[l], c);
						break;
					}
				}
				if (val.HasProperty("_Glossiness"))
				{
					val.SetFloat("_Glossiness", 0.15f);
				}
			}
		}
		return val;
	}

	private static void AddMesh(GameObject parent, Mesh m, Material mat, string name)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		GameObject val = new GameObject(name);
		val.transform.SetParent(parent.transform, false);
		val.AddComponent<MeshFilter>().sharedMesh = m;
		((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = mat;
	}

	private static Texture2D LoadTex(string file)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		byte[] array = Plugin.Bytes(file);
		if (array == null)
		{
			return null;
		}
		Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true);
		ImageConversion.LoadImage(val, array);
		return val;
	}
}
public static class Obj
{
	public static Dictionary<string, Mesh> Load(byte[] data)
	{
		//IL_0178: 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_0094: Expected O, but got Unknown
		//IL_01b7: 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_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: 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_02d7: Unknown result type (might be due to invalid IL or missing references)
		Dictionary<string, Mesh> dictionary = new Dictionary<string, Mesh>();
		if (data == null)
		{
			return dictionary;
		}
		CultureInfo invariantCulture = CultureInfo.InvariantCulture;
		List<Vector3> list = new List<Vector3>();
		List<Vector3> list2 = new List<Vector3>();
		List<Vector2> list3 = new List<Vector2>();
		string text = null;
		List<Vector3> list4 = null;
		List<Vector3> list5 = null;
		List<Vector2> list6 = null;
		List<int> list7 = null;
		Dictionary<string, int> dictionary2 = null;
		string[] array = Encoding.UTF8.GetString(data).Split('\n');
		for (int i = 0; i <= array.Length; i++)
		{
			string text2 = ((i < array.Length) ? array[i].Trim() : "o ");
			if (text2.StartsWith("o "))
			{
				if (text != null && list7.Count > 0)
				{
					Mesh val = new Mesh();
					((Object)val).name = text;
					val.SetVertices(list4);
					val.SetUVs(0, list6);
					val.SetTriangles(list7, 0);
					if (list5.Count == list4.Count)
					{
						val.SetNormals(list5);
					}
					else
					{
						val.RecalculateNormals();
					}
					val.RecalculateBounds();
					dictionary[text] = val;
				}
				text = text2.Substring(2).Trim();
				list4 = new List<Vector3>();
				list5 = new List<Vector3>();
				list6 = new List<Vector2>();
				list7 = new List<int>();
				dictionary2 = new Dictionary<string, int>();
				continue;
			}
			string[] array2 = text2.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
			if (array2.Length < 3)
			{
				continue;
			}
			if (array2[0] == "v")
			{
				list.Add(new Vector3(0f - float.Parse(array2[1], invariantCulture), float.Parse(array2[2], invariantCulture), float.Parse(array2[3], invariantCulture)));
			}
			else if (array2[0] == "vn")
			{
				list2.Add(new Vector3(0f - float.Parse(array2[1], invariantCulture), float.Parse(array2[2], invariantCulture), float.Parse(array2[3], invariantCulture)));
			}
			else if (array2[0] == "vt")
			{
				list3.Add(new Vector2(float.Parse(array2[1], invariantCulture), float.Parse(array2[2], invariantCulture)));
			}
			else
			{
				if (!(array2[0] == "f") || text == null || array2.Length < 4)
				{
					continue;
				}
				int[] array3 = new int[3];
				for (int j = 0; j < 3; j++)
				{
					string text3 = array2[j + 1];
					if (!dictionary2.TryGetValue(text3, out var value))
					{
						string[] array4 = text3.Split('/');
						value = (dictionary2[text3] = list4.Count);
						list4.Add(list[int.Parse(array4[0], invariantCulture) - 1]);
						list6.Add((array4.Length > 1 && array4[1].Length > 0) ? list3[int.Parse(array4[1], invariantCulture) - 1] : Vector2.zero);
						if (array4.Length > 2 && array4[2].Length > 0)
						{
							list5.Add(list2[int.Parse(array4[2], invariantCulture) - 1]);
						}
					}
					array3[j] = value;
				}
				list7.Add(array3[0]);
				list7.Add(array3[2]);
				list7.Add(array3[1]);
			}
		}
		return dictionary;
	}
}
public static class Wav
{
	public static AudioClip Load(string file)
	{
		try
		{
			byte[] array = Plugin.Bytes(file);
			if (array == null)
			{
				return null;
			}
			int num = BitConverter.ToInt16(array, 22);
			int num2 = BitConverter.ToInt32(array, 24);
			int i = 12;
			int num3 = 0;
			int num4;
			for (; i < array.Length - 8; i += 8 + num4)
			{
				num4 = BitConverter.ToInt32(array, i + 4);
				if (array[i] == 100 && array[i + 1] == 97 && array[i + 2] == 116 && array[i + 3] == 97)
				{
					i += 8;
					num3 = num4;
					break;
				}
			}
			if (num3 <= 0 || i + num3 > array.Length)
			{
				num3 = array.Length - i;
			}
			int num5 = num3 / 2;
			float[] array2 = new float[num5];
			for (int j = 0; j < num5; j++)
			{
				array2[j] = (float)BitConverter.ToInt16(array, i + j * 2) / 32768f;
			}
			AudioClip val = AudioClip.Create(file, num5 / num, num, num2, false);
			val.SetData(array2, 0);
			return val;
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)("WAV error " + file + ": " + ex.Message));
			return null;
		}
	}
}
public static class Synth
{
	private const int SR = 44100;

	private static AudioClip Make(string n, float[] d)
	{
		AudioClip val = AudioClip.Create(n, d.Length, 1, 44100, false);
		val.SetData(d, 0);
		return val;
	}

	public static AudioClip Whistle()
	{
		int num = 88200;
		float[] array = new float[num];
		double num2 = 0.0;
		Random random = new Random(1);
		for (int i = 0; i < num; i++)
		{
			float num3 = (float)i / (float)num;
			float num4 = Mathf.Lerp(1700f, 3700f, num3 * num3) + 140f * Mathf.Sin((float)i * 0.011f);
			num2 += Math.PI * 2.0 * (double)num4 / 44100.0;
			float num5 = (float)Math.Sin(num2);
			num5 = Mathf.Sign(num5) * Mathf.Sqrt(Mathf.Abs(num5));
			array[i] = (num5 * 0.45f + ((float)random.NextDouble() - 0.5f) * 0.18f) * Mathf.Min(1f, num3 * 25f);
		}
		return Make("pyro_whistle", array);
	}

	public static AudioClip Piu()
	{
		int num = 39689;
		float[] array = new float[num];
		double num2 = 0.0;
		Random random = new Random(2);
		for (int i = 0; i < num; i++)
		{
			float num3 = (float)i / (float)num;
			num2 += Math.PI * 2.0 * (double)(3400f * Mathf.Pow(0.2f, num3)) / 44100.0;
			float num4 = ((float)random.NextDouble() - 0.5f) * 0.25f;
			array[i] = ((float)Math.Sin(num2) * 0.55f + num4) * Mathf.Min(1f, num3 * 40f) * Mathf.Clamp01((1f - num3) * 3f);
		}
		return Make("pyro_piu", array);
	}

	public static AudioClip Thump()
	{
		int num = 13230;
		float[] array = new float[num];
		double num2 = 0.0;
		Random random = new Random(3);
		for (int i = 0; i < num; i++)
		{
			float num3 = (float)i / (float)num;
			num2 += Math.PI * 2.0 * (double)Mathf.Lerp(120f, 45f, num3) / 44100.0;
			float num4 = ((i < 400) ? (((float)random.NextDouble() - 0.5f) * (1f - (float)i / 400f)) : 0f);
			array[i] = (float)Math.Sin(num2) * 0.9f * Mathf.Exp((0f - num3) * 7f) + num4 * 0.8f;
		}
		return Make("pyro_thump", array);
	}
}
public class LightFade : MonoBehaviour
{
	public float life = 0.5f;

	private float t;

	private Light l;

	private float i0;

	private void Start()
	{
		l = ((Component)this).GetComponent<Light>();
		if ((Object)(object)l != (Object)null)
		{
			i0 = l.intensity;
		}
	}

	private void Update()
	{
		t += Time.deltaTime;
		if ((Object)(object)l != (Object)null)
		{
			l.intensity = i0 * Mathf.Clamp01(1f - t / life);
		}
	}
}
public static class Fx
{
	private static Material mat;

	public static Material Mat()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Expected O, but got Unknown
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)mat != (Object)null)
		{
			return mat;
		}
		Texture2D val = new Texture2D(32, 32, (TextureFormat)4, false);
		for (int i = 0; i < 32; i++)
		{
			for (int j = 0; j < 32; j++)
			{
				float num = ((float)j - 15.5f) / 15.5f;
				float num2 = ((float)i - 15.5f) / 15.5f;
				float num3 = Mathf.Clamp01(1f - Mathf.Sqrt(num * num + num2 * num2));
				val.SetPixel(j, i, new Color(1f, 1f, 1f, num3 * num3));
			}
		}
		val.Apply();
		Shader val2 = Shader.Find("Sprites/Default");
		if ((Object)(object)val2 == (Object)null)
		{
			val2 = Shader.Find("UI/Default");
		}
		mat = new Material(val2);
		mat.mainTexture = (Texture)(object)val;
		return mat;
	}

	public static ParticleSystem Sparks(Transform parent, Vector3 local, float rate, float speedMin, float speedMax, float size, float life, Color a, Color b, float grav, int dir)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("PyroPS");
		val.transform.SetParent(parent, false);
		val.transform.localPosition = local;
		if (dir != 0)
		{
			val.transform.localRotation = Quaternion.Euler((dir > 0) ? (-90f) : 90f, 0f, 0f);
		}
		ParticleSystem val2 = val.AddComponent<ParticleSystem>();
		val2.Stop(true, (ParticleSystemStopBehavior)0);
		MainModule main = val2.main;
		((MainModule)(ref main)).playOnAwake = false;
		((MainModule)(ref main)).loop = true;
		((MainModule)(ref main)).startLifetime = new MinMaxCurve(life * 0.6f, life);
		((MainModule)(ref main)).startSpeed = new MinMaxCurve(speedMin, speedMax);
		((MainModule)(ref main)).startSize = new MinMaxCurve(size * 0.5f, size);
		((MainModule)(ref main)).startColor = new MinMaxGradient(a, b);
		((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(grav);
		((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
		((MainModule)(ref main)).maxParticles = 600;
		EmissionModule emission = val2.emission;
		((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(rate);
		ShapeModule shape = val2.shape;
		if (dir != 0)
		{
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
			((ShapeModule)(ref shape)).angle = 12f;
			((ShapeModule)(ref shape)).radius = 0.005f;
		}
		else
		{
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = 0.01f;
		}
		((Renderer)val.GetComponent<ParticleSystemRenderer>()).sharedMaterial = Mat();
		return val2;
	}

	private static void FadeOut(ParticleSystem ps)
	{
		//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_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Expected O, but got Unknown
		//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_003f: 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_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: 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)
		ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime;
		((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
		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, 0.1f),
			new GradientAlphaKey(1f, 0.65f),
			new GradientAlphaKey(0f, 1f)
		});
		((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val);
	}

	public static void Burst(Vector3 pos, Color c, int count, float speed, float life, float size, float lightRange)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: 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_0035: 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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: 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)
		GameObject val = new GameObject("PyroBurst");
		val.transform.position = pos;
		ParticleSystem val2 = Sparks(val.transform, Vector3.zero, 0f, speed * 0.35f, speed, size, life, c, Color.Lerp(c, Color.white, 0.5f), 0.35f, 0);
		MainModule main = val2.main;
		((MainModule)(ref main)).maxParticles = count + 10;
		FadeOut(val2);
		val2.Play();
		val2.Emit(count);
		if (lightRange > 0f)
		{
			Light val3 = val.AddComponent<Light>();
			val3.type = (LightType)2;
			val3.color = c;
			val3.range = lightRange;
			val3.intensity = 8f;
			val.AddComponent<LightFade>().life = 0.6f;
		}
		Object.Destroy((Object)(object)val, life + 0.6f);
	}

	public static GameObject Smoke(Vector3 pos, float duration)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: 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_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: 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)
		GameObject val = new GameObject("PyroSmoke");
		val.transform.position = pos;
		ParticleSystem val2 = Sparks(val.transform, Vector3.zero, 16f, 0.5f, 2.2f, 5.5f, 10f, new Color(0.2f, 0.2f, 0.22f, 0.95f), new Color(0.3f, 0.3f, 0.33f, 0.9f), -0.01f, 0);
		MainModule main = val2.main;
		((MainModule)(ref main)).loop = false;
		((MainModule)(ref main)).duration = duration;
		((MainModule)(ref main)).maxParticles = 400;
		ShapeModule shape = val2.shape;
		((ShapeModule)(ref shape)).radius = 0.6f;
		FadeOut(val2);
		val2.Play();
		val.AddComponent<PyroSmokeZone>().life = duration + 5f;
		Object.Destroy((Object)(object)val, duration + 12f);
		return val;
	}

	public static AudioSource Sound(Vector3 pos, AudioClip clip, float vol, float min, float max, AudioMixerGroup grp, float pitch, Transform follow)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)clip == (Object)null)
		{
			return null;
		}
		GameObject val = new GameObject("PyroSnd");
		if ((Object)(object)follow != (Object)null)
		{
			val.transform.SetParent(follow, false);
		}
		val.transform.position = pos;
		AudioSource val2 = val.AddComponent<AudioSource>();
		val2.outputAudioMixerGroup = grp;
		val2.clip = clip;
		val2.spatialBlend = 1f;
		val2.volume = vol;
		val2.pitch = pitch;
		val2.rolloffMode = (AudioRolloffMode)0;
		val2.minDistance = min;
		val2.maxDistance = max;
		val2.dopplerLevel = (((Object)(object)follow != (Object)null) ? 1f : 0f);
		val2.spread = 25f;
		val2.Play();
		Object.Destroy((Object)(object)val, clip.length / Mathf.Max(0.1f, pitch) + 0.3f);
		return val2;
	}
}
public class PyroStar : MonoBehaviour
{
	private Vector3 vel;

	private float life;

	private float grav;

	private bool candle;

	private int bounces;

	private Color col;

	private ParticleScriptExplosion pse;

	private Def d;

	private Transform owner;

	public static void Spawn(Vector3 pos, Vector3 dir, Color c, bool candle, float life, ParticleScriptExplosion pse, Def d, Transform owner)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0011: 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_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_005e: 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_0082: 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_00a1: 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)
		GameObject val = new GameObject("PyroStar");
		val.transform.position = pos;
		PyroStar pyroStar = val.AddComponent<PyroStar>();
		pyroStar.vel = dir * (candle ? 22f : 11f);
		pyroStar.life = life;
		pyroStar.grav = (candle ? 3f : 6f);
		pyroStar.candle = candle;
		pyroStar.col = c;
		pyroStar.pse = pse;
		pyroStar.d = d;
		pyroStar.owner = owner;
		Fx.Sparks(val.transform, Vector3.zero, 90f, 0.1f, 0.6f, 0.07f, 0.35f, c, Color.white, 0.2f, 0).Play();
		Light val2 = val.AddComponent<Light>();
		val2.type = (LightType)2;
		val2.color = c;
		val2.range = 4f;
		val2.intensity = 3f;
	}

	private void Update()
	{
		//IL_0008: 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_0018: 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_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_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00fa: 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_010b: 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)
		float deltaTime = Time.deltaTime;
		vel += Vector3.down * grav * deltaTime;
		Vector3 val = vel * deltaTime;
		float magnitude = ((Vector3)(ref val)).magnitude;
		RaycastHit val2 = default(RaycastHit);
		if (magnitude > 0.0001f && Physics.Raycast(((Component)this).transform.position, val / magnitude, ref val2, magnitude + 0.05f, -1, (QueryTriggerInteraction)1) && ((Object)(object)owner == (Object)null || !((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(owner)))
		{
			if (!candle && bounces < 2 && ((RaycastHit)(ref val2)).normal.y < -0.5f)
			{
				vel = Vector3.Reflect(vel, ((RaycastHit)(ref val2)).normal) * 0.5f;
				bounces++;
				((Component)this).transform.position = ((RaycastHit)(ref val2)).point + ((RaycastHit)(ref val2)).normal * 0.05f;
			}
			else
			{
				Explode(((RaycastHit)(ref val2)).point - val / magnitude * 0.05f, ((Component)((RaycastHit)(ref val2)).collider).transform);
			}
			return;
		}
		Transform transform = ((Component)this).transform;
		transform.position += val;
		life -= deltaTime;
		if (life <= 0f)
		{
			Explode(((Component)this).transform.position, null);
		}
	}

	private void Explode(Vector3 pos, Transform hitT)
	{
		//IL_0072: 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_001f: 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)
		float value = Plugin.DamageMult.Value;
		if ((Object)(object)pse != (Object)null)
		{
			pse.Spawn(pos, d.Size, (int)((float)d.Dmg * value), (int)((float)d.EnemyDmg * value), d.Force, false, false, d.Shake, d.Inv);
		}
		Fx.Burst(pos, col, 40, 6f, 0.8f, 0.09f, 6f);
		if (candle)
		{
			PyroFire.Spawn(pos, hitT, pse);
		}
		Object.Destroy((Object)(object)((Component)this).gameObject);
	}
}
public class PyroFire : MonoBehaviour
{
	private Transform target;

	private Vector3 local;

	private ParticleScriptExplosion pse;

	private float t;

	private int ticks;

	public static void Spawn(Vector3 pos, Transform target, ParticleScriptExplosion pse)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: 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)
		GameObject val = new GameObject("PyroFire");
		val.transform.position = pos;
		PyroFire pyroFire = val.AddComponent<PyroFire>();
		pyroFire.target = target;
		pyroFire.pse = pse;
		if ((Object)(object)target != (Object)null)
		{
			pyroFire.local = target.InverseTransformPoint(pos);
		}
		Fx.Sparks(val.transform, Vector3.zero, 45f, 0.3f, 1.2f, 0.25f, 0.6f, new Color(1f, 0.55f, 0.1f), new Color(1f, 0.85f, 0.3f), -0.4f, 0).Play();
		Light val2 = val.AddComponent<Light>();
		val2.type = (LightType)2;
		val2.color = new Color(1f, 0.6f, 0.2f);
		val2.range = 4f;
		val2.intensity = 2.5f;
		Object.Destroy((Object)(object)val, 5.2f);
	}

	private void Update()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)target != (Object)null)
		{
			((Component)this).transform.position = target.TransformPoint(local);
		}
		t += Time.deltaTime;
		if (t >= 1f && ticks < 5)
		{
			t = 0f;
			ticks++;
			if ((Object)(object)pse != (Object)null)
			{
				pse.Spawn(((Component)this).transform.position, 0.9f, 3, (int)(Plugin.BurnDps.Value * Plugin.DamageMult.Value), 0f, false, true, 0f, 0f);
			}
		}
	}
}
public class PyroSmokeZone : MonoBehaviour
{
	public float life = 30f;

	private float tick;

	private readonly List<string> hidden = new List<string>();

	private static FieldInfo noVisionField;

	private static IList NoVision()
	{
		if ((Object)(object)EnemyDirector.instance == (Object)null)
		{
			return null;
		}
		if (noVisionField == null)
		{
			noVisionField = typeof(EnemyDirector).GetField("debugNoVision", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		if (!(noVisionField != null))
		{
			return null;
		}
		return noVisionField.GetValue(EnemyDirector.instance) as IList;
	}

	private static bool Inside(PlayerAvatar pa, Vector3 c)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: 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_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = (((Object)(object)pa.playerTransform != (Object)null) ? pa.playerTransform.position : ((Component)pa).transform.position);
		Vector3 val2 = val - c;
		return ((Vector3)(ref val2)).sqrMagnitude < 56f;
	}

	private void Update()
	{
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: 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_01f1: 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_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: 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)
		life -= Time.deltaTime;
		if (life <= 0f)
		{
			Release();
			((Behaviour)this).enabled = false;
			return;
		}
		tick -= Time.deltaTime;
		if (tick > 0f)
		{
			return;
		}
		tick = 0.25f;
		Vector3 position = ((Component)this).transform.position;
		PlayerAvatar val = SemiFunc.PlayerAvatarLocal();
		if (Plugin.SmokeInvincible.Value && (Object)(object)val != (Object)null && Inside(val, position))
		{
			PlayerHealth val2 = ((Component)val).GetComponentInChildren<PlayerHealth>(true);
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = ((Component)val).GetComponentInParent<PlayerHealth>();
			}
			if ((Object)(object)val2 != (Object)null)
			{
				val2.InvincibleSet(0.6f);
			}
		}
		if (!SemiFunc.IsMasterClientOrSingleplayer())
		{
			return;
		}
		IList list = NoVision();
		List<PlayerAvatar> list2 = SemiFunc.PlayerGetAll();
		for (int i = 0; i < list2.Count; i++)
		{
			PlayerAvatar val3 = list2[i];
			if ((Object)(object)val3 == (Object)null)
			{
				continue;
			}
			string text = SemiFunc.PlayerGetSteamID(val3);
			if (Inside(val3, position))
			{
				val3.OverrideDisableEnemyInvestigate(0.6f);
				if (list != null && text != null && !list.Contains(text))
				{
					list.Add(text);
					hidden.Add(text);
				}
			}
			else if (text != null && hidden.Contains(text))
			{
				hidden.Remove(text);
				list?.Remove(text);
			}
		}
		if ((Object)(object)EnemyDirector.instance == (Object)null || EnemyDirector.instance.enemiesSpawned == null)
		{
			return;
		}
		foreach (EnemyParent item in EnemyDirector.instance.enemiesSpawned)
		{
			if ((Object)(object)item == (Object)null)
			{
				continue;
			}
			Enemy componentInChildren = ((Component)item).GetComponentInChildren<Enemy>(true);
			if ((Object)(object)componentInChildren == (Object)null)
			{
				continue;
			}
			EnemyRigidbody componentInChildren2 = ((Component)item).GetComponentInChildren<EnemyRigidbody>(true);
			Vector3 val4 = (((Object)(object)componentInChildren2 != (Object)null) ? ((Component)componentInChildren2).transform.position : ((Component)componentInChildren).transform.position);
			Vector3 val5 = val4 - position;
			if (!(((Vector3)(ref val5)).sqrMagnitude > 90f))
			{
				componentInChildren.DisableChase(0.6f);
				EnemyVision componentInChildren3 = ((Component)item).GetComponentInChildren<EnemyVision>(true);
				if ((Object)(object)componentInChildren3 != (Object)null)
				{
					componentInChildren3.DisableVision(0.6f);
				}
			}
		}
	}

	private void Release()
	{
		IList list = NoVision();
		if (list != null)
		{
			for (int i = 0; i < hidden.Count; i++)
			{
				list.Remove(hidden[i]);
			}
		}
		hidden.Clear();
	}

	private void OnDestroy()
	{
		Release();
	}
}
public class PyroItem : MonoBehaviourPun
{
	public int defIndex = -1;

	private Def d;

	private ItemToggle toggle;

	private PhysGrabObject pgo;

	private Rigidbody rb;

	private ParticleScriptExplosion pse;

	private AudioMixerGroup grp;

	private Transform vis;

	private Transform fx;

	private ParticleSystem spark;

	private ParticleSystem jet;

	private Light glow;

	private AudioSource hiss;

	private bool lit;

	private bool active;

	private bool done;

	private bool sent;

	private bool stuck;

	private bool whistling;

	private float timer;

	private float fuseDur;

	private float phaseT;

	private float shotT;

	private float tick;

	private float endT;

	private Vector3 flyDir;

	private int shotsFired;

	private FixedJoint joint;

	private GameObject cloud;

	private static readonly Color[] Pal = (Color[])(object)new Color[5]
	{
		new Color(1f, 0.25f, 0.25f),
		new Color(0.3f, 0.55f, 1f),
		new Color(0.35f, 1f, 0.35f),
		new Color(1f, 0.9f, 0.2f),
		new Color(0.8f, 0.4f, 1f)
	};

	private void Start()
	{
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Expected O, but got Unknown
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: 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_02e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		if (defIndex >= 0 && defIndex < Plugin.Defs.Length)
		{
			d = Plugin.Defs[defIndex];
		}
		else
		{
			for (int i = 0; i < Plugin.Defs.Length; i++)
			{
				if (((Object)this).name.Contains("Item " + Plugin.Defs[i].Name))
				{
					d = Plugin.Defs[i];
				}
			}
		}
		if (d == null)
		{
			Plugin.Log.LogWarning((object)("PyroItem without definition: " + ((Object)this).name));
			return;
		}
		toggle = ((Component)this).GetComponent<ItemToggle>();
		pgo = ((Component)this).GetComponent<PhysGrabObject>();
		rb = ((Component)this).GetComponent<Rigidbody>();
		pse = ((Component)this).GetComponent<ParticleScriptExplosion>();
		if ((Object)(object)pse == (Object)null)
		{
			pse = ((Component)this).GetComponentInChildren<ParticleScriptExplosion>(true);
		}
		AudioSource[] componentsInChildren = ((Component)this).GetComponentsInChildren<AudioSource>(true);
		for (int j = 0; j < componentsInChildren.Length; j++)
		{
			if ((Object)(object)componentsInChildren[j].outputAudioMixerGroup != (Object)null)
			{
				grp = componentsInChildren[j].outputAudioMixerGroup;
				break;
			}
		}
		vis = ((Component)this).transform.Find("PyroVisual");
		if ((Object)(object)vis == (Object)null)
		{
			vis = ((Component)this).transform;
		}
		if ((Object)(object)rb != (Object)null && d.Com != Vector3.zero)
		{
			rb.centerOfMass = d.Com;
		}
		GameObject val = new GameObject("PyroFuseFX");
		val.transform.SetParent(vis, false);
		val.transform.localPosition = d.FuseA;
		fx = val.transform;
		glow = val.AddComponent<Light>();
		glow.type = (LightType)2;
		glow.color = new Color(1f, 0.7f, 0.3f);
		glow.range = 1.5f;
		glow.intensity = 0f;
		((Behaviour)glow).enabled = false;
		hiss = val.AddComponent<AudioSource>();
		hiss.clip = Plugin.Hiss;
		hiss.loop = true;
		hiss.spatialBlend = 1f;
		hiss.outputAudioMixerGroup = grp;
		hiss.rolloffMode = (AudioRolloffMode)1;
		hiss.minDistance = 1f;
		hiss.maxDistance = 25f;
		hiss.playOnAwake = false;
		hiss.volume = 0.85f;
		spark = Fx.Sparks(fx, Vector3.zero, 60f, 0.6f, 1.6f, 0.02f, 0.35f, new Color(1f, 0.85f, 0.4f), new Color(1f, 0.45f, 0.1f), 0.6f, 0);
	}

	private bool Grabbed()
	{
		if ((Object)(object)pgo != (Object)null)
		{
			return pgo.grabbed;
		}
		return false;
	}

	private void Update()
	{
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		if (d == null || done)
		{
			return;
		}
		bool flag = SemiFunc.IsMasterClientOrSingleplayer();
		if (!lit)
		{
			if (flag && !sent && (Object)(object)toggle != (Object)null && toggle.toggleState)
			{
				sent = true;
				float num = Random.Range(Plugin.FuseMin.Value, Mathf.Max(Plugin.FuseMin.Value, Plugin.FuseMax.Value));
				if (SemiFunc.IsMultiplayer())
				{
					((MonoBehaviourPun)this).photonView.RPC("IgniteRPC", (RpcTarget)0, new object[1] { num });
				}
				else
				{
					IgniteRPC(num);
				}
			}
		}
		else if (!active)
		{
			timer -= Time.deltaTime;
			fx.localPosition = Vector3.Lerp(d.FuseA, d.FuseB, 1f - Mathf.Clamp01(timer / fuseDur));
			glow.intensity = 1.5f + Random.value * 2.5f;
			if (d.Kind == Kind.Heuler && timer <= 2f)
			{
				HeulerTick(flag);
			}
			if (stuck && Grabbed() && (Object)(object)joint != (Object)null)
			{
				Object.Destroy((Object)(object)joint);
				stuck = false;
			}
			if (!(timer <= 0f) || !flag || sent)
			{
				return;
			}
			sent = true;
			if (d.Kind == Kind.Heuler || d.Kind == Kind.Shell)
			{
				SendBoom();
			}
			else if (d.Kind == Kind.Rocket || d.Kind == Kind.Dart)
			{
				Vector3 val = AimDir();
				if (SemiFunc.IsMultiplayer())
				{
					((MonoBehaviourPun)this).photonView.RPC("LaunchRPC", (RpcTarget)0, new object[1] { val });
				}
				else
				{
					LaunchRPC(val);
				}
			}
			else if (SemiFunc.IsMultiplayer())
			{
				((MonoBehaviourPun)this).photonView.RPC("PhaseRPC", (RpcTarget)0, new object[0]);
			}
			else
			{
				PhaseRPC();
			}
		}
		else
		{
			ActiveTick(flag);
		}
	}

	private void FixedUpdate()
	{
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: 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_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: 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_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		if (d == null || done || (Object)(object)rb == (Object)null || !SemiFunc.IsMasterClientOrSingleplayer())
		{
			return;
		}
		if (active && (d.Kind == Kind.Rocket || d.Kind == Kind.Dart))
		{
			if ((Object)(object)pgo != (Object)null)
			{
				pgo.OverrideZeroGravity(0.2f);
			}
			rb.velocity = flyDir * ((d.Kind == Kind.Rocket) ? 22f : 26f);
			rb.angularVelocity = Vector3.zero;
			rb.MoveRotation(Quaternion.FromToRotation(((Component)this).transform.up, flyDir) * rb.rotation);
		}
		else if (d.Kind == Kind.Dart && !stuck && !Grabbed())
		{
			Vector3 velocity = rb.velocity;
			if (((Vector3)(ref velocity)).sqrMagnitude > 9f)
			{
				Quaternion val = Quaternion.FromToRotation(((Component)this).transform.up, ((Vector3)(ref velocity)).normalized) * rb.rotation;
				rb.MoveRotation(Quaternion.Slerp(rb.rotation, val, 12f * Time.fixedDeltaTime));
				Rigidbody obj = rb;
				obj.angularVelocity *= 0.8f;
			}
		}
	}

	private Vector3 AimDir()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = ((Component)this).transform.up;
		if (Grabbed() && pgo.playerGrabbing != null && pgo.playerGrabbing.Count > 0)
		{
			PhysGrabber val2 = pgo.playerGrabbing[0];
			PlayerAvatar val3 = (((Object)(object)val2 != (Object)null) ? val2.playerAvatar : null);
			if ((Object)(object)val3 != (Object)null)
			{
				if ((Object)(object)val3 == (Object)(object)SemiFunc.PlayerAvatarLocal() && (Object)(object)GameDirector.instance != (Object)null && (Object)(object)GameDirector.instance.MainCamera != (Object)null)
				{
					val = ((Component)GameDirector.instance.MainCamera).transform.forward;
				}
				else
				{
					Transform val4 = SemiFunc.PlayerGetFaceEyeTransform(val3);
					if ((Object)(object)val4 != (Object)null)
					{
						val = val4.forward;
					}
				}
			}
		}
		return ((Vector3)(ref val)).normalized;
	}

	private void HeulerTick(bool master)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: 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_0150: Unknown result type (might be due to invalid IL or missing references)
		if (!whistling)
		{
			whistling = true;
			Fx.Sound(((Component)this).transform.position, Plugin.Whistle, 1f, 4f, 65f, grp, 1f, ((Component)this).transform);
			jet = Fx.Sparks(vis, d.FuseB, 220f, 2.5f, 5f, 0.03f, 0.4f, Color.white, new Color(1f, 0.9f, 0.4f), 0.3f, 1);
			jet.Play();
		}
		if (!master)
		{
			return;
		}
		tick -= Time.deltaTime;
		if (!(tick > 0f))
		{
			tick = 0.15f;
			SemiFunc.EnemyInvestigate(((Component)this).transform.position, 25f, false);
			if ((Object)(object)rb != (Object)null && !Grabbed())
			{
				rb.AddForce(new Vector3(Random.Range(-1f, 1f), 0.5f, Random.Range(-1f, 1f)) * 0.6f, (ForceMode)2);
				rb.AddTorque(Random.insideUnitSphere * 2f, (ForceMode)2);
			}
		}
	}

	private void ActiveTick(bool master)
	{
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: 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_016a: 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_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_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: 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_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: 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_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: 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_01fd: Unknown result type (might be due to invalid IL or missing references)
		phaseT += Time.deltaTime;
		if (d.Kind == Kind.Rocket || d.Kind == Kind.Dart)
		{
			if (master && phaseT >= 1.4f && !sent)
			{
				sent = true;
				SendBoom();
			}
			return;
		}
		if (d.Kind == Kind.Smoke)
		{
			if ((Object)(object)cloud != (Object)null)
			{
				cloud.transform.position = ((Component)this).transform.position;
			}
			if (master && phaseT >= Plugin.SmokeTime.Value)
			{
				Kill();
			}
			return;
		}
		bool flag = d.Kind == Kind.Candle;
		if (!master)
		{
			return;
		}
		if (shotsFired < d.Shots)
		{
			shotT -= Time.deltaTime;
			if (!(shotT > 0f))
			{
				shotT = (flag ? 0.8f : 0.5f);
				Vector3 val;
				Vector3 val2;
				if (flag)
				{
					val = ((Component)this).transform.position + ((Component)this).transform.up * 0.37f;
					val2 = ((Component)this).transform.up;
				}
				else
				{
					val = ((Component)this).transform.position + ((Component)this).transform.up * 0.16f + ((Component)this).transform.right * Random.Range(-0.05f, 0.05f) + ((Component)this).transform.forward * Random.Range(-0.05f, 0.05f);
					Vector3 val3 = ((Component)this).transform.up + Random.insideUnitSphere * 0.22f;
					val2 = ((Vector3)(ref val3)).normalized;
				}
				if (SemiFunc.IsMultiplayer())
				{
					((MonoBehaviourPun)this).photonView.RPC("ShotRPC", (RpcTarget)0, new object[3] { val, val2, shotsFired });
				}
				else
				{
					ShotRPC(val, val2, shotsFired);
				}
				shotsFired++;
				endT = (flag ? 7f : 2f);
			}
		}
		else
		{
			endT -= Time.deltaTime;
			if (endT <= 0f)
			{
				Kill();
			}
		}
	}

	private void OnCollisionEnter(Collision c)
	{
		//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_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: 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)
		if (d == null || done || !lit || !SemiFunc.IsMasterClientOrSingleplayer())
		{
			return;
		}
		if ((d.Kind == Kind.Rocket || d.Kind == Kind.Dart) && active)
		{
			if (phaseT > 0.12f && !sent)
			{
				sent = true;
				SendBoom();
			}
		}
		else
		{
			if (d.Kind != Kind.Dart || stuck || Grabbed() || c.contactCount <= 0)
			{
				return;
			}
			Vector3 relativeVelocity = c.relativeVelocity;
			if (((Vector3)(ref relativeVelocity)).magnitude > 4f)
			{
				Vector3 up = ((Component)this).transform.up;
				ContactPoint contact = c.GetContact(0);
				if (Vector3.Dot(up, -((ContactPoint)(ref contact)).normal) > 0.4f)
				{
					stuck = true;
					joint = ((Component)this).gameObject.AddComponent<FixedJoint>();
					((Joint)joint).connectedBody = c.rigidbody;
				}
			}
		}
	}

	private void SendBoom()
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.IsMultiplayer())
		{
			((MonoBehaviourPun)this).photonView.RPC("BoomRPC", (RpcTarget)0, new object[1] { ((Component)this).transform.position });
		}
		else
		{
			BoomRPC(((Component)this).transform.position);
		}
	}

	private void Kill()
	{
		if (!done)
		{
			done = true;
			if ((Object)(object)joint != (Object)null)
			{
				Object.Destroy((Object)(object)joint);
			}
			if ((Object)(object)pgo != (Object)null)
			{
				pgo.DestroyPhysGrabObject();
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}

	[PunRPC]
	public void IgniteRPC(float duration)
	{
		if (!lit && d != null)
		{
			lit = true;
			sent = false;
			timer = duration;
			fuseDur = duration;
			if ((Object)(object)spark != (Object)null)
			{
				spark.Play();
			}
			if ((Object)(object)glow != (Object)null)
			{
				((Behaviour)glow).enabled = true;
			}
			if ((Object)(object)hiss != (Object)null && (Object)(object)hiss.clip != (Object)null)
			{
				hiss.Play();
			}
		}
	}

	[PunRPC]
	public void PhaseRPC()
	{
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		if (active || d == null)
		{
			return;
		}
		active = true;
		sent = false;
		phaseT = 0f;
		shotT = 0.3f;
		tick = 0f;
		if ((Object)(object)spark != (Object)null)
		{
			spark.Stop();
		}
		if ((Object)(object)glow != (Object)null)
		{
			((Behaviour)glow).enabled = false;
		}
		if (d.Kind == Kind.Smoke)
		{
			if ((Object)(object)hiss != (Object)null)
			{
				hiss.pitch = 0.6f;
			}
			cloud = Fx.Smoke(((Component)this).transform.position, Plugin.SmokeTime.Value);
		}
		else if ((Object)(object)hiss != (Object)null)
		{
			hiss.Stop();
		}
	}

	[PunRPC]
	public void LaunchRPC(Vector3 dir)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: 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_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		if (!active && d != null)
		{
			active = true;
			sent = false;
			phaseT = 0f;
			flyDir = dir;
			if ((Object)(object)spark != (Object)null)
			{
				spark.Stop();
			}
			if ((Object)(object)glow != (Object)null)
			{
				((Behaviour)glow).enabled = false;
			}
			if ((Object)(object)hiss != (Object)null)
			{
				hiss.Stop();
			}
			if ((Object)(object)joint != (Object)null)
			{
				Object.Destroy((Object)(object)joint);
				stuck = false;
			}
			if ((Object)(object)pgo != (Object)null)
			{
				pgo.OverrideGrabDisable(2.5f);
			}
			bool flag = d.Kind == Kind.Rocket;
			Fx.Sound(((Component)this).transform.position, Plugin.Piu, 1f, 3f, 65f, grp, flag ? 1f : 1.35f, ((Component)this).transform);
			jet = Fx.Sparks(vis, d.FuseB, flag ? 260f : 160f, 3f, 7f, flag ? 0.05f : 0.035f, 0.5f, new Color(1f, 0.9f, 0.5f), d.Col, 0.2f, -1);
			jet.Play();
		}
	}

	[PunRPC]
	public void ShotRPC(Vector3 pos, Vector3 dir, int idx)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: 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_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		if (d != null)
		{
			bool flag = d.Kind == Kind.Candle;
			Color c = Pal[idx % Pal.Length];
			Fx.Sound(pos, Plugin.Thump, 0.9f, 2f, 65f, grp, flag ? 1.5f : 1f, null);
			Fx.Burst(pos, new Color(1f, 0.9f, 0.6f), 14, 2.5f, 0.25f, 0.04f, 3f);
			PyroStar.Spawn(pos, dir, c, flag, flag ? 1.5f : (0.55f + 0.03f * (float)(idx * 37 % 10)), pse, d, ((Component)this).transform);
		}
	}

	[PunRPC]
	public void BoomRPC(Vector3 pos)
	{
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: 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_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		if (done || d == null)
		{
			return;
		}
		if ((Object)(object)hiss != (Object)null)
		{
			hiss.Stop();
		}
		if ((Object)(object)spark != (Object)null)
		{
			spark.Stop();
		}
		if ((Object)(object)jet != (Object)null)
		{
			jet.Stop();
		}
		float value = Plugin.DamageMult.Value;
		if ((Object)(object)pse != (Object)null)
		{
			pse.Spawn(pos, d.Size, (int)((float)d.Dmg * value), (int)((float)d.EnemyDmg * value), d.Force, false, true, d.Shake, d.Inv);
		}
		AudioClip clip = Plugin.Booms[Mathf.Clamp(d.Clip, 0, 2)];
		AudioSource val = Fx.Sound(pos, clip, d.Vol, 3f + d.Size, 40f + d.Size * 20f, grp, 1f, null);
		if ((Object)(object)val != (Object)null)
		{
			AudioLowPassFilter val2 = ((Component)val).gameObject.AddComponent<AudioLowPassFilter>();
			float num = Mathf.Clamp01(SemiFunc.PlayerLocalDistance(pos) / val.maxDistance);
			val2.cutoffFrequency = Mathf.Lerp(22000f, 750f, num * num);
		}
		if (d.Kind == Kind.Rocket || d.Kind == Kind.Shell)
		{
			int count = ((d.Kind == Kind.Rocket) ? 90 : ((int)(60f + d.Size * 25f)));
			Fx.Burst(pos, d.Col, count, 5f + d.Size, 1.6f, 0.12f + d.Size * 0.01f, 8f + d.Size * 2f);
			if (d.Size > 10f)
			{
				Fx.Burst(pos, Color.white, 250, 16f, 2.4f, 0.1f, 30f);
			}
		}
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			Kill();
		}
		else
		{
			done = true;
		}
	}
}