Decompiled source of R2MRework v1.2.0

R2MM.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using BepInEx;
using HarmonyLib;
using Landfall.TABC;
using Landfall.TABS;
using Landfall.TABS.AI;
using Landfall.TABS.AI.Systems;
using Landfall.TABS.GameMode;
using Landfall.TABS.GameState;
using Landfall.TABS.Services;
using Landfall.TABS.UnitPlacement;
using Landfall.TABS.WinConditions;
using Microsoft.CodeAnalysis;
using Unity.Entities;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[BepInPlugin("R2M", "R2M", "1.0.8")]
public sealed class R2M : BaseUnityPlugin
{
	private struct R2TargetSample
	{
		public Unit Unit;

		public float X;

		public float Y;

		public float Z;

		public bool Valid;
	}

	private sealed class R2R
	{
		public Vector3 Start;

		public Vector3 End;

		public Vector3[] Points;

		public float StartTime;

		public float Duration;

		public float Seed;
	}

	private sealed class R2D
	{
		public Unit Unit;

		public Vector3 Point;

		public Vector3 Dir;

		public float End;

		public float Kill;

		public bool Killed;

		public readonly List<R2Mesh> M = new List<R2Mesh>();
	}

	private sealed class R2Mesh
	{
		public Transform T;

		public MeshFilter F;

		public SkinnedMeshRenderer S;

		public Mesh Original;

		public Mesh Mesh;

		public Vector3[] Base;

		public Vector3[] Work;

		public Vector3 Impact;

		public Vector3 Axis;

		public float Seed;

		public float Amp;
	}

	private sealed class R2S
	{
		public Unit Target;

		public Vector3 Start;

		public Vector3 End;

		public Vector3 Pos;

		public Quaternion Rot;

		public float Duration;

		public float T;

		public float Spin;

		public float Seed;

		public float Radius;

		public bool Hit;
	}

	private sealed class R2C
	{
		public Unit Unit;

		public Vector3 Point;

		public Vector3 Axis;

		public float End;

		public float Kill;

		public bool Killed;

		public bool Permanent;

		public Renderer[] Rs;

		public bool[] Enabled;

		public readonly List<R2F> F = new List<R2F>();
	}

	private sealed class R2F
	{
		public Mesh Mesh;

		public Vector3 Pos;

		public Vector3 BasePos;

		public Vector3 Vel;

		public Quaternion Rot;

		public Vector3 Spin;

		public float Seed;

		public float Scale;
	}

	private sealed class R2G
	{
		public Unit Unit;

		public Transform[] T;

		public Vector3[] Scale;

		public Rigidbody[] Bodies;

		public float Seed;

		public int Mode;

		public R2P Cube;
	}

	private sealed class R2P
	{
		public Vector3 Pos;

		public Vector3 Vel;

		public Quaternion Rot;

		public Vector3 Spin;

		public float Life;

		public float Seed;

		public float Radius;

		public int Bounces;

		public float Scan;

		public bool HitTarget;
	}

	private sealed class R2L
	{
		public Light Light;

		public Color Color;

		public float Intensity;
	}

	private sealed class R2X
	{
		public Unit Unit;

		public Renderer[] Renderers;

		public Transform[] Bones;

		public Vector3[] OriginalScale;

		public Rigidbody[] Bodies;

		public Animator[] Animators;

		public RigidbodyConstraints[] Constraints;

		public bool[] Kinematic;

		public bool[] Gravity;

		public bool[] AnimatorEnabled;

		public float Seed;

		public float Health;

		public float MaxHealth;
	}

	private sealed class R2Y
	{
		public string Text;

		public Vector3 Position;

		public float At;
	}

	private sealed class R2B
	{
		public Unit Unit;

		public UnitBlueprint Blueprint;

		public Team Team;

		public Vector3 Position;

		public bool HasGuid;

		public Guid Guid;

		public float Expires;
	}

	private static readonly List<R2D> R2Ds = new List<R2D>();

	private static readonly List<R2B> R2Bs = new List<R2B>();

	private static readonly HashSet<Guid> R2Blocked = new HashSet<Guid>();

	private static readonly HashSet<int> R2BlockedIds = new HashSet<int>();

	private static readonly List<Unit> R2TrackedUnits = new List<Unit>(32);

	private static readonly HashSet<int> R2Protected = new HashSet<int>();

	private static readonly Dictionary<int, Renderer[]> R2Tinted = new Dictionary<int, Renderer[]>();

	private static readonly HashSet<int> R2Cams = new HashSet<int>();

	private static readonly RaycastHit[] R2Hits = (RaycastHit[])(object)new RaycastHit[128];

	private static readonly RaycastHit[] R2RayHits = (RaycastHit[])(object)new RaycastHit[512];

	private static readonly Collider[] R2OverlapHits = (Collider[])(object)new Collider[1024];

	private static readonly HashSet<int> R2SeenUnits = new HashSet<int>();

	private static readonly FieldInfo R2HHUnit = typeof(HealthHandler).GetField("unit", BindingFlags.Instance | BindingFlags.NonPublic);

	private static readonly FieldInfo R2APIUnit = typeof(UnitAPI).GetField("m_unit", BindingFlags.Instance | BindingFlags.NonPublic);

	private static Material R2Mat;

	private static MaterialPropertyBlock R2Block;

	private static Mesh R2CubeMesh;

	private static Mesh R2LaserMesh;

	private static Harmony R2H;

	private static bool R2PlacementState;

	private static bool R2BattleState;

	private static bool R2PlayableState;

	private static GameStateManager R2State;

	private static TeamSystem R2Teams;

	private static Unit[] R2UnitCache = (Unit[])(object)new Unit[256];

	private static int R2UnitCount;

	private static float R2StateAt = -999f;

	private static float R2UnitCacheAt = -999f;

	private static float R2GuardFallbackAt = -999f;

	private static readonly ParallelOptions R2Parallel = new ParallelOptions
	{
		MaxDegreeOfParallelism = 4
	};

	private static R2TargetSample[] R2TargetSamples = new R2TargetSample[256];

	private static readonly int[] R2TargetBest = new int[8];

	private static readonly float[] R2TargetBestDist = new float[8];

	private static bool R2On;

	private static float R2RenderTime;

	private static readonly List<R2Mesh> R2DeformJobs = new List<R2Mesh>(64);

	private static int R2DeformVertexTotal;

	private static float R2CleanMark = -999f;

	private static bool R2InitDone;

	private static bool R2Finalizing;

	private static Vector3 R2Pos;

	private static Vector3 R2MoveVel;

	private static Unit R2T;

	private static float R2CD;

	private static float R2Beam;

	private static Vector3 R2BeamEnd;

	private static Vector3 R2BeamDir = Vector3.forward;

	private static float R2Charge;

	private static bool R2Charging;

	private static Unit R2ChargeTarget;

	private const float R2ChargeTime = 0.55f;

	private const float R2AttackRange = 24f;

	private static float R2NextAI;

	private static float R2NextColor;

	private static float R2NextGuard;

	private static float R2TintSeed;

	private static float R2RemoveDelay = 0.72f;

	private static bool R2WasPlayable;

	private static bool R2WasBattle;

	private static bool R2SpawnSaved;

	private static Vector3 R2SpawnPos;

	private static int R2AttackSeq;

	private static int R2AttackState;

	private static float R2BattleTime;

	private static float R2SoulCD;

	private static float R2SoulCharge;

	private static float R2SoulTime;

	private static bool R2SoulCharging;

	private static Unit R2SoulFocus;

	private static readonly List<R2G> R2Gs = new List<R2G>();

	private static readonly List<R2P> R2Ps = new List<R2P>();

	private static float R2CubeCD;

	private static float R2CubeCharge;

	private static bool R2CubeCharging;

	private static float R2CubeTime;

	private static Unit R2CubeTarget;

	private static float R2SpaceCD;

	private static float R2RayCD;

	private static float R2RayCharge;

	private static bool R2RayCharging;

	private static Unit R2RayTarget;

	private static float R2RayTime;

	private static readonly List<R2R> R2Rs = new List<R2R>();

	private static float R2SpaceTime;

	private static bool R2SpaceActive;

	private static float R2SpacePrevScale = 1f;

	private static Material R2SpaceSky;

	private static Material R2SpaceSkyOriginal;

	private static bool R2SpaceFog;

	private static Color R2SpaceAmbient;

	private static Color R2SpaceFogColor;

	private static float R2SpaceFogDensity;

	private static float R2SpaceReflection;

	private static AmbientMode R2SpaceAmbientMode;

	private static readonly List<R2L> R2Lights = new List<R2L>();

	private static readonly List<R2X> R2SpaceUnits = new List<R2X>();

	private static Font R2SayFont;

	private static Material R2SayMat;

	private static Mesh R2SayMesh;

	private static string R2SaySource = string.Empty;

	private static Vector3 R2SayPos;

	private static float R2SayAt;

	private static float R2SayStart;

	private static readonly Queue<R2Y> R2SayQueue = new Queue<R2Y>();

	private const float R2BattleDelay = 1.75f;

	private const float R2KeepMin = 10.5f;

	private const float R2KeepMax = 18.5f;

	private const float R2SoulRange = 12.5f;

	private const float R2SoulTrigger = 8.5f;

	private const float R2SoulChargeTime = 0.95f;

	private const float R2SoulDuration = 1.55f;

	private const float R2SoulCooldown = 2.8f;

	private const float R2CubeChargeTime = 0.72f;

	private const float R2CubeCooldown = 3.2f;

	private const float R2CubeLife = 2.35f;

	private const float R2CubeRange = 24f;

	private const float R2CubePullRange = 5.8f;

	private const float R2SpaceCooldown = 28f;

	private const float R2SpaceDuration = 20f;

	private const float R2SpaceTrigger = 6f;

	private const float R2RayRange = 34f;

	private const float R2RayChargeTime = 0.62f;

	private const float R2RayCooldown = 5.4f;

	private const float R2RaySpeed = 8f;

	private const int R2RayDepth = 7;

	private const float R2RayBounceRadius = 1.25f;

	private const float R2RayFinalRadius = 3.5f;

	private const float R2RayMaxDistance = 700f;

	private const float R2SayReveal = 0.055f;

	private const float R2SayStartDuration = 0.35f;

	private const float R2SayHoldDuration = 1.35f;

	private const float R2SayCorruptDuration = 0.95f;

	private const float R2SayFadeDuration = 0.8f;

	private const float R2StateCacheInterval = 0.08f;

	private const float R2UnitCacheInterval = 0.09f;

	private const float R2GuardFallbackInterval = 0.45f;

	private const int R2ParallelUnitThreshold = 64;

	private const int R2ParallelDeformVertices = 3072;

	private static float R2SayDirty;

	private static float R2SawCD;

	private static float R2SawCharge;

	private static bool R2SawCharging;

	private static Unit R2SawChargeTarget;

	private static readonly List<R2S> R2Ss = new List<R2S>();

	private static readonly List<R2C> R2Cs = new List<R2C>();

	private static Mesh R2SawMesh;

	private const float R2SawRange = 23f;

	private const float R2SawChargeTime = 0.34f;

	private const float R2SawCooldown = 1.35f;

	private const float R2SawFlight = 0.52f;

	private const float R2SawKillDelay = 0.42f;

	private const float R2CutDuration = 1.35f;

	private static int R2RenderFrame = -1;

	private static readonly HashSet<MethodBase> R2VictoryRoutes = new HashSet<MethodBase>();

	private static readonly HashSet<int> R2HardKilled = new HashSet<int>();

	private static readonly HashSet<int> R2DelayedDestroy = new HashSet<int>();

	private static readonly Dictionary<int, Unit> R2PendingDestroy = new Dictionary<int, Unit>(32);

	private void Awake()
	{
		R2Start();
	}

	private void Update()
	{
		R2Main();
	}

	private void OnDestroy()
	{
		R2Stop();
	}

	private void OnRenderObject()
	{
		R2RO();
	}

	private void R2Start()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Expected O, but got Unknown
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Expected O, but got Unknown
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Expected O, but got Unknown
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Expected O, but got Unknown
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Expected O, but got Unknown
		if (R2InitDone)
		{
			return;
		}
		R2InitDone = true;
		R2H = new Harmony("R2M");
		R2H.PatchAll(typeof(R2M).Assembly);
		R2PatchVictoryRoutes();
		R2Mat = new Material(Shader.Find("Hidden/Internal-Colored"));
		((Object)R2Mat).hideFlags = (HideFlags)61;
		R2Mat.SetInt("_ZWrite", 1);
		R2Mat.SetInt("_ZTest", 4);
		R2Mat.SetInt("_Cull", 2);
		R2Mat.SetInt("_SrcBlend", 1);
		R2Mat.SetInt("_DstBlend", 0);
		R2Block = new MaterialPropertyBlock();
		R2CubeMesh = R2MakeCube();
		R2LaserMesh = R2MakeCylinder(40);
		R2SawMesh = R2MakeSaw(64);
		try
		{
			R2SayFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
		}
		catch
		{
			R2SayFont = null;
		}
		if ((Object)(object)R2SayFont != (Object)null)
		{
			Shader val = Shader.Find("Sprites/Default");
			if ((Object)(object)val != (Object)null)
			{
				R2SayMat = new Material(val);
				((Object)R2SayMat).hideFlags = (HideFlags)61;
				R2SayMat.mainTexture = R2SayFont.material.mainTexture;
				R2SayMat.SetInt("_ZTest", 8);
				R2SayMat.SetInt("_ZWrite", 0);
				R2SayMat.SetInt("_Cull", 0);
			}
		}
		Camera.onPostRender = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(R2Render));
		SceneManager.sceneLoaded += R2Scene;
	}

	private void R2Stop()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		Camera.onPostRender = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(R2Render));
		SceneManager.sceneLoaded -= R2Scene;
		if (R2H != null)
		{
			R2H.UnpatchSelf();
		}
		if ((Object)(object)R2Mat != (Object)null)
		{
			Object.Destroy((Object)(object)R2Mat);
		}
		if ((Object)(object)R2CubeMesh != (Object)null)
		{
			Object.Destroy((Object)(object)R2CubeMesh);
		}
		R2Rs.Clear();
		if ((Object)(object)R2LaserMesh != (Object)null)
		{
			Object.Destroy((Object)(object)R2LaserMesh);
		}
		if ((Object)(object)R2SawMesh != (Object)null)
		{
			Object.Destroy((Object)(object)R2SawMesh);
		}
		if ((Object)(object)R2SayMat != (Object)null)
		{
			Object.Destroy((Object)(object)R2SayMat);
		}
		if ((Object)(object)R2SayMesh != (Object)null)
		{
			Object.Destroy((Object)(object)R2SayMesh);
		}
		R2Reset();
	}

	private void R2Render(Camera c)
	{
		R2RenderNow(c);
	}

	private void R2RO()
	{
		Camera current = Camera.current;
		if ((Object)(object)current != (Object)null)
		{
			R2RenderNow(current);
		}
	}

	private void R2RenderNow(Camera c)
	{
		if (!R2On || !Object.op_Implicit((Object)(object)c) || (Object)(object)R2Mat == (Object)null)
		{
			return;
		}
		R2RenderTime = Time.unscaledTime;
		if (R2RenderFrame != Time.frameCount)
		{
			R2RenderFrame = Time.frameCount;
			R2Cams.Clear();
		}
		if (R2Cams.Add(((Object)c).GetInstanceID()))
		{
			R2DrawH();
			if (R2Beam > 0f)
			{
				R2DrawL();
			}
			else if (R2Charging && Object.op_Implicit((Object)(object)R2ChargeTarget))
			{
				R2DrawCharge();
			}
			if (R2SawCharging && Object.op_Implicit((Object)(object)R2SawChargeTarget))
			{
				R2DrawSawCharge();
			}
			if (R2SoulCharging || R2AttackState == 3)
			{
				R2DrawSoul();
			}
			if (R2CubeCharging || R2AttackState == 4 || R2Ps.Count > 0)
			{
				R2DrawCubes();
			}
			if (R2AttackState == 5 || R2SpaceActive)
			{
				R2DrawSpace();
			}
			if (R2RayCharging)
			{
				R2DrawRayCharge();
			}
			if (!R2RayCharging && (R2AttackState == 6 || R2Rs.Count > 0))
			{
				R2DrawRay();
			}
			if (R2Ss.Count > 0)
			{
				R2DrawSaws();
			}
			if (R2Cs.Count > 0)
			{
				R2DrawCuts();
			}
			R2SayDraw();
		}
	}

	private void R2Activate()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		R2Reset();
		R2On = true;
		R2SpawnPos = R2Find();
		R2SpawnSaved = true;
		R2Pos = R2SpawnPos;
		R2MoveVel = Vector3.zero;
		R2T = null;
		R2CD = 0.08f;
		R2Beam = 0f;
		R2WasBattle = false;
		R2WasPlayable = true;
		R2RefreshState(force: true);
	}

	private static void R2EnterBattle()
	{
		R2BattleTime = 0f;
		R2AttackState = 0;
		R2Charge = 0f;
		R2Charging = false;
		R2SawCharge = 0f;
		R2SawCharging = false;
		R2SoulCharge = 0f;
		R2SoulCharging = false;
		R2SoulTime = 0f;
		R2SoulFocus = null;
		R2CubeCharge = 0f;
		R2CubeCharging = false;
		R2CubeTime = 0f;
		R2CubeTarget = null;
		R2SpaceActive = false;
		R2T = null;
		R2CD = 1.1f;
		R2SawCD = 0.8f;
		R2SoulCD = 1.5f;
		R2CubeCD = 1.8f;
		R2SpaceCD = 5f;
		R2RayCD = 3.5f;
		R2RayCharge = 0f;
		R2RayCharging = false;
		R2RayTarget = null;
		R2RayTime = 0f;
		R2Rs.Clear();
		R2RefreshUnitCache(force: true);
	}

	private static void R2UpdateEffects()
	{
		if (R2Ds.Count > 0)
		{
			R2Deform();
		}
		if (R2Cs.Count > 0)
		{
			R2UpdateCuts();
		}
		if (R2Ss.Count > 0 || R2SawCharging)
		{
			R2UpdateSaws();
		}
		if (R2SoulCharging || R2Gs.Count > 0)
		{
			R2UpdateSoul();
		}
		if (R2CubeCharging || R2Ps.Count > 0)
		{
			R2UpdateCubes();
		}
		if (R2SpaceActive || R2AttackState == 5)
		{
			R2UpdateSpace();
		}
		if (R2RayCharging || R2Rs.Count > 0)
		{
			R2UpdateRay();
		}
	}

	private void R2Main()
	{
		R2RefreshState();
		float unscaledDeltaTime = Time.unscaledDeltaTime;
		R2CD -= unscaledDeltaTime;
		R2Beam -= unscaledDeltaTime;
		R2SawCD -= unscaledDeltaTime;
		R2SoulCD -= unscaledDeltaTime;
		R2CubeCD -= unscaledDeltaTime;
		R2SpaceCD -= unscaledDeltaTime;
		R2RayCD -= unscaledDeltaTime;
		R2RayTime += unscaledDeltaTime;
		R2BattleTime = (R2BattleState ? (R2BattleTime + unscaledDeltaTime) : 0f);
		R2NextAI -= unscaledDeltaTime;
		R2NextColor -= unscaledDeltaTime;
		R2NextGuard -= unscaledDeltaTime;
		if (!R2On)
		{
			if (Input.GetKeyDown((KeyCode)283) && R2PlacementState && R2Place())
			{
				R2Activate();
			}
			return;
		}
		bool r2PlacementState = R2PlacementState;
		bool r2BattleState = R2BattleState;
		bool r2PlayableState = R2PlayableState;
		if (r2BattleState && !R2WasBattle)
		{
			R2EnterBattle();
		}
		if (R2WasBattle && !r2BattleState)
		{
			R2ReturnToSpawn();
		}
		if (!r2PlayableState && R2WasPlayable)
		{
			R2Reset();
			return;
		}
		R2WasPlayable = r2PlayableState;
		R2WasBattle = r2BattleState;
		if (R2NextColor <= 0f)
		{
			R2NextColor = 0.08f;
			R2TintSeed = R2Hash(Time.frameCount * 31 + 173);
		}
		if (Input.GetKeyDown((KeyCode)283) && r2PlacementState && R2Place())
		{
			R2Activate();
			return;
		}
		if (!r2BattleState)
		{
			if (R2SayQueue.Count > 0 || !string.IsNullOrEmpty(R2SaySource))
			{
				R2SayUpdate();
			}
			if (Time.unscaledTime - R2CleanMark >= 0.6f)
			{
				R2CleanBlocks();
			}
			return;
		}
		R2RefreshUnitCache();
		R2UpdateEffects();
		if (Time.unscaledTime - R2CleanMark >= 0.6f)
		{
			R2CleanBlocks();
		}
		if (R2NextGuard <= 0f)
		{
			R2NextGuard = 0.045f;
			R2GuardAll();
		}
		R2AI();
		R2SayUpdate();
	}

	private void R2Scene(Scene scene, LoadSceneMode mode)
	{
		R2Reset();
	}

	private static void R2PatchVictoryRoutes()
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Expected O, but got Unknown
		try
		{
			Type[] types = typeof(BaseGameMode).Assembly.GetTypes();
			HarmonyMethod val = new HarmonyMethod(typeof(R2M).GetMethod("R2BlockVictoryRoute", BindingFlags.Static | BindingFlags.NonPublic));
			foreach (Type type in types)
			{
				if (type == typeof(R2M))
				{
					continue;
				}
				MethodInfo[] methods;
				try
				{
					methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				}
				catch
				{
					continue;
				}
				foreach (MethodInfo methodInfo in methods)
				{
					bool flag = false;
					if (((type.Name ?? string.Empty).IndexOf("WinConditionPropagator", StringComparison.OrdinalIgnoreCase) >= 0 || type == typeof(GameStateManager)) && (methodInfo.Name.Equals("OnUnitDied", StringComparison.OrdinalIgnoreCase) || methodInfo.Name.Equals("OnUnitRemoved", StringComparison.OrdinalIgnoreCase) || methodInfo.Name.Equals("OnMatchOver", StringComparison.OrdinalIgnoreCase) || methodInfo.Name.Equals("OnMatchOVer", StringComparison.OrdinalIgnoreCase)))
					{
						flag = true;
					}
					if (!methodInfo.IsSpecialName && !methodInfo.ContainsGenericParameters && (R2VictoryName(methodInfo.Name) || flag) && !R2VictoryRoutes.Contains(methodInfo))
					{
						try
						{
							R2H.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
							R2VictoryRoutes.Add(methodInfo);
						}
						catch
						{
						}
					}
				}
			}
		}
		catch
		{
		}
	}

	private static bool R2VictoryName(string n)
	{
		if (string.IsNullOrEmpty(n))
		{
			return false;
		}
		if (n.Equals("DecideWinner", StringComparison.OrdinalIgnoreCase))
		{
			return true;
		}
		if (n.Equals("OnWinnerDecided", StringComparison.OrdinalIgnoreCase))
		{
			return true;
		}
		if (n.Equals("DelayedCheckMatchOver", StringComparison.OrdinalIgnoreCase))
		{
			return true;
		}
		if (n.Equals("UpdateForMatchOver", StringComparison.OrdinalIgnoreCase))
		{
			return true;
		}
		if (n.Equals("OnMatchOver", StringComparison.OrdinalIgnoreCase))
		{
			return true;
		}
		if (n.Equals("OnMatchOVer", StringComparison.OrdinalIgnoreCase))
		{
			return true;
		}
		if (n.Equals("MatchOver", StringComparison.OrdinalIgnoreCase))
		{
			return true;
		}
		if (n.Equals("BeginEndingMatch", StringComparison.OrdinalIgnoreCase))
		{
			return true;
		}
		if (n.Equals("DisplayEndOfMatchUI", StringComparison.OrdinalIgnoreCase))
		{
			return true;
		}
		if (n.Equals("OpenVictoryConditionPanel", StringComparison.OrdinalIgnoreCase))
		{
			return true;
		}
		if (n.Equals("ShowVictory", StringComparison.OrdinalIgnoreCase))
		{
			return true;
		}
		if (n.Equals("DisplayVictory", StringComparison.OrdinalIgnoreCase))
		{
			return true;
		}
		if (n.Equals("ShowEndOfMatch", StringComparison.OrdinalIgnoreCase))
		{
			return true;
		}
		if (n.Equals("DisplayEndOfMatch", StringComparison.OrdinalIgnoreCase))
		{
			return true;
		}
		return false;
	}

	private static bool R2BlockVictoryRoute()
	{
		if (R2On)
		{
			return !R2BattleState;
		}
		return true;
	}

	private static void R2ReturnToSpawn()
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		if (R2On && R2SpawnSaved)
		{
			R2ClearBattle();
			R2Pos = R2SpawnPos;
			R2MoveVel = Vector3.zero;
			R2T = null;
			R2CD = 0.15f;
			R2Beam = 0f;
			R2WasBattle = false;
		}
	}

	private static void R2ClearBattle()
	{
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		R2SpaceEnd(completed: false);
		R2FlushPendingDestroy();
		for (int num = R2Ds.Count - 1; num >= 0; num--)
		{
			R2D r2D = R2Ds[num];
			if (r2D != null)
			{
				for (int i = 0; i < r2D.M.Count; i++)
				{
					R2Mesh r2Mesh = r2D.M[i];
					if (r2Mesh != null)
					{
						if ((Object)(object)r2Mesh.F != (Object)null)
						{
							r2Mesh.F.sharedMesh = r2Mesh.Original;
						}
						if ((Object)(object)r2Mesh.S != (Object)null)
						{
							r2Mesh.S.sharedMesh = r2Mesh.Original;
						}
						if ((Object)(object)r2Mesh.Mesh != (Object)null)
						{
							Object.Destroy((Object)(object)r2Mesh.Mesh);
						}
					}
				}
			}
		}
		for (int num2 = R2Cs.Count - 1; num2 >= 0; num2--)
		{
			R2ClearCut(R2Cs[num2]);
		}
		foreach (Renderer[] value in R2Tinted.Values)
		{
			if (value == null)
			{
				continue;
			}
			for (int j = 0; j < value.Length; j++)
			{
				if (Object.op_Implicit((Object)(object)value[j]))
				{
					value[j].SetPropertyBlock((MaterialPropertyBlock)null);
				}
			}
		}
		R2Tinted.Clear();
		R2Blocked.Clear();
		R2Protected.Clear();
		R2Bs.Clear();
		R2Ds.Clear();
		R2Cs.Clear();
		R2Ss.Clear();
		R2Ps.Clear();
		R2T = null;
		R2Beam = 0f;
		R2BeamEnd = Vector3.zero;
		R2BeamDir = Vector3.forward;
		R2Charge = 0f;
		R2Charging = false;
		R2ChargeTarget = null;
		R2SawCD = 0f;
		R2SawCharge = 0f;
		R2SawCharging = false;
		R2SawChargeTarget = null;
		R2SoulCharge = 0f;
		R2SoulTime = 0f;
		R2SoulCharging = false;
		R2SoulFocus = null;
		R2CubeCharge = 0f;
		R2CubeCharging = false;
		R2CubeTime = 0f;
		R2CubeTarget = null;
		R2SpaceCD = 0f;
		R2RayCD = 0f;
		R2RayCharge = 0f;
		R2RayCharging = false;
		R2RayTarget = null;
		R2RayTime = 0f;
		R2Rs.Clear();
		R2AttackSeq = 0;
		R2HardKilled.Clear();
		R2DelayedDestroy.Clear();
		R2PendingDestroy.Clear();
		R2AttackState = 0;
		R2BattleTime = 0f;
		R2MoveVel = Vector3.zero;
		R2NextGuard = 0f;
		R2SaySource = string.Empty;
		R2SayAt = 0f;
		R2SayStart = 0f;
		R2SayQueue.Clear();
		if ((Object)(object)R2SayMesh != (Object)null)
		{
			Object.Destroy((Object)(object)R2SayMesh);
			R2SayMesh = null;
		}
		R2SayDirty = 0f;
	}

	private static void R2Reset()
	{
		//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)
		R2ClearBattle();
		R2Finalizing = false;
		R2Cams.Clear();
		R2On = false;
		R2SpawnSaved = false;
		R2SpawnPos = Vector3.zero;
		R2Pos = Vector3.zero;
		R2WasPlayable = false;
		R2WasBattle = false;
	}

	private static void R2RefreshState(bool force = false)
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Invalid comparison between Unknown and I4
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Invalid comparison between Unknown and I4
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Invalid comparison between Unknown and I4
		float unscaledTime = Time.unscaledTime;
		if (!force && unscaledTime - R2StateAt < 0.08f)
		{
			return;
		}
		R2StateAt = unscaledTime;
		try
		{
			R2State = ServiceLocator.GetService<GameStateManager>();
			bool num = R2State != null && (int)R2State.GameState == 0;
			bool flag = R2State != null && (int)R2State.GameState == 1;
			if (!flag)
			{
				RoundHandler instance = RoundHandler.instance;
				flag = (Object)(object)instance != (Object)null && (int)instance.roundState == 1;
			}
			R2PlacementState = num;
			R2BattleState = flag;
			R2PlayableState = num || flag;
		}
		catch
		{
			R2PlacementState = false;
			R2BattleState = false;
			R2PlayableState = false;
		}
	}

	private static bool R2Place()
	{
		return R2PlacementState;
	}

	private static bool R2Battle()
	{
		return R2BattleState;
	}

	private static void R2RefreshUnitCache(bool force = false)
	{
		if (!R2BattleState)
		{
			return;
		}
		float unscaledTime = Time.unscaledTime;
		if (!force && unscaledTime - R2UnitCacheAt < 0.09f)
		{
			return;
		}
		R2UnitCacheAt = unscaledTime;
		try
		{
			if (World.Active != null)
			{
				if (R2Teams == null)
				{
					R2Teams = World.Active.GetExistingManager<TeamSystem>();
				}
				if (R2Teams != null)
				{
					List<Unit> allUnits = R2Teams.GetAllUnits();
					int num = allUnits?.Count ?? 0;
					if (num > R2UnitCache.Length)
					{
						Array.Resize(ref R2UnitCache, Mathf.NextPowerOfTwo(num));
					}
					for (int i = 0; i < num; i++)
					{
						R2UnitCache[i] = allUnits[i];
					}
					for (int j = num; j < R2UnitCount; j++)
					{
						R2UnitCache[j] = null;
					}
					R2UnitCount = num;
					return;
				}
			}
		}
		catch
		{
			R2Teams = null;
		}
		try
		{
			Unit[] array = Object.FindObjectsOfType<Unit>();
			int num2 = ((array != null) ? array.Length : 0);
			if (num2 > R2UnitCache.Length)
			{
				Array.Resize(ref R2UnitCache, Mathf.NextPowerOfTwo(num2));
			}
			for (int k = 0; k < num2; k++)
			{
				R2UnitCache[k] = array[k];
			}
			for (int l = num2; l < R2UnitCount; l++)
			{
				R2UnitCache[l] = null;
			}
			R2UnitCount = num2;
		}
		catch
		{
			R2UnitCount = 0;
		}
	}

	private static Vector3 R2Find()
	{
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//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_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: 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_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_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: 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_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_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		Camera main = Camera.main;
		if ((Object)(object)main != (Object)null)
		{
			if (R2Ray(main.ScreenPointToRay(Input.mousePosition), out var p))
			{
				return p + Vector3.up * 4f;
			}
			if (R2Ray(main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f)), out p))
			{
				return p + Vector3.up * 4f;
			}
			if (R2Down(((Component)main).transform.position + Vector3.up * 50f, out p))
			{
				return p + Vector3.up * 4f;
			}
		}
		return Vector3.up * 5f;
	}

	private static bool R2Ray(Ray r, out Vector3 p)
	{
		//IL_0001: 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_002d: 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_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		p = default(Vector3);
		int num = Physics.RaycastNonAlloc(r, R2Hits, 2500f, -5, (QueryTriggerInteraction)1);
		float num2 = float.MaxValue;
		bool result = false;
		for (int i = 0; i < num; i++)
		{
			RaycastHit val = R2Hits[i];
			if (Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).collider) && !((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Unit>() != (Object)null) && !(Vector3.Angle(((RaycastHit)(ref val)).normal, Vector3.up) > 70f) && ((RaycastHit)(ref val)).distance < num2)
			{
				num2 = ((RaycastHit)(ref val)).distance;
				p = ((RaycastHit)(ref val)).point;
				result = true;
			}
		}
		return result;
	}

	private static bool R2Down(Vector3 a, out Vector3 p)
	{
		//IL_0001: 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_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: 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)
		p = default(Vector3);
		RaycastHit val = default(RaycastHit);
		if (Physics.Raycast(a, Vector3.down, ref val, 4000f, -5, (QueryTriggerInteraction)1) && Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).collider) && (Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Unit>() == (Object)null && Vector3.Angle(((RaycastHit)(ref val)).normal, Vector3.up) <= 70f)
		{
			p = ((RaycastHit)(ref val)).point;
			return true;
		}
		return false;
	}

	private static void R2AI()
	{
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_0219: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_024a: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: 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_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_0342: Unknown result type (might be due to invalid IL or missing references)
		//IL_0347: 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)
		//IL_0356: Unknown result type (might be due to invalid IL or missing references)
		//IL_039f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
		if (!R2BattleState)
		{
			return;
		}
		if (R2AttackState == 1)
		{
			R2UpdateLaserAttack();
		}
		else if (R2AttackState == 6)
		{
			R2UpdateRay();
		}
		else
		{
			if (R2AttackState == 2 || R2AttackState == 3 || R2AttackState == 4 || R2AttackState == 5 || R2BattleTime < 1.75f)
			{
				return;
			}
			if (R2NextAI <= 0f)
			{
				R2NextAI = 0.035f;
				R2T = R2Target();
			}
			if (!Object.op_Implicit((Object)(object)R2T) || R2T.dead || (Object)(object)R2T.data == (Object)null || !Object.op_Implicit((Object)(object)R2T.data.mainRig))
			{
				R2T = null;
				return;
			}
			Vector3 val = R2T.data.mainRig.position + Vector3.up * 1.15f;
			Vector3 val2 = val - R2Pos;
			if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f)
			{
				float magnitude = ((Vector3)(ref val2)).magnitude;
				float num = 10.5f;
				num = ((R2SoulCD <= 0f && R2AttackSeq % 5 == 4 && magnitude <= 15f) ? 7.2f : ((R2AttackSeq % 4 != 1 || !(R2CubeCD <= 0f)) ? Mathf.Clamp(magnitude, 10.5f, 18.5f) : Mathf.Clamp(magnitude, 13.5f, 17.5f)));
				Vector3 val3 = ((magnitude > num + 0.6f) ? (val - ((Vector3)(ref val2)).normalized * num) : ((magnitude < num - 0.6f) ? (val - ((Vector3)(ref val2)).normalized * num) : R2Pos));
				R2Pos = Vector3.SmoothDamp(R2Pos, val3, ref R2MoveVel, 0.12f, 34f, Time.unscaledDeltaTime);
			}
			val = (R2BeamEnd = R2T.data.mainRig.position + Vector3.up * 1.15f);
			Vector3 val4 = val - R2Pos;
			Vector3 r2BeamDir;
			if (!(((Vector3)(ref val4)).sqrMagnitude > 0.001f))
			{
				r2BeamDir = Vector3.forward;
			}
			else
			{
				val4 = val - R2Pos;
				r2BeamDir = ((Vector3)(ref val4)).normalized;
			}
			R2BeamDir = r2BeamDir;
			val4 = val - R2Pos;
			float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude;
			if (R2SpaceCD <= 0f && (float)R2AttackSeq >= 6f && R2AttackSeq % 6 == 0)
			{
				R2AttackSeq++;
				R2SpaceStart();
			}
			else if (R2SoulCD <= 0f && sqrMagnitude <= 72.25f && R2AttackSeq % 5 == 4)
			{
				R2SoulStart();
			}
			else if (R2CubeCD <= 0f && sqrMagnitude <= 576f && R2AttackSeq % 4 == 1)
			{
				R2CubeStart();
			}
			else if (R2RayCD <= 0f && sqrMagnitude <= 1156f && R2AttackSeq % 7 == 3)
			{
				R2RayStart();
			}
			else if (!(sqrMagnitude > 576f))
			{
				if (R2SawCD <= 0f && R2AttackSeq % 3 == 2)
				{
					R2SawCharging = true;
					R2SawChargeTarget = R2T;
					R2SawCharge = 0f;
					R2AttackState = 2;
					Say("SAW", R2Pos + Vector3.up * 4f);
				}
				else if (!(R2CD > 0f) && !(R2SawCD > 0f))
				{
					R2Charging = true;
					R2ChargeTarget = R2T;
					R2Charge = 0f;
					R2AttackState = 1;
					Say("LASER", R2Pos + Vector3.up * 4f);
				}
			}
		}
	}

	private static void R2UpdateLaserAttack()
	{
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		if (!R2Charging)
		{
			if (R2Beam <= 0f)
			{
				R2AttackState = 0;
				R2AttackSeq++;
			}
			return;
		}
		if (!Object.op_Implicit((Object)(object)R2ChargeTarget) || R2ChargeTarget.dead || !R2BattleState)
		{
			R2Charging = false;
			R2ChargeTarget = null;
			R2Charge = 0f;
			R2AttackState = 0;
			return;
		}
		R2Charge += Time.unscaledDeltaTime;
		Vector3 val = (R2BeamEnd = (((Object)(object)R2ChargeTarget.data != (Object)null && Object.op_Implicit((Object)(object)R2ChargeTarget.data.mainRig)) ? (R2ChargeTarget.data.mainRig.position + Vector3.up * 1.15f) : R2BeamEnd));
		Vector3 val2 = val - R2Pos;
		Vector3 r2BeamDir;
		if (!(((Vector3)(ref val2)).sqrMagnitude > 0.001f))
		{
			r2BeamDir = Vector3.forward;
		}
		else
		{
			val2 = val - R2Pos;
			r2BeamDir = ((Vector3)(ref val2)).normalized;
		}
		R2BeamDir = r2BeamDir;
		if (R2Charge >= 0.55f)
		{
			R2Attack(R2ChargeTarget, val);
			R2CD = 0.95f;
			R2Charge = 0f;
			R2Charging = false;
			R2ChargeTarget = null;
		}
	}

	private static void R2RayStart()
	{
		//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_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)
		if (R2AttackState == 0 && !(R2RayCD > 0f) && Object.op_Implicit((Object)(object)R2T) && R2BattleState)
		{
			R2AttackState = 6;
			R2RayCharging = true;
			R2RayCharge = 0f;
			R2RayTime = 0f;
			R2RayTarget = R2T;
			R2Rs.Clear();
			Say("RRAY", R2Pos + Vector3.up * 4.4f);
		}
	}

	private static void R2UpdateRay()
	{
		//IL_00d4: 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_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)
		if (!R2RayCharging)
		{
			if (R2Rs.Count == 0)
			{
				R2FlushPendingDestroy();
				R2AttackState = 0;
				R2RayCD = 5.4f;
				R2AttackSeq++;
			}
			return;
		}
		if (!Object.op_Implicit((Object)(object)R2RayTarget) || R2RayTarget.dead || (Object)(object)R2RayTarget.data == (Object)null || !Object.op_Implicit((Object)(object)R2RayTarget.data.mainRig) || !R2BattleState)
		{
			R2RayCharging = false;
			R2RayTarget = null;
			R2RayCharge = 0f;
			R2Rs.Clear();
			R2FlushPendingDestroy();
			R2AttackState = 0;
			return;
		}
		R2RayCharge += Time.unscaledDeltaTime;
		if (!(R2RayCharge < 0.62f))
		{
			R2RayFire(R2RayTarget.data.mainRig.position + Vector3.up * 1.1f);
			R2RayCharging = false;
			R2RayTarget = null;
			R2RayCharge = 0f;
			R2RayCD = 5.4f;
		}
	}

	private static void R2RayFire(Vector3 target)
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: 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_003c: 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_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: 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_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: 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_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: 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_018b: 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_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: 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_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: 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_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)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: 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_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: 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_00b2: 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_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_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0107: 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_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_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		R2Rs.Clear();
		Vector3 val = R2Pos + Vector3.up * 0.15f;
		Vector3 val2 = target - val;
		Vector3 val3;
		if (!(((Vector3)(ref val2)).sqrMagnitude > 0.001f))
		{
			val3 = Vector3.forward;
		}
		else
		{
			val2 = target - val;
			val3 = ((Vector3)(ref val2)).normalized;
		}
		Vector3 val4 = val3;
		for (int i = 0; i <= 7; i++)
		{
			Vector3 val5 = ((((Vector3)(ref val4)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val4)).normalized : Vector3.forward);
			Vector3 val6 = val + val5 * 700f;
			RaycastHit best;
			bool num = R2RayTerrain(val, val5, 700f, out best);
			if (num)
			{
				val6 = ((RaycastHit)(ref best)).point;
			}
			Vector3.Distance(val, val6);
			R2AddRaySegment(val, val6, i);
			R2RayKillUnits(val6, (i >= 7) ? 3.5f : 1.25f);
			R2RayKillAlongSegment(val, val6, 0.7f);
			if (!num || i >= 7)
			{
				break;
			}
			Vector3 val7 = Vector3.Reflect(val5, ((RaycastHit)(ref best)).normal);
			if (((Vector3)(ref val7)).sqrMagnitude < 0.001f)
			{
				break;
			}
			val = ((RaycastHit)(ref best)).point + ((Vector3)(ref val7)).normalized * 0.08f;
			val4 = ((Vector3)(ref val7)).normalized;
			R2RaySpark(((RaycastHit)(ref best)).point, ((RaycastHit)(ref best)).normal, ((Vector3)(ref val7)).normalized, i);
		}
		for (int j = 0; j < 6; j++)
		{
			float num2 = (float)j / 6f * (float)Math.PI * 2f + Time.unscaledTime * 2.8f;
			Vector3 up = Vector3.up;
			val2 = Vector3.Cross(up, Vector3.right);
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			val2 = Vector3.Cross(up, normalized);
			Vector3 normalized2 = ((Vector3)(ref val2)).normalized;
			val2 = normalized * Mathf.Cos(num2) + normalized2 * Mathf.Sin(num2);
			Vector3 normalized3 = ((Vector3)(ref val2)).normalized;
			R2AddRaySegment(target, target + normalized3 * (2.4f + 2.2f * Mathf.Sin((float)j + Time.unscaledTime)), 99 + j);
		}
	}

	private static bool R2RayTerrain(Vector3 o, Vector3 d, float max, out RaycastHit best)
	{
		//IL_0001: 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_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		best = default(RaycastHit);
		int num = Physics.RaycastNonAlloc(o, d, R2RayHits, max, -5, (QueryTriggerInteraction)1);
		float num2 = float.MaxValue;
		bool result = false;
		for (int i = 0; i < num; i++)
		{
			RaycastHit val = R2RayHits[i];
			if (Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).collider) && !Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Unit>()) && ((RaycastHit)(ref val)).distance < num2)
			{
				num2 = ((RaycastHit)(ref val)).distance;
				best = val;
				result = true;
			}
		}
		return result;
	}

	private static Unit R2UnitAtSegment(Vector3 a, Vector3 b, float radius)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: 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_0092: Unknown result type (might be due to invalid IL or missing references)
		int num = Physics.OverlapCapsuleNonAlloc(a, b, radius, R2OverlapHits, -5, (QueryTriggerInteraction)1);
		Unit result = null;
		float num2 = float.MaxValue;
		for (int i = 0; i < num; i++)
		{
			Collider val = R2OverlapHits[i];
			if (!Object.op_Implicit((Object)(object)val))
			{
				continue;
			}
			Unit componentInParent = ((Component)val).GetComponentInParent<Unit>();
			if (Object.op_Implicit((Object)(object)componentInParent) && !componentInParent.dead && !R2IsBlocked(componentInParent))
			{
				float num3 = Vector3.Distance(((Object)(object)componentInParent.data != (Object)null && Object.op_Implicit((Object)(object)componentInParent.data.mainRig)) ? componentInParent.data.mainRig.position : ((Component)componentInParent).transform.position, a);
				if (num3 < num2)
				{
					num2 = num3;
					result = componentInParent;
				}
			}
		}
		return result;
	}

	private static void R2RayKillAlongSegment(Vector3 a, Vector3 b, float radius)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: 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_00a3: 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)
		int num = Physics.OverlapCapsuleNonAlloc(a, b, radius, R2OverlapHits, -5, (QueryTriggerInteraction)1);
		R2SeenUnits.Clear();
		for (int i = 0; i < num; i++)
		{
			Collider val = R2OverlapHits[i];
			if (Object.op_Implicit((Object)(object)val))
			{
				Unit componentInParent = ((Component)val).GetComponentInParent<Unit>();
				if (Object.op_Implicit((Object)(object)componentInParent) && !componentInParent.dead && !R2IsBlocked(componentInParent) && R2SeenUnits.Add(((Object)componentInParent).GetInstanceID()))
				{
					Vector3 p = (((Object)(object)componentInParent.data != (Object)null && Object.op_Implicit((Object)(object)componentInParent.data.mainRig)) ? componentInParent.data.mainRig.position : ((Component)componentInParent).transform.position);
					R2RayHit(componentInParent, p);
				}
			}
		}
	}

	private static void R2RayKillUnits(Vector3 p, float radius)
	{
		//IL_0000: 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)
		int num = Physics.OverlapSphereNonAlloc(p, radius, R2OverlapHits, -5, (QueryTriggerInteraction)1);
		R2SeenUnits.Clear();
		for (int i = 0; i < num; i++)
		{
			Collider val = R2OverlapHits[i];
			if (Object.op_Implicit((Object)(object)val))
			{
				Unit componentInParent = ((Component)val).GetComponentInParent<Unit>();
				if (Object.op_Implicit((Object)(object)componentInParent) && !componentInParent.dead && !R2IsBlocked(componentInParent) && R2SeenUnits.Add(((Object)componentInParent).GetInstanceID()))
				{
					R2RayHit(componentInParent, p);
				}
			}
		}
	}

	private static void R2RayHit(Unit u, Vector3 p)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)u) && !R2IsBlocked(u))
		{
			R2QueuePendingDestroy(u);
			R2TintUnit(u);
			Say("Cease To Exist " + ((Object)u).name, p + Vector3.up * 2.2f);
		}
	}

	private static void R2AddRaySegment(Vector3 a, Vector3 b, int seed)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		float num = Vector3.Distance(a, b);
		if (!(num < 0.05f))
		{
			R2R item = new R2R
			{
				Start = a,
				End = b,
				Points = R2BoltPoints(a, b, 10, 0.7f, seed),
				StartTime = Time.unscaledTime,
				Duration = 0.14f + Mathf.Min(2.35f, num * 0.0065f),
				Seed = R2Hash(seed * 313 + Mathf.RoundToInt(num * 17f))
			};
			R2Rs.Add(item);
		}
	}

	private static Vector3[] R2BoltPoints(Vector3 a, Vector3 b, int resolution, float offset, int seed)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//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_0066: 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_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		Vector3[] array = (Vector3[])(object)new Vector3[resolution + 1];
		Vector3 val = b - a;
		Vector3 val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val)).normalized : Vector3.forward);
		Vector3 val3 = Vector3.Cross(val2, Vector3.up);
		if (((Vector3)(ref val3)).sqrMagnitude < 0.01f)
		{
			val3 = Vector3.Cross(val2, Vector3.right);
		}
		((Vector3)(ref val3)).Normalize();
		Vector3 val4 = Vector3.Cross(val2, val3);
		Vector3 normalized = ((Vector3)(ref val4)).normalized;
		for (int i = 0; i <= resolution; i++)
		{
			float num = (float)i / (float)resolution;
			float num2 = Mathf.Sin(((float)(i + 1) + (float)seed * 19f) * 17.31f) * offset;
			float num3 = Mathf.Sin(((float)(i + 4) + (float)seed * 7f) * 11.17f) * offset;
			if (i == 0 || i == resolution)
			{
				num2 = 0f;
				num3 = 0f;
			}
			array[i] = Vector3.Lerp(a, b, num) + val3 * num2 + normalized * num3;
		}
		return array;
	}

	private static void R2RaySpark(Vector3 p, Vector3 normal, Vector3 reflected, int depth)
	{
		//IL_0006: 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_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_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: 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_006f: Unknown result type (might be due to invalid IL or missing references)
		R2R item = new R2R
		{
			Start = p + normal * 0.03f,
			End = p + ((Vector3)(ref reflected)).normalized * (1.2f + (float)depth * 0.15f),
			Points = R2BoltPoints(p + normal * 0.03f, p + ((Vector3)(ref reflected)).normalized * (1.2f + (float)depth * 0.15f), 6, 0.45f, depth + 71),
			StartTime = Time.unscaledTime,
			Duration = 0.22f,
			Seed = R2Hash(depth * 101 + 47)
		};
		R2Rs.Add(item);
	}

	private static void R2DrawRayCharge()
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: 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_0076: 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_0095: 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_009c: 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_008e: 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_00e6: 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_0108: 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_012a: 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_0135: 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_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: 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_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_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0223: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)R2RayTarget) && Object.op_Implicit((Object)(object)R2RayTarget.data) && Object.op_Implicit((Object)(object)R2RayTarget.data.mainRig))
		{
			Vector3 val = R2Pos + Vector3.up * 0.1f;
			Vector3 val2 = R2RayTarget.data.mainRig.position + Vector3.up * 1.1f;
			Vector3 val3 = val2 - val;
			Vector3 val4;
			if (!(((Vector3)(ref val3)).sqrMagnitude > 0.001f))
			{
				val4 = Vector3.forward;
			}
			else
			{
				val3 = val2 - val;
				val4 = ((Vector3)(ref val3)).normalized;
			}
			Vector3 val5 = val4;
			float num = Mathf.Clamp01(R2RayCharge / 0.62f);
			float num2 = 0.4f + 0.6f * Mathf.Sin(Time.unscaledTime * 25f) * Mathf.Sin(Time.unscaledTime * 25f);
			R2Ring(val, val5, 0.65f + 2f * num + num2 * 0.35f, 1f);
			R2Ring(val2, val5, 1f + 2.7f * num + num2 * 0.5f, 1.2f);
			Vector3 val6 = Vector3.Cross(val5, Vector3.up);
			if (((Vector3)(ref val6)).sqrMagnitude < 0.01f)
			{
				val6 = Vector3.Cross(val5, Vector3.right);
			}
			((Vector3)(ref val6)).Normalize();
			val3 = Vector3.Cross(val5, val6);
			Vector3 normalized = ((Vector3)(ref val3)).normalized;
			for (int i = 0; i < 3; i++)
			{
				float num3 = Time.unscaledTime * (8f + (float)i * 3f) + (float)i * 2.1f;
				Vector3 a = val + (val6 * Mathf.Cos(num3) + normalized * Mathf.Sin(num3)) * (0.35f + num * 0.65f);
				Vector3 b = Vector3.Lerp(val, val2, 0.18f + 0.15f * (float)i) + (val6 * Mathf.Cos(num3 * 1.7f) + normalized * Mathf.Sin(num3 * 1.7f)) * (1.2f + num * 2.2f);
				R2AddPreviewBolt(a, b, 24 + i);
			}
		}
	}

	private static void R2AddPreviewBolt(Vector3 a, Vector3 b, int seed)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: 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_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: 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_00f7: 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_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)R2Mat == (Object)null)
		{
			return;
		}
		Vector3[] array = R2BoltPoints(a, b, 6, 0.28f, seed);
		float unscaledTime = Time.unscaledTime;
		Color val = Color.Lerp(new Color(1f, 0.08f, 0.02f, 1f), new Color(0.2f, 1f, 0.12f, 1f), 0.5f + 0.5f * Mathf.Sin(unscaledTime * 11f + (float)seed));
		val = Color.Lerp(val, Color.white, 0.7f);
		val *= 0.65f + 0.35f * Mathf.Sin(unscaledTime * 19f + (float)seed) * Mathf.Sin(unscaledTime * 19f + (float)seed);
		val.a = 1f;
		R2Mat.SetColor("_Color", val);
		R2Mat.color = val;
		R2Mat.SetPass(0);
		for (int i = 0; i < array.Length - 1; i++)
		{
			Vector3 val2 = array[i + 1] - array[i];
			float magnitude = ((Vector3)(ref val2)).magnitude;
			if (!(magnitude < 0.01f))
			{
				Graphics.DrawMeshNow(R2LaserMesh, Matrix4x4.TRS(array[i], Quaternion.LookRotation(((Vector3)(ref val2)).normalized, Vector3.up) * Quaternion.AngleAxis(unscaledTime * 1200f + (float)i * 20f, Vector3.forward), new Vector3(0.06f, 0.06f, magnitude)));
			}
		}
	}

	private static void R2DrawRay()
	{
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: 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_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)R2Mat == (Object)null)
		{
			return;
		}
		float unscaledTime = Time.unscaledTime;
		for (int num = R2Rs.Count - 1; num >= 0; num--)
		{
			R2R r2R = R2Rs[num];
			if (r2R == null || r2R.Points == null || r2R.Points.Length < 2 || unscaledTime - r2R.StartTime > r2R.Duration + 0.35f)
			{
				R2Rs.RemoveAt(num);
			}
			else
			{
				float num2 = Mathf.Clamp01(Mathf.Clamp01((unscaledTime - r2R.StartTime) / Mathf.Max(0.001f, r2R.Duration)) * 1.8f);
				for (int i = 0; i < 3; i++)
				{
					Color val = Color.Lerp(new Color(1f, 0.15f, 0.05f, 1f), new Color(0.35f, 1f, 0.15f, 1f), 0.5f + 0.5f * Mathf.Sin(unscaledTime * 13f + r2R.Seed * 9f + (float)i));
					val = Color.Lerp(val, Color.white, i switch
					{
						1 => 0.6f, 
						0 => 0.25f, 
						_ => 0.88f, 
					});
					val *= 0.55f + 0.45f * Mathf.Sin(unscaledTime * 24f + r2R.Seed * 7f) * Mathf.Sin(unscaledTime * 24f + r2R.Seed * 7f);
					val.a = 1f;
					R2Mat.SetColor("_Color", val);
					R2Mat.color = val;
					R2Mat.SetInt("_ZWrite", 1);
					R2Mat.SetInt("_ZTest", 4);
					R2Mat.SetInt("_Cull", 2);
					R2Mat.SetPass(0);
					for (int j = 0; j < r2R.Points.Length - 1 && !(((float)j + 1f) / ((float)r2R.Points.Length - 1f) > num2 + 0.08f); j++)
					{
						Vector3 val2 = r2R.Points[j];
						Vector3 val3 = r2R.Points[j + 1] - val2;
						float magnitude = ((Vector3)(ref val3)).magnitude;
						if (!(magnitude < 0.01f))
						{
							Quaternion val4 = Quaternion.LookRotation(((Vector3)(ref val3)).normalized, Vector3.up) * Quaternion.AngleAxis(unscaledTime * 1400f + (float)j * 41f, Vector3.forward);
							float num3 = i switch
							{
								1 => 0.1f, 
								0 => 0.19f, 
								_ => 0.045f, 
							};
							Graphics.DrawMeshNow(R2LaserMesh, Matrix4x4.TRS(val2, val4, new Vector3(num3, num3, magnitude)));
						}
					}
				}
			}
		}
	}

	private static Unit R2Target()
	{
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: 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_0113: Unknown result type (might be due to invalid IL or missing references)
		R2RefreshUnitCache();
		int count = R2UnitCount;
		if (count <= 0)
		{
			return null;
		}
		if (count > R2TargetSamples.Length)
		{
			Array.Resize(ref R2TargetSamples, Mathf.NextPowerOfTwo(count));
		}
		float px = R2Pos.x;
		float py = R2Pos.y;
		float pz = R2Pos.z;
		for (int i = 0; i < count; i++)
		{
			Unit val = R2UnitCache[i];
			R2TargetSample r2TargetSample = new R2TargetSample
			{
				Unit = val,
				Valid = false
			};
			if (Object.op_Implicit((Object)(object)val) && !val.dead && (Object)(object)val.data != (Object)null && Object.op_Implicit((Object)(object)val.data.mainRig) && !R2IsBlocked(val))
			{
				Vector3 position = val.data.mainRig.position;
				r2TargetSample.X = position.x;
				r2TargetSample.Y = position.y;
				r2TargetSample.Z = position.z;
				r2TargetSample.Valid = true;
			}
			R2TargetSamples[i] = r2TargetSample;
		}
		int num = Math.Min(8, Math.Min(count / 64, Math.Max(1, Environment.ProcessorCount - 1)));
		for (int j = 0; j < R2TargetBest.Length; j++)
		{
			R2TargetBest[j] = -1;
			R2TargetBestDist[j] = float.MaxValue;
		}
		if (num < 2)
		{
			Unit result = null;
			float num2 = float.MaxValue;
			for (int k = 0; k < count; k++)
			{
				R2TargetSample r2TargetSample2 = R2TargetSamples[k];
				if (r2TargetSample2.Valid)
				{
					float num3 = r2TargetSample2.X - px;
					float num4 = r2TargetSample2.Y - py;
					float num5 = r2TargetSample2.Z - pz;
					float num6 = num3 * num3 + num4 * num4 + num5 * num5;
					if (num6 < num2)
					{
						num2 = num6;
						result = r2TargetSample2.Unit;
					}
				}
			}
			return result;
		}
		int chunk = (count + num - 1) / num;
		Parallel.For(0, num, R2Parallel, delegate(int w)
		{
			int num11 = w * chunk;
			int num12 = Math.Min(count, num11 + chunk);
			int num13 = -1;
			float num14 = float.MaxValue;
			for (int l = num11; l < num12; l++)
			{
				R2TargetSample r2TargetSample3 = R2TargetSamples[l];
				if (r2TargetSample3.Valid)
				{
					float num15 = r2TargetSample3.X - px;
					float num16 = r2TargetSample3.Y - py;
					float num17 = r2TargetSample3.Z - pz;
					float num18 = num15 * num15 + num16 * num16 + num17 * num17;
					if (num18 < num14)
					{
						num14 = num18;
						num13 = l;
					}
				}
			}
			R2TargetBest[w] = num13;
			R2TargetBestDist[w] = num14;
		});
		Unit result2 = null;
		float num7 = float.MaxValue;
		for (int num8 = 0; num8 < num; num8++)
		{
			int num9 = R2TargetBest[num8];
			if (num9 >= 0)
			{
				float num10 = R2TargetBestDist[num8];
				if (num10 < num7)
				{
					num7 = num10;
					result2 = R2TargetSamples[num9].Unit;
				}
			}
		}
		return result2;
	}

	private static void R2Attack(Unit u, Vector3 hit)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: 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_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		if (R2AttackState == 1 && Object.op_Implicit((Object)(object)u) && !R2IsBlocked(u))
		{
			R2T = u;
			R2BeamEnd = hit;
			Vector3 val = hit - R2Pos;
			Vector3 r2BeamDir;
			if (!(((Vector3)(ref val)).sqrMagnitude > 0.0001f))
			{
				r2BeamDir = Vector3.forward;
			}
			else
			{
				val = hit - R2Pos;
				r2BeamDir = ((Vector3)(ref val)).normalized;
			}
			R2BeamDir = r2BeamDir;
			R2Beam = 0.3f;
			R2Impact(u, hit);
		}
	}

	private static void R2UpdateSaws()
	{
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: 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_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: 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_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: 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_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: 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_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_022c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		if (R2SawCharging)
		{
			if (!Object.op_Implicit((Object)(object)R2SawChargeTarget) || R2SawChargeTarget.dead || !R2BattleState)
			{
				R2SawCharging = false;
				R2SawChargeTarget = null;
				R2SawCharge = 0f;
				R2AttackState = 0;
			}
			else
			{
				R2SawCharge += Time.unscaledDeltaTime;
				if (R2SawCharge >= 0.34f)
				{
					R2SawFire(R2SawChargeTarget);
					R2SawCharging = false;
					R2SawChargeTarget = null;
					R2SawCharge = 0f;
					R2SawCD = 1.35f;
					R2AttackSeq++;
				}
			}
		}
		for (int num = R2Ss.Count - 1; num >= 0; num--)
		{
			R2S r2S = R2Ss[num];
			if (r2S == null || !Object.op_Implicit((Object)(object)r2S.Target) || r2S.Target.dead || !R2BattleState)
			{
				R2Ss.RemoveAt(num);
			}
			else
			{
				r2S.T += Time.unscaledDeltaTime / r2S.Duration;
				Vector3 val = Vector3.Lerp(r2S.Start, r2S.End, Mathf.Clamp01(r2S.T));
				Vector3 val2 = r2S.End - r2S.Start;
				Vector3 val3 = ((((Vector3)(ref val2)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val2)).normalized : Vector3.forward);
				Vector3 val4 = Vector3.Cross(val3, Vector3.up);
				if (((Vector3)(ref val4)).sqrMagnitude < 0.01f)
				{
					val4 = Vector3.Cross(val3, Vector3.right);
				}
				((Vector3)(ref val4)).Normalize();
				Vector3 val5 = Vector3.Cross(val3, val4);
				Vector3 normalized = ((Vector3)(ref val5)).normalized;
				float num2 = 0.16f + 0.1f * Mathf.Sin(Time.unscaledTime * 33f + r2S.Seed);
				float num3 = Time.unscaledTime * 28f + r2S.Spin;
				r2S.Pos = val + val4 * Mathf.Sin(num3) * num2 + normalized * Mathf.Cos(num3 * 0.83f) * num2;
				r2S.Rot = Quaternion.LookRotation(val3, normalized) * Quaternion.AngleAxis(num3 * 8f, Vector3.forward);
				if (!r2S.Hit && r2S.T >= 0.94f)
				{
					r2S.Hit = true;
					R2SawImpact(r2S.Target, r2S.End, val3);
					R2Ss.Clear();
					break;
				}
			}
		}
		if (!R2SawCharging && R2Ss.Count == 0 && R2AttackState == 2)
		{
			R2AttackState = 0;
			R2AttackSeq++;
		}
	}

	private static void R2SoulStart()
	{
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		if (R2AttackState != 0 || R2SoulCD > 0f)
		{
			return;
		}
		R2AttackState = 3;
		R2SoulCharging = true;
		R2SoulCharge = 0f;
		R2SoulTime = 0f;
		R2SoulFocus = R2NearestSoul();
		R2Gs.Clear();
		R2RefreshUnitCache(force: true);
		for (int i = 0; i < R2UnitCount; i++)
		{
			Unit val = R2UnitCache[i];
			if (Object.op_Implicit((Object)(object)val) && !val.dead && !((Object)(object)val.data == (Object)null) && Object.op_Implicit((Object)(object)val.data.mainRig) && !R2IsBlocked(val) && Vector3.Distance(val.data.mainRig.position, R2Pos) <= 12.5f)
			{
				R2Remember(val);
				R2G r2G = R2MakeSoul(val);
				r2G.Mode = 1;
				R2Gs.Add(r2G);
				if (R2Gs.Count >= 8)
				{
					break;
				}
			}
		}
		if (R2Gs.Count == 0)
		{
			R2AttackState = 0;
			R2SoulCharging = false;
			R2SoulFocus = null;
		}
		else
		{
			Say("SOUL GRAB", R2Pos + Vector3.up * 4.2f);
		}
	}

	private static Unit R2NearestSoul()
	{
		//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_0067: 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)
		R2RefreshUnitCache(force: true);
		Unit result = null;
		float num = 156.25f;
		for (int i = 0; i < R2UnitCount; i++)
		{
			Unit val = R2UnitCache[i];
			if (Object.op_Implicit((Object)(object)val) && !val.dead && !((Object)(object)val.data == (Object)null) && Object.op_Implicit((Object)(object)val.data.mainRig) && !R2IsBlocked(val))
			{
				Vector3 val2 = val.data.mainRig.position - R2Pos;
				float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
				if (sqrMagnitude < num)
				{
					num = sqrMagnitude;
					result = val;
				}
			}
		}
		return result;
	}

	private static R2G R2MakeSoul(Unit u)
	{
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		R2G r2G = new R2G
		{
			Unit = u,
			Seed = R2Hash(((Object)u).GetInstanceID() * 17 + 41),
			Mode = 1
		};
		r2G.T = ((Component)u).GetComponentsInChildren<Transform>(true);
		r2G.Scale = (Vector3[])(object)new Vector3[r2G.T.Length];
		for (int i = 0; i < r2G.T.Length; i++)
		{
			if (Object.op_Implicit((Object)(object)r2G.T[i]))
			{
				r2G.Scale[i] = r2G.T[i].localScale;
			}
		}
		r2G.Bodies = ((Component)u).GetComponentsInChildren<Rigidbody>(true);
		return r2G;
	}

	private static bool R2HasG(Unit u, int mode)
	{
		for (int i = 0; i < R2Gs.Count; i++)
		{
			if (R2Gs[i] != null && (Object)(object)R2Gs[i].Unit == (Object)(object)u && R2Gs[i].Mode == mode)
			{
				return true;
			}
		}
		return false;
	}

	private static void R2UpdateSoul()
	{
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: 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_010a: 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_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: 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_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_032a: Unknown result type (might be due to invalid IL or missing references)
		//IL_033b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0340: Unknown result type (might be due to invalid IL or missing references)
		if (R2AttackState != 3)
		{
			return;
		}
		float unscaledDeltaTime = Time.unscaledDeltaTime;
		R2SoulTime += unscaledDeltaTime;
		if (R2SoulCharging)
		{
			R2SoulCharge += unscaledDeltaTime;
			if (R2SoulCharge >= 0.95f)
			{
				R2SoulCharging = false;
			}
			return;
		}
		float num = Mathf.Clamp01(R2SoulTime / 1.55f);
		for (int num2 = R2Gs.Count - 1; num2 >= 0; num2--)
		{
			R2G r2G = R2Gs[num2];
			if (r2G != null && r2G.Mode == 1)
			{
				if (!Object.op_Implicit((Object)(object)r2G.Unit) || r2G.Unit.dead)
				{
					R2Gs.RemoveAt(num2);
				}
				else
				{
					Unit unit = r2G.Unit;
					R2BlockUnit(unit);
					Vector3 val = (((Object)(object)unit.data != (Object)null && Object.op_Implicit((Object)(object)unit.data.mainRig)) ? unit.data.mainRig.position : ((Component)unit).transform.position);
					Vector3 val2 = R2Pos - val;
					float magnitude = ((Vector3)(ref val2)).magnitude;
					Vector3 val3 = ((magnitude > 0.001f) ? (val2 / magnitude) : Vector3.zero);
					float num3 = 18f + 220f * (1f - Mathf.Clamp01(magnitude / 12.5f));
					Rigidbody[] bodies = r2G.Bodies;
					foreach (Rigidbody val4 in bodies)
					{
						if (Object.op_Implicit((Object)(object)val4))
						{
							val4.useGravity = false;
							val4.velocity = Vector3.Lerp(val4.velocity, val3 * num3, 0.55f);
							val4.AddForce(val3 * num3 * 2.2f, (ForceMode)5);
						}
					}
					if ((Object)(object)unit.data != (Object)null && Object.op_Implicit((Object)(object)unit.data.mainRig))
					{
						unit.data.mainRig.position = Vector3.MoveTowards(unit.data.mainRig.position, R2Pos + Vector3.up * 0.04f, (6.5f + 13f * num) * unscaledDeltaTime);
					}
					Transform transform = ((Component)unit).transform;
					transform.position = Vector3.MoveTowards(transform.position, R2Pos + Vector3.up * 0.04f, (4f + 8f * num) * unscaledDeltaTime);
					float num4 = 1f - Mathf.Clamp01(magnitude / 12.5f);
					float num5 = Mathf.SmoothStep(1f, 0.035f, Mathf.Clamp01(num * 0.78f + num4 * 0.72f));
					for (int j = 0; j < r2G.T.Length; j++)
					{
						Transform val5 = r2G.T[j];
						if (Object.op_Implicit((Object)(object)val5))
						{
							Vector3 val6 = r2G.Scale[j];
							float num6 = Mathf.Lerp(1f, 0.12f, Mathf.Clamp01(num + num4 * 0.75f));
							float num7 = 0.035f * Mathf.Sin(Time.unscaledTime * 30f + r2G.Seed * 15f + (float)j * 0.21f);
							val5.localScale = Vector3.Scale(val6, new Vector3(num5 + num7, num5 * num6, num5 - num7));
						}
					}
					if (magnitude <= 1.45f || R2SoulTime >= 1.55f)
					{
						R2SoulAbsorb(r2G);
						R2Gs.RemoveAt(num2);
					}
				}
			}
		}
		if (!R2SoulCharging && !R2Gs.Exists((R2G x) => x != null && x.Mode == 1))
		{
			R2FlushPendingDestroy();
			R2AttackState = 0;
			R2SoulCD = 2.8f;
			R2SoulTime = 0f;
			R2SoulCharge = 0f;
			R2SoulFocus = null;
			R2AttackSeq++;
		}
	}

	private static void R2SoulAbsorb(R2G g)
	{
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//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_0067: 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_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: 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_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		if (g != null && Object.op_Implicit((Object)(object)g.Unit))
		{
			Unit unit = g.Unit;
			R2Remember(unit);
			R2TintUnit(unit);
			Vector3 val = (((Object)(object)unit.data != (Object)null && Object.op_Implicit((Object)(object)unit.data.mainRig)) ? unit.data.mainRig.position : R2Pos);