Decompiled source of RecruitableSurvivors v1.0.0

RecruitableSurvivors.dll

Decompiled 16 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using EntityStates;
using EntityStates.SurvivorPod;
using R2API;
using R2API.Utils;
using Rewired.ComponentControls.Effects;
using RoR2;
using RoR2.Hologram;
using RoR2.Navigation;
using RoR2.Skills;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("RecruitableSurvivors")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RecruitableSurvivors")]
[assembly: AssemblyTitle("RecruitableSurvivors")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace RecruitableSurvivors;

internal class Assets
{
	public static AssetBundle MainAssetBundle;

	public static T Load<T>(string name) where T : Object
	{
		return MainAssetBundle.LoadAsset<T>(name);
	}

	public static void PopulateAssets()
	{
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		if ((Object)(object)MainAssetBundle == (Object)null)
		{
			using (Stream stream = executingAssembly.GetManifestResourceStream("RecruitableSurvivors.AssetBundle." + "RecruitableSurvivors".ToLower() + "assets"))
			{
				MainAssetBundle = AssetBundle.LoadFromStream(stream);
			}
		}
	}
}
internal class SummonerTracker : MonoBehaviour
{
	public NetworkUser networkUser;

	public TeamIndex teamIndex;

	public GameObject summonerObject;

	public Inventory summonerInventory;

	public Transform exitTransform;
}
internal class PodDescent : BaseState
{
	private ShakeEmitter shakeEmitter;

	public override void OnEnter()
	{
		//IL_0078: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
		((BaseState)this).OnEnter();
		((EntityState)this).PlayAnimation("Base", Descent.InitialSpawnStateHash);
		Transform modelTransform = ((EntityState)this).GetModelTransform();
		if (!Object.op_Implicit((Object)(object)modelTransform))
		{
			return;
		}
		ChildLocator component = ((Component)modelTransform).GetComponent<ChildLocator>();
		if (Object.op_Implicit((Object)(object)component))
		{
			Transform val = component.FindChild("Travel");
			if (Object.op_Implicit((Object)(object)val))
			{
				shakeEmitter = ((Component)val).gameObject.AddComponent<ShakeEmitter>();
				shakeEmitter.wave = new Wave
				{
					amplitude = 1f,
					frequency = 180f,
					cycleOffset = 0f
				};
				shakeEmitter.duration = 10000f;
				shakeEmitter.radius = 50f;
				shakeEmitter.amplitudeTimeDecay = false;
			}
		}
	}

	public override void FixedUpdate()
	{
		((EntityState)this).FixedUpdate();
		if (((EntityState)this).isAuthority)
		{
			AuthorityFixedUpdate();
		}
	}

	protected void AuthorityFixedUpdate()
	{
		//IL_005a: 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)
		if (((EntityState)this).fixedAge > Descent.failsafeTimer)
		{
			Debug.LogError((object)$"Descent timeout {Descent.failsafeTimer}...");
			TransitionIntoNextState();
			return;
		}
		Animator modelAnimator = ((EntityState)this).GetModelAnimator();
		if (!Object.op_Implicit((Object)(object)modelAnimator))
		{
			return;
		}
		int layerIndex = modelAnimator.GetLayerIndex("Base");
		if (layerIndex != -1)
		{
			AnimatorStateInfo currentAnimatorStateInfo = modelAnimator.GetCurrentAnimatorStateInfo(layerIndex);
			if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Idle"))
			{
				TransitionIntoNextState();
			}
		}
	}

	protected virtual void TransitionIntoNextState()
	{
		((EntityState)this).outer.SetNextState((EntityState)(object)new PodLanded());
	}

	public override void OnExit()
	{
		EntityState.Destroy((Object)(object)shakeEmitter);
		((EntityState)this).OnExit();
	}
}
public class PodLanded : BaseState
{
	private PurchaseInteraction interaction;

	private SummonerTracker tracker;

	public override void OnEnter()
	{
		((BaseState)this).OnEnter();
		((EntityState)this).PlayAnimation("Base", Landed.IdleStateHash);
		Util.PlaySound("Play_UI_podSteamLoop", ((EntityState)this).gameObject);
		tracker = ((EntityState)this).GetComponent<SummonerTracker>();
		interaction = ((EntityState)this).GetComponent<PurchaseInteraction>();
		((UnityEvent<PayCostContext, PayCostResults>)(object)interaction.onDetailedPurchaseServer).AddListener((UnityAction<PayCostContext, PayCostResults>)PurchaseRequest);
	}

	private void PurchaseRequest(PayCostContext context, PayCostResults results)
	{
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		tracker.summonerObject = (Object.op_Implicit((Object)(object)context.activatorBody) ? ((Component)context.activatorBody).gameObject : null);
		tracker.summonerInventory = context.activatorInventory;
		tracker.networkUser = ((Object.op_Implicit((Object)(object)context.activatorMaster) && Object.op_Implicit((Object)(object)context.activatorMaster.playerCharacterMasterController)) ? context.activatorMaster.playerCharacterMasterController.networkUser : null);
		tracker.teamIndex = (TeamIndex)((!Object.op_Implicit((Object)(object)context.activatorBody)) ? 1 : ((int)context.activatorBody.teamComponent.teamIndex));
		interaction.SetAvailable(false);
		((EntityState)this).outer.SetNextState((EntityState)(object)new PodPreRelease());
	}

	public override void OnExit()
	{
		Util.PlaySound("Stop_UI_podSteamLoop", ((EntityState)this).gameObject);
		((EntityState)this).OnExit();
	}
}
public class PodPreRelease : BaseState
{
	private Animator modelAnimator;

	public override void OnEnter()
	{
		((BaseState)this).OnEnter();
		((EntityState)this).PlayAnimation("Base", PreRelease.IdleToReleaseStateHash);
		Util.PlaySound("Play_UI_podBlastDoorOpen", ((EntityState)this).gameObject);
		modelAnimator = ((EntityState)this).GetModelAnimator();
		if (Object.op_Implicit((Object)(object)modelAnimator))
		{
			((Component)((Component)((Component)modelAnimator).transform).GetComponent<ChildLocator>().FindChild("InitialExhaustFX")).gameObject.SetActive(true);
		}
	}

	public override void FixedUpdate()
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		((EntityState)this).FixedUpdate();
		if (!Object.op_Implicit((Object)(object)modelAnimator))
		{
			return;
		}
		int layerIndex = modelAnimator.GetLayerIndex("Base");
		if (layerIndex != -1)
		{
			AnimatorStateInfo currentAnimatorStateInfo = modelAnimator.GetCurrentAnimatorStateInfo(layerIndex);
			if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("IdleToReleaseFinished"))
			{
				((EntityState)this).outer.SetNextState((EntityState)(object)new PodRelease());
			}
		}
	}
}
public class PodRelease : BaseState
{
	public override void OnEnter()
	{
		//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_00c4: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: 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)
		((BaseState)this).OnEnter();
		((EntityState)this).PlayAnimation("Base", Release.ReleaseStateHash);
		Transform modelTransform = ((EntityState)this).GetModelTransform();
		if (Object.op_Implicit((Object)(object)modelTransform))
		{
			ChildLocator component = ((Component)modelTransform).GetComponent<ChildLocator>();
			((Component)component.FindChild("Door")).gameObject.SetActive(false);
			((Component)component.FindChild("ReleaseExhaustFX")).gameObject.SetActive(true);
		}
		SummonerTracker component2 = ((EntityState)this).GetComponent<SummonerTracker>();
		if (!NetworkServer.active)
		{
			return;
		}
		GameObject val = CharacterMaster.PickRandomSurvivorBodyPrefab(Run.instance.randomSurvivorOnRespawnRng, component2.networkUser, false);
		GameObject val2 = (Object.op_Implicit((Object)(object)val) ? MasterCatalog.GetMasterPrefab(MasterCatalog.FindAiMasterIndexForBody(val.GetComponent<CharacterBody>().bodyIndex)) : null);
		if (Object.op_Implicit((Object)(object)val2))
		{
			CharacterMaster val3 = new MasterSummon
			{
				summonerBodyObject = component2.summonerObject,
				inventoryToCopy = (MainPlugin.shareInventory.Value ? component2.summonerInventory : null),
				useAmbientLevel = true,
				ignoreTeamMemberLimit = true,
				position = component2.exitTransform.position,
				teamIndexOverride = component2.teamIndex,
				rotation = component2.exitTransform.rotation,
				masterPrefab = val2
			}.Perform();
			if (Object.op_Implicit((Object)(object)val3))
			{
				CharacterBody body = val3.GetBody();
				if (Object.op_Implicit((Object)(object)body))
				{
					body.AddBuff(Prefabs.setRespawnableBuff);
					EntityStateMachine val4 = EntityStateMachine.FindByCustomName(((Component)body).gameObject, "Body");
					if (Object.op_Implicit((Object)(object)val4))
					{
						val4.SetNextStateToMain();
					}
				}
			}
		}
		((EntityState)this).outer.SetNextState((EntityState)(object)new PodReleaseFinished());
	}
}
public class PodReleaseFinished : SurvivorPodBaseState
{
	public override void OnEnter()
	{
		((SurvivorPodBaseState)this).OnEnter();
		((EntityState)this).PlayAnimation("Base", ReleaseFinished.ReleaseStateHash);
	}
}
internal class Hook
{
	internal static void Hooks()
	{
		Stage.onServerStageBegin += Stage_onServerStageBegin;
		CharacterBody.onBodyStartGlobal += CharacterBody_onBodyStartGlobal;
	}

	private static void CharacterBody_onBodyStartGlobal(CharacterBody body)
	{
		if (body.HasBuff(Prefabs.setRespawnableBuff) && Object.op_Implicit((Object)(object)body.master))
		{
			body.master.destroyOnBodyDeath = true;
			Object.DontDestroyOnLoad((Object)(object)((Component)body.master).gameObject);
		}
	}

	private static void Stage_onServerStageBegin(Stage stage)
	{
		//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_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Expected O, but got Unknown
		if (Utils.isArtifactEnabled(Prefabs.artifact))
		{
			GameObject val = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest((SpawnCard)(object)Prefabs.podSpawnCard, new DirectorPlacementRule
			{
				placementMode = (PlacementMode)4
			}, Run.instance.stageRng));
			if (!Object.op_Implicit((Object)(object)val))
			{
				Debug.LogError((object)"[RecruitableSurvivors]: Unable to spawn pod.");
			}
		}
	}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.Dragonyck.RecruitableSurvivors", "RecruitableSurvivors", "1.0.0")]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class MainPlugin : BaseUnityPlugin
{
	public const string MODUID = "com.Dragonyck.RecruitableSurvivors";

	public const string MODNAME = "RecruitableSurvivors";

	public const string VERSION = "1.0.0";

	internal const string MODKEY = "RECRUITABLESURVIVORS_";

	internal static ConfigEntry<int> cost;

	internal static ConfigEntry<bool> shareInventory;

	private void Awake()
	{
		cost = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Recruitment Cost", 75, (ConfigDescription)null);
		shareInventory = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Share Items", true, (ConfigDescription)null);
		Assets.PopulateAssets();
		Prefabs.CreatePrefabs();
		Hook.Hooks();
	}
}
internal class Prefabs
{
	internal static GameObject podInteractable;

	internal static BuffDef setRespawnableBuff;

	internal static ArtifactDef artifact;

	internal static InteractableSpawnCard podSpawnCard;

	internal static void CreatePrefabs()
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: 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_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: 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_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Expected O, but got Unknown
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: 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_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Expected O, but got Unknown
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: 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_02e0: Unknown result type (might be due to invalid IL or missing references)
		setRespawnableBuff = Utils.NewBuffDef("SetRespawnable", stack: false, hidden: true, null, Color.clear);
		bool flag = false;
		ContentAddition.AddEntityState<PodDescent>(ref flag);
		ContentAddition.AddEntityState<PodLanded>(ref flag);
		ContentAddition.AddEntityState<PodPreRelease>(ref flag);
		ContentAddition.AddEntityState<PodRelease>(ref flag);
		ContentAddition.AddEntityState<PodReleaseFinished>(ref flag);
		LanguageAPI.Add("RECRUITABLESURVIVORS_INTERACTABLE_NAME", "Survivor Recruitment Pod");
		LanguageAPI.Add("RECRUITABLESURVIVORS_INTERACTABLE_DESCRIPTION", "Recruit a random survivor.");
		LanguageAPI.Add("RECRUITABLESURVIVORS_INTERACTABLE_CONTEXT", "Recruit");
		InspectDef val = ScriptableObject.CreateInstance<InspectDef>();
		val.Info = new InspectInfo
		{
			TitleToken = "RECRUITABLESURVIVORS_INTERACTABLE_NAME",
			DescriptionToken = "RECRUITABLESURVIVORS_INTERACTABLE_DESCRIPTION",
			Visual = Load<Sprite>("RoR2/Base/Common/MiscIcons/texSprintIcon.png")
		};
		podInteractable = Instantiate("RoR2/Base/SurvivorPod/SurvivorPod.prefab", "PodInteractable", registerNetwork: true);
		podInteractable.GetComponent<EntityStateMachine>().initialStateType = new SerializableEntityStateType(typeof(PodDescent));
		podInteractable.AddComponent<GenericInspectInfoProvider>().InspectInfo = val;
		podInteractable.AddComponent<SummonerTracker>().exitTransform = podInteractable.GetComponent<VehicleSeat>().exitPosition;
		Renderer targetRenderer = podInteractable.GetComponent<Highlight>().targetRenderer;
		((Component)targetRenderer).gameObject.AddComponent<EntityLocator>().entity = podInteractable;
		BoxCollider val2 = ((Component)targetRenderer).gameObject.AddComponent<BoxCollider>();
		val2.center = Vector3.forward * 1f;
		val2.size = new Vector3(1.7f, 2f, 3.5f);
		((Collider)val2).isTrigger = true;
		GameObject val3 = new GameObject("HoloPivot");
		val3.transform.parent = ((Component)podInteractable.GetComponent<ModelLocator>().modelTransform).GetComponent<ChildLocator>().FindChild("Base");
		val3.transform.localPosition = Vector3.up * 5.2f;
		val3.transform.localRotation = Quaternion.identity;
		val3.transform.localScale = Vector3.one;
		HologramProjector val4 = podInteractable.AddComponent<HologramProjector>();
		val4.hologramPivot = val3.transform;
		val4.displayDistance = 15f;
		Object.Destroy((Object)(object)podInteractable.GetComponent<BuffPassengerWhileSeated>());
		Object.Destroy((Object)(object)podInteractable.GetComponent<BuffPassengerWhileSeated>());
		Object.Destroy((Object)(object)podInteractable.GetComponent<SurvivorPodController>());
		Object.Destroy((Object)(object)podInteractable.GetComponent<VehicleSeat>());
		Object.Destroy((Object)(object)podInteractable.GetComponent<EntityLocator>());
		InstantiatePrefabBehavior[] components = podInteractable.GetComponents<InstantiatePrefabBehavior>();
		for (int i = 0; i < components.Length; i++)
		{
			Object.Destroy((Object)(object)components[i]);
		}
		PurchaseInteraction val5 = podInteractable.AddComponent<PurchaseInteraction>();
		val5.displayNameToken = val.Info.TitleToken;
		val5.contextToken = "RECRUITABLESURVIVORS_INTERACTABLE_CONTEXT";
		val5.cost = MainPlugin.cost.Value;
		val5.Networkcost = val5.cost;
		val5.costType = (CostTypeIndex)1;
		val5.NetworkcostType = (CostTypeIndex)1;
		val5.shouldProximityHighlight = true;
		GenericDisplayNameProvider val6 = podInteractable.AddComponent<GenericDisplayNameProvider>();
		val6.displayToken = val5.displayNameToken;
		podSpawnCard = Object.Instantiate<InteractableSpawnCard>(Load<InteractableSpawnCard>("RoR2/Base/ShrineChance/iscShrineChance.asset"));
		podSpawnCard.maxSpawnsPerStage = 1;
		((SpawnCard)podSpawnCard).directorCreditCost = 0;
		((SpawnCard)podSpawnCard).prefab = podInteractable;
		podSpawnCard.skipSpawnWhenSacrificeArtifactEnabled = false;
		artifact = NewArtifact("SURVIVORPOD", "Recruitment", "At least one Survivor Recruitment Pod spawns every stage, allowing you to recruit a random survivor.");
	}

	internal static ArtifactDef NewArtifact(string token, string name, string description, Sprite smallIconSelectedSprite = null, Sprite smallIconDeselectedSprite = null)
	{
		LanguageAPI.Add("RECRUITABLESURVIVORS_" + token + "_NAME", "Artifact of " + name);
		LanguageAPI.Add("RECRUITABLESURVIVORS_" + token + "_DESCRIPTION", description);
		ArtifactDef val = ScriptableObject.CreateInstance<ArtifactDef>();
		val.cachedName = "RECRUITABLESURVIVORS_" + token;
		val.nameToken = "RECRUITABLESURVIVORS_" + token + "_NAME";
		val.descriptionToken = "RECRUITABLESURVIVORS_" + token + "_DESCRIPTION";
		string text = "icon";
		Sprite val2 = Assets.Load<Sprite>(text);
		val.smallIconSelectedSprite = (Object.op_Implicit((Object)(object)val2) ? val2 : Load<Sprite>("RoR2/Junk/Misc/texHandSelect.png"));
		val.smallIconDeselectedSprite = (Object.op_Implicit((Object)(object)val2) ? Assets.Load<Sprite>(text + "Disabled") : Load<Sprite>("RoR2/Junk/Misc/texHandSelectDisabled.png"));
		ContentAddition.AddArtifactDef(val);
		return val;
	}

	internal static T Load<T>(string path)
	{
		//IL_0002: 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)
		return Addressables.LoadAssetAsync<T>((object)path).WaitForCompletion();
	}

	internal static GameObject Instantiate(string path, string name, bool registerNetwork = false)
	{
		return PrefabAPI.InstantiateClone(Load<GameObject>(path), name, registerNetwork);
	}

	internal static GameObject Instantiate(GameObject obj, string name, bool registerNetwork = false)
	{
		return PrefabAPI.InstantiateClone(obj, name, registerNetwork);
	}
}
internal static class Extensions
{
	public static GameObject NewSyringe(this GameObject g, params Material[] m)
	{
		((Renderer)g.GetComponentsInChildren<MeshRenderer>(false)[0]).material = m[0];
		((Renderer)g.GetComponent<TrailRenderer>()).material = m[1];
		((Renderer)g.GetComponent<ParticleSystemRenderer>()).material = m[2];
		return g;
	}

	public static Material SwapTexture(this Material m, Texture2D t)
	{
		m.mainTexture = (Texture)(object)t;
		return m;
	}

	public static GameObject SwapMaterials(this GameObject g, Material[] m)
	{
		Renderer[] componentsInChildren = g.GetComponentsInChildren<Renderer>();
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			if (Object.op_Implicit((Object)(object)m[i]))
			{
				componentsInChildren[i].material = m[i];
			}
		}
		return g;
	}

	public static float Mult(this float f, float mult = 100f)
	{
		return f * mult;
	}

	public static Color ToRGB255(this Color c, string title, string body)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: 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_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		return new Color(c.r / 255f, c.g / 255f, c.b / 255f);
	}

	public static void SetStrings(this TooltipProvider t, string title, string body)
	{
		t.overrideTitleText = title;
		t.overrideBodyText = body;
	}
}
internal class Utils
{
	public static BuffDef NewBuffDef(string name, bool stack, bool hidden, Sprite sprite, Color color)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		BuffDef val = ScriptableObject.CreateInstance<BuffDef>();
		((Object)val).name = name;
		val.canStack = stack;
		val.isHidden = hidden;
		val.iconSprite = sprite;
		val.buffColor = color;
		ContentAddition.AddBuffDef(val);
		return val;
	}

	internal static bool isArtifactEnabled(ArtifactDef artifact)
	{
		if (!Object.op_Implicit((Object)(object)artifact) || !Object.op_Implicit((Object)(object)RunArtifactManager.instance))
		{
			return false;
		}
		return RunArtifactManager.instance.IsArtifactEnabled(artifact);
	}

	internal static void DisablePooling(GameObject obj)
	{
		VFXAttributes val = obj.GetComponent<VFXAttributes>();
		if (!Object.op_Implicit((Object)(object)val))
		{
			val = obj.AddComponent<VFXAttributes>();
		}
		val.DoNotCullPool = true;
		val.DoNotPool = true;
	}

	internal static void RecolorEffect(GameObject obj, Color color)
	{
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)obj))
		{
			return;
		}
		OmniEffect component = obj.GetComponent<OmniEffect>();
		if (Object.op_Implicit((Object)(object)component))
		{
			Object.DestroyImmediate((Object)(object)obj.GetComponent<OmniEffect>());
		}
		Renderer[] componentsInChildren = obj.GetComponentsInChildren<Renderer>(Object.op_Implicit((Object)(object)component));
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			((Component)componentsInChildren[i]).gameObject.SetActive(true);
			if (Object.op_Implicit((Object)(object)componentsInChildren[i].material) && componentsInChildren[i].material.HasProperty("_TintColor"))
			{
				componentsInChildren[i].material.SetColor("_TintColor", color);
			}
		}
	}

	public static Vector3 FindNearestNodePosition(Vector3 targetPosition, GraphType nodeGraphType)
	{
		//IL_0009: 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_0010: 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_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: 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_004a: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Expected O, but got Unknown
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//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_0089: Unknown result type (might be due to invalid IL or missing references)
		SpawnCard val = ScriptableObject.CreateInstance<SpawnCard>();
		val.hullSize = (HullClassification)1;
		val.nodeGraphType = nodeGraphType;
		val.prefab = Prefabs.Load<GameObject>("RoR2/Base/Common/DirectorSpawnProbeHelperPrefab.prefab");
		Vector3 result = targetPosition;
		GameObject val2 = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(val, new DirectorPlacementRule
		{
			placementMode = (PlacementMode)3,
			position = targetPosition
		}, RoR2Application.rng));
		if (Object.op_Implicit((Object)(object)val2))
		{
			result = val2.transform.position;
		}
		if (Object.op_Implicit((Object)(object)val2))
		{
			Object.Destroy((Object)(object)val2);
		}
		Object.Destroy((Object)(object)val);
		return result;
	}

	public static Vector3 GetForwardDirection(Vector3 dir)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: 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_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: 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_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		Vector2 val = Util.Vector3XZToVector2XY(dir);
		if (val != Vector2.zero)
		{
			((Vector2)(ref val)).Normalize();
			Vector3 val2 = new Vector3(val.x, 0f, val.y);
			return ((Vector3)(ref val2)).normalized;
		}
		return dir;
	}

	public static void PlayAnimation(GameObject g, string layerName, string animationStateName)
	{
		Animator component = g.GetComponent<Animator>();
		if (Object.op_Implicit((Object)(object)component))
		{
			int layerIndex = component.GetLayerIndex(layerName);
			component.speed = 1f;
			component.Update(0f);
			component.PlayInFixedTime(animationStateName, layerIndex, 0f);
		}
	}

	public static void PlayAnimation(GameObject g, string layerName, string animationStateName, string playbackRateParam, float duration)
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		Animator component = g.GetComponent<Animator>();
		if (Object.op_Implicit((Object)(object)component))
		{
			component.speed = 1f;
			component.Update(0f);
			int layerIndex = component.GetLayerIndex(layerName);
			component.SetFloat(playbackRateParam, 1f);
			component.PlayInFixedTime(animationStateName, layerIndex, 0f);
			component.Update(0f);
			AnimatorStateInfo currentAnimatorStateInfo = component.GetCurrentAnimatorStateInfo(layerIndex);
			float length = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).length;
			component.SetFloat(playbackRateParam, length / duration);
		}
	}

	public static void AnimatorPlayAnimation(Animator modelAnimator, string layerName, string animationStateName)
	{
		int layerIndex = modelAnimator.GetLayerIndex(layerName);
		modelAnimator.speed = 1f;
		modelAnimator.Update(0f);
		modelAnimator.PlayInFixedTime(animationStateName, layerIndex, 0f);
	}

	public static void AnimatorPlayAnimation(Animator modelAnimator, string layerName, string animationStateName, string playbackRateParam, float duration)
	{
		//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)
		modelAnimator.speed = 1f;
		modelAnimator.Update(0f);
		int layerIndex = modelAnimator.GetLayerIndex(layerName);
		modelAnimator.SetFloat(playbackRateParam, 1f);
		modelAnimator.PlayInFixedTime(animationStateName, layerIndex, 0f);
		modelAnimator.Update(0f);
		AnimatorStateInfo currentAnimatorStateInfo = modelAnimator.GetCurrentAnimatorStateInfo(layerIndex);
		float length = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).length;
		modelAnimator.SetFloat(playbackRateParam, length / duration);
	}

	public static Color HexTo10(string hexColor)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: 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_0039: Unknown result type (might be due to invalid IL or missing references)
		char[] array = hexColor.ToCharArray();
		return new Color((float)(array[0] + array[1]), (float)(array[2] + array[3]), (float)(array[4] + array[5]), 255f) / 255f;
	}

	public static EntityStateMachine NewStateMachine<T>(GameObject obj, string customName) where T : EntityState
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: 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)
		SerializableEntityStateType val = default(SerializableEntityStateType);
		((SerializableEntityStateType)(ref val))..ctor(typeof(T));
		EntityStateMachine val2 = obj.AddComponent<EntityStateMachine>();
		val2.customName = customName;
		val2.initialStateType = val;
		val2.mainStateType = val;
		return val2;
	}

	public static void AddAlt(SkillFamily skillFamily, SkillDef SkillDef)
	{
		//IL_0029: 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: Expected O, but got Unknown
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		Array.Resize(ref skillFamily.variants, skillFamily.variants.Length + 1);
		Variant[] variants = skillFamily.variants;
		int num = skillFamily.variants.Length - 1;
		Variant val = new Variant
		{
			skillDef = SkillDef
		};
		((Variant)(ref val)).viewableNode = new Node(SkillDef.skillNameToken, false, (Node)null);
		variants[num] = val;
	}

	public static ObjectScaleCurve AddScaleComponent(GameObject target, float timeMax)
	{
		ObjectScaleCurve val = target.AddComponent<ObjectScaleCurve>();
		val.useOverallCurveOnly = true;
		val.timeMax = timeMax;
		val.overallCurve = AnimationCurve.Linear(0f, 0f, 1f, 1f);
		return val;
	}

	public static RotateAroundAxis AddRotationComponent(GameObject target, float speed, RotationAxis axis)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		RotateAroundAxis val = target.AddComponent<RotateAroundAxis>();
		val.speed = (Speed)2;
		val.fastRotationSpeed = speed;
		val.rotateAroundAxis = axis;
		return val;
	}

	public static AnimateShaderAlpha AddShaderAlphaComponent(GameObject target, float timeMax, AnimationCurve curve, bool destroyOnEnd = true, bool disableOnEnd = false)
	{
		AnimateShaderAlpha val = target.AddComponent<AnimateShaderAlpha>();
		val.timeMax = timeMax;
		val.alphaCurve = curve;
		val.destroyOnEnd = destroyOnEnd;
		val.disableOnEnd = disableOnEnd;
		return val;
	}

	internal static Sprite CreateSprite(Texture2D tex)
	{
		//IL_001a: 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)
		return Sprite.Create(tex, new Rect(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height), new Vector2(0.5f, 0.5f), 128f);
	}

	internal static T CopyComponent<T>(T original, GameObject destination) where T : Component
	{
		Type type = ((object)original).GetType();
		Component val = destination.AddComponent(type);
		FieldInfo[] fields = type.GetFields();
		FieldInfo[] array = fields;
		foreach (FieldInfo fieldInfo in array)
		{
			fieldInfo.SetValue(val, fieldInfo.GetValue(original));
		}
		return (T)(object)((val is T) ? val : null);
	}

	public static Sprite CreateSpriteFromTexture(Texture2D texture)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)texture))
		{
			return Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0.5f, 0.5f));
		}
		return null;
	}

	public static GameObject FindInActiveObjectByName(string name)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Invalid comparison between Unknown and I4
		Transform[] array = Resources.FindObjectsOfTypeAll<Transform>();
		for (int i = 0; i < array.Length; i++)
		{
			if ((int)((Object)array[i]).hideFlags == 0 && ((Object)array[i]).name == name)
			{
				return ((Component)array[i]).gameObject;
			}
		}
		return null;
	}

	public static void CreateHitboxes(string name, Transform parent, Vector3[] sizes, Vector3[] positions)
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Expected O, but got Unknown
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		HitBoxGroup val = ((Component)parent).gameObject.AddComponent<HitBoxGroup>();
		val.groupName = name;
		List<HitBox> list = new List<HitBox>();
		for (int i = 0; i < sizes.Length; i++)
		{
			GameObject val2 = new GameObject(name + (i + 1));
			val2.transform.SetParent(parent);
			val2.transform.localPosition = positions[i];
			val2.transform.localRotation = Quaternion.Euler(Vector3.forward * 45f);
			val2.transform.localScale = sizes[i];
			HitBox item = val2.AddComponent<HitBox>();
			val2.layer = LayerIndex.projectile.intVal;
			list.Add(item);
		}
		val.hitBoxes = list.ToArray();
	}

	public static GameObject CreateHitbox(string name, Transform parent, Vector3 scale, Vector3 localPosition)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_001b: 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_0032: 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_0048: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.transform.SetParent(parent);
		val.transform.localPosition = localPosition;
		val.transform.localRotation = Quaternion.Euler(Vector3.forward * 45f);
		val.transform.localScale = scale;
		HitBoxGroup val2 = ((Component)parent).gameObject.AddComponent<HitBoxGroup>();
		HitBox val3 = val.AddComponent<HitBox>();
		val.layer = LayerIndex.projectile.intVal;
		val2.hitBoxes = (HitBox[])(object)new HitBox[1] { val3 };
		val2.groupName = name;
		return val;
	}

	public static Material FindMaterial(string name)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Invalid comparison between Unknown and I4
		Material[] array = Resources.FindObjectsOfTypeAll<Material>();
		for (int i = 0; i < array.Length; i++)
		{
			if ((int)((Object)array[i]).hideFlags == 0 && ((Object)array[i]).name == name)
			{
				return array[i];
			}
		}
		return null;
	}
}