Decompiled source of ShieldGeneratorBehemoth v0.3.5

BepInEx/plugins/ShieldGeneratorBehemoth/ShieldBehemothRuntime010.dll

Decompiled 18 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
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.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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyFileVersion("0.3.5.0")]
[assembly: AssemblyVersion("0.3.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 = 6;

		public static float Level(float level)
		{
			return (float.IsNaN(level) || float.IsInfinity(level)) ? 1f : Math.Max(1f, level);
		}

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

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

		public static float Armor(BehemothAllyKind k)
		{
			return k switch
			{
				BehemothAllyKind.Turret => 150, 
				BehemothAllyKind.Skirmisher => 50, 
				BehemothAllyKind.Artillery => 125, 
				BehemothAllyKind.Heavy => 200, 
				_ => 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)
		{
			return (float.IsNaN(value) || float.IsInfinity(value)) ? 0f : Math.Max(0f, value);
		}

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

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

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

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

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

		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)
		{
			return !Active && now >= ReloadUntil;
		}

		public bool Begin(BehemothAllyKind kind, float now)
		{
			if (!Ready(now))
			{
				return false;
			}
			Remaining = BehemothAllyBalance.BurstCount(kind);
			NextShot = now;
			LastShot = now;
			return true;
		}

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

		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)
		{
			return Active && now - Math.Max(LastShot, NextShot) > 2f;
		}

		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)
		{
			return 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 && CritDamage == b.CritDamage;
		}
	}
	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 => (Length > 1E-05f) ? (this * (1f / Length)) : default(BehemothAllyPoint);

		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)
		{
			return kind switch
			{
				BehemothAllyKind.Skirmisher => 220, 
				BehemothAllyKind.Heavy => 400, 
				BehemothAllyKind.Artillery => 900, 
				_ => 250, 
			};
		}

		public static float YawRate(BehemothAllyKind kind)
		{
			return kind switch
			{
				BehemothAllyKind.Skirmisher => 120, 
				BehemothAllyKind.Artillery => 42, 
				BehemothAllyKind.Heavy => 48, 
				_ => 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)
		{
			return (float.IsNaN(value) || float.IsInfinity(value)) ? 30f : Math.Max(5f, Math.Min(300f, value));
		}

		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:
			{
				BehemothAllyPoint normalized = new BehemothAllyPoint(behemothAllyPoint.X, 0f, behemothAllyPoint.Z).Normalized;
				return 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)
		{
			return kind == BehemothAllyKind.Artillery && distance < 110f;
		}
	}
	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)
		{
			return (!BehemothSupportRules.Finite(requested)) ? 45f : Math.Max(0f, Math.Min(300f, requested));
		}

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

		public static float UpgradeLegacyDefault(float requested, int revision)
		{
			return ((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)) ? 45f : Distance(requested);
		}

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

		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)
		{
			return part == "tankbase" || part == "sidearmor";
		}
	}
	public enum BehemothAllyKind : byte
	{
		Turret,
		Medium,
		Heavy,
		Skirmisher,
		Artillery,
		DropZone
	}
	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);
			}
			return kind switch
			{
				BehemothAllyKind.DropZone => !ZoneUsed, 
				BehemothAllyKind.Medium => now >= NextMedium && living < 1, 
				BehemothAllyKind.Turret => Charges > 0 && living < 3, 
				_ => 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[4]
			{
				BehemothAllyKind.Heavy,
				BehemothAllyKind.Medium,
				BehemothAllyKind.Skirmisher,
				BehemothAllyKind.Artillery
			})[Math.Min(3, Math.Max(0, (int)(roll * 4f)))];
		}
	}
	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)
		{
			return (kind == BehemothAllyKind.Artillery) ? Math.Max(1f, Math.Min(4f, distance / 55f)) : Math.Max(0.05f, distance / 180f);
		}

		public static float LaunchY(float dy, float seconds, float gravity)
		{
			return dy / seconds + gravity * seconds * 0.5f;
		}
	}
	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)
		{
			return (!BehemothSupportRules.Finite(speed) || !BehemothSupportRules.Finite(age) || !BehemothSupportRules.Finite(seconds) || seconds <= 0f) ? 0f : (speed * Math.Max(0f, 1f - Math.Max(0f, age) / seconds));
		}

		public static float DamageSeverity(float health, bool dead)
		{
			return dead ? 1f : ((!BehemothSupportRules.Finite(health) || health > 0.3f) ? 0f : (0.2f + 0.8f * Math.Max(0f, Math.Min(1f, (0.3f - health) / 0.3f))));
		}
	}
	public static class BehemothRules
	{
		public static bool InSphere(float dx, float dy, float dz, float radius)
		{
			return radius >= 0f && dx * dx + dy * dy + dz * dz <= radius * radius;
		}

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

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

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

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

		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);
			return Finite(height) && Finite(slopeX) && Finite(slopeZ);
		}

		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)
		{
			return fired >= 0 && fired < count && elapsed + 0.0001f >= (float)fired * Math.Max(0f, spacing);
		}

		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]);
				}
			}
			return Finite(num) ? num : fallback;
		}

		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_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			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_0039: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			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_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			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_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			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_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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: 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_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: 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) * MathF.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_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.position = point;
			ParticleSystem val = StormParticles.Create(((Component)this).transform, "Massive white red detonation", cloud, radius * 0.23f, 0.6f, 0f, burst: true);
			MainModule main = val.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);
			val.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_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			LineRenderer val = new GameObject("Storm lightning").AddComponent<LineRenderer>();
			((Component)val).transform.SetParent(parent, false);
			((Renderer)val).sharedMaterial = material;
			float startWidth = (val.endWidth = width);
			val.startWidth = startWidth;
			Color startColor = (val.endColor = color);
			val.startColor = startColor;
			((Renderer)val).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)val).receiveShadows = false;
			val.useWorldSpace = true;
			val.numCapVertices = 2;
			return val;
		}

		public static void Tint(Renderer renderer, Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_000d: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			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_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: 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_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: 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_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0252: 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_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Expected O, but got Unknown
			//IL_0261: 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;
			return enabled ? Math.Min(1f, current + num) : Math.Max(0f, 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)
		{
			return !float.IsNaN(f) && !float.IsInfinity(f);
		}
	}
	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 = 0f;

		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_007b: 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_002d: 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_0049: 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_0074: 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 = false;

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

		public int particleSeed = 9137;

		[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 => (Object)(object)_rayRenderer != (Object)null && _rayRenderer.enabled;

		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)
		{
			return ((Object)(object)t != (Object)null) ? ((Component)t).GetComponent<Renderer>() : null;
		}

		private void Awake()
		{
			//IL_0540: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: 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 };
			foreach (Renderer[] array2 in array)
			{
				if (array2 == null)
				{
					continue;
				}
				Renderer[] array3 = array2;
				foreach (Renderer val3 in array3)
				{
					if ((Object)(object)val3 != (Object)null)
					{
						val3.enabled = false;
					}
				}
			}
			Renderer[] array4 = (Renderer[])(object)new Renderer[7] { _outerRenderer, _innerRenderer, _collarRenderer, _streakRenderer, _groundRenderer, _columnRenderer, _rayRenderer };
			foreach (Renderer val4 in array4)
			{
				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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_0193: 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_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Unknown result type (might be due to invalid IL or missing references)
			//IL_0496: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0554: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Unknown result type (might be due to invalid IL or missing references)
			//IL_0740: Unknown result type (might be due to invalid IL or missing references)
			//IL_0752: Unknown result type (might be due to invalid IL or missing references)
			//IL_0645: Unknown result type (might be due to invalid IL or missing references)
			//IL_0617: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_064a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0656: Unknown result type (might be due to invalid IL or missing references)
			//IL_0665: Unknown result type (might be due to invalid IL or missing references)
			//IL_082c: Unknown result type (might be due to invalid IL or missing references)
			//IL_085a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0864: Unknown result type (might be due to invalid IL or missing references)
			//IL_0871: Unknown result type (might be due to invalid IL or missing references)
			//IL_0880: Unknown result type (might be due to invalid IL or missing references)
			//IL_0885: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e9: Unknown result type (might be due to invalid IL or missing references)
			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 particle = TU1MegaBombPlan.SampleParticle(n, num7, time, particleSeed);
					if (!(particle.Color.a < 0.002f))
					{
						Particle[] obj = _buffers[n];
						int num8 = num5++;
						Particle val2 = default(Particle);
						((Particle)(ref val2)).position = particle.Position;
						((Particle)(ref val2)).velocity = Vector3.zero;
						((Particle)(ref val2)).startColor = Color32.op_Implicit(particle.Color);
						((Particle)(ref val2)).startSize3D = new Vector3(particle.Width, particle.Height, particle.Width);
						((Particle)(ref val2)).rotation = particle.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_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_0010: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			int num = 2009;
			Vector3[] vertices = (Vector3[])(object)new Vector3[num];
			Vector2[] array = (Vector2[])(object)new Vector2[num];
			for (int i = 0; i <= 40; i++)
			{
				for (int j = 0; j <= 48; j++)
				{
					array[i * 49 + j] = new Vector2((float)j / 48f, (float)i / 40f);
				}
			}
			Mesh val = new Mesh
			{
				name = "V6_MorphingWhiteHotColumn"
			};
			val.MarkDynamic();
			val.vertices = vertices;
			val.uv = array;
			val.triangles = GridTriangles(40, 48);
			WhiteColors(val);
			return val;
		}

		private static int[] GridTriangles(int rows, int sides)
		{
			int[] array = new int[rows * sides * 6];
			int num = 0;
			for (int i = 0; i < rows; i++)
			{
				for (int j = 0; j < sides; j++)
				{
					int num2 = i * (sides + 1) + j;
					int num3 = num2 + sides + 1;
					array[num++] = num2;
					array[num++] = num3;
					array[num++] = num2 + 1;
					array[num++] = num2 + 1;
					array[num++] = num3;
					array[num++] = num3 + 1;
				}
			}
			return array;
		}

		public static void WriteColumn(TU1MegaBombPlan.Frame f, Vector3[] positions)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i <= 40; i++)
			{
				for (int j = 0; j <= 48; j++)
				{
					positions[i * 49 + j] = TU1MegaBombPlan.ColumnPoint(f, (float)i / 40f, (float)j * MathF.PI * 2f / 48f);
				}
			}
		}

		public static Mesh Dome()
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			Mesh val = Column();
			((Object)val).name = "Early_Expanding_Blue_Dome";
			Vector3[] vertices = val.vertices;
			for (int i = 0; i <= 40; i++)
			{
				for (int j = 0; j <= 48; j++)
				{
					float num = (float)i / 40f;
					float num2 = (float)j * MathF.PI * 2f / 48f;
					float num3 = (float)Math.Sqrt(Math.Max(0f, 1f - num * num));
					vertices[i * 49 + j] = new Vector3((float)Math.Cos(num2) * num3, num, (float)Math.Sin(num2) * num3);
				}
			}
			val.vertices = vertices;
			val.RecalculateBounds();
			return val;
		}

		public static Mesh Body(bool upper)
		{
			Mesh val = Column();
			((Object)val).name = (upper ? "Independent_Rising_Upper_Fireball" : "Independent_Lower_Fireball");
			return val;
		}

		public static void WriteBody(TU1MegaBombPlan.Frame f, Vector3[] positions, bool upper)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i <= 40; i++)
			{
				for (int j = 0; j <= 48; j++)
				{
					positions[i * 49 + j] = TU1MegaBombPlan.BodyPoint(f, (float)i / 40f, (float)j * MathF.PI * 2f / 48f, upper);
				}
			}
		}

		public static Mesh Rays()
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[48];
			Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
			int[] array3 = new int[144];
			int[] array4 = GridTriangles(3, 2);
			for (int i = 0; i < 4; i++)
			{
				for (int j = 0; j <= 3; j++)
				{
					for (int k = 0; k <= 2; k++)
					{
						array2[i * 12 + j * 3 + k] = new Vector2((float)k / 2f, (float)j / 3f);
					}
				}
				for (int l = 0; l < array4.Length; l++)
				{
					array3[i * array4.Length + l] = i * 12 + array4[l];
				}
			}
			Mesh val = new Mesh
			{
				name = "ExactlyFourTranslucentEpicenterRays"
			};
			val.MarkDynamic();
			val.vertices = array;
			val.uv = array2;
			val.triangles = array3;
			WhiteColors(val);
			return val;
		}

		public static void WriteRays(TU1MegaBombPlan.Frame f, Vector3[] positions)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 4; i++)
			{
				float num = (f.RayAngle + (float)(90 * i)) * MathF.PI / 180f;
				float num2 = (float)Math.Cos(num);
				float num3 = (float)Math.Sin(num);
				for (int j = 0; j <= 3; j++)
				{
					for (int k = 0; k <= 2; k++)
					{
						float num4 = (float)j / 3f;
						float num5 = num4 * f.RayLength;
						float num6 = (float)(k - 1) * (0.15f + num4 * 10f);
						positions[i * 12 + j * 3 + k] = new Vector3(num2 * num5 - num3 * num6, 3f + num5 * 0.17f, num3 * num5 + num2 * num6);
					}
				}
			}
		}

		public static Mesh GroundRing(int sides = 128)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[(sides + 1) * 4];
			Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
			int[] array3 = new int[sides * 18];
			int num = 0;
			for (int i = 0; i <= sides; i++)
			{
				float num2 = (float)i * MathF.PI * 2f / (float)sides;
				float num3 = (float)Math.Cos(num2);
				float num4 = (float)Math.Sin(num2);
				array[i * 4] = new Vector3(num3, 0f, num4);
				array[i * 4 + 1] = new Vector3(num3, 1f, num4);
				array[i * 4 + 2] = new Vector3(num3 * 0.93f, 1f, num4 * 0.93f);
				array[i * 4 + 3] = new Vector3(num3 * 0.93f, 0f, num4 * 0.93f);
				for (int j = 0; j < 4; j++)
				{
					array2[i * 4 + j] = new Vector2((float)i / (float)sides * 12f, (float)j / 3f);
				}
				if (i != sides)
				{
					for (int k = 0; k < 3; k++)
					{
						int num5 = i * 4 + k;
						array3[num++] = num5;
						array3[num++] = num5 + 4;
						array3[num++] = num5 + 1;
						array3[num++] = num5 + 1;
						array3[num++] = num5 + 4;
						array3[num++] = num5 + 5;
					}
				}
			}
			Mesh val = new Mesh
			{
				name = "ContinuousWhiteWave_Rim"
			};
			val.vertices = array;
			val.uv = array2;
			val.triangles = array3;
			val.RecalculateBounds();
			WhiteColors(val);
			return val;
		}

		public static Mesh PulseDisk(int sides = 128, int rings = 16)
		{
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			int num = sides + 1;
			int num2 = (rings + 1) * num;
			Vector3[] array = (Vector3[])(object)new Vector3[num2 * 2];
			Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
			Color[] array3 = (Color[])(object)new Color[array.Length];
			int[] array4 = new int[rings * sides * 12];
			int num3 = 0;
			for (int i = 0; i < 2; i++)
			{
				for (int j = 0; j <= rings; j++)
				{
					for (int k = 0; k <= sides; k++)
					{
						float num4 = (float)j / (float)rings;
						float num5 = (float)k * MathF.PI * 2f / (float)sides;
						float num6 = (float)Math.Cos(num5);
						float num7 = (float)Math.Sin(num5);
						int num8 = i * num2 + j * num + k;
						array[num8] = new Vector3(num6 * num4, (i == 0) ? (-0.5f) : 0.5f, num7 * num4);
						array2[num8] = new Vector2(0.5f + num6 * num4 * 0.5f, 0.5f + num7 * num4 * 0.5f);
						float num9 = (float)Math.Exp(0.0 - Math.Pow((num4 - 0.67f) / 0.23f, 2.0));
						float num10 = (0.24f + 0.65f * num9) * (1f - TU1MegaBombPlan.Smooth(0.77f, 1f, num4));
						array3[num8] = new Color(1f, 1f, 1f, num10);
						if (j != rings && k != sides)
						{
							int num11 = num8 + num;
							array4[num3++] = num8;
							array4[num3++] = num11;
							array4[num3++] = num8 + 1;
							array4[num3++] = num8 + 1;
							array4[num3++] = num11;
							array4[num3++] = num11 + 1;
						}
					}
				}
			}
			Mesh val = new Mesh
			{
				name = "Filled_Feathered_Blue_Pulse_Disk"
			};
			val.vertices = array;
			val.uv = array2;
			val.colors = array3;
			val.triangles = array4;
			val.RecalculateBounds();
			return val;
		}

		private static void WhiteColors(Mesh mesh)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			Color[] array = (Color[])(object)new Color[mesh.vertexCount];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = Color.white;
			}
			mesh.colors = array;
		}
	}
	public static class TU1MegaBombPlan
	{
		public struct Frame
		{
			public float Time;

			public float Height;

			public float Width;

			public float CoreAlpha;

			public float GroundRadius;

			public float GroundHeight;

			public float GroundAlpha;

			public float BlueRadius;

			public float BlueHeight;

			public float BlueAlpha;

			public float HeadY;

			public float HeadRadius;

			public float HeadAlpha;

			public float CapRadius;

			public float CapHeight;

			public float CapY;

			public float CapAlpha;

			public float RayAlpha;

			public float RayAngle;

			public float RayLength;

			public float Afterburn;

			public float Fade;

			public float LowerRadius;

			public float LowerHeight;

			public float LowerAlpha;

			public float UpperBaseY;

			public float UpperHeight;

			public float UpperRadius;

			public float UpperAlpha;

			public float Flash;
		}

		public struct Ring
		{
			public float Radius;

			public float Height;

			public float Y;

			public float Alpha;
		}

		public struct Particle
		{
			public Vector3 Position;

			public float Width;

			public float Height;

			public float Rotation;

			public Color Color;
		}

		public const float Duration = 27.757235f;

		public const float LowerRadiusScale = 1.18f;

		public const float LowerHeightScale = 1.12f;

		public const float DomeSpeed = 1.18f;

		public const float WhiteWallHeightScale = 2f;

		public const float BaseSizeScale = 2f;

		public const float ConnectorWidthScale = 1.15f;

		public const int RayCount = 4;

		public const int ParticleKinds = 8;

		public const int PressureDiskCount = 4;

		public const int BlueWaveCount = 10;

		public const int BodyPulseCount = 8;

		public static readonly int[] Capacities = new int[8] { 3000, 2400, 640, 240, 360, 1000, 192, 288 };

		private static readonly float[] Heights = new float[30]
		{
			0f, 3f, 0.4f, 10f, 0.8f, 24f, 1.5f, 47f, 2.4f, 50f,
			3.2f, 34f, 4f, 30f, 5f, 25f, 8f, 22f, 12f, 22f,
			16f, 20f, 20f, 23f, 24f, 16f, 26f, 6f, 27.757235f, 0f
		};

		private static readonly float[] LowerRadii = new float[28]
		{
			0f, 2f, 0.25f, 4f, 0.8f, 6.5f, 1.5f, 8.5f, 2.7f, 8.8f,
			3.5f, 9.5f, 5f, 11f, 7.5f, 12.5f, 11f, 14f, 16f, 13f,
			18f, 11f, 22f, 5f, 25f, 2f, 27.757235f, 0f
		};

		private static readonly float[] LowerHeights = new float[28]
		{
			0f, 3f, 0.5f, 9f, 0.8f, 21f, 1.5f, 46f, 2.4f, 48f,
			3.2f, 32f, 4.2f, 23f, 5.5f, 18f, 7.5f, 15f, 11f, 13f,
			16f, 12f, 19f, 19f, 24f, 13f, 27.757235f, 0f
		};

		private static readonly float[] UpperCentre = new float[26]
		{
			0f, 24f, 3.5f, 24f, 4.2f, 30f, 5f, 38f, 7f, 52f,
			9f, 67f, 12f, 77f, 14f, 82f, 16f, 87f, 18f, 94f,
			21f, 109f, 24f, 123f, 27.757235f, 130f
		};

		private static readonly float[] UpperHeights = new float[28]
		{
			0f, 0f, 3.5f, 0f, 4.2f, 12f, 5f, 30f, 7f, 64f,
			9f, 92f, 12f, 110f, 14f, 105f, 16f, 94f, 17.5f, 76f,
			19f, 48f, 21f, 32f, 24f, 14f, 27.757235f, 0f
		};

		private static readonly float[] UpperRadii = new float[26]
		{
			0f, 0f, 3.5f, 0.1f, 4.2f, 2f, 5f, 6f, 6.5f, 12f,
			8.5f, 19f, 11f, 22f, 14f, 22f, 16f, 20f, 18f, 17f,
			21f, 14f, 24f, 11f, 27.757235f, 0f
		};

		public static Color RayTint(float alpha)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			return new Color(1.4f, 0.065f, 0.09f, alpha);
		}

		public static Color BodyPulseTint(float alpha)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			return new Color(0.035f, 0.14f, 1f, alpha);
		}

		public static float Saturate(float x)
		{
			return Math.Max(0f, Math.Min(1f, x));
		}

		public static float Smooth(float a, float b, float t)
		{
			float num = Saturate((t - a) / (b - a));
			return num * num * (3f - 2f * num);
		}

		public static float Mix(float a, float b, float u)
		{
			return a + (b - a) * Saturate(u);
		}

		public static float Noise(int i, int seed)
		{
			uint num = (uint)(i * 374761393 + seed * 668265263);
			num = (num ^ (num >> 13)) * 1274126177;
			return (float)(num ^ (num >> 16)) / 4.2949673E+09f;
		}

		private static float Curve(float t, float[] a)
		{
			for (int i = 2; i < a.Length; i += 2)
			{
				if (t <= a[i])
				{
					return Mix(a[i - 1], a[i + 1], Smooth(a[i - 2], a[i], t));
				}
			}
			return a[^1];
		}

		public static Frame Sample(float time, float raySeconds = 5.2f, float raySpeed = 34f)
		{
			float num = Math.Max(0f, Math.Min(27.757235f, time));
			float num2 = 1f - Smooth(24.2f, 27.757235f, num);
			float num3 = Smooth(16.9f, 18.5f, num) * num2;
			float u = Smooth(0.25f, 1.4f, num);
			float t = num * 1.18f;
			float num4 = Curve(num, LowerRadii) * Mix(1f, 1.18f, u);
			float num5 = Curve(num, LowerHeights) * Mix(1f, 1.12f, u);
			float num6 = num5 * 1f;
			float num7 = Curve(num, UpperCentre) - Curve(num, UpperHeights) * 0.5f + num6;
			float num8 = Smooth(3.6f, 4.4f, num) * (1f - Smooth(16.4f, 18.2f, num));
			float num9 = 6f + 8.8f * num + 0.13f * num * num;
			return new Frame
			{
				Time = num,
				Height = Mix(Curve(num, Heights), num7 + 7f, num8),
				Width = Mix(8f, 3f, Smooth(3f, 19f, num)) * 1.15f,
				CoreAlpha = Math.Max(num8 * 0.78f, num3 * 0.65f) * num2,
				GroundRadius = num9,
				GroundHeight = 2f * (0.35f + 2.4f * Smooth(0f, 16f, num)),
				GroundAlpha = Smooth(0f, 0.2f, num) * (1f - Smooth(17.5f, 23f, num)),
				BlueRadius = Mix(4f, 110f, Smooth(0f, 3.1f, t)),
				BlueHeight = Mix(3f, 78f, Smooth(0f, 3.1f, t)),
				BlueAlpha = 0.24f * Smooth(0.1f, 0.45f, t) * (1f - Smooth(2.7f, 3.7f, t)),
				HeadY = Mix(88f, 132f, Smooth(16.8f, 24f, num)) + num6,
				HeadRadius = Mix(17f, 24f, Smooth(16.4f, 21f, num)),
				HeadAlpha = Smooth(16.4f, 17.8f, num) * (1f - Smooth(21.5f, 25f, num)),
				CapRadius = num9 * (1.02f + 0.22f * Smooth(15.7f, 17.9f, num)),
				CapHeight = 0.2f + 0.5f * Smooth(15.7f, 18f, num),
				CapY = 0.35f,
				CapAlpha = 0.35f * Smooth(15.7f, 16.5f, num) * (1f - Smooth(18f, 20.5f, num)),
				RayAlpha = 0.31f * Smooth(0f, 0.12f, num) * (1f - Smooth(Math.Max(0.2f, raySeconds - 1.5f), Math.Max(0.3f, raySeconds), num)),
				RayAngle = 32f + num * raySpeed,
				RayLength = Mix(100f, 235f, Smooth(0f, 2.1f, num)),
				Afterburn = num3,
				Fade = num2,
				LowerRadius = num4 * 2f,
				LowerHeight = num5 * 2f,
				LowerAlpha = Smooth(0f, 0.12f, num) * num2,
				UpperBaseY = num7,
				UpperHeight = Curve(num, UpperHeights),
				UpperRadius = Curve(num, UpperRadii),
				UpperAlpha = Smooth(3.5f, 4.35f, num) * (1f - Smooth(16.3f, 18.9f, num)),
				Flash = Smooth(0f, 0.08f, num) * (1f - Smooth(0.28f, 0.85f, num))
			};
		}

		public static Ring PressureDisk(int index, float time)
		{
			Frame frame = Sample(time);
			float num = 0.5f + 0.5f * (float)Math.Sin(time * 5.4f - (float)index * 0.85f);
			return new Ring
			{
				Radius = frame.LowerRadius * (1.04f + (float)index * 0.075f) * (0.96f + 0.09f * num),
				Height = 0.38f + (float)index * 0.08f,
				Y = 0.5f + frame.LowerHeight * (0.09f + (float)index * 0.205f),
				Alpha = (0.24f + 0.4f * num) * Smooth(1.5f + (float)index * 0.12f, 2.3f + (float)index * 0.16f, time) * (1f - Smooth(17f, 22f, time)) * frame.Fade
			};
		}

		public static Ring BlueWave(int index, float time)
		{
			float num = 0.18f + (float)index * 0.72f;
			float num2 = time - num;
			if (num2 < 0f)
			{
				return default(Ring);
			}
			float num3 = (float)Math.Floor(num2 / 7.2f);
			float num4 = num2 - num3 * 7.2f;
			float num5 = time - num4;
			Frame frame = Sample(num5);
			float num6 = Smooth(0f, 11f, num5);
			float num7 = Smooth(0f, 0.18f, num4) * (1f - Smooth(4.9f, 7.2f, num4)) * (1f - Smooth(16f, 23f, time));
			if (num5 > 17.8f)
			{
				num7 = 0f;
			}
			return new Ring
			{
				Radius = 6f + frame.LowerRadius * 0.5f + num4 * (34f + num6 * 22f),
				Height = 0.14f + 0.26f * (1f - num4 / 7.2f),
				Y = 0.5f + frame.LowerHeight * (float)(index % 3) * 0.1f,
				Alpha = num7 * (0.08f + 0.12f * num6)
			};
		}

		public static float ColumnRadius(float time, float h)
		{
			float num = Saturate(h);
			float a = (0.7f + 0.06f * (float)Math.Sin(num * 18f - time * 3f)) * (1f - Smooth(0.85f, 1f, num));
			float u = Smooth(3.6f, 4.4f, time) * (1f - Smooth(17.3f, 18.1f, time));
			float num2 = 0.82f + 0.18f * (1f - Smooth(0.1f, 0.4f, num)) + 0.55f * Smooth(0.55f, 0.91f, num);
			a = Mix(a, num2 * (1f - Smooth(0.95f, 1f, num)), u);
			return Math.Ma