Decompiled source of Gaara v0.3.3

plugins/Gaara/Gaara.dll

Decompiled 20 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.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 KinematicCharacterController;
using On.RoR2;
using On.RoR2.UI;
using R2API;
using R2API.Utils;
using Rewired;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
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("Gaara")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+68d6fe91a1ed5e7ae9932b53bfa7ee1e841d6952")]
[assembly: AssemblyProduct("Gaara")]
[assembly: AssemblyTitle("Gaara")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace GaaraMod;

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", "Gaara.bnk");
		if (File.Exists(path))
		{
			SoundBanks.Add(File.ReadAllBytes(path));
		}
		else
		{
			Plugin.Log.LogWarning((object)"GAARA_AUDIO bank missing");
		}
	}

	public static uint Sfx(string key, GameObject at)
	{
		uint result = (Object.op_Implicit((Object)(object)at) ? AkSoundEngine.PostEvent("Play_Gaara_" + key, at) : 0u);
		Combat.Trace?.Invoke("SFX Play_Gaara_" + 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)("GAARA_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_Gaara_" + (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)("GAARA_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)("GAARA_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)("GAARA_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)("GAARA_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 sealed class SandBastionCast : BaseSkillState
{
	public Vector3 point;

	public Vector3 facing;

	public byte mode;

	private float duration;

	private ActionPlay act;

	public static float MinDist = 16f;

	public override void OnEnter()
	{
		//IL_01eb: 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_00b6: 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_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: 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_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: 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_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: 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_0119: 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_0182: 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_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: 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_01bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: 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_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: 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_0141: 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_038a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0390: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0303: Unknown result type (might be due to invalid IL or missing references)
		//IL_0308: Unknown result type (might be due to invalid IL or missing references)
		//IL_0316: Unknown result type (might be due to invalid IL or missing references)
		//IL_034b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0351: Unknown result type (might be due to invalid IL or missing references)
		((BaseState)this).OnEnter();
		BastionActor bastionActor = null;
		foreach (BastionActor item in BastionActor.Active)
		{
			if (Object.op_Implicit((Object)(object)item) && (Object)(object)item.owner == (Object)(object)((EntityState)this).gameObject && !item.Ending)
			{
				bastionActor = item;
			}
		}
		if (((EntityState)this).isAuthority)
		{
			if (Object.op_Implicit((Object)(object)bastionActor))
			{
				mode = 1;
				point = bastionActor.center;
				facing = -(bastionActor.rot * Vector3.forward);
			}
			else
			{
				mode = 0;
				Ray aimRay = ((BaseState)this).GetAimRay();
				point = (Combat.AimHit(aimRay, ((EntityState)this).characterBody, Tuning.BastionRange.Value + 30f, out var best, entities: false) ? ((RaycastHit)(ref best)).point : (((Ray)(ref aimRay)).origin + ((Ray)(ref aimRay)).direction * Tuning.BastionRange.Value));
				Vector3 v = point - ((EntityState)this).characterBody.footPosition;
				v.y = 0f;
				if (((Vector3)(ref v)).sqrMagnitude < 0.01f)
				{
					v = Aim.Flat(((Ray)(ref aimRay)).direction);
				}
				float num = Mathf.Clamp(((Vector3)(ref v)).magnitude, MinDist + BastionActor.ThickFor(Tuning.BastionHeight.Value) * 0.5f, Tuning.BastionRange.Value);
				point = ((EntityState)this).characterBody.footPosition + ((Vector3)(ref v)).normalized * num + Vector3.up * (point.y - ((EntityState)this).characterBody.footPosition.y);
				facing = Aim.Flat(v);
			}
		}
		if (Object.op_Implicit((Object)(object)((EntityState)this).characterDirection))
		{
			((EntityState)this).characterDirection.forward = facing;
		}
		CharVisual charVisual = CharVisual.Find(((EntityState)this).characterBody);
		bool flag = !GaaraFlight.IsFlying(((EntityState)this).characterBody) && Object.op_Implicit((Object)(object)((EntityState)this).characterMotor) && ((EntityState)this).characterMotor.isGrounded;
		if (mode == 0)
		{
			duration = 0.35f;
			if (Object.op_Implicit((Object)(object)charVisual) && Object.op_Implicit((Object)(object)charVisual.Anim) && TrackedReference.op_Implicit((TrackedReference)(object)charVisual.Anim["skl2_s"]))
			{
				act = new ActionPlay
				{
					clip = "skl2_s",
					startF = 8f,
					endF = 24f,
					duration = duration
				};
				if (flag)
				{
					charVisual.PlayAction(act);
				}
			}
			if (Object.op_Implicit((Object)(object)charVisual) && Object.op_Implicit((Object)(object)charVisual.GourdMouth))
			{
				Transform gm = charVisual.GourdMouth;
				Vector3 tgt = Combat.Ground(point + Vector3.up * 3f, 30f);
				SandVfx.Stream(gm, tgt, 0.3f, 1.2f);
				SandTube.Make(SandTube.Arc(() => (!Object.op_Implicit((Object)(object)gm)) ? tgt : gm.position, () => tgt, 4f), 0.3f, 0.16f, 0f, 0.6f, 0.05f, 0.2f);
			}
			if (NetworkServer.active)
			{
				BastionActor.Spawn(((EntityState)this).characterBody, point, facing);
			}
			Snd.Voice(((EntityState)this).characterBody, "Bastion", 2.5f, grunt: true);
		}
		else
		{
			duration = 0.45f;
			if (Object.op_Implicit((Object)(object)charVisual) && Object.op_Implicit((Object)(object)charVisual.Anim) && TrackedReference.op_Implicit((TrackedReference)(object)charVisual.Anim["skl1_s"]))
			{
				act = new ActionPlay
				{
					clip = "skl1_s",
					startF = 14f,
					endF = 33f,
					duration = duration
				};
				if (flag)
				{
					charVisual.PlayAction(act);
				}
			}
			if (NetworkServer.active && Object.op_Implicit((Object)(object)bastionActor))
			{
				bastionActor.Collapse();
			}
		}
		Combat.Trace?.Invoke("BASTION_CAST mode=" + ((mode == 0) ? "raise" : "collapse") + " t=" + Time.time.ToString("0.000"));
	}

	public override void FixedUpdate()
	{
		((EntityState)this).FixedUpdate();
		if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= duration)
		{
			((EntityState)this).outer.SetNextStateToMain();
		}
	}

	public override void OnExit()
	{
		CharVisual charVisual = CharVisual.Find(((EntityState)this).characterBody);
		if (Object.op_Implicit((Object)(object)charVisual) && act != null)
		{
			charVisual.EndAction(act);
		}
		((EntityState)this).OnExit();
	}

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

	public override void OnSerialize(NetworkWriter w)
	{
		//IL_0015: 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)
		((BaseSkillState)this).OnSerialize(w);
		w.Write(mode);
		w.Write(point);
		w.Write(facing);
	}

	public override void OnDeserialize(NetworkReader r)
	{
		//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_0021: 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)
		((BaseSkillState)this).OnDeserialize(r);
		mode = r.ReadByte();
		point = r.ReadVector3();
		facing = r.ReadVector3();
	}
}
public sealed class BastionActor : NetworkBehaviour
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static hook_IsColliderValidForCollisions <>9__43_0;

		internal bool <Build>b__43_0(orig_IsColliderValidForCollisions orig, CharacterMotor self, Collider coll)
		{
			//IL_0060: 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)
			if (Object.op_Implicit((Object)(object)coll) && ((Component)coll).gameObject.layer == LayerIndex.collideWithCharacterHullOnly.intVal)
			{
				BastionActor componentInParent = ((Component)coll).GetComponentInParent<BastionActor>();
				if (Object.op_Implicit((Object)(object)componentInParent) && Object.op_Implicit((Object)(object)self) && Object.op_Implicit((Object)(object)self.body) && Object.op_Implicit((Object)(object)self.body.teamComponent) && self.body.teamComponent.teamIndex == componentInParent.team)
				{
					return false;
				}
			}
			return orig.Invoke(self, coll);
		}
	}

	public static GameObject Prefab;

	public static readonly List<BastionActor> Active = new List<BastionActor>();

	public static int Spawned;

	public static int Deleted;

	public static int PushedOut;

	public static int Collapses;

	public static int CollapseHits;

	public const float Rise = 0.6f;

	public const float Crumble = 0.8f;

	public const float Sink = 3f;

	public const float CollapseT = 0.95f;

	public const float CollapseHitAt = 0.32f;

	public const float FallT = 0.32f;

	public static float CollapseDamage = 7f;

	public static float CollapseAhead = 9f;

	public static float QaWidth = -1f;

	public static float QaHeight = -1f;

	public Vector3 center;

	public Quaternion rot;

	public float startTime;

	public float width;

	public float height;

	public float life;

	public float collapseAt = -1f;

	public TeamIndex team;

	public GameObject owner;

	private bool ending;

	private float endAt = -1f;

	private bool collapseHit;

	private CharacterBody ownerBody;

	private BoxCollider box;

	private float nextScan;

	private static readonly Collider[] buf = (Collider[])(object)new Collider[64];

	public readonly List<Vector4> Hits = new List<Vector4>();

	private bool granted;

	private bool released;

	private static readonly Dictionary<HealthComponent, HurtBox> hitBuf = new Dictionary<HealthComponent, HurtBox>();

	private static readonly List<CharacterBody> tmp = new List<CharacterBody>();

	public float Thick => ThickFor(height);

	public bool Ending
	{
		get
		{
			if (!ending)
			{
				return collapseAt >= 0f;
			}
			return true;
		}
	}

	private float Now
	{
		get
		{
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				return Time.fixedTime;
			}
			return Run.instance.fixedTime;
		}
	}

	public float Age => Now - startTime;

	public float EndAge
	{
		get
		{
			if (!(collapseAt >= 0f))
			{
				if (!ending)
				{
					return life;
				}
				return endAt;
			}
			return collapseAt + 0.95f;
		}
	}

	private GenericSkill XSkill
	{
		get
		{
			if (!Object.op_Implicit((Object)(object)ownerBody))
			{
				return null;
			}
			return ((Component)ownerBody).GetComponent<ExtraSkillLocator>()?.extraFirst;
		}
	}

	public float LookEnd => EndAge;

	public static float ThickFor(float h)
	{
		return Mathf.Clamp(h * 0.22f, 1.8f, 5.5f);
	}

	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
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Expected O, but got Unknown
		GameObject val = new GameObject("GaaraSandBastion");
		val.AddComponent<NetworkIdentity>();
		val.AddComponent<BastionActor>();
		Prefab = PrefabAPI.InstantiateClone(val, "GaaraSandBastion", true);
		Object.DestroyImmediate((Object)val);
		Plugin.NetworkPrefabs.Add(Prefab);
		object obj = <>c.<>9__43_0;
		if (obj == null)
		{
			hook_IsColliderValidForCollisions val2 = delegate(orig_IsColliderValidForCollisions orig, CharacterMotor self, Collider coll)
			{
				//IL_0060: 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)
				if (Object.op_Implicit((Object)(object)coll) && ((Component)coll).gameObject.layer == LayerIndex.collideWithCharacterHullOnly.intVal)
				{
					BastionActor componentInParent = ((Component)coll).GetComponentInParent<BastionActor>();
					if (Object.op_Implicit((Object)(object)componentInParent) && Object.op_Implicit((Object)(object)self) && Object.op_Implicit((Object)(object)self.body) && Object.op_Implicit((Object)(object)self.body.teamComponent) && self.body.teamComponent.teamIndex == componentInParent.team)
					{
						return false;
					}
				}
				return orig.Invoke(self, coll);
			};
			<>c.<>9__43_0 = val2;
			obj = (object)val2;
		}
		CharacterMotor.IsColliderValidForCollisions += (hook_IsColliderValidForCollisions)obj;
	}

	public unsafe static void Spawn(CharacterBody owner, Vector3 point, Vector3 facing)
	{
		//IL_0052: 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_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: 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_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: 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_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_0170: 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_018b: 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_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)
		if (!NetworkServer.active || !Object.op_Implicit((Object)(object)owner))
		{
			return;
		}
		BastionActor[] array = Active.ToArray();
		foreach (BastionActor bastionActor in array)
		{
			if (Object.op_Implicit((Object)(object)bastionActor) && (Object)(object)bastionActor.owner == (Object)(object)((Component)owner).gameObject)
			{
				bastionActor.EndNow();
			}
		}
		Vector3 val = Combat.Ground(point + Vector3.up * 3f, 30f);
		GameObject obj = Object.Instantiate<GameObject>(Prefab, val, Quaternion.LookRotation(-facing));
		BastionActor component = obj.GetComponent<BastionActor>();
		component.center = val;
		component.rot = Quaternion.LookRotation(-facing);
		component.team = owner.teamComponent.teamIndex;
		component.owner = ((Component)owner).gameObject;
		component.ownerBody = owner;
		component.startTime = (Object.op_Implicit((Object)(object)Run.instance) ? Run.instance.fixedTime : Time.fixedTime);
		component.width = ((QaWidth > 0f) ? QaWidth : Tuning.BastionWidth.Value);
		component.height = ((QaHeight > 0f) ? QaHeight : Tuning.BastionHeight.Value);
		component.life = Tuning.BastionDuration.Value;
		NetworkServer.Spawn(obj);
		Spawned++;
		Action<string> trace = Combat.Trace;
		if (trace != null)
		{
			string[] obj2 = new string[10] { "BASTION spawn at=", null, null, null, null, null, null, null, null, null };
			Vector3 val2 = val;
			obj2[1] = ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString();
			obj2[2] = " dist=";
			val2 = val - owner.footPosition;
			obj2[3] = ((Vector3)(ref val2)).magnitude.ToString("0.0");
			obj2[4] = " size=";
			obj2[5] = component.width.ToString("0");
			obj2[6] = "x";
			obj2[7] = component.height.ToString("0");
			obj2[8] = " thick=";
			obj2[9] = component.Thick.ToString("0.0");
			trace(string.Concat(obj2));
		}
	}

	public void EndNow()
	{
		if (!ending)
		{
			ending = true;
			endAt = Age;
			((NetworkBehaviour)this).SetDirtyBit(1u);
		}
	}

	public void Collapse()
	{
		if (NetworkServer.active && !Ending)
		{
			collapseAt = Age;
			Collapses++;
			((NetworkBehaviour)this).SetDirtyBit(1u);
			Combat.Trace?.Invoke("RAMPART_COLLAPSE start age=" + Age.ToString("0.00"));
		}
	}

	private void OnEnable()
	{
		Active.Add(this);
	}

	private void OnDisable()
	{
		Active.Remove(this);
		ReleaseSkill();
	}

	private void Start()
	{
		//IL_0007: 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_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Expected O, but got Unknown
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		((Component)this).transform.position = center;
		((Component)this).transform.rotation = rot;
		if (!Object.op_Implicit((Object)(object)ownerBody) && Object.op_Implicit((Object)(object)owner))
		{
			ownerBody = owner.GetComponent<CharacterBody>();
		}
		GameObject val = new GameObject("BastionCollider");
		val.layer = LayerIndex.collideWithCharacterHullOnly.intVal;
		val.transform.SetParent(((Component)this).transform, false);
		box = val.AddComponent<BoxCollider>();
		box.size = new Vector3(width, height + 3f, Thick);
		box.center = new Vector3(0f, (height - 3f) * 0.5f, 0f);
		((Component)this).gameObject.AddComponent<BastionLook>().actor = this;
	}

	private void HoldSkill()
	{
		if (!Object.op_Implicit((Object)(object)ownerBody) || !ownerBody.hasEffectiveAuthority || released)
		{
			return;
		}
		GenericSkill xSkill = XSkill;
		if (!Object.op_Implicit((Object)(object)xSkill))
		{
			return;
		}
		if (!Ending)
		{
			if (!granted)
			{
				granted = true;
				if (xSkill.stock < 1)
				{
					xSkill.stock = 1;
				}
			}
			xSkill.rechargeStopwatch = 0f;
		}
		else
		{
			ReleaseSkill();
		}
	}

	private void ReleaseSkill()
	{
		if (granted && !released)
		{
			released = true;
			GenericSkill xSkill = XSkill;
			if (Object.op_Implicit((Object)(object)xSkill) && Object.op_Implicit((Object)(object)ownerBody) && ownerBody.hasEffectiveAuthority)
			{
				xSkill.stock = Mathf.Max(0, xSkill.stock - 1);
				xSkill.rechargeStopwatch = 0f;
				Combat.Trace?.Invoke("BASTION cooldown starts (wall ended) stock=" + xSkill.stock);
			}
		}
	}

	private void FixedUpdate()
	{
		float age = Age;
		float num = Mathf.Clamp01(age / 0.6f);
		float num2 = Mathf.Clamp01((age - EndAge) / 0.8f);
		HoldSkill();
		bool flag = collapseAt >= 0f && age >= collapseAt + 0.192f;
		if (Object.op_Implicit((Object)(object)box))
		{
			((Collider)box).enabled = num > 0.5f && num2 < 0.4f && !flag;
		}
		if (!NetworkServer.active)
		{
			return;
		}
		if (collapseAt >= 0f && !collapseHit && age >= collapseAt + 0.32f)
		{
			collapseHit = true;
			CollapseStrike();
		}
		if (age >= EndAge + ((collapseAt >= 0f) ? 0.4f : 0.90000004f) || !Object.op_Implicit((Object)(object)owner))
		{
			NetworkServer.Destroy(((Component)this).gameObject);
		}
		else if (age < EndAge && collapseAt < 0f)
		{
			PushOutEnemies();
			if (Time.fixedTime >= nextScan)
			{
				nextScan = Time.fixedTime + 0.08f;
				DeleteProjectiles();
			}
		}
	}

	private void CollapseStrike()
	{
		//IL_001c: 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_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: 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_0056: 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_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)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: 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_00f5: 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_010c: 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_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)ownerBody))
		{
			return;
		}
		float num = Thick + CollapseAhead;
		Vector3 val = -(rot * Vector3.forward);
		Vector3 val2 = center + val * (num * 0.5f - Thick * 0.5f) + Vector3.up * 3f;
		Vector3 val3 = default(Vector3);
		((Vector3)(ref val3))..ctor(width * 0.5f + 1f, 9f, num * 0.5f);
		Combat.Box(ownerBody, val2, val3, Quaternion.LookRotation(val), hitBuf);
		bool crit = ownerBody.RollCrit();
		int num2 = 0;
		Combat.Source = "X.RampartCollapse";
		foreach (KeyValuePair<HealthComponent, HurtBox> item in hitBuf)
		{
			HurtBox value = item.Value;
			if (Combat.Deal(ownerBody, value, ((Component)value).transform.position, CollapseDamage, 1f, crit, val * 1500f + Vector3.down * 600f, (DamageType)0, ((Component)this).gameObject, (DamageColorIndex)0, (DamageSource)8))
			{
				num2++;
				CharacterBody val4 = (Object.op_Implicit((Object)(object)value.healthComponent) ? value.healthComponent.body : null);
				if (Object.op_Implicit((Object)(object)val4) && value.healthComponent.alive)
				{
					Sanded.Apply(val4);
				}
			}
		}
		CollapseHits += num2;
		Action<string> trace = Combat.Trace;
		if (trace != null)
		{
			string[] obj = new string[8]
			{
				"RAMPART_COLLAPSE hit victims=",
				num2.ToString(),
				" candidates=",
				hitBuf.Count.ToString(),
				" box=",
				null,
				null,
				null
			};
			Vector3 val5 = val3 * 2f;
			obj[5] = ((Vector3)(ref val5)).ToString("F0");
			obj[6] = " t=";
			obj[7] = Time.time.ToString("0.000");
			trace(string.Concat(obj));
		}
	}

	public bool InBox(Vector3 p, float pad)
	{
		//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_000b: 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_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: 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_0057: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = Quaternion.Inverse(rot) * (p - center);
		if (Mathf.Abs(val.x) < width * 0.5f + pad && val.y > -1f - pad && val.y < height + pad)
		{
			return Mathf.Abs(val.z) < Thick * 0.5f + pad;
		}
		return false;
	}

	private void PushOutEnemies()
	{
		//IL_0052: 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_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_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_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_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: 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_013d: 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_0148: 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_015d: 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_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: 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_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: 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_01b4: 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)
		tmp.Clear();
		tmp.AddRange(CharacterBody.readOnlyInstancesList);
		foreach (CharacterBody item in tmp)
		{
			if (!Object.op_Implicit((Object)(object)item) || !Object.op_Implicit((Object)(object)item.teamComponent) || item.teamComponent.teamIndex == team || !Object.op_Implicit((Object)(object)item.characterMotor) || !Object.op_Implicit((Object)(object)item.healthComponent) || !item.healthComponent.alive)
			{
				continue;
			}
			Vector3 val = Quaternion.Inverse(rot) * (item.footPosition - center);
			float num = Thick * 0.5f + 0.5f;
			if (!(Mathf.Abs(val.x) > width * 0.5f + 0.3f) && !(val.y < -2f) && !(val.y > height) && !(Mathf.Abs(val.z) >= num))
			{
				float num2 = ((val.z >= 0f) ? 1f : (-1f));
				Vector3 val2 = center + rot * new Vector3(val.x, val.y, num2 * (num + 0.05f));
				CharacterMotor characterMotor = item.characterMotor;
				Vector3 val3 = rot * Vector3.forward * num2;
				Vector3 velocity = characterMotor.velocity;
				float num3 = Vector3.Dot(velocity, val3);
				if (num3 < 0f)
				{
					characterMotor.velocity = velocity - val3 * num3;
				}
				((BaseCharacterController)characterMotor).Motor.SetPosition(val2 + (item.transform.position - item.footPosition), true);
				PushedOut++;
			}
		}
	}

	private void DeleteProjectiles()
	{
		//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_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		int num = Physics.OverlapBoxNonAlloc(((Component)this).transform.position + rot * (Vector3.up * height * 0.5f), new Vector3(width * 0.5f + 0.4f, height * 0.5f + 0.4f, Thick * 0.5f + 0.7f), buf, rot, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.projectile)).mask), (QueryTriggerInteraction)2);
		for (int i = 0; i < num; i++)
		{
			ProjectileController val = (Object.op_Implicit((Object)(object)buf[i]) ? ((Component)buf[i]).GetComponentInParent<ProjectileController>() : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				TeamFilter teamFilter = val.teamFilter;
				if (!Object.op_Implicit((Object)(object)teamFilter) || teamFilter.teamIndex != team)
				{
					Fx.Emit(SandFx.WallHit, ((Component)val).transform.position, 1f, center);
					NetworkServer.Destroy(((Component)val).gameObject);
					Deleted++;
				}
			}
		}
	}

	public override bool OnSerialize(NetworkWriter w, bool initial)
	{
		//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_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Expected I4, but got Unknown
		w.Write(center);
		w.Write(rot);
		w.Write(startTime);
		w.Write(width);
		w.Write(height);
		w.Write(life);
		w.Write((int)team);
		w.Write(owner);
		w.Write(ending);
		w.Write(endAt);
		w.Write(collapseAt);
		return true;
	}

	public override void OnDeserialize(NetworkReader r, bool initial)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		center = r.ReadVector3();
		rot = r.ReadQuaternion();
		startTime = r.ReadSingle();
		width = r.ReadSingle();
		height = r.ReadSingle();
		life = r.ReadSingle();
		team = (TeamIndex)(sbyte)r.ReadInt32();
		owner = r.ReadGameObject();
		ending = r.ReadBoolean();
		endAt = r.ReadSingle();
		collapseAt = r.ReadSingle();
	}
}
public sealed class BastionHitFx : FxBase
{
	protected override void Begin()
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: 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_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_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00ad: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: 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_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: 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)
		life = 0.2f;
		BastionActor bastionActor = null;
		float num = 1E+09f;
		foreach (BastionActor item in BastionActor.Active)
		{
			if (Object.op_Implicit((Object)(object)item))
			{
				Vector3 val = item.center - data.start;
				float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
				if (sqrMagnitude < num)
				{
					num = sqrMagnitude;
					bastionActor = item;
				}
			}
		}
		if (Object.op_Implicit((Object)(object)bastionActor))
		{
			Vector3 val2 = Quaternion.Inverse(bastionActor.rot) * (data.origin - bastionActor.center);
			bastionActor.Hits.Add(new Vector4(val2.x, val2.y, (val2.z >= 0f) ? 1f : (-1f), Time.time));
			if (bastionActor.Hits.Count > 12)
			{
				bastionActor.Hits.RemoveAt(0);
			}
		}
		SandVfx.Puff(data.origin, 0.9f, Vector3.up, 2, 10, 1.2f);
		for (int i = 0; i < 14; i++)
		{
			Grains.Emit(data.origin, Random.onUnitSphere * Random.Range(3f, 7f) + Vector3.up * 2f, Random.Range(0.12f, 0.3f), 0.7f);
		}
		SandVfx.SfxAt("S_SandHit", data.origin);
	}
}
public sealed class BastionLook : MonoBehaviour
{
	public BastionActor actor;

	private Mesh mesh;

	private Vector3[] baseV;

	private Vector3[] v;

	private Vector2[] uv;

	private Renderer rend;

	private MaterialPropertyBlock mpb;

	private static readonly int fadeId = Shader.PropertyToID("_Fade");

	private bool burst;

	private bool crumbled;

	private bool collapsedFx;

	private bool impactFx;

	private float lastSpill;

	private float flowT;

	private int nx;

	private int ny;

	private int faceN;

	private float[] ground;

	private ParticleSystem trickle;

	private Mesh streakM;

	private Renderer streakR;

	private const int SK = 9;

	private const int SY = 12;

	private Vector2[] streakUV;

	private static Material WallMat => SandPalette.FlowSand;

	private void Start()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Expected O, but got Unknown
		//IL_00d7: 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_00f2: 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_00fc: 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_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: 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_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("BastionBody");
		val.transform.SetParent(((Component)this).transform, false);
		rend = (Renderer)(object)val.AddComponent<MeshRenderer>();
		rend.sharedMaterial = WallMat;
		rend.shadowCastingMode = (ShadowCastingMode)0;
		mpb = new MaterialPropertyBlock();
		nx = Mathf.Clamp(Mathf.RoundToInt(actor.width * 1.4f), 22, 72);
		ny = Mathf.Clamp(Mathf.RoundToInt(actor.height * 1.1f), 10, 28);
		ground = new float[nx + 1];
		RaycastHit val3 = default(RaycastHit);
		for (int i = 0; i <= nx; i++)
		{
			float num = ((float)i / (float)nx - 0.5f) * actor.width;
			Vector3 val2 = actor.center + actor.rot * new Vector3(num, 0f, 0f);
			ground[i] = (Physics.Raycast(val2 + Vector3.up * (actor.height * 0.5f + 3f), Vector3.down, ref val3, actor.height + 15f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1) ? (((RaycastHit)(ref val3)).point.y - actor.center.y) : 0f);
		}
		mesh = MakeMesh(actor.width * 0.96f, actor.height, actor.Thick * 0.8f, (int)(actor.startTime * 13f));
		val.AddComponent<MeshFilter>().sharedMesh = mesh;
		mesh.MarkDynamic();
		baseV = mesh.vertices;
		v = (Vector3[])baseV.Clone();
		uv = mesh.uv;
		BuildStreaks();
		Snd.Sfx("S_Goheki", ((Component)this).gameObject);
		Snd.Sfx("S_GroundHit", ((Component)this).gameObject);
		SandVfx.SfxAt("S_Sabaku", actor.center);
	}

	private void LateUpdate()
	{
		//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_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: 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_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_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: 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)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_028c: Unknown result type (might be due to invalid IL or missing references)
		//IL_028e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02da: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ff: 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_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_0325: Unknown result type (might be due to invalid IL or missing references)
		//IL_0328: Unknown result type (might be due to invalid IL or missing references)
		//IL_033e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0345: Unknown result type (might be due to invalid IL or missing references)
		//IL_034d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0354: Unknown result type (might be due to invalid IL or missing references)
		//IL_035d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0364: Unknown result type (might be due to invalid IL or missing references)
		//IL_036c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_043b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0453: 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_03d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0661: Unknown result type (might be due to invalid IL or missing references)
		//IL_0666: Unknown result type (might be due to invalid IL or missing references)
		//IL_0669: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_06be: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_06dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0713: Unknown result type (might be due to invalid IL or missing references)
		//IL_0720: Unknown result type (might be due to invalid IL or missing references)
		//IL_0725: 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_0731: Unknown result type (might be due to invalid IL or missing references)
		//IL_0733: Unknown result type (might be due to invalid IL or missing references)
		//IL_0735: Unknown result type (might be due to invalid IL or missing references)
		//IL_0737: Unknown result type (might be due to invalid IL or missing references)
		//IL_0741: Unknown result type (might be due to invalid IL or missing references)
		//IL_0984: Unknown result type (might be due to invalid IL or missing references)
		//IL_0989: Unknown result type (might be due to invalid IL or missing references)
		//IL_0999: Unknown result type (might be due to invalid IL or missing references)
		//IL_09a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_09a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_07bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a08: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a0a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a0f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a17: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a1c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a3b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a40: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a45: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c83: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c88: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c98: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a50: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a52: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a57: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a67: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a71: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a76: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a7b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a85: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a8a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a8f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a91: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a98: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a9a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aa4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aa9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aae: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ab2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b67: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b69: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b73: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b78: Unknown result type (might be due to invalid IL or missing references)
		//IL_0baa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bb6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bc2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bce: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bd5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bd9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bf7: 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_08d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e9: 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_0903: Unknown result type (might be due to invalid IL or missing references)
		//IL_090d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0912: Unknown result type (might be due to invalid IL or missing references)
		//IL_091c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0926: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cad: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cb2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cb7: Unknown result type (might be due to invalid IL or missing references)
		//IL_080c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0811: Unknown result type (might be due to invalid IL or missing references)
		//IL_0815: Unknown result type (might be due to invalid IL or missing references)
		//IL_081a: Unknown result type (might be due to invalid IL or missing references)
		//IL_081f: Unknown result type (might be due to invalid IL or missing references)
		//IL_083f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0844: Unknown result type (might be due to invalid IL or missing references)
		//IL_0849: Unknown result type (might be due to invalid IL or missing references)
		//IL_084d: Unknown result type (might be due to invalid IL or missing references)
		//IL_085d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0867: Unknown result type (might be due to invalid IL or missing references)
		//IL_086c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0878: Unknown result type (might be due to invalid IL or missing references)
		//IL_087c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0890: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f4b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f50: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f5c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f67: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f6c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f71: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f76: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f78: Unknown result type (might be due to invalid IL or missing references)
		//IL_0acc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ace: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ad3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ad8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ae9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b02: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b07: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b0c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b1d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b22: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f9d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ccf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cd4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cd9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cdb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fc2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e34: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e39: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e4a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e5a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e5f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e64: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e74: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e88: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e8d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d6f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d71: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d76: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d86: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d90: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d95: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d9a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dc9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dcf: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)actor) || (Object)(object)mesh == (Object)null)
		{
			return;
		}
		float age = actor.Age;
		float lookEnd = actor.LookEnd;
		float time = Time.time;
		float num = Mathf.Clamp01(age / 0.6f);
		num = 1f - (1f - num) * (1f - num) * (1f - num);
		bool flag = actor.collapseAt >= 0f;
		float num2 = (flag ? Mathf.Clamp01((age - actor.collapseAt) / 0.95f) : 0f);
		float num3 = (flag ? 0f : Mathf.Clamp01((age - lookEnd) / 0.8f));
		Vector3 val = actor.rot * Vector3.right;
		Vector3 val2 = actor.rot * Vector3.forward;
		if (!burst && age > 0.02f)
		{
			burst = true;
			for (int i = -4; i <= 4; i++)
			{
				SandVfx.Puff(actor.center + val * (float)i * actor.width * 0.11f + Vector3.up * 0.5f, 2.4f, Vector3.up, 3, 8, 1.2f);
			}
			Fx.Debris(actor.center + Vector3.up, actor.width * 0.3f, 10, 10f, 1.6f, 1.2f);
			ShakeEmitter.CreateSimpleShakeEmitter(actor.center, new Wave
			{
				amplitude = 1.6f,
				frequency = 16f
			}, 0.6f, 60f, true);
		}
		float num4 = (0f - (actor.height + 3f)) * (1f - num) - actor.height * 0.9f * num3 * num3;
		float num5 = (flag ? Mathf.Clamp01((age - actor.collapseAt) / 0.32f) : 0f);
		float num6 = num5 * num5;
		float num7 = (flag ? Mathf.Clamp01((age - actor.collapseAt - 0.32f) / 0.5f) : 0f);
		for (int j = 0; j < baseV.Length; j++)
		{
			Vector3 val3 = baseV[j];
			float num8 = Mathf.Clamp01(val3.y / actor.height);
			val3.y += num4;
			val3 += new Vector3(0f, 0f, Mathf.Sign(val3.z) * 0.025f * Mathf.Sin(time * 0.6f + val3.x * 0.3f + val3.y * 0.2f) * num8);
			for (int k = 0; k < actor.Hits.Count; k++)
			{
				Vector4 val4 = actor.Hits[k];
				float num9 = time - val4.w;
				if (!(num9 > 1.4f))
				{
					float num10 = (val3.x - val4.x) * (val3.x - val4.x) + (val3.y - val4.y) * (val3.y - val4.y);
					if (!(num10 > 9f))
					{
						float num11 = ((num9 < 0.08f) ? (num9 / 0.08f) : Mathf.Clamp01(1f - (num9 - 0.08f) / 1.2f)) * 1.6f * Mathf.Exp((0f - num10) / 3f) * ((Mathf.Sign(val3.z) == val4.z) ? 1f : 0.7f);
						val3.z -= Mathf.Sign(val3.z) * num11;
					}
				}
			}
			if (flag)
			{
				float num12 = num6 * 82f * (MathF.PI / 180f);
				float num13 = val3.y * (1f - 0.5f * num6);
				float z = val3.z;
				val3.y = num13 * Mathf.Cos(num12) + z * Mathf.Sin(num12) * 0.2f;
				val3.z = z * Mathf.Cos(num12) - num13 * Mathf.Sin(num12);
				val3.y *= 1f - 0.6f * num7;
				val3.x *= 1f + 0.04f * num7;
			}
			v[j] = val3;
		}
		flowT += Time.deltaTime * ((num < 1f) ? (0.45f * (1f - num) + 0.05f) : (flag ? 0.28f : ((num3 > 0f) ? 0.3f : 0f)));
		for (int l = 0; l < uv.Length; l++)
		{
			uv[l].y = baseV[l].y * 0.16f + flowT;
		}
		mesh.vertices = v;
		mesh.uv = uv;
		mesh.RecalculateNormals();
		mesh.RecalculateBounds();
		if (Object.op_Implicit((Object)(object)streakM))
		{
			if (Object.op_Implicit((Object)(object)streakR))
			{
				((Component)streakR).transform.localPosition = Vector3.up * num4;
			}
			for (int m = 0; m < streakUV.Length; m++)
			{
				streakUV[m].y = (float)(m / 2 % 13) / 12f * 3f - time * 0.8f;
			}
			streakM.uv = streakUV;
		}
		for (int n = 0; n < actor.Hits.Count; n++)
		{
			Vector4 val5 = actor.Hits[n];
			float num14 = time - val5.w;
			if (num14 > 0.1f && num14 < 1.1f && Random.value < 0.6f)
			{
				Vector3 val6 = actor.center + actor.rot * new Vector3(val5.x, val5.y, val5.z * actor.Thick * 0.5f);
				Vector3 val7 = val6 + actor.rot * new Vector3(Random.Range(-2f, 2f), Random.Range(0.5f, 2.5f), val5.z * 0.4f);
				Grains.Emit(val7, (val6 - val7) / 0.35f, 0.2f, 0.35f);
			}
		}
		if (num >= 1f && num3 <= 0f && !flag)
		{
			if (!Object.op_Implicit((Object)(object)trickle))
			{
				trickle = MakeTrickle();
			}
			int num15 = ((Random.value < Time.deltaTime * 14f) ? 1 : 0);
			EmitParams val8 = default(EmitParams);
			for (int num16 = 0; num16 < num15; num16++)
			{
				float num17 = Random.Range(-0.47f, 0.47f) * actor.width;
				float num18 = ((Random.value < 0.5f) ? 1f : (-1f));
				((EmitParams)(ref val8)).position = actor.center + val * num17 + Vector3.up * (actor.height * Random.Range(0.8f, 0.97f)) + val2 * num18 * actor.Thick * 0.45f;
				((EmitParams)(ref val8)).velocity = val2 * num18 * Random.Range(0.3f, 1.2f);
				trickle.Emit(val8, 1);
			}
			if (time - lastSpill > 1.8f)
			{
				lastSpill = time;
				SandVfx.Puff(actor.center + val * Random.Range(-0.45f, 0.45f) * actor.width + Vector3.up * 0.5f, 1.4f, Vector3.up * 0.3f, 1, 4, 1.2f);
			}
		}
		if (flag && !collapsedFx)
		{
			collapsedFx = true;
			if (Object.op_Implicit((Object)(object)trickle))
			{
				trickle.Stop();
			}
			Snd.Sfx("S_Sand4", ((Component)this).gameObject);
			SandVfx.SfxAt("S_RockDeep", actor.center + Vector3.up * actor.height * 0.6f);
			Combat.Trace?.Invoke("RAMPART_COLLAPSE look start t=" + time.ToString("0.000"));
		}
		Vector3 side;
		if (flag && !impactFx && age - actor.collapseAt >= 0.32f)
		{
			impactFx = true;
			Vector3 val9 = -val2;
			Vector3 val10 = actor.center + val9 * (actor.Thick * 0.5f + BastionActor.CollapseAhead * 0.75f);
			for (int num19 = -6; num19 <= 6; num19++)
			{
				Vector3 val11 = val10 + val * (float)num19 * actor.width * 0.075f + Vector3.up * 0.5f;
				side = val9 + Vector3.up * 0.3f;
				SandVfx.Puff(val11, 2.6f, ((Vector3)(ref side)).normalized, 2, 10, 1.4f);
				for (int num20 = 0; num20 < 10; num20++)
				{
					Grains.Emit(val11 + Random.insideUnitSphere, val9 * Random.Range(4f, 10f) + Vector3.up * Random.Range(3f, 9f) + val * Random.Range(-4f, 4f), Random.Range(0.2f, 0.45f), Random.Range(0.6f, 1f));
				}
			}
			Fx.Debris(val10 + Vector3.up * 1.5f, actor.width * 0.4f, 12, 11f, 1.6f, 1.1f);
			SandVfx.SfxAt("S_CmbL", val10);
			SandVfx.SfxAt("S_RockBig", val10);
			SandVfx.SfxAt("S_GroundHit", val10);
			SandVfx.SfxAt("S_Exp2", val10);
			ShakeEmitter.CreateSimpleShakeEmitter(val10, new Wave
			{
				amplitude = 2.6f,
				frequency = 14f
			}, 0.7f, 70f, true);
			Combat.Trace?.Invoke("RAMPART_COLLAPSE impact look t=" + time.ToString("0.000"));
		}
		if ((num3 > 0f || (flag && num2 >= 1f)) && !crumbled)
		{
			crumbled = true;
			if (Object.op_Implicit((Object)(object)trickle))
			{
				trickle.Stop();
			}
			Vector3 val12 = actor.center + Vector3.up * actor.height * (flag ? 0.15f : 0.5f) - val2 * (flag ? (BastionActor.CollapseAhead * 0.4f) : 0f);
			SandVfx.Return(val12, actor.owner);
			CharacterBody val13 = (Object.op_Implicit((Object)(object)actor.owner) ? actor.owner.GetComponent<CharacterBody>() : null);
			CharVisual charVisual = (Object.op_Implicit((Object)(object)val13) ? CharVisual.Find(val13) : null);
			Transform gm = (Object.op_Implicit((Object)(object)charVisual) ? charVisual.GourdMouth : null);
			if (Object.op_Implicit((Object)(object)gm))
			{
				for (int num21 = -2; num21 <= 2; num21++)
				{
					Vector3 src = val12 + val * (float)num21 * actor.width * 0.18f;
					Func<Vector3> a = () => src;
					Func<Vector3> b = () => (!Object.op_Implicit((Object)(object)gm)) ? src : gm.position;
					float lift = 4f + (float)Mathf.Abs(num21);
					side = default(Vector3);
					SandTube.Make(SandTube.Arc(a, b, lift, side), 0.45f + 0.05f * (float)Mathf.Abs(num21), 0.16f, 0f, 0.4f, 0.05f, 0.25f).grainRate = 0.6f;
				}
			}
			List<Vector3> list = new List<Vector3>();
			for (int num22 = 0; num22 < 14; num22++)
			{
				list.Add(actor.center + val * ((float)num22 / 13f - 0.5f) * actor.width + Vector3.up * actor.height * Random.Range(0.1f, 0.6f));
			}
			SandVfx.Crumble(list, 2.2f);
			if (!flag)
			{
				Snd.Sfx("S_Sand4", ((Component)this).gameObject);
			}
		}
		float num23 = (flag ? (1f - Mathf.Clamp01((num2 - 0.75f) / 0.25f) * 0f) : (1f - num3));
		if (flag && age > actor.collapseAt + 0.95f)
		{
			num23 = 1f - Mathf.Clamp01((age - actor.collapseAt - 0.95f) / 0.4f);
		}
		Camera val14 = Fx.Cam();
		if (Object.op_Implicit((Object)(object)val14))
		{
			Vector3 val15 = Quaternion.Inverse(actor.rot) * (((Component)val14).transform.position - actor.center);
			if (Mathf.Abs(val15.x) < actor.width * 0.5f + 6f && Mathf.Abs(val15.z) < actor.Thick * 0.5f + 20f && val15.y < actor.height + 6f)
			{
				num23 *= 0.4f;
			}
		}
		mpb.SetFloat(fadeId, num23);
		rend.SetPropertyBlock(mpb);
		if (Object.op_Implicit((Object)(object)streakR))
		{
			streakR.enabled = !flag && num > 0.3f && age < 1.05f;
			streakR.SetPropertyBlock(mpb);
		}
	}

	private void BuildStreaks()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Expected O, but got Unknown
		//IL_0109: 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_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("BastionStreaks");
		val.transform.SetParent(((Component)this).transform, false);
		streakM = new Mesh
		{
			name = "GaaraBastionStreaks"
		};
		List<Vector3> list = new List<Vector3>();
		List<Vector2> list2 = new List<Vector2>();
		List<int> list3 = new List<int>();
		for (int i = 0; i < 2; i++)
		{
			for (int j = 0; j < 9; j++)
			{
				float num = (((float)j + 0.5f) / 9f - 0.5f) * actor.width * 0.9f + (Mathf.PerlinNoise((float)j * 1.7f, (float)i) - 0.5f) * 3f;
				float num2 = 0.7f + 0.5f * Mathf.PerlinNoise((float)j, 3f);
				int count = list.Count;
				for (int k = 0; k <= 12; k++)
				{
					float num3 = (float)k / 12f;
					float[] array = new float[2]
					{
						0f - num2,
						num2
					};
					foreach (float num4 in array)
					{
						Vector3 item = Surface(num + num4, num3, (i == 0) ? 1f : (-1f));
						list.Add(item);
						list2.Add(new Vector2((num4 > 0f) ? 1f : 0f, num3 * 3f));
					}
				}
				for (int m = 0; m < 12; m++)
				{
					int num5 = count + m * 2;
					if (i == 0)
					{
						list3.AddRange(new int[6]
						{
							num5,
							num5 + 2,
							num5 + 1,
							num5 + 1,
							num5 + 2,
							num5 + 3
						});
					}
					else
					{
						list3.AddRange(new int[6]
						{
							num5,
							num5 + 1,
							num5 + 2,
							num5 + 1,
							num5 + 3,
							num5 + 2
						});
					}
				}
			}
		}
		streakM.SetVertices(list);
		streakM.SetUVs(0, list2);
		streakM.SetTriangles(list3, 0);
		streakM.RecalculateBounds();
		streakUV = list2.ToArray();
		val.AddComponent<MeshFilter>().sharedMesh = streakM;
		streakR = (Renderer)(object)val.AddComponent<MeshRenderer>();
		streakR.sharedMaterial = CoffinLook.StreamMat;
		streakR.shadowCastingMode = (ShadowCastingMode)0;
	}

	private Vector3 Surface(float x, float yy, float sz)
	{
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: 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_00b0: 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)
		int num = 0;
		float num2 = 1E+09f;
		int num3 = (nx + 1) * (ny + 1);
		int num4 = ((!(sz > 0f)) ? num3 : 0);
		int num5 = Mathf.Clamp(Mathf.RoundToInt(yy * (float)ny), 0, ny);
		for (int i = 0; i <= nx; i++)
		{
			float num6 = Mathf.Abs(baseV[num4 + num5 * (nx + 1) + i].x - x);
			if (num6 < num2)
			{
				num2 = num6;
				num = num4 + num5 * (nx + 1) + i;
			}
		}
		Vector3 val = baseV[num];
		return new Vector3(x, val.y, val.z + sz * 0.08f);
	}

	private ParticleSystem MakeTrickle()
	{
		//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_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: 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_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: 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_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Expected O, but got Unknown
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("BastionTrickle");
		val.transform.SetParent(((Component)this).transform, false);
		ParticleSystem val2 = val.AddComponent<ParticleSystem>();
		val2.Stop(true, (ParticleSystemStopBehavior)0);
		MainModule main = val2.main;
		((MainModule)(ref main)).loop = true;
		((MainModule)(ref main)).playOnAwake = false;
		((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.6f, 2.4f);
		((MainModule)(ref main)).startSize = new MinMaxCurve(0.12f, 0.3f);
		((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(SandPalette.Grain);
		((MainModule)(ref main)).maxParticles = 600;
		((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
		((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(1.1f);
		EmissionModule emission = val2.emission;
		((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
		ShapeModule shape = val2.shape;
		((ShapeModule)(ref shape)).enabled = false;
		ParticleSystemRenderer component = ((Component)val2).GetComponent<ParticleSystemRenderer>();
		((Renderer)component).sharedMaterial = SandVfx.Grains;
		((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
		TextureSheetAnimationModule textureSheetAnimation = val2.textureSheetAnimation;
		((TextureSheetAnimationModule)(ref textureSheetAnimation)).enabled = true;
		((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesX = 5;
		((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesY = 4;
		((TextureSheetAnimationModule)(ref textureSheetAnimation)).startFrame = new MinMaxCurve(0f, 19.99f);
		((TextureSheetAnimationModule)(ref textureSheetAnimation)).frameOverTime = new MinMaxCurve(0f, new AnimationCurve((Keyframe[])(object)new Keyframe[2]
		{
			new Keyframe(0f, 0f),
			new Keyframe(1f, 0f)
		}));
		val2.Play();
		return val2;
	}

	private Mesh MakeMesh(float w, float h, float t, int seed)
	{
		//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_0450: Unknown result type (might be due to invalid IL or missing references)
		//IL_0457: Unknown result type (might be due to invalid IL or missing references)
		//IL_045f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0467: 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_0474: Expected O, but got Unknown
		//IL_01bd: 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)
		List<Vector3> list = new List<Vector3>();
		List<Vector2> list2 = new List<Vector2>();
		List<int> list3 = new List<int>();
		int nb = 5;
		for (int i = 0; i < 2; i++)
		{
			float num = ((i == 0) ? 1f : (-1f));
			int count = list.Count;
			for (int j = 0; j <= ny; j++)
			{
				for (int k = 0; k <= nx; k++)
				{
					float num2 = ((float)k / (float)nx - 0.5f) * w;
					float num3 = (float)j / (float)ny;
					float num4 = G(num2) - 1.5f;
					float num5 = Top(num2);
					float num6 = num4 + (num5 - num4) * num3;
					float num7 = Mathf.Lerp(1.35f, 0.32f, Mathf.Pow(num3, 0.85f));
					float num8 = ((num3 > 0.86f) ? (0.35f * t * Mathf.Sin((num3 - 0.86f) / 0.14f * MathF.PI) * ((num > 0f) ? 1f : 0.5f)) : 0f);
					float num9 = t * num7 * (0.85f + 0.3f * N(num2 + num * 5f, num6, 0.12f)) + t * 1f * Butt(num2) * Mathf.Lerp(1.2f, 0.35f, num3) * (1f - num3 * 0.3f) + num8 + 0.15f * (N(num2 * 1.7f, num6 * 0.4f, 0.5f) - 0.5f);
					list.Add(new Vector3(num2, num6, num * num9));
					list2.Add(new Vector2(num2 * 0.3f, num6 * 0.3f));
				}
			}
			for (int l = 0; l < ny; l++)
			{
				for (int m = 0; m < nx; m++)
				{
					int num10 = count + l * (nx + 1) + m;
					int num11 = num10 + nx + 1;
					if (i == 0)
					{
						list3.AddRange(new int[6]
						{
							num10,
							num11,
							num10 + 1,
							num10 + 1,
							num11,
							num11 + 1
						});
					}
					else
					{
						list3.AddRange(new int[6]
						{
							num10,
							num10 + 1,
							num11,
							num10 + 1,
							num11 + 1,
							num11
						});
					}
				}
			}
		}
		int num12 = ny * (nx + 1);
		int num13 = (nx + 1) * (ny + 1) + ny * (nx + 1);
		for (int n = 0; n < nx; n++)
		{
			int num14 = num12 + n;
			int num15 = num13 + n;
			list3.AddRange(new int[6]
			{
				num14,
				num14 + 1,
				num15,
				num14 + 1,
				num15 + 1,
				num15
			});
		}
		for (int num16 = 0; num16 < ny; num16++)
		{
			int num17 = num16 * (nx + 1);
			int num18 = (nx + 1) * (ny + 1) + num16 * (nx + 1);
			list3.AddRange(new int[6]
			{
				num17,
				num17 + nx + 1,
				num18,
				num18,
				num17 + nx + 1,
				num18 + nx + 1
			});
			int num19 = num17 + nx;
			int num20 = num18 + nx;
			list3.AddRange(new int[6]
			{
				num19,
				num20,
				num19 + nx + 1,
				num20,
				num20 + nx + 1,
				num19 + nx + 1
			});
		}
		Mesh val = new Mesh
		{
			name = "GaaraBastion"
		};
		val.SetVertices(list);
		val.SetUVs(0, list2);
		val.SetTriangles(list3, 0);
		val.RecalculateNormals();
		val.RecalculateBounds();
		return val;
		float Butt(float x)
		{
			float num21 = 0f;
			for (int num22 = 0; num22 < nb; num22++)
			{
				float num23 = (((float)num22 + 0.5f) / (float)nb - 0.5f) * w * 0.9f;
				float num24 = (x - num23) / (w * 0.06f);
				num21 += Mathf.Exp((0f - num24) * num24 * 0.8f);
			}
			return num21;
		}
		float G(float x)
		{
			float num21 = (x / w + 0.5f) * (float)nx;
			int num22 = Mathf.Clamp((int)num21, 0, nx);
			int num23 = Mathf.Min(nx, num22 + 1);
			return Mathf.Lerp(ground[num22], ground[num23], num21 - (float)num22);
		}
		float N(float x, float y, float s)
		{
			float num21 = Mathf.PerlinNoise(x * s + (float)seed * 0.37f, y * s + (float)seed * 0.11f);
			float num22 = Mathf.PerlinNoise(x * s * 2.3f + 7.1f, y * s * 2.3f + 3.3f);
			return num21 * 0.7f + num22 * 0.3f;
		}
		float Top(float x)
		{
			float num21 = x / w + 0.5f;
			float num22 = 0.06f * Mathf.Max(0f, Mathf.Sin(x * 1.1f + (float)seed));
			return h * (0.86f + 0.1f * N(x, 0f, 0.12f) + 0.06f * (N(x * 3.1f, 4f, 0.5f) - 0.5f) * 2f + num22) * (1f - 0.35f * Mathf.Pow(Mathf.Abs(num21 * 2f - 1f), 4f));
		}
	}
}
public sealed class SandCoffinCast : BaseSkillState
{
	private sealed class CoffinVoiceState
	{
		public float last = -99f;

		public int count;
	}

	public byte mode = 2;

	public GameObject victim;

	public static float CoffinVoiceCd = 6f;

	private float duration;

	private ActionPlay act;

	public static float ConeDeg = 8f;

	public static float ConePad = 1.3f;

	private static readonly Dictionary<int, CoffinVoiceState> coffinVoice = new Dictionary<int, CoffinVoiceState>();

	public static float Range => Tuning.CoffinRange.Value;

	public override void OnEnter()
	{
		//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dd: 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_0168: Unknown result type (might be due to invalid IL or missing references)
		((BaseState)this).OnEnter();
		if (((EntityState)this).isAuthority)
		{
			Decide();
		}
		CharVisual charVisual = CharVisual.Find(((EntityState)this).characterBody);
		bool flag = Object.op_Implicit((Object)(object)charVisual) && CharVisual.IsKid(charVisual.ShownSkin);
		bool flag2 = !GaaraFlight.IsFlying(((EntityState)this).characterBody) && Object.op_Implicit((Object)(object)((EntityState)this).characterMotor) && ((EntityState)this).characterMotor.isGrounded;
		if (mode == 0)
		{
			duration = 0.3f;
			if (Object.op_Implicit((Object)(object)charVisual) && Object.op_Implicit((Object)(object)charVisual.Anim) && TrackedReference.op_Implicit((TrackedReference)(object)charVisual.Anim["skl2_s"]))
			{
				act = new ActionPlay
				{
					clip = "skl2_s",
					startF = 10f,
					endF = 24f,
					duration = duration
				};
				if (flag2)
				{
					charVisual.PlayAction(act);
				}
			}
			CharacterBody val = (Object.op_Implicit((Object)(object)victim) ? victim.GetComponent<CharacterBody>() : null);
			if (Object.op_Implicit((Object)(object)charVisual) && Object.op_Implicit((Object)(object)charVisual.GourdMouth) && Object.op_Implicit((Object)(object)val))
			{
				Transform gm = charVisual.GourdMouth;
				CharacterBody vbc = val;
				SandTube.Make(SandTube.Arc(() => (!Object.op_Implicit((Object)(object)gm)) ? vbc.corePosition : gm.position, () => (!Object.op_Implicit((Object)(object)vbc)) ? gm.position : vbc.corePosition, 1.2f), 0.22f, 0.12f, 0f, 0.7f, 0.04f, 0.14f);
			}
			CoffinVoice(((EntityState)this).characterBody, flag);
			if (NetworkServer.active && Object.op_Implicit((Object)(object)val))
			{
				CoffinActor.Spawn(((EntityState)this).characterBody, val);
			}
		}
		else if (mode == 1)
		{
			duration = 0.5f;
			if (Object.op_Implicit((Object)(object)charVisual) && Object.op_Implicit((Object)(object)charVisual.Anim) && TrackedReference.op_Implicit((TrackedReference)(object)charVisual.Anim["skl1_s"]))
			{
				act = new ActionPlay
				{
					clip = "skl1_s",
					startF = 14f,
					endF = 33f,
					duration = duration
				};
				if (flag2)
				{
					charVisual.PlayAction(act);
				}
			}
			Snd.Voice(((EntityState)this).characterBody, flag ? "BurialKid" : "Burial", 2.5f);
			if (NetworkServer.active)
			{
				CoffinActor.Bury(((EntityState)this).characterBody);
			}
			if (((EntityState)this).isAuthority && Object.op_Implicit((Object)(object)((BaseSkillState)this).activatorSkillSlot))
			{
				((BaseSkillState)this).activatorSkillSlot.DeductStock(1);
			}
		}
		else
		{
			duration = 0.05f;
		}
		if (Object.op_Implicit((Object)(object)((EntityState)this).characterDirection) && mode != 2)
		{
			CharacterDirection characterDirection = ((EntityState)this).characterDirection;
			Ray aimRay = ((BaseState)this).GetAimRay();
			characterDirection.forward = Aim.Flat(((Ray)(ref aimRay)).direction);
		}
		Combat.Trace?.Invoke("COFFIN_CAST mode=" + ((mode == 0) ? "coffin" : ((mode == 1) ? "burial" : "none")) + " victim=" + (Object.op_Implicit((Object)(object)victim) ? ((Object)victim).name : "-") + " active=" + CoffinActor.CountFor(((EntityState)this).gameObject));
	}

	private static void CoffinVoice(CharacterBody body, bool kid)
	{
		if (!Object.op_Implicit((Object)(object)body))
		{
			return;
		}
		int instanceID = ((Object)body).GetInstanceID();
		if (!coffinVoice.TryGetValue(instanceID, out var value))
		{
			value = (coffinVoice[instanceID] = new CoffinVoiceState());
		}
		if (Time.time - value.last <= CoffinVoiceCd)
		{
			Plugin.Log.LogInfo((object)("GAARA_VOICE coffin cooldown age=" + (Time.time - value.last).ToString("0.0") + " next=" + ((value.count % 2 == 0) ? "CoffinSabaku" : "Coffin")));
			return;
		}
		bool flag = value.count % 2 == 0;
		string key = (flag ? "CoffinSabaku" : "Coffin");
		if (Snd.Voice(body, key, flag ? 2.5f : 1.2f, grunt: false, 2, log: true))
		{
			value.last = Time.time;
			value.count++;
			Combat.Trace?.Invoke("COFFIN_VOICE " + (flag ? "CoffinSabaku (v_spl 144 trimmed: Sand Coffin!)" : "Coffin (2gar_pl 21: You can't escape!)") + " n=" + value.count + " kid=" + kid + " t=" + Time.time.ToString("0.00"));
		}
	}

	private void Decide()
	{
		//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_0068: 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_006f: 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_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: 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_009b: 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_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: 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_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		Ray aimRay = ((BaseState)this).GetAimRay();
		Vector3 corePosition = ((EntityState)this).characterBody.corePosition;
		float num = Mathf.Tan(ConeDeg * (MathF.PI / 180f));
		CharacterBody val = null;
		CharacterBody val2 = null;
		float num2 = float.MaxValue;
		float num3 = float.MaxValue;
		bool flag = false;
		foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
		{
			if (!Combat.TargetBody(readOnlyInstances, ((EntityState)this).characterBody))
			{
				continue;
			}
			Vector3 corePosition2 = readOnlyInstances.corePosition;
			Vector3 val3 = corePosition2 - ((Ray)(ref aimRay)).origin;
			float num4 = Vector3.Dot(val3, ((Ray)(ref aimRay)).direction);
			if (num4 < 1f)
			{
				continue;
			}
			Vector3 val4 = corePosition2 - corePosition;
			if (((Vector3)(ref val4)).magnitude > Range)
			{
				continue;
			}
			val4 = val3 - ((Ray)(ref aimRay)).direction * num4;
			float magnitude = ((Vector3)(ref val4)).magnitude;
			float num5 = ConePad + readOnlyInstances.bestFitRadius * 0.5f + num4 * num;
			if (magnitude > num5 || (!Combat.Visible(((Ray)(ref aimRay)).origin, corePosition2) && !Combat.Visible(corePosition, corePosition2)))
			{
				continue;
			}
			bool flag2 = CoffinActor.IsCoffined(((Component)readOnlyInstances).gameObject);
			bool flag3 = !flag2 && Sanded.Has(readOnlyInstances);
			if (!flag2 && !flag3)
			{
				continue;
			}
			float num6 = Mathf.Max(0.6f, readOnlyInstances.bestFitRadius * 0.7f);
			if (magnitude <= num6)
			{
				float num7 = magnitude / num6 - (flag3 ? 0.05f : 0f);
				if (num7 < num3)
				{
					num3 = num7;
					val2 = readOnlyInstances;
					flag = flag2;
				}
			}
			if (flag3)
			{
				float num8 = magnitude / num4;
				if (num8 < num2)
				{
					num2 = num8;
					val = readOnlyInstances;
				}
			}
		}
		if (Object.op_Implicit((Object)(object)val2))
		{
			mode = (flag ? ((byte)1) : ((byte)0));
			victim = ((Component)val2).gameObject;
		}
		else if (Object.op_Implicit((Object)(object)val))
		{
			mode = 0;
			victim = ((Component)val).gameObject;
		}
		else if (CoffinActor.CountFor(((EntityState)this).gameObject) > 0)
		{
			mode = 1;
			victim = null;
		}
		else
		{
			mode = 2;
			victim = null;
		}
	}

	public override void FixedUpdate()
	{
		((EntityState)this).FixedUpdate();
		if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= duration)
		{
			((EntityState)this).outer.SetNextStateToMain();
		}
	}

	public override void OnExit()
	{
		CharVisual charVisual = CharVisual.Find(((EntityState)this).characterBody);
		if (Object.op_Implicit((Object)(object)charVisual) && act != null)
		{
			charVisual.EndAction(act);
		}
		((EntityState)this).OnExit();
	}

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

	public override void OnSerialize(NetworkWriter w)
	{
		((BaseSkillState)this).OnSerialize(w);
		w.Write(mode);
		w.Write(victim);
	}

	public override void OnDeserialize(NetworkReader r)
	{
		((BaseSkillState)this).OnDeserialize(r);
		mode = r.ReadByte();
		victim = r.ReadGameObject();
	}
}
public sealed class CoffinHeld : EntityState
{
	public override void FixedUpdate()
	{
		((EntityState)this).FixedUpdate();
		if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge > 0.1f && !CoffinActor.IsBound(((EntityState)this).gameObject))
		{
			base.outer.SetNextStateToMain();
		}
		if (((EntityState)this).fixedAge > Tuning.CoffinDuration.Value + 5f && ((EntityState)this).isAuthority)
		{
			base.outer.SetNextStateToMain();
		}
	}

	public override InterruptPriority GetMinimumInterruptPriority()
	{
		return (InterruptPriority)7;
	}
}
public sealed class CoffinActor : NetworkBehaviour
{
	public static GameObject Prefab;

	public static readonly List<CoffinActor> Active = new List<CoffinActor>();

	public static int Spawned;

	public static int Crushed;

	public static int Expired;

	public static float ExpireLower = 0.4f;

	public const float Contract = 0.45f;

	public GameObject owner;

	public GameObject victim;

	public float startTime;

	public float crushAt = -1f;

	public float life;

	public float lift;

	public bool heavy;

	public static float LiftStart = 0.3f;

	public static float LiftDur = 0.5f;

	public static int BurstFrame = -1;

	public static int BurstCount;

	private Vector3 hold;

	private bool crushed;

	private float nextTick;

	private float nextStun;

	private float doneAt = -1f;

	private CharacterBody ownerBody;

	private CharacterBody victimBody;

	private bool lowering;

	private static float Now
	{
		get
		{
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				return Time.fixedTime;
			}
			return Run.instance.fixedTime;
		}
	}

	public float Age => Now - startTime;

	public bool Holding
	{
		get
		{
			if (crushAt < 0f)
			{
				return crushAt > -1.5f;
			}
			return false;
		}
	}

	public bool Bound
	{
		get
		{
			if (!crushed)
			{
				return crushAt > -1.5f;
			}
			return false;
		}
	}

	public float LiftAt(float age)
	{
		if (lift <= 0f)
		{
			return 0f;
		}
		float num = Mathf.Clamp01((age - LiftStart) / LiftDur);
		float num2 = Mathf.Clamp01((age - life) / ExpireLower);
		return lift * num * num * (3f - 2f * num) * (1f - num2 * num2 * (3f - 2f * num2));
	}

	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("GaaraSandCoffin");
		val.AddComponent<NetworkIdentity>();
		val.AddComponent<CoffinActor>();
		Prefab = PrefabAPI.InstantiateClone(val, "GaaraSandCoffin", true);
		Object.DestroyImmediate((Object)val);
		Plugin.NetworkPrefabs.Add(Prefab);
	}

	public static bool IsBound(GameObject v)
	{
		foreach (CoffinActor item in Active)
		{
			if (Object.op_Implicit((Object)(object)item) && (Object)(object)item.victim == (Object)(object)v && item.Bound)
			{
				return true;
			}
		}
		return false;
	}

	public static bool IsCoffined(GameObject v)
	{
		foreach (CoffinActor item in Active)
		{
			if (Object.op_Implicit((Object)(object)item) && (Object)(object)item.victim == (Object)(object)v && item.Holding)
			{
				return true;
			}
		}
		return false;
	}

	public static int CountFor(GameObject owner)
	{
		int num = 0;
		foreach (CoffinActor item in Active)
		{
			if (Object.op_Implicit((Object)(object)item) && (Object)(object)item.owner == (Object)(object)owner && item.Holding)
			{
				num++;
			}
		}
		return num;
	}

	public static bool IsHeavy(CharacterBody b)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Invalid comparison between Unknown and I4
		if (Object.op_Implicit((Object)(object)b))
		{
			if (!b.isBoss && !b.isChampion && !Combat.IsHeavy(b))
			{
				return (int)b.hullClassification == 2;
			}
			return true;
		}
		return false;
	}

	public static void Spawn(CharacterBody owner, CharacterBody victim)
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_021b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0221: 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_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: 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)
		if (!NetworkServer.active || !Object.op_Implicit((Object)(object)owner) || !Object.op_Implicit((Object)(object)victim) || IsCoffined(((Component)victim).gameObject))
		{
			return;
		}
		bool flag = IsHeavy(victim);
		GameObject val = Object.Instantiate<GameObject>(Prefab, victim.footPosition, Quaternion.identity);
		CoffinActor component = val.GetComponent<CoffinActor>();
		component.owner = ((Component)owner).gameObject;
		component.victim = ((Component)victim).gameObject;
		component.startTime = Now;
		component.life = Tuning.CoffinDuration.Value;
		component.heavy = flag;
		component.hold = victim.transform.position;
		component.ownerBody = owner;
		component.victimBody = victim;
		bool flag2 = Object.op_Implicit((Object)(object)victim.characterMotor) && victim.characterMotor.isGrounded;
		float num = victim.bestFitRadius * 2f;
		HurtBoxGroup hurtBoxGroup = victim.hurtBoxGroup;
		if (Object.op_Implicit((Object)(obje