Decompiled source of ShieldGeneratorBehemoth v0.6.5

BepInEx/plugins/ShieldGeneratorBehemoth/ShieldBehemothRuntime010.dll

Decompiled 10 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.ExpansionManagement;
using RoR2.Navigation;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using TMPro;
using TankUniversal.Behemoth.MegaBombV13;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ShieldBehemothRuntime010")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.6.5.0")]
[assembly: AssemblyInformationalVersion("0.6.5")]
[assembly: AssemblyProduct("ShieldBehemothRuntime010")]
[assembly: AssemblyTitle("ShieldBehemothRuntime010")]
[assembly: AssemblyVersion("0.6.5.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TankUniversal.Behemoth
{
	public static class BehemothAllyBalance
	{
		public const int ZoneTankLimit = 10;

		public const float SuicideTrigger = 7f;

		public const float SuicideRadius = 16f;

		public static float Level(float level)
		{
			if (!float.IsNaN(level) && !float.IsInfinity(level))
			{
				return Math.Max(1f, level);
			}
			return 1f;
		}

		public static float BaseHealth(BehemothAllyKind k)
		{
			return k switch
			{
				BehemothAllyKind.Skirmisher => 500, 
				BehemothAllyKind.Artillery => 1750, 
				BehemothAllyKind.Heavy => 3500, 
				BehemothAllyKind.Megaron => 7500, 
				BehemothAllyKind.DropZone => 25000, 
				BehemothAllyKind.Titan => 15000, 
				BehemothAllyKind.SuicideTank => 450, 
				_ => 1500, 
			};
		}

		public static float BaseDamage(BehemothAllyKind k)
		{
			return k switch
			{
				BehemothAllyKind.Turret => 50, 
				BehemothAllyKind.Skirmisher => 25, 
				BehemothAllyKind.Artillery => 1000, 
				BehemothAllyKind.Heavy => 500, 
				BehemothAllyKind.Megaron => 750, 
				BehemothAllyKind.DropZone => 0, 
				BehemothAllyKind.Titan => 1200, 
				BehemothAllyKind.SuicideTank => 1500, 
				_ => 200, 
			};
		}

		public static float Armor(BehemothAllyKind k)
		{
			return k switch
			{
				BehemothAllyKind.Turret => 150, 
				BehemothAllyKind.Skirmisher => 50, 
				BehemothAllyKind.Artillery => 125, 
				BehemothAllyKind.Heavy => 200, 
				BehemothAllyKind.Megaron => 350, 
				BehemothAllyKind.Titan => 200, 
				BehemothAllyKind.SuicideTank => 25, 
				_ => 100, 
			};
		}

		public static float HealthGain(BehemothAllyKind k)
		{
			return (k == BehemothAllyKind.DropZone) ? 5000 : 100;
		}

		public static float DamageGain(BehemothAllyKind k)
		{
			return (k != BehemothAllyKind.DropZone) ? 100 : 0;
		}

		public static float Health(BehemothAllyKind k, float level)
		{
			return BaseHealth(k) + (Level(level) - 1f) * HealthGain(k);
		}

		public static float Damage(BehemothAllyKind k, float level)
		{
			return BaseDamage(k) + (Level(level) - 1f) * DamageGain(k);
		}

		public static float Positive(float value)
		{
			if (!float.IsNaN(value) && !float.IsInfinity(value))
			{
				return Math.Max(0f, value);
			}
			return 0f;
		}

		public static float Share(float value)
		{
			return Positive(value) * 0.05f;
		}

		public static float PercentBonus(float actual, float baseline)
		{
			if (!(baseline > 0.0001f))
			{
				return 0f;
			}
			return Positive(actual / baseline - 1f);
		}

		public static int BurstCount(BehemothAllyKind k)
		{
			if (k != BehemothAllyKind.Turret && k != BehemothAllyKind.Skirmisher && k != BehemothAllyKind.Artillery)
			{
				return 1;
			}
			return 3;
		}

		public static float Reload(BehemothAllyKind k)
		{
			switch (k)
			{
			default:
				return 1.5f;
			case BehemothAllyKind.Heavy:
			case BehemothAllyKind.Artillery:
				return 3f;
			case BehemothAllyKind.Turret:
			case BehemothAllyKind.Skirmisher:
				return 4f;
			case BehemothAllyKind.Megaron:
				return 0.8f;
			}
		}

		public static float ShotGap(BehemothAllyKind k, float attackSpeed)
		{
			if (k != BehemothAllyKind.Artillery && k != BehemothAllyKind.Megaron)
			{
				return Math.Max(0.06f, 0.15f / Math.Max(0.1f, Positive(attackSpeed)));
			}
			return 0.5f;
		}

		public static float PlacementRange(BehemothAllyKind k)
		{
			return (k == BehemothAllyKind.DropZone) ? 250 : 150;
		}

		public static string FlightCue(BehemothAllyKind k)
		{
			return k switch
			{
				BehemothAllyKind.Skirmisher => null, 
				BehemothAllyKind.Artillery => "AllyArtilleryFlight", 
				_ => "AllyShellFlight", 
			};
		}

		public static string ImpactCue(BehemothAllyKind k, uint id)
		{
			return ((k == BehemothAllyKind.Heavy || k == BehemothAllyKind.Artillery) ? "AllyBigImpact" : "AllyImpact") + (1 + id % 3);
		}
	}
	public sealed class BehemothAllyBurst
	{
		public int Remaining { get; private set; }

		public float NextShot { get; private set; }

		public float ReloadUntil { get; private set; }

		public float LastShot { get; private set; }

		public bool Active => Remaining > 0;

		public bool Ready(float now)
		{
			if (!Active)
			{
				return now >= ReloadUntil;
			}
			return false;
		}

		public bool Begin(BehemothAllyKind kind, float now, int rounds = 0)
		{
			if (!Ready(now))
			{
				return false;
			}
			Remaining = ((rounds > 0) ? Math.Min(3, rounds) : BehemothAllyBalance.BurstCount(kind));
			NextShot = now;
			LastShot = now;
			return true;
		}

		public bool Due(float now)
		{
			if (Active)
			{
				return now >= NextShot;
			}
			return false;
		}

		public void Fired(BehemothAllyKind kind, float now, float attackSpeed)
		{
			if (!Due(now))
			{
				throw new InvalidOperationException("Salvo fired before its schedule");
			}
			Remaining--;
			LastShot = now;
			if (Active)
			{
				NextShot = now + BehemothAllyBalance.ShotGap(kind, attackSpeed);
			}
			else
			{
				ReloadUntil = now + BehemothAllyBalance.Reload(kind);
			}
		}

		public bool TimedOut(float now)
		{
			if (Active)
			{
				return now - Math.Max(LastShot, NextShot) > 2f;
			}
			return false;
		}

		public void Cancel(BehemothAllyKind kind, float now)
		{
			if (Active)
			{
				Remaining = 0;
				ReloadUntil = now + BehemothAllyBalance.Reload(kind);
			}
		}
	}
	public struct BehemothOwnerBonuses
	{
		public float Level;

		public float Health;

		public float Damage;

		public float Armor;

		public float Shield;

		public float Regen;

		public float Crit;

		public float AttackSpeed;

		public float MoveSpeed;

		public float CritDamage;

		public bool Same(BehemothOwnerBonuses b)
		{
			if (Level == b.Level && Health == b.Health && Damage == b.Damage && Armor == b.Armor && Shield == b.Shield && Regen == b.Regen && Crit == b.Crit && AttackSpeed == b.AttackSpeed && MoveSpeed == b.MoveSpeed)
			{
				return CritDamage == b.CritDamage;
			}
			return false;
		}
	}
	public struct BehemothAllyPoint
	{
		public float X;

		public float Y;

		public float Z;

		public float Length => (float)Math.Sqrt(X * X + Y * Y + Z * Z);

		public BehemothAllyPoint Normalized
		{
			get
			{
				if (!(Length > 1E-05f))
				{
					return default(BehemothAllyPoint);
				}
				return this * (1f / Length);
			}
		}

		public BehemothAllyPoint(float x, float y, float z)
		{
			X = x;
			Y = y;
			Z = z;
		}

		public static BehemothAllyPoint operator +(BehemothAllyPoint a, BehemothAllyPoint b)
		{
			return new BehemothAllyPoint(a.X + b.X, a.Y + b.Y, a.Z + b.Z);
		}

		public static BehemothAllyPoint operator -(BehemothAllyPoint a, BehemothAllyPoint b)
		{
			return new BehemothAllyPoint(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
		}

		public static BehemothAllyPoint operator *(BehemothAllyPoint p, float value)
		{
			return new BehemothAllyPoint(p.X * value, p.Y * value, p.Z * value);
		}
	}
	public static class BehemothAllyCombatRules
	{
		public static float Cadence(BehemothAllyKind kind)
		{
			return BehemothAllyBalance.Reload(kind);
		}

		public static float Range(BehemothAllyKind kind)
		{
			if (kind != BehemothAllyKind.SuicideTank)
			{
				return kind switch
				{
					BehemothAllyKind.Skirmisher => 220, 
					BehemothAllyKind.Heavy => 400, 
					BehemothAllyKind.Megaron => 650, 
					BehemothAllyKind.Artillery => 900, 
					BehemothAllyKind.Titan => 15, 
					_ => 250, 
				};
			}
			return 7f;
		}

		public static float YawRate(BehemothAllyKind kind)
		{
			return kind switch
			{
				BehemothAllyKind.Skirmisher => 120, 
				BehemothAllyKind.Artillery => 42, 
				BehemothAllyKind.Heavy => 48, 
				BehemothAllyKind.SuicideTank => 140, 
				_ => 90, 
			};
		}

		public static float PitchRate(BehemothAllyKind kind)
		{
			return kind switch
			{
				BehemothAllyKind.Artillery => 40, 
				BehemothAllyKind.Heavy => 42, 
				_ => 70, 
			};
		}

		public static float Elevation(BehemothAllyPoint direction)
		{
			return (float)(Math.Atan2(direction.Y, Math.Sqrt(direction.X * direction.X + direction.Z * direction.Z)) * 180.0 / Math.PI);
		}

		public static float Yaw(BehemothAllyPoint direction)
		{
			return (float)(Math.Atan2(direction.X, direction.Z) * 180.0 / Math.PI);
		}

		public static float Wrap(float angle)
		{
			angle %= 360f;
			if (angle > 180f)
			{
				angle -= 360f;
			}
			if (angle < -180f)
			{
				angle += 360f;
			}
			return angle;
		}

		public static float StepAngle(float current, float target, float speed, float dt)
		{
			return current + Math.Max((0f - speed) * Math.Max(0f, dt), Math.Min(speed * Math.Max(0f, dt), Wrap(target - current)));
		}

		public static float StepPitch(float current, float target, float speed, float dt)
		{
			return Math.Max(-15f, Math.Min(85f, StepAngle(current, Math.Max(-15f, Math.Min(85f, target)), speed, dt)));
		}

		public static float Interval(float value)
		{
			if (!float.IsNaN(value) && !float.IsInfinity(value))
			{
				return Math.Max(5f, Math.Min(300f, value));
			}
			return 30f;
		}

		public static bool Aligned(BehemothAllyPoint barrel, BehemothAllyPoint desired)
		{
			if (barrel.Length < 0.001f || desired.Length < 0.001f)
			{
				return false;
			}
			barrel = barrel.Normalized;
			desired = desired.Normalized;
			return barrel.X * desired.X + barrel.Y * desired.Y + barrel.Z * desired.Z >= (float)Math.Cos(0.006108652381980153);
		}

		public static BehemothAllyPoint Launch(BehemothAllyKind kind, BehemothAllyPoint from, BehemothAllyPoint target)
		{
			BehemothAllyPoint behemothAllyPoint = target - from;
			int num;
			switch (kind)
			{
			case BehemothAllyKind.Artillery:
				return new BehemothAllyPoint(behemothAllyPoint.X, 0f, behemothAllyPoint.Z).Normalized * 23.25f + new BehemothAllyPoint(0f, 49.85f, 0f);
			default:
				num = 180;
				break;
			case BehemothAllyKind.Skirmisher:
				num = 220;
				break;
			case BehemothAllyKind.Turret:
				num = 400;
				break;
			case BehemothAllyKind.Heavy:
				num = 270;
				break;
			}
			float num2 = num;
			float num3 = Math.Max(0.03f, behemothAllyPoint.Length / num2);
			float num4 = ((kind == BehemothAllyKind.Medium) ? 3 : 0);
			return behemothAllyPoint * (1f / num3) + new BehemothAllyPoint(0f, num4 * num3 * 0.5f, 0f);
		}

		public static bool Retreat(BehemothAllyKind kind, float distance)
		{
			if (kind == BehemothAllyKind.Artillery)
			{
				return distance < 110f;
			}
			return false;
		}
	}
	public enum BehemothLoftPhase : byte
	{
		Climb,
		Cruise,
		Drop
	}
	public struct BehemothLoftFlight
	{
		public BehemothAllyPoint Position;

		public BehemothAllyPoint Velocity;

		public BehemothAllyPoint Goal;

		public BehemothLoftPhase Phase;

		public float Age;

		public float Apex;

		public BehemothLoftFlight(BehemothAllyPoint origin, BehemothAllyPoint velocity, BehemothAllyPoint goal)
		{
			Position = origin;
			Velocity = velocity;
			Goal = goal;
			Phase = BehemothLoftPhase.Climb;
			Age = 0f;
			float length = new BehemothAllyPoint(goal.X - origin.X, 0f, goal.Z - origin.Z).Length;
			Apex = Math.Max(origin.Y, goal.Y) + Math.Max(45f, Math.Min(100f, length * 0.18f));
		}

		public void Step(float delta, BehemothAllyPoint target, bool targetValid)
		{
			if (delta <= 0f || float.IsNaN(delta) || float.IsInfinity(delta))
			{
				return;
			}
			Age += delta;
			if (targetValid && Phase != BehemothLoftPhase.Drop)
			{
				Goal = target;
				if (Goal.Y + 25f > Apex)
				{
					Apex = Goal.Y + 25f;
					if (Phase == BehemothLoftPhase.Cruise)
					{
						Phase = BehemothLoftPhase.Climb;
						Velocity = new BehemothAllyPoint(Goal.X - Position.X, 0f, Goal.Z - Position.Z).Normalized * 23.25f + new BehemothAllyPoint(0f, 49.85f, 0f);
					}
				}
			}
			float num = delta;
			for (int i = 0; i < 3; i++)
			{
				if (!(num > 1E-06f))
				{
					break;
				}
				if (Phase == BehemothLoftPhase.Climb)
				{
					float num2 = Math.Min(num, Math.Max(0f, (Apex - Position.Y) / Math.Max(1f, Velocity.Y)));
					Position += Velocity * num2;
					num -= num2;
					if (!(Position.Y >= Apex - 0.001f))
					{
						break;
					}
					Position.Y = Apex;
					Phase = BehemothLoftPhase.Cruise;
				}
				else if (Phase == BehemothLoftPhase.Cruise)
				{
					BehemothAllyPoint behemothAllyPoint = new BehemothAllyPoint(Goal.X - Position.X, 0f, Goal.Z - Position.Z);
					float length = behemothAllyPoint.Length;
					Velocity = behemothAllyPoint.Normalized * 75f;
					float num3 = Math.Min(num, length / 75f);
					Position += Velocity * num3;
					num -= num3;
					if (!(length <= 75f * num3 + 0.001f))
					{
						break;
					}
					Position.X = Goal.X;
					Position.Z = Goal.Z;
					Phase = BehemothLoftPhase.Drop;
					Velocity = new BehemothAllyPoint(0f, -8f, 0f);
				}
				else
				{
					Position += Velocity * num + new BehemothAllyPoint(0f, -16f * num * num, 0f);
					Velocity.Y -= 32f * num;
					num = 0f;
				}
			}
		}
	}
	public static class BehemothCameraRules
	{
		public const float DefaultDistance = 45f;

		public const float DefaultHeight = 20f;

		public const float MaximumDistance = 300f;

		public const float MaximumHeight = 120f;

		public static float Distance(float requested)
		{
			if (BehemothSupportRules.Finite(requested))
			{
				return Math.Max(0f, Math.Min(300f, requested));
			}
			return 45f;
		}

		public static float Height(float requested)
		{
			if (BehemothSupportRules.Finite(requested))
			{
				return Math.Max(0f, Math.Min(120f, requested));
			}
			return 20f;
		}

		public static float UpgradeLegacyDefault(float requested, int revision)
		{
			if ((revision >= 1 || (!(Math.Abs(requested - 130f) < 0.001f) && !(Math.Abs(requested - 110f) < 0.001f) && !(Math.Abs(requested - 80f) < 0.001f))) && (revision >= 2 || !(Math.Abs(requested - 55f) < 0.001f)) && (revision >= 3 || !(Math.Abs(requested - 25f) < 0.001f)))
			{
				return Distance(requested);
			}
			return 45f;
		}

		public static float RearOffset(float length)
		{
			if (!BehemothSupportRules.Finite(length))
			{
				return 22f;
			}
			return Math.Max(0f, length) * 0.5f + 2f;
		}

		public static float Ease(float current, float target, float dt, float seconds)
		{
			if (!BehemothSupportRules.Finite(current))
			{
				return target;
			}
			if (!BehemothSupportRules.Finite(target) || !BehemothSupportRules.Finite(dt) || dt <= 0f)
			{
				return current;
			}
			return target + (current - target) * (float)Math.Exp((0f - Math.Min(dt, 0.1f)) / Math.Max(0.01f, seconds));
		}

		public static bool TakesDamage(string part)
		{
			if (!(part == "tankbase"))
			{
				return part == "sidearmor";
			}
			return true;
		}
	}
	public enum BehemothAllyKind : byte
	{
		Turret,
		Medium,
		Heavy,
		Skirmisher,
		Artillery,
		DropZone,
		Megaron,
		Titan,
		SuicideTank
	}
	public sealed class BehemothDeploymentBudget
	{
		public int Charges { get; private set; } = 3;

		public double NextCharge { get; private set; } = double.PositiveInfinity;

		public double NextMedium { get; private set; }

		public uint TurretsPlaced { get; private set; }

		public bool ZoneUsed { get; private set; }

		public void ZoneOccupancy(int occupied)
		{
			ZoneUsed = occupied > 0;
		}

		public void Tick(double now)
		{
			if (!double.IsNaN(now) && !double.IsInfinity(now))
			{
				while (Charges < 3 && now >= NextCharge)
				{
					Charges++;
					NextCharge = ((Charges < 3) ? (NextCharge + 60.0) : double.PositiveInfinity);
				}
			}
		}

		public bool Allowed(BehemothAllyKind kind, double now, int living)
		{
			Tick(now);
			if (double.IsNaN(now) || double.IsInfinity(now))
			{
				return false;
			}
			if (kind == BehemothAllyKind.DropZone)
			{
				ZoneOccupancy(living);
			}
			switch (kind)
			{
			case BehemothAllyKind.DropZone:
				return living < 2;
			default:
				return false;
			case BehemothAllyKind.Medium:
				if (now >= NextMedium)
				{
					return living < 1;
				}
				return false;
			case BehemothAllyKind.Turret:
				if (Charges > 0)
				{
					return living < 3;
				}
				return false;
			}
		}

		public void Commit(BehemothAllyKind kind, double now)
		{
			Tick(now);
			switch (kind)
			{
			case BehemothAllyKind.Turret:
				if (Charges <= 0)
				{
					throw new InvalidOperationException("No turret stock");
				}
				if (TurretsPlaced < uint.MaxValue)
				{
					TurretsPlaced++;
				}
				if (Charges == 3)
				{
					NextCharge = now + 60.0;
				}
				Charges--;
				break;
			case BehemothAllyKind.Medium:
				NextMedium = now + 60.0;
				break;
			case BehemothAllyKind.DropZone:
				ZoneUsed = true;
				break;
			}
		}

		public static float TurretHealth(float level)
		{
			return BehemothAllyBalance.Health(BehemothAllyKind.Turret, level);
		}

		public static float TurretDamage(float level)
		{
			return BehemothAllyBalance.Damage(BehemothAllyKind.Turret, level);
		}

		public static float TurretCrit(float level)
		{
			return Math.Min(100f, Math.Max(0f, level - 1f) * 20f);
		}

		public static BehemothAllyKind ZoneRoll(float roll)
		{
			if (float.IsNaN(roll) || float.IsInfinity(roll))
			{
				throw new ArgumentException("Invalid roll");
			}
			return (new BehemothAllyKind[7]
			{
				BehemothAllyKind.Heavy,
				BehemothAllyKind.Medium,
				BehemothAllyKind.Skirmisher,
				BehemothAllyKind.Artillery,
				BehemothAllyKind.Megaron,
				BehemothAllyKind.Titan,
				BehemothAllyKind.SuicideTank
			})[Math.Min(6, Math.Max(0, (int)(roll * 7f)))];
		}
	}
	public static class BehemothAllyGeometry
	{
		public static void Motor(float width, float height, float length, out float radius, out float motorHeight)
		{
			if (float.IsNaN(width) || float.IsInfinity(width) || float.IsNaN(height) || float.IsInfinity(height) || float.IsNaN(length) || float.IsInfinity(length) || width <= 0f || height <= 0f || length <= 0f)
			{
				throw new ArgumentException("Invalid vehicle bounds");
			}
			radius = Math.Max(0.5f, Math.Min(2f, Math.Min(width, length) * 0.3f));
			motorHeight = Math.Max(radius * 2f, height * 0.65f);
		}

		public static float Gravity(BehemothAllyKind kind)
		{
			return kind switch
			{
				BehemothAllyKind.Medium => 3, 
				BehemothAllyKind.Artillery => 18, 
				_ => 0, 
			};
		}

		public static float FlightSeconds(BehemothAllyKind kind, float distance)
		{
			if (kind != BehemothAllyKind.Artillery)
			{
				return Math.Max(0.05f, distance / 180f);
			}
			return Math.Max(1f, Math.Min(4f, distance / 55f));
		}

		public static float LaunchY(float dy, float seconds, float gravity)
		{
			return dy / seconds + gravity * seconds * 0.5f;
		}
	}
	public enum BehemothFortressKind : byte
	{
		Wall,
		Gate,
		Hub
	}
	public struct BehemothFortressEdge
	{
		public BehemothAllyPoint A;

		public BehemothAllyPoint B;

		public bool Alive;

		public BehemothFortressEdge(BehemothAllyPoint a, BehemothAllyPoint b, bool alive = true)
		{
			A = a;
			B = b;
			Alive = alive;
		}
	}
	public static class BehemothFortressRules
	{
		public const float MinimumHubRadius = 25f;

		public const float MaximumHubRadius = 70f;

		public const float HubRadius = 45f;

		public const float Reduction = 0.55f;

		public const float HealFraction = 0.015f;

		public const float HealInterval = 2f;

		public const float FactoryMultiplier = 1.5f;

		public const float IntervalMultiplier = 0.5f;

		public const int MaxFortresses = 3;

		public const int MaxHubs = 4;

		public const int ZoneLimit = 2;

		public const int Segments = 16;

		public const float MinScale = 0.3f;

		public const float MaxScale = 1f;

		public const float MaxSide = 110f;

		public const float BuildRange = 180f;

		public const float ConnectionTolerance = 0.3f;

		public static bool Finite(float x)
		{
			if (!float.IsNaN(x))
			{
				return !float.IsInfinity(x);
			}
			return false;
		}

		public static bool Valid(float yaw, float scale)
		{
			if (Finite(yaw) && Finite(scale) && scale >= 0.3f)
			{
				return scale <= 1f;
			}
			return false;
		}

		public static float Health(BehemothFortressKind kind, bool fortressHub = false)
		{
			return kind switch
			{
				BehemothFortressKind.Gate => 30000, 
				BehemothFortressKind.Hub => fortressHub ? 25000 : 10000, 
				_ => 20000, 
			};
		}

		public static float HubRange(float scale)
		{
			return 25f + 45f * Math.Max(0f, Math.Min(1f, (scale - 0.3f) / 0.7f));
		}

		public static bool ValidWalls(float scale)
		{
			if (Finite(scale) && scale >= 0.3f)
			{
				return scale <= 1f;
			}
			return false;
		}

		public static bool Covered(IReadOnlyList<BehemothFortressEdge> walls, BehemothAllyPoint center, BehemothAllyPoint point, float height, float wallHeight = 0f)
		{
			if (walls == null || walls.Count < 4 || !PointValid(center) || !PointValid(point) || !Finite(height) || height <= 0f || !Finite(wallHeight) || wallHeight < 0f || wallHeight > height)
			{
				return false;
			}
			float num = 0f;
			float num2 = 0f;
			float num3 = center.Y;
			float num4 = point.X - center.X;
			float num5 = point.Z - center.Z;
			foreach (BehemothFortressEdge wall in walls)
			{
				float num6 = wall.B.X - wall.A.X;
				float num7 = wall.B.Z - wall.A.Z;
				float num8 = wall.A.X - center.X;
				float num9 = wall.A.Z - center.Z;
				float num10 = num4 * num7 - num5 * num6;
				if (!(Math.Abs(num10) < 1E-05f))
				{
					float num11 = (num8 * num7 - num9 * num6) / num10;
					float num12 = (num8 * num5 - num9 * num4) / num10;
					if (num11 > 0f && num12 >= -0.0001f && num12 <= 1.0001f && (num2 == 0f || num11 < num2))
					{
						num2 = num11;
						num3 = wall.A.Y + (wall.B.Y - wall.A.Y) * num12;
					}
				}
			}
			if (num4 * num4 + num5 * num5 < 1E-06f)
			{
				num = 0f;
			}
			else
			{
				if (num2 <= 0f || num2 < 0.9999f)
				{
					return false;
				}
				num = 1f / num2;
			}
			float num13 = center.Y + (num3 - center.Y) * num + wallHeight + (height - wallHeight) * (float)Math.Sqrt(Math.Max(0f, 1f - num * num));
			if (point.Y >= Math.Min(center.Y, num3) - 8f)
			{
				return point.Y <= num13 + 0.05f;
			}
			return false;
		}

		public static bool PointValid(BehemothAllyPoint p)
		{
			if (Finite(p.X) && Finite(p.Y))
			{
				return Finite(p.Z);
			}
			return false;
		}

		public static bool Powered(IReadOnlyList<BehemothFortressEdge> walls, bool hubAlive)
		{
			if (!hubAlive || walls == null || walls.Count < 4)
			{
				return false;
			}
			double num = 0.0;
			for (int i = 0; i < walls.Count; i++)
			{
				BehemothFortressEdge behemothFortressEdge = walls[i];
				BehemothFortressEdge behemothFortressEdge2 = walls[(i + 1) % walls.Count];
				if (!behemothFortressEdge.Alive || !PointValid(behemothFortressEdge.A) || !PointValid(behemothFortressEdge.B) || (behemothFortressEdge.A - behemothFortressEdge.B).Length < 0.1f || (behemothFortressEdge.B - behemothFortressEdge2.A).Length > 0.3f)
				{
					return false;
				}
				num += (double)(behemothFortressEdge.A.X * behemothFortressEdge.B.Z - behemothFortressEdge.B.X * behemothFortressEdge.A.Z);
			}
			return Math.Abs(num) > 4.0;
		}

		public static bool Inside(IReadOnlyList<BehemothFortressEdge> walls, BehemothAllyPoint p)
		{
			if (walls == null || !PointValid(p))
			{
				return false;
			}
			bool flag = false;
			foreach (BehemothFortressEdge wall in walls)
			{
				BehemothAllyPoint a = wall.A;
				BehemothAllyPoint b = wall.B;
				if (a.Z > p.Z != b.Z > p.Z && p.X < (b.X - a.X) * (p.Z - a.Z) / (b.Z - a.Z) + a.X)
				{
					flag = !flag;
				}
			}
			return flag;
		}

		public static BehemothAllyPoint CanopyPoint(BehemothAllyPoint center, BehemothAllyPoint boundary, float fraction, float height, float wallHeight)
		{
			float num = Math.Max(0f, Math.Min(1f, fraction)) * (float)Math.PI * 0.5f;
			float num2 = (float)Math.Cos(num);
			float num3 = (float)Math.Sin(num);
			return new BehemothAllyPoint(center.X + (boundary.X - center.X) * num2, center.Y + (boundary.Y - center.Y) * num2 + wallHeight + (height - wallHeight) * num3, center.Z + (boundary.Z - center.Z) * num2);
		}

		public static bool CanLock(bool hostile, bool alive, float distance, float aimDot)
		{
			if (hostile && alive && Finite(distance) && distance >= 1f && distance <= 900f && Finite(aimDot))
			{
				return aimDot >= 0.9659258f;
			}
			return false;
		}

		public static bool LockSequence(uint sequence, uint previous)
		{
			if (sequence != 0)
			{
				return sequence > previous;
			}
			return false;
		}
	}
	public sealed class BehemothPylonLatch
	{
		private bool ready = true;

		public bool Observe(float health)
		{
			if (!BehemothSupportRules.Finite(health))
			{
				return false;
			}
			if (health > 0.35f)
			{
				ready = true;
			}
			if (health > 0.3f || !ready)
			{
				return false;
			}
			ready = false;
			return true;
		}
	}
	public static class BehemothHubRules
	{
		public const int PersistentBolts = 2;

		public const float ShutdownSeconds = 8f;

		public static float Power(bool dead, float age)
		{
			if (!dead)
			{
				return 1f;
			}
			if (!BehemothSupportRules.Finite(age))
			{
				return 0f;
			}
			float num = Math.Max(0f, Math.Min(1f, age / 8f));
			return 1f - num * num * (3f - 2f * num);
		}

		public static float ShutdownAngle(float start, float speed, float age, float seconds)
		{
			if (!BehemothSupportRules.Finite(start) || !BehemothSupportRules.Finite(speed) || !BehemothSupportRules.Finite(age) || !BehemothSupportRules.Finite(seconds) || seconds <= 0f)
			{
				return start;
			}
			float num = Math.Max(0f, Math.Min(seconds, age));
			return start + speed * (num - num * num / (2f * seconds));
		}

		public static float ShutdownSpeed(float speed, float age, float seconds)
		{
			if (BehemothSupportRules.Finite(speed) && BehemothSupportRules.Finite(age) && BehemothSupportRules.Finite(seconds) && !(seconds <= 0f))
			{
				return speed * Math.Max(0f, 1f - Math.Max(0f, age) / seconds);
			}
			return 0f;
		}

		public static float DamageSeverity(float health, bool dead)
		{
			if (!dead)
			{
				if (BehemothSupportRules.Finite(health) && !(health > 0.3f))
				{
					return 0.2f + 0.8f * Math.Max(0f, Math.Min(1f, (0.3f - health) / 0.3f));
				}
				return 0f;
			}
			return 1f;
		}
	}
	public static class BehemothMegaBombWallRules
	{
		public const float DamageCoefficient = 20f;

		public const float PlayerScale = 2f;

		public const float TitanScale = 0.5f;

		public static float Damage(float value)
		{
			if (BehemothTitanRules.Finite(value) && !(value <= 0f))
			{
				return (float)Math.Min(3.3230697913918834E+35, (double)value * 20.0);
			}
			return 0f;
		}

		public static bool Contact(float previousRadius, float radius, float previousDistance, float distance, float bodyRadius, float bottom, float top, float wallHeight, float alpha)
		{
			if (!BehemothTitanRules.Finite(bottom) || !BehemothTitanRules.Finite(top) || !BehemothTitanRules.Finite(wallHeight) || !BehemothTitanRules.Finite(alpha) || alpha <= 0.01f || wallHeight < 0f || top < 0f || bottom > wallHeight)
			{
				return false;
			}
			return RadialContact(previousRadius, radius, previousDistance, distance, bodyRadius);
		}

		public static bool RadialContact(float previousRadius, float radius, float previousDistance, float distance, float bodyRadius)
		{
			if (!BehemothTitanRules.Finite(previousRadius) || !BehemothTitanRules.Finite(radius) || !BehemothTitanRules.Finite(previousDistance) || !BehemothTitanRules.Finite(distance) || !BehemothTitanRules.Finite(bodyRadius) || radius < 0f || previousRadius < 0f || bodyRadius < 0f)
			{
				return false;
			}
			float num = Math.Min(previousDistance - previousRadius, distance - radius);
			float num2 = Math.Max(previousDistance - previousRadius * 0.93f, distance - radius * 0.93f);
			if (num <= bodyRadius)
			{
				return num2 >= 0f - bodyRadius;
			}
			return false;
		}
	}
	public enum BehemothPilotMode : byte
	{
		Native,
		OnFoot,
		Driving
	}
	public static class BehemothPilotingRules
	{
		public const float ExitDistance = 25f;

		public const float BoardRange = 4f;

		public const float ReturnRange = 35f;

		public const float InputTimeout = 0.4f;

		public const float TeleportRange = 500f;

		public static bool RemoveParkedComponent(string name)
		{
			if (!(name == "MinionLeash"))
			{
				return name == "Deployable";
			}
			return true;
		}

		public static bool Boardable(BehemothAllyKind kind)
		{
			if (kind != BehemothAllyKind.Megaron && kind != BehemothAllyKind.Heavy && kind != BehemothAllyKind.Medium && kind != BehemothAllyKind.Skirmisher && kind != BehemothAllyKind.Turret)
			{
				return kind == BehemothAllyKind.Artillery;
			}
			return true;
		}

		public static bool Finite(float x)
		{
			if (!float.IsNaN(x))
			{
				return !float.IsInfinity(x);
			}
			return false;
		}

		public static bool Fresh(float now, float received)
		{
			if (Finite(now) && Finite(received) && now >= received)
			{
				return now - received <= 0.4f;
			}
			return false;
		}
	}
	public sealed class BehemothPilotLedger
	{
		private readonly Dictionary<uint, uint> seats = new Dictionary<uint, uint>();

		private readonly Dictionary<uint, uint> riders = new Dictionary<uint, uint>();

		public uint Driver(uint vehicle)
		{
			if (!seats.TryGetValue(vehicle, out var value))
			{
				return 0u;
			}
			return value;
		}

		public uint Vehicle(uint rider)
		{
			if (!riders.TryGetValue(rider, out var value))
			{
				return 0u;
			}
			return value;
		}

		public bool Board(uint rider, uint vehicle, BehemothAllyKind kind)
		{
			if (rider == 0 || vehicle == 0 || rider == vehicle || !BehemothPilotingRules.Boardable(kind) || Driver(vehicle) != 0 || Vehicle(rider) != 0)
			{
				return false;
			}
			seats.Add(vehicle, rider);
			riders.Add(rider, vehicle);
			return true;
		}

		public void Release(uint rider)
		{
			if (riders.TryGetValue(rider, out var value))
			{
				riders.Remove(rider);
				seats.Remove(value);
			}
		}

		public void Clear()
		{
			riders.Clear();
			seats.Clear();
		}
	}
	public static class BehemothRules
	{
		public const string ReleaseVersion = "0.6.5";

		public static void RequirePlanVersion(string actual, string fileName)
		{
			if (actual != "0.6.5")
			{
				throw new InvalidDataException(fileName + ": expected Behemoth 0.6.5, found " + (actual ?? "missing version") + ". Install the complete matching package.");
			}
		}

		public static bool InSphere(float dx, float dy, float dz, float radius)
		{
			if (radius >= 0f)
			{
				return dx * dx + dy * dy + dz * dz <= radius * radius;
			}
			return false;
		}

		public static bool InRadar(float dx, float dz, float radius)
		{
			if (radius > 0f)
			{
				return dx * dx + dz * dz <= radius * radius;
			}
			return false;
		}

		public static float LightningHash(uint seed, int index)
		{
			int num = (int)seed ^ (index * -1640531527);
			int num2 = (num ^ (num >>> 16)) * 2146121005;
			int num3 = (num2 ^ (num2 >>> 15)) * -2073254261;
			return (float)(uint)((num3 ^ (num3 >>> 16)) & 0xFFFFFF) / 16777215f;
		}

		public static bool Finite(float value)
		{
			if (!float.IsNaN(value))
			{
				return !float.IsInfinity(value);
			}
			return false;
		}

		public static float StormReach(float elapsed, float duration)
		{
			if (!(duration > 0f))
			{
				return 1f;
			}
			return Smooth(elapsed / duration);
		}

		public static float StormFlare(float t, float distance, float maximum)
		{
			return (float)Math.Sin((double)Math.Max(0f, Math.Min(1f, t)) * Math.PI) * Math.Min(maximum, Math.Max(0f, distance) * 0.18f);
		}

		public static bool SupportedFootprint(float[] heights, float[] normals, float minimumNormal, float maximumSpread)
		{
			if (heights == null || normals == null || heights.Length < 4 || heights.Length != normals.Length)
			{
				return false;
			}
			float num = float.PositiveInfinity;
			float num2 = float.NegativeInfinity;
			for (int i = 0; i < heights.Length; i++)
			{
				if (!Finite(heights[i]) || !Finite(normals[i]) || normals[i] < minimumNormal)
				{
					return false;
				}
				num = Math.Min(num, heights[i]);
				num2 = Math.Max(num2, heights[i]);
			}
			return num2 - num <= maximumSpread;
		}

		public static void MapPoint(float u, float v, float centerX, float centerZ, float halfExtent, out float x, out float z)
		{
			x = centerX + (u - 0.5f) * halfExtent * 2f;
			z = centerZ + (v - 0.5f) * halfExtent * 2f;
		}

		public static void TerrainNormal(float frontLeft, float frontRight, float rearLeft, float rearRight, float width, float length, out float x, out float y, out float z)
		{
			if (width <= 0f || length <= 0f)
			{
				throw new ArgumentOutOfRangeException("width");
			}
			x = (0f - (frontRight + rearRight - frontLeft - rearLeft)) / (2f * width);
			y = 1f;
			z = (0f - (frontLeft + frontRight - rearLeft - rearRight)) / (2f * length);
			float num = (float)Math.Sqrt(x * x + y * y + z * z);
			x /= num;
			y /= num;
			z /= num;
		}

		public static void RadarPoint(float dx, float dz, float headingDegrees, float range, float pixelRadius, out float x, out float y)
		{
			if (range <= 0f || pixelRadius <= 0f)
			{
				throw new ArgumentOutOfRangeException("range");
			}
			double num = (double)headingDegrees * Math.PI / 180.0;
			x = (float)(((double)dx * Math.Cos(num) - (double)dz * Math.Sin(num)) * (double)pixelRadius / (double)range);
			y = (float)(((double)dx * Math.Sin(num) + (double)dz * Math.Cos(num)) * (double)pixelRadius / (double)range);
		}

		public static bool TreadPlane(float[] xs, float[] ys, float[] zs, out float height, out float slopeX, out float slopeZ)
		{
			height = (slopeX = (slopeZ = 0f));
			if (xs == null || ys == null || zs == null || xs.Length != ys.Length || xs.Length != zs.Length)
			{
				return false;
			}
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			double num4 = 0.0;
			double num5 = 0.0;
			double num6 = 0.0;
			for (int i = 0; i < ys.Length; i++)
			{
				if (Finite(ys[i]))
				{
					num++;
					num4 += (double)xs[i];
					num5 += (double)ys[i];
					num6 += (double)zs[i];
					if (xs[i] < 0f)
					{
						num2++;
					}
					else
					{
						num3++;
					}
				}
			}
			if (num < 4 || num2 < 2 || num3 < 2)
			{
				return false;
			}
			num4 /= (double)num;
			num5 /= (double)num;
			num6 /= (double)num;
			double num7 = 0.0;
			double num8 = 0.0;
			double num9 = 0.0;
			double num10 = 0.0;
			double num11 = 0.0;
			for (int j = 0; j < ys.Length; j++)
			{
				if (Finite(ys[j]))
				{
					double num12 = (double)xs[j] - num4;
					double num13 = (double)zs[j] - num6;
					double num14 = (double)ys[j] - num5;
					num7 += num12 * num12;
					num8 += num13 * num13;
					num9 += num12 * num13;
					num10 += num12 * num14;
					num11 += num13 * num14;
				}
			}
			double num15 = num7 * num8 - num9 * num9;
			if (num15 < 0.0001)
			{
				return false;
			}
			slopeX = (float)((num10 * num8 - num11 * num9) / num15);
			slopeZ = (float)((num11 * num7 - num10 * num9) / num15);
			height = (float)(num5 - (double)slopeX * num4 - (double)slopeZ * num6);
			if (Finite(height) && Finite(slopeX))
			{
				return Finite(slopeZ);
			}
			return false;
		}

		public static void ZoomMap(float u, float v, float half, float scroll, float minimum, float maximum, out float next, out float dx, out float dz)
		{
			minimum = Math.Min(minimum, maximum);
			next = Math.Max(minimum, Math.Min(maximum, half * (float)Math.Exp(scroll * 0.12f)));
			dx = (u * 2f - 1f) * (half - next);
			dz = (v * 2f - 1f) * (half - next);
		}

		public static bool RoundDue(float elapsed, int fired, int count, float spacing)
		{
			if (fired >= 0 && fired < count)
			{
				return elapsed + 0.0001f >= (float)fired * Math.Max(0f, spacing);
			}
			return false;
		}

		public static bool TreadSupport(float[] xs, float[] ys, float[] zs, float maximumSlope, out float height, out float slopeX, out float slopeZ)
		{
			height = (slopeX = (slopeZ = 0f));
			if (!TreadPlane(xs, ys, zs, out var height2, out var slopeX2, out var slopeZ2))
			{
				return false;
			}
			float num = float.PositiveInfinity;
			float num2 = float.NegativeInfinity;
			for (int i = 0; i < ys.Length; i++)
			{
				if (Finite(ys[i]))
				{
					num = Math.Min(num, zs[i]);
					num2 = Math.Max(num2, zs[i]);
				}
			}
			if (num > 0.5f || num2 < -0.5f)
			{
				return false;
			}
			float num3 = float.PositiveInfinity;
			for (int j = 0; j < ys.Length - 2; j++)
			{
				if (!Finite(ys[j]))
				{
					continue;
				}
				for (int k = j + 1; k < ys.Length - 1; k++)
				{
					if (!Finite(ys[k]))
					{
						continue;
					}
					for (int l = k + 1; l < ys.Length; l++)
					{
						if (!Finite(ys[l]))
						{
							continue;
						}
						float num4 = xs[k] - xs[j];
						float num5 = zs[k] - zs[j];
						float num6 = xs[l] - xs[j];
						float num7 = zs[l] - zs[j];
						float num8 = num4 * num7 - num6 * num5;
						if (Math.Abs(num8) < 0.0001f)
						{
							continue;
						}
						float num9 = ((ys[k] - ys[j]) * num7 - (ys[l] - ys[j]) * num5) / num8;
						float num10 = (num4 * (ys[l] - ys[j]) - num6 * (ys[k] - ys[j])) / num8;
						if (num9 * num9 + num10 * num10 > maximumSlope * maximumSlope + 0.0001f)
						{
							continue;
						}
						float num11 = ys[j] - num9 * xs[j] - num10 * zs[j];
						if (num11 >= num3)
						{
							continue;
						}
						bool flag = true;
						for (int m = 0; m < ys.Length; m++)
						{
							if (Finite(ys[m]) && num11 + num9 * xs[m] + num10 * zs[m] < ys[m] - 0.002f)
							{
								flag = false;
								break;
							}
						}
						if (flag)
						{
							num3 = num11;
							slopeX = num9;
							slopeZ = num10;
						}
					}
				}
			}
			if (Finite(num3))
			{
				height = num3;
				return true;
			}
			float num12 = (float)Math.Sqrt(slopeX2 * slopeX2 + slopeZ2 * slopeZ2);
			float num13 = ((num12 > maximumSlope) ? (maximumSlope / num12) : 1f);
			slopeX = slopeX2 * num13;
			slopeZ = slopeZ2 * num13;
			height = TreadClearance(xs, ys, zs, slopeX, slopeZ, height2);
			return Finite(height);
		}

		public static float TreadClearance(float[] xs, float[] ys, float[] zs, float slopeX, float slopeZ, float fallback)
		{
			float num = float.NegativeInfinity;
			for (int i = 0; i < ys.Length; i++)
			{
				if (Finite(ys[i]))
				{
					num = Math.Max(num, ys[i] - slopeX * xs[i] - slopeZ * zs[i]);
				}
			}
			if (!Finite(num))
			{
				return fallback;
			}
			return num;
		}

		public static float Smooth(float t)
		{
			t = Math.Max(0f, Math.Min(1f, t));
			return t * t * (3f - 2f * t);
		}

		public static void EngineGains(float warmup, float speedBlend, out float tone, out float churn, out float drive)
		{
			float num = Smooth(warmup);
			float num2 = Smooth(speedBlend);
			tone = (1f - 0.65f * num) * (1f - num2);
			churn = 0.65f * num * (1f - 0.65f * num2);
			drive = num2;
		}
	}
	public sealed class BehemothStormVisual : MonoBehaviour
	{
		private Transform[] tips;

		private MeshRenderer[] cores;

		private ParticleSystem[] sparks;

		private LineRenderer[] bridges;

		private Mesh chargeMesh;

		private float age;

		private float duration;

		public void Begin(Transform[] anchors, float seconds, Material energy, Material cloud)
		{
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			tips = anchors;
			duration = seconds;
			cores = (MeshRenderer[])(object)new MeshRenderer[3];
			sparks = (ParticleSystem[])(object)new ParticleSystem[3];
			bridges = (LineRenderer[])(object)new LineRenderer[3];
			for (int i = 0; i < 3; i++)
			{
				GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
				Collider component = val.GetComponent<Collider>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.enabled = false;
					Object.Destroy((Object)(object)component);
				}
				MeshFilter component2 = val.GetComponent<MeshFilter>();
				if (!Object.op_Implicit((Object)(object)chargeMesh))
				{
					chargeMesh = Object.Instantiate<Mesh>(component2.sharedMesh);
					((Object)chargeMesh).name = "Behemoth white vertex charge sphere";
					Color[] array = (Color[])(object)new Color[chargeMesh.vertexCount];
					for (int j = 0; j < array.Length; j++)
					{
						array[j] = Color.white;
					}
					chargeMesh.colors = array;
				}
				component2.sharedMesh = chargeMesh;
				val.transform.SetParent(((Component)this).transform, false);
				cores[i] = val.GetComponent<MeshRenderer>();
				((Renderer)cores[i]).sharedMaterial = energy;
				((Renderer)cores[i]).shadowCastingMode = (ShadowCastingMode)0;
				sparks[i] = StormParticles.Create(((Component)this).transform, "Red spike charge", cloud, 2f, 1f, 50f, burst: false);
				bridges[i] = StormParticles.Line(((Component)this).transform, energy, 0.08f, new Color(1f, 0.035f, 0.1f, 1f));
				bridges[i].positionCount = 13;
			}
			UpdateGeometry(0f);
		}

		private void Update()
		{
			age += Time.deltaTime;
			if (tips == null || age > duration + 0.5f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else
			{
				UpdateGeometry(Mathf.Clamp01(age / duration));
			}
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)chargeMesh))
			{
				Object.Destroy((Object)(object)chargeMesh);
			}
		}

		private void UpdateGeometry(float progress)
		{
			//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_003d: 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_0062: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: 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_0166: 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_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 3; i++)
			{
				if (!Object.op_Implicit((Object)(object)tips[i]))
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
					break;
				}
				Vector3 position = tips[i].position;
				((Component)cores[i]).transform.position = position;
				((Component)cores[i]).transform.localScale = Vector3.one * (0.3f + progress * 1.6f) * (1f + 0.12f * Mathf.Sin(age * 43f + (float)i));
				StormParticles.Tint((Renderer)(object)cores[i], Color.Lerp(new Color(1f, 0f, 0.025f), new Color(1f, 0.7f, 0.8f), progress * progress));
				((Component)sparks[i]).transform.position = position;
				ShapeModule shape = sparks[i].shape;
				((ShapeModule)(ref shape)).radius = 0.25f + progress * 0.9f;
				EmissionModule emission = sparks[i].emission;
				((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(12f + progress * 75f);
				Vector3 position2 = tips[(i + 1) % 3].position;
				((Renderer)bridges[i]).enabled = progress > 0.2f;
				for (int j = 0; j < 13; j++)
				{
					float num = (float)j / 12f;
					Vector3 val = Vector3.Lerp(position, position2, num);
					if (j > 0 && j < 12)
					{
						val += new Vector3(Mathf.Sin((float)(j * 13) + age * 64f), Mathf.Sin((float)(j * 7) + age * 51f), Mathf.Cos((float)(j * 17) + age * 57f)) * (0.1f + 0.45f * progress);
					}
					bridges[i].SetPosition(j, val);
				}
				bridges[i].widthMultiplier = 0.06f + 0.16f * progress;
			}
		}
	}
	public sealed class BehemothStormBolt : MonoBehaviour
	{
		private LineRenderer[] cores;

		private LineRenderer[] halos;

		private Vector3 from;

		private Vector3 to;

		private float age;

		private float flight = 0.65f;

		private float flare = 8f;

		private float radius;

		private float pulseRate = 30f;

		private uint seed;

		private bool ended;

		private bool automaticImpact;

		private Material cloud;

		private float[] intensityPulses;

		private Func<Vector3> sourcePosition;

		private Func<Vector3> targetPosition;

		private static readonly float[] DefaultPulses = new float[9] { 1f, 0.7f, 1f, 1.22f, 1.34f, 0.44f, 1.1f, 1.05f, 1.35f };

		public void Begin(Vector3 origin, Vector3 target, uint variation, float blastRadius, Material energy, Material particles)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			BeginFlight(origin, target, variation, blastRadius, energy, particles, 0.65f, 8f);
			automaticImpact = true;
		}

		public void BeginFlight(Vector3 origin, Vector3 target, uint variation, float blastRadius, Material energy, Material particles, float seconds, float spread, float mainWidth = 2.2f, int branchCount = 4, float flashesPerSecond = 30f, float[] pulses = null, Material haloMaterial = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: 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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: 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_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Expected O, but got Unknown
			from = origin;
			to = target;
			seed = variation;
			radius = blastRadius;
			cloud = particles;
			flight = seconds;
			flare = spread;
			pulseRate = flashesPerSecond;
			intensityPulses = ((pulses != null && pulses.Length != 0) ? pulses : DefaultPulses);
			int num = Mathf.Clamp(branchCount, 1, 8) + 1;
			cores = (LineRenderer[])(object)new LineRenderer[num];
			halos = (LineRenderer[])(object)new LineRenderer[num];
			for (int i = 0; i < num; i++)
			{
				float num2 = mainWidth * ((i == 0) ? 1f : (0.4f + 0.2f * BehemothRules.LightningHash(seed, i)));
				cores[i] = StormParticles.Line(((Component)this).transform, energy, num2, Color.white);
				halos[i] = StormParticles.Line(((Component)this).transform, Object.op_Implicit((Object)(object)haloMaterial) ? haloMaterial : energy, num2 * 1.75f, new Color(0.69f, 0.43f, 1f, 0.52f));
				LineRenderer obj = cores[i];
				int positionCount = (halos[i].positionCount = ((i == 0) ? 25 : 13));
				obj.positionCount = positionCount;
				if (i > 0)
				{
					AnimationCurve val = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
					{
						new Keyframe(0f, 0.03f),
						new Keyframe(0.18f, 0.55f),
						new Keyframe(1f, 1.25f)
					});
					LineRenderer obj2 = cores[i];
					AnimationCurve widthCurve = (halos[i].widthCurve = val);
					obj2.widthCurve = widthCurve;
					cores[i].widthMultiplier = num2;
					halos[i].widthMultiplier = num2 * 1.75f;
				}
			}
			UpdateBolt();
		}

		public void Follow(Func<Vector3> source, Func<Vector3> target)
		{
			sourcePosition = source;
			targetPosition = target;
		}

		public void Cancel()
		{
			if (!ended)
			{
				ended = true;
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void Update()
		{
			//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_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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			if (!ended)
			{
				age += Time.deltaTime;
				if (sourcePosition != null)
				{
					from = sourcePosition();
				}
				if (targetPosition != null)
				{
					to = targetPosition();
				}
				if (automaticImpact && age >= flight)
				{
					new GameObject("Storm impact").AddComponent<BehemothStormImpact>().Begin(to, radius, cloud);
					Cancel();
				}
				else if (age > flight + 1f)
				{
					Cancel();
				}
				else
				{
					UpdateBolt();
				}
			}
		}

		private void UpdateBolt()
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0056: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: 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_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: 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_0301: 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_01a1: 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_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: 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_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Vector3 val = to - from;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			val = Vector3.Cross(normalized, Vector3.up);
			Vector3 val2 = ((Vector3)(ref val)).normalized;
			if (((Vector3)(ref val2)).sqrMagnitude < 0.01f)
			{
				val2 = Vector3.right;
			}
			val = Vector3.Cross(val2, normalized);
			Vector3 normalized2 = ((Vector3)(ref val)).normalized;
			float num = Vector3.Distance(from, to);
			float num2 = BehemothRules.StormReach(age, flight);
			float num3 = Mathf.Min(1.5f, num * 0.025f);
			int num4 = Mathf.FloorToInt(age * pulseRate);
			float num5 = (((seed & 1) == 0) ? 1 : (-1));
			float num6 = intensityPulses[num4 % intensityPulses.Length];
			for (int i = 0; i < cores.Length; i++)
			{
				bool flag = num4 % 9 != 5 || i < 2;
				LineRenderer obj = cores[i];
				bool enabled = (((Renderer)halos[i]).enabled = flag);
				((Renderer)obj).enabled = enabled;
				float num7 = BehemothRules.LightningHash(seed, i * 19 + 1 + num4 * 307) * (float)Math.PI * 2f;
				for (int j = 0; j < cores[i].positionCount; j++)
				{
					float num8 = (float)j / (float)(cores[i].positionCount - 1) * num2;
					float num9 = BehemothRules.StormFlare(num8, num, flare);
					Vector3 val3 = Vector3.Lerp(from, to, num8) + val2 * (num9 * num5) + Vector3.up * (num9 * 0.4f);
					if (i > 0)
					{
						val3 += (val2 * Mathf.Cos(num7) + normalized2 * Mathf.Sin(num7)) * num9 * (0.35f + (float)i * 0.12f);
					}
					if (j > 0 && j < cores[i].positionCount - 1)
					{
						val3 += (val2 * (BehemothRules.LightningHash(seed, num4 * 137 + i * 21 + j) - 0.5f) + normalized2 * (BehemothRules.LightningHash(seed, num4 * 233 + i * 23 + j) - 0.5f)) * num3 * 2f;
					}
					cores[i].SetPosition(j, val3);
					halos[i].SetPosition(j, val3);
				}
				StormParticles.Tint((Renderer)(object)cores[i], new Color(num6 * 1.5f, num6 * 1.5f, num6 * 1.5f, 1f));
				StormParticles.Tint((Renderer)(object)halos[i], new Color(0.9f, 0.73f, 1f, Mathf.Clamp01(num6 * 0.55f)));
			}
		}
	}
	public sealed class BehemothStormImpact : MonoBehaviour
	{
		private float age;

		public void Begin(Vector3 point, float radius, Material cloud)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.position = point;
			ParticleSystem obj = StormParticles.Create(((Component)this).transform, "Massive white red detonation", cloud, radius * 0.23f, 0.6f, 0f, burst: true);
			MainModule main = obj.main;
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(radius * 0.8f, radius * 2.1f);
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.45f, 1.75f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(radius * 0.3f, radius * 0.75f);
			obj.Emit(64);
		}

		private void Update()
		{
			age += Time.deltaTime;
			if (age > 2.4f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	public static class StormParticles
	{
		public static LineRenderer Line(Transform parent, Material material, float width, Color color)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			LineRenderer obj = new GameObject("Storm lightning").AddComponent<LineRenderer>();
			((Component)obj).transform.SetParent(parent, false);
			((Renderer)obj).sharedMaterial = material;
			float startWidth = (obj.endWidth = width);
			obj.startWidth = startWidth;
			Color startColor = (obj.endColor = color);
			obj.startColor = startColor;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)obj).receiveShadows = false;
			obj.useWorldSpace = true;
			obj.numCapVertices = 2;
			return obj;
		}

		public static void Tint(Renderer renderer, Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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)
			MaterialPropertyBlock val = new MaterialPropertyBlock();
			val.SetColor("_Color", color);
			val.SetColor("_TintColor", color);
			val.SetColor("_EmColor", color);
			val.SetColor("_EmissionColor", color);
			renderer.SetPropertyBlock(val);
		}

		public static ParticleSystem Create(Transform parent, string name, Material material, float size, float lifetime, float rate, bool burst)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//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_005d: 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_0086: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected O, but got Unknown
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: 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_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: 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_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: 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_01ca: 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_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: 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_023c: 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_0250: Expected O, but got Unknown
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.SetActive(false);
			val.transform.SetParent(parent, false);
			ParticleSystem val2 = val.AddComponent<ParticleSystem>();
			val2.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = val2.main;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).loop = !burst;
			((MainModule)(ref main)).duration = 3f;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(lifetime);
			((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(size);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(burst ? 8f : 1.5f);
			((MainModule)(ref main)).maxParticles = 256;
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit((Color)(burst ? Color.white : new Color(1f, 0.6f, 0.7f, 0.85f)));
			((MainModule)(ref main)).cullingMode = (ParticleSystemCullingMode)3;
			EmissionModule emission = val2.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(rate);
			ShapeModule shape = val2.shape;
			((ShapeModule)(ref shape)).enabled = true;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = 0.2f;
			ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val3 = new Gradient();
			val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
			{
				new GradientColorKey(Color.white, 0f),
				new GradientColorKey(new Color(1f, 0.05f, 0.1f), 0.55f),
				new GradientColorKey(new Color(0.17f, 0.1f, 0.15f), 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(0.95f, 0f),
				new GradientAlphaKey(0.7f, 0.35f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3);
			SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, 0.25f),
				new Keyframe(0.2f, 1f),
				new Keyframe(1f, 1.7f)
			}));
			ParticleSystemRenderer component = ((Component)val2).GetComponent<ParticleSystemRenderer>();
			((Renderer)component).sharedMaterial = material;
			component.renderMode = (ParticleSystemRenderMode)0;
			((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
			val.SetActive(true);
			val2.Play();
			return val2;
		}
	}
	public static class BehemothSupportRules
	{
		public static bool Inside(float x, float y, float z, float tx, float ty, float tz, float radius)
		{
			if (!Finite(x) || !Finite(y) || !Finite(z) || !Finite(tx) || !Finite(ty) || !Finite(tz) || !Finite(radius) || radius <= 0f)
			{
				return false;
			}
			double num = (double)tx - (double)x;
			double num2 = (double)ty - (double)y;
			double num3 = (double)tz - (double)z;
			return num * num + num2 * num2 + num3 * num3 <= (double)radius * (double)radius;
		}

		public static float SpeedMultiplier(int hundredthsPercent)
		{
			return Math.Max(0.01f, 1f - (float)Math.Max(0, hundredthsPercent) / 10000f);
		}

		public static float CooldownMultiplier(int hundredthsPercent)
		{
			return 1f + (float)Math.Max(0, hundredthsPercent) / 10000f;
		}

		public static float SphereAudioGain(float distance, float radius, float beyondRange)
		{
			if (!Finite(distance) || !Finite(radius) || !Finite(beyondRange) || beyondRange <= 0f)
			{
				return 0f;
			}
			return Math.Max(0f, Math.Min(1f, 1f - Math.Max(0f, distance - Math.Max(0f, radius)) / beyondRange));
		}

		public static float Fade(float current, bool enabled, float dt, float seconds)
		{
			if (!Finite(current) || !Finite(dt) || !Finite(seconds) || seconds <= 0f)
			{
				return enabled ? 1 : 0;
			}
			float num = Math.Max(0f, dt) / seconds;
			if (!enabled)
			{
				return Math.Max(0f, current - num);
			}
			return Math.Min(1f, current + num);
		}

		public static void PickupExtents(float width, float length, float yaw, float pitch, float roll, out float x, out float y, out float z)
		{
			double num = (double)yaw * Math.PI / 180.0;
			double a = (double)pitch * Math.PI / 180.0;
			double a2 = (double)roll * Math.PI / 180.0;
			x = (float)(Math.Abs(Math.Cos(num)) * (double)width * 0.5 + Math.Abs(Math.Sin(num)) * (double)length * 0.5);
			z = (float)(Math.Abs(Math.Sin(num)) * (double)width * 0.5 + Math.Abs(Math.Cos(num)) * (double)length * 0.5);
			y = 1.2f + (float)(Math.Abs(Math.Sin(a)) * (double)length * 0.5 + Math.Abs(Math.Sin(a2)) * (double)width * 0.5);
		}

		public static bool Finite(float f)
		{
			if (!float.IsNaN(f))
			{
				return !float.IsInfinity(f);
			}
			return false;
		}
	}
	public static class BehemothTitanBlastRules
	{
		public static void Tint(float r, float g, float b, bool wave, out float red, out float green, out float blue)
		{
			red = ((BehemothTitanRules.Finite(r) && BehemothTitanRules.Finite(g) && BehemothTitanRules.Finite(b)) ? Math.Max(0f, Math.Max(r, Math.Max(g, b))) : 0f);
			green = red * (wave ? 0.006f : 0.22f);
			blue = red * (wave ? 0.03f : 0.015f);
		}

		public static void Flame(float r, float g, float b, float heat, out float red, out float green, out float blue)
		{
			Tint(r, g, b, wave: false, out red, out green, out blue);
			float num = Math.Max(0f, Math.Min(1f, heat));
			green = red * (0.12f + 0.6f * num);
			blue = red * (0.008f + 0.045f * num);
		}

		public static bool WhiteWall(string name)
		{
			switch (name)
			{
			default:
				return name.StartsWith("Late_Expanding_Cap_", StringComparison.Ordinal);
			case null:
				return false;
			case "Continuous_White_Wave":
			case "BLAST_COLLAR":
			case "STREAKS":
				return true;
			}
		}
	}
	public enum BehemothTitanPose : byte
	{
		Idle,
		Walk,
		Roar,
		Strike,
		Die,
		Flinch,
		Fly
	}
	public static class BehemothTitanRules
	{
		public const float Height = 18f;

		public const float Range = 15f;

		public const float RoarSeconds = 2.717143f;

		public const float StrikeSeconds = 3f;

		public const float DeathSeconds = 9f;

		public const float ReloadSeconds = 4f;

		public const float ImpactTime = 1.3333334f;

		public const float WallRadius = 45f;

		public const float WallSeconds = 27.757235f;

		public const float StompSide = 2.14f;

		public const float StompForward = 4.33f;

		public static bool Finite(float n)
		{
			if (!float.IsNaN(n))
			{
				return !float.IsInfinity(n);
			}
			return false;
		}

		public static bool Newer(uint id, uint previous)
		{
			if (id != 0)
			{
				if (previous != 0)
				{
					return (int)(id - previous) > 0;
				}
				return true;
			}
			return false;
		}

		public static string Clip(BehemothTitanPose pose)
		{
			return pose switch
			{
				BehemothTitanPose.Fly => "fly", 
				BehemothTitanPose.Flinch => "flinch", 
				BehemothTitanPose.Die => "die", 
				BehemothTitanPose.Strike => "strike", 
				BehemothTitanPose.Walk => "walk", 
				_ => "idle", 
			};
		}

		public static float Sample(float age, float seconds, int frames, bool loop)
		{
			if (!Finite(age) || !Finite(seconds) || seconds <= 0f || frames < 2)
			{
				return 0f;
			}
			float num = Math.Max(0f, age) / seconds;
			if (!loop)
			{
				return Math.Min(1f, num) * (float)(frames - 1);
			}
			return (num - (float)Math.Floor(num)) * (float)frames;
		}

		public static float WalkRate(float speed, float natural)
		{
			if (Finite(speed) && Finite(natural) && !(natural <= 0.01f))
			{
				return Math.Max(0.5f, Math.Min(1.6f, speed / natural));
			}
			return 1f;
		}

		public static bool Landed(float previous, float current, float cycle, float[] lands)
		{
			if (lands == null || !Finite(previous) || !Finite(current) || !Finite(cycle) || cycle <= 0f || current <= previous || current - previous >= cycle)
			{
				return false;
			}
			foreach (float num in lands)
			{
				double num2 = Math.Floor((previous - num) / cycle);
				if (Math.Floor((current - num) / cycle) > num2)
				{
					return true;
				}
			}
			return false;
		}

		public static bool Footstep(float previous, float current)
		{
			if (Finite(previous) && Finite(current) && current > previous)
			{
				return Math.Floor((current + 0.375f) / 1.5f) > Math.Floor((previous + 0.375f) / 1.5f);
			}
			return false;
		}
	}
	public sealed class BehemothTitanAttack
	{
		private bool hit;

		public float Started { get; private set; }

		public float ReadyAt { get; private set; }

		public bool Active { get; private set; }

		public bool Dead { get; private set; }

		public bool Begin(float now)
		{
			if (!BehemothTitanRules.Finite(now) || Dead || Active || now < ReadyAt)
			{
				return false;
			}
			Started = now;
			Active = true;
			hit = false;
			return true;
		}

		public bool Tick(float now)
		{
			if (!Active || Dead || !BehemothTitanRules.Finite(now) || now < Started)
			{
				return false;
			}
			float num = now - Started;
			int num2;
			if (!hit)
			{
				num2 = ((num >= 1.3333334f) ? 1 : 0);
				if (num2 != 0)
				{
					hit = true;
				}
			}
			else
			{
				num2 = 0;
			}
			if (num >= 3f)
			{
				Active = false;
				ReadyAt = Started + 3f + 4f;
			}
			return (byte)num2 != 0;
		}

		public BehemothTitanPose Pose(float now)
		{
			return BehemothTitanPose.Strike;
		}

		public float PoseAge(float now)
		{
			return Math.Max(0f, now - Started);
		}

		public void Die()
		{
			Dead = true;
			Active = false;
		}

		public void Revive(float now)
		{
			Dead = false;
			Active = false;
			hit = false;
			ReadyAt = now + 4f;
		}
	}
	public sealed class BehemothTitanPlayback
	{
		private int lastStep = -1;

		public float[] Lands;

		public float Cycle;

		public BehemothTitanPose Pose { get; private set; }

		public float Age { get; private set; }

		public uint Sequence { get; private set; }

		public bool Snapshot(BehemothTitanPose pose, float age, uint id)
		{
			if (!BehemothTitanRules.Newer(id, Sequence) || !BehemothTitanRules.Finite(age) || age < 0f || (int)pose > 6)
			{
				return false;
			}
			if (pose != Pose || age + 1f < Age)
			{
				lastStep = -1;
			}
			bool num = pose == Pose && pose == BehemothTitanPose.Walk && Sequence != 0;
			Sequence = id;
			Pose = pose;
			if (!num)
			{
				Age = age;
			}
			return true;
		}

		public bool Advance(float seconds, float rate = 1f)
		{
			if (!BehemothTitanRules.Finite(seconds) || seconds <= 0f)
			{
				return false;
			}
			if (!BehemothTitanRules.Finite(rate) || rate <= 0f)
			{
				rate = 1f;
			}
			float age = Age;
			Age += Math.Min(seconds, 0.25f) * ((Pose == BehemothTitanPose.Walk) ? rate : 1f);
			if (Lands != null && Cycle > 0f)
			{
				if (Pose == BehemothTitanPose.Walk)
				{
					return BehemothTitanRules.Landed(age, Age, Cycle, Lands);
				}
				return false;
			}
			int num = (int)Math.Floor((Age + 0.375f) / 1.5f);
			if (Pose != BehemothTitanPose.Walk || !BehemothTitanRules.Footstep(age, Age) || num <= lastStep)
			{
				return false;
			}
			lastStep = num;
			return true;
		}
	}
	public sealed class BehemothVisualRig : MonoBehaviour
	{
		public Transform turretYaw;

		public Transform gunPitch;

		public Transform gunRecoil;

		public Transform muzzle;

		public Transform barrelFace;

		public float yawDegreesPerSecond = 12f;

		public float pitchDegreesPerSecond;

		private float angle;

		private float shutdownAge;

		private float shutdownStart;

		private float shutdownSpeed;

		private float shutdownSeconds;

		private bool stopping;

		public bool IsShuttingDown => stopping;

		private void Awake()
		{
			Bind();
		}

		public void Bind()
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			turretYaw = Find(((Component)this).transform, "TurretYaw");
			gunPitch = Find(((Component)this).transform, "GunPitch");
			gunRecoil = Find(((Component)this).transform, "GunRecoil");
			muzzle = Find(((Component)this).transform, "muzzle");
			barrelFace = muzzle;
			if (Object.op_Implicit((Object)(object)turretYaw))
			{
				angle = turretYaw.localEulerAngles.y;
			}
		}

		public void AimWorld(Vector3 direction)
		{
		}

		public void AimLocal(Vector3 direction)
		{
		}

		public void FireVisualRecoil()
		{
		}

		public void SetAngles(float yaw, float elevation)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			angle = yaw;
			if (Object.op_Implicit((Object)(object)turretYaw))
			{
				turretYaw.localRotation = Quaternion.Euler(0f, angle, 0f);
			}
		}

		public void BeginShutdown(float seconds)
		{
			if (!stopping)
			{
				SetShutdown(angle, yawDegreesPerSecond, 0f, seconds);
			}
		}

		public void SetShutdown(float start, float speed, float age, float seconds)
		{
			stopping = true;
			shutdownStart = start;
			shutdownSpeed = speed;
			shutdownAge = Mathf.Max(0f, age);
			shutdownSeconds = seconds;
			ApplyShutdown();
		}

		public void ResumeSpin()
		{
			stopping = false;
		}

		private void ApplyShutdown()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			angle = BehemothHubRules.ShutdownAngle(shutdownStart, shutdownSpeed, shutdownAge, shutdownSeconds);
			if (Object.op_Implicit((Object)(object)turretYaw))
			{
				turretYaw.localRotation = Quaternion.Euler(0f, angle, 0f);
			}
		}

		private void LateUpdate()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)turretYaw))
			{
				if (stopping)
				{
					shutdownAge += Time.deltaTime;
					ApplyShutdown();
				}
				else
				{
					angle = Mathf.Repeat(angle + yawDegreesPerSecond * Time.deltaTime, 360f);
					turretYaw.localRotation = Quaternion.Euler(0f, angle, 0f);
				}
			}
		}

		public static Transform Find(Transform root, string name)
		{
			if (((Object)root).name == name)
			{
				return root;
			}
			for (int i = 0; i < root.childCount; i++)
			{
				Transform val = Find(root.GetChild(i), name);
				if (Object.op_Implicit((Object)(object)val))
				{
					return val;
				}
			}
			return null;
		}
	}
}
namespace TankUniversal.Behemoth.MegaBombV13
{
	[DisallowMultipleComponent]
	public sealed class TU1MegaBombEffect : MonoBehaviour
	{
		[Header("Playback")]
		public bool playOnStart = true;

		public bool destroyWhenComplete;

		[Range(0.1f, 1f)]
		public float particleDensity = 1f;

		public int particleSeed = 9137;

		[NonSerialized]
		public Func<int, TU1MegaBombPlan.Particle, Color> particleColor;

		[Header("Exactly four early translucent rays")]
		[Range(1f, 10f)]
		public float rayLifetime = 5.2f;

		[Range(-90f, 90f)]
		public float rayRotationDegreesPerSecond = 34f;

		[Range(0f, 1f)]
		public float rayOpacity = 1f;

		[Header("Faint blue pulses around both body sections")]
		[Range(0f, 2f)]
		public float blueDiskOpacity = 1f;

		[Range(0.2f, 3f)]
		public float blueDiskRadius = 1f;

		[Header("Audio")]
		[Range(0f, 1f)]
		public float effectsVolume = 1f;

		public float blastWallSoundDelay = 2.7f;

		private Transform _outer;

		private Transform _inner;

		private Transform _collar;

		private Transform _streaks;

		private Transform _ground;

		private Transform _column;

		private Transform _rays;

		private Transform[] _caps;

		private Renderer[] _capRenderers;

		private Transform[] _pressure;

		private Transform[] _blue;

		private Renderer[] _pressureRenderers;

		private Renderer[] _blueRenderers;

		private Transform[] _bodyPulses;

		private Renderer[] _bodyPulseRenderers;

		private Transform[] _bodies;

		private Renderer[] _bodyRenderers;

		private Mesh[] _bodyMeshes;

		private Vector3[][] _bodyPositions;

		private Renderer _outerRenderer;

		private Renderer _innerRenderer;

		private Renderer _collarRenderer;

		private Renderer _streakRenderer;

		private Renderer _groundRenderer;

		private Renderer _columnRenderer;

		private Renderer _rayRenderer;

		private ParticleSystem[] _systems;

		private Particle[][] _buffers;

		private Mesh _columnMesh;

		private Mesh _rayMesh;

		private Mesh _domeMesh;

		private Vector3[] _columnPositions;

		private Vector3[] _rayPositions;

		private Light[] _lights;

		private AudioSource _nuke;

		private AudioSource _wallSound;

		private MaterialPropertyBlock _block;

		private bool _playing;

		private bool _wallPlayed;

		private float _time;

		public float Elapsed => _time;

		public bool RaysVisible
		{
			get
			{
				if ((Object)(object)_rayRenderer != (Object)null)
				{
					return _rayRenderer.enabled;
				}
				return false;
			}
		}

		public int LiveParticleCount
		{
			get
			{
				int num = 0;
				if (_systems != null)
				{
					ParticleSystem[] systems = _systems;
					foreach (ParticleSystem val in systems)
					{
						if ((Object)(object)val != (Object)null)
						{
							num += val.particleCount;
						}
					}
				}
				return num;
			}
		}

		private Transform Child(string path)
		{
			return ((Component)this).transform.Find(path);
		}

		private static Renderer RendererOf(Transform t)
		{
			if (!((Object)(object)t != (Object)null))
			{
				return null;
			}
			return ((Component)t).GetComponent<Renderer>();
		}

		private void Awake()
		{
			//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fd: Expected O, but got Unknown
			_outer = Child("Subtype5_A/BLAST_WALL_Outer");
			_inner = Child("Subtype5_B/BLAST_WALL_Inner");
			_collar = Child("Subtype5_A/BLAST_COLLAR");
			_streaks = Child("Subtype5_A/STREAKS");
			_ground = Child("Subtype5_A/Continuous_White_Wave");
			_column = Child("Subtype2/Reconstructed_FlameColumn");
			_rays = Child("Four_Rotating_Rays");
			_caps = (Transform[])(object)new Transform[3];
			_capRenderers = (Renderer[])(object)new Renderer[3];
			for (int i = 0; i < 3; i++)
			{
				_caps[i] = Child("Subtype2/Late_Expanding_Cap_" + i);
				_capRenderers[i] = RendererOf(_caps[i]);
			}
			_pressure = (Transform[])(object)new Transform[4];
			_pressureRenderers = (Renderer[])(object)new Renderer[_pressure.Length];
			for (int j = 0; j < _pressure.Length; j++)
			{
				_pressure[j] = Child("Subtype2/Anchored_Pulse_Disk_" + j);
				_pressureRenderers[j] = RendererOf(_pressure[j]);
			}
			_blue = (Transform[])(object)new Transform[10];
			_blueRenderers = (Renderer[])(object)new Renderer[_blue.Length];
			for (int k = 0; k < _blue.Length; k++)
			{
				_blue[k] = Child("Subtype5_A/Flat_Blue_Shockwave_" + k);
				_blueRenderers[k] = RendererOf(_blue[k]);
			}
			_bodyPulses = (Transform[])(object)new Transform[8];
			_bodyPulseRenderers = (Renderer[])(object)new Renderer[_bodyPulses.Length];
			for (int l = 0; l < _bodyPulses.Length; l++)
			{
				_bodyPulses[l] = Child("Subtype2/Blue_Body_Pulse_" + l);
				_bodyPulseRenderers[l] = RendererOf(_bodyPulses[l]);
			}
			_bodies = (Transform[])(object)new Transform[2];
			_bodyRenderers = (Renderer[])(object)new Renderer[2];
			_bodyMeshes = (Mesh[])(object)new Mesh[2];
			_bodyPositions = new Vector3[2][];
			for (int m = 0; m < 2; m++)
			{
				_bodies[m] = Child("Subtype2/" + ((m == 0) ? "Lower_Fireball" : "Upper_Fireball"));
				_bodyRenderers[m] = RendererOf(_bodies[m]);
				if ((Object)(object)_bodies[m] != (Object)null)
				{
					_bodyMeshes[m] = TU1MegaBombGeometry.Body(m == 1);
					((Component)_bodies[m]).GetComponent<MeshFilter>().sharedMesh = _bodyMeshes[m];
					_bodyPositions[m] = (Vector3[])(object)new Vector3[_bodyMeshes[m].vertexCount];
				}
			}
			if ((Object)(object)_outer != (Object)null)
			{
				_domeMesh = TU1MegaBombGeometry.Dome();
				((Component)_outer).GetComponent<MeshFilter>().sharedMesh = _domeMesh;
			}
			_outerRenderer = RendererOf(_outer);
			_innerRenderer = RendererOf(_inner);
			_collarRenderer = RendererOf(_collar);
			_streakRenderer = RendererOf(_streaks);
			_groundRenderer = RendererOf(_ground);
			_columnRenderer = RendererOf(_column);
			_rayRenderer = RendererOf(_rays);
			if ((Object)(object)_column != (Object)null)
			{
				_columnMesh = TU1MegaBombGeometry.Column();
				((Component)_column).GetComponent<MeshFilter>().sharedMesh = _columnMesh;
				_columnPositions = (Vector3[])(object)new Vector3[_columnMesh.vertexCount];
			}
			if ((Object)(object)_rays != (Object)null)
			{
				_rayMesh = TU1MegaBombGeometry.Rays();
				((Component)_rays).GetComponent<MeshFilter>().sharedMesh = _rayMesh;
				_rayPositions = (Vector3[])(object)new Vector3[_rayMesh.vertexCount];
			}
			_systems = (ParticleSystem[])(object)new ParticleSystem[8];
			_buffers = new Particle[_systems.Length][];
			string[] array = new string[8] { "Particles/Gold_White_Sparks", "Particles/Pink_Rising_Sparks", "Particles/WhiteHot_Fire", "Particles/AfterSmoke", "Particles/Detached_Hot_Cloud", "Particles/Wave_Spray", "Particles/Ignition_Flare", "Particles/Fireball_Halo" };
			for (int n = 0; n < _systems.Length; n++)
			{
				Transform val = Child(array[n]);
				_systems[n] = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<ParticleSystem>() : null);
				_buffers[n] = (Particle[])(object)new Particle[TU1MegaBombPlan.Capacities[n]];
			}
			_lights = ((Component)this).GetComponentsInChildren<Light>(true);
			_block = new MaterialPropertyBlock();
			Transform val2 = Child("OriginalAudio_nuke.wav");
			Transform val3 = Child("OriginalAudio_BLAST_WALL.wav");
			_nuke = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<AudioSource>() : null);
			_wallSound = (((Object)(object)val3 != (Object)null) ? ((Component)val3).GetComponent<AudioSource>() : null);
			Stop();
		}

		private void Start()
		{
			if (playOnStart && !_playing)
			{
				Play();
			}
		}

		public void Play()
		{
			Stop();
			_playing = true;
			_time = 0f;
			_wallPlayed = false;
			ParticleSystem[] systems = _systems;
			foreach (ParticleSystem val in systems)
			{
				if ((Object)(object)val != (Object)null)
				{
					val.Play(false);
				}
			}
			if ((Object)(object)_nuke != (Object)null)
			{
				_nuke.volume = effectsVolume;
				_nuke.Play();
			}
			Animate(0f);
		}

		public void Stop()
		{
			_playing = false;
			if (_systems != null)
			{
				ParticleSystem[] systems = _systems;
				foreach (ParticleSystem val in systems)
				{
					if ((Object)(object)val != (Object)null)
					{
						val.Stop(false, (ParticleSystemStopBehavior)0);
					}
				}
			}
			if ((Object)(object)_nuke != (Object)null)
			{
				_nuke.Stop();
			}
			if ((Object)(object)_wallSound != (Object)null)
			{
				_wallSound.Stop();
			}
			if (_lights != null)
			{
				Light[] lights = _lights;
				foreach (Light val2 in lights)
				{
					if ((Object)(object)val2 != (Object)null)
					{
						((Behaviour)val2).enabled = false;
					}
				}
			}
			Renderer[][] array = new Renderer[5][] { _capRenderers, _pressureRenderers, _blueRenderers, _bodyRenderers, _bodyPulseRenderers };
			Renderer[] array3;
			foreach (Renderer[] array2 in array)
			{
				if (array2 == null)
				{
					continue;
				}
				array3 = array2;
				foreach (Renderer val3 in array3)
				{
					if ((Object)(object)val3 != (Object)null)
					{
						val3.enabled = false;
					}
				}
			}
			array3 = (Renderer[])(object)new Renderer[7] { _outerRenderer, _innerRenderer, _collarRenderer, _streakRenderer, _groundRenderer, _columnRenderer, _rayRenderer };
			foreach (Renderer val4 in array3)
			{
				if ((Object)(object)val4 != (Object)null)
				{
					val4.enabled = false;
				}
			}
		}

		private void Update()
		{
			if (!_playing)
			{
				return;
			}
			_time += Time.deltaTime;
			Animate(_time);
			if (!_wallPlayed && _time >= blastWallSoundDelay)
			{
				_wallPlayed = true;
				if ((Object)(object)_wallSound != (Object)null)
				{
					_wallSound.volume = effectsVolume;
					_wallSound.Play();
				}
			}
			if (_time >= 27.757235f)
			{
				Stop();
				if (destroyWhenComplete)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
			}
		}

		private void Animate(float time)
		{
			//IL_008d: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_0130: 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_0197: 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_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0507: Unknown result type (might be due to invalid IL or missing references)
			//IL_050c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0736: Unknown result type (might be due to invalid IL or missing references)
			//IL_073b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0607: Unknown result type (might be due to invalid IL or missing references)
			//IL_07aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07da: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_080d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0804: Unknown result type (might be due to invalid IL or missing references)
			//IL_0812: Unknown result type (might be due to invalid IL or missing references)
			//IL_0833: Unknown result type (might be due to invalid IL or missing references)
			//IL_086e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0870: Unknown result type (might be due to invalid IL or missing references)
			TU1MegaBombPlan.Frame f = TU1MegaBombPlan.Sample(time, rayLifetime, rayRotationDegreesPerSecond);
			Scale(_outer, f.BlueRadius, f.BlueHeight, f.BlueRadius);
			Scale(_inner, f.BlueRadius * 0.88f / 0.918f, f.BlueHeight * 0.85f / 0.413f, f.BlueRadius * 0.88f / 0.918f);
			Appearance(_outerRenderer, new Color(0.035f, 0.12f, 1f, f.BlueAlpha), new Vector2(0f, (0f - time) * 0.9f));
			Appearance(_innerRenderer, new Color(0.06f, 0.07f, 1f, 0f), new Vector2(time * 0.1f, (0f - time) * 0.7f));
			Scale(_ground, f.GroundRadius, f.GroundHeight, f.GroundRadius);
			Appearance(_groundRenderer, new Color(1.1f, 1.1f, 1.02f, f.GroundAlpha), new Vector2((0f - time) * 0.18f, (0f - time) * 0.8f));
			Scale(_collar, f.GroundRadius * 0.98f, f.GroundHeight * 1.5f, f.GroundRadius * 0.98f);
			Appearance(_collarRenderer, new Color(1f, 0.85f, 0.9f, f.GroundAlpha * 0.12f), new Vector2(0f, 0f - time));
			Scale(_streaks, f.CapRadius, f.CapHeight * 0.1f, f.CapRadius);
			if ((Object)(object)_streaks != (Object)null)
			{
				_streaks.localPosition = new Vector3(0f, f.CapY, 0f);
			}
			Appearance(_streakRenderer, new Color(1f, 1f, 0.9f, f.CapAlpha * 0.015f), new Vector2(0f, 0f - time));
			for (int i = 0; i < 3; i++)
			{
				float num = f.CapRadius * (0.9f + (float)i * 0.055f);
				Scale(_caps[i], num, f.CapHeight, num);
				if ((Object)(object)_caps[i] != (Object)null)
				{
					_caps[i].localPosition = new Vector3(0f, f.CapY + (float)i * 0.1f, 0f);
				}
				Appearance(_capRenderers[i], new Color(1.05f, 1.05f, 0.98f, f.CapAlpha * (0.26f - (float)i * 0.05f)), new Vector2(0f, (0f - time) * 0.7f));
			}
			for (int j = 0; j < _pressure.Length; j++)
			{
				TU1MegaBombPlan.Ring ring = TU1MegaBombPlan.PressureDisk(j, time);
				Scale(_pressure[j], ring.Radius, ring.Height, ring.Radius);
				if ((Object)(object)_pressure[j] != (Object)null)
				{
					_pressure[j].localPosition = new Vector3(0f, ring.Y, 0f);
				}
				Appearance(_pressureRenderers[j], new Color(1f, 0.85f + (float)j * 0.04f, 0.55f + (float)j * 0.12f, ring.Alpha), new Vector2((0f - time) * 0.24f, 0f));
			}
			for (int k = 0; k < _blue.Length; k++)
			{
				TU1MegaBombPlan.Ring ring2 = TU1MegaBombPlan.BlueWave(k, time);
				Scale(_blue[k], ring2.Radius, ring2.Height, ring2.Radius);
				if ((Object)(object)_blue[k] != (Object)null)
				{
					_blue[k].localPosition = new Vector3(0f, ring2.Y, 0f);
				}
				Appearance(_blueRenderers[k], new Color(0.1f, 0.24f, 1f, ring2.Alpha), new Vector2(time * 0.17f, 0f));
			}
			for (int l = 0; l < _bodyPulses.Length; l++)
			{
				TU1MegaBombPlan.Ring ring3 = TU1MegaBombPlan.BodyPulse(l, time);
				Scale(_bodyPulses[l], ring3.Radius * blueDiskRadius, ring3.Height, ring3.Radius * blueDiskRadius);
				if ((Object)(object)_bodyPulses[l] != (Object)null)
				{
					_bodyPulses[l].localPosition = new Vector3(0f, ring3.Y, 0f);
				}
				Appearance(_bodyPulseRenderers[l], TU1MegaBombPlan.BodyPulseTint(ring3.Alpha * blueDiskOpacity), Vector2.zero);
			}
			for (int m = 0; m < 2; m++)
			{
				if ((Object)(object)_bodyMeshes[m] != (Object)null)
				{
					TU1MegaBombGeometry.WriteBody(f, _bodyPositions[m], m == 1);
					_bodyMeshes[m].vertices = _bodyPositions[m];
					_bodyMeshes[m].RecalculateNormals();
					_bodyMeshes[m].RecalculateBounds();
					float num2 = TU1MegaBombPlan.Smooth(17f, 22f, time);
					Color tint = ((m == 0) ? new Color(1f, 1f - num2 * 0.75f, 0.94f - num2 * 0.78f, f.LowerAlpha) : new Color(1f, 1f, 0.95f, f.UpperAlpha));
					Appearance(_bodyRenderers[m], tint, new Vector2(0f, (0f - time) * 0.46f));
				}
			}
			if ((Object)(object)_columnMesh != (Object)null)
			{
				TU1MegaBombGeometry.WriteColumn(f, _columnPositions);
				_columnMesh.vertices = _columnPositions;
				_columnMesh.RecalculateNormals();
				_columnMesh.RecalculateBounds();
			}
			float num3 = TU1MegaBombPlan.Smooth(17f, 20f, time);
			float num4 = TU1MegaBombPlan.Smooth(22f, 25f, time);
			Appearance(_columnRenderer, new Color(1f, Mathf.Lerp(1f, 0.7f, num3) * (1f - num4 * 0.85f), Mathf.Lerp(0.94f, 0.22f, num3) * (1f - num4 * 0.6f), f.CoreAlpha), new Vector2(0f, (0f - time) * 0.38f));
			if ((Object)(object)_rayMesh != (Object)null)
			{
				TU1MegaBombGeometry.WriteRays(f, _rayPositions);
				_rayMesh.vertices = _rayPositions;
				_rayMesh.RecalculateBounds();
			}
			Appearance(_rayRenderer, TU1MegaBombPlan.RayTint(f.RayAlpha * rayOpacity), Vector2.zero);
			for (int n = 0; n < _systems.Length; n++)
			{
				ParticleSystem val = _systems[n];
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				int num5 = 0;
				int num6 = Mathf.Clamp(Mathf.RoundToInt((float)TU1MegaBombPlan.Capacities[n] * particleDensity), 1, TU1MegaBombPlan.Capacities[n]);
				for (int num7 = 0; num7 < num6; num7++)
				{
					TU1MegaBombPlan.Particle arg = TU1MegaBombPlan.SampleParticle(n, num7, time, particleSeed, f);
					if (!(arg.Color.a < 0.002f))
					{
						Particle[] obj = _buffers[n];
						int num8 = num5++;
						Particle val2 = default(Particle);
						((Particle)(ref val2)).position = arg.Position;
						((Particle)(ref val2)).velocity = Vector3.zero;
						((Particle)(ref val2)).startColor = Color32.op_Implicit((particleColor == null) ? arg.Color : particleColor(n, arg));
						((Particle)(ref val2)).startSize3D = new Vector3(arg.Width, arg.Height, arg.Width);
						((Particle)(ref val2)).rotation = arg.Rotation;
						((Particle)(ref val2)).startLifetime = 60f;
						((Particle)(ref val2)).remainingLifetime = 60f;
						((Particle)(ref val2)).randomSeed = (uint)(num7 + 1);
						obj[num8] = val2;
					}
				}
				val.SetParticles(_buffers[n], num5);
			}
			for (int num9 = 0; num9 < _lights.Length; num9++)
			{
				Light val3 = _lights[num9];
				if (!((Object)(object)val3 == (Object)null))
				{
					((Behaviour)val3).enabled = f.CoreAlpha > 0.01f || f.LowerAlpha > 0.01f;
					val3.range = 128f;
					val3.intensity = (f.Fade * ((num9 == 0) ? 3.5f : 2f) + f.Flash * 8f) * (0.8f + 0.2f * TU1MegaBombPlan.Noise((int)(time * 8f), 19));
				}
			}
			if ((Object)(object)_nuke != (Object)null)
			{
				_nuke.volume = effectsVolume;
			}
			if ((Object)(object)_wallSound != (Object)null)
			{
				_wallSound.volume = effectsVolume;
			}
		}

		private void Appearance(Renderer r, Color tint, Vector2 scroll)
		{
			//IL_000b: 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_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_005a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)r == (Object)null))
			{
				r.enabled = tint.a > 0.0001f;
				_block.Clear();
				_block.SetColor("_TintColor", tint);
				_block.SetVector("_UvScroll", new Vector4(scroll.x, scroll.y, 0f, 0f));
				r.SetPropertyBlock(_block);
			}
		}

		private static void Scale(Transform t, float x, float y, float z)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)t != (Object)null)
			{
				t.localScale = new Vector3(x, y, z);
			}
		}

		private void OnDisable()
		{
			Stop();
		}

		private void OnDestroy()
		{
			if ((Object)(object)_domeMesh != (Object)null)
			{
				Object.Destroy((Object)(object)_domeMesh);
			}
			if ((Object)(object)_columnMesh != (Object)null)
			{
				Object.Destroy((Object)(object)_columnMesh);
			}
			if ((Object)(object)_rayMesh != (Object)null)
			{
				Object.Destroy((Object)(object)_rayMesh);
			}
			if (_bodyMeshes == null)
			{
				return;
			}
			Mesh[] bodyMeshes = _bodyMeshes;
			foreach (Mesh val in bodyMeshes)
			{
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
			}
		}
	}
	public static class TU1MegaBombGeometry
	{
		public const int ColumnRows = 40;

		public const int ColumnSides = 48;

		public static Mesh Column()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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 ref