Decompiled source of UESOrbitalBombardment v0.1.1

plugins/UESOrbitalBombardment/UESOrbitalBombardment.dll

Decompiled 12 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using BepInEx;
using HG.Reflection;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.Projectile;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.Rendering;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace UESOrbitalBombardment
{
	[HarmonyPatch]
	internal static class Bombardment
	{
		internal static GameObject Projectile;

		internal static void Register()
		{
			//IL_0047: 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)
			Projectile = PrefabAPI.InstantiateClone(Plugin.Load<GameObject>((object)"RoR2/Base/Captain/CaptainAirstrikeProjectile1.prefab"), "UESOrbitalStrikeProjectile", true);
			ProjectileImpactExplosion component = Projectile.GetComponent<ProjectileImpactExplosion>();
			((ProjectileExplosion)component).blastRadius = 7f;
			((ProjectileExplosion)component).blastDamageCoefficient = 1f;
			((ProjectileExplosion)component).blastProcCoefficient = 1f;
			((ProjectileExplosion)component).falloffModel = (FalloffModel)0;
			((ProjectileExplosion)component).blastAttackerFiltering = (AttackerFiltering)2;
			Projectile.GetComponent<ProjectileController>().procCoefficient = 1f;
			if (!ContentAddition.AddProjectile(Projectile))
			{
				throw new InvalidOperationException("Orbital projectile registration failed.");
			}
		}

		[HarmonyPatch(typeof(EquipmentSlot), "PerformEquipmentAction")]
		[HarmonyPrefix]
		private static bool Fire(EquipmentSlot __instance, EquipmentDef __0, ref bool __result)
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__0 != (Object)(object)Plugin.Equipment)
			{
				return true;
			}
			__result = false;
			CharacterBody characterBody = __instance.characterBody;
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)characterBody) || !Object.op_Implicit((Object)(object)characterBody.healthComponent) || !characterBody.healthComponent.alive || !characterBody.isEquipmentActivationAllowed || !Object.op_Implicit((Object)(object)characterBody.inventory) || characterBody.inventory.GetEquipmentDisabled())
			{
				return false;
			}
			Targeting.Context context = Targeting.For(__instance);
			Vector3 point;
			if (Util.HasEffectiveAuthority(((Component)characterBody).gameObject) && context.Gate.Fire && context.Valid)
			{
				point = context.Point;
			}
			else if (!Targeting.FindPoint(characterBody, out point))
			{
				return false;
			}
			new GameObject("UES Orbital Bombardment Salvo").AddComponent<Salvo>().Initialize(characterBody, point);
			__result = true;
			return false;
		}

		[HarmonyPatch(typeof(BlastAttack), "Fire")]
		[HarmonyPrefix]
		private static void FilterAllies(BlastAttack __instance)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Invalid comparison between Unknown and I4
			//IL_0066: 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_007d: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)__instance.inflictor))
			{
				return;
			}
			ProjectileController component = __instance.inflictor.GetComponent<ProjectileController>();
			if (Object.op_Implicit((Object)(object)component) && !((Object)(object)ProjectileCatalog.GetProjectilePrefab(component.catalogIndex) != (Object)(object)Projectile))
			{
				TeamIndex team = __instance.teamIndex;
				CustomFilter prior = (((int)__instance.attackerFiltering == 6) ? __instance.filterCallback : null);
				__instance.attackerFiltering = (AttackerFiltering)6;
				__instance.filterCallback = (CustomFilter)((BlastAttackFilterStruct hit) => Object.op_Implicit((Object)(object)hit.healthComponent) && Object.op_Implicit((Object)(object)hit.healthComponent.body) && Object.op_Implicit((Object)(object)hit.healthComponent.body.teamComponent) && (int)hit.healthComponent.body.teamComponent.teamIndex != -1 && (int)hit.healthComponent.body.teamComponent.teamIndex != 0 && hit.healthComponent.body.teamComponent.teamIndex != team && (prior == null || prior.Invoke(hit)));
			}
		}
	}
	internal sealed class Salvo : MonoBehaviour
	{
		private CharacterBody owner;

		private Vector3 center;

		private SceneIndex scene;

		private float age;

		private float damage;

		private double rotation;

		private int next;

		internal void Initialize(CharacterBody body, Vector3 point)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			owner = body;
			center = point;
			damage = body.damage * 12f;
			rotation = Random.Range(0f, (float)Math.PI * 2f);
			scene = (SceneIndex)((!Object.op_Implicit((Object)(object)SceneCatalog.mostRecentSceneDef)) ? (-1) : ((int)SceneCatalog.mostRecentSceneDef.sceneDefIndex));
			Util.PlaySound("Play_captain_shift_call", ((Component)body).gameObject);
		}

		private void FixedUpdate()
		{
			//IL_0055: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00b7: 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_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_00d1: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance) || !Object.op_Implicit((Object)(object)owner) || !Object.op_Implicit((Object)(object)owner.healthComponent) || !owner.healthComponent.alive || !Object.op_Implicit((Object)(object)SceneCatalog.mostRecentSceneDef) || SceneCatalog.mostRecentSceneDef.sceneDefIndex != scene)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			RaycastHit val2 = default(RaycastHit);
			while (next < 12 && age >= Rules.LaunchTime(next))
			{
				Rules.Offset(next++, rotation, out var x, out var z);
				Vector3 val = center + new Vector3(x, 0f, z) + Vector3.up * 6f;
				Vector3 down = Vector3.down;
				LayerIndex world = LayerIndex.world;
				if (Physics.Raycast(val, down, ref val2, 18f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1) && !(((RaycastHit)(ref val2)).normal.y < 0.35f))
				{
					ProjectileManager instance = ProjectileManager.instance;
					FireProjectileInfo val3 = new FireProjectileInfo
					{
						projectilePrefab = Bombardment.Projectile,
						position = ((RaycastHit)(ref val2)).point + Vector3.up * 0.1f,
						rotation = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f),
						owner = ((Component)owner).gameObject,
						damage = damage,
						force = 1500f,
						crit = Util.CheckRoll(owner.crit, owner.master)
					};
					((FireProjectileInfo)(ref val3)).speedOverride = 0f;
					val3.damageColorIndex = (DamageColorIndex)3;
					val3.damageTypeOverride = DamageTypeCombo.op_Implicit((DamageType)32);
					instance.FireProjectile(val3);
				}
			}
			age += Time.fixedDeltaTime;
			if (next >= 12)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	internal static class Lore
	{
		internal const string Text = "UES ORBITAL FIRE SUPPORT\nRECOVERED FIELD TRANSMISSION // SQUAD 04\n\nThe cargo hauler had stopped burning. That was the only good news.\n\nThree Commandos lay behind its split hull. One watched the ridge. One pressed a dressing against his leg. The third kept turning a dial on a radio that had answered nothing but static for the last eleven minutes.\n\nSomething heavy struck the other side of the hull. Then another. The metal bent inward.\n\n\"UES, this is Squad Four. We are pinned down. Requesting orbital support.\"\n\nStatic.\n\n\"We cannot withdraw. Sending our position.\"\n\nA voice broke through, calm enough to sound out of place.\n\n\"Squad Four, your marker is on your own position. Confirm.\"\n\nThe Commando looked at the torn hull. At the dressing. At the last few rounds on his ammunition counter.\n\n\"Confirmed. Put it around us.\"\n\n\"Copy. Heads down.\"\n\nThe sky opened in thin white lines.\n\nThe first strike took the ridge. The next two landed beyond the hauler. Then the whole valley shook, one impact after another, until the pounding on the hull disappeared beneath the thunder.\n\nWhen it stopped, the radio was still hissing.\n\n\"Squad Four. Report.\"\n\nThe wounded Commando started laughing. The one watching the ridge finally lowered his rifle.\n\n\"Still here, UES.\"\n\n\"We see you.\"";
	}
	[BepInPlugin("wreckzog.uesorbitalbombardment", "UES Orbital Bombardment", "0.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string Guid = "wreckzog.uesorbitalbombardment";

		public const string Version = "0.1.1";

		internal static Plugin Instance;

		internal static EquipmentDef Equipment;

		internal static EquipmentDef Launcher;

		internal static EquipmentDef Radio;

		internal static CraftableDef Recipe;

		private Harmony harmony;

		private void Awake()
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Expected O, but got Unknown
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Expected O, but got Unknown
			Instance = this;
			Launcher = Plugin.Load<EquipmentDef>((object)"RoR2/Base/CommandMissile/CommandMissile.asset");
			Radio = Plugin.Load<EquipmentDef>((object)"RoR2/Base/DroneBackup/DroneBackup.asset");
			Equipment = ScriptableObject.CreateInstance<EquipmentDef>();
			((Object)Equipment).name = "UESOrbitalBombardment";
			Equipment.nameToken = "UES_ORBITAL_BOMBARDMENT_NAME";
			Equipment.pickupToken = "UES_ORBITAL_BOMBARDMENT_PICKUP";
			Equipment.descriptionToken = "UES_ORBITAL_BOMBARDMENT_DESCRIPTION";
			Equipment.loreToken = "UES_ORBITAL_BOMBARDMENT_LORE";
			Equipment.cooldown = 120f;
			Equipment.canDrop = true;
			Equipment.enigmaCompatible = true;
			Equipment.canBeRandomlyTriggered = false;
			Equipment.colorIndex = (ColorIndex)5;
			Equipment.pickupModelPrefab = Visuals.Pickup(Plugin.Load<GameObject>(((AssetReference)Radio.pickupModelReference).RuntimeKey));
			Equipment.pickupIconSprite = Visuals.Icon(Plugin.Load<Sprite>(((AssetReference)Radio.pickupIconSpriteReference).RuntimeKey));
			if (!ContentAddition.AddEquipmentDef(Equipment))
			{
				throw new InvalidOperationException("Equipment registration failed.");
			}
			LanguageAPI.Add(Equipment.nameToken, "UES Orbital Bombardment");
			LanguageAPI.Add(Equipment.pickupToken, "Hold equipment to aim an orbital bombardment. Release to authorize the strikes.");
			LanguageAPI.Add(Equipment.descriptionToken, "<style=cIsUtility>Hold</style> the equipment button to aim a <style=cIsDamage>24m</style> bombardment zone. <style=cIsUtility>Release</style> to call <style=cIsDamage>12 orbital strikes</style> over <style=cIsUtility>6 seconds</style>, each dealing <style=cIsDamage>1200% damage</style> in a <style=cIsDamage>7m</style> radius and <style=cIsUtility>stunning</style> enemies. Aim away from terrain to cancel. <style=cIsUtility>Craft at CHEF: Disposable Missile Launcher + Fuel Cell.</style>");
			LanguageAPI.Add(Equipment.loreToken, "UES ORBITAL FIRE SUPPORT\nRECOVERED FIELD TRANSMISSION // SQUAD 04\n\nThe cargo hauler had stopped burning. That was the only good news.\n\nThree Commandos lay behind its split hull. One watched the ridge. One pressed a dressing against his leg. The third kept turning a dial on a radio that had answered nothing but static for the last eleven minutes.\n\nSomething heavy struck the other side of the hull. Then another. The metal bent inward.\n\n\"UES, this is Squad Four. We are pinned down. Requesting orbital support.\"\n\nStatic.\n\n\"We cannot withdraw. Sending our position.\"\n\nA voice broke through, calm enough to sound out of place.\n\n\"Squad Four, your marker is on your own position. Confirm.\"\n\nThe Commando looked at the torn hull. At the dressing. At the last few rounds on his ammunition counter.\n\n\"Confirmed. Put it around us.\"\n\n\"Copy. Heads down.\"\n\nThe sky opened in thin white lines.\n\nThe first strike took the ridge. The next two landed beyond the hauler. Then the whole valley shook, one impact after another, until the pounding on the hull disappeared beneath the thunder.\n\nWhen it stopped, the radio was still hissing.\n\n\"Squad Four. Report.\"\n\nThe wounded Commando started laughing. The one watching the ridge finally lowered his rifle.\n\n\"Still here, UES.\"\n\n\"We see you.\"");
			Recipe = ScriptableObject.CreateInstance<CraftableDef>();
			((Object)Recipe).name = "CraftableUESOrbitalBombardment";
			Recipe.pickup = (Object)(object)Equipment;
			CraftableDef recipe = Recipe;
			Recipe[] array = new Recipe[1];
			Recipe val = new Recipe();
			val.amountToDrop = 1;
			val.ingredients = (RecipeIngredient[])(object)new RecipeIngredient[2]
			{
				Ingredient((Object)(object)Launcher),
				Ingredient((Object)(object)Plugin.Load<ItemDef>((object)"RoR2/Base/EquipmentMagazine/EquipmentMagazine.asset"))
			};
			array[0] = val;
			recipe.recipes = (Recipe[])(object)array;
			if (!ContentAddition.AddCraftableDef(Recipe))
			{
				throw new InvalidOperationException("CHEF recipe registration failed.");
			}
			Bombardment.Register();
			harmony = new Harmony("wreckzog.uesorbitalbombardment");
			harmony.PatchAll(typeof(Plugin).Assembly);
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(Loaded));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"UES Orbital Bombardment loaded: hold equipment to aim, release to fire; CHEF recipe: Missile Launcher + Fuel Cell.");
		}

		private void Loaded()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			PickupIndex result = PickupCatalog.FindPickupIndex(Equipment.equipmentIndex);
			if ((int)Equipment.equipmentIndex == -1 || (Object)(object)ProjectileCatalog.GetProjectilePrefab(ProjectileCatalog.GetProjectileIndex(Bombardment.Projectile)) != (Object)(object)Bombardment.Projectile || !Array.Exists(CraftableCatalog.GetAllRecipes(), (RecipeEntry recipe) => recipe.result == result))
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Equipment or CHEF recipe catalog registration failed.");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("CATALOG PASS: equipment, CHEF equipment recipe, orbital projectile, and " + Visuals.AddDisplays() + " radio display rule sets registered."));
			}
		}

		private static RecipeIngredient Ingredient(Object pickup)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			return new RecipeIngredient
			{
				type = (IngredientTypeIndex)0,
				pickup = pickup,
				requiredTags = Array.Empty<ItemTag>(),
				forbiddenTags = Array.Empty<ItemTag>()
			};
		}

		internal static T Load<T>(object key) where T : Object
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			T val = Addressables.LoadAssetAsync<T>(key).WaitForCompletion();
			if (!Object.op_Implicit((Object)(object)val))
			{
				throw new InvalidOperationException("Missing native asset: " + key);
			}
			return val;
		}

		internal static void Warn(string message)
		{
			((BaseUnityPlugin)Instance).Logger.LogWarning((object)message);
		}

		private void OnDestroy()
		{
			RoR2Application.onLoad = (Action)Delegate.Remove(RoR2Application.onLoad, new Action(Loaded));
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}
	}
	[HarmonyPatch(typeof(BasicPickupDropTable), "GenerateWeightedSelection")]
	internal static class RareDrops
	{
		[HarmonyPostfix]
		private static void Reweight(WeightedSelection<UniquePickup> ___selector)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Plugin.Equipment) || (int)Plugin.Equipment.equipmentIndex == -1)
			{
				return;
			}
			PickupIndex val = PickupCatalog.FindPickupIndex(Plugin.Equipment.equipmentIndex);
			for (int i = 0; i < ___selector.Count; i++)
			{
				ChoiceInfo<UniquePickup> choice = ___selector.GetChoice(i);
				if (choice.value.pickupIndex == val)
				{
					___selector.ModifyChoiceWeight(i, choice.weight * 0.1f);
				}
			}
		}
	}
	internal sealed class AimGate
	{
		internal bool Aiming { get; private set; }

		internal bool Fire { get; private set; }

		internal void Step(bool ready, bool pressed, bool held, bool valid, bool cancel)
		{
			Fire = false;
			if (!ready || cancel)
			{
				Aiming = false;
				return;
			}
			if (pressed && held)
			{
				Aiming = true;
			}
			if (Aiming && !held)
			{
				Fire = valid;
				Aiming = false;
			}
		}
	}
	internal static class Rules
	{
		internal const int StrikeCount = 12;

		internal const float Radius = 24f;

		internal const float StrikeRadius = 7f;

		internal const float Duration = 5.5f;

		internal const float Cooldown = 120f;

		internal const float DamageCoefficient = 12f;

		internal const float MaxRange = 200f;

		internal const float DropWeight = 0.1f;

		internal static void Offset(int index, double rotation, out float x, out float z)
		{
			double num;
			switch (index)
			{
			default:
				throw new ArgumentOutOfRangeException("index");
			case 3:
			case 4:
			case 5:
			case 6:
			case 7:
			case 8:
			case 9:
			case 10:
			case 11:
				num = 17.0 * Math.Sqrt(((double)index - 2.5) / 9.0);
				break;
			case 1:
			case 2:
				num = 4.0;
				break;
			case 0:
				num = 0.0;
				break;
			}
			double num2 = num;
			double num3 = rotation + (double)index * 2.399963229728653;
			x = (float)(Math.Cos(num3) * num2);
			z = (float)(Math.Sin(num3) * num2);
		}

		internal static float LaunchTime(int index)
		{
			return 5.5f * (float)index / 11f;
		}
	}
	[HarmonyPatch]
	internal static class Targeting
	{
		internal sealed class Context
		{
			internal readonly AimGate Gate = new AimGate();

			internal RadiusIndicator Indicator;

			internal Vector3 Point;

			internal bool Valid;
		}

		private static readonly ConditionalWeakTable<EquipmentSlot, Context> Contexts = new ConditionalWeakTable<EquipmentSlot, Context>();

		internal static Context For(EquipmentSlot slot)
		{
			return Contexts.GetValue(slot, (EquipmentSlot _) => new Context());
		}

		internal static bool IsOurs(EquipmentSlot slot)
		{
			//IL_003e: 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)
			if (Object.op_Implicit((Object)(object)slot) && Object.op_Implicit((Object)(object)Plugin.Equipment) && Object.op_Implicit((Object)(object)slot.characterBody) && Object.op_Implicit((Object)(object)slot.characterBody.inventory))
			{
				return slot.characterBody.inventory.GetEquipmentIndex() == Plugin.Equipment.equipmentIndex;
			}
			return false;
		}

		[HarmonyPatch(typeof(EquipmentSlot), "MyFixedUpdate")]
		[HarmonyPrefix]
		private static void BeforeTick(EquipmentSlot __instance)
		{
			//IL_0071: 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)
			Context context = For(__instance);
			CharacterBody characterBody = __instance.characterBody;
			bool num = IsOurs(__instance);
			bool flag = Object.op_Implicit((Object)(object)characterBody) && Util.HasEffectiveAuthority(((Component)characterBody).gameObject);
			bool flag2 = num && flag && Object.op_Implicit((Object)(object)characterBody.inputBank) && Object.op_Implicit((Object)(object)characterBody.healthComponent) && characterBody.healthComponent.alive && characterBody.isEquipmentActivationAllowed && !characterBody.inventory.GetEquipmentDisabled() && characterBody.inventory.GetActiveEquipment().charges > 0;
			bool cancel = flag2 && characterBody.inputBank.interact.down && characterBody.inventory.accessibleEquipmentSetCount > 1;
			context.Valid = flag2 && FindPoint(characterBody, out context.Point);
			context.Gate.Step(flag2, flag2 && ((ButtonState)(ref characterBody.inputBank.activateEquipment)).justPressed, flag2 && characterBody.inputBank.activateEquipment.down, context.Valid, cancel);
			if (context.Gate.Aiming && context.Valid)
			{
				if (!Object.op_Implicit((Object)(object)context.Indicator))
				{
					context.Indicator = RadiusIndicator.Create(((Component)characterBody).transform);
				}
				context.Indicator.Set(context.Point);
			}
			else if (Object.op_Implicit((Object)(object)context.Indicator))
			{
				Object.Destroy((Object)(object)((Component)context.Indicator).gameObject);
				context.Indicator = null;
			}
		}

		[HarmonyPatch(typeof(EquipmentSlot), "MyFixedUpdate")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> ReleaseInsteadOfPress(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(ButtonState), "justPressed");
			MethodInfo operand = AccessTools.Method(typeof(Targeting), "ActivationPressed", (Type[])null, (Type[])null);
			List<int> list2 = new List<int>();
			for (int i = 0; i < list.Count; i++)
			{
				if (CodeInstructionExtensions.Calls(list[i], methodInfo))
				{
					list2.Add(i);
				}
			}
			if (list2.Count != 3)
			{
				throw new InvalidOperationException("Equipment input changed: expected three justPressed checks; refusing an unsafe patch.");
			}
			for (int num = 2; num >= 0; num -= 2)
			{
				int num2 = list2[num];
				CodeInstruction val = new CodeInstruction(OpCodes.Ldarg_0, (object)null);
				val.labels.AddRange(list[num2].labels);
				list[num2].labels.Clear();
				val.blocks.AddRange(list[num2].blocks);
				list[num2].blocks.Clear();
				list.Insert(num2, val);
				list[num2 + 1].opcode = OpCodes.Call;
				list[num2 + 1].operand = operand;
			}
			return list;
		}

		private static bool ActivationPressed(ref ButtonState button, EquipmentSlot slot)
		{
			if (!IsOurs(slot))
			{
				return ((ButtonState)(ref button)).justPressed;
			}
			CharacterBody characterBody = slot.characterBody;
			if (characterBody.inputBank.interact.down && characterBody.inventory.accessibleEquipmentSetCount > 1)
			{
				return ((ButtonState)(ref button)).justPressed;
			}
			return For(slot).Gate.Fire;
		}

		internal static bool FindPoint(CharacterBody body, out Vector3 point)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			point = default(Vector3);
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.inputBank))
			{
				return false;
			}
			Ray aimRay = body.inputBank.GetAimRay();
			LayerIndex world = LayerIndex.world;
			RaycastHit val = default(RaycastHit);
			if (!Physics.Raycast(aimRay, ref val, 200f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1) || ((RaycastHit)(ref val)).normal.y < 0.35f)
			{
				return false;
			}
			point = ((RaycastHit)(ref val)).point;
			return true;
		}
	}
	internal sealed class RadiusIndicator : MonoBehaviour
	{
		private const int Segments = 96;

		private LineRenderer ring;

		private LineRenderer crossA;

		private LineRenderer crossB;

		internal static RadiusIndicator Create(Transform owner)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("UES Bombardment Radius Preview");
			val.transform.SetParent(owner, false);
			RadiusIndicator radiusIndicator = val.AddComponent<RadiusIndicator>();
			radiusIndicator.ring = radiusIndicator.Line("Radius", 96, loop: true, 0.16f);
			radiusIndicator.crossA = radiusIndicator.Line("CrosshairA", 2, loop: false, 0.12f);
			radiusIndicator.crossB = radiusIndicator.Line("CrosshairB", 2, loop: false, 0.12f);
			return radiusIndicator;
		}

		private LineRenderer Line(string name, int count, bool loop, float width)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(((Component)this).transform, false);
			LineRenderer obj = val.AddComponent<LineRenderer>();
			((Renderer)obj).sharedMaterial = Visuals.LineMaterial;
			obj.useWorldSpace = true;
			obj.loop = loop;
			obj.positionCount = count;
			float startWidth = (obj.endWidth = width);
			obj.startWidth = startWidth;
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0.35f, 0.9f, 1f, 0.95f);
			obj.endColor = val2;
			obj.startColor = val2;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)obj).receiveShadows = false;
			return obj;
		}

		internal void Set(Vector3 point)
		{
			//IL_0019: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0047: 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_0062: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 96; i++)
			{
				float num = (float)i * (float)Math.PI * 2f / 96f;
				Vector3 point2 = point + new Vector3(Mathf.Cos(num), 0f, Mathf.Sin(num)) * 24f;
				ring.SetPosition(i, Ground(point2));
			}
			crossA.SetPosition(0, Ground(point + Vector3.left * 1.5f));
			crossA.SetPosition(1, Ground(point + Vector3.right * 1.5f));
			crossB.SetPosition(0, Ground(point + Vector3.back * 1.5f));
			crossB.SetPosition(1, Ground(point + Vector3.forward * 1.5f));
		}

		private static Vector3 Ground(Vector3 point)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = point + Vector3.up * 8f;
			Vector3 down = Vector3.down;
			LayerIndex world = LayerIndex.world;
			RaycastHit val2 = default(RaycastHit);
			if (!Physics.Raycast(val, down, ref val2, 24f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1))
			{
				return point + Vector3.up * 0.12f;
			}
			return ((RaycastHit)(ref val2)).point + Vector3.up * 0.12f;
		}
	}
	internal static class TestCommand
	{
		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void Equip(ConCommandArgs args)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance) || !Object.op_Implicit((Object)(object)((ConCommandArgs)(ref args)).senderMaster) || !Object.op_Implicit((Object)(object)((ConCommandArgs)(ref args)).senderMaster.inventory))
			{
				MonoBehaviour.print((object)"ues_bombardment requires a host player in an active run.");
				return;
			}
			Inventory inventory = ((ConCommandArgs)(ref args)).senderMaster.inventory;
			EquipmentIndex equipmentIndex = Plugin.Equipment.equipmentIndex;
			EquipmentLocation activeEquipmentLocation = inventory.activeEquipmentLocation;
			inventory.SetEquipmentIndex(equipmentIndex, ref activeEquipmentLocation);
		}
	}
	internal static class Visuals
	{
		private static Material lineMaterial;

		private static readonly Dictionary<Material, Material> RadioMaterials = new Dictionary<Material, Material>();

		private static readonly Dictionary<Texture, Texture2D> RadioTextures = new Dictionary<Texture, Texture2D>();

		private static readonly Dictionary<GameObject, GameObject> RadioDisplays = new Dictionary<GameObject, GameObject>();

		internal static Material LineMaterial
		{
			get
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Expected O, but got Unknown
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)lineMaterial))
				{
					return lineMaterial;
				}
				lineMaterial = new Material(Plugin.Load<Material>((object)"RoR2/Base/Captain/matCaptainAirstrikeAltLaser.mat"))
				{
					name = "UESRadiusMaterial"
				};
				string[] array = new string[4] { "_MainTex", "_Cloud1Tex", "_Cloud2Tex", "_RemapTex" };
				foreach (string text in array)
				{
					if (lineMaterial.HasProperty(text))
					{
						lineMaterial.SetTexture(text, (Texture)(object)Texture2D.whiteTexture);
					}
				}
				if (lineMaterial.HasProperty("_TintColor"))
				{
					lineMaterial.SetColor("_TintColor", new Color(0.25f, 0.85f, 1f));
				}
				return lineMaterial;
			}
		}

		internal static GameObject Pickup(GameObject source)
		{
			return RadioPrefab(source, "PickupUESOrbitalBombardment");
		}

		private static GameObject RadioPrefab(GameObject source, string name)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = PrefabAPI.InstantiateClone(source, name, false);
			Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val2 in componentsInChildren)
			{
				Material[] sharedMaterials = val2.sharedMaterials;
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					if (!Object.op_Implicit((Object)(object)sharedMaterials[j]))
					{
						continue;
					}
					Material val3 = sharedMaterials[j];
					if (!RadioMaterials.TryGetValue(val3, out var value))
					{
						value = new Material(val3)
						{
							name = "UES_" + ((Object)val3).name
						};
						if (val3.HasProperty("_MainTex") && Object.op_Implicit((Object)(object)val3.GetTexture("_MainTex")))
						{
							value.SetTexture("_MainTex", (Texture)(object)RadioTexture(val3.GetTexture("_MainTex"), emission: false));
						}
						if (val3.HasProperty("_EmTex") && Object.op_Implicit((Object)(object)val3.GetTexture("_EmTex")))
						{
							value.SetTexture("_EmTex", (Texture)(object)RadioTexture(val3.GetTexture("_EmTex"), emission: true));
						}
						if (value.HasProperty("_Color"))
						{
							value.SetColor("_Color", Color.white);
						}
						if (value.HasProperty("_EmColor"))
						{
							value.SetColor("_EmColor", new Color(0.35f, 0.85f, 1f));
						}
						if (value.HasProperty("_EmPower"))
						{
							value.SetFloat("_EmPower", 0.65f);
						}
						RadioMaterials.Add(val3, value);
					}
					sharedMaterials[j] = value;
				}
				val2.sharedMaterials = sharedMaterials;
			}
			ItemDisplay[] componentsInChildren2 = val.GetComponentsInChildren<ItemDisplay>(true);
			foreach (ItemDisplay val4 in componentsInChildren2)
			{
				if (val4.rendererInfos == null)
				{
					continue;
				}
				RendererInfo[] array = (RendererInfo[])val4.rendererInfos.Clone();
				for (int k = 0; k < array.Length; k++)
				{
					if (Object.op_Implicit((Object)(object)array[k].renderer) && Object.op_Implicit((Object)(object)array[k].renderer.sharedMaterial))
					{
						array[k].defaultMaterial = array[k].renderer.sharedMaterial;
						array[k].defaultMaterialAddress = null;
					}
				}
				val4.rendererInfos = array;
				val4.canBeEliteRecolored = false;
			}
			return val;
		}

		private static Texture2D RadioTexture(Texture source, bool emission)
		{
			//IL_0055: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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_0245: 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_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: 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)
			if (RadioTextures.TryGetValue(source, out var value))
			{
				return value;
			}
			Texture2D val = Copy(source);
			((Object)val).name = (emission ? "UESRadioEmission" : "UESRadioDiffuse");
			Color[] pixels = val.GetPixels();
			for (int i = 0; i < ((Texture)val).height; i++)
			{
				for (int j = 0; j < ((Texture)val).width; j++)
				{
					int num = i * ((Texture)val).width + j;
					Color val2 = pixels[num];
					float num2 = Mathf.Max(val2.r, Mathf.Max(val2.g, val2.b));
					if (emission)
					{
						pixels[num] = new Color(num2 * 0.08f, num2 * 0.25f, num2 * 0.32f, val2.a);
					}
					else if (j < 15)
					{
						pixels[num] = Color.Lerp(new Color(0.025f, 0.04f, 0.05f), new Color(0.42f, 0.4f, 0.32f), Mathf.Clamp01(num2 * 2.8f));
					}
					else if (j < 32)
					{
						pixels[num] = Color.Lerp(new Color(0.008f, 0.018f, 0.035f), new Color(0.085f, 0.13f, 0.2f), Mathf.Clamp01(num2 * 1.9f));
					}
					else if (j < 54)
					{
						pixels[num] = new Color(num2 * 0.28f, num2 * 0.9f, num2, val2.a);
					}
				}
			}
			for (int k = 108; k <= 190; k++)
			{
				for (int l = 85; l <= 253; l++)
				{
					pixels[k * ((Texture)val).width + l] = (emission ? new Color(0.015f, 0.08f, 0.1f) : new Color(0.025f, 0.1f, 0.14f));
				}
			}
			Color ink = (emission ? new Color(0.25f, 0.7f, 0.8f) : new Color(0.9f, 0.96f, 0.9f));
			Text(pixels, ((Texture)val).width, "UES", 136, 181, 4, ink);
			Text(pixels, ((Texture)val).width, "ORBITAL", 128, 142, 2, ink);
			Text(pixels, ((Texture)val).width, "LINK READY", 140, 120, 1, ink);
			val.SetPixels(pixels);
			val.Apply(true, false);
			RadioTextures.Add(source, val);
			return val;
		}

		private static Texture2D Copy(Texture source)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0046: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			RenderTexture active = RenderTexture.active;
			RenderTexture temporary = RenderTexture.GetTemporary(source.width, source.height, 0, (RenderTextureFormat)0);
			try
			{
				Graphics.Blit(source, temporary);
				RenderTexture.active = temporary;
				Texture2D val = new Texture2D(source.width, source.height, (TextureFormat)4, true)
				{
					filterMode = source.filterMode,
					wrapMode = source.wrapMode
				};
				val.ReadPixels(new Rect(0f, 0f, (float)source.width, (float)source.height), 0, 0);
				val.Apply();
				return val;
			}
			finally
			{
				RenderTexture.active = active;
				RenderTexture.ReleaseTemporary(temporary);
			}
		}

		private static void Text(Color[] pixels, int width, string text, int x, int top, int scale, Color ink)
		{
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			string[] array = new string[15]
			{
				"01110100011000111111100011000110001", "11110100011000111110100011000111110", "11110100011000110001100011000111110", "11111100001000011110100001000011111", "11111001000010000100001000010011111", "10001100101010011000101001001010001", "10000100001000010000100001000011111", "10001110011010110011100011000110001", "01110100011000110001100011000101110", "11110100011000111110101001001010001",
				"01111100001000001110000010000111110", "11111001000010000100001000010000100", "10001100011000110001100011000101110", "10001100010101000100001000010000100", "00000000000000000000000000000000000"
			};
			for (int i = 0; i < text.Length; i++)
			{
				char value = text[i];
				int num = "ABDEIKLNORSTUY ".IndexOf(value);
				if (num < 0)
				{
					throw new InvalidOperationException("Missing radio stencil character: " + value);
				}
				for (int j = 0; j < 7; j++)
				{
					for (int k = 0; k < 5; k++)
					{
						if (array[num][j * 5 + k] != '1')
						{
							continue;
						}
						for (int l = 0; l < scale; l++)
						{
							for (int m = 0; m < scale; m++)
							{
								pixels[(top - j * scale - l) * width + x + k * scale + m] = ink;
							}
						}
					}
				}
				x += 6 * scale;
			}
		}

		internal static Sprite Icon(Sprite source)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_0056: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: 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_01af: 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)
			RenderTexture active = RenderTexture.active;
			Rect textureRect = source.textureRect;
			RenderTexture temporary = RenderTexture.GetTemporary(((Texture)source.texture).width, ((Texture)source.texture).height, 0, (RenderTextureFormat)0);
			try
			{
				Graphics.Blit((Texture)(object)source.texture, temporary);
				RenderTexture.active = temporary;
				Texture2D val = new Texture2D((int)((Rect)(ref textureRect)).width, (int)((Rect)(ref textureRect)).height, (TextureFormat)4, false);
				val.ReadPixels(textureRect, 0, 0);
				Color[] pixels = val.GetPixels();
				for (int i = 0; i < pixels.Length; i++)
				{
					Color val2 = pixels[i];
					if (!(val2.r > 0.55f) || !(val2.g > 0.25f) || !(val2.g < val2.r * 0.85f) || !(val2.b < val2.g * 0.7f))
					{
						float num = Mathf.Max(val2.r, Mathf.Max(val2.g, val2.b));
						if (val2.g > val2.b * 2f && val2.g > 0.3f)
						{
							pixels[i] = new Color(num * 0.18f, num * 0.8f, num, val2.a);
						}
						else if (val2.g > val2.r * 1.05f && val2.g > val2.b * 1.05f)
						{
							Color val3 = Color.Lerp(new Color(0.4f, 0.43f, 0.42f), new Color(0.95f, 0.93f, 0.82f), Mathf.Clamp01(num * 2.5f));
							val3.a = val2.a;
							pixels[i] = val3;
						}
						else
						{
							pixels[i] = new Color(num * 0.34f, num * 0.57f, num * 0.78f, val2.a);
						}
					}
				}
				val.SetPixels(pixels);
				val.Apply();
				((Object)val).name = "texUESOrbitalBombardmentIcon";
				return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			}
			finally
			{
				RenderTexture.active = active;
				RenderTexture.ReleaseTemporary(temporary);
			}
		}

		internal static int AddDisplays()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0179: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			HashSet<ItemDisplayRuleSet> hashSet = new HashSet<ItemDisplayRuleSet>();
			foreach (GameObject allBodyPrefab in BodyCatalog.allBodyPrefabs)
			{
				CharacterModel[] componentsInChildren = allBodyPrefab.GetComponentsInChildren<CharacterModel>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					ItemDisplayRuleSet itemDisplayRuleSet = componentsInChildren[i].itemDisplayRuleSet;
					if (!Object.op_Implicit((Object)(object)itemDisplayRuleSet) || !hashSet.Add(itemDisplayRuleSet))
					{
						continue;
					}
					DisplayRuleGroup equipmentDisplayRuleGroup = itemDisplayRuleSet.GetEquipmentDisplayRuleGroup(Plugin.Radio.equipmentIndex);
					if (equipmentDisplayRuleGroup.rules == null || equipmentDisplayRuleGroup.rules.Length == 0)
					{
						continue;
					}
					ItemDisplayRule[] array = (ItemDisplayRule[])equipmentDisplayRuleGroup.rules.Clone();
					for (int j = 0; j < array.Length; j++)
					{
						GameObject val = array[j].followerPrefab;
						if (!Object.op_Implicit((Object)(object)val) && array[j].followerPrefabAddress != null && ((AssetReference)array[j].followerPrefabAddress).RuntimeKeyIsValid())
						{
							val = Plugin.Load<GameObject>(((AssetReference)array[j].followerPrefabAddress).RuntimeKey);
						}
						if (Object.op_Implicit((Object)(object)val))
						{
							if (!RadioDisplays.TryGetValue(val, out var value))
							{
								value = RadioPrefab(val, "DisplayUES_" + ((Object)val).name);
								RadioDisplays.Add(val, value);
							}
							array[j].followerPrefab = value;
							array[j].followerPrefabAddress = null;
						}
					}
					itemDisplayRuleSet.SetDisplayRuleGroup((Object)(object)Plugin.Equipment, new DisplayRuleGroup
					{
						rules = array
					});
					itemDisplayRuleSet.GenerateRuntimeValues();
					num++;
				}
			}
			return num;
		}
	}
}