Qb.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using Chen.GradiusMod;
using Chen.GradiusMod.Drones;
using Chen.GradiusMod.Items;
using Chen.GradiusMod.Items.GradiusOption;
using Chen.GradiusMod.Items.GradiusOption.Components;
using Chen.Helpers.GeneralHelpers;
using Chen.Helpers.LogHelpers;
using Chen.Helpers.UnityHelpers;
using Chen.Qb.Components;
using Chen.Qb.States;
using EntityStates;
using EntityStates.Captain.Weapon;
using EntityStates.Commando.CommandoWeapon;
using EntityStates.Drone.DroneWeapon;
using Microsoft.CodeAnalysis;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.CharacterAI;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("Qb.Tests")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Qb")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.2.0.0")]
[assembly: AssemblyInformationalVersion("2.2.0+2b8d799e5412d3ce4a73700be8ce5a4a9661c04f")]
[assembly: AssemblyProduct("Qb")]
[assembly: AssemblyTitle("Qb")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/cheeeeeeeeeen/RoR2-Qb-Drone")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.2.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace Chen.Qb
{
	[BepInPlugin("com.Chen.Qb", "Qb", "2.2.3")]
	[BepInDependency("com.bepis.r2api", "5.3.0")]
	[BepInDependency("com.Chen.ChensHelpers", "1.2.1")]
	[BepInDependency("com.Chen.ChensGradiusMod", "4.0.2")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class ModPlugin : BaseUnityPlugin
	{
		public const string ModVer = "2.2.3";

		public const string ModName = "Qb";

		public const string ModGuid = "com.Chen.Qb";

		internal static ConfigFile cfgFile;

		internal static Log Log;

		internal static List<DroneInfo> dronesList = new List<DroneInfo>();

		internal static AssetBundle assetBundle;

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			Log = new Log(((BaseUnityPlugin)this).Logger);
			Log.Debug((object)"Initializing config file...");
			cfgFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "com.Chen.Qb.cfg"), true);
			Log.Debug((object)"Loading asset bundle...");
			assetBundle = new AssetsManager(new BundleInfo("Chen.Qb.assetbundle", (BundleType)0)).Register();
			Extensions.ConvertShaders(assetBundle);
			Log.Debug((object)"Registering Qb Drone...");
			dronesList = DroneCatalog.Initialize("com.Chen.Qb", cfgFile);
			DroneCatalog.ScopedSetupAll(dronesList);
		}

		internal static bool DebugCheck()
		{
			return false;
		}
	}
	internal class QbDrone : Drone<QbDrone>
	{
		private static readonly Lazy<SkillDef> _skillBasis = LazyAddressable<SkillDef>("RoR2/Base/Drones/Drone1BodyGun.asset");

		private static readonly Lazy<InteractableSpawnCard> _iscBasis = LazyAddressable<InteractableSpawnCard>("RoR2/Base/Drones/iscBrokenDrone1.asset");

		private static readonly Lazy<GameObject> _originalSpiderMine = LazyAddressable<GameObject>("RoR2/Base/Engi/SpiderMine.prefab");

		private static readonly Lazy<InteractableSpawnCard> _megaDroneSpawnCard = LazyAddressable<InteractableSpawnCard>("RoR2/Base/Drones/iscBrokenMegaDrone.asset");

		private static readonly Lazy<GameObject> _equipmentDroneBody = LazyAddressable<GameObject>("RoR2/Base/Drones/EquipmentDroneBody.prefab");

		private static readonly Lazy<GameObject> _flameDroneBody = LazyAddressable<GameObject>("RoR2/Base/Drones/FlameDroneBody.prefab");

		public InteractableSpawnCard iSpawnCard { get; set; }

		public GameObject spiderMine { get; set; }

		public float baseMaxHealth { get; private set; }

		public override bool canHaveOptions => true;

		private GameObject brokenObject { get; set; }

		private DirectorCardHolder iDirectorCardHolder { get; set; }

		private GameObject droneBody { get; set; }

		private GameObject droneMaster { get; set; }

		private static InteractableSpawnCard interactableSpawnCardBasis => _iscBasis.Value;

		private static InteractableSpawnCard megaDroneSpawnCard => _megaDroneSpawnCard.Value;

		private static SkillDef skillBasis => _skillBasis.Value;

		private static GameObject originalSpiderMine => _originalSpiderMine.Value;

		private static GameObject equipmentDroneBody => _equipmentDroneBody.Value;

		private static CharacterBody flameDroneBody
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)_flameDroneBody.Value))
				{
					return null;
				}
				return _flameDroneBody.Value.GetComponent<CharacterBody>();
			}
		}

		protected override GameObject DroneCharacterMasterObject => droneMaster;

		protected override void SetupConfig()
		{
			((Drone)this).spawnWeightWithMachinesArtifact = 0;
			((Drone)this).SetupConfig();
			baseMaxHealth = ((Drone)this).config.Bind<float>(((Drone)this).configCategory, "BaseMaxHealth", baseMaxHealth, "The max health of the drone at level 1. The health gained per level scales along with it. Set to 0 to use 200% of the vanilla Incinerator Drone's health.").Value;
		}

		protected override void SetupComponents()
		{
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Expected O, but got Unknown
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_048b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Unknown result type (might be due to invalid IL or missing references)
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0527: Unknown result type (might be due to invalid IL or missing references)
			//IL_052e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0535: Unknown result type (might be due to invalid IL or missing references)
			//IL_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_053c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Expected O, but got Unknown
			//IL_0546: Unknown result type (might be due to invalid IL or missing references)
			//IL_054b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0553: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Unknown result type (might be due to invalid IL or missing references)
			//IL_055c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0566: Expected O, but got Unknown
			((Drone)this).SetupComponents();
			LanguageAPI.Add("QB_DRONE_NAME", "Qb Drone");
			LanguageAPI.Add("QB_DRONE_CONTEXT", "Repair Qb Drone");
			LanguageAPI.Add("QB_DRONE_INTERACTABLE_NAME", "Broken Qb Drone");
			LanguageAPI.Add("QB_DRONE_PICKUP", "A mysterious floating cube that lobs grenades, rockets nearby enemies and periodically unleashes a salvo.");
			LanguageAPI.Add("QB_DRONE_DESCRIPTION", "Lobs a volley of <style=cIsDamage>15 grenades</style> for <style=cIsDamage>500% damage</style> each. Fires rockets at enemies within <style=cIsUtility>10m</style> for <style=cIsDamage>100% damage</style>. Every <style=cIsUtility>60 seconds</style>, unleashes a salvo of <style=cIsDamage>missiles, fireworks and mines</style> from all of its sides.");
			LanguageAPI.Add("QB_DRONE_SKILL_DESCRIPTION", "Lob Grenades: Lob 15 grenades for <style=cIsDamage>500% damage</style> each. Also fires at nearby enemies and periodically unleashes a <style=cIsDamage>Mayhem Salvo</style>.");
			GameObject val = ((Drone)this).CreatePickupDisplay(ModPlugin.assetBundle.LoadAsset<GameObject>("Assets/DroneBody/MainBody.prefab"));
			brokenObject = PrefabAPI.InstantiateClone(((SpawnCard)interactableSpawnCardBasis).prefab, ((Drone)this).name + "Broken", true);
			SummonMasterBehavior component = brokenObject.GetComponent<SummonMasterBehavior>();
			droneMaster = PrefabAPI.InstantiateClone(component.masterPrefab, ((Drone)this).name + "Master", true);
			ContentAddition.AddMaster(droneMaster);
			AISkillDriver[] components = droneMaster.GetComponents<AISkillDriver>();
			if (components.Length > 4)
			{
				components[3].maxDistance = 25f;
				components[4].maxDistance = 50f;
			}
			else
			{
				ModPlugin.Log.Warning((object)(((Drone)this).name + ": The Gunner Drone skill drivers changed. Attack ranges are left at their default values."));
			}
			Extensions.SetAllDriversToAimTowardsEnemies(components);
			CharacterMaster component2 = droneMaster.GetComponent<CharacterMaster>();
			droneBody = PrefabAPI.InstantiateClone(component2.bodyPrefab, ((Drone)this).name + "Body", true);
			ContentAddition.AddBody(droneBody);
			CharacterBody component3 = droneBody.GetComponent<CharacterBody>();
			component3.baseNameToken = "QB_DRONE_NAME";
			CharacterBody val2 = flameDroneBody;
			component3.baseMaxHealth = (Object.op_Implicit((Object)(object)val2) ? val2.baseMaxHealth : component3.baseMaxHealth) * 2f;
			component3.levelMaxHealth = (Object.op_Implicit((Object)(object)val2) ? val2.levelMaxHealth : component3.levelMaxHealth) * 2f;
			if (baseMaxHealth > 0f)
			{
				component3.levelMaxHealth *= baseMaxHealth / component3.baseMaxHealth;
				component3.baseMaxHealth = baseMaxHealth;
			}
			component3.baseRegen *= 2f;
			component3.baseDamage *= 2f;
			component3.baseCrit *= 2f;
			component3.levelRegen *= 2f;
			component3.levelDamage *= 2f;
			component3.levelCrit *= 2f;
			component3.portraitIcon = ModPlugin.assetBundle.LoadAsset<Texture>("Assets/Icon/QbIcon.png");
			GameObject val3 = ModPlugin.assetBundle.LoadAsset<GameObject>("Assets/DroneBody/MainBody.prefab");
			Extensions.ReplaceModel(droneBody, val3, DebugCheck());
			Extensions.InitializeDroneModelComponents(val3, component3, 1.4f);
			SkillLocator component4 = droneBody.GetComponent<SkillLocator>();
			bool flag = default(bool);
			ContentAddition.AddEntityState<ScatterGrenades>(ref flag);
			SkillDef val4 = Object.Instantiate<SkillDef>(skillBasis);
			val4.activationState = new SerializableEntityStateType(typeof(ScatterGrenades));
			val4.baseRechargeInterval = 12f;
			val4.beginSkillCooldownOnSkillEnd = true;
			val4.baseMaxStock = 1;
			val4.fullRestockOnAssign = false;
			ContentAddition.AddSkillDef(val4);
			SkillFamily val5 = Object.Instantiate<SkillFamily>(component4.primary.skillFamily);
			val5.variants = (Variant[])(object)new Variant[1];
			Variant[] variants = val5.variants;
			Variant val6 = new Variant
			{
				skillDef = val4,
				unlockableDef = null
			};
			((Variant)(ref val6)).viewableNode = new Node("", false, (Node)null);
			variants[0] = val6;
			Reflection.SetFieldValue<SkillFamily>((object)component4.primary, "_skillFamily", val5);
			ContentAddition.AddSkillFamily(val5);
			UseEquipmentDroneCommand(droneBody, component4);
			Extensions.GetOrAddComponent<CharacterDeathBehavior>((Component)(object)component3).deathState = new SerializableEntityStateType(typeof(DeathState));
			component2.bodyPrefab = droneBody;
			component.masterPrefab = droneMaster;
			PurchaseInteraction component5 = brokenObject.GetComponent<PurchaseInteraction>();
			component5.cost *= 4;
			component5.Networkcost = component5.cost;
			component5.contextToken = "QB_DRONE_CONTEXT";
			component5.displayNameToken = "QB_DRONE_INTERACTABLE_NAME";
			brokenObject.GetComponent<GenericDisplayNameProvider>().displayToken = "QB_DRONE_NAME";
			GameObject val7 = ModPlugin.assetBundle.LoadAsset<GameObject>("Assets/DroneBroken/MainBroken.prefab");
			GameObject gameObject = ((Component)val7.transform.Find("BrokenCube")).gameObject;
			((Drone)this).ReplaceBrokenModel(brokenObject, val7, (Renderer)(object)gameObject.GetComponent<MeshRenderer>(), (GameObject[])(object)new GameObject[1] { gameObject });
			Transform val8 = Drone.FindBrokenDamagePoint(val7);
			if (Object.op_Implicit((Object)(object)val8))
			{
				val8.localPosition = Vector3.zero;
				val8.localRotation = Quaternion.identity;
				val8.localScale = Vector3.one;
			}
			iSpawnCard = Object.Instantiate<InteractableSpawnCard>(interactableSpawnCardBasis);
			((Object)iSpawnCard).name = "iscBroken" + ((Drone)this).name;
			((SpawnCard)iSpawnCard).prefab = brokenObject;
			iSpawnCard.slightlyRandomizeOrientation = false;
			iSpawnCard.orientToFloor = true;
			if (Object.op_Implicit((Object)(object)megaDroneSpawnCard))
			{
				((SpawnCard)iSpawnCard).directorCreditCost = ((SpawnCard)megaDroneSpawnCard).directorCreditCost;
			}
			DirectorCard card = new DirectorCard
			{
				spawnCard = (SpawnCard)(object)iSpawnCard,
				selectionWeight = 1,
				minimumStageCompletions = 4,
				spawnDistance = (MonsterSpawnDistance)1,
				preventOverhead = false
			};
			iDirectorCardHolder = new DirectorCardHolder
			{
				Card = card,
				MonsterCategory = (MonsterCategory)0,
				InteractableCategory = (InteractableCategory)5
			};
			spiderMine = PrefabAPI.InstantiateClone(originalSpiderMine, "QbSpiderMine", true);
			ProjectileDeployToOwner component6 = spiderMine.GetComponent<ProjectileDeployToOwner>();
			if (Object.op_Implicit((Object)(object)component6))
			{
				Object.DestroyImmediate((Object)(object)component6);
			}
			spiderMine.AddComponent<Disappear>();
			ContentAddition.AddProjectile(spiderMine);
			((Drone)this).droneDef = ((Drone)this).CreateDroneDef(Drone.LoadVanillaDroneDef("RoR2/Base/Drones/MegaDrone.asset"), droneBody, brokenObject, iSpawnCard, "QB_DRONE", component3.portraitIcon, val, Drone.LoadVanillaDroneDef("RoR2/Base/Drones/EquipmentDrone.asset"));
		}

		private void UseEquipmentDroneCommand(GameObject bodyObject, SkillLocator locator)
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			DroneCommandReceiver component = bodyObject.GetComponent<DroneCommandReceiver>();
			DroneCommandReceiver val = (Object.op_Implicit((Object)(object)equipmentDroneBody) ? equipmentDroneBody.GetComponent<DroneCommandReceiver>() : null);
			if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.commandSkill) || !Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.commandSkill))
			{
				ModPlugin.Log.Warning((object)(((Drone)this).name + ": The drone command components were not found. Qb keeps the Gunner Drone command."));
				return;
			}
			if ((Object)(object)component.commandSkill == (Object)(object)locator.primary)
			{
				ModPlugin.Log.Warning((object)(((Drone)this).name + ": The drone command shares the primary skill slot. Qb keeps its grenades as the command."));
				return;
			}
			Reflection.SetFieldValue<SkillFamily>((object)component.commandSkill, "_skillFamily", val.commandSkill.skillFamily);
			component.targetType = val.targetType;
			component.targetDistance = val.targetDistance;
		}

		protected override void SetupBehavior()
		{
			((Drone)this).SetupBehavior();
			DirectorAPI.InteractableActions += delegate(DccsPool pool, StageInfo stage)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				Drone.AddToDronePools(pool, stage, iDirectorCardHolder);
			};
			CharacterBody.onBodyStartGlobal += CharacterBody_onBodyStartGlobal;
		}

		private void CharacterBody_onBodyStartGlobal(CharacterBody obj)
		{
			if (((Object)obj).name.Contains("QbDroneBody"))
			{
				((Component)obj).gameObject.AddComponent<ShootCloseRangedBullet>();
				((Component)obj).gameObject.AddComponent<Salvo>();
			}
		}

		internal static Lazy<T> LazyAddressable<T>(string key)
		{
			return new Lazy<T>(delegate
			{
				//IL_0006: 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)
				T val = Addressables.LoadAssetAsync<T>((object)key).WaitForCompletion();
				if (val == null)
				{
					ModPlugin.Log.Error((object)("Failed to load the addressable asset " + key + "."));
				}
				return val;
			});
		}

		internal static bool DebugCheck()
		{
			return false;
		}
	}
	internal static class Util
	{
		public static void FireOptions(CharacterBody owner, FireProjectileInfo ownerInfo, Func<GameObject, Vector3, Vector3> customDirection)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			ItemBase<GradiusOption>.instance.FireForAllOptions(owner, (Action<GameObject, OptionBehavior, GameObject, Vector3>)delegate(GameObject option, OptionBehavior _b, GameObject _t, Vector3 direction)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: 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_0094: 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_00a0: 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_00ac: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				if (customDirection != null)
				{
					direction = customDirection(option, direction);
				}
				FireProjectileInfo val = new FireProjectileInfo
				{
					projectilePrefab = ownerInfo.projectilePrefab,
					crit = ownerInfo.crit,
					damage = ownerInfo.damage,
					damageColorIndex = ownerInfo.damageColorIndex,
					force = ownerInfo.force,
					owner = ownerInfo.owner,
					position = option.transform.position,
					rotation = Util.QuaternionSafeLookRotation(direction)
				};
				ProjectileManager.instance.FireProjectile(val);
			});
		}

		public static void EffectOptions(CharacterBody owner, GameObject effectPrefab, bool transmit)
		{
			ItemBase<GradiusOption>.instance.FireForAllOptions(owner, (Action<GameObject, OptionBehavior, GameObject, Vector3>)delegate(GameObject option, OptionBehavior _b, GameObject _t, Vector3 direction)
			{
				//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_000c: 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_001d: 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_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Expected O, but got Unknown
				EffectData val = new EffectData
				{
					origin = option.transform.position,
					rootObject = option,
					rotation = Util.QuaternionSafeLookRotation(direction)
				};
				EffectManager.SpawnEffect(effectPrefab, val, transmit);
			});
		}
	}
}
namespace Chen.Qb.States
{
	internal class DeathState : DroneDeathState
	{
		protected override bool SpawnInteractable { get; set; } = ((Drone)Drone<QbDrone>.instance).canBeRepurchased;

		protected override InteractableSpawnCard GetInteractableSpawnCard => Drone<QbDrone>.instance.iSpawnCard;
	}
	internal class ScatterGrenades : BaseState
	{
		private static bool initialized;

		private static GameObject effectPrefab;

		private static float duration;

		private static int projectileNumber;

		private static float intervalFire;

		private static string soundString;

		private static float spread;

		private static float damageCoefficient;

		private static GameObject grenadePrefab;

		private Transform aimOrigin;

		private float timer;

		private int soundId;

		private static void Initialize()
		{
			//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)
			if (!initialized)
			{
				initialized = true;
				effectPrefab = FireTazer.chargeEffectPrefab;
				projectileNumber = 15;
				intervalFire = 0.1f;
				duration = intervalFire * (float)projectileNumber;
				soundString = ChargeCaptainShotgun.enterSoundString;
				spread = 20f;
				damageCoefficient = 5f;
				grenadePrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Commando/CommandoGrenadeProjectile.prefab").WaitForCompletion();
			}
		}

		private void StopSound()
		{
			if (soundId >= 0)
			{
				AkSoundEngine.StopPlayingID((uint)soundId);
			}
		}

		public override void OnEnter()
		{
			Initialize();
			((BaseState)this).OnEnter();
			aimOrigin = ((EntityState)this).transform.Find("ModelBase").Find("MainBody").Find("Node (Front)")
				.Find("AimOrigin");
			timer = 0f;
			soundId = -1;
		}

		public override void FixedUpdate()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_00a8: 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_00bf: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_00fe: 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_0148: 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_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: 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)
			((EntityState)this).FixedUpdate();
			timer += Time.fixedDeltaTime;
			if (timer >= intervalFire)
			{
				timer -= intervalFire;
				Vector3 position = aimOrigin.position;
				Quaternion rotation = Util.QuaternionSafeLookRotation(Util.ApplySpread(((EntityState)this).transform.forward, 0f, spread, 1f, 1f, 0f, 0f));
				StopSound();
				soundId = (int)Util.PlaySound(soundString, ((EntityState)this).gameObject);
				if (Object.op_Implicit((Object)(object)effectPrefab))
				{
					EffectData val = new EffectData
					{
						origin = position,
						rootObject = ((Component)aimOrigin).gameObject,
						rotation = rotation
					};
					EffectManager.SpawnEffect(effectPrefab, val, false);
					Util.EffectOptions(((EntityState)this).characterBody, effectPrefab, transmit: false);
				}
				if (((EntityState)this).isAuthority)
				{
					float damage = base.damageStat * damageCoefficient;
					FireProjectileInfo val2 = new FireProjectileInfo
					{
						projectilePrefab = grenadePrefab,
						crit = ((BaseState)this).RollCrit(),
						damage = damage,
						damageColorIndex = (DamageColorIndex)0,
						force = 0f,
						owner = ((EntityState)this).gameObject,
						position = position,
						rotation = rotation
					};
					ProjectileManager.instance.FireProjectile(val2);
					Util.FireOptions(((EntityState)this).characterBody, val2, (GameObject _o, Vector3 optionDirection) => Util.ApplySpread(optionDirection, 0f, spread, 1f, 1f, 0f, 0f));
				}
			}
			if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= duration)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			return (InterruptPriority)2;
		}
	}
}
namespace Chen.Qb.Components
{
	internal class Disappear : MonoBehaviour
	{
		private readonly float life = 240f;

		private float age;

		private void FixedUpdate()
		{
			if (age >= life)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			age += Time.fixedDeltaTime;
		}
	}
	internal class Salvo : MonoBehaviour
	{
		private static bool initialized;

		private static GameObject effectPrefab;

		private static float cooldown;

		private static float mayhemDuration;

		private static List<GameObject> projectilePrefabs;

		private static List<float> damageCoefficients;

		private static List<float> forces;

		private static float mayhemInterval;

		private static GameObject fireworksProjectile;

		private CharacterBody characterBody;

		private float timer;

		private bool mayhemMode;

		private float mayhemTimer;

		private ushort currentAim;

		private InputBankTest inputBank;

		private float mayhemIntervalTimer;

		private Transform modelTransform;

		private Transform root;

		private static void Initialize()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if (!initialized)
			{
				initialized = true;
				fireworksProjectile = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Firework/FireworkProjectile.prefab").WaitForCompletion();
				effectPrefab = FireTazer.chargeEffectPrefab;
				cooldown = 60f;
				mayhemDuration = 1.5f;
				projectilePrefabs = new List<GameObject>
				{
					CommonAssets.missilePrefab,
					fireworksProjectile,
					Drone<QbDrone>.instance.spiderMine
				};
				damageCoefficients = new List<float> { 3f, 1.5f, 5f };
				forces = new List<float> { 1.5f, 3f, 2.5f };
				mayhemInterval = 0.05f;
			}
		}

		private void Awake()
		{
			Initialize();
			characterBody = ((Component)this).gameObject.GetComponent<CharacterBody>();
			inputBank = characterBody.inputBank;
			mayhemIntervalTimer = (mayhemTimer = (timer = 0f));
			mayhemMode = false;
			currentAim = 10;
			modelTransform = ((Component)this).gameObject.transform.Find("ModelBase").Find("MainBody");
		}

		private void FixedUpdate()
		{
			if (PauseScreenController.paused)
			{
				return;
			}
			if (mayhemMode)
			{
				mayhemTimer += Time.fixedDeltaTime;
				if (mayhemTimer >= mayhemDuration)
				{
					mayhemMode = false;
					mayhemIntervalTimer = (mayhemTimer = 0f);
					currentAim = 10;
				}
				else
				{
					DoMayhem();
				}
			}
			else
			{
				timer += Time.fixedDeltaTime;
				if (timer >= cooldown)
				{
					timer -= cooldown;
					mayhemMode = true;
				}
			}
		}

		private void DoMayhem()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_0069: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: 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_0169: Unknown result type (might be due to invalid IL or missing references)
			mayhemIntervalTimer += Time.fixedDeltaTime;
			if (!(mayhemIntervalTimer >= mayhemInterval))
			{
				return;
			}
			Ray aimRay = SetAim(CycleAim(ref currentAim));
			Quaternion rotation = Util.QuaternionSafeLookRotation(((Ray)(ref aimRay)).direction);
			if (Object.op_Implicit((Object)(object)effectPrefab))
			{
				EffectData val = new EffectData
				{
					origin = ((Ray)(ref aimRay)).origin,
					rootObject = ((Component)root).gameObject,
					rotation = rotation
				};
				EffectManager.SpawnEffect(effectPrefab, val, false);
				Util.EffectOptions(characterBody, effectPrefab, transmit: false);
			}
			if (NetworkServer.active)
			{
				int index = Random.Range(0, projectilePrefabs.Count);
				float damage = characterBody.damage * damageCoefficients[index];
				FireProjectileInfo val2 = new FireProjectileInfo
				{
					projectilePrefab = projectilePrefabs[index],
					crit = characterBody.RollCrit(),
					damage = damage,
					damageColorIndex = (DamageColorIndex)0,
					force = forces[index],
					owner = ((Component)this).gameObject,
					position = ((Ray)(ref aimRay)).origin,
					rotation = rotation
				};
				ProjectileManager.instance.FireProjectile(val2);
				Util.FireOptions(characterBody, val2, (GameObject _o, Vector3 _d) => ((Ray)(ref aimRay)).direction);
			}
			mayhemIntervalTimer -= mayhemInterval;
		}

		private Ray SetAim(ushort aim)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			root = modelTransform;
			Ray aimRay = inputBank.GetAimRay();
			Vector3 val = ((Ray)(ref aimRay)).direction;
			switch (aim)
			{
			case 0:
				root = modelTransform.Find("Node (Front)");
				val = modelTransform.forward;
				break;
			case 1:
				root = modelTransform.Find("Node (Top)");
				val = modelTransform.up;
				break;
			case 2:
				root = modelTransform.Find("Node (Left)");
				val = -modelTransform.right;
				break;
			case 3:
				root = modelTransform.Find("Node (Right)");
				val = modelTransform.right;
				break;
			case 4:
				root = modelTransform.Find("Node (Bottom)");
				val = -modelTransform.up;
				break;
			case 5:
				root = modelTransform.Find("Node (Back)");
				val = -modelTransform.forward;
				break;
			}
			root = root.Find("AimOrigin");
			return new Ray(root.position, ((Vector3)(ref val)).normalized);
		}

		private ushort CycleAim(ref ushort aim)
		{
			aim++;
			if (aim > 5)
			{
				aim = 0;
			}
			return aim;
		}
	}
	internal class ShootCloseRangedBullet : MonoBehaviour
	{
		private static bool initialized;

		private static GameObject effectPrefab;

		private static GameObject projectilePrefab;

		private static float cooldown;

		private static string soundString;

		private static float damageCoefficient;

		private static float range;

		private static float force;

		private static float velocity;

		private BullseyeSearch enemyFinder;

		private HurtBox target;

		private CharacterBody characterBody;

		private InputBankTest inputBank;

		private TeamComponent teamComponent;

		private float timer;

		private static void Initialize()
		{
			if (!initialized)
			{
				initialized = true;
				effectPrefab = FireTazer.chargeEffectPrefab;
				projectilePrefab = FireTwinRocket.projectilePrefab;
				cooldown = 0.3f;
				soundString = FirePistol2.firePistolSoundString;
				damageCoefficient = 1f;
				range = 10f;
				force = FireTwinRocket.force;
				velocity = projectilePrefab.GetComponent<ProjectileSimple>().desiredForwardSpeed * 2f;
			}
		}

		private void Awake()
		{
			Initialize();
			characterBody = ((Component)this).gameObject.GetComponent<CharacterBody>();
			inputBank = characterBody.inputBank;
			teamComponent = characterBody.teamComponent;
			timer = 0f;
		}

		private void FixedUpdate()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected O, but got Unknown
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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_016e: 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_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Expected O, but got Unknown
			//IL_0231: 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_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			timer += Time.fixedDeltaTime;
			if (!(timer >= cooldown))
			{
				return;
			}
			BullseyeSearch val = new BullseyeSearch
			{
				maxDistanceFilter = range,
				maxAngleFilter = 180f,
				searchOrigin = ((Component)this).transform.position
			};
			Ray aimRay = inputBank.GetAimRay();
			val.searchDirection = ((Ray)(ref aimRay)).direction;
			val.filterByLoS = true;
			val.sortMode = (SortMode)1;
			val.teamMaskFilter = TeamMask.allButNeutral;
			enemyFinder = val;
			if (Object.op_Implicit((Object)(object)teamComponent))
			{
				((TeamMask)(ref enemyFinder.teamMaskFilter)).RemoveTeam(teamComponent.teamIndex);
			}
			enemyFinder.RefreshCandidates();
			target = enemyFinder.GetResults().FirstOrDefault();
			if (Object.op_Implicit((Object)(object)target))
			{
				Vector3 targetPosition = ((Component)target).transform.position;
				float num = range * 3f;
				Vector3 val2 = ((Component)this).transform.position;
				GameObject gameObject = ((Component)this).gameObject;
				foreach (Transform item in ((Component)this).transform.Find("ModelBase").Find("MainBody"))
				{
					Transform val3 = item;
					Vector3 position = ((Component)val3).transform.position;
					float num2 = Vector3.Distance(targetPosition, position);
					if (num2 < num)
					{
						val2 = position;
						num = num2;
						gameObject = ((Component)val3).gameObject;
					}
				}
				Vector3 val4 = targetPosition - val2;
				Quaternion rotation = Util.QuaternionSafeLookRotation(((Vector3)(ref val4)).normalized);
				Util.PlaySound(soundString, ((Component)this).gameObject);
				if (Object.op_Implicit((Object)(object)effectPrefab))
				{
					EffectData val5 = new EffectData
					{
						origin = val2,
						rootObject = gameObject,
						rotation = rotation
					};
					EffectManager.SpawnEffect(effectPrefab, val5, false);
					Util.EffectOptions(characterBody, effectPrefab, transmit: false);
				}
				if (NetworkServer.active)
				{
					float damage = characterBody.damage * damageCoefficient;
					FireProjectileInfo val6 = new FireProjectileInfo
					{
						projectilePrefab = projectilePrefab,
						position = val2,
						rotation = rotation,
						owner = ((Component)this).gameObject,
						damage = damage,
						force = force,
						crit = characterBody.RollCrit(),
						damageColorIndex = (DamageColorIndex)0
					};
					((FireProjectileInfo)(ref val6)).speedOverride = velocity;
					FireProjectileInfo val7 = val6;
					ProjectileManager.instance.FireProjectile(val7);
					Util.FireOptions(characterBody, val7, delegate(GameObject option, Vector3 _d)
					{
						//IL_0001: Unknown result type (might be due to invalid IL or missing references)
						//IL_000c: Unknown result type (might be due to invalid IL or missing references)
						//IL_0011: Unknown result type (might be due to invalid IL or missing references)
						//IL_0016: Unknown result type (might be due to invalid IL or missing references)
						//IL_0019: Unknown result type (might be due to invalid IL or missing references)
						Vector3 val8 = targetPosition - option.transform.position;
						return ((Vector3)(ref val8)).normalized;
					});
				}
				timer -= cooldown;
			}
			timer = Mathf.Min(cooldown, timer);
		}
	}
}