Decompiled source of ChensHelpers v1.1.4

ChensHelpers.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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.Logging;
using Chen.Helpers.CollectionHelpers;
using Chen.Helpers.GeneralHelpers;
using Chen.Helpers.LogHelpers;
using Chen.Helpers.UnityHelpers;
using On.RoR2.Networking;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Networking;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("ChensHelpers")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2")]
[assembly: AssemblyProduct("ChensHelpers")]
[assembly: AssemblyTitle("ChensHelpers")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/cheeeeeeeeeen/RoR2-ChensHelpers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.2.0")]
[module: UnverifiableCode]
namespace Chen.Helpers
{
	[BepInPlugin("com.Chen.ChensHelpers", "ChensHelpers", "1.1.4")]
	[BepInDependency("com.bepis.r2api", "5.1.2")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[R2APISubmoduleDependency(new string[] { "SoundAPI", "NetworkingAPI" })]
	public class HelperPlugin : BaseUnityPlugin
	{
		public const string ModVer = "1.1.4";

		public const string ModName = "ChensHelpers";

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

		internal static Log Log { get; private set; }

		private void Awake()
		{
			Log = new Log(((BaseUnityPlugin)this).Logger);
			NetworkingAPI.RegisterMessageType<MinionExtensions.SyncOwner>();
		}
	}
}
namespace Chen.Helpers.UnityHelpers
{
	public static class Extensions
	{
		public static T GetOrAddComponent<T>(this GameObject gameObject) where T : Component
		{
			T val = gameObject.GetComponent<T>();
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = gameObject.AddComponent<T>();
			}
			return val;
		}

		public static T GetOrAddComponent<T>(this Component component) where T : Component
		{
			return component.gameObject.GetOrAddComponent<T>();
		}

		public static T GetOrAddComponent<T>(this GameObject gameObject, Action<T> action) where T : Component
		{
			T orAddComponent = gameObject.GetOrAddComponent<T>();
			action(orAddComponent);
			return orAddComponent;
		}

		public static T GetOrAddComponent<T>(this Component component, Action<T> action) where T : Component
		{
			return component.gameObject.GetOrAddComponent(action);
		}

		public static T GetOrAddComponent<T>(this GameObject gameObject, Action<T> getAction, Action<T> addAction) where T : Component
		{
			T val = gameObject.GetComponent<T>();
			if (Object.op_Implicit((Object)(object)val))
			{
				getAction(val);
			}
			else
			{
				val = gameObject.AddComponent<T>();
				addAction(val);
			}
			return val;
		}

		public static T GetOrAddComponent<T>(this Component component, Action<T> getAction, Action<T> addAction) where T : Component
		{
			return component.gameObject.GetOrAddComponent(getAction, addAction);
		}

		public static List<T> DeepCopyComponentsFrom<T>(this GameObject targetGameObject, GameObject sourceGameObject) where T : Component
		{
			List<T> list = new List<T>();
			T[] components = sourceGameObject.GetComponents<T>();
			T[] array = components;
			foreach (T originalComponent in array)
			{
				T item = originalComponent.DeepCopy(targetGameObject);
				list.Add(item);
			}
			return list;
		}

		public static List<T> DeepCopyComponentsTo<T>(this GameObject sourceGameObject, GameObject targetGameObject) where T : Component
		{
			return targetGameObject.DeepCopyComponentsFrom<T>(sourceGameObject);
		}

		public static T DeepCopy<T>(this T originalComponent, GameObject targetGameObject) where T : Component
		{
			T val = targetGameObject.AddComponent<T>();
			FieldInfo[] fields = typeof(T).GetFields();
			FieldInfo[] array = fields;
			foreach (FieldInfo fieldInfo in array)
			{
				fieldInfo.SetValue(val, fieldInfo.GetValue(originalComponent));
			}
			return val;
		}
	}
	public abstract class ListProcessor<T> : MonoBehaviour
	{
		protected List<T> processList = new List<T>();

		private float intervalTimer;

		private readonly List<T> failedItems = new List<T>();

		protected abstract bool repeatUntilSuccess { get; set; }

		protected abstract float processInterval { get; set; }

		public virtual bool Add(T item)
		{
			return processList.ConditionalAdd(item, (T listItem) => item.Equals(listItem));
		}

		protected abstract bool Process(T item);

		protected virtual void OnSuccess(T item)
		{
		}

		protected virtual void OnFailure(T item)
		{
			if (repeatUntilSuccess)
			{
				failedItems.Add(item);
			}
		}

		protected virtual void FixedUpdate()
		{
			intervalTimer += Time.fixedDeltaTime;
			if (!(intervalTimer >= processInterval))
			{
				return;
			}
			while (processList.Count > 0)
			{
				foreach (T process in processList)
				{
					if (Process(process))
					{
						OnSuccess(process);
					}
					else
					{
						OnFailure(process);
					}
				}
				if (!repeatUntilSuccess)
				{
					break;
				}
				processList.Clear();
				processList.AddRange(failedItems);
			}
			intervalTimer -= processInterval;
		}
	}
	public abstract class QueueProcessor<T> : MonoBehaviour
	{
		protected readonly Queue<T> processQueue = new Queue<T>();

		private float intervalTimer;

		protected abstract int itemsPerFrame { get; set; }

		protected abstract float processInterval { get; set; }

		public virtual void Add(T item)
		{
			processQueue.Enqueue(item);
		}

		protected abstract bool Process(T item);

		protected virtual void OnSuccess(T item)
		{
		}

		protected virtual void OnFailure(T item)
		{
		}

		protected virtual void FixedUpdate()
		{
			intervalTimer += Time.fixedDeltaTime;
			if (!(intervalTimer >= processInterval))
			{
				return;
			}
			for (int i = 0; i < itemsPerFrame; i++)
			{
				if (processQueue.Count <= 0)
				{
					break;
				}
				T item = processQueue.Dequeue();
				if (Process(item))
				{
					OnSuccess(item);
					continue;
				}
				OnFailure(item);
				processQueue.Enqueue(item);
			}
			intervalTimer -= processInterval;
		}
	}
	public class TemporaryParticleSystem : MonoBehaviour
	{
		public bool detonate;

		public ParticleSystem particleSystem;

		protected virtual void Awake()
		{
			detonate = true;
			particleSystem = ((Component)this).gameObject.GetComponent<ParticleSystem>();
			if (!Object.op_Implicit((Object)(object)particleSystem))
			{
				Object.Destroy((Object)(object)this);
			}
		}

		protected virtual void FixedUpdate()
		{
			if (detonate && !particleSystem.isEmitting)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
}
namespace Chen.Helpers.MathHelpers
{
	public static class Arithmetic
	{
		public static float SafeDivide(this float dividend, float divisor, float fallbackResult = float.PositiveInfinity)
		{
			if (divisor == 0f)
			{
				return fallbackResult;
			}
			return dividend / divisor;
		}

		public static int SafeDivide(this int dividend, int divisor, int fallbackResult = 0)
		{
			if (divisor == 0)
			{
				return fallbackResult;
			}
			return dividend / divisor;
		}

		public static int Sum(this int[] numbers, Func<int, int> preProcess = null)
		{
			int num = 0;
			foreach (int num2 in numbers)
			{
				int num3 = preProcess?.Invoke(num2) ?? num2;
				num += num3;
			}
			return num;
		}

		public static float Sum(this float[] numbers, Func<float, float> preProcess = null)
		{
			float num = 0f;
			foreach (float num2 in numbers)
			{
				float num3 = preProcess?.Invoke(num2) ?? num2;
				num += num3;
			}
			return num;
		}

		public static float Average(this int[] numbers, Func<int, int> preProcess = null)
		{
			return numbers.Sum(preProcess) / numbers.Length;
		}

		public static float Average(this float[] numbers, Func<float, float> preProcess = null)
		{
			return numbers.Sum(preProcess) / (float)numbers.Length;
		}
	}
	public static class Percent
	{
		private static readonly int[] groupSize = new int[1] { 3 };

		private static readonly NumberFormatInfo numberFormatInfo = new NumberFormatInfo
		{
			PercentPositivePattern = 1,
			PercentNegativePattern = 1,
			NegativeSign = "-",
			PercentSymbol = "%",
			PercentDecimalDigits = 0,
			PercentDecimalSeparator = ".",
			PercentGroupSeparator = "",
			PercentGroupSizes = groupSize,
			NumberNegativePattern = 1,
			NumberGroupSizes = groupSize,
			NumberGroupSeparator = "",
			NumberDecimalSeparator = ".",
			NumberDecimalDigits = 0
		};

		public static float ToPercent(this float number)
		{
			return number * 100f;
		}

		public static string ToPercent(this float number, uint precision)
		{
			return number.ToString($"P{precision}", numberFormatInfo);
		}

		public static float ToDecimal(this float percentage)
		{
			return percentage / 100f;
		}

		public static string ToDecimal(this float percentage, uint precision)
		{
			return percentage.ToDecimal().ToString($"N{precision}", numberFormatInfo);
		}
	}
	public static class Wave
	{
		public static float Sine(float phase, float frequency, float amplitude, float baseValue)
		{
			float x = GetX(phase, frequency);
			float y = Mathf.Sin(x * 2f * MathF.PI);
			return Compute(y, amplitude, baseValue);
		}

		public static float Triangle(float phase, float frequency, float amplitude, float baseValue)
		{
			float x = GetX(phase, frequency);
			float y = ((!(x < 0.5f)) ? (-4f * x + 3f) : (4f * x - 1f));
			return Compute(y, amplitude, baseValue);
		}

		public static float Square(float phase, float frequency, float amplitude, float baseValue)
		{
			float x = GetX(phase, frequency);
			float y = ((!(x < 0.5f)) ? (-1f) : 1f);
			return Compute(y, amplitude, baseValue);
		}

		public static float Sawtooth(float phase, float frequency, float amplitude, float baseValue)
		{
			return Compute(GetX(phase, frequency), amplitude, baseValue);
		}

		public static float InvertedSawtooth(float phase, float frequency, float amplitude, float baseValue)
		{
			return Compute(1f - GetX(phase, frequency), amplitude, baseValue);
		}

		public static float Noisy(float amplitude, float baseValue)
		{
			return Compute(1f - Random.value * 2f, amplitude, baseValue);
		}

		private static float GetX(float phase, float frequency)
		{
			float num = (Time.time + phase) * frequency;
			return num - Mathf.Floor(num);
		}

		private static float Compute(float y, float amplitude, float baseValue)
		{
			return y * amplitude + baseValue;
		}
	}
}
namespace Chen.Helpers.LogHelpers
{
	public class Log
	{
		private readonly ManualLogSource logger;

		public Log(ManualLogSource logger)
		{
			this.logger = logger;
		}

		public void Debug(object data)
		{
			logger.LogDebug(data);
		}

		public void Error(object data)
		{
			logger.LogError(data);
		}

		public void Info(object data)
		{
			logger.LogInfo(data);
		}

		public void Message(object data)
		{
			logger.LogMessage(data);
		}

		public void Warning(object data)
		{
			logger.LogWarning(data);
		}
	}
}
namespace Chen.Helpers.LogHelpers.Collections
{
	public static class Extensions
	{
		private const string defaultToken = "%DATA%";

		public static void MessageArray<T>(this Log logger, T[] data, string format = "%DATA%", string representation = "%DATA%")
		{
			GenericLogging(data, format, representation, delegate(string item)
			{
				logger.Message(item);
			});
		}

		public static void MessageArray<T>(this Log logger, T[] data, Func<T, string> formatter)
		{
			GenericLogging(data, formatter, delegate(string formatted)
			{
				logger.Message(formatted);
			});
		}

		public static void InfoArray<T>(this Log logger, T[] data, string format = "%DATA%", string representation = "%DATA%")
		{
			GenericLogging(data, format, representation, delegate(string item)
			{
				logger.Info(item);
			});
		}

		public static void InfoArray<T>(this Log logger, T[] data, Func<T, string> formatter)
		{
			GenericLogging(data, formatter, delegate(string formatted)
			{
				logger.Info(formatted);
			});
		}

		public static void WarningArray<T>(this Log logger, T[] data, string format = "%DATA%", string representation = "%DATA%")
		{
			GenericLogging(data, format, representation, delegate(string item)
			{
				logger.Warning(item);
			});
		}

		public static void WarningArray<T>(this Log logger, T[] data, Func<T, string> formatter)
		{
			GenericLogging(data, formatter, delegate(string formatted)
			{
				logger.Warning(formatted);
			});
		}

		public static void ErrorArray<T>(this Log logger, T[] data, string format = "%DATA%", string representation = "%DATA%")
		{
			GenericLogging(data, format, representation, delegate(string item)
			{
				logger.Error(item);
			});
		}

		public static void ErrorArray<T>(this Log logger, T[] data, Func<T, string> formatter)
		{
			GenericLogging(data, formatter, delegate(string formatted)
			{
				logger.Error(formatted);
			});
		}

		public static void DebugArray<T>(this Log logger, T[] data, string format = "%DATA%", string representation = "%DATA%")
		{
			GenericLogging(data, format, representation, delegate(string item)
			{
				logger.Debug(item);
			});
		}

		public static void DebugArray<T>(this Log logger, T[] data, Func<T, string> formatter)
		{
			GenericLogging(data, formatter, delegate(string formatted)
			{
				logger.Debug(formatted);
			});
		}

		private static void GenericLogging<T>(T[] data, string format, string token, Action<string> logAction)
		{
			for (int i = 0; i < data.Length; i++)
			{
				T val = data[i];
				string text = "";
				string[] array = format.Split(new string[1] { token }, StringSplitOptions.None);
				int num = array.Length;
				for (int j = 0; j < num; j++)
				{
					text += array[j];
					if (j != num - 1)
					{
						text += val.ToString();
					}
				}
				logAction(text);
			}
		}

		private static void GenericLogging<T>(T[] data, Func<T, string> formatter, Action<string> logAction)
		{
			foreach (T arg in data)
			{
				logAction(formatter(arg));
			}
		}
	}
}
namespace Chen.Helpers.GeneralHelpers
{
	public class AssetsManager
	{
		public struct BundleInfo : IEquatable<BundleInfo>
		{
			public string source;

			public BundleType type;

			public BundleInfo(string source, BundleType type)
			{
				this.source = source;
				this.type = type;
			}

			public bool Equals(BundleInfo other)
			{
				return source == other.source;
			}
		}

		public enum BundleType : byte
		{
			UnityAssetBundle,
			WWiseSoundBank
		}

		private readonly BundleInfo bundleInfo;

		public AssetsManager(BundleInfo bundleInfo)
		{
			this.bundleInfo = bundleInfo;
		}

		public AssetBundle Register()
		{
			using Stream stream = Assembly.GetCallingAssembly().GetManifestResourceStream(bundleInfo.source);
			switch (bundleInfo.type)
			{
			case BundleType.UnityAssetBundle:
				return AssetBundle.LoadFromStream(stream);
			case BundleType.WWiseSoundBank:
			{
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				SoundBanks.Add(array);
				return null;
			}
			default:
				return null;
			}
		}
	}
	public class BlastAttack : BlastAttack
	{
		public struct HitPointAndResult
		{
			public HitPoint[] hitPoints;

			public Result result;
		}

		public HitPointAndResult InformativeFire()
		{
			//IL_0022: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			HitPoint[] array = ((BlastAttack)this).CollectHits();
			((BlastAttack)this).HandleHits(array);
			HitPointAndResult result = default(HitPointAndResult);
			result.hitPoints = array;
			result.result = new Result
			{
				hitCount = array.Length
			};
			return result;
		}
	}
	public static class DefaultData
	{
		public static Dictionary<string, string> ShaderReplacements = new Dictionary<string, string>
		{
			{ "fake ror/hopoo games/deferred/hgstandard", "shaders/deferred/hgstandard" },
			{ "fake ror/hopoo games/fx/hgcloud intersection remap", "shaders/fx/hgintersectioncloudremap" },
			{ "fake ror/hopoo games/fx/hgcloud remap", "shaders/fx/hgcloudremap" },
			{ "fake ror/hopoo games/fx/hgdistortion", "shaders/fx/hgdistortion" },
			{ "fake ror/hopoo games/deferred/hgsnow topped", "shaders/deferred/snow topped" }
		};
	}
	public static class DropletGenerator
	{
		public static void Update()
		{
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			bool keyDown = Input.GetKeyDown((KeyCode)284);
			bool keyDown2 = Input.GetKeyDown((KeyCode)285);
			bool keyDown3 = Input.GetKeyDown((KeyCode)286);
			bool keyDown4 = Input.GetKeyDown((KeyCode)287);
			bool keyDown5 = Input.GetKeyDown((KeyCode)288);
			bool keyDown6 = Input.GetKeyDown((KeyCode)289);
			bool keyDown7 = Input.GetKeyDown((KeyCode)290);
			if (keyDown || keyDown2 || keyDown3 || keyDown4 || keyDown5 || keyDown6 || keyDown7)
			{
				Transform transform = Instances.hostBodyObject.transform;
				List<PickupIndex> list = (keyDown ? Run.instance.availableTier1DropList : (keyDown2 ? Run.instance.availableTier2DropList : (keyDown3 ? Run.instance.availableTier3DropList : (keyDown4 ? Run.instance.availableEquipmentDropList : (keyDown5 ? Run.instance.availableLunarItemDropList : ((!keyDown6) ? Run.instance.availableBossDropList : Run.instance.availableLunarEquipmentDropList))))));
				PickupDropletController.CreatePickupDroplet(list[Run.instance.spawnRng.RangeInt(0, list.Count)], transform.position, new Vector3(0f, -5f, 0f));
			}
		}
	}
	public static class Extensions
	{
		public static RendererInfo[] BuildRendererInfos(this CharacterModel model, GameObject basisObject)
		{
			return model.BuildRendererInfos(basisObject, (ShadowCastingMode)1, ignoreOverlays: false);
		}

		public static RendererInfo[] BuildRendererInfos(this CharacterModel model, GameObject basisObject, ShadowCastingMode mode, bool ignoreOverlays)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			MeshRenderer[] componentsInChildren = basisObject.GetComponentsInChildren<MeshRenderer>();
			model.baseRendererInfos = (RendererInfo[])(object)new RendererInfo[componentsInChildren.Length];
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				model.baseRendererInfos[i] = new RendererInfo
				{
					defaultMaterial = ((Renderer)componentsInChildren[i]).material,
					renderer = (Renderer)(object)componentsInChildren[i],
					defaultShadowCastingMode = mode,
					ignoreOverlays = ignoreOverlays
				};
			}
			return model.baseRendererInfos;
		}

		public static void ReplaceModel(this GameObject originalClonedObject, GameObject replacementModel, bool debug = false)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			ModelLocator component = originalClonedObject.GetComponent<ModelLocator>();
			if (Object.op_Implicit((Object)(object)component))
			{
				Transform val;
				if (Object.op_Implicit((Object)(object)(val = originalClonedObject.transform.Find("ModelBase"))))
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
				if (Object.op_Implicit((Object)(object)(val = originalClonedObject.transform.Find("Model Base"))))
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
				GameObject val2 = new GameObject("ModelBase");
				val2.transform.parent = originalClonedObject.transform;
				val2.transform.localPosition = Vector3.zero;
				val2.transform.localRotation = Quaternion.identity;
				val2.transform.localScale = Vector3.one;
				Transform transform = replacementModel.transform;
				transform.parent = val2.transform;
				transform.localPosition = Vector3.zero;
				transform.localRotation = Quaternion.identity;
				component.modelTransform = replacementModel.transform;
				component.modelBaseTransform = val2.transform;
				if (debug)
				{
					replacementModel.AddComponent<MaterialController>();
				}
			}
		}

		public static void ConvertShaders(this AssetBundle assetBundle, Dictionary<string, string> replacementDictionary, string shaderPrefix)
		{
			IEnumerable<Material> enumerable = assetBundle.LoadAllAssets<Material>().Where(materialFilter);
			foreach (Material item in enumerable)
			{
				Shader val = Resources.Load<Shader>(replacementDictionary[((Object)item.shader).name.ToLower()]);
				if (Object.op_Implicit((Object)(object)val))
				{
					item.shader = val;
				}
			}
			bool materialFilter(Material material)
			{
				return ((Object)material.shader).name.ToLower().StartsWith(shaderPrefix.ToLower());
			}
		}

		public static void ConvertShaders(this AssetBundle assetBundle)
		{
			assetBundle.ConvertShaders(DefaultData.ShaderReplacements, "Fake RoR");
		}
	}
	public abstract class GenericContentPackProvider : IContentPackProvider
	{
		protected ContentPack contentPack = new ContentPack();

		public string identifier => ContentIdentifier();

		public void Initialize()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)delegate(AddContentPackProviderDelegate addContentPackProvider)
			{
				addContentPackProvider.Invoke((IContentPackProvider)(object)this);
			};
		}

		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			contentPack.identifier = identifier;
			LoadStaticContentAsyncActions(args);
			args.ReportProgress(1f);
			yield break;
		}

		public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
		{
			ContentPack.Copy(contentPack, args.output);
			args.ReportProgress(1f);
			yield break;
		}

		public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
		{
			args.ReportProgress(1f);
			yield break;
		}

		protected abstract string ContentIdentifier();

		protected abstract void LoadStaticContentAsyncActions(LoadStaticContentAsyncArgs args);
	}
	public static class Instances
	{
		public static PlayerCharacterMasterController hostPcmc
		{
			get
			{
				PlayerCharacterMasterController val = PlayerCharacterMasterController.instances[0];
				if (!Object.op_Implicit((Object)(object)val))
				{
					HelperPlugin.Log.Debug("hostPcmc is null");
				}
				return val;
			}
		}

		public static CharacterMaster hostMaster
		{
			get
			{
				CharacterMaster val = null;
				if (Object.op_Implicit((Object)(object)hostPcmc))
				{
					val = hostPcmc.master;
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					HelperPlugin.Log.Debug("hostMaster is null");
				}
				return val;
			}
		}

		public static GameObject hostMasterObject
		{
			get
			{
				GameObject result = null;
				if (Object.op_Implicit((Object)(object)hostMaster))
				{
					result = ((Component)hostMaster).gameObject;
				}
				return result;
			}
		}

		public static CharacterBody hostBody
		{
			get
			{
				CharacterBody val = null;
				if (Object.op_Implicit((Object)(object)hostMaster))
				{
					val = hostMaster.GetBody();
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					HelperPlugin.Log.Debug("hostBody is null");
				}
				return val;
			}
		}

		public static GameObject hostBodyObject
		{
			get
			{
				GameObject result = null;
				if (Object.op_Implicit((Object)(object)hostBody))
				{
					result = ((Component)hostBody).gameObject;
				}
				return result;
			}
		}
	}
	public class MaterialController : MonoBehaviour
	{
		private void Start()
		{
			HelperPlugin.Log.Warning("Attached Material Controller to " + ((Object)((Component)this).gameObject).name + ". Ignore this if you are a mod developer debugging. Report otherwise.");
			Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>();
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				Material val2 = null;
				MeshRenderer val3 = (MeshRenderer)(object)((val is MeshRenderer) ? val : null);
				if (val3 != null)
				{
					val2 = ((Renderer)val3).sharedMaterial;
				}
				else
				{
					SkinnedMeshRenderer val4 = (SkinnedMeshRenderer)(object)((val is SkinnedMeshRenderer) ? val : null);
					if (val4 != null)
					{
						val2 = ((Renderer)val4).sharedMaterials[0];
					}
				}
				if (Object.op_Implicit((Object)(object)val2))
				{
					GameObject gameObject = ((Component)val).gameObject;
					HGBaseController hGBaseController = null;
					switch (((Object)val2.shader).name)
					{
					case "Hopoo Games/Deferred/Standard":
						hGBaseController = gameObject.AddComponent<HGStandardController>();
						break;
					case "Hopoo Games/FX/Cloud Remap":
						hGBaseController = gameObject.AddComponent<HGCloudRemapController>();
						break;
					case "Hopoo Games/FX/Cloud Intersection Remap":
						hGBaseController = gameObject.AddComponent<HGIntersectionController>();
						break;
					}
					if (Object.op_Implicit((Object)(object)hGBaseController))
					{
						RecursivePathGeneration(gameObject);
						hGBaseController.Material = val2;
						hGBaseController.Renderer = val;
						HelperPlugin.Log.Warning(((object)hGBaseController).GetType().Name + " assigned to " + ((Object)gameObject).name + ".");
					}
					else
					{
						HelperPlugin.Log.Error("Shader Controller not implemented for " + ((Object)val2.shader).name + ".");
					}
				}
			}
			Object.Destroy((Object)(object)this);
		}

		private void RecursivePathGeneration(GameObject rendererGameObject, Transform parent = null)
		{
			if (Object.op_Implicit((Object)(object)parent))
			{
				((Object)rendererGameObject).name = ((Object)((Component)parent).gameObject).name + "." + ((Object)rendererGameObject).name;
			}
			parent = (Object.op_Implicit((Object)(object)parent) ? parent.parent : rendererGameObject.transform.parent);
			if (Object.op_Implicit((Object)(object)parent))
			{
				RecursivePathGeneration(rendererGameObject, parent);
			}
		}
	}
	public class HGBaseController : MonoBehaviour
	{
		public Material Material;

		public Renderer Renderer;

		public string MaterialName;

		public void SetShaderKeywordBasedOnBool(bool enabled, string keyword)
		{
			if (!Object.op_Implicit((Object)(object)Material))
			{
				HelperPlugin.Log.Error("Material field was null, cannot run shader keyword method.");
			}
			else if (enabled)
			{
				if (!Material.IsKeywordEnabled(keyword))
				{
					Material.EnableKeyword(keyword);
				}
			}
			else if (Material.IsKeywordEnabled(keyword))
			{
				Material.DisableKeyword(keyword);
			}
		}

		public void PutMaterialIntoMeshRenderer()
		{
			if (Object.op_Implicit((Object)(object)Material) && Object.op_Implicit((Object)(object)Renderer))
			{
				Renderer renderer = Renderer;
				SkinnedMeshRenderer val = (SkinnedMeshRenderer)(object)((renderer is SkinnedMeshRenderer) ? renderer : null);
				if (val != null)
				{
					((Renderer)val).sharedMaterials = (Material[])(object)new Material[1] { Material };
				}
				Renderer renderer2 = Renderer;
				MeshRenderer val2 = (MeshRenderer)(object)((renderer2 is MeshRenderer) ? renderer2 : null);
				if (val2 != null)
				{
					((Renderer)val2).material = Material;
				}
			}
		}
	}
	public class HGStandardController : HGBaseController
	{
		public enum _RampInfoEnum
		{
			TwoTone = 0,
			SmoothedTwoTone = 1,
			Unlitish = 3,
			Subsurface = 4,
			Grass = 5
		}

		public enum _DecalLayerEnum
		{
			Default,
			Environment,
			Character,
			Misc
		}

		public enum _CullEnum
		{
			Off,
			Front,
			Back
		}

		public enum _PrintDirectionEnum
		{
			BottomUp = 0,
			TopDown = 1,
			BackToFront = 3
		}

		public bool _EnableCutout;

		public Color _Color;

		public Texture _MainTex;

		public Vector2 _MainTexScale;

		public Vector2 _MainTexOffset;

		[Range(0f, 5f)]
		public float _NormalStrength;

		public Texture _NormalTex;

		public Vector2 _NormalTexScale;

		public Vector2 _NormalTexOffset;

		public Color _EmColor;

		public Texture _EmTex;

		[Range(0f, 10f)]
		public float _EmPower;

		[Range(0f, 1f)]
		public float _Smoothness;

		public bool _IgnoreDiffuseAlphaForSpeculars;

		public _RampInfoEnum _RampChoice;

		public _DecalLayerEnum _DecalLayer;

		[Range(0f, 1f)]
		public float _SpecularStrength;

		[Range(0.1f, 20f)]
		public float _SpecularExponent;

		public _CullEnum _Cull_Mode;

		public bool _EnableDither;

		[Range(0f, 1f)]
		public float _FadeBias;

		public bool _EnableFresnelEmission;

		public Texture _FresnelRamp;

		[Range(0.1f, 20f)]
		public float _FresnelPower;

		public Texture _FresnelMask;

		[Range(0f, 20f)]
		public float _FresnelBoost;

		public bool _EnablePrinting;

		[Range(-25f, 25f)]
		public float _SliceHeight;

		[Range(0f, 10f)]
		public float _PrintBandHeight;

		[Range(0f, 1f)]
		public float _PrintAlphaDepth;

		public Texture _PrintAlphaTexture;

		public Vector2 _PrintAlphaTextureScale;

		public Vector2 _PrintAlphaTextureOffset;

		[Range(0f, 10f)]
		public float _PrintColorBoost;

		[Range(0f, 4f)]
		public float _PrintAlphaBias;

		[Range(0f, 1f)]
		public float _PrintEmissionToAlbedoLerp;

		public _PrintDirectionEnum _PrintDirection;

		public Texture _PrintRamp;

		[Range(-10f, 10f)]
		public float _EliteBrightnessMin;

		[Range(-10f, 10f)]
		public float _EliteBrightnessMax;

		public bool _EnableSplatmap;

		public bool _UseVertexColorsInstead;

		[Range(0f, 1f)]
		public float _BlendDepth;

		public Texture _SplatmapTex;

		public Vector2 _SplatmapTexScale;

		public Vector2 _SplatmapTexOffset;

		[Range(0f, 20f)]
		public float _SplatmapTileScale;

		public Texture _GreenChannelTex;

		public Texture _GreenChannelNormalTex;

		[Range(0f, 1f)]
		public float _GreenChannelSmoothness;

		[Range(-2f, 5f)]
		public float _GreenChannelBias;

		public Texture _BlueChannelTex;

		public Texture _BlueChannelNormalTex;

		[Range(0f, 1f)]
		public float _BlueChannelSmoothness;

		[Range(-2f, 5f)]
		public float _BlueChannelBias;

		public bool _EnableFlowmap;

		public Texture _FlowTexture;

		public Texture _FlowHeightmap;

		public Vector2 _FlowHeightmapScale;

		public Vector2 _FlowHeightmapOffset;

		public Texture _FlowHeightRamp;

		public Vector2 _FlowHeightRampScale;

		public Vector2 _FlowHeightRampOffset;

		[Range(-1f, 1f)]
		public float _FlowHeightBias;

		[Range(0.1f, 20f)]
		public float _FlowHeightPower;

		[Range(0.1f, 20f)]
		public float _FlowEmissionStrength;

		[Range(0f, 15f)]
		public float _FlowSpeed;

		[Range(0f, 5f)]
		public float _MaskFlowStrength;

		[Range(0f, 5f)]
		public float _NormalFlowStrength;

		[Range(0f, 10f)]
		public float _FlowTextureScaleFactor;

		public bool _EnableLimbRemoval;

		public void Start()
		{
			GrabMaterialValues();
		}

		public void GrabMaterialValues()
		{
			//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_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_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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_051c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0521: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: 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_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_0574: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Material))
			{
				_EnableCutout = Material.IsKeywordEnabled("CUTOUT");
				_Color = Material.GetColor("_Color");
				_MainTex = Material.GetTexture("_MainTex");
				_MainTexScale = Material.GetTextureScale("_MainTex");
				_MainTexOffset = Material.GetTextureOffset("_MainTex");
				_NormalStrength = Material.GetFloat("_NormalStrength");
				_NormalTex = Material.GetTexture("_NormalTex");
				_NormalTexScale = Material.GetTextureScale("_NormalTex");
				_NormalTexOffset = Material.GetTextureOffset("_NormalTex");
				_EmColor = Material.GetColor("_EmColor");
				_EmTex = Material.GetTexture("_EmTex");
				_EmPower = Material.GetFloat("_EmPower");
				_Smoothness = Material.GetFloat("_Smoothness");
				_IgnoreDiffuseAlphaForSpeculars = Material.IsKeywordEnabled("FORCE_SPEC");
				_RampChoice = (_RampInfoEnum)Material.GetFloat("_RampInfo");
				_DecalLayer = (_DecalLayerEnum)Material.GetFloat("_DecalLayer");
				_SpecularStrength = Material.GetFloat("_SpecularStrength");
				_SpecularExponent = Material.GetFloat("_SpecularExponent");
				_Cull_Mode = (_CullEnum)Material.GetFloat("_Cull");
				_EnableDither = Material.IsKeywordEnabled("DITHER");
				_FadeBias = Material.GetFloat("_FadeBias");
				_EnableFresnelEmission = Material.IsKeywordEnabled("FRESNEL_EMISSION");
				_FresnelRamp = Material.GetTexture("_FresnelRamp");
				_FresnelPower = Material.GetFloat("_FresnelPower");
				_FresnelMask = Material.GetTexture("_FresnelMask");
				_FresnelBoost = Material.GetFloat("_FresnelBoost");
				_EnablePrinting = Material.IsKeywordEnabled("PRINT_CUTOFF");
				_SliceHeight = Material.GetFloat("_SliceHeight");
				_PrintBandHeight = Material.GetFloat("_SliceBandHeight");
				_PrintAlphaDepth = Material.GetFloat("_SliceAlphaDepth");
				_PrintAlphaTexture = Material.GetTexture("_SliceAlphaTex");
				_PrintAlphaTextureScale = Material.GetTextureScale("_SliceAlphaTex");
				_PrintAlphaTextureOffset = Material.GetTextureOffset("_SliceAlphaTex");
				_PrintColorBoost = Material.GetFloat("_PrintBoost");
				_PrintAlphaBias = Material.GetFloat("_PrintBias");
				_PrintEmissionToAlbedoLerp = Material.GetFloat("_PrintEmissionToAlbedoLerp");
				_PrintDirection = (_PrintDirectionEnum)Material.GetFloat("_PrintDirection");
				_PrintRamp = Material.GetTexture("_PrintRamp");
				_EliteBrightnessMin = Material.GetFloat("_EliteBrightnessMin");
				_EliteBrightnessMax = Material.GetFloat("_EliteBrightnessMax");
				_EnableSplatmap = Material.IsKeywordEnabled("SPLATMAP");
				_UseVertexColorsInstead = Material.IsKeywordEnabled("USE_VERTEX_COLORS");
				_BlendDepth = Material.GetFloat("_Depth");
				_SplatmapTex = Material.GetTexture("_SplatmapTex");
				_SplatmapTexScale = Material.GetTextureScale("_SplatmapTex");
				_SplatmapTexOffset = Material.GetTextureOffset("_SplatmapTex");
				_SplatmapTileScale = Material.GetFloat("_SplatmapTileScale");
				_GreenChannelTex = Material.GetTexture("_GreenChannelTex");
				_GreenChannelNormalTex = Material.GetTexture("_GreenChannelNormalTex");
				_GreenChannelSmoothness = Material.GetFloat("_GreenChannelSmoothness");
				_GreenChannelBias = Material.GetFloat("_GreenChannelBias");
				_BlueChannelTex = Material.GetTexture("_BlueChannelTex");
				_BlueChannelNormalTex = Material.GetTexture("_BlueChannelNormalTex");
				_BlueChannelSmoothness = Material.GetFloat("_BlueChannelSmoothness");
				_BlueChannelBias = Material.GetFloat("_BlueChannelBias");
				_EnableFlowmap = Material.IsKeywordEnabled("FLOWMAP");
				_FlowTexture = Material.GetTexture("_FlowTex");
				_FlowHeightmap = Material.GetTexture("_FlowHeightmap");
				_FlowHeightmapScale = Material.GetTextureScale("_FlowHeightmap");
				_FlowHeightmapOffset = Material.GetTextureOffset("_FlowHeightmap");
				_FlowHeightRamp = Material.GetTexture("_FlowHeightRamp");
				_FlowHeightRampScale = Material.GetTextureScale("_FlowHeightRamp");
				_FlowHeightRampOffset = Material.GetTextureOffset("_FlowHeightRamp");
				_FlowHeightBias = Material.GetFloat("_FlowHeightBias");
				_FlowHeightPower = Material.GetFloat("_FlowHeightPower");
				_FlowEmissionStrength = Material.GetFloat("_FlowEmissionStrength");
				_FlowSpeed = Material.GetFloat("_FlowSpeed");
				_MaskFlowStrength = Material.GetFloat("_FlowMaskStrength");
				_NormalFlowStrength = Material.GetFloat("_FlowNormalStrength");
				_FlowTextureScaleFactor = Material.GetFloat("_FlowTextureScaleFactor");
				_EnableLimbRemoval = Material.IsKeywordEnabled("LIMBREMOVAL");
				MaterialName = ((Object)Material).name;
			}
		}

		public void Update()
		{
			//IL_005e: 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)
			//IL_00ad: 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_0125: 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_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0507: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_070c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0758: Unknown result type (might be due to invalid IL or missing references)
			//IL_076e: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Material))
			{
				if (((Object)Material).name != MaterialName && Object.op_Implicit((Object)(object)Renderer))
				{
					GrabMaterialValues();
					PutMaterialIntoMeshRenderer();
				}
				SetShaderKeywordBasedOnBool(_EnableCutout, "CUTOUT");
				Material.SetColor("_Color", _Color);
				if (Object.op_Implicit((Object)(object)_MainTex))
				{
					Material.SetTexture("_MainTex", _MainTex);
					Material.SetTextureScale("_MainTex", _MainTexScale);
					Material.SetTextureOffset("_MainTex", _MainTexOffset);
				}
				else
				{
					Material.SetTexture("_MainTex", (Texture)null);
				}
				Material.SetFloat("_NormalStrength", _NormalStrength);
				if (Object.op_Implicit((Object)(object)_NormalTex))
				{
					Material.SetTexture("_NormalTex", _NormalTex);
					Material.SetTextureScale("_NormalTex", _NormalTexScale);
					Material.SetTextureOffset("_NormalTex", _NormalTexOffset);
				}
				else
				{
					Material.SetTexture("_NormalTex", (Texture)null);
				}
				Material.SetColor("_EmColor", _EmColor);
				if (Object.op_Implicit((Object)(object)_EmTex))
				{
					Material.SetTexture("_EmTex", _EmTex);
				}
				else
				{
					Material.SetTexture("_EmTex", (Texture)null);
				}
				Material.SetFloat("_EmPower", _EmPower);
				Material.SetFloat("_Smoothness", _Smoothness);
				SetShaderKeywordBasedOnBool(_IgnoreDiffuseAlphaForSpeculars, "FORCE_SPEC");
				Material.SetFloat("_RampInfo", Convert.ToSingle(_RampChoice));
				Material.SetFloat("_DecalLayer", Convert.ToSingle(_DecalLayer));
				Material.SetFloat("_SpecularStrength", _SpecularStrength);
				Material.SetFloat("_SpecularExponent", _SpecularExponent);
				Material.SetFloat("_Cull", Convert.ToSingle(_Cull_Mode));
				SetShaderKeywordBasedOnBool(_EnableDither, "DITHER");
				Material.SetFloat("_FadeBias", _FadeBias);
				SetShaderKeywordBasedOnBool(_EnableFresnelEmission, "FRESNEL_EMISSION");
				if (Object.op_Implicit((Object)(object)_FresnelRamp))
				{
					Material.SetTexture("_FresnelRamp", _FresnelRamp);
				}
				else
				{
					Material.SetTexture("_FresnelRamp", (Texture)null);
				}
				Material.SetFloat("_FresnelPower", _FresnelPower);
				if (Object.op_Implicit((Object)(object)_FresnelMask))
				{
					Material.SetTexture("_FresnelMask", _FresnelMask);
				}
				else
				{
					Material.SetTexture("_FresnelMask", (Texture)null);
				}
				Material.SetFloat("_FresnelBoost", _FresnelBoost);
				SetShaderKeywordBasedOnBool(_EnablePrinting, "PRINT_CUTOFF");
				Material.SetFloat("_SliceHeight", _SliceHeight);
				Material.SetFloat("_SliceBandHeight", _PrintBandHeight);
				Material.SetFloat("_SliceAlphaDepth", _PrintAlphaDepth);
				if (Object.op_Implicit((Object)(object)_PrintAlphaTexture))
				{
					Material.SetTexture("_SliceAlphaTex", _PrintAlphaTexture);
					Material.SetTextureScale("_SliceAlphaTex", _PrintAlphaTextureScale);
					Material.SetTextureOffset("_SliceAlphaTex", _PrintAlphaTextureOffset);
				}
				else
				{
					Material.SetTexture("_SliceAlphaTex", (Texture)null);
				}
				Material.SetFloat("_PrintBoost", _PrintColorBoost);
				Material.SetFloat("_PrintBias", _PrintAlphaBias);
				Material.SetFloat("_PrintEmissionToAlbedoLerp", _PrintEmissionToAlbedoLerp);
				Material.SetFloat("_PrintDirection", Convert.ToSingle(_PrintDirection));
				if (Object.op_Implicit((Object)(object)_PrintRamp))
				{
					Material.SetTexture("_PrintRamp", _PrintRamp);
				}
				else
				{
					Material.SetTexture("_PrintRamp", (Texture)null);
				}
				Material.SetFloat("_EliteBrightnessMin", _EliteBrightnessMin);
				Material.SetFloat("_EliteBrightnessMax", _EliteBrightnessMax);
				SetShaderKeywordBasedOnBool(_EnableSplatmap, "SPLATMAP");
				SetShaderKeywordBasedOnBool(_UseVertexColorsInstead, "USE_VERTEX_COLORS");
				Material.SetFloat("_Depth", _BlendDepth);
				if (Object.op_Implicit((Object)(object)_SplatmapTex))
				{
					Material.SetTexture("_SplatmapTex", _SplatmapTex);
					Material.SetTextureScale("_SplatmapTex", _SplatmapTexScale);
					Material.SetTextureOffset("_SplatmapTex", _SplatmapTexOffset);
				}
				else
				{
					Material.SetTexture("_SplatmapTex", (Texture)null);
				}
				Material.SetFloat("_SplatmapTileScale", _SplatmapTileScale);
				if (Object.op_Implicit((Object)(object)_GreenChannelTex))
				{
					Material.SetTexture("_GreenChannelTex", _GreenChannelTex);
				}
				else
				{
					Material.SetTexture("_GreenChannelTex", (Texture)null);
				}
				if (Object.op_Implicit((Object)(object)_GreenChannelNormalTex))
				{
					Material.SetTexture("_GreenChannelNormalTex", _GreenChannelNormalTex);
				}
				else
				{
					Material.SetTexture("_GreenChannelNormalTex", (Texture)null);
				}
				Material.SetFloat("_GreenChannelSmoothness", _GreenChannelSmoothness);
				Material.SetFloat("_GreenChannelBias", _GreenChannelBias);
				if (Object.op_Implicit((Object)(object)_BlueChannelTex))
				{
					Material.SetTexture("_BlueChannelTex", _BlueChannelTex);
				}
				else
				{
					Material.SetTexture("_BlueChannelTex", (Texture)null);
				}
				if (Object.op_Implicit((Object)(object)_BlueChannelNormalTex))
				{
					Material.SetTexture("_BlueChannelNormalTex", _BlueChannelNormalTex);
				}
				else
				{
					Material.SetTexture("_BlueChannelNormalTex", (Texture)null);
				}
				Material.SetFloat("_BlueChannelSmoothness", _BlueChannelSmoothness);
				Material.SetFloat("_BlueChannelBias", _BlueChannelBias);
				SetShaderKeywordBasedOnBool(_EnableFlowmap, "FLOWMAP");
				if (Object.op_Implicit((Object)(object)_FlowTexture))
				{
					Material.SetTexture("_FlowTex", _FlowTexture);
				}
				else
				{
					Material.SetTexture("_FlowTex", (Texture)null);
				}
				if (Object.op_Implicit((Object)(object)_FlowHeightmap))
				{
					Material.SetTexture("_FlowHeightmap", _FlowHeightmap);
					Material.SetTextureScale("_FlowHeightmap", _FlowHeightmapScale);
					Material.SetTextureOffset("_FlowHeightmap", _FlowHeightmapOffset);
				}
				else
				{
					Material.SetTexture("_FlowHeightmap", (Texture)null);
				}
				if (Object.op_Implicit((Object)(object)_FlowHeightRamp))
				{
					Material.SetTexture("_FlowHeightRamp", _FlowHeightRamp);
					Material.SetTextureScale("_FlowHeightRamp", _FlowHeightRampScale);
					Material.SetTextureOffset("_FlowHeightRamp", _FlowHeightRampOffset);
				}
				else
				{
					Material.SetTexture("_FlowHeightRamp", (Texture)null);
				}
				Material.SetFloat("_FlowHeightBias", _FlowHeightBias);
				Material.SetFloat("_FlowHeightPower", _FlowHeightPower);
				Material.SetFloat("_FlowEmissionStrength", _FlowEmissionStrength);
				Material.SetFloat("_FlowSpeed", _FlowSpeed);
				Material.SetFloat("_FlowMaskStrength", _MaskFlowStrength);
				Material.SetFloat("_FlowNormalStrength", _NormalFlowStrength);
				Material.SetFloat("_FlowTextureScaleFactor", _FlowTextureScaleFactor);
				SetShaderKeywordBasedOnBool(_EnableLimbRemoval, "LIMBREMOVAL");
			}
		}
	}
	public class HGCloudRemapController : HGBaseController
	{
		public enum _CullEnum
		{
			Off,
			Front,
			Back
		}

		public enum _ZTestEnum
		{
			Disabled,
			Never,
			Less,
			Equal,
			LessEqual,
			Greater,
			NotEqual,
			GreaterEqual,
			Always
		}

		public Color _Tint;

		public bool _DisableRemapping;

		public Texture _MainTex;

		public Vector2 _MainTexScale;

		public Vector2 _MainTexOffset;

		public Texture _RemapTex;

		public Vector2 _RemapTexScale;

		public Vector2 _RemapTexOffset;

		[Range(0f, 2f)]
		public float _SoftFactor;

		[Range(1f, 20f)]
		public float _BrightnessBoost;

		[Range(0f, 20f)]
		public float _AlphaBoost;

		[Range(0f, 1f)]
		public float _AlphaBias;

		public bool _UseUV1;

		public bool _FadeWhenNearCamera;

		[Range(0f, 1f)]
		public float _FadeCloseDistance;

		public _CullEnum _Cull_Mode;

		public _ZTestEnum _ZTest_Mode;

		[Range(-10f, 10f)]
		public float _DepthOffset;

		public bool _CloudRemapping;

		public bool _DistortionClouds;

		[Range(-2f, 2f)]
		public float _DistortionStrength;

		public Texture _Cloud1Tex;

		public Vector2 _Cloud1TexScale;

		public Vector2 _Cloud1TexOffset;

		public Texture _Cloud2Tex;

		public Vector2 _Cloud2TexScale;

		public Vector2 _Cloud2TexOffset;

		public Vector4 _CutoffScroll;

		public bool _VertexColors;

		public bool _LuminanceForVertexAlpha;

		public bool _LuminanceForTextureAlpha;

		public bool _VertexOffset;

		public bool _FresnelFade;

		public bool _SkyboxOnly;

		[Range(-20f, 20f)]
		public float _FresnelPower;

		[Range(0f, 3f)]
		public float _VertexOffsetAmount;

		public void Start()
		{
			GrabMaterialValues();
		}

		public void GrabMaterialValues()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Material))
			{
				_Tint = Material.GetColor("_TintColor");
				_DisableRemapping = Material.IsKeywordEnabled("DISABLEREMAP");
				_MainTex = Material.GetTexture("_MainTex");
				_MainTexScale = Material.GetTextureScale("_MainTex");
				_MainTexOffset = Material.GetTextureOffset("_MainTex");
				_RemapTex = Material.GetTexture("_RemapTex");
				_RemapTexScale = Material.GetTextureScale("_RemapTex");
				_RemapTexOffset = Material.GetTextureOffset("_RemapTex");
				_SoftFactor = Material.GetFloat("_InvFade");
				_BrightnessBoost = Material.GetFloat("_Boost");
				_AlphaBoost = Material.GetFloat("_AlphaBoost");
				_AlphaBias = Material.GetFloat("_AlphaBias");
				_UseUV1 = Material.IsKeywordEnabled("USE_UV1");
				_FadeWhenNearCamera = Material.IsKeywordEnabled("FADECLOSE");
				_FadeCloseDistance = Material.GetFloat("_FadeCloseDistance");
				_Cull_Mode = (_CullEnum)Material.GetFloat("_Cull");
				_ZTest_Mode = (_ZTestEnum)Material.GetFloat("_ZTest");
				_DepthOffset = Material.GetFloat("_DepthOffset");
				_CloudRemapping = Material.IsKeywordEnabled("USE_CLOUDS");
				_DistortionClouds = Material.IsKeywordEnabled("CLOUDOFFSET");
				_DistortionStrength = Material.GetFloat("_DistortionStrength");
				_Cloud1Tex = Material.GetTexture("_Cloud1Tex");
				_Cloud1TexScale = Material.GetTextureScale("_Cloud1Tex");
				_Cloud1TexOffset = Material.GetTextureOffset("_Cloud1Tex");
				_Cloud2Tex = Material.GetTexture("_Cloud2Tex");
				_Cloud2TexScale = Material.GetTextureScale("_Cloud2Tex");
				_Cloud2TexOffset = Material.GetTextureOffset("_Cloud2Tex");
				_CutoffScroll = Material.GetVector("_CutoffScroll");
				_VertexColors = Material.IsKeywordEnabled("VERTEXCOLOR");
				_LuminanceForVertexAlpha = Material.IsKeywordEnabled("VERTEXALPHA");
				_LuminanceForTextureAlpha = Material.IsKeywordEnabled("CALCTEXTUREALPHA");
				_VertexOffset = Material.IsKeywordEnabled("VERTEXOFFSET");
				_FresnelFade = Material.IsKeywordEnabled("FRESNEL");
				_SkyboxOnly = Material.IsKeywordEnabled("SKYBOX_ONLY");
				_FresnelPower = Material.GetFloat("_FresnelPower");
				_VertexOffsetAmount = Material.GetFloat("_OffsetAmount");
				MaterialName = ((Object)Material).name;
			}
		}

		public void Update()
		{
			//IL_004d: 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)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Material))
			{
				if (((Object)Material).name != MaterialName && Object.op_Implicit((Object)(object)Renderer))
				{
					GrabMaterialValues();
					PutMaterialIntoMeshRenderer();
				}
				Material.SetColor("_TintColor", _Tint);
				SetShaderKeywordBasedOnBool(_DisableRemapping, "DISABLEREMAP");
				if (Object.op_Implicit((Object)(object)_MainTex))
				{
					Material.SetTexture("_MainTex", _MainTex);
					Material.SetTextureScale("_MainTex", _MainTexScale);
					Material.SetTextureOffset("_MainTex", _MainTexOffset);
				}
				else
				{
					Material.SetTexture("_MainTex", (Texture)null);
				}
				if (Object.op_Implicit((Object)(object)_RemapTex))
				{
					Material.SetTexture("_RemapTex", _RemapTex);
					Material.SetTextureScale("_RemapTex", _RemapTexScale);
					Material.SetTextureOffset("_RemapTex", _RemapTexOffset);
				}
				else
				{
					Material.SetTexture("_RemapTex", (Texture)null);
				}
				Material.SetFloat("_InvFade", _SoftFactor);
				Material.SetFloat("_Boost", _BrightnessBoost);
				Material.SetFloat("_AlphaBoost", _AlphaBoost);
				Material.SetFloat("_AlphaBias", _AlphaBias);
				SetShaderKeywordBasedOnBool(_UseUV1, "USE_UV1");
				SetShaderKeywordBasedOnBool(_FadeWhenNearCamera, "FADECLOSE");
				Material.SetFloat("_FadeCloseDistance", _FadeCloseDistance);
				Material.SetFloat("_Cull", Convert.ToSingle(_Cull_Mode));
				Material.SetFloat("_ZTest", Convert.ToSingle(_ZTest_Mode));
				Material.SetFloat("_DepthOffset", _DepthOffset);
				SetShaderKeywordBasedOnBool(_CloudRemapping, "USE_CLOUDS");
				SetShaderKeywordBasedOnBool(_DistortionClouds, "CLOUDOFFSET");
				Material.SetFloat("_DistortionStrength", _DistortionStrength);
				if (Object.op_Implicit((Object)(object)_Cloud1Tex))
				{
					Material.SetTexture("_Cloud1Tex", _Cloud1Tex);
					Material.SetTextureScale("_Cloud1Tex", _Cloud1TexScale);
					Material.SetTextureOffset("_Cloud1Tex", _Cloud1TexOffset);
				}
				else
				{
					Material.SetTexture("_Cloud1Tex", (Texture)null);
				}
				if (Object.op_Implicit((Object)(object)_Cloud2Tex))
				{
					Material.SetTexture("_Cloud2Tex", _Cloud2Tex);
					Material.SetTextureScale("_Cloud2Tex", _Cloud2TexScale);
					Material.SetTextureOffset("_Cloud2Tex", _Cloud2TexOffset);
				}
				else
				{
					Material.SetTexture("_Cloud2Tex", (Texture)null);
				}
				Material.SetVector("_CutoffScroll", _CutoffScroll);
				SetShaderKeywordBasedOnBool(_VertexColors, "VERTEXCOLOR");
				SetShaderKeywordBasedOnBool(_LuminanceForVertexAlpha, "VERTEXALPHA");
				SetShaderKeywordBasedOnBool(_LuminanceForTextureAlpha, "CALCTEXTUREALPHA");
				SetShaderKeywordBasedOnBool(_VertexOffset, "VERTEXOFFSET");
				SetShaderKeywordBasedOnBool(_FresnelFade, "FRESNEL");
				SetShaderKeywordBasedOnBool(_SkyboxOnly, "SKYBOX_ONLY");
				Material.SetFloat("_FresnelPower", _FresnelPower);
				Material.SetFloat("_OffsetAmount", _VertexOffsetAmount);
			}
		}
	}
	public class HGIntersectionController : HGBaseController
	{
		public enum _SrcBlendFloatEnum
		{
			Zero,
			One,
			DstColor,
			SrcColor,
			OneMinusDstColor,
			SrcAlpha,
			OneMinusSrcColor,
			DstAlpha,
			OneMinusDstAlpha,
			SrcAlphaSaturate,
			OneMinusSrcAlpha
		}

		public enum _DstBlendFloatEnum
		{
			Zero,
			One,
			DstColor,
			SrcColor,
			OneMinusDstColor,
			SrcAlpha,
			OneMinusSrcColor,
			DstAlpha,
			OneMinusDstAlpha,
			SrcAlphaSaturate,
			OneMinusSrcAlpha
		}

		public enum _CullEnum
		{
			Off,
			Front,
			Back
		}

		public _SrcBlendFloatEnum _Source_Blend_Mode;

		public _DstBlendFloatEnum _Destination_Blend_Mode;

		public Color _Tint;

		public Texture _MainTex;

		public Vector2 _MainTexScale;

		public Vector2 _MainTexOffset;

		public Texture _Cloud1Tex;

		public Vector2 _Cloud1TexScale;

		public Vector2 _Cloud1TexOffset;

		public Texture _Cloud2Tex;

		public Vector2 _Cloud2TexScale;

		public Vector2 _Cloud2TexOffset;

		public Texture _RemapTex;

		public Vector2 _RemapTexScale;

		public Vector2 _RemapTexOffset;

		public Vector4 _CutoffScroll;

		[Range(0f, 30f)]
		public float _SoftFactor;

		[Range(0.1f, 20f)]
		public float _SoftPower;

		[Range(0f, 5f)]
		public float _BrightnessBoost;

		[Range(0.1f, 20f)]
		public float _RimPower;

		[Range(0f, 5f)]
		public float _RimStrength;

		[Range(0f, 20f)]
		public float _AlphaBoost;

		[Range(0f, 20f)]
		public float _IntersectionStrength;

		public _CullEnum _Cull_Mode;

		public bool _FadeFromVertexColorsOn;

		public bool _EnableTriplanarProjectionsForClouds;

		public void Start()
		{
			GrabMaterialValues();
		}

		public void GrabMaterialValues()
		{
			//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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_0110: 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_013c: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Material))
			{
				_Source_Blend_Mode = (_SrcBlendFloatEnum)Material.GetFloat("_SrcBlendFloat");
				_Destination_Blend_Mode = (_DstBlendFloatEnum)Material.GetFloat("_DstBlendFloat");
				_Tint = Material.GetColor("_TintColor");
				_MainTex = Material.GetTexture("_MainTex");
				_MainTexScale = Material.GetTextureScale("_MainTex");
				_MainTexOffset = Material.GetTextureOffset("_MainTex");
				_Cloud1Tex = Material.GetTexture("_Cloud1Tex");
				_Cloud1TexScale = Material.GetTextureScale("_Cloud1Tex");
				_Cloud1TexOffset = Material.GetTextureOffset("_Cloud1Tex");
				_Cloud2Tex = Material.GetTexture("_Cloud2Tex");
				_Cloud2TexScale = Material.GetTextureScale("_Cloud2Tex");
				_Cloud2TexOffset = Material.GetTextureOffset("_Cloud2Tex");
				_RemapTex = Material.GetTexture("_RemapTex");
				_RemapTexScale = Material.GetTextureScale("_RemapTex");
				_RemapTexOffset = Material.GetTextureOffset("_RemapTex");
				_CutoffScroll = Material.GetVector("_CutoffScroll");
				_SoftFactor = Material.GetFloat("_InvFade");
				_SoftPower = Material.GetFloat("_SoftPower");
				_BrightnessBoost = Material.GetFloat("_Boost");
				_RimPower = Material.GetFloat("_RimPower");
				_RimStrength = Material.GetFloat("_RimStrength");
				_AlphaBoost = Material.GetFloat("_AlphaBoost");
				_IntersectionStrength = Material.GetFloat("_IntersectionStrength");
				_Cull_Mode = (_CullEnum)Material.GetFloat("_Cull");
				_FadeFromVertexColorsOn = Material.IsKeywordEnabled("FADE_FROM_VERTEX_COLORS");
				_EnableTriplanarProjectionsForClouds = Material.IsKeywordEnabled("TRIPLANAR");
				MaterialName = ((Object)Material).name;
			}
		}

		public void Update()
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Material))
			{
				if (((Object)Material).name != MaterialName && Object.op_Implicit((Object)(object)Renderer))
				{
					GrabMaterialValues();
					PutMaterialIntoMeshRenderer();
				}
				Material.SetFloat("_SrcBlendFloat", Convert.ToSingle(_Source_Blend_Mode));
				Material.SetFloat("_DstBlendFloat", Convert.ToSingle(_Destination_Blend_Mode));
				Material.SetColor("_TintColor", _Tint);
				if (Object.op_Implicit((Object)(object)_MainTex))
				{
					Material.SetTexture("_MainTex", _MainTex);
					Material.SetTextureScale("_MainTex", _MainTexScale);
					Material.SetTextureOffset("_MainTex", _MainTexOffset);
				}
				else
				{
					Material.SetTexture("_MainTex", (Texture)null);
				}
				if (Object.op_Implicit((Object)(object)_Cloud1Tex))
				{
					Material.SetTexture("_Cloud1Tex", _Cloud1Tex);
					Material.SetTextureScale("_Cloud1Tex", _Cloud1TexScale);
					Material.SetTextureOffset("_Cloud1Tex", _Cloud1TexOffset);
				}
				else
				{
					Material.SetTexture("_Cloud1Tex", (Texture)null);
				}
				if (Object.op_Implicit((Object)(object)_Cloud2Tex))
				{
					Material.SetTexture("_Cloud2Tex", _Cloud2Tex);
					Material.SetTextureScale("_Cloud2Tex", _Cloud2TexScale);
					Material.SetTextureOffset("_Cloud2Tex", _Cloud2TexOffset);
				}
				else
				{
					Material.SetTexture("_Cloud2Tex", (Texture)null);
				}
				if (Object.op_Implicit((Object)(object)_RemapTex))
				{
					Material.SetTexture("_RemapTex", _RemapTex);
					Material.SetTextureScale("_RemapTex", _RemapTexScale);
					Material.SetTextureOffset("_RemapTex", _RemapTexOffset);
				}
				else
				{
					Material.SetTexture("_RemapTex", (Texture)null);
				}
				Material.SetVector("_CutoffScroll", _CutoffScroll);
				Material.SetFloat("_InvFade", _SoftFactor);
				Material.SetFloat("_SoftPower", _SoftPower);
				Material.SetFloat("_Boost", _BrightnessBoost);
				Material.SetFloat("_RimPower", _RimPower);
				Material.SetFloat("_RimStrength", _RimStrength);
				Material.SetFloat("_AlphaBoost", _AlphaBoost);
				Material.SetFloat("_IntersectionStrength", _IntersectionStrength);
				Material.SetFloat("_Cull", Convert.ToSingle(_Cull_Mode));
				SetShaderKeywordBasedOnBool(_FadeFromVertexColorsOn, "FADE_FROM_VERTEX_COLORS");
				SetShaderKeywordBasedOnBool(_EnableTriplanarProjectionsForClouds, "TRIPLANAR");
			}
		}
	}
	public static class MinionExtensions
	{
		internal class SyncOwner : INetMessage, ISerializableObject
		{
			private NetworkInstanceId minionNetId;

			private NetworkInstanceId ownerNetId;

			private bool useQueue;

			public SyncOwner()
			{
			}

			public SyncOwner(NetworkInstanceId minionNetId, NetworkInstanceId ownerNetId, bool useQueue)
			{
				//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_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)
				this.minionNetId = minionNetId;
				this.ownerNetId = ownerNetId;
				this.useQueue = useQueue;
			}

			public void Serialize(NetworkWriter writer)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				writer.Write(minionNetId);
				writer.Write(ownerNetId);
				writer.Write(useQueue);
			}

			public void Deserialize(NetworkReader reader)
			{
				//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_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)
				minionNetId = reader.ReadNetworkId();
				ownerNetId = reader.ReadNetworkId();
				useQueue = reader.ReadBoolean();
			}

			public void OnReceived()
			{
				//IL_0039: 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_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)
				if (NetworkServer.active)
				{
					return;
				}
				if (useQueue)
				{
					OwnershipSyncer orAddComponent = ((Component)Run.instance).gameObject.GetOrAddComponent<OwnershipSyncer>();
					orAddComponent.Add(new OwnershipSyncer.OwnerMinionPair(minionNetId, ownerNetId));
					return;
				}
				GameObject val = Util.FindNetworkObject(minionNetId);
				GameObject val2 = Util.FindNetworkObject(ownerNetId);
				if (!Object.op_Implicit((Object)(object)val))
				{
					HelperPlugin.Log.Warning("SyncOwner: minionObject or ownerObject is null.");
				}
				if (!Object.op_Implicit((Object)(object)val2))
				{
					HelperPlugin.Log.Warning("SyncOwner: ownerObject is null.");
				}
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2))
				{
					ProcessAssignment(val, val2, "SyncOwner");
				}
			}
		}

		internal class OwnershipSyncer : QueueProcessor<OwnershipSyncer.OwnerMinionPair>
		{
			internal struct OwnerMinionPair
			{
				public NetworkInstanceId minionNetId;

				public NetworkInstanceId ownerNetId;

				public OwnerMinionPair(NetworkInstanceId minionNetId, NetworkInstanceId ownerNetId)
				{
					//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_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)
					this.minionNetId = minionNetId;
					this.ownerNetId = ownerNetId;
				}
			}

			protected override int itemsPerFrame { get; set; } = 1;


			protected override float processInterval { get; set; }

			protected override bool Process(OwnerMinionPair pair)
			{
				//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)
				GameObject val = Util.FindNetworkObject(pair.minionNetId);
				GameObject val2 = Util.FindNetworkObject(pair.ownerNetId);
				if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2))
				{
					return false;
				}
				ProcessAssignment(val, val2, "OwnershipSyncer");
				return true;
			}

			protected override void FixedUpdate()
			{
				base.FixedUpdate();
				if (processQueue.Count <= 0)
				{
					Object.Destroy((Object)(object)this);
				}
			}
		}

		public static void LoopMinions(this CharacterMaster ownerOrMinion, Action<CharacterMaster> logic)
		{
			MinionOwnership minionOwnership = ownerOrMinion.minionOwnership;
			if (!Object.op_Implicit((Object)(object)minionOwnership))
			{
				return;
			}
			MinionOwnership[] array = Object.FindObjectsOfType<MinionOwnership>();
			MinionOwnership[] array2 = array;
			foreach (MinionOwnership val in array2)
			{
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.ownerMaster))
				{
					bool flag = !Object.op_Implicit((Object)(object)minionOwnership.ownerMaster) && (Object)(object)val.ownerMaster == (Object)(object)ownerOrMinion;
					bool flag2 = Object.op_Implicit((Object)(object)minionOwnership.ownerMaster) && (Object)(object)val.ownerMaster == (Object)(object)minionOwnership.ownerMaster;
					if (flag || flag2)
					{
						CharacterMaster component = ((Component)val).GetComponent<CharacterMaster>();
						logic(component);
					}
				}
			}
		}

		public static List<T> GetAllMinionComponents<T>(this CharacterMaster ownerOrMinion) where T : Component
		{
			List<T> list = new List<T>();
			ownerOrMinion.LoopMinions(delegate(CharacterMaster minion)
			{
				T component = ((Component)minion).gameObject.GetComponent<T>();
				if (Object.op_Implicit((Object)(object)component))
				{
					list.Add(component);
				}
			});
			return list;
		}

		public static void AssignOwner(this CharacterMaster minion, CharacterMaster newOwner, bool transmit = false, bool useQueue = false)
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active)
			{
				minion.minionOwnership.SetOwner(newOwner);
				if (transmit)
				{
					NetworkIdentity component = ((Component)minion).gameObject.GetComponent<NetworkIdentity>();
					NetworkIdentity component2 = ((Component)newOwner).gameObject.GetComponent<NetworkIdentity>();
					if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component2))
					{
						HelperPlugin.Log.Warning("AssignOwner with transmit: NetworkIdentity is missing.");
					}
					else
					{
						NetMessageExtensions.Send((INetMessage)(object)new SyncOwner(component.netId, component2.netId, useQueue), (NetworkDestination)1);
					}
				}
			}
			else
			{
				NetworkIdentity component3 = ((Component)newOwner).gameObject.GetComponent<NetworkIdentity>();
				if (!Object.op_Implicit((Object)(object)component3))
				{
					HelperPlugin.Log.Warning("AssignOwner: Network Identity is missing!");
					return;
				}
				minion.minionOwnership.ownerMasterId = component3.netId;
				MinionGroup.SetMinionOwner(minion.minionOwnership, component3.netId);
			}
		}

		internal static void ProcessAssignment(GameObject minionObject, GameObject ownerObject, string caller)
		{
			CharacterMaster component = minionObject.GetComponent<CharacterMaster>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				HelperPlugin.Log.Warning(caller + ": minion is null.");
			}
			CharacterMaster component2 = ownerObject.GetComponent<CharacterMaster>();
			if (!Object.op_Implicit((Object)(object)component2))
			{
				HelperPlugin.Log.Warning(caller + ": owner is null.");
			}
			if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component2))
			{
				component.AssignOwner(component2);
			}
		}
	}
	public static class MultiplayerTest
	{
		private const string defaultEnableMessage = "Multiplayer Testing is enabled! If you see this message, report this as a bug to the mod developer!";

		private const string defaultDisableMessage = "Multiplayer Testing disabled.";

		private static void OnClientConnect(orig_OnClientConnect orig, NetworkManagerSystem self, NetworkConnection conn)
		{
		}

		private static void Enable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			NetworkManagerSystem.OnClientConnect += new hook_OnClientConnect(OnClientConnect);
		}

		private static void Disable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			NetworkManagerSystem.OnClientConnect -= new hook_OnClientConnect(OnClientConnect);
		}

		public static void Enable(ManualLogSource logger, string message = "Multiplayer Testing is enabled! If you see this message, report this as a bug to the mod developer!")
		{
			if (logger != null)
			{
				logger.LogWarning((object)message);
			}
			Enable();
		}

		public static void Enable(Log logger, string message = "Multiplayer Testing is enabled! If you see this message, report this as a bug to the mod developer!")
		{
			logger?.Warning(message);
			Enable();
		}

		public static void Disable(ManualLogSource logger, string message = "Multiplayer Testing disabled.")
		{
			if (logger != null)
			{
				logger.LogWarning((object)message);
			}
			Disable();
		}

		public static void Disable(Log logger, string message = "Multiplayer Testing disabled.")
		{
			logger?.Warning(message);
			Disable();
		}
	}
	public class SoundPlayer
	{
		public struct EventPosterKey
		{
			public KeyCode key;

			public List<uint> eventIds;

			public EventPosterKey(KeyCode key, params uint[] eventIds)
			{
				//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)
				this.key = key;
				this.eventIds = new List<uint>();
				this.eventIds.AddRange(eventIds);
			}
		}

		private readonly Dictionary<KeyCode, List<uint>> keybinds = new Dictionary<KeyCode, List<uint>>();

		public SoundPlayer(params EventPosterKey[] eventPosterKeys)
		{
			foreach (EventPosterKey eventPosterKey in eventPosterKeys)
			{
				RegisterKeybind(eventPosterKey);
			}
		}

		public void Update()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<KeyCode, List<uint>> keybind in keybinds)
			{
				if (!Input.GetKeyDown(keybind.Key))
				{
					continue;
				}
				foreach (uint item in keybind.Value)
				{
					AkSoundEngine.PostEvent(item, Instances.hostBodyObject);
				}
			}
		}

		public void RegisterKeybind(EventPosterKey eventPosterKey)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			keybinds[eventPosterKey.key] = eventPosterKey.eventIds;
		}

		public void RegisterKeybind(KeyCode key, params uint[] eventIds)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			keybinds[key] = eventIds.ToList();
		}
	}
}
namespace Chen.Helpers.CollectionHelpers
{
	public static class Extensions
	{
		public static bool ConditionalAdd<T>(this List<T> list, T value, Func<T, bool> condition)
		{
			if (list.Exists((T item) => condition(item)))
			{
				return false;
			}
			list.Add(value);
			return true;
		}

		public static bool ConditionalAddRange<T>(this List<T> list, T[] data, Func<T, T, bool> condition)
		{
			bool flag = true;
			foreach (T datum in data)
			{
				bool flag2 = list.ConditionalAdd(datum, (T item) => condition(item, datum));
				if (flag && !flag2)
				{
					flag = false;
				}
			}
			return flag;
		}

		public static bool ConditionalRemove<T>(this List<T> list, T value)
		{
			if (!list.Contains(value))
			{
				return false;
			}
			list.Remove(value);
			return true;
		}

		public static bool Contains<T>(this T[] array, T value)
		{
			for (int i = 0; i < array.Length; i++)
			{
				T val = array[i];
				if (val.Equals(value))
				{
					return true;
				}
			}
			return false;
		}

		public static List<T> ToList<T>(this T[] array)
		{
			List<T> list = new List<T>();
			list.AddRange(array);
			return list;
		}
	}
}