Decompiled source of Deidara v0.8.4

plugins/Deidara/Deidara.dll

Decompiled 8 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Json;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using ExtraSkillSlots;
using HG.BlendableTypes;
using KinematicCharacterController;
using On.RoR2;
using On.RoR2.UI;
using R2API;
using R2API.Utils;
using Rewired;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Skills;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Deidara")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+44fed6b71362c457175f188b6a9c3e305ec5f906")]
[assembly: AssemblyProduct("Deidara")]
[assembly: AssemblyTitle("Deidara")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace DeidaraMod;

public static class Snd
{
	private sealed class Speaking
	{
		public float until;

		public int prio;

		public uint id;
	}

	private static readonly Dictionary<int, Speaking> speaking = new Dictionary<int, Speaking>();

	public static uint LastVoiceId;

	public static void Init()
	{
		string path = Path.Combine(Media.Assets, "Audio", "Deidara.bnk");
		if (File.Exists(path))
		{
			SoundBanks.Add(File.ReadAllBytes(path));
		}
		else
		{
			Plugin.Log.LogWarning((object)"DEIDARA_AUDIO bank missing");
		}
	}

	public static uint Sfx(string key, GameObject at)
	{
		if (key != null && !key.StartsWith("S_"))
		{
			key = "S_" + key;
		}
		uint result = (Object.op_Implicit((Object)(object)at) ? AkSoundEngine.PostEvent("Play_Deidara_" + key, at) : 0u);
		Combat.Trace?.Invoke("SFX Play_Deidara_" + key + " playingId=" + result + " rt=" + Time.realtimeSinceStartup.ToString("0.000"));
		return result;
	}

	public static bool Voice(CharacterBody body, string key, float length, bool grunt = false, int prio = -1, bool log = false)
	{
		if (!Object.op_Implicit((Object)(object)body))
		{
			return false;
		}
		int instanceID = ((Object)body).GetInstanceID();
		float time = Time.time;
		if (prio < 0)
		{
			prio = ((!grunt) ? 1 : 0);
		}
		if (!speaking.TryGetValue(instanceID, out var value))
		{
			Dictionary<int, Speaking> dictionary = speaking;
			Speaking obj = new Speaking
			{
				until = -1f
			};
			value = obj;
			dictionary[instanceID] = obj;
		}
		if (time < value.until && prio <= value.prio)
		{
			if (log)
			{
				Plugin.Log.LogInfo((object)("DEIDARA_VOICE skip " + key + " busy prio=" + value.prio + " t=" + time.ToString("0.00")));
			}
			return false;
		}
		if (grunt && Random.value > 0.55f)
		{
			return false;
		}
		if (time < value.until && value.id != 0)
		{
			AkSoundEngine.StopPlayingID(value.id, 80);
		}
		bool flag = VoiceLoadout.Get(body) == VoiceLoadout.Lang.English;
		string text = "Play_Deidara_" + (flag ? "VE_" : "V_") + key;
		uint num = AkSoundEngine.PostEvent(text, ((Component)body).gameObject, 1048576u, (EventCallback)null, (object)null);
		value.until = time + length;
		value.prio = prio;
		value.id = num;
		LastVoiceId = num;
		Combat.Trace?.Invoke("VOICE " + (flag ? "VE_" : "V_") + key + " playingId=" + num + " rt=" + Time.realtimeSinceStartup.ToString("0.000"));
		if (log)
		{
			Plugin.Log.LogInfo((object)("DEIDARA_VOICE post " + text + " id=" + num + " t=" + time.ToString("0.00")));
			VoiceProbe.Watch(body, text, num);
		}
		return num != 0;
	}

	public static bool Playing(uint id, out int ms)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Invalid comparison between Unknown and I4
		ms = 0;
		if (id != 0 && (int)AkSoundEngine.GetSourcePlayPosition(id, ref ms, true) == 1)
		{
			return ms > 0;
		}
		return false;
	}
}
public sealed class VoiceProbe : MonoBehaviour
{
	private sealed class W
	{
		public string ev;

		public uint id;

		public float postT;
	}

	private readonly List<W> watch = new List<W>();

	public static float GateSeconds = 15f;

	public float ShowerReadyAt;

	private uint showerPending;

	private float showerPendingUntil;

	private float showerLen;

	public bool ShowerBlocked
	{
		get
		{
			if (showerPending == 0)
			{
				return Time.time < ShowerReadyAt;
			}
			return true;
		}
	}

	public static VoiceProbe For(CharacterBody b)
	{
		if (!Object.op_Implicit((Object)(object)b))
		{
			return null;
		}
		return ((Component)b).GetComponent<VoiceProbe>() ?? ((Component)b).gameObject.AddComponent<VoiceProbe>();
	}

	public static void Watch(CharacterBody b, string ev, uint id)
	{
		VoiceProbe voiceProbe = For(b);
		if (Object.op_Implicit((Object)(object)voiceProbe) && id != 0)
		{
			voiceProbe.watch.Add(new W
			{
				ev = ev,
				id = id,
				postT = Time.time
			});
		}
	}

	public void ObserveShower(uint id, float len)
	{
		if (id != 0)
		{
			showerPending = id;
			showerPendingUntil = Time.time + 1f;
			showerLen = len;
		}
	}

	private void Update()
	{
		if (showerPending != 0)
		{
			if (Snd.Playing(showerPending, out var ms))
			{
				ShowerReadyAt = Time.time - (float)ms / 1000f + showerLen + GateSeconds;
				Plugin.Log.LogInfo((object)("DEIDARA_VOICE shower audible id=" + showerPending + " gateUntil=" + ShowerReadyAt.ToString("0.00") + " t=" + Time.time.ToString("0.00")));
				showerPending = 0u;
			}
			else if (Time.time > showerPendingUntil)
			{
				showerPending = 0u;
			}
		}
		for (int num = watch.Count - 1; num >= 0; num--)
		{
			W w = watch[num];
			if (Snd.Playing(w.id, out var ms2))
			{
				Plugin.Log.LogInfo((object)("DEIDARA_VOICE audible " + w.ev + " id=" + w.id + " posMs=" + ms2 + " t=" + Time.time.ToString("0.00")));
				watch.RemoveAt(num);
			}
			else if (Time.time - w.postT > 1.5f)
			{
				Plugin.Log.LogInfo((object)("DEIDARA_VOICE NOT_PLAYING " + w.ev + " id=" + w.id));
				watch.RemoveAt(num);
			}
		}
	}
}
public static class PrimaryVoice
{
	private sealed class St
	{
		public float last = -999f;

		public int target = -1;
	}

	private static readonly Dictionary<int, St> state = new Dictionary<int, St>();

	public static void Swing(CharacterBody body, int stage, int finisher, string key, float length)
	{
		if (!Object.op_Implicit((Object)(object)body))
		{
			return;
		}
		int instanceID = ((Object)body).GetInstanceID();
		if (!state.TryGetValue(instanceID, out var value))
		{
			value = (state[instanceID] = new St());
		}
		if (stage == 0)
		{
			value.target = ((!(Random.value < Tuning.PrimaryVoiceChance.Value)) ? (-1) : ((!(Random.value < 0.5f)) ? finisher : 0));
			Combat.Trace?.Invoke("PRIMARYVOICE string start plan=" + value.target);
		}
		if (value.target == stage)
		{
			value.target = -1;
			float num = Time.time - value.last;
			if (num < Tuning.PrimaryVoiceCooldown.Value)
			{
				Combat.Trace?.Invoke("PRIMARYVOICE cooldown skip age=" + num.ToString("0.0"));
			}
			else if (Snd.Voice(body, key, length))
			{
				value.last = Time.time;
				Combat.Trace?.Invoke("PRIMARYVOICE played " + key + " stage=" + stage);
			}
		}
	}
}
public static class C3Aim
{
	public static bool Valid(CharacterBody b)
	{
		Vector3 ground;
		return Height(b, out ground) >= Tuning.C3MinHeight.Value;
	}

	public static float Height(CharacterBody b, out Vector3 ground)
	{
		//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_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_0038: 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_0064: 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_006f: 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)
		ground = Vector3.zero;
		if (!Object.op_Implicit((Object)(object)b))
		{
			return 0f;
		}
		RaycastHit val = default(RaycastHit);
		if (!Physics.SphereCast(b.footPosition + Vector3.up * 1.5f, 1.2f, Vector3.down, ref val, 400f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
		{
			return 0f;
		}
		ground = ((RaycastHit)(ref val)).point;
		return b.footPosition.y - ((RaycastHit)(ref val)).point.y;
	}
}
public sealed class C3Drop : BaseSkillState
{
	private bool dropped;

	private Gesture gest;

	private Vector3 vel;

	public override void OnEnter()
	{
		//IL_0022: 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_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		((BaseState)this).OnEnter();
		if (((EntityState)this).isAuthority && Object.op_Implicit((Object)(object)((EntityState)this).characterMotor))
		{
			vel = ((EntityState)this).characterMotor.velocity + Physics.gravity * Time.fixedDeltaTime;
		}
		CharVisual charVisual = CharVisual.Find(((EntityState)this).characterBody);
		if (Object.op_Implicit((Object)(object)charVisual))
		{
			gest = Poses.Cast("awaskl1_s", 0f, 20f, 0.25f, 0.8f);
			charVisual.PlayGesture(gest, 0.08f);
		}
		Lines.C3(((EntityState)this).characterBody);
		Snd.Sfx("C3Release", ((EntityState)this).gameObject);
	}

	public override void FixedUpdate()
	{
		//IL_0035: 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_0044: 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_004f: Unknown result type (might be due to invalid IL or missing references)
		((EntityState)this).FixedUpdate();
		if (!dropped && ((EntityState)this).fixedAge >= 0.15f)
		{
			dropped = true;
			if (NetworkServer.active)
			{
				C3Doll.Spawn(((EntityState)this).characterBody, ((EntityState)this).characterBody.footPosition + Vector3.down * 4.5f, vel);
			}
		}
		if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= 0.5f)
		{
			((EntityState)this).outer.SetNextStateToMain();
		}
	}

	public override void OnExit()
	{
		//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_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		if (!dropped && NetworkServer.active && Object.op_Implicit((Object)(object)((EntityState)this).characterBody))
		{
			dropped = true;
			C3Doll.Spawn(((EntityState)this).characterBody, ((EntityState)this).characterBody.footPosition + Vector3.down * 4.5f, vel);
		}
		((EntityState)this).OnExit();
	}

	public override InterruptPriority GetMinimumInterruptPriority()
	{
		return (InterruptPriority)1;
	}

	public override void OnSerialize(NetworkWriter w)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		((BaseSkillState)this).OnSerialize(w);
		w.Write(vel);
	}

	public override void OnDeserialize(NetworkReader r)
	{
		//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)
		((BaseSkillState)this).OnDeserialize(r);
		vel = r.ReadVector3();
	}
}
public sealed class C3Doll : NetworkBehaviour
{
	public static GameObject Prefab;

	public GameObject ownerObj;

	public Vector3 start;

	public Vector3 v0;

	public Vector3 land;

	public float t0;

	public float fallTime;

	private bool exploded;

	private Transform vis;

	private float explodedAt;

	private readonly HashSet<HealthComponent> hitOnce = new HashSet<HealthComponent>();

	public static float Carry = 0.25f;

	public static float CarryTau = 0.15f;

	private float clientT0;

	public static float KillDepth = 600f;

	public static int Spawned;

	public static int Exploded;

	public static int LiveImpacts;

	private float lastT;

	public static int ColumnHits;

	private Vector3 facing = Vector3.forward;

	private Renderer[] rends;

	public static float G => Mathf.Max(1f, Tuning.C3Gravity.Value);

	private float Age
	{
		get
		{
			if (!NetworkServer.active)
			{
				return Time.time - clientT0;
			}
			return Time.fixedTime - t0;
		}
	}

	public static int ImpactMask => LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask) | LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.collideWithCharacterHullOnly)).mask);

	public static void Build()
	{
		//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_0011: 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_0024: Expected O, but got Unknown
		//IL_002e: Expected O, but got Unknown
		GameObject val = new GameObject("DeidaraC3");
		val.AddComponent<NetworkIdentity>();
		val.AddComponent<C3Doll>();
		Prefab = PrefabAPI.InstantiateClone(val, "DeidaraC3", true);
		Object.DestroyImmediate((Object)val);
	}

	private static Vector3 At(Vector3 s, Vector3 v, float t)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: 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_0035: 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_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		return s + new Vector3(v.x, 0f, v.z) * (CarryTau * (1f - Mathf.Exp((0f - t) / CarryTau))) + Vector3.up * (v.y * t) + Vector3.down * (0.5f * G * t * t);
	}

	public static void Spawn(CharacterBody owner, Vector3 from, Vector3 vel)
	{
		//IL_0002: 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_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: 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_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: 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_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: 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)
		//IL_0118: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: 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_0138: 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_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: 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_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: 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_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: 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_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)
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(vel.x * Carry, Mathf.Clamp(vel.y, -14f, 0f), vel.z * Carry);
		float num = 1f / 30f;
		float num2 = 0f;
		Vector3 val2 = from;
		Vector3 val3 = from;
		float num3 = -1f;
		if (Physics.CheckSphere(from, 0.6f, ImpactMask, (QueryTriggerInteraction)1))
		{
			val3 = from;
			num3 = 0.05f;
		}
		else
		{
			RaycastHit val6 = default(RaycastHit);
			for (int i = 0; i < 300; i++)
			{
				float num4 = num2 + num;
				Vector3 val4 = At(from, val, num4);
				Vector3 val5 = val4 - val2;
				float magnitude = ((Vector3)(ref val5)).magnitude;
				if (magnitude > 0.0001f && Physics.SphereCast(val2, 1.2f, val5 / magnitude, ref val6, magnitude, ImpactMask, (QueryTriggerInteraction)1))
				{
					val3 = ((RaycastHit)(ref val6)).point;
					num3 = num2 + num * (((RaycastHit)(ref val6)).distance / magnitude);
					break;
				}
				val2 = val4;
				num2 = num4;
				if (from.y - val2.y > KillDepth)
				{
					break;
				}
			}
		}
		bool flag = num3 > 0f;
		if (!flag)
		{
			val3 = val2;
			num3 = Mathf.Max(num2, 0.05f);
		}
		if (num3 < 0.05f)
		{
			num3 = 0.05f;
		}
		float num5 = from.y - val3.y;
		GameObject obj = Object.Instantiate<GameObject>(Prefab, from, Quaternion.identity);
		C3Doll component = obj.GetComponent<C3Doll>();
		component.ownerObj = ((Component)owner).gameObject;
		component.start = from;
		component.v0 = val;
		component.land = val3;
		component.fallTime = num3;
		component.t0 = Time.fixedTime;
		NetworkServer.Spawn(obj);
		Spawned++;
		ManualLogSource log = Plugin.Log;
		string[] obj2 = new string[11]
		{
			"DEIDARA_C3 drop h=",
			num5.ToString("0.0"),
			" fall=",
			num3.ToString("0.00"),
			"s found=",
			flag.ToString(),
			" carry=",
			null,
			null,
			null,
			null
		};
		Vector2 val7 = new Vector2(val.x, val.z);
		obj2[7] = ((Vector2)(ref val7)).magnitude.ToString("0.0");
		obj2[8] = "m/s travel=";
		val7 = new Vector2(val3.x - from.x, val3.z - from.z);
		obj2[9] = ((Vector2)(ref val7)).magnitude.ToString("0.0");
		obj2[10] = "m";
		log.LogInfo((object)string.Concat(obj2));
	}

	private Vector3 PosAt(float t)
	{
		//IL_001d: 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_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		if (!(t >= fallTime))
		{
			return At(start, v0, t);
		}
		return land;
	}

	public static float StemTop(float R, float a)
	{
		return R * 0.12f + R * (0.35f + 1.85f * Mathf.Sqrt(Mathf.Clamp01(a / C3Fx.StemTime)));
	}

	private void FixedUpdate()
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkServer.active)
		{
			return;
		}
		if (!exploded)
		{
			float num = Time.fixedTime - t0;
			if (num < fallTime && LiveImpact(lastT, num, out var at))
			{
				land = at;
				fallTime = Mathf.Max(0.05f, num);
				((NetworkBehaviour)this).SetDirtyBit(1u);
				LiveImpacts++;
				Plugin.Log.LogInfo((object)("DEIDARA_C3 live impact at t=" + num.ToString("0.00") + " " + ((Vector3)(ref at)).ToString("F1")));
			}
			lastT = num;
			if (num >= fallTime)
			{
				exploded = true;
				explodedAt = Time.fixedTime;
				Exploded++;
				Explode();
			}
		}
		else
		{
			float num2 = Time.fixedTime - explodedAt;
			float value = Tuning.C3Radius.Value;
			if (num2 <= C3Fx.StemTime + 0.3f)
			{
				Column(num2, value);
			}
			if (num2 > C3Fx.StemTime + 0.5f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}

	private bool LiveImpact(float a, float b, out Vector3 at)
	{
		//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_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0033: 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_003a: 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_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: 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_0122: 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_014f: 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_00f7: 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_0106: Unknown result type (might be due to invalid IL or missing references)
		at = Vector3.zero;
		Vector3 val = PosAt(a);
		Vector3 val2 = PosAt(b) - val;
		float magnitude = ((Vector3)(ref val2)).magnitude;
		if (magnitude < 0.0001f)
		{
			return false;
		}
		Vector3 val3 = val2 / magnitude;
		CharacterBody val4 = (Object.op_Implicit((Object)(object)ownerObj) ? ownerObj.GetComponent<CharacterBody>() : null);
		RaycastHit[] array = Physics.SphereCastAll(val, 1.5f, val3, magnitude, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.entityPrecise)).mask), (QueryTriggerInteraction)2);
		float num = float.MaxValue;
		RaycastHit[] array2 = array;
		for (int i = 0; i < array2.Length; i++)
		{
			RaycastHit val5 = array2[i];
			HurtBox val6 = (Object.op_Implicit((Object)(object)((RaycastHit)(ref val5)).collider) ? ((Component)((RaycastHit)(ref val5)).collider).GetComponent<HurtBox>() : null);
			if (Object.op_Implicit((Object)(object)val6) && Object.op_Implicit((Object)(object)val4) && Combat.Target(val6, val4) && !(((RaycastHit)(ref val5)).distance >= num))
			{
				num = ((RaycastHit)(ref val5)).distance;
				at = ((((RaycastHit)(ref val5)).distance > 0f) ? ((RaycastHit)(ref val5)).point : val6.collider.ClosestPoint(val));
			}
		}
		RaycastHit val7 = default(RaycastHit);
		if (Physics.SphereCast(val, 1.2f, val3, ref val7, magnitude, ImpactMask, (QueryTriggerInteraction)1) && ((RaycastHit)(ref val7)).distance < num)
		{
			num = ((RaycastHit)(ref val7)).distance;
			at = ((RaycastHit)(ref val7)).point;
		}
		return num < float.MaxValue;
	}

	private void Explode()
	{
		//IL_001d: 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)
		//IL_0028: 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_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: 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_00b4: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: 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_00e8: 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_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_0138: 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_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_015e: 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)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		CharacterBody val = (Object.op_Implicit((Object)(object)ownerObj) ? ownerObj.GetComponent<CharacterBody>() : null);
		Vector3 val2 = land;
		Fx.Emit(ClayFx.C3Impact, val2, Tuning.C3Radius.Value, start);
		if (Object.op_Implicit((Object)(object)val))
		{
			Combat.Source = "C3";
			bool crit = val.RollCrit();
			int num = 0;
			float value = Tuning.C3Radius.Value;
			foreach (HurtBox item in Combat.Around(val, val2 + Vector3.up * 1.5f, value, sight: false))
			{
				Vector3 val3 = Combat.Point(item, val2);
				Vector3 val4 = val3 - val2;
				float num2 = ((Vector3)(ref val4)).magnitude / value;
				float num3 = Mathf.Lerp(1f, 0.55f, num2 * num2);
				Vector3 val5 = val3 - val2;
				val5.y = 0f;
				val5 = ((((Vector3)(ref val5)).sqrMagnitude < 0.01f) ? Vector3.up : ((Vector3)(ref val5)).normalized);
				if (Object.op_Implicit((Object)(object)item.healthComponent))
				{
					hitOnce.Add(item.healthComponent);
				}
				float coefficient = Tuning.C3Damage.Value * num3;
				val4 = val5 + Vector3.up * 0.6f;
				if (Combat.Deal(val, item, val3, coefficient, 1f, crit, ((Vector3)(ref val4)).normalized * 4000f * num3, (DamageType)0, ((Component)this).gameObject, (DamageColorIndex)0, (DamageSource)8))
				{
					num++;
				}
			}
			Plugin.Log.LogInfo((object)("DEIDARA_C3 impact hits=" + num + " R=" + value.ToString("0")));
		}
		if (Object.op_Implicit((Object)(object)vis))
		{
			((Component)vis).gameObject.SetActive(false);
		}
	}

	private void Column(float a, float R)
	{
		//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_0044: 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_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: 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_00ed: 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_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_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_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: 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)
		CharacterBody val = (Object.op_Implicit((Object)(object)ownerObj) ? ownerObj.GetComponent<CharacterBody>() : null);
		if (!Object.op_Implicit((Object)(object)val))
		{
			return;
		}
		float num = StemTop(R, a);
		Vector3 origin = land + Vector3.up * (num * 0.5f);
		foreach (HurtBox item in Combat.Around(val, origin, num * 0.5f + R * 0.8f, sight: false))
		{
			HealthComponent healthComponent = item.healthComponent;
			if (!Object.op_Implicit((Object)(object)healthComponent) || hitOnce.Contains(healthComponent))
			{
				continue;
			}
			Vector3 val2 = Combat.Point(item, land + Vector3.up * num * 0.5f);
			float num2 = val2.y - land.y;
			Vector2 val3 = new Vector2(val2.x - land.x, val2.z - land.z);
			float magnitude = ((Vector2)(ref val3)).magnitude;
			bool num3 = num2 >= 0f && num2 <= num && magnitude <= R * 0.3f;
			bool flag = a > 0.5f && Mathf.Abs(num2 - num) <= R * 0.3f && magnitude <= R * 0.75f;
			if (num3 || flag)
			{
				hitOnce.Add(healthComponent);
				Vector3 val4 = val2 - land;
				val4.y = 0f;
				val4 = ((((Vector3)(ref val4)).sqrMagnitude < 0.01f) ? Vector3.forward : ((Vector3)(ref val4)).normalized);
				Combat.Source = "C3.plume";
				float coefficient = Tuning.C3Damage.Value * 0.75f;
				bool crit = val.RollCrit();
				Vector3 val5 = Vector3.up + val4 * 0.4f;
				if (Combat.Deal(val, item, val2, coefficient, 1f, crit, ((Vector3)(ref val5)).normalized * 2500f, (DamageType)0, ((Component)this).gameObject, (DamageColorIndex)0, (DamageSource)8))
				{
					ColumnHits++;
					Plugin.Log.LogInfo((object)("DEIDARA_C3 plume hit " + (Object.op_Implicit((Object)(object)healthComponent.body) ? ((Object)healthComponent.body).name : "?") + " h=" + num2.ToString("0") + " d=" + magnitude.ToString("0") + " a=" + a.ToString("0.00")));
				}
			}
		}
	}

	public override bool OnSerialize(NetworkWriter w, bool initial)
	{
		//IL_004a: 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_0062: 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)
		if (!initial)
		{
			if (((NetworkBehaviour)this).syncVarDirtyBits == 0)
			{
				w.WritePackedUInt32(0u);
				return false;
			}
			w.WritePackedUInt32(2u);
			w.Write(land);
			w.Write(fallTime);
			return true;
		}
		w.WritePackedUInt32(1u);
		w.Write(ownerObj);
		w.Write(start);
		w.Write(v0);
		w.Write(land);
		w.Write(fallTime);
		return true;
	}

	public override void OnDeserialize(NetworkReader r, bool initial)
	{
		//IL_0036: 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_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: 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_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		switch (r.ReadPackedUInt32())
		{
		case 0u:
			return;
		case 2u:
			land = r.ReadVector3();
			fallTime = r.ReadSingle();
			return;
		}
		ownerObj = r.ReadGameObject();
		start = r.ReadVector3();
		v0 = r.ReadVector3();
		land = r.ReadVector3();
		fallTime = r.ReadSingle();
		clientT0 = Time.time;
	}

	private void Start()
	{
		//IL_0059: 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_005e: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkServer.active && clientT0 <= 0f)
		{
			clientT0 = Time.time;
		}
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(v0.x, 0f, v0.z);
		facing = ((((Vector3)(ref val)).sqrMagnitude > 0.25f) ? ((Vector3)(ref val)).normalized : Vector3.forward);
		GameObject val2 = Rigs.Creature("C3", ((Component)this).transform, 0.05f);
		if (Object.op_Implicit((Object)(object)val2))
		{
			vis = val2.transform;
			rends = val2.GetComponentsInChildren<Renderer>(true);
			Renderer[] array = rends;
			for (int i = 0; i < array.Length; i++)
			{
				array[i].sharedMaterial = Rigs.ClayWarm;
			}
		}
	}

	private void LateUpdate()
	{
		//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_0055: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: 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_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: 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_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_019f: Unknown result type (might be due to invalid IL or missing references)
		float age = Age;
		if (age > fallTime + 0.05f)
		{
			if (Object.op_Implicit((Object)(object)vis) && ((Component)vis).gameObject.activeSelf)
			{
				((Component)vis).gameObject.SetActive(false);
			}
			return;
		}
		Vector3 position = PosAt(age);
		((Component)this).transform.position = position;
		if (!Object.op_Implicit((Object)(object)vis))
		{
			return;
		}
		float num = Mathf.Clamp01(age / Mathf.Max(0.05f, fallTime));
		float num2 = Mathf.Clamp01((num - 0.12f) / 0.88f);
		float num3 = Mathf.Lerp(Tuning.C3Scale.Value / 5f, Tuning.C3Scale.Value, num2 * num2 * (3f - 2f * num2));
		float num4 = 1f + 0.1f * num;
		vis.rotation = Quaternion.LookRotation(facing, Vector3.up);
		vis.localScale = new Vector3(num3 / Mathf.Sqrt(num4), num3 * num4, num3 / Mathf.Sqrt(num4));
		vis.localPosition = Vector3.down * (11f * num3 * num4 * (1f - num));
		Camera val = Fx.Cam();
		if (!Object.op_Implicit((Object)(object)val) || rends == null)
		{
			return;
		}
		Vector3 position2 = ((Component)val).transform.position;
		Renderer[] array = rends;
		foreach (Renderer val2 in array)
		{
			if (Object.op_Implicit((Object)(object)val2))
			{
				Bounds bounds = val2.bounds;
				((Bounds)(ref bounds)).Expand(4f);
				val2.forceRenderingOff = ((Bounds)(ref bounds)).Contains(position2);
			}
		}
	}
}
public enum ClayKind : byte
{
	Spider,
	Bird,
	Beetle,
	Snake
}
public enum ClayState : byte
{
	Moving,
	Attached,
	Placed,
	Gone
}
public sealed class ClayCharge : NetworkBehaviour
{
	public static readonly List<ClayCharge> All = new List<ClayCharge>();

	public GameObject ownerObj;

	public ClayKind kind;

	public ClayState state;

	public GameObject victimObj;

	public short hurtIndex = -1;

	public Vector3 local;

	public Vector3 pos;

	public Vector3 vel;

	public float armedAt;

	private HurtBox target;

	private HurtBox attachBox;

	private Vector3 lastValid;

	private Vector3 travelDir;

	private Vector3 aimPoint;

	private float born;

	private float travelled;

	private float nextSeek;

	private float nextTrapCheck;

	private bool hasAim;

	public bool Aerial;

	public float SpawnTime;

	private bool attInit;

	private Vector3 attFrom;

	private float attT0;

	private Quaternion attRot;

	private Vector3 baseScale;

	private float attScale;

	private Transform visual;

	private Animation anim;

	private float syncT;

	private Vector3 shownPos;

	private bool shownInit;

	private Light tell;

	private float phase;

	public static float TossBase = 3.5f;

	public static float TossPerRootM = 1.1f;

	public static float TossMax = 12f;

	public static float TossLead = 0.8f;

	private float fallV;

	private float fallFor;

	private float lane;

	private Vector3 tossV;

	public static float SpiderGap = 1.1f;

	public static float AirGap = 1f;

	public static float AirToss = 3f;

	private bool landed;

	private float nextTrail;

	private static Mesh sphere;

	private Transform[] segs;

	private float[] segR;

	private float snakePhase;

	private Transform[] legU;

	private Quaternion[] legBase;

	private Vector3[] legUp;

	private Vector3[] legLift;

	private float[] legSign;

	private float[] legPhase;

	private float gaitPh;

	private float gaitAmp;

	private Vector3 gNrm = Vector3.up;

	private bool gNrmInit;

	public static float GaitAmp = 34f;

	public static float GaitLift = 40f;

	public static float GaitStride = 0.9f;

	public static float GaitMaxHz = 5f;

	private Vector3 crawlDir;

	private Vector3 crawlGoal;

	private float crawlNext;

	private bool crawlInit;

	private Transform tellQ;

	private Renderer tellR;

	private MaterialPropertyBlock mpb;

	public CharacterBody Owner
	{
		get
		{
			if (!Object.op_Implicit((Object)(object)ownerObj))
			{
				return null;
			}
			return ownerObj.GetComponent<CharacterBody>();
		}
	}

	public bool Armed
	{
		get
		{
			if (state != ClayState.Attached)
			{
				return state == ClayState.Placed;
			}
			return true;
		}
	}

	public CharacterBody Victim
	{
		get
		{
			if (!Object.op_Implicit((Object)(object)victimObj))
			{
				return null;
			}
			return victimObj.GetComponent<CharacterBody>();
		}
	}

	public static ClayCharge Spawn(CharacterBody owner, ClayKind kind, Vector3 at, Vector3 dir, Vector3 aim, bool hasAim)
	{
		//IL_0022: 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_0031: 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_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: 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_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_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_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: 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_00dc: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkServer.active || !Object.op_Implicit((Object)(object)owner) || !Object.op_Implicit((Object)(object)Clay.Prefab))
		{
			return null;
		}
		GameObject obj = Object.Instantiate<GameObject>(Clay.Prefab, at, Quaternion.LookRotation((((Vector3)(ref dir)).sqrMagnitude > 0.0001f) ? dir : Vector3.forward));
		ClayCharge component = obj.GetComponent<ClayCharge>();
		component.ownerObj = ((Component)owner).gameObject;
		component.kind = kind;
		component.state = ClayState.Moving;
		component.pos = at;
		component.vel = dir * ((kind == ClayKind.Bird) ? Tuning.C1BirdSpeed.Value : Tuning.C1SpiderSpeed.Value);
		component.travelDir = dir;
		component.aimPoint = aim;
		component.hasAim = hasAim;
		component.born = Time.fixedTime;
		component.lastValid = at;
		if (kind == ClayKind.Spider && !Grounded(at, AirGap + 0.2f))
		{
			component.fallV = AirToss;
			component.tossV = TossVelocity(at, dir);
		}
		NetworkServer.Spawn(obj);
		ClayOwner.Enforce(owner);
		return component;
	}

	public static float TossDistance(float h)
	{
		return Mathf.Min(TossMax, TossBase + TossPerRootM * Mathf.Sqrt(Mathf.Max(0f, h)));
	}

	private static Vector3 TossVelocity(Vector3 at, Vector3 dir)
	{
		//IL_0002: 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_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_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: 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_0077: 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_00fe: 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)
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(dir.x, 0f, dir.z);
		if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
		{
			return Vector3.zero;
		}
		((Vector3)(ref val)).Normalize();
		RaycastHit val2 = default(RaycastHit);
		float num = (Physics.Raycast(at + Vector3.up * 0.2f, Vector3.down, ref val2, 1000f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1) ? Mathf.Max(0f, at.y - ((RaycastHit)(ref val2)).point.y - AirGap) : 30f);
		float airToss = AirToss;
		float num2 = (2500f - airToss * airToss) / 60f;
		float num3 = ((num <= num2) ? ((airToss + Mathf.Sqrt(airToss * airToss + 60f * num)) / 30f) : ((airToss + 50f) / 30f + (num - num2) / 50f));
		float num4 = Mathf.Max(0f, TossDistance(num) - TossLead);
		return val * (num4 / Mathf.Max(0.2f, num3));
	}

	public static ClayCharge SpawnSnake(CharacterBody owner, Vector3 at, Vector3 v0)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_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_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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_0071: Unknown result type (might be due to invalid IL or missing references)
		ClayCharge clayCharge = Spawn(owner, ClayKind.Snake, at, (((Vector3)(ref v0)).sqrMagnitude > 0.001f) ? ((Vector3)(ref v0)).normalized : Vector3.down, at, hasAim: false);
		if (Object.op_Implicit((Object)(object)clayCharge))
		{
			clayCharge.vel = v0;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(v0.x, 0f, v0.z);
			clayCharge.travelDir = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : owner.transform.forward);
			clayCharge.Dirty();
		}
		return clayCharge;
	}

	public static ClayCharge SpawnAttached(CharacterBody owner, ClayKind kind, HurtBox h, Vector3 worldPoint)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		ClayCharge clayCharge = Spawn(owner, kind, worldPoint, Vector3.up, worldPoint, hasAim: false);
		if (Object.op_Implicit((Object)(object)clayCharge) && Object.op_Implicit((Object)(object)h))
		{
			clayCharge.AttachTo(h, worldPoint);
		}
		return clayCharge;
	}

	private void AttachTo(HurtBox h, Vector3 p)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: 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_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: 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_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: 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_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_00c7: 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_00ef: 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_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//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_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: 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_0186: Unknown result type (might be due to invalid IL or missing references)
		CharacterBody val = (Object.op_Implicit((Object)(object)h.healthComponent) ? h.healthComponent.body : null);
		if (!Object.op_Implicit((Object)(object)val))
		{
			Place(p);
			return;
		}
		if (kind == ClayKind.Spider && Object.op_Implicit((Object)(object)h.collider))
		{
			int num = 0;
			foreach (ClayCharge item in All)
			{
				if ((Object)(object)item != (Object)(object)this && item.kind == ClayKind.Spider && item.state == ClayState.Attached && (Object)(object)item.victimObj == (Object)(object)((Component)val).gameObject)
				{
					num++;
				}
			}
			Bounds bounds = h.collider.bounds;
			Vector3 val2 = p - ((Bounds)(ref bounds)).center;
			val2.y = 0f;
			float num2 = ((((Vector3)(ref val2)).sqrMagnitude > 0.0001f) ? Mathf.Atan2(val2.z, val2.x) : 0f) + (float)num * 2.39996f;
			float num3 = ((num % 3 == 0) ? 0.15f : ((num % 3 == 1) ? 0.55f : (-0.2f))) * ((Bounds)(ref bounds)).extents.y;
			Vector3 val3 = ((Bounds)(ref bounds)).center + new Vector3(Mathf.Cos(num2) * ((Bounds)(ref bounds)).extents.x, num3, Mathf.Sin(num2) * ((Bounds)(ref bounds)).extents.z) * 2.5f;
			p = h.collider.ClosestPoint(val3);
		}
		tossV = Vector3.zero;
		attachBox = h;
		victimObj = ((Component)val).gameObject;
		hurtIndex = h.indexInGroup;
		local = ((Component)h).transform.InverseTransformPoint(p);
		pos = p;
		state = ClayState.Attached;
		armedAt = Time.fixedTime;
		Dirty();
		if (kind == ClayKind.Snake)
		{
			CharacterBody owner = Owner;
			if (Object.op_Implicit((Object)(object)owner))
			{
				Combat.Source = "Snake.bite";
				Combat.Deal(owner, h, p, Tuning.ShotDamage.Value, 0.5f, owner.RollCrit(), Vector3.zero, (DamageType)0, null, (DamageColorIndex)0, (DamageSource)1);
			}
		}
		if (Tuning.Verbose.Value)
		{
			Plugin.Log.LogInfo((object)("DEIDARA_CLAY attach " + kind.ToString() + " -> " + ((Object)val).name));
		}
	}

	private void Place(Vector3 p)
	{
		//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_000c: 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_0013: 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)
		tossV = Vector3.zero;
		pos = p;
		vel = Vector3.zero;
		victimObj = null;
		hurtIndex = -1;
		attachBox = null;
		state = ClayState.Placed;
		if (armedAt <= 0f)
		{
			armedAt = Time.fixedTime;
		}
		Dirty();
	}

	private void Dirty()
	{
		((NetworkBehaviour)this).SetDirtyBit(1u);
	}

	public void Fizzle()
	{
		//IL_001e: 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)
		if (NetworkServer.active && state != ClayState.Gone)
		{
			state = ClayState.Gone;
			Fx.Emit(ClayFx.Crumble, WorldPos(), 1f, Vector3.zero, (int)kind);
			NetworkServer.Destroy(((Component)this).gameObject);
		}
	}

	public void Detonated()
	{
		if (NetworkServer.active)
		{
			state = ClayState.Gone;
			NetworkServer.Destroy(((Component)this).gameObject);
		}
	}

	public Vector3 WorldPos()
	{
		//IL_002b: 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)
		if (state == ClayState.Attached)
		{
			HurtBox val = Box();
			if (Object.op_Implicit((Object)(object)val))
			{
				return ((Component)val).transform.TransformPoint(local);
			}
		}
		return pos;
	}

	private HurtBox Box()
	{
		if (Object.op_Implicit((Object)(object)attachBox))
		{
			return attachBox;
		}
		CharacterBody victim = Victim;
		if (!Object.op_Implicit((Object)(object)victim) || hurtIndex < 0 || !Object.op_Implicit((Object)(object)victim.modelLocator) || !Object.op_Implicit((Object)(object)victim.modelLocator.modelTransform))
		{
			return null;
		}
		HurtBoxGroup component = ((Component)victim.modelLocator.modelTransform).GetComponent<HurtBoxGroup>();
		if (Object.op_Implicit((Object)(object)component) && hurtIndex < component.hurtBoxes.Length)
		{
			attachBox = component.hurtBoxes[hurtIndex];
		}
		return attachBox;
	}

	private void OnEnable()
	{
		All.Add(this);
		SpawnTime = Time.time;
		phase = Random.value * 6.28f;
	}

	private void OnDisable()
	{
		All.Remove(this);
	}

	private void FixedUpdate()
	{
		//IL_0148: 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_0212: 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_0221: 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)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkServer.active || state == ClayState.Gone)
		{
			return;
		}
		CharacterBody owner = Owner;
		if (!Object.op_Implicit((Object)(object)owner))
		{
			Fizzle();
			return;
		}
		float fixedTime = Time.fixedTime;
		if (Armed && fixedTime - armedAt > Tuning.C1Lifetime.Value)
		{
			Fizzle();
			return;
		}
		if (!Armed && fixedTime - born > ((kind == ClayKind.Snake) ? 10f : 8f) && (fallV > -0.5f || fixedTime - born > 30f))
		{
			Place(pos);
		}
		switch (state)
		{
		case ClayState.Moving:
			if (kind == ClayKind.Bird)
			{
				StepBird(owner, Time.fixedDeltaTime);
			}
			else if (kind == ClayKind.Snake && !landed)
			{
				StepSnakeFall(owner, Time.fixedDeltaTime);
			}
			else
			{
				StepSpider(owner, Time.fixedDeltaTime);
			}
			break;
		case ClayState.Attached:
		{
			HurtBox val = Box();
			CharacterBody victim = Victim;
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)victim) || !Object.op_Implicit((Object)(object)victim.healthComponent) || !victim.healthComponent.alive)
			{
				Place(lastValid);
				if (kind == ClayKind.Spider && !Grounded(lastValid, 0.8f))
				{
					state = ClayState.Moving;
					target = null;
					travelled = 0f;
					born = fixedTime;
					fallV = 0f;
					Dirty();
				}
			}
			else
			{
				lastValid = ((Component)val).transform.TransformPoint(local);
				pos = lastValid;
				Aerial = victim.isFlying || !Grounded(lastValid, 4f);
			}
			break;
		}
		case ClayState.Placed:
			if (kind == ClayKind.Spider && fixedTime >= nextTrapCheck)
			{
				nextTrapCheck = fixedTime + 0.3f;
				List<HurtBox> list = Combat.Around(owner, pos + Vector3.up * 0.5f, 3.5f);
				if (list.Count > 0)
				{
					target = list[0];
					state = ClayState.Moving;
					born = fixedTime;
					travelled = 0f;
					Dirty();
				}
			}
			break;
		}
		if (state == ClayState.Moving && fixedTime - syncT > 0.1f)
		{
			syncT = fixedTime;
			Dirty();
		}
	}

	private static bool Grounded(Vector3 p, float d)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: 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_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_0020: Unknown result type (might be due to invalid IL or missing references)
		return Physics.Raycast(p + Vector3.up * 0.2f, Vector3.down, d, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1);
	}

	private void StepSpider(CharacterBody owner, float dt)
	{
		//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_008e: 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_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)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: 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_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: 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_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: 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_0304: Unknown result type (might be due to invalid IL or missing references)
		//IL_0309: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0440: Unknown result type (might be due to invalid IL or missing references)
		//IL_0445: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0468: Unknown result type (might be due to invalid IL or missing references)
		//IL_046d: Unknown result type (might be due to invalid IL or missing references)
		//IL_046f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0475: Unknown result type (might be due to invalid IL or missing references)
		//IL_047a: Unknown result type (might be due to invalid IL or missing references)
		//IL_047f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0484: Unknown result type (might be due to invalid IL or missing references)
		//IL_0486: Unknown result type (might be due to invalid IL or missing references)
		//IL_0490: Unknown result type (might be due to invalid IL or missing references)
		//IL_0495: Unknown result type (might be due to invalid IL or missing references)
		//IL_049a: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_041b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0420: Unknown result type (might be due to invalid IL or missing references)
		//IL_0427: Unknown result type (might be due to invalid IL or missing references)
		//IL_042c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0431: Unknown result type (might be due to invalid IL or missing references)
		//IL_062c: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0776: Unknown result type (might be due to invalid IL or missing references)
		//IL_077b: Unknown result type (might be due to invalid IL or missing references)
		//IL_078a: Unknown result type (might be due to invalid IL or missing references)
		//IL_067f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0927: Unknown result type (might be due to invalid IL or missing references)
		//IL_092a: Unknown result type (might be due to invalid IL or missing references)
		//IL_092f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0935: Unknown result type (might be due to invalid IL or missing references)
		//IL_093a: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_035f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0366: Unknown result type (might be due to invalid IL or missing references)
		//IL_036b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0370: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_065b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0967: Unknown result type (might be due to invalid IL or missing references)
		//IL_0969: Unknown result type (might be due to invalid IL or missing references)
		//IL_0975: Unknown result type (might be due to invalid IL or missing references)
		//IL_094a: Unknown result type (might be due to invalid IL or missing references)
		//IL_094d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0952: Unknown result type (might be due to invalid IL or missing references)
		//IL_0957: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: 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_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_07da: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0801: Unknown result type (might be due to invalid IL or missing references)
		//IL_0806: Unknown result type (might be due to invalid IL or missing references)
		//IL_080b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0818: Unknown result type (might be due to invalid IL or missing references)
		//IL_081d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0822: Unknown result type (might be due to invalid IL or missing references)
		//IL_0825: Unknown result type (might be due to invalid IL or missing references)
		//IL_082a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0834: Unknown result type (might be due to invalid IL or missing references)
		//IL_0839: Unknown result type (might be due to invalid IL or missing references)
		//IL_083e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0847: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_08d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_08f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_08fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0538: Unknown result type (might be due to invalid IL or missing references)
		//IL_054b: Unknown result type (might be due to invalid IL or missing references)
		//IL_055e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0563: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0399: Unknown result type (might be due to invalid IL or missing references)
		//IL_039b: Unknown result type (might be due to invalid IL or missing references)
		//IL_039f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_085b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0860: Unknown result type (might be due to invalid IL or missing references)
		//IL_086a: Unknown result type (might be due to invalid IL or missing references)
		//IL_086f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0874: Unknown result type (might be due to invalid IL or missing references)
		//IL_0885: Unknown result type (might be due to invalid IL or missing references)
		//IL_088a: Unknown result type (might be due to invalid IL or missing references)
		//IL_072a: Unknown result type (might be due to invalid IL or missing references)
		//IL_072f: Unknown result type (might be due to invalid IL or missing references)
		//IL_090f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0914: Unknown result type (might be due to invalid IL or missing references)
		//IL_091f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0924: Unknown result type (might be due to invalid IL or missing references)
		//IL_0576: Unknown result type (might be due to invalid IL or missing references)
		float fixedTime = Time.fixedTime;
		bool flag = kind == ClayKind.Snake;
		if ((!Object.op_Implicit((Object)(object)target) || !Object.op_Implicit((Object)(object)target.healthComponent) || !target.healthComponent.alive) && fixedTime >= nextSeek)
		{
			nextSeek = fixedTime + 0.25f;
			target = (flag ? SeekGround(owner, pos) : Seek(owner));
		}
		Vector3 val = travelDir;
		val.y = 0f;
		if (flag)
		{
			using List<HurtBox>.Enumerator enumerator = Combat.Around(owner, pos + Vector3.up * 0.4f, 0.9f, sight: false).GetEnumerator();
			if (enumerator.MoveNext())
			{
				HurtBox current = enumerator.Current;
				AttachTo(current, Combat.Point(current, pos));
				return;
			}
		}
		Vector2 val4;
		if (Object.op_Implicit((Object)(object)target))
		{
			Vector3 val2 = Combat.Point(target, pos);
			Vector3 val3 = val2 - pos;
			val4 = new Vector2(val3.x, val3.z);
			float magnitude = ((Vector2)(ref val4)).magnitude;
			CharacterBody val5 = (Object.op_Implicit((Object)(object)target.healthComponent) ? target.healthComponent.body : null);
			float num = (Object.op_Implicit((Object)(object)val5) ? Mathf.Clamp(val5.radius, 0.3f, 3f) : 0.5f);
			if (((Vector3)(ref val3)).magnitude < (flag ? 1.1f : 0.8f) || (!flag && fallV > -0.5f && magnitude < num + 0.6f && val3.y > -1f && val3.y < 3f))
			{
				AttachTo(target, val2);
				return;
			}
			val3.y = 0f;
			if (!flag && ((Vector3)(ref val3)).sqrMagnitude > 0.01f)
			{
				if (lane == 0f)
				{
					lane = Random.Range(-1f, 1f);
				}
				Vector3 val6 = Vector3.Cross(Vector3.up, ((Vector3)(ref val3)).normalized);
				val3 += val6 * lane * Mathf.Clamp(magnitude * 0.3f - num * 0.25f, 0f, 2.4f);
			}
			if (((Vector3)(ref val3)).sqrMagnitude > 0.01f)
			{
				val = ((Vector3)(ref val3)).normalized;
			}
		}
		else if (fallV > -0.5f && travelled > (flag ? 3f : (Tuning.C1SpiderSeek.Value * 0.75f)))
		{
			Place(pos);
			return;
		}
		if (flag && travelled > Tuning.SnakeSeek.Value * 1.6f)
		{
			Place(pos);
			return;
		}
		if (!flag)
		{
			Vector3 val7 = Vector3.zero;
			foreach (ClayCharge item in All)
			{
				if (!((Object)(object)item == (Object)(object)this) && item.kind == ClayKind.Spider && item.state == ClayState.Moving && !((Object)(object)item.ownerObj != (Object)(object)ownerObj))
				{
					Vector3 val8 = pos - item.pos;
					val8.y = 0f;
					float magnitude2 = ((Vector3)(ref val8)).magnitude;
					if (magnitude2 < SpiderGap && magnitude2 > 0.001f)
					{
						val7 += val8 / magnitude2 * (1f - magnitude2 / SpiderGap);
					}
					else if (magnitude2 <= 0.001f)
					{
						val7 += Random.insideUnitSphere;
					}
				}
			}
			val7.y = 0f;
			if (((Vector3)(ref val7)).sqrMagnitude > 0.0001f)
			{
				val.y = 0f;
				val = ((Vector3)(ref val)).normalized + val7 * 2.2f;
			}
		}
		if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
		{
			val = Vector3.forward;
		}
		((Vector3)(ref val)).Normalize();
		float num2 = (flag ? Tuning.SnakeSpeed.Value : Tuning.C1SpiderSpeed.Value);
		Vector3 val9 = pos + val * num2 * dt;
		bool flag2 = false;
		RaycastHit val10 = default(RaycastHit);
		bool flag3 = Physics.Raycast(val9 + Vector3.up * 1.5f, Vector3.down, ref val10, 6f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1);
		bool flag4 = false;
		if (!flag && Object.op_Implicit((Object)(object)target))
		{
			Vector3 val11 = Combat.Point(target, pos);
			CharacterBody val12 = (Object.op_Implicit((Object)(object)target.healthComponent) ? target.healthComponent.body : null);
			float num3 = (Object.op_Implicit((Object)(object)val12) ? Mathf.Clamp(val12.radius, 0.3f, 3f) : 0.5f);
			val4 = new Vector2(val11.x - pos.x, val11.z - pos.z);
			flag4 = ((Vector2)(ref val4)).magnitude < num3 + 2.5f && val11.y > pos.y - 1f && fallV > -6f;
		}
		if (flag4)
		{
			fallV = 0f;
			fallFor = 0f;
			if (flag3 && pos.y - ((RaycastHit)(ref val10)).point.y <= AirGap)
			{
				val9.y = Mathf.Lerp(pos.y, ((RaycastHit)(ref val10)).point.y + 0.05f, 0.6f);
			}
		}
		else if (flag3 && (pos.y - ((RaycastHit)(ref val10)).point.y <= AirGap || (fallV < -6f && pos.y - ((RaycastHit)(ref val10)).point.y <= 0.6f)))
		{
			val9.y = Mathf.Lerp(pos.y, ((RaycastHit)(ref val10)).point.y + 0.05f, (fallV < -6f) ? 1f : 0.6f);
			if (tossV != Vector3.zero && Tuning.Verbose.Value)
			{
				Plugin.Log.LogInfo((object)("DEIDARA_CLAY toss landed at " + ((Vector3)(ref pos)).ToString("F2") + " t=" + (Time.fixedTime - born).ToString("F2")));
			}
			fallV = 0f;
			fallFor = 0f;
			tossV = Vector3.zero;
		}
		else
		{
			flag2 = true;
			fallV = Mathf.Max(fallV - 30f * dt, -50f);
			fallFor += dt;
			if (fallFor > 1.5f && !Physics.Raycast(pos, Vector3.down, 1000f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
			{
				Fizzle();
				return;
			}
			Vector3 val13 = ((((Vector3)(ref tossV)).sqrMagnitude > 0.0001f) ? (tossV + (Object.op_Implicit((Object)(object)target) ? (val * Tuning.C1SpiderAirDrift.Value) : Vector3.zero)) : (val * Tuning.C1SpiderAirDrift.Value));
			val9 = pos + val13 * dt + Vector3.up * (fallV * dt);
			RaycastHit val14 = default(RaycastHit);
			if (Physics.Linecast(pos + Vector3.up * 0.3f, val9, ref val14, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
			{
				val9 = ((RaycastHit)(ref val14)).point + Vector3.up * 0.05f;
				fallV = 0f;
				flag2 = false;
				tossV = Vector3.zero;
			}
		}
		if (Object.op_Implicit((Object)(object)target) && !flag2)
		{
			Vector3 val15 = Combat.Point(target, pos);
			if (val15.y > pos.y + 1.2f)
			{
				val4 = new Vector2(val15.x - pos.x, val15.z - pos.z);
				if (((Vector2)(ref val4)).magnitude < 2.5f)
				{
					val9 = Vector3.MoveTowards(pos, val15, num2 * 1.2f * dt);
				}
			}
		}
		vel = (val9 - pos) / dt;
		if (!flag2)
		{
			float num4 = travelled;
			Vector3 val16 = val9 - pos;
			travelled = num4 + ((Vector3)(ref val16)).magnitude;
		}
		pos = val9;
		((Component)this).transform.position = pos;
	}

	private void StepSnakeFall(CharacterBody owner, float dt)
	{
		//IL_0051: 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_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: 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_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_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: 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_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: 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_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: 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_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: 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_01b6: 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_01d1: 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: 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_0309: Unknown result type (might be due to invalid IL or missing references)
		//IL_030e: Unknown result type (might be due to invalid IL or missing references)
		//IL_030f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0314: Unknown result type (might be due to invalid IL or missing references)
		//IL_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: 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_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: 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_0294: 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_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02af: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cb: 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_02eb: Unknown result type (might be due to invalid IL or missing references)
		float fixedTime = Time.fixedTime;
		if ((!Object.op_Implicit((Object)(object)target) || !Object.op_Implicit((Object)(object)target.healthComponent) || !target.healthComponent.alive) && fixedTime >= nextSeek)
		{
			nextSeek = fixedTime + 0.2f;
			target = SeekFall(owner, PredictLanding());
		}
		vel.y = Mathf.Max(vel.y - 26f * dt, -45f);
		if (Object.op_Implicit((Object)(object)target))
		{
			Vector3 val = Combat.Point(target, pos);
			Vector3 val2 = val - pos;
			float num = Mathf.Clamp((pos.y - val.y) / Mathf.Max(6f, 0f - vel.y), 0.15f, 3f);
			Vector3 val3 = new Vector3(val2.x, 0f, val2.z) / num;
			if (((Vector3)(ref val3)).magnitude > 30f)
			{
				val3 = ((Vector3)(ref val3)).normalized * 30f;
			}
			Vector3 val4 = Vector3.MoveTowards(new Vector3(vel.x, 0f, vel.z), val3, 34f * dt);
			vel.x = val4.x;
			vel.z = val4.z;
		}
		Vector3 val5 = vel * dt;
		float magnitude = ((Vector3)(ref val5)).magnitude;
		Vector3 val6 = ((magnitude > 0.0001f) ? (val5 / magnitude) : Vector3.down);
		RaycastHit val7 = default(RaycastHit);
		if (Physics.SphereCast(pos, 0.5f, val6, ref val7, magnitude + 0.3f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.entityPrecise)).mask), (QueryTriggerInteraction)2))
		{
			HurtBox component = ((Component)((RaycastHit)(ref val7)).collider).GetComponent<HurtBox>();
			if (Combat.Target(component, owner))
			{
				AttachTo(component, ((RaycastHit)(ref val7)).point);
				return;
			}
		}
		RaycastHit val8 = default(RaycastHit);
		if (Physics.SphereCast(pos, 0.25f, val6, ref val8, magnitude + 0.2f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
		{
			pos = ((RaycastHit)(ref val8)).point + Vector3.up * 0.05f;
			landed = true;
			Vector3 val9 = default(Vector3);
			((Vector3)(ref val9))..ctor(vel.x, 0f, vel.z);
			travelDir = ((((Vector3)(ref val9)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val9)).normalized : travelDir);
			vel = val9 * 0.3f;
			travelled = 0f;
			((Component)this).transform.position = pos;
			Dirty();
			Fx.Emit(ClayFx.Crumble, pos, 1f, Vector3.zero, (int)kind);
		}
		else
		{
			pos += val5;
			((Component)this).transform.position = pos;
		}
	}

	private Vector3 PredictLanding()
	{
		//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_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_0022: 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_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)
		//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_003d: 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_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = pos;
		Vector3 val2 = vel;
		RaycastHit val4 = default(RaycastHit);
		for (int i = 0; i < 40; i++)
		{
			val2.y -= 1.3000001f;
			Vector3 val3 = val + val2 * 0.05f;
			if (Physics.Linecast(val, val3, ref val4, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
			{
				return ((RaycastHit)(ref val4)).point;
			}
			val = val3;
		}
		return Combat.Ground(val, 80f);
	}

	private HurtBox SeekFall(CharacterBody owner, Vector3 landing)
	{
		//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_000f: 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_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: 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_0021: 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_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)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: 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_004e: 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_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)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: 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_00a2: 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_00a8: 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_00be: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		HurtBox result = null;
		float num = float.MaxValue;
		Vector3 val = pos;
		Vector3 val2 = landing - val;
		float magnitude = ((Vector3)(ref val2)).magnitude;
		Vector3 origin = val + val2 * 0.5f;
		Vector3 val3 = ((magnitude > 0.01f) ? (val2 / magnitude) : Vector3.down);
		foreach (HurtBox item in Combat.Around(owner, origin, magnitude * 0.5f + Tuning.SnakeSeek.Value, sight: false))
		{
			Vector3 val4 = Combat.Point(item, val);
			if (val4.y > val.y + 2f)
			{
				continue;
			}
			float num2 = Mathf.Clamp(Vector3.Dot(val4 - val, val3), 0f, magnitude);
			Vector3 val5 = val + val3 * num2 - val4;
			float magnitude2 = ((Vector3)(ref val5)).magnitude;
			if (magnitude2 > Tuning.SnakeSeek.Value)
			{
				continue;
			}
			int num3 = 0;
			foreach (ClayCharge item2 in All)
			{
				if ((Object)(object)item2 != (Object)(object)this && Object.op_Implicit((Object)(object)item2.target) && (Object)(object)item2.target.healthComponent == (Object)(object)item.healthComponent && item2.state == ClayState.Moving)
				{
					num3++;
				}
			}
			CharacterBody val6 = (Object.op_Implicit((Object)(object)item.healthComponent) ? item.healthComponent.body : null);
			float num4 = (Object.op_Implicit((Object)(object)val6) ? Mathf.Clamp(val6.radius, 0.5f, 6f) : 1f);
			float num5 = magnitude2 + (float)num3 * 6f / num4;
			if (num5 < num)
			{
				num = num5;
				result = item;
			}
		}
		return result;
	}

	private HurtBox SeekGround(CharacterBody owner, Vector3 around)
	{
		//IL_0009: 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_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		HurtBox result = null;
		float num = float.MaxValue;
		foreach (HurtBox item in Combat.Around(owner, around + Vector3.up, Tuning.SnakeSeek.Value, sight: false))
		{
			CharacterBody val = (Object.op_Implicit((Object)(object)item.healthComponent) ? item.healthComponent.body : null);
			if (!Object.op_Implicit((Object)(object)val) || val.isFlying)
			{
				continue;
			}
			Vector3 val2 = Combat.Point(item, around) - around;
			val2.y = 0f;
			float magnitude = ((Vector3)(ref val2)).magnitude;
			int num2 = 0;
			foreach (ClayCharge item2 in All)
			{
				if ((Object)(object)item2 != (Object)(object)this && Object.op_Implicit((Object)(object)item2.target) && (Object)(object)item2.target.healthComponent == (Object)(object)item.healthComponent && item2.state == ClayState.Moving)
				{
					num2++;
				}
			}
			float num3 = magnitude + (float)num2 * 7f;
			if (num3 < num)
			{
				num = num3;
				result = item;
			}
		}
		return result;
	}

	private void StepBird(CharacterBody owner, float dt)
	{
		//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_00a5: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: 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_008d: 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_0076: 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_0085: 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_00d1: 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_00e5: 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_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: 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_0126: 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_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: 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_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		float fixedTime = Time.fixedTime;
		if ((!Object.op_Implicit((Object)(object)target) || !Object.op_Implicit((Object)(object)target.healthComponent) || !target.healthComponent.alive) && fixedTime >= nextSeek)
		{
			nextSeek = fixedTime + 0.2f;
			target = SeekBird(owner);
		}
		Vector3 val = (Object.op_Implicit((Object)(object)target) ? Combat.Point(target, pos) : (hasAim ? aimPoint : (pos + travelDir * 30f)));
		Vector3 val2 = val - pos;
		float value = Tuning.C1BirdSpeed.Value;
		Vector3 val3 = ((((Vector3)(ref vel)).sqrMagnitude > 0.01f) ? ((Vector3)(ref vel)).normalized : travelDir);
		val3 = Vector3.RotateTowards(val3, ((Vector3)(ref val2)).normalized, (Object.op_Implicit((Object)(object)target) ? 9f : 5f) * dt, 0f);
		Vector3 val4 = val3 * value * dt;
		RaycastHit val5 = default(RaycastHit);
		if (Physics.SphereCast(pos, 0.45f, val3, ref val5, ((Vector3)(ref val4)).magnitude + 0.3f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.entityPrecise)).mask), (QueryTriggerInteraction)2))
		{
			HurtBox component = ((Component)((RaycastHit)(ref val5)).collider).GetComponent<HurtBox>();
			if (Combat.Target(component, owner))
			{
				AttachTo(component, ((RaycastHit)(ref val5)).point);
				return;
			}
		}
		if (Object.op_Implicit((Object)(object)target) && ((Vector3)(ref val2)).magnitude < 1f)
		{
			AttachTo(target, val);
			return;
		}
		RaycastHit val6 = default(RaycastHit);
		if (Physics.SphereCast(pos, 0.2f, val3, ref val6, ((Vector3)(ref val4)).magnitude + 0.2f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
		{
			Place(((RaycastHit)(ref val6)).point + ((RaycastHit)(ref val6)).normal * 0.12f);
			return;
		}
		if (!Object.op_Implicit((Object)(object)target) && hasAim && ((Vector3)(ref val2)).magnitude < value * dt * 1.5f)
		{
			Place(val);
			return;
		}
		vel = val3 * value;
		pos += val4;
		((Component)this).transform.position = pos;
		travelled += ((Vector3)(ref val4)).magnitude;
		if (travelled > 160f)
		{
			Place(pos);
		}
	}

	private HurtBox Seek(CharacterBody owner)
	{
		//IL_000a: 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_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: 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_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
		HurtBox result = null;
		float num = float.MaxValue;
		foreach (HurtBox item in Combat.Around(owner, pos + Vector3.up, Tuning.C1SpiderSeek.Value, sight: false))
		{
			Vector3 val = Combat.Point(item, pos);
			Vector3 val2 = val - pos;
			val2.y = 0f;
			float magnitude = ((Vector3)(ref val2)).magnitude;
			if (Mathf.Abs(val.y - pos.y