Decompiled source of AtlantumEnrichment v1.0.1

AtlantumEnrichment.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("AtlantumEnrichment")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AtlantumEnrichment")]
[assembly: AssemblyTitle("AtlantumEnrichment")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 AtlantumEnrichment
{
	[BepInPlugin("com.certifried.atlantumenrichment", "AtlantumEnrichment", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class AtlantumEnrichmentPlugin : BaseUnityPlugin
	{
		public const string GUID = "com.certifried.atlantumenrichment";

		public const string NAME = "AtlantumEnrichment";

		public const string VERSION = "1.0.0";

		private static AtlantumEnrichmentPlugin instance;

		public static ManualLogSource Log;

		private Harmony harmony;

		public static ConfigEntry<float> BaseExplosionRisk;

		public static ConfigEntry<float> SafetyModuleReduction;

		public static ConfigEntry<float> RadiationDamage;

		public static ConfigEntry<float> RadiationRadius;

		public static ConfigEntry<float> RadiationDecayTime;

		public static ConfigEntry<bool> EnableExplosions;

		public static List<CentrifugeController> ActiveCentrifuges = new List<CentrifugeController>();

		public static List<EnrichmentChamberController> ActiveChambers = new List<EnrichmentChamberController>();

		public static List<WasteProcessorController> ActiveWasteProcessors = new List<WasteProcessorController>();

		public static List<RadiationZone> ActiveRadiationZones = new List<RadiationZone>();

		public static float TotalEnrichedAtlantum = 0f;

		public static int TotalExplosions = 0;

		public static float TotalWasteProduced = 0f;

		private void Awake()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"AtlantumEnrichment v1.0.0 loading...");
			InitializeConfig();
			harmony = new Harmony("com.certifried.atlantumenrichment");
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"AtlantumEnrichment loaded successfully!");
			((BaseUnityPlugin)this).Logger.LogWarning((object)"WARNING: Atlantum enrichment is dangerous! Use safety modules!");
		}

		private void InitializeConfig()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			BaseExplosionRisk = ((BaseUnityPlugin)this).Config.Bind<float>("Risk", "BaseExplosionRisk", 0.25f, new ConfigDescription("Base explosion risk per enrichment cycle (0.25 = 25%)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			SafetyModuleReduction = ((BaseUnityPlugin)this).Config.Bind<float>("Risk", "SafetyModuleReduction", 0.1f, new ConfigDescription("Risk reduction per safety module installed", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 0.25f), Array.Empty<object>()));
			RadiationDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Radiation", "RadiationDamage", 5f, new ConfigDescription("Damage per second in radiation zones", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>()));
			RadiationRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Radiation", "RadiationRadius", 15f, new ConfigDescription("Radius of radiation zones in meters", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 50f), Array.Empty<object>()));
			RadiationDecayTime = ((BaseUnityPlugin)this).Config.Bind<float>("Radiation", "RadiationDecayTime", 300f, new ConfigDescription("Time in seconds for radiation to decay", (AcceptableValueBase)(object)new AcceptableValueRange<float>(60f, 600f), Array.Empty<object>()));
			EnableExplosions = ((BaseUnityPlugin)this).Config.Bind<bool>("Risk", "EnableExplosions", true, "Enable explosions from enrichment failures (disable for safer gameplay)");
		}

		private void Update()
		{
			ActiveCentrifuges.RemoveAll((CentrifugeController c) => (Object)(object)c == (Object)null);
			ActiveChambers.RemoveAll((EnrichmentChamberController c) => (Object)(object)c == (Object)null);
			ActiveWasteProcessors.RemoveAll((WasteProcessorController w) => (Object)(object)w == (Object)null);
			ActiveRadiationZones.RemoveAll((RadiationZone z) => (Object)(object)z == (Object)null);
			foreach (RadiationZone activeRadiationZone in ActiveRadiationZones)
			{
				if ((Object)(object)activeRadiationZone != (Object)null)
				{
					activeRadiationZone.UpdateZone();
				}
			}
		}

		private void OnDestroy()
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}

		public static CentrifugeController SpawnCentrifuge(Vector3 position)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateCentrifugePrimitive();
			val.transform.position = position;
			((Object)val).name = $"Centrifuge_{ActiveCentrifuges.Count}";
			CentrifugeController centrifugeController = val.AddComponent<CentrifugeController>();
			centrifugeController.Initialize();
			ActiveCentrifuges.Add(centrifugeController);
			Log.LogInfo((object)$"Spawned Centrifuge at {position}");
			return centrifugeController;
		}

		public static EnrichmentChamberController SpawnEnrichmentChamber(Vector3 position)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateEnrichmentChamberPrimitive();
			val.transform.position = position;
			((Object)val).name = $"EnrichmentChamber_{ActiveChambers.Count}";
			EnrichmentChamberController enrichmentChamberController = val.AddComponent<EnrichmentChamberController>();
			enrichmentChamberController.Initialize();
			ActiveChambers.Add(enrichmentChamberController);
			Log.LogInfo((object)$"Spawned Enrichment Chamber at {position}");
			return enrichmentChamberController;
		}

		public static WasteProcessorController SpawnWasteProcessor(Vector3 position)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateWasteProcessorPrimitive();
			val.transform.position = position;
			((Object)val).name = $"WasteProcessor_{ActiveWasteProcessors.Count}";
			WasteProcessorController wasteProcessorController = val.AddComponent<WasteProcessorController>();
			wasteProcessorController.Initialize();
			ActiveWasteProcessors.Add(wasteProcessorController);
			Log.LogInfo((object)$"Spawned Waste Processor at {position}");
			return wasteProcessorController;
		}

		public static RadiationZone CreateRadiationZone(Vector3 center, float intensity = 1f)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0026: 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)
			GameObject val = new GameObject($"RadiationZone_{ActiveRadiationZones.Count}");
			val.transform.position = center;
			RadiationZone radiationZone = val.AddComponent<RadiationZone>();
			radiationZone.Initialize(intensity);
			ActiveRadiationZones.Add(radiationZone);
			Log.LogWarning((object)$"RADIATION LEAK at {center}! Intensity: {intensity:P0}");
			return radiationZone;
		}

		public static void TriggerExplosion(Vector3 position, float radius, float damage)
		{
			//IL_003b: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if (!EnableExplosions.Value)
			{
				Log.LogInfo((object)"Explosion prevented (disabled in config)");
				return;
			}
			TotalExplosions++;
			Log.LogError((object)$"EXPLOSION at {position}! Radius: {radius}m");
			SpawnExplosionEffect(position, radius);
			CreateRadiationZone(position);
			DamageNearbyFacilities(position, radius, damage);
		}

		private static void SpawnExplosionEffect(Vector3 position, float radius)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("AtlantumExplosion");
			val.transform.position = position;
			ParticleSystem val2 = val.AddComponent<ParticleSystem>();
			MainModule main = val2.main;
			((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(1.5f);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(20f);
			((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(2f);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.2f, 0.8f, 1f));
			EmissionModule emission = val2.emission;
			((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1]
			{
				new Burst(0f, (short)100)
			});
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
			ShapeModule shape = val2.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = radius * 0.3f;
			Light val3 = val.AddComponent<Light>();
			val3.type = (LightType)2;
			val3.range = radius * 2f;
			val3.intensity = 10f;
			val3.color = new Color(0.2f, 0.9f, 1f);
			Object.Destroy((Object)(object)val, 3f);
		}

		private static void DamageNearbyFacilities(Vector3 center, float radius, float damage)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			foreach (CentrifugeController activeCentrifuge in ActiveCentrifuges)
			{
				if (!((Object)(object)activeCentrifuge == (Object)null))
				{
					float num = Vector3.Distance(center, ((Component)activeCentrifuge).transform.position);
					if (num < radius)
					{
						float num2 = 1f - num / radius;
						activeCentrifuge.TakeDamage(damage * num2);
					}
				}
			}
			foreach (EnrichmentChamberController activeChamber in ActiveChambers)
			{
				if (!((Object)(object)activeChamber == (Object)null))
				{
					float num3 = Vector3.Distance(center, ((Component)activeChamber).transform.position);
					if (num3 < radius)
					{
						float num4 = 1f - num3 / radius;
						activeChamber.TakeDamage(damage * num4);
					}
				}
			}
		}

		private static GameObject CreateCentrifugePrimitive()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_016b: 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)
			GameObject val = new GameObject("Centrifuge");
			GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val2).name = "Base";
			val2.transform.SetParent(val.transform);
			val2.transform.localPosition = Vector3.up * 0.25f;
			val2.transform.localScale = new Vector3(2f, 0.5f, 2f);
			val2.GetComponent<Renderer>().material = GetMaterial(new Color(0.4f, 0.4f, 0.45f));
			GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val3).name = "Drum";
			val3.transform.SetParent(val.transform);
			val3.transform.localPosition = Vector3.up * 1.5f;
			val3.transform.localScale = new Vector3(1.5f, 2f, 1.5f);
			val3.GetComponent<Renderer>().material = GetMaterial(new Color(0.6f, 0.6f, 0.65f));
			GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val4).name = "GlowRing";
			val4.transform.SetParent(val.transform);
			val4.transform.localPosition = Vector3.up * 1.5f;
			val4.transform.localScale = new Vector3(1.7f, 0.1f, 1.7f);
			val4.GetComponent<Renderer>().material = GetMaterial(new Color(0.2f, 0.8f, 1f));
			return val;
		}

		private static GameObject CreateEnrichmentChamberPrimitive()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: 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_021e: 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_0260: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("EnrichmentChamber");
			GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val2).name = "Container";
			val2.transform.SetParent(val.transform);
			val2.transform.localPosition = Vector3.up * 1.5f;
			val2.transform.localScale = new Vector3(3f, 3f, 3f);
			val2.GetComponent<Renderer>().material = GetMaterial(new Color(0.3f, 0.35f, 0.4f));
			GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val3).name = "WarningStripes";
			val3.transform.SetParent(val.transform);
			val3.transform.localPosition = new Vector3(0f, 1.5f, 1.51f);
			val3.transform.localScale = new Vector3(2f, 2f, 0.02f);
			val3.GetComponent<Renderer>().material = GetMaterial(new Color(1f, 0.8f, 0f));
			GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)val4).name = "CoreWindow";
			val4.transform.SetParent(val.transform);
			val4.transform.localPosition = new Vector3(0f, 1.5f, 1.3f);
			val4.transform.localScale = new Vector3(0.8f, 0.8f, 0.3f);
			val4.GetComponent<Renderer>().material = GetMaterial(new Color(0.1f, 0.9f, 1f, 0.7f));
			for (int i = 0; i < 4; i++)
			{
				GameObject val5 = GameObject.CreatePrimitive((PrimitiveType)3);
				((Object)val5).name = $"SafetySlot_{i}";
				val5.transform.SetParent(val.transform);
				float num = (float)i * 90f * ((float)Math.PI / 180f);
				val5.transform.localPosition = new Vector3(Mathf.Cos(num) * 1.8f, 0.5f, Mathf.Sin(num) * 1.8f);
				val5.transform.localScale = new Vector3(0.4f, 1f, 0.4f);
				val5.GetComponent<Renderer>().material = GetMaterial(new Color(0.2f, 0.2f, 0.25f));
			}
			return val;
		}

		private static GameObject CreateWasteProcessorPrimitive()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: 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_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("WasteProcessor");
			GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)1);
			((Object)val2).name = "Tank";
			val2.transform.SetParent(val.transform);
			val2.transform.localPosition = Vector3.up * 1.5f;
			val2.transform.localScale = new Vector3(2f, 2f, 2f);
			val2.GetComponent<Renderer>().material = GetMaterial(new Color(0.5f, 0.5f, 0.3f));
			GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val3).name = "HazardSymbol";
			val3.transform.SetParent(val.transform);
			val3.transform.localPosition = new Vector3(0f, 1.5f, 1.01f);
			val3.transform.localRotation = Quaternion.Euler(90f, 0f, 0f);
			val3.transform.localScale = new Vector3(0.8f, 0.02f, 0.8f);
			val3.GetComponent<Renderer>().material = GetMaterial(new Color(1f, 1f, 0f));
			GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val4).name = "OutputPipe";
			val4.transform.SetParent(val.transform);
			val4.transform.localPosition = new Vector3(1.5f, 0.5f, 0f);
			val4.transform.localRotation = Quaternion.Euler(0f, 0f, 90f);
			val4.transform.localScale = new Vector3(0.3f, 1f, 0.3f);
			val4.GetComponent<Renderer>().material = GetMaterial(new Color(0.4f, 0.4f, 0.4f));
			return val;
		}

		private static Material GetMaterial(Color color)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(Shader.Find("Sprites/Default"));
			val.color = color;
			return val;
		}

		public static void LogInfo(string message)
		{
			ManualLogSource log = Log;
			if (log != null)
			{
				log.LogInfo((object)message);
			}
		}

		public static void LogWarning(string message)
		{
			ManualLogSource log = Log;
			if (log != null)
			{
				log.LogWarning((object)message);
			}
		}

		public static void LogError(string message)
		{
			ManualLogSource log = Log;
			if (log != null)
			{
				log.LogError((object)message);
			}
		}
	}
	public class CentrifugeController : MonoBehaviour
	{
		private static int nextId;

		public float MaxRawAtlantum = 100f;

		public float MaxConcentrated = 50f;

		public float MaxWaste = 50f;

		public float ProcessingRate = 2f;

		public float ConcentrationYield = 0.4f;

		public float WasteYield = 0.5f;

		public float MaxHealth = 100f;

		public float ExplosionRiskMultiplier = 0.5f;

		public int MaxSafetyModules = 2;

		private float targetSpinSpeed;

		private Transform drum;

		private Light statusLight;

		private ParticleSystem processParticles;

		public int FacilityId { get; private set; }

		public float RawAtlantumStored { get; private set; }

		public float ConcentratedAtlantumStored { get; private set; }

		public float WasteStored { get; private set; }

		public float Health { get; private set; } = 100f;


		public int SafetyModulesInstalled { get; private set; }

		public bool IsProcessing => RawAtlantumStored > 0f && ConcentratedAtlantumStored < MaxConcentrated;

		public float SpinSpeed { get; private set; }

		public void Initialize()
		{
			FacilityId = nextId++;
			SetupVisuals();
		}

		private void SetupVisuals()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_00be: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			drum = ((Component)this).transform.Find("Drum");
			GameObject val = new GameObject("StatusLight");
			val.transform.SetParent(((Component)this).transform);
			val.transform.localPosition = Vector3.up * 3.5f;
			statusLight = val.AddComponent<Light>();
			statusLight.type = (LightType)2;
			statusLight.range = 3f;
			statusLight.intensity = 1f;
			statusLight.color = Color.green;
			GameObject val2 = new GameObject("ProcessParticles");
			val2.transform.SetParent(((Component)this).transform);
			val2.transform.localPosition = Vector3.up * 1.5f;
			processParticles = val2.AddComponent<ParticleSystem>();
			MainModule main = processParticles.main;
			((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(1f);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(2f);
			((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.1f);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.2f, 0.8f, 1f, 0.5f));
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			EmissionModule emission = processParticles.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
			ShapeModule shape = processParticles.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10;
			((ShapeModule)(ref shape)).radius = 0.5f;
		}

		private void Update()
		{
			if (IsProcessing)
			{
				ProcessAtlantum();
				CheckExplosionRisk();
			}
			UpdateVisuals();
		}

		private void ProcessAtlantum()
		{
			float num = Mathf.Min(RawAtlantumStored, ProcessingRate * Time.deltaTime);
			RawAtlantumStored -= num;
			float num2 = num * ConcentrationYield;
			float num3 = num * WasteYield;
			ConcentratedAtlantumStored = Mathf.Min(MaxConcentrated, ConcentratedAtlantumStored + num2);
			WasteStored = Mathf.Min(MaxWaste, WasteStored + num3);
			AtlantumEnrichmentPlugin.TotalEnrichedAtlantum += num2;
			AtlantumEnrichmentPlugin.TotalWasteProduced += num3;
		}

		private void CheckExplosionRisk()
		{
			float num = AtlantumEnrichmentPlugin.BaseExplosionRisk.Value * ExplosionRiskMultiplier;
			float num2 = (float)SafetyModulesInstalled * AtlantumEnrichmentPlugin.SafetyModuleReduction.Value;
			float num3 = Mathf.Max(0.01f, num - num2);
			float num4 = num3 * Time.deltaTime * 0.001f;
			if (Random.value < num4)
			{
				TriggerMalfunction();
			}
		}

		private void TriggerMalfunction()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			AtlantumEnrichmentPlugin.LogWarning($"Centrifuge {FacilityId} malfunction!");
			AtlantumEnrichmentPlugin.TriggerExplosion(((Component)this).transform.position, AtlantumEnrichmentPlugin.RadiationRadius.Value * 0.5f, 50f);
			TakeDamage(30f);
		}

		public void TakeDamage(float damage)
		{
			Health -= damage;
			AtlantumEnrichmentPlugin.LogWarning($"Centrifuge {FacilityId} took {damage} damage. Health: {Health}/{MaxHealth}");
			if (Health <= 0f)
			{
				Explode();
			}
		}

		private void Explode()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			AtlantumEnrichmentPlugin.LogError($"Centrifuge {FacilityId} DESTROYED!");
			float num = (RawAtlantumStored + ConcentratedAtlantumStored) / 100f;
			AtlantumEnrichmentPlugin.TriggerExplosion(((Component)this).transform.position, AtlantumEnrichmentPlugin.RadiationRadius.Value * num, 100f * num);
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		private void UpdateVisuals()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			targetSpinSpeed = (IsProcessing ? 360f : 0f);
			SpinSpeed = Mathf.Lerp(SpinSpeed, targetSpinSpeed, Time.deltaTime * 2f);
			if ((Object)(object)drum != (Object)null)
			{
				drum.Rotate(Vector3.up, SpinSpeed * Time.deltaTime);
			}
			if ((Object)(object)statusLight != (Object)null)
			{
				if (Health < MaxHealth * 0.3f)
				{
					statusLight.color = Color.red;
				}
				else if (IsProcessing)
				{
					statusLight.color = new Color(0.2f, 0.8f, 1f);
				}
				else
				{
					statusLight.color = Color.green;
				}
			}
			if ((Object)(object)processParticles != (Object)null)
			{
				EmissionModule emission = processParticles.emission;
				((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(IsProcessing ? 30f : 0f);
			}
		}

		public void AddRawAtlantum(float amount)
		{
			RawAtlantumStored = Mathf.Min(MaxRawAtlantum, RawAtlantumStored + amount);
		}

		public float TakeConcentrated(float amount)
		{
			float num = Mathf.Min(amount, ConcentratedAtlantumStored);
			ConcentratedAtlantumStored -= num;
			return num;
		}

		public float TakeWaste(float amount)
		{
			float num = Mathf.Min(amount, WasteStored);
			WasteStored -= num;
			return num;
		}

		public bool InstallSafetyModule()
		{
			if (SafetyModulesInstalled >= MaxSafetyModules)
			{
				return false;
			}
			SafetyModulesInstalled++;
			AtlantumEnrichmentPlugin.LogInfo($"Centrifuge {FacilityId} safety module installed ({SafetyModulesInstalled}/{MaxSafetyModules})");
			return true;
		}

		public void Repair(float amount)
		{
			Health = Mathf.Min(MaxHealth, Health + amount);
		}

		private void OnDestroy()
		{
			AtlantumEnrichmentPlugin.ActiveCentrifuges.Remove(this);
		}
	}
	public class EnrichmentChamberController : MonoBehaviour
	{
		private static int nextId;

		public float MaxConcentrated = 50f;

		public float MaxEnriched = 20f;

		public float MaxWaste = 100f;

		public float ProcessingRate = 0.5f;

		public float EnrichmentYield = 0.2f;

		public float WasteYield = 0.7f;

		public float MaxHealth = 100f;

		public float ExplosionRiskMultiplier = 1.5f;

		public int MaxSafetyModules = 4;

		public float MaxContainment = 100f;

		private float containmentDecayRate = 0.1f;

		private Light coreLight;

		private ParticleSystem coreParticles;

		private List<Transform> safetyModuleVisuals = new List<Transform>();

		public int FacilityId { get; private set; }

		public float ConcentratedAtlantumStored { get; private set; }

		public float EnrichedAtlantumStored { get; private set; }

		public float WasteStored { get; private set; }

		public float Health { get; private set; } = 100f;


		public int SafetyModulesInstalled { get; private set; }

		public float ContainmentIntegrity { get; private set; } = 100f;


		public bool IsProcessing => ConcentratedAtlantumStored > 0f && EnrichedAtlantumStored < MaxEnriched;

		public bool IsCritical => ContainmentIntegrity < 30f;

		public void Initialize()
		{
			FacilityId = nextId++;
			SetupVisuals();
		}

		private void SetupVisuals()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("CoreLight");
			val.transform.SetParent(((Component)this).transform);
			val.transform.localPosition = Vector3.up * 1.5f;
			coreLight = val.AddComponent<Light>();
			coreLight.type = (LightType)2;
			coreLight.range = 8f;
			coreLight.intensity = 2f;
			coreLight.color = new Color(0.1f, 0.9f, 1f);
			GameObject val2 = new GameObject("CoreParticles");
			val2.transform.SetParent(((Component)this).transform);
			val2.transform.localPosition = Vector3.up * 1.5f;
			coreParticles = val2.AddComponent<ParticleSystem>();
			MainModule main = coreParticles.main;
			((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(2f);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0.5f);
			((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.2f);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.2f, 1f, 0.8f, 0.6f));
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			EmissionModule emission = coreParticles.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
			ShapeModule shape = coreParticles.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = 0.3f;
			for (int i = 0; i < 4; i++)
			{
				Transform val3 = ((Component)this).transform.Find($"SafetySlot_{i}");
				if ((Object)(object)val3 != (Object)null)
				{
					safetyModuleVisuals.Add(val3);
				}
			}
		}

		private void Update()
		{
			if (IsProcessing)
			{
				ProcessAtlantum();
				DegradeContainment();
				CheckExplosionRisk();
			}
			UpdateVisuals();
		}

		private void ProcessAtlantum()
		{
			float num = Mathf.Min(ConcentratedAtlantumStored, ProcessingRate * Time.deltaTime);
			ConcentratedAtlantumStored -= num;
			float num2 = num * EnrichmentYield;
			float num3 = num * WasteYield;
			EnrichedAtlantumStored = Mathf.Min(MaxEnriched, EnrichedAtlantumStored + num2);
			WasteStored = Mathf.Min(MaxWaste, WasteStored + num3);
			AtlantumEnrichmentPlugin.TotalEnrichedAtlantum += num2;
			AtlantumEnrichmentPlugin.TotalWasteProduced += num3;
		}

		private void DegradeContainment()
		{
			float num = containmentDecayRate;
			num *= 1f - (float)SafetyModulesInstalled * 0.2f;
			ContainmentIntegrity -= num * Time.deltaTime;
			if (ContainmentIntegrity <= 0f)
			{
				ContainmentBreach();
			}
		}

		private void CheckExplosionRisk()
		{
			float num = AtlantumEnrichmentPlugin.BaseExplosionRisk.Value * ExplosionRiskMultiplier;
			float num2 = (float)SafetyModulesInstalled * AtlantumEnrichmentPlugin.SafetyModuleReduction.Value;
			float num3 = 1f + (1f - ContainmentIntegrity / MaxContainment) * 2f;
			float num4 = Mathf.Max(0.01f, (num - num2) * num3);
			float num5 = num4 * Time.deltaTime * 0.001f;
			if (Random.value < num5)
			{
				TriggerMalfunction();
			}
		}

		private void ContainmentBreach()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			AtlantumEnrichmentPlugin.LogError($"CONTAINMENT BREACH at Enrichment Chamber {FacilityId}!");
			AtlantumEnrichmentPlugin.CreateRadiationZone(((Component)this).transform.position, 1.5f);
			TakeDamage(50f);
			ContainmentIntegrity = 20f;
		}

		private void TriggerMalfunction()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			AtlantumEnrichmentPlugin.LogError($"Enrichment Chamber {FacilityId} CRITICAL MALFUNCTION!");
			AtlantumEnrichmentPlugin.TriggerExplosion(((Component)this).transform.position, AtlantumEnrichmentPlugin.RadiationRadius.Value, 100f);
			TakeDamage(50f);
			ContainmentIntegrity -= 30f;
		}

		public void TakeDamage(float damage)
		{
			Health -= damage;
			AtlantumEnrichmentPlugin.LogWarning($"Enrichment Chamber {FacilityId} took {damage} damage. Health: {Health}/{MaxHealth}");
			if (Health <= 0f)
			{
				Meltdown();
			}
		}

		private void Meltdown()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			AtlantumEnrichmentPlugin.LogError($"MELTDOWN at Enrichment Chamber {FacilityId}!");
			float num = 2f + EnrichedAtlantumStored / MaxEnriched;
			AtlantumEnrichmentPlugin.TriggerExplosion(((Component)this).transform.position, AtlantumEnrichmentPlugin.RadiationRadius.Value * num, 200f);
			AtlantumEnrichmentPlugin.CreateRadiationZone(((Component)this).transform.position, 2f);
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		private void UpdateVisuals()
		{
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)coreLight != (Object)null)
			{
				float num = (IsProcessing ? 4f : 1f);
				float num2 = 1f + (1f - ContainmentIntegrity / MaxContainment);
				coreLight.intensity = num * num2;
				if (IsCritical)
				{
					coreLight.color = Color.Lerp(new Color(0.1f, 0.9f, 1f), Color.red, 1f - ContainmentIntegrity / 30f);
				}
				else
				{
					coreLight.color = new Color(0.1f, 0.9f, 1f);
				}
			}
			if ((Object)(object)coreParticles != (Object)null)
			{
				EmissionModule emission = coreParticles.emission;
				((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(IsProcessing ? 50f : 10f);
			}
			for (int i = 0; i < safetyModuleVisuals.Count; i++)
			{
				Renderer component = ((Component)safetyModuleVisuals[i]).GetComponent<Renderer>();
				if ((Object)(object)component != (Object)null)
				{
					component.material.color = ((i < SafetyModulesInstalled) ? new Color(0.2f, 1f, 0.3f) : new Color(0.2f, 0.2f, 0.25f));
				}
			}
		}

		public void AddConcentratedAtlantum(float amount)
		{
			ConcentratedAtlantumStored = Mathf.Min(MaxConcentrated, ConcentratedAtlantumStored + amount);
		}

		public float TakeEnriched(float amount)
		{
			float num = Mathf.Min(amount, EnrichedAtlantumStored);
			EnrichedAtlantumStored -= num;
			return num;
		}

		public float TakeWaste(float amount)
		{
			float num = Mathf.Min(amount, WasteStored);
			WasteStored -= num;
			return num;
		}

		public bool InstallSafetyModule()
		{
			if (SafetyModulesInstalled >= MaxSafetyModules)
			{
				return false;
			}
			SafetyModulesInstalled++;
			AtlantumEnrichmentPlugin.LogInfo($"Enrichment Chamber {FacilityId} safety module installed ({SafetyModulesInstalled}/{MaxSafetyModules})");
			return true;
		}

		public void RepairContainment(float amount)
		{
			ContainmentIntegrity = Mathf.Min(MaxContainment, ContainmentIntegrity + amount);
		}

		public void Repair(float amount)
		{
			Health = Mathf.Min(MaxHealth, Health + amount);
		}

		private void OnDestroy()
		{
			AtlantumEnrichmentPlugin.ActiveChambers.Remove(this);
		}
	}
	public class WasteProcessorController : MonoBehaviour
	{
		private static int nextId;

		public float MaxWaste = 200f;

		public float MaxDepleted = 100f;

		public float MaxRecovered = 10f;

		public float ProcessingRate = 1f;

		public float DepletionYield = 0.8f;

		public float RecoveryYield = 0.05f;

		public float MaxHealth = 100f;

		private ParticleSystem steamParticles;

		private Light processLight;

		public int FacilityId { get; private set; }

		public float WasteStored { get; private set; }

		public float DepletedAtlantumStored { get; private set; }

		public float RecoveredMaterialStored { get; private set; }

		public float Health { get; private set; } = 100f;


		public bool IsProcessing => WasteStored > 0f && DepletedAtlantumStored < MaxDepleted;

		public void Initialize()
		{
			FacilityId = nextId++;
			SetupVisuals();
		}

		private void SetupVisuals()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Steam");
			val.transform.SetParent(((Component)this).transform);
			val.transform.localPosition = Vector3.up * 3f;
			steamParticles = val.AddComponent<ParticleSystem>();
			MainModule main = steamParticles.main;
			((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(3f);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(1.5f);
			((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.4f);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.7f, 0.7f, 0.5f, 0.4f));
			EmissionModule emission = steamParticles.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
			ShapeModule shape = steamParticles.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
			((ShapeModule)(ref shape)).angle = 15f;
			GameObject val2 = new GameObject("ProcessLight");
			val2.transform.SetParent(((Component)this).transform);
			val2.transform.localPosition = Vector3.up * 1.5f;
			processLight = val2.AddComponent<Light>();
			processLight.type = (LightType)2;
			processLight.range = 4f;
			processLight.intensity = 1f;
			processLight.color = new Color(1f, 1f, 0.5f);
		}

		private void Update()
		{
			if (IsProcessing)
			{
				ProcessWaste();
			}
			UpdateVisuals();
		}

		private void ProcessWaste()
		{
			float num = Mathf.Min(WasteStored, ProcessingRate * Time.deltaTime);
			WasteStored -= num;
			float num2 = num * DepletionYield;
			float num3 = num * RecoveryYield;
			DepletedAtlantumStored = Mathf.Min(MaxDepleted, DepletedAtlantumStored + num2);
			RecoveredMaterialStored = Mathf.Min(MaxRecovered, RecoveredMaterialStored + num3);
		}

		private void UpdateVisuals()
		{
			//IL_0018: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)steamParticles != (Object)null)
			{
				EmissionModule emission = steamParticles.emission;
				((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(IsProcessing ? 15f : 0f);
			}
			if ((Object)(object)processLight != (Object)null)
			{
				processLight.intensity = (IsProcessing ? 2f : 0.5f);
			}
		}

		public void AddWaste(float amount)
		{
			WasteStored = Mathf.Min(MaxWaste, WasteStored + amount);
		}

		public float TakeDepleted(float amount)
		{
			float num = Mathf.Min(amount, DepletedAtlantumStored);
			DepletedAtlantumStored -= num;
			return num;
		}

		public float TakeRecovered(float amount)
		{
			float num = Mathf.Min(amount, RecoveredMaterialStored);
			RecoveredMaterialStored -= num;
			return num;
		}

		public void TakeDamage(float damage)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			Health -= damage;
			if (Health <= 0f)
			{
				AtlantumEnrichmentPlugin.CreateRadiationZone(((Component)this).transform.position, 0.5f);
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		public void Repair(float amount)
		{
			Health = Mathf.Min(MaxHealth, Health + amount);
		}

		private void OnDestroy()
		{
			AtlantumEnrichmentPlugin.ActiveWasteProcessors.Remove(this);
		}
	}
	public class RadiationZone : MonoBehaviour
	{
		private static int nextId;

		private float damageTickRate = 1f;

		private float lastDamageTick;

		private ParticleSystem radiationParticles;

		private Light radiationLight;

		private SphereCollider zoneCollider;

		public int ZoneId { get; private set; }

		public float Intensity { get; private set; } = 1f;


		public float Radius { get; private set; }

		public float TimeRemaining { get; private set; }

		public void Initialize(float intensity)
		{
			ZoneId = nextId++;
			Intensity = intensity;
			Radius = AtlantumEnrichmentPlugin.RadiationRadius.Value * intensity;
			TimeRemaining = AtlantumEnrichmentPlugin.RadiationDecayTime.Value * intensity;
			SetupVisuals();
			SetupCollider();
		}

		private void SetupVisuals()
		{
			//IL_0018: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			radiationParticles = ((Component)this).gameObject.AddComponent<ParticleSystem>();
			MainModule main = radiationParticles.main;
			((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(3f);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0.5f);
			((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.3f);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.2f, 1f, 0.3f, 0.3f));
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).maxParticles = 500;
			EmissionModule emission = radiationParticles.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(50f * Intensity);
			ShapeModule shape = radiationParticles.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = Radius;
			GameObject val = new GameObject("RadiationGlow");
			val.transform.SetParent(((Component)this).transform);
			val.transform.localPosition = Vector3.up * 0.5f;
			radiationLight = val.AddComponent<Light>();
			radiationLight.type = (LightType)2;
			radiationLight.range = Radius * 1.5f;
			radiationLight.intensity = 2f * Intensity;
			radiationLight.color = new Color(0.3f, 1f, 0.4f);
		}

		private void SetupCollider()
		{
			zoneCollider = ((Component)this).gameObject.AddComponent<SphereCollider>();
			zoneCollider.radius = Radius;
			((Collider)zoneCollider).isTrigger = true;
		}

		public void UpdateZone()
		{
			TimeRemaining -= Time.deltaTime;
			if (TimeRemaining <= 0f)
			{
				AtlantumEnrichmentPlugin.LogInfo($"Radiation zone {ZoneId} has decayed");
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			float num = TimeRemaining / (AtlantumEnrichmentPlugin.RadiationDecayTime.Value * Intensity);
			UpdateIntensity(Intensity * num);
			if (Time.time - lastDamageTick >= damageTickRate)
			{
				ApplyRadiationDamage();
				lastDamageTick = Time.time;
			}
		}

		private void UpdateIntensity(float newIntensity)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			float num = newIntensity / Intensity;
			if ((Object)(object)radiationParticles != (Object)null)
			{
				EmissionModule emission = radiationParticles.emission;
				((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(50f * num);
			}
			if ((Object)(object)radiationLight != (Object)null)
			{
				radiationLight.intensity = 2f * num;
			}
		}

		private void ApplyRadiationDamage()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			float num = AtlantumEnrichmentPlugin.RadiationDamage.Value * Intensity;
			foreach (CentrifugeController activeCentrifuge in AtlantumEnrichmentPlugin.ActiveCentrifuges)
			{
				if (!((Object)(object)activeCentrifuge == (Object)null) && Vector3.Distance(((Component)this).transform.position, ((Component)activeCentrifuge).transform.position) < Radius)
				{
					activeCentrifuge.TakeDamage(num * 0.5f);
				}
			}
			foreach (EnrichmentChamberController activeChamber in AtlantumEnrichmentPlugin.ActiveChambers)
			{
				if (!((Object)(object)activeChamber == (Object)null) && Vector3.Distance(((Component)this).transform.position, ((Component)activeChamber).transform.position) < Radius)
				{
					activeChamber.TakeDamage(num * 0.5f);
					activeChamber.RepairContainment((0f - num) * 0.2f);
				}
			}
			foreach (WasteProcessorController activeWasteProcessor in AtlantumEnrichmentPlugin.ActiveWasteProcessors)
			{
				if (!((Object)(object)activeWasteProcessor == (Object)null) && Vector3.Distance(((Component)this).transform.position, ((Component)activeWasteProcessor).transform.position) < Radius)
				{
					activeWasteProcessor.TakeDamage(num * 0.3f);
				}
			}
		}

		public void Remediate(float amount)
		{
			TimeRemaining -= amount;
			AtlantumEnrichmentPlugin.LogInfo($"Radiation zone {ZoneId} remediated. Time remaining: {TimeRemaining:F1}s");
		}

		public void Cleanse()
		{
			AtlantumEnrichmentPlugin.LogInfo($"Radiation zone {ZoneId} cleansed!");
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		private void OnDestroy()
		{
			AtlantumEnrichmentPlugin.ActiveRadiationZones.Remove(this);
		}
	}
}