Decompiled source of SurvivorRandomizer v1.0.1

SurvivorRandomizer.dll

Decompiled a day 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 EntityStates;
using HG.Reflection;
using On.RoR2;
using R2API;
using R2API.Utils;
using Rewired.ComponentControls.Effects;
using RoR2;
using RoR2.ExpansionManagement;
using RoR2.Skills;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.UI;

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

internal class DelayedOverlay : MonoBehaviour
{
	private void Start()
	{
		//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)
		EffectManager.SimpleEffect(Prefabs.gummyExplosion, ((Component)this).transform.position, Quaternion.identity, false);
		Util.PlaySound("Play_item_use_gummyClone_spawn", ((Component)this).gameObject);
	}
}
internal class RandomizerBehaviour : MonoBehaviour
{
	public float stopwatch;

	public float interval = MainPlugin.randomizeInterval.Value;

	private CharacterMaster master;

	private GameObject bodyInstance;

	private CharacterBody currentBody;

	private bool triggerRandomization;

	private bool justSpawned;

	private bool removeInvincibility;

	private bool hadInvincibility;

	private float healthPercentage;

	private float barrierPercentage;

	private float shieldPercentage;

	private List<SurvivorDef> survivors = new List<SurvivorDef>();

	private void Start()
	{
		master = ((Component)this).GetComponent<CharacterMaster>();
		master.onBodyStart += Master_onBodyStart;
	}

	private void Master_onBodyStart(CharacterBody body)
	{
		currentBody = body;
		justSpawned = true;
		if (NetworkServer.active)
		{
			HealthComponent healthComponent = body.healthComponent;
			if (healthPercentage > 0f)
			{
				healthComponent.Networkhealth = healthComponent.fullHealth * healthPercentage;
			}
			if (barrierPercentage > 0f)
			{
				healthComponent.Networkbarrier = healthComponent.fullBarrier * barrierPercentage;
			}
			if (shieldPercentage > 0f)
			{
				healthComponent.Networkshield = healthComponent.fullShield * shieldPercentage;
			}
			healthPercentage = 0f;
			barrierPercentage = 0f;
			shieldPercentage = 0f;
			removeInvincibility = !hadInvincibility;
		}
		if (MainPlugin.enableGoo.Value)
		{
			((Component)body).gameObject.AddComponent<DelayedOverlay>();
		}
	}

	private void FixedUpdate()
	{
		if (!Object.op_Implicit((Object)(object)master) || (Object.op_Implicit((Object)(object)master) && !Object.op_Implicit((Object)(object)master.bodyInstanceObject)) || master.lostBodyToDeath)
		{
			stopwatch = 0f;
			return;
		}
		if (justSpawned && Object.op_Implicit((Object)(object)currentBody) && currentBody.hasEffectiveAuthority)
		{
			justSpawned = false;
			EntityStateMachine val = Array.Find(((Component)currentBody).GetComponents<EntityStateMachine>(), (EntityStateMachine x) => x.customName == "Body");
			if (Object.op_Implicit((Object)(object)val))
			{
				val.SetNextStateToMain();
			}
		}
		if (removeInvincibility && Object.op_Implicit((Object)(object)currentBody))
		{
			removeInvincibility = false;
			if (NetworkServer.active && currentBody.HasBuff(Buffs.HiddenInvincibility))
			{
				currentBody.RemoveBuff(Buffs.HiddenInvincibility);
				currentBody.ClearTimedBuffs(Buffs.HiddenInvincibility);
			}
		}
		if (!Object.op_Implicit((Object)(object)bodyInstance))
		{
			bodyInstance = master.bodyInstanceObject;
			if (Object.op_Implicit((Object)(object)bodyInstance) && MainPlugin.randomizeOnStart.Value)
			{
				Stage.onStageStartGlobal += delegate
				{
					triggerRandomization = true;
				};
			}
		}
		if (triggerRandomization)
		{
			triggerRandomization = false;
			Randomize();
		}
		stopwatch += Time.fixedDeltaTime;
		if (stopwatch >= interval)
		{
			stopwatch = 0f;
			triggerRandomization = true;
		}
	}

	private GameObject GetBodyPrefab()
	{
		if (survivors == null || survivors.Count == 0)
		{
			survivors.AddRange(Prefabs.survivorDefs);
			survivors.RemoveAll((SurvivorDef x) => Object.op_Implicit((Object)(object)x.bodyPrefab.GetComponent<ExpansionRequirementComponent>()) && !Run.instance.IsExpansionEnabled(x.bodyPrefab.GetComponent<ExpansionRequirementComponent>().requiredExpansion));
		}
		return survivors[RoR2Application.rng.RangeInt(0, survivors.Count)].bodyPrefab;
	}

	private void Randomize()
	{
		//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_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: 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)
		bool flag = !Object.op_Implicit((Object)(object)master);
		bool flag2 = Object.op_Implicit((Object)(object)master) && !Object.op_Implicit((Object)(object)master.bodyInstanceObject);
		if (!NetworkServer.active || flag || flag2)
		{
			if (flag)
			{
				Debug.LogWarning((object)"[SurvivorRandomizer]: No CharacterMaster");
			}
			if (flag2)
			{
				Debug.LogWarning((object)"[SurvivorRandomizer]: No Body Instance");
			}
			return;
		}
		master.bodyPrefab = GetBodyPrefab();
		CharacterBody component = master.bodyPrefab.GetComponent<CharacterBody>();
		CharacterBody body = master.GetBody();
		HealthComponent healthComponent = body.healthComponent;
		Transform component2 = master.bodyInstanceObject.GetComponent<Transform>();
		Vector3 position = component2.position;
		Quaternion rotation = component2.rotation;
		healthPercentage = ((healthComponent.Networkhealth < healthComponent.fullHealth) ? (healthComponent.Networkhealth / healthComponent.fullHealth) : 0f);
		barrierPercentage = ((healthComponent.Networkbarrier > 0f) ? (healthComponent.Networkbarrier / healthComponent.fullBarrier) : 0f);
		shieldPercentage = ((healthComponent.Networkshield > 0f) ? (healthComponent.Networkshield / healthComponent.fullShield) : 0f);
		hadInvincibility = body.HasBuff(Buffs.HiddenInvincibility);
		master.DestroyBody();
		position = master.CalculateSafeGroundPosition(position, component);
		currentBody = master.SpawnBody(position, rotation);
		HereticInitialStateHelper component3 = ((Component)currentBody).GetComponent<HereticInitialStateHelper>();
		if (Object.op_Implicit((Object)(object)component3))
		{
			component3.PrepareTransformation();
		}
		justSpawned = true;
	}
}
internal class UIBehaviour : MonoBehaviour
{
	public GameObject bar;

	public Image barImage;

	public RandomizerBehaviour behaviour;

	public HUD hud;

	private void Awake()
	{
		hud = ((Component)this).GetComponent<HUD>();
	}

	private void Update()
	{
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)behaviour))
		{
			barImage.fillAmount = 0f;
			if (Object.op_Implicit((Object)(object)hud) && Object.op_Implicit((Object)(object)hud.targetMaster))
			{
				behaviour = ((Component)hud.targetMaster).GetComponent<RandomizerBehaviour>();
				if (Object.op_Implicit((Object)(object)behaviour))
				{
					bar.transform.localPosition = new Vector3(-210f, -40f, 0f);
					bar.SetActive(true);
				}
			}
		}
		else
		{
			barImage.fillAmount = behaviour.stopwatch / behaviour.interval;
		}
	}
}
internal class Hook
{
	internal static void Hooks()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		CharacterMaster.onStartGlobal += CharacterMaster_onStartGlobal;
		CharacterModel.IsGummyClone += new hook_IsGummyClone(CharacterModel_IsGummyClone);
	}

	private static bool CharacterModel_IsGummyClone(orig_IsGummyClone orig, CharacterModel self)
	{
		if (Object.op_Implicit((Object)(object)self.body) && Object.op_Implicit((Object)(object)((Component)self.body).GetComponent<DelayedOverlay>()))
		{
			return true;
		}
		return orig.Invoke(self);
	}

	private static void CharacterMaster_onStartGlobal(CharacterMaster master)
	{
		if (Object.op_Implicit((Object)(object)master.playerCharacterMasterController) && Run.instance.IsExpansionEnabled(Prefabs.expansion))
		{
			RandomizerBehaviour component = ((Component)master).GetComponent<RandomizerBehaviour>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				component = ((Component)master).gameObject.AddComponent<RandomizerBehaviour>();
			}
		}
	}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.Dragonyck.SurvivorRandomizer", "SurvivorRandomizer", "1.0.0")]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class MainPlugin : BaseUnityPlugin
{
	public const string MODUID = "com.Dragonyck.SurvivorRandomizer";

	public const string MODNAME = "SurvivorRandomizer";

	public const string VERSION = "1.0.0";

	internal static ConfigEntry<bool> enableGoo;

	internal static ConfigEntry<bool> randomizeOnStart;

	internal static ConfigEntry<float> randomizeInterval;

	internal static ConfigEntry<string> blacklist;

	private void Awake()
	{
		enableGoo = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Goobo Overlay Effect", true, (ConfigDescription)null);
		randomizeOnStart = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Randomize On Stage Start", true, (ConfigDescription)null);
		randomizeInterval = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Randomizer Interval", 30f, (ConfigDescription)null);
		blacklist = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Survivor Blacklist", "HereticBody;", "Use their body code names, and ; as a separator.");
		Assets.PopulateAssets();
		Prefabs.CreatePrefabs();
		Hook.Hooks();
	}
}
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("SurvivorRandomizer.AssetBundle." + "SurvivorRandomizer".ToLower() + "assets"))
			{
				MainAssetBundle = AssetBundle.LoadFromStream(stream);
			}
		}
	}
}
internal class Prefabs
{
	internal static List<SurvivorDef> survivorDefs;

	internal static GameObject gummyExplosion;

	internal static Material gummyCloneMat;

	internal static ExpansionDef expansion;

	[SystemInitializer(new Type[] { typeof(SurvivorCatalog) })]
	internal static void UpdateSurvivorDefs()
	{
		string[] blacklist = MainPlugin.blacklist.Value.Split(';');
		survivorDefs = new List<SurvivorDef>();
		survivorDefs.AddRange(SurvivorCatalog.survivorDefs);
		survivorDefs.RemoveAll((SurvivorDef x) => (Object)(object)x.bodyPrefab == (Object)null || blacklist.Contains(((Object)x.bodyPrefab).name));
	}

	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 void CreatePrefabs()
	{
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Expected O, but got Unknown
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Expected O, but got Unknown
		//IL_00a7: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		gummyExplosion = Load<GameObject>("RoR2/DLC1/GummyClone/GummyCloneExplosion.prefab");
		gummyCloneMat = Load<Material>("RoR2/DLC1/GummyClone/matGummyClone.mat");
		GameObject val = Load<GameObject>("RoR2/Base/UI/HUDSimple.prefab");
		Object.DontDestroyOnLoad((Object)(object)val);
		HUD component = val.GetComponent<HUD>();
		Transform transform = ((Component)component.expBar).transform;
		GameObject val2 = new GameObject("RandomizerBar", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val2.layer = LayerIndex.ui.intVal;
		RectTransform val3 = (RectTransform)val2.transform;
		((Transform)val3).SetParent(transform);
		((Transform)val3).localPosition = new Vector3(-210f, -40f, 0f);
		((Transform)val3).localRotation = Quaternion.identity;
		((Transform)val3).localScale = Vector3.one;
		val3.sizeDelta = new Vector2(422f, 10f);
		Image component2 = val2.GetComponent<Image>();
		component2.fillAmount = 0f;
		component2.type = (Type)3;
		component2.fillMethod = (FillMethod)0;
		component2.sprite = Load<Sprite>("RoR2/Base/Common/texUIHurtHealthbar.png");
		val2.SetActive(false);
		UIBehaviour uIBehaviour = ((Component)component).gameObject.AddComponent<UIBehaviour>();
		uIBehaviour.bar = val2;
		uIBehaviour.barImage = component2;
		LanguageAPI.Add("SRANDOM_EXPANSION_NAME", "Survivor Randomizer");
		LanguageAPI.Add("SRANDOM_EXPANSION_DESCRIPTION", "Enables survivor randomization.");
		expansion = ScriptableObject.CreateInstance<ExpansionDef>();
		((Object)expansion).name = "SurvivorRandomizerExpansionDef";
		expansion.nameToken = "SRANDOM_EXPANSION_NAME";
		expansion.descriptionToken = "SRANDOM_EXPANSION_DESCRIPTION";
		expansion.iconSprite = Assets.Load<Sprite>("expansionIcon");
		expansion.disabledIconSprite = Load<Sprite>("RoR2/Base/Common/MiscIcons/texUnlockIcon.png");
		ContentAddition.AddExpansionDef(expansion);
	}
}
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 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 SkillDef NewSkillDef<T>(Type activationState, string activationStateMachineName, int baseMaxStock, float baseRechargeInterval, bool beginSkillCooldownOnSkillEnd, bool canceledFromSprinting, bool fullRestockOnAssign, InterruptPriority interruptPriority, bool isCombatSkill, bool mustKeyPress, bool cancelSprintingOnActivation, int rechargeStock, int requiredStock, int stockToConsume, Sprite icon, string skillDescriptionToken, string skillName, params string[] keywordTokens) where T : SkillDef
	{
		//IL_000e: 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_0069: 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)
		T val = ScriptableObject.CreateInstance<T>();
		((SkillDef)val).activationState = new SerializableEntityStateType(activationState);
		((SkillDef)val).activationStateMachineName = activationStateMachineName;
		((SkillDef)val).baseMaxStock = baseMaxStock;
		((SkillDef)val).baseRechargeInterval = baseRechargeInterval;
		((SkillDef)val).beginSkillCooldownOnSkillEnd = beginSkillCooldownOnSkillEnd;
		((SkillDef)val).canceledFromSprinting = canceledFromSprinting;
		((SkillDef)val).fullRestockOnAssign = fullRestockOnAssign;
		((SkillDef)val).interruptPriority = interruptPriority;
		((SkillDef)val).isCombatSkill = isCombatSkill;
		((SkillDef)val).mustKeyPress = mustKeyPress;
		((SkillDef)val).cancelSprintingOnActivation = cancelSprintingOnActivation;
		((SkillDef)val).rechargeStock = rechargeStock;
		((SkillDef)val).requiredStock = requiredStock;
		((SkillDef)val).stockToConsume = stockToConsume;
		((SkillDef)val).icon = icon;
		((SkillDef)val).skillDescriptionToken = skillDescriptionToken;
		((SkillDef)val).skillName = skillName;
		((SkillDef)val).skillNameToken = ((SkillDef)val).skillName;
		((SkillDef)val).keywordTokens = keywordTokens;
		ContentAddition.AddSkillDef((SkillDef)(object)val);
		return (SkillDef)(object)val;
	}

	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 GenericSkill NewGenericSkill(GameObject obj, SkillDef skill)
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Expected O, but got Unknown
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		GenericSkill val = obj.AddComponent<GenericSkill>();
		SkillFamily val2 = ScriptableObject.CreateInstance<SkillFamily>();
		val2.variants = (Variant[])(object)new Variant[1];
		val._skillFamily = val2;
		SkillFamily skillFamily = val.skillFamily;
		Variant[] variants = skillFamily.variants;
		Variant val3 = new Variant
		{
			skillDef = skill
		};
		((Variant)(ref val3)).viewableNode = new Node(skill.skillNameToken, false, (Node)null);
		variants[0] = val3;
		ContentAddition.AddSkillFamily(skillFamily);
		return val;
	}

	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 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;
	}

	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_0073: 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.identity;
			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_0039: 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.identity;
		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;
	}

	internal static EffectComponent RegisterEffect(GameObject effect, float duration, string soundName = "", bool applyScale = false, bool parentToReferencedTransform = true, bool positionAtReferencedTransform = true)
	{
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		EffectComponent val = effect.GetComponent<EffectComponent>();
		if (!Object.op_Implicit((Object)(object)val))
		{
			val = effect.AddComponent<EffectComponent>();
		}
		if (duration != -1f)
		{
			DestroyOnTimer component = effect.GetComponent<DestroyOnTimer>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				effect.AddComponent<DestroyOnTimer>().duration = duration;
			}
			else
			{
				component.duration = duration;
			}
		}
		if (!Object.op_Implicit((Object)(object)effect.GetComponent<NetworkIdentity>()))
		{
			effect.AddComponent<NetworkIdentity>();
		}
		if (!Object.op_Implicit((Object)(object)effect.GetComponent<VFXAttributes>()))
		{
			effect.AddComponent<VFXAttributes>().vfxPriority = (VFXPriority)2;
		}
		val.applyScale = applyScale;
		val.effectIndex = (EffectIndex)(-1);
		val.parentToReferencedTransform = parentToReferencedTransform;
		val.positionAtReferencedTransform = positionAtReferencedTransform;
		val.soundName = soundName;
		ContentAddition.AddEffect(effect);
		return val;
	}

	public static Material InstantiateMaterial(Color color, Texture tex, Color emColor, float emPower, Texture emTex, float normStr, Texture normTex)
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		Material val = Object.Instantiate<Material>(LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterBodies/CommandoBody").GetComponentInChildren<CharacterModel>().baseRendererInfos[0].defaultMaterial);
		if (Object.op_Implicit((Object)(object)val))
		{
			val.SetColor("_Color", color);
			val.SetTexture("_MainTex", tex);
			val.SetColor("_EmColor", emColor);
			val.SetFloat("_EmPower", emPower);
			val.SetTexture("_EmTex", emTex);
			val.SetFloat("_NormalStrength", 1f);
			val.SetTexture("_NormalTex", normTex);
			return val;
		}
		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;
	}
}