Decompiled source of TGCore v2.0.5

TGCore.dll

Decompiled 3 days ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using DM;
using EzECS.Barriers;
using HarmonyLib;
using Landfall.MonoBatch;
using Landfall.TABC;
using Landfall.TABS;
using Landfall.TABS.AI;
using Landfall.TABS.AI.Components;
using Landfall.TABS.AI.Components.Modifiers;
using Landfall.TABS.AI.Components.Pathfinding;
using Landfall.TABS.AI.Components.Tags;
using Landfall.TABS.AI.Systems;
using Landfall.TABS.GameMode;
using Landfall.TABS.GameState;
using Landfall.TABS.RuntimeCleanup;
using Landfall.TABS.UnitEditor;
using Landfall.TABS.Workshop;
using LevelCreator;
using Microsoft.CodeAnalysis;
using Pathfinding;
using Photon.Bolt;
using RootMotion.FinalIK;
using TFBGames;
using TGCore.Library;
using TGCore.Localization;
using TGCore.Properties;
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
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: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("TGCore")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+02f7fdbf30565a4686e257af49039563604dafbc")]
[assembly: AssemblyProduct("TGCore")]
[assembly: AssemblyTitle("TGCore")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TGCore
{
	public static class TGAddons
	{
		public static object InvokeMethod<T>(this T obj, string methodName, params object[] args)
		{
			Type typeFromHandle = typeof(T);
			MethodInfo declaredMethod = typeFromHandle.GetTypeInfo().GetDeclaredMethod(methodName);
			return declaredMethod.Invoke(obj, args);
		}

		public static T SetField<T>(this T self, string name, object value) where T : class
		{
			FieldInfo field = typeof(T).GetField(name, (BindingFlags)(-1));
			if (field != null)
			{
				field.SetValue(self, value);
			}
			return self;
		}

		public static object GetField<T>(this T self, string name) where T : class
		{
			FieldInfo field = typeof(T).GetField(name, (BindingFlags)(-1));
			if (field != null)
			{
				return field.GetValue(self);
			}
			return null;
		}

		public static string DeepString(this GameObject self)
		{
			string text = "\nGameObject '" + ((Object)self).name + "':\n{\n\tComponents:\n\t{\n";
			text = string.Concat(text, string.Concat(from Component component in self.GetComponents<Component>()
				select "\t\t" + ((object)component).GetType().Name + "\n"));
			text += "\t}\n";
			if (self.transform.childCount > 0)
			{
				text += "\tChildren:\n\t{\n";
				text = string.Concat(text, string.Concat(from Transform child in (IEnumerable)self.transform
					select ((Component)child).gameObject.DeepString().Replace("\n", "\n\t\t")));
				text += "\n\t}\n";
			}
			return text + "}\n";
		}

		public static T DeepCopyOf<T>(this T self, T from) where T : class
		{
			FieldInfo[] fields = typeof(T).GetFields((BindingFlags)(-1));
			foreach (FieldInfo fieldInfo in fields)
			{
				try
				{
					fieldInfo.SetValue(self, fieldInfo.GetValue(from));
				}
				catch
				{
				}
			}
			PropertyInfo[] properties = typeof(T).GetProperties((BindingFlags)(-1));
			foreach (PropertyInfo propertyInfo in properties)
			{
				if (propertyInfo.CanWrite && propertyInfo.CanRead)
				{
					try
					{
						propertyInfo.SetValue(self, propertyInfo.GetValue(from));
					}
					catch
					{
					}
				}
			}
			return self;
		}

		public static SettingsInstance CreateSetting(SettingsType settingsType, string settingName, string toolTip, string settingListToAddTo, float defaultValue, float currentValue, string[] options = null, float min = 0f, float max = 1f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_002a: 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_003a: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			SettingsInstance val = new SettingsInstance
			{
				settingName = settingName,
				toolTip = toolTip,
				m_settingsKey = settingName,
				settingsType = settingsType,
				options = options,
				min = min,
				max = max,
				defaultValue = (int)defaultValue,
				currentValue = (int)currentValue,
				defaultSliderValue = defaultValue,
				currentSliderValue = currentValue
			};
			GlobalSettingsHandler service = ServiceLocator.GetService<GlobalSettingsHandler>();
			List<SettingsInstance> list = (settingListToAddTo switch
			{
				"BUG" => service.BugsSettings, 
				"VIDEO" => service.VideoSettings, 
				"AUDIO" => service.AudioSettings, 
				"CONTROLS" => service.ControlSettings, 
				_ => service.GameplaySettings, 
			}).ToList();
			list.Add(val);
			switch (settingListToAddTo)
			{
			case "BUG":
				typeof(GlobalSettingsHandler).GetField("m_bugsSettings", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(service, list.ToArray());
				break;
			case "VIDEO":
				typeof(GlobalSettingsHandler).GetField("m_videoSettings", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(service, list.ToArray());
				break;
			case "AUDIO":
				typeof(GlobalSettingsHandler).GetField("m_audioSettings", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(service, list.ToArray());
				break;
			case "CONTROLS":
				typeof(GlobalSettingsHandler).GetField("m_controlSettings", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(service, list.ToArray());
				break;
			default:
				typeof(GlobalSettingsHandler).GetField("m_gameplaySettings", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(service, list.ToArray());
				break;
			}
			return val;
		}

		public static void AddItems(IEnumerable<UnitBlueprint> newUnits, IEnumerable<Faction> newFactions, IEnumerable<TABSCampaignAsset> newCampaigns, IEnumerable<TABSCampaignLevelAsset> newCampaignLevels, IEnumerable<VoiceBundle> newVoiceBundles, IEnumerable<FactionIcon> newFactionIcons, IEnumerable<Unit> newUnitBases, IEnumerable<PropItem> newProps, IEnumerable<SpecialAbility> newAbilities, IEnumerable<WeaponItem> newWeapons, IEnumerable<ProjectileEntity> newProjectiles)
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_055f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0572: Unknown result type (might be due to invalid IL or missing references)
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			//IL_064c: Unknown result type (might be due to invalid IL or missing references)
			//IL_070a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0724: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0992: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ac: Unknown result type (might be due to invalid IL or missing references)
			LandfallContentDatabase landfallContentDatabase = ContentDatabase.Instance().LandfallContentDatabase;
			Dictionary<DatabaseID, Object> dictionary = (Dictionary<DatabaseID, Object>)(typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(ContentDatabase.Instance().AssetLoader));
			Dictionary<DatabaseID, UnitBlueprint> units = (Dictionary<DatabaseID, UnitBlueprint>)(typeof(LandfallContentDatabase).GetField("m_unitBlueprints", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(landfallContentDatabase));
			foreach (UnitBlueprint item in newUnits.Where((UnitBlueprint unit) => Object.op_Implicit((Object)(object)unit) && units != null && !units.ContainsKey(unit.Entity.GUID)))
			{
				units.Add(item.Entity.GUID, item);
				dictionary.Add(item.Entity.GUID, (Object)(object)item);
			}
			typeof(LandfallContentDatabase).GetField("m_unitBlueprints", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(landfallContentDatabase, units);
			Dictionary<DatabaseID, Faction> factions = (Dictionary<DatabaseID, Faction>)(typeof(LandfallContentDatabase).GetField("m_factions", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(landfallContentDatabase));
			List<DatabaseID> list = (List<DatabaseID>)(typeof(LandfallContentDatabase).GetField("m_defaultHotbarFactionIds", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(landfallContentDatabase));
			foreach (Faction item2 in newFactions.Where((Faction faction) => Object.op_Implicit((Object)(object)faction) && factions != null && !factions.ContainsKey(faction.Entity.GUID)))
			{
				factions.Add(item2.Entity.GUID, item2);
				dictionary.Add(item2.Entity.GUID, (Object)(object)item2);
				list.Add(item2.Entity.GUID);
			}
			typeof(LandfallContentDatabase).GetField("m_factions", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(landfallContentDatabase, factions);
			typeof(LandfallContentDatabase).GetField("m_defaultHotbarFactionIds", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(landfallContentDatabase, list.OrderBy((DatabaseID x) => factions[x].index).ToList());
			TGMain.NewFactions.AddRange(newFactions);
			Dictionary<DatabaseID, TABSCampaignAsset> campaigns = (Dictionary<DatabaseID, TABSCampaignAsset>)(typeof(LandfallContentDatabase).GetField("m_campaigns", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(landfallContentDatabase));
			foreach (TABSCampaignAsset item3 in newCampaigns.Where((TABSCampaignAsset campaign) => Object.op_Implicit((Object)(object)campaign) && campaigns != null && !campaigns.ContainsKey(campaign.Entity.GUID)))
			{
				campaigns.Add(item3.Entity.GUID, item3);
				dictionary.Add(item3.Entity.GUID, (Object)(object)item3);
			}
			typeof(LandfallContentDatabase).GetField("m_campaigns", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(landfallContentDatabase, campaigns);
			Dictionary<DatabaseID, TABSCampaignLevelAsset> campaignLevels = (Dictionary<DatabaseID, TABSCampaignLevelAsset>)typeof(LandfallContentDatabase).GetField("m_campaignLevels", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
			foreach (TABSCampaignLevelAsset item4 in newCampaignLevels.Where((TABSCampaignLevelAsset campaignLevel) => Object.op_Implicit((Object)(object)campaignLevel) && campaignLevels != null && !campaignLevels.ContainsKey(campaignLevel.Entity.GUID)))
			{
				campaignLevels.Add(item4.Entity.GUID, item4);
				dictionary.Add(item4.Entity.GUID, (Object)(object)item4);
			}
			typeof(LandfallContentDatabase).GetField("m_campaignLevels", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, campaignLevels);
			Dictionary<DatabaseID, VoiceBundle> voiceBundles = (Dictionary<DatabaseID, VoiceBundle>)typeof(LandfallContentDatabase).GetField("m_voiceBundles", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
			foreach (VoiceBundle item5 in newVoiceBundles.Where((VoiceBundle voiceBundle) => Object.op_Implicit((Object)(object)voiceBundle) && voiceBundles != null && !voiceBundles.ContainsKey(voiceBundle.Entity.GUID)))
			{
				voiceBundles.Add(item5.Entity.GUID, item5);
				dictionary.Add(item5.Entity.GUID, (Object)(object)item5);
			}
			typeof(LandfallContentDatabase).GetField("m_voiceBundles", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, voiceBundles);
			List<DatabaseID> factionIcons = (List<DatabaseID>)typeof(LandfallContentDatabase).GetField("m_factionIconIds", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
			foreach (FactionIcon item6 in newFactionIcons.Where((FactionIcon factionIcon) => Object.op_Implicit((Object)(object)factionIcon) && factionIcons != null && !factionIcons.Contains(factionIcon.Entity.GUID)))
			{
				factionIcons.Add(item6.Entity.GUID);
				dictionary.Add(item6.Entity.GUID, (Object)(object)item6);
			}
			typeof(LandfallContentDatabase).GetField("m_factionIconIds", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, factionIcons);
			Dictionary<DatabaseID, GameObject> unitBases = (Dictionary<DatabaseID, GameObject>)(typeof(LandfallContentDatabase).GetField("m_unitBases", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(landfallContentDatabase));
			foreach (Unit item7 in newUnitBases.Where((Unit unitBase) => Object.op_Implicit((Object)(object)unitBase) && unitBases != null && !unitBases.ContainsKey(unitBase.Entity.GUID)))
			{
				unitBases.Add(item7.Entity.GUID, ((Component)item7).gameObject);
				dictionary.Add(item7.Entity.GUID, (Object)(object)((Component)item7).gameObject);
			}
			typeof(LandfallContentDatabase).GetField("m_unitBases", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, unitBases);
			Dictionary<DatabaseID, GameObject> props = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_characterProps", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
			foreach (PropItem item8 in newProps.Where((PropItem prop) => Object.op_Implicit((Object)(object)prop) && props != null && !props.ContainsKey(((CharacterItem)prop).Entity.GUID)))
			{
				props.Add(((CharacterItem)item8).Entity.GUID, ((Component)item8).gameObject);
				dictionary.Add(((CharacterItem)item8).Entity.GUID, (Object)(object)((Component)item8).gameObject);
			}
			typeof(LandfallContentDatabase).GetField("m_characterProps", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, props);
			Dictionary<DatabaseID, GameObject> abilities = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_combatMoves", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
			foreach (SpecialAbility item9 in newAbilities.Where((SpecialAbility ability) => Object.op_Implicit((Object)(object)ability) && abilities != null && !abilities.ContainsKey(((CharacterItem)ability).Entity.GUID)))
			{
				abilities.Add(((CharacterItem)item9).Entity.GUID, ((Component)item9).gameObject);
				dictionary.Add(((CharacterItem)item9).Entity.GUID, (Object)(object)((Component)item9).gameObject);
			}
			typeof(LandfallContentDatabase).GetField("m_combatMoves", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, abilities);
			Dictionary<DatabaseID, GameObject> weapons = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_weapons", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
			foreach (WeaponItem item10 in newWeapons.Where((WeaponItem weapon) => Object.op_Implicit((Object)(object)weapon) && weapons != null && !weapons.ContainsKey(((CharacterItem)weapon).Entity.GUID)))
			{
				weapons.Add(((CharacterItem)item10).Entity.GUID, ((Component)item10).gameObject);
				dictionary.Add(((CharacterItem)item10).Entity.GUID, (Object)(object)((Component)item10).gameObject);
			}
			typeof(LandfallContentDatabase).GetField("m_weapons", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, weapons);
			Dictionary<DatabaseID, GameObject> projectiles = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_projectiles", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
			foreach (ProjectileEntity item11 in newProjectiles.Where((ProjectileEntity proj) => Object.op_Implicit((Object)(object)proj) && projectiles != null && !projectiles.ContainsKey(proj.Entity.GUID)))
			{
				projectiles.Add(item11.Entity.GUID, ((Component)item11).gameObject);
				dictionary.Add(item11.Entity.GUID, (Object)(object)((Component)item11).gameObject);
			}
			typeof(LandfallContentDatabase).GetField("m_projectiles", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, projectiles);
		}

		public static void AddTeamColors(UnitEditorColorPalette colorPalette)
		{
			if (Object.op_Implicit((Object)(object)colorPalette))
			{
				UnitEditorColorPalette unitEditorColorPalette = ContentDatabase.Instance().LandfallContentDatabase.GetUnitEditorColorPalette();
				TeamColorPaletteData[] source = (TeamColorPaletteData[])colorPalette.GetField<UnitEditorColorPalette>("m_teamColors");
				ParentCatagories[] array = (ParentCatagories[])unitEditorColorPalette.GetField<UnitEditorColorPalette>("m_ColorPalleteParentCatagories");
				List<TeamColorPaletteData> list = array[1].colorPaletteCatagories[0].TeamColors.ToList();
				list.AddRange(source.ToList());
				array[1].colorPaletteCatagories[0].TeamColors = Enumerable.ToArray(list);
				unitEditorColorPalette.SetField<UnitEditorColorPalette>("m_ColorPalleteParentCatagories", array);
				unitEditorColorPalette.Initialize();
			}
		}
	}
	[BepInPlugin("teamgrad.core", "Team Grad Core", "2.0.5")]
	public class TGMain : BaseUnityPlugin
	{
		public static TGMain instance;

		public static AssetBundle tgcore = AssetBundle.LoadFromMemory(Resources.tgcore);

		public static List<TGMod> modList = new List<TGMod>();

		public static List<SoundBank> newSounds = new List<SoundBank>();

		public static List<DMEditorObjectTable> objectTables = new List<DMEditorObjectTable>();

		public static List<Faction> NewFactions = new List<Faction>();

		public static ContentDatabase DB => ContentDatabase.Instance();

		public static LandfallContentDatabase landfallDb => ContentDatabase.Instance().LandfallContentDatabase;

		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			instance = this;
			Debug.Log((object)"LOADING TGCORE...");
			new Harmony("TGCore").PatchAll();
			((MonoBehaviour)this).StartCoroutine(InitializeMods());
			SceneManager.sceneLoaded += OnSceneLoad;
		}

		private IEnumerator InitializeMods()
		{
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
			ServiceLocator.GetService<CustomContentLoaderModIO>().QuickRefresh((WorkshopContentType)0, (Action)null);
			UnitBlueprint vampire = DB.GetUnitBlueprint(new DatabaseID(-1, 164120656));
			if (Object.op_Implicit((Object)(object)vampire))
			{
				List<GameObject> abilities = new List<GameObject>(vampire.objectsToSpawnAsChildren) { tgcore.LoadAsset<GameObject>("Move_Vampire_Vampire") };
				vampire.objectsToSpawnAsChildren = abilities.ToArray();
			}
			TGAddons.AddTeamColors(tgcore.LoadAsset<UnitEditorColorPalette>("UCColorPalette"));
			LocalizationHolder languageHolder = ((Component)this).gameObject.AddComponent<LocalizationHolder>();
			modList = Chainloader.ManagerObject.GetComponents<TGMod>().ToList();
			List<TGMod> failedModList = new List<TGMod>();
			foreach (TGMod mod in modList)
			{
				try
				{
					Debug.Log((object)"LOADING MOD...");
					mod.Launch();
					mod.AddSettings();
					mod.Localize(languageHolder);
					SceneManager.sceneLoaded += mod.SceneManager;
				}
				catch (Exception ex)
				{
					failedModList.Add(mod);
					Debug.LogError((object)"A MOD HAS FAILED TO LAUNCH:");
					Debug.LogError((object)ex);
				}
			}
			modList.RemoveAll((TGMod x) => failedModList.Contains(x));
			UpdateSoundBank();
			languageHolder.ReadLocalization();
			foreach (TGMod mod2 in modList)
			{
				try
				{
					mod2.LateLaunch();
				}
				catch (Exception ex2)
				{
					Debug.LogError((object)"A MOD HAS FAILED TO LAUNCH:");
					Debug.LogError((object)ex2);
				}
			}
			modList.RemoveAll((TGMod x) => failedModList.Contains(x));
		}

		public void UpdateSoundBank()
		{
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: 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_0161: Expected O, but got Unknown
			Debug.Log((object)"UPDATING SOUNDS...");
			foreach (SoundBank newSound in newSounds)
			{
				try
				{
					if (((Object)newSound).name.Contains("Sound"))
					{
						SoundBank soundBank = ServiceLocator.GetService<SoundPlayer>().soundBank;
						SoundBankCategory[] categories = newSound.Categories;
						foreach (SoundBankCategory val in categories)
						{
							val.categoryMixerGroup = soundBank.Categories[0].categoryMixerGroup;
						}
						List<SoundBankCategory> list = soundBank.Categories.ToList();
						list.AddRange(newSound.Categories);
						soundBank.Categories = list.ToArray();
					}
					else
					{
						if (!((Object)newSound).name.Contains("Music"))
						{
							continue;
						}
						SoundBank bank = ServiceLocator.GetService<MusicHandler>().bank;
						List<SoundBankCategory> list2 = bank.Categories.ToList();
						list2.AddRange(newSound.Categories);
						SoundBankCategory[] categories2 = newSound.Categories;
						foreach (SoundBankCategory val2 in categories2)
						{
							SoundEffectInstance[] soundEffects = val2.soundEffects;
							foreach (SoundEffectInstance val3 in soundEffects)
							{
								SongInstance val4 = new SongInstance
								{
									clip = val3.clipTypes[0].clips[0],
									soundEffectInstance = val3,
									songRef = val2.categoryName + "/" + val3.soundRef
								};
								ServiceLocator.GetService<MusicHandler>().m_songs.Add(val4.songRef, val4);
							}
						}
						bank.Categories = list2.ToArray();
						continue;
					}
				}
				catch (Exception ex)
				{
					Debug.LogError((object)"UPDATING SOUNDS HAS FAILED:");
					Debug.LogError((object)ex);
				}
			}
		}

		public void OnSceneLoad(Scene scene, LoadSceneMode loadSceneMode)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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)
			if (((Scene)(ref scene)).name.Contains("GameScene"))
			{
				GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
				foreach (GameObject val in rootGameObjects)
				{
					Transform val2 = TransformExtensions.FindChildRecursive(val.transform, "HealthBar");
					if (Object.op_Implicit((Object)(object)val2))
					{
						GameObject gameObject = ((Component)TransformExtensions.FindChildRecursive(val2, "Fill")).gameObject;
						GameObject val3 = Object.Instantiate<GameObject>(gameObject, gameObject.transform.position, gameObject.transform.rotation, val2);
						RectTransform component = val3.GetComponent<RectTransform>();
						RectTransformExtensions.SetTop(component, -10f);
						RectTransformExtensions.SetBottom(component, 15f);
						Image component2 = val3.GetComponent<Image>();
						((Graphic)component2).color = Color.yellow;
						component2.fillAmount = 0f;
						val3.AddComponent<UpdateBarByBarrier>().image = component2;
					}
				}
				return;
			}
			if (((Scene)(ref scene)).name.Contains("Editor Scene"))
			{
				DMEditorObjectTable val4 = (from x in ((Scene)(ref scene)).GetRootGameObjects()
					where Object.op_Implicit((Object)(object)x.GetComponent<DMEditor>())
					select x.GetComponent<DMEditor>().editorObjectTable).ToArray()[0];
				{
					foreach (DMEditorObjectTable objectTable in objectTables)
					{
						DMEditorObjectRow[] rowValues = ((DataTable<DMEditorObjectRow>)(object)objectTable).GetRowValues();
						for (int num = 0; num < rowValues.Length; num++)
						{
							((DataTable<DMEditorObjectRow>)(object)val4).AddRow(((DataTable<DMEditorObjectRow>)(object)objectTable).GetKeys()[num], rowValues[num]);
						}
					}
					return;
				}
			}
			if (((Scene)(ref scene)).name.Contains("LevelScene"))
			{
				DMEditorObjectTable val5 = (from x in ((Scene)(ref scene)).GetRootGameObjects()
					where Object.op_Implicit((Object)(object)x.GetComponent<SpawnLevel>())
					select x).Select((Func<GameObject, DMEditorObjectTable>)((GameObject x) => (DMEditorObjectTable)x.GetComponent<SpawnLevel>().GetField<SpawnLevel>("editorObjectTable"))).ToArray()[0];
				{
					foreach (DMEditorObjectTable objectTable2 in objectTables)
					{
						DMEditorObjectRow[] rowValues2 = ((DataTable<DMEditorObjectRow>)(object)objectTable2).GetRowValues();
						for (int num2 = 0; num2 < rowValues2.Length; num2++)
						{
							((DataTable<DMEditorObjectRow>)(object)val5).AddRow(((DataTable<DMEditorObjectRow>)(object)objectTable2).GetKeys()[num2], rowValues2[num2]);
						}
					}
					return;
				}
			}
			if (!((Scene)(ref scene)).name.Contains("UnitCreator"))
			{
				return;
			}
			GameObject[] rootGameObjects2 = ((Scene)(ref scene)).GetRootGameObjects();
			foreach (GameObject val6 in rootGameObjects2)
			{
				UnitEditorSpawnTestEnemies component3 = val6.GetComponent<UnitEditorSpawnTestEnemies>();
				if (Object.op_Implicit((Object)(object)component3))
				{
					List<Faction> list = component3.factionsToSpawn.ToList();
					list.AddRange(NewFactions);
					component3.factionsToSpawn = list.ToArray();
				}
			}
		}
	}
	public class TGMod : BaseUnityPlugin
	{
		private void Awake()
		{
			EarlyLaunch();
		}

		public virtual void EarlyLaunch()
		{
		}

		public virtual void Launch()
		{
		}

		public virtual void LateLaunch()
		{
		}

		public virtual void AddSettings()
		{
		}

		public virtual void SceneManager(Scene scene, LoadSceneMode loadSceneMode)
		{
		}

		public virtual void Localize(LocalizationHolder languageHolder)
		{
		}
	}
}
namespace TGCore.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("TGCore.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] tgcore
		{
			get
			{
				object obj = ResourceManager.GetObject("tgcore", resourceCulture);
				return (byte[])obj;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace TGCore.Localization
{
	public class LocalizationEntry : MonoBehaviour
	{
		public Language langage;

		public List<string> key;

		public List<string> value;
	}
	public class LocalizationHolder : MonoBehaviour
	{
		public List<LocalizationEntry> languages = new List<LocalizationEntry>();

		public void ReadLocalization()
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"LOCALIZING...");
			Dictionary<Language, Dictionary<string, string>> dictionary = (Dictionary<Language, Dictionary<string, string>>)(typeof(Localizer).GetField("m_localization", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null));
			try
			{
				foreach (LocalizationEntry item in languages.Where((LocalizationEntry x) => x.key.Count > 0 && x.value.Count > 0))
				{
					for (int num = 0; num < item.key.Count; num++)
					{
						dictionary?[item.langage].Add(item.key[num], item.value[num]);
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)"LOCALIZATION HAS FAILED:");
				Debug.LogError((object)ex);
			}
		}
	}
}
namespace TGCore.Library
{
	public class AchillesArmor : MonoBehaviour
	{
		public class UnitIsArmored : MonoBehaviour
		{
			public bool armorActive = true;

			public GameObject projectileHitEffect;

			public GameObject weaponHitEffect;

			public float parryForce;

			public float parryPower;

			public float blockPower;

			public float armorHealth;

			public float startingArmorHealth;
		}

		private Unit Unit;

		private UnitIsArmored ArmoredUnit;

		private AchillesArmorEvent[] ArmorListeners;

		private bool HealthBarEnabled;

		private bool ArmorDisabled;

		private float ArmorDisabledCounter;

		private float MaxArmorHealth;

		private ShieldBar CurrentShieldBar;

		public GameObject healthBar;

		[Header("Armor Settings")]
		public UnityEvent armorDisableEvent = new UnityEvent();

		public UnityEvent armorEnableEvent = new UnityEvent();

		public float armorDisabledTime = 3f;

		[Header("Hit Settings")]
		public GameObject projectileHitEffect;

		public GameObject weaponHitEffect;

		public float parryForce;

		public float parryPower;

		public float blockPower;

		[Header("Health Settings")]
		public float armorHealth = 500f;

		public float maxDamageToBlock = 9999f;

		public bool healthRegenerate;

		public float healthRegenerationRate = 50f;

		public void Start()
		{
			Unit = ((Component)((Component)this).transform.root).GetComponent<Unit>();
			Unit unit = Unit;
			unit.WasDealtDamageAction = (Action<float>)Delegate.Combine(unit.WasDealtDamageAction, new Action<float>(Armor));
			ArmoredUnit = ((Component)Unit).gameObject.AddComponent<UnitIsArmored>();
			ArmoredUnit.projectileHitEffect = projectileHitEffect;
			ArmoredUnit.weaponHitEffect = weaponHitEffect;
			ArmoredUnit.parryForce = parryForce;
			ArmoredUnit.parryPower = parryPower;
			ArmoredUnit.blockPower = blockPower;
			ArmoredUnit.armorHealth = armorHealth;
			ArmoredUnit.startingArmorHealth = armorHealth;
			MaxArmorHealth = armorHealth;
			ArmorListeners = ((Component)Unit).GetComponentsInChildren<AchillesArmorEvent>();
			HealthBarEnabled = ServiceLocator.GetService<GlobalSettingsHandler>().GetSettingsInstance("GAMEPLAY_HEALTHBARS").currentValue == 1;
			ShieldBar.Shielded component = ((Component)Unit).GetComponent<ShieldBar.Shielded>();
			if (HealthBarEnabled)
			{
				if (!Object.op_Implicit((Object)(object)component))
				{
					CurrentShieldBar = Object.Instantiate<GameObject>(healthBar).GetComponent<ShieldBar>();
					CurrentShieldBar.Init(Unit, null, ArmoredUnit);
				}
				else if (Object.op_Implicit((Object)(object)component))
				{
					CurrentShieldBar = component.bar;
					CurrentShieldBar.SetArmor(ArmoredUnit);
				}
			}
		}

		public void Armor(float damage)
		{
			if (ArmorDisabled)
			{
				return;
			}
			if (damage > maxDamageToBlock)
			{
				armorHealth = 0f;
			}
			else
			{
				DataHandler data = Unit.data;
				data.health += damage;
				armorHealth -= damage;
				armorHealth = Mathf.Clamp(armorHealth, 0f, MaxArmorHealth);
			}
			if (armorHealth <= 0f)
			{
				ArmorDisabled = true;
				armorDisableEvent.Invoke();
				AchillesArmorEvent[] armorListeners = ArmorListeners;
				foreach (AchillesArmorEvent achillesArmorEvent in armorListeners)
				{
					achillesArmorEvent.OnArmorDeactivated();
				}
				ArmoredUnit.armorActive = false;
			}
			ArmoredUnit.armorHealth = armorHealth;
		}

		public void Update()
		{
			if (ArmorDisabled && (!Unit.data.Dead || Unit.data.healthHandler.willBeRewived))
			{
				ArmorDisabledCounter += Time.deltaTime;
				if (!(ArmorDisabledCounter >= armorDisabledTime))
				{
					return;
				}
				ArmorDisabledCounter = 0f;
				ArmorDisabled = false;
				armorHealth = MaxArmorHealth;
				armorEnableEvent.Invoke();
				AchillesArmorEvent[] armorListeners = ArmorListeners;
				foreach (AchillesArmorEvent achillesArmorEvent in armorListeners)
				{
					achillesArmorEvent.OnArmorActivated();
				}
				ArmoredUnit.armorActive = true;
				ArmoredUnit.armorHealth = MaxArmorHealth;
				ShieldBar.Shielded component = ((Component)Unit).GetComponent<ShieldBar.Shielded>();
				if (HealthBarEnabled)
				{
					if (!Object.op_Implicit((Object)(object)component))
					{
						CurrentShieldBar = Object.Instantiate<GameObject>(healthBar).GetComponent<ShieldBar>();
						CurrentShieldBar.Init(Unit, null, ArmoredUnit);
					}
					else if (Object.op_Implicit((Object)(object)component))
					{
						CurrentShieldBar = component.bar;
						CurrentShieldBar.SetArmor(ArmoredUnit);
					}
				}
			}
			else if (healthRegenerate)
			{
				DataHandler data = Unit.data;
				data.health += Time.deltaTime * healthRegenerationRate;
				Unit.data.health = Mathf.Clamp(Unit.data.health, 0f, Unit.data.maxHealth);
			}
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)ArmoredUnit))
			{
				Object.Destroy((Object)(object)ArmoredUnit);
			}
		}
	}
	public class AchillesArmorEvent : MonoBehaviour
	{
		public UnityEvent armorActivationEvent = new UnityEvent();

		public UnityEvent armorDeactivationEvent = new UnityEvent();

		public void OnArmorActivated()
		{
			armorActivationEvent.Invoke();
		}

		public void OnArmorDeactivated()
		{
			armorDeactivationEvent.Invoke();
		}
	}
	public class AddDamageToUnitPart : MonoBehaviour
	{
		public enum BodyTarget
		{
			Head,
			RightFoot,
			LeftFoot,
			RightHand,
			LeftHand,
			MainRig,
			Hip,
			MainWeapon
		}

		private CollisionWeapon NewDamage;

		private CollisionWeaponToggleable NewToggleableDamage;

		private CollisionSound NewSound;

		private MeleeWeaponAddEffect NewEffect;

		private MeleeWeaponSpawn NewSpawn;

		private MeleeWeaponSpawnToggleable NewToggleableSpawn;

		private Unit OwnUnit;

		public BodyTarget bodyTarget;

		public bool destroyOnFail;

		private void Start()
		{
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_056f: 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_0581: Unknown result type (might be due to invalid IL or missing references)
			//IL_0586: Unknown result type (might be due to invalid IL or missing references)
			OwnUnit = ((Component)((Component)this).transform.root).GetComponent<Unit>();
			GameObject val = null;
			switch (bodyTarget)
			{
			case BodyTarget.Head:
				if (Object.op_Implicit((Object)(object)OwnUnit.data.head))
				{
					val = ((Component)OwnUnit.data.head).gameObject;
				}
				break;
			case BodyTarget.LeftFoot:
				if (Object.op_Implicit((Object)(object)OwnUnit.data.footLeft))
				{
					val = ((Component)OwnUnit.data.footLeft).gameObject;
				}
				break;
			case BodyTarget.RightFoot:
				if (Object.op_Implicit((Object)(object)OwnUnit.data.footRight))
				{
					val = ((Component)OwnUnit.data.footRight).gameObject;
				}
				break;
			case BodyTarget.LeftHand:
				if (Object.op_Implicit((Object)(object)OwnUnit.data.leftHand))
				{
					val = ((Component)OwnUnit.data.leftHand).gameObject;
				}
				break;
			case BodyTarget.RightHand:
				if (Object.op_Implicit((Object)(object)OwnUnit.data.rightHand))
				{
					val = ((Component)OwnUnit.data.rightHand).gameObject;
				}
				break;
			case BodyTarget.Hip:
				if (Object.op_Implicit((Object)(object)OwnUnit.data.hip))
				{
					val = ((Component)OwnUnit.data.hip).gameObject;
				}
				break;
			case BodyTarget.MainWeapon:
				if (Object.op_Implicit((Object)(object)OwnUnit.WeaponHandler) && (Object.op_Implicit((Object)(object)OwnUnit.WeaponHandler.rightWeapon) || Object.op_Implicit((Object)(object)OwnUnit.WeaponHandler.leftWeapon)))
				{
					val = (Object.op_Implicit((Object)(object)OwnUnit.WeaponHandler.rightWeapon) ? ((Component)OwnUnit.WeaponHandler.rightWeapon).gameObject : ((Component)OwnUnit.WeaponHandler.leftWeapon).gameObject);
				}
				break;
			default:
				val = ((Component)OwnUnit.data.mainRig).gameObject;
				break;
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				if (destroyOnFail)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
				return;
			}
			CollisionWeapon component = ((Component)this).GetComponent<CollisionWeapon>();
			if (Object.op_Implicit((Object)(object)component))
			{
				NewDamage = val.AddComponent<CollisionWeapon>();
				NewDamage.damage = component.damage;
				NewDamage.impactMultiplier = component.impactMultiplier;
				NewDamage.onImpactForce = component.onImpactForce;
				NewDamage.massCap = component.massCap;
				NewDamage.ignoreTeamMates = component.ignoreTeamMates;
				NewDamage.staticDamageValue = component.staticDamageValue;
				NewDamage.onlyOncePerData = component.onlyOncePerData;
				NewDamage.cooldown = component.cooldown;
				NewDamage.onlyCollideWithRigs = true;
				NewDamage.dealDamageEvent = component.dealDamageEvent;
				NewDamage.callEffectsOn = component.callEffectsOn;
				NewDamage.playSoundWhenHitNonRigidbodies = component.playSoundWhenHitNonRigidbodies;
				NewDamage.screenShakeMultiplier = component.screenShakeMultiplier;
				Object.Destroy((Object)(object)component);
			}
			CollisionWeaponToggleable component2 = ((Component)this).GetComponent<CollisionWeaponToggleable>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				NewToggleableDamage = val.AddComponent<CollisionWeaponToggleable>();
				NewToggleableDamage.damage = component2.damage;
				NewToggleableDamage.impactMultiplier = component2.impactMultiplier;
				NewToggleableDamage.onImpactForce = component2.onImpactForce;
				NewToggleableDamage.massCap = component2.massCap;
				NewToggleableDamage.ignoreTeamMates = component2.ignoreTeamMates;
				NewToggleableDamage.staticDamageValue = component2.staticDamageValue;
				NewToggleableDamage.onlyOncePerData = component2.onlyOncePerData;
				NewToggleableDamage.cooldown = component2.cooldown;
				NewToggleableDamage.dealDamageEvent = component2.dealDamageEvent;
				NewToggleableDamage.canDealDamage = component2.canDealDamage;
				NewToggleableDamage.callEffectsOn = component2.callEffectsOn;
				NewToggleableDamage.playSoundWhenHitNonRigidbodies = component2.playSoundWhenHitNonRigidbodies;
				NewToggleableDamage.screenShakeMultiplier = component2.screenShakeMultiplier;
				NewToggleableDamage.canDealDamage = component2.canDealDamage;
				Object.Destroy((Object)(object)component2);
			}
			CollisionSound component3 = ((Component)this).GetComponent<CollisionSound>();
			if (Object.op_Implicit((Object)(object)component3))
			{
				NewSound = val.AddComponent<CollisionSound>();
				NewSound.SoundEffectRef = component3.SoundEffectRef;
				NewSound.multiplier = component3.multiplier;
				NewSound.onlySoundOnRig = component3.onlySoundOnRig;
				Object.Destroy((Object)(object)component3);
			}
			MeleeWeaponAddEffect component4 = ((Component)this).GetComponent<MeleeWeaponAddEffect>();
			if (Object.op_Implicit((Object)(object)component4))
			{
				NewEffect = val.AddComponent<MeleeWeaponAddEffect>();
				NewEffect.EffectPrefab = component4.EffectPrefab;
				NewEffect.ignoreTeamMates = component4.ignoreTeamMates;
				Object.Destroy((Object)(object)component4);
			}
			MeleeWeaponSpawn component5 = ((Component)this).GetComponent<MeleeWeaponSpawn>();
			if (Object.op_Implicit((Object)(object)component5))
			{
				NewSpawn = val.AddComponent<MeleeWeaponSpawn>();
				NewSpawn.objectToSpawn = component5.objectToSpawn;
				NewSpawn.pos = component5.pos;
				NewSpawn.rot = component5.rot;
				NewSpawn.cd = component5.cd;
				NewSpawn.SpawnEvent = component5.SpawnEvent;
				Object.Destroy((Object)(object)component5);
			}
			MeleeWeaponSpawnToggleable component6 = ((Component)this).GetComponent<MeleeWeaponSpawnToggleable>();
			if (Object.op_Implicit((Object)(object)component6))
			{
				NewToggleableSpawn = val.AddComponent<MeleeWeaponSpawnToggleable>();
				NewToggleableSpawn.objectToSpawn = component6.objectToSpawn;
				NewToggleableSpawn.pos = component6.pos;
				NewToggleableSpawn.rot = component6.rot;
				NewToggleableSpawn.cooldown = component6.cooldown;
				NewToggleableSpawn.spawnEvent = component6.spawnEvent;
				NewToggleableSpawn.impactMultiplier = component6.impactMultiplier;
				NewToggleableSpawn.startOnCooldown = component6.startOnCooldown;
				NewToggleableSpawn.useWeaponToToggle = component6.useWeaponToToggle;
				NewToggleableSpawn.collisionTarget = component6.collisionTarget;
				NewToggleableSpawn.toggled = component6.toggled;
				Object.Destroy((Object)(object)component5);
			}
		}

		public void RemoveDamage()
		{
			if (Object.op_Implicit((Object)(object)NewDamage))
			{
				Object.Destroy((Object)(object)NewDamage);
			}
			if (Object.op_Implicit((Object)(object)NewToggleableDamage))
			{
				Object.Destroy((Object)(object)NewToggleableDamage);
			}
			if (Object.op_Implicit((Object)(object)NewSound))
			{
				Object.Destroy((Object)(object)NewSound);
			}
			if (Object.op_Implicit((Object)(object)NewEffect))
			{
				Object.Destroy((Object)(object)NewEffect);
			}
			if (Object.op_Implicit((Object)(object)NewSpawn))
			{
				Object.Destroy((Object)(object)NewSpawn);
			}
			if (Object.op_Implicit((Object)(object)NewToggleableSpawn))
			{
				Object.Destroy((Object)(object)NewToggleableSpawn);
			}
		}

		public void Release()
		{
			if (Object.op_Implicit((Object)(object)NewDamage))
			{
				NewDamage.Release();
			}
			if (Object.op_Implicit((Object)(object)NewToggleableDamage))
			{
				NewToggleableDamage.Release();
			}
		}

		public void SetCanDealDamage(bool value)
		{
			if (Object.op_Implicit((Object)(object)NewToggleableDamage))
			{
				NewToggleableDamage.SetCanDealDamage(value);
			}
		}

		public void SetCanSpawn(bool value)
		{
			if (Object.op_Implicit((Object)(object)NewToggleableSpawn))
			{
				NewToggleableSpawn.Toggle(value);
			}
		}

		private void OnDestroy()
		{
			RemoveDamage();
		}
	}
	public class AddEffectToRandomUnits : MonoBehaviour
	{
		public enum SelectionType
		{
			Percentage,
			Specific
		}

		private Team Team;

		private TeamSystem TeamSystem;

		private List<Unit> HitList = new List<Unit>();

		[Header("Selection Settings")]
		public SelectionType selectionType;

		public int value;

		public float delay;

		public bool enemyTeam = true;

		[Header("Effect Settings")]
		public UnitEffectBase effectToAdd;

		public bool addEffectOnce;

		private void Start()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			Team = ((Component)((Component)this).transform.root).GetComponent<Unit>().Team;
			TeamSystem = World.Active.GetOrCreateManager<TeamSystem>();
		}

		public void AddEffectToUnits()
		{
			//IL_0011: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			ClearHitList();
			((MonoBehaviour)this).StartCoroutine(DoEffect(TeamSystem.GetTeamUnits((Team)(((int)Team != 0) ? ((!enemyTeam) ? ((int)Team) : 0) : (enemyTeam ? 1 : ((int)Team))))));
		}

		private IEnumerator DoEffect(List<Unit> enemyUnits)
		{
			if (selectionType == SelectionType.Percentage && enemyUnits.Count / value > 0)
			{
				for (int i = 0; i < enemyUnits.Count / value; i++)
				{
					if (!HitList.Contains(enemyUnits[i]))
					{
						AddEffect(((Component)((Component)this).transform.root).GetComponent<Unit>(), enemyUnits[i].data);
						HitList.Add(enemyUnits[i]);
						yield return (object)new WaitForSeconds(delay);
					}
				}
			}
			else
			{
				if (selectionType != SelectionType.Specific)
				{
					yield break;
				}
				for (int j = 0; j < value; j++)
				{
					if (enemyUnits.Count <= 0)
					{
						break;
					}
					Unit chosenUnit = enemyUnits[Random.Range(0, enemyUnits.Count - 1)];
					if (!HitList.Contains(chosenUnit))
					{
						AddEffect(((Component)((Component)this).transform.root).GetComponent<Unit>(), chosenUnit.data);
						HitList.Add(chosenUnit);
						yield return (object)new WaitForSeconds(delay);
					}
				}
			}
		}

		public void ClearHitList()
		{
			HitList.Clear();
		}

		public void AddEffect(Unit attacker, DataHandler targetData)
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)attacker != (Object)null && (!Object.op_Implicit((Object)(object)targetData) || !targetData.Dead) && Object.op_Implicit((Object)(object)targetData))
			{
				UnitEffectBase val = UnitEffectBase.AddEffectToTarget(((Component)((Component)targetData.unit).transform).gameObject, effectToAdd);
				if (!Object.op_Implicit((Object)(object)val))
				{
					GameObject val2 = Object.Instantiate<GameObject>(((Component)effectToAdd).gameObject, ((Component)targetData.unit).transform.root);
					val2.transform.position = ((Component)targetData.unit).transform.position;
					val2.transform.rotation = Quaternion.LookRotation(targetData.mainRig.position - attacker.data.mainRig.position);
					val = val2.GetComponent<UnitEffectBase>();
					TeamHolder.AddTeamHolder(val2, ((Component)((Component)this).transform.root).gameObject);
					val.DoEffect();
				}
				else if (!addEffectOnce)
				{
					((Component)val).transform.rotation = Quaternion.LookRotation(targetData.mainRig.position - attacker.data.mainRig.position);
					val.Ping();
				}
			}
		}
	}
	public class AddEffectToTargetOnce : MonoBehaviour
	{
		private Unit OwnUnit;

		public UnitEffectBase effectPrefab;

		public bool onlyOnce;

		private void Start()
		{
			OwnUnit = ((Component)((Component)this).transform.root).GetComponent<Unit>();
		}

		public void Go()
		{
			AddEffect(OwnUnit.data.targetData);
		}

		public void GoWithRandomTarget(float radius)
		{
			//IL_0007: 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)
			RaycastHit[] source = Physics.SphereCastAll(((Component)this).transform.position, radius, Vector3.up, 0.1f, LayerMask.GetMask(new string[1] { "MainRig" }));
			Unit[] array = (from hit in source
				select ((Component)((RaycastHit)(ref hit)).transform.root).GetComponent<Unit>() into x
				where Object.op_Implicit((Object)(object)x) && !x.data.Dead && x.Team != OwnUnit.Team
				select x).Distinct().ToArray();
			if (array.Length != 0)
			{
				AddEffect(array[Random.Range(0, array.Length)].data);
			}
		}

		public void AddEffect(DataHandler targetData)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)OwnUnit) && Object.op_Implicit((Object)(object)targetData) && !targetData.Dead)
			{
				UnitEffectBase val = UnitEffectBase.AddEffectToTarget(((Component)targetData.unit).gameObject, effectPrefab);
				if (!Object.op_Implicit((Object)(object)val))
				{
					GameObject val2 = Object.Instantiate<GameObject>(((Component)effectPrefab).gameObject, ((Component)targetData.unit).transform);
					val2.transform.position = ((Component)targetData.unit).transform.position;
					val2.transform.rotation = Quaternion.LookRotation(targetData.mainRig.position - OwnUnit.data.mainRig.position);
					TeamHolder.AddTeamHolder(val2, ((Component)((Component)this).transform.root).gameObject);
					val = val2.GetComponent<UnitEffectBase>();
					val.DoEffect();
				}
				else if (!onlyOnce)
				{
					((Component)val).transform.rotation = Quaternion.LookRotation(targetData.mainRig.position - OwnUnit.data.mainRig.position);
					val.Ping();
				}
			}
		}
	}
	public class AddHitEffectToWeapon : MonoBehaviour
	{
		private Weapon[] Weapons;

		private SpookySwords[] SpookySwords;

		private ProjectileLauncher[] ProjectileLaunchers;

		private static GameObject Pool;

		private Dictionary<RangeWeapon, GameObject> WeaponToProjectileDict = new Dictionary<RangeWeapon, GameObject>();

		private Dictionary<ProjectileLauncher, GameObject> LauncherToProjectileDict = new Dictionary<ProjectileLauncher, GameObject>();

		private Dictionary<SpookySwords, GameObject> SpookyToProjectileDict = new Dictionary<SpookySwords, GameObject>();

		private Dictionary<CollisionWeapon, MeleeWeaponAddEffect> WeaponToEffectDict = new Dictionary<CollisionWeapon, MeleeWeaponAddEffect>();

		private Dictionary<CollisionWeaponToggleable, MeleeWeaponAddEffect> ToggleableWeaponToEffectDict = new Dictionary<CollisionWeaponToggleable, MeleeWeaponAddEffect>();

		public UnitEffectBase effect;

		public bool goOnStart = true;

		private void Awake()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)Pool))
			{
				GameObject val = new GameObject("TG Projectile Pool")
				{
					hideFlags = (HideFlags)61
				};
				val.transform.position = Vector3.down * -1000f;
				Pool = val;
				Pool.SetActive(false);
			}
		}

		private void Start()
		{
			Weapons = ((Component)((Component)this).transform.root).GetComponentsInChildren<Weapon>();
			SpookySwords = ((Component)((Component)this).transform.root).GetComponentsInChildren<SpookySwords>();
			ProjectileLaunchers = ((Component)((Component)this).transform.root).GetComponentsInChildren<ProjectileLauncher>();
			if (goOnStart)
			{
				AddEffects();
			}
		}

		public void AddEffects()
		{
			Weapon[] weapons = Weapons;
			foreach (Weapon val in weapons)
			{
				Weapon val2 = val;
				Weapon val3 = val2;
				MeleeWeapon val4 = (MeleeWeapon)(object)((val3 is MeleeWeapon) ? val3 : null);
				if (val4 == null)
				{
					RangeWeapon val5 = (RangeWeapon)(object)((val3 is RangeWeapon) ? val3 : null);
					if (val5 == null)
					{
						continue;
					}
					GameObject objectToSpawn = val5.ObjectToSpawn;
					GameObject val6 = CloneAndPoolObject(objectToSpawn);
					PooledProjectile component = val6.GetComponent<PooledProjectile>();
					if (Object.op_Implicit((Object)(object)component))
					{
						Object.Destroy((Object)(object)component);
					}
					ProjectileHit[] componentsInChildren = val6.GetComponentsInChildren<ProjectileHit>();
					CollisionWeapon[] componentsInChildren2 = val6.GetComponentsInChildren<CollisionWeapon>();
					Explosion[] componentsInChildren3 = val6.GetComponentsInChildren<Explosion>();
					ProjectileHit[] array = componentsInChildren;
					foreach (ProjectileHit val7 in array)
					{
						ProjectileHitAddEffect val8 = ((Component)val7).gameObject.AddComponent<ProjectileHitAddEffect>();
						val8.EffectPrefab = effect;
					}
					CollisionWeapon[] array2 = componentsInChildren2;
					foreach (CollisionWeapon val9 in array2)
					{
						MeleeWeaponAddEffect val10 = ((Component)val9).gameObject.AddComponent<MeleeWeaponAddEffect>();
						val10.EffectPrefab = effect;
						val10.ignoreTeamMates = true;
					}
					Explosion[] array3 = componentsInChildren3;
					foreach (Explosion val11 in array3)
					{
						if (!val11.onlyTeamMates)
						{
							AddObjectEffect val12 = ((Component)val11).gameObject.AddComponent<AddObjectEffect>();
							val12.EffectPrefab = effect;
							val12.OnlyOnce = true;
						}
					}
					val5.ObjectToSpawn = val6;
					if (!WeaponToProjectileDict.ContainsKey(val5))
					{
						WeaponToProjectileDict.Add(val5, objectToSpawn);
					}
				}
				else
				{
					CollisionWeapon[] componentsInChildren4 = ((Component)val4).GetComponentsInChildren<CollisionWeapon>();
					foreach (CollisionWeapon val13 in componentsInChildren4)
					{
						MeleeWeaponAddEffect val14 = ((Component)val4).gameObject.AddComponent<MeleeWeaponAddEffect>();
						val14.EffectPrefab = effect;
						val14.ignoreTeamMates = true;
						List<CollisionWeaponEffect> list = ((CollisionWeaponEffect[])GetField<CollisionWeapon>(val13, "meleeWeaponEffects")).ToList();
						list.Add((CollisionWeaponEffect)(object)val14);
						SetField<CollisionWeapon>(val13, "meleeWeaponEffects", list.ToArray());
						WeaponToEffectDict.Add(val13, val14);
					}
					CollisionWeaponToggleable[] componentsInChildren5 = ((Component)val4).GetComponentsInChildren<CollisionWeaponToggleable>();
					foreach (CollisionWeaponToggleable collisionWeaponToggleable in componentsInChildren5)
					{
						MeleeWeaponAddEffect val15 = ((Component)val4).gameObject.AddComponent<MeleeWeaponAddEffect>();
						val15.EffectPrefab = effect;
						val15.ignoreTeamMates = true;
						List<CollisionWeaponEffect> list2 = ((CollisionWeaponEffect[])GetField(collisionWeaponToggleable, "MeleeWeaponEffects")).ToList();
						list2.Add((CollisionWeaponEffect)(object)val15);
						SetField(collisionWeaponToggleable, "MeleeWeaponEffects", list2.ToArray());
						ToggleableWeaponToEffectDict.Add(collisionWeaponToggleable, val15);
					}
				}
			}
			SpookySwords[] spookySwords = SpookySwords;
			foreach (SpookySwords val16 in spookySwords)
			{
				GameObject val17 = CloneAndPoolObject(val16.sourceSword);
				ProjectileHit[] componentsInChildren6 = val17.GetComponentsInChildren<ProjectileHit>();
				ProjectileHit[] array4 = componentsInChildren6;
				foreach (ProjectileHit val18 in array4)
				{
					ProjectileHitAddEffect val19 = ((Component)val18).gameObject.AddComponent<ProjectileHitAddEffect>();
					val19.EffectPrefab = effect;
					if (val18.objectsToSpawn.Length == 0)
					{
						continue;
					}
					ObjectToSpawn[] objectsToSpawn = val18.objectsToSpawn;
					foreach (ObjectToSpawn val20 in objectsToSpawn)
					{
						val20.objectToSpawn = CloneAndPoolObject(val20.objectToSpawn);
						Explosion[] componentsInChildren7 = val20.objectToSpawn.GetComponentsInChildren<Explosion>();
						Explosion[] array5 = componentsInChildren7;
						foreach (Explosion val21 in array5)
						{
							if (!val21.onlyTeamMates)
							{
								AddObjectEffect val22 = ((Component)val21).gameObject.AddComponent<AddObjectEffect>();
								val22.EffectPrefab = effect;
								val22.OnlyOnce = true;
							}
						}
					}
				}
				val16.sourceSword = val17;
				if (!SpookyToProjectileDict.ContainsKey(val16))
				{
					SpookyToProjectileDict.Add(val16, val17);
				}
				List<SpookySword> source = (List<SpookySword>)val16.GetField<SpookySwords>("swords");
				foreach (SpookySword item in source.Where((SpookySword x) => x != null && Object.op_Implicit((Object)(object)x.gameObject)))
				{
					ProjectileHit[] componentsInChildren8 = item.gameObject.GetComponentsInChildren<ProjectileHit>();
					ProjectileHit[] array6 = componentsInChildren8;
					foreach (ProjectileHit val23 in array6)
					{
						ProjectileHitAddEffect val24 = ((Component)val23).gameObject.AddComponent<ProjectileHitAddEffect>();
						val24.EffectPrefab = effect;
						List<ProjectileHitEffect> list3 = ((ProjectileHitEffect[])GetField<ProjectileHit>(val23, "hitEffects")).ToList();
						list3.Add((ProjectileHitEffect)(object)val24);
						SetField<ProjectileHit>(val23, "hitEffects", list3.ToArray());
					}
				}
			}
			ProjectileLauncher[] projectileLaunchers = ProjectileLaunchers;
			foreach (ProjectileLauncher projectileLauncher in projectileLaunchers)
			{
				GameObject objectToSpawn2 = projectileLauncher.objectToSpawn;
				GameObject val25 = CloneAndPoolObject(objectToSpawn2);
				PooledProjectile component2 = val25.GetComponent<PooledProjectile>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					Object.Destroy((Object)(object)component2);
				}
				ProjectileHit[] componentsInChildren9 = val25.GetComponentsInChildren<ProjectileHit>();
				CollisionWeapon[] componentsInChildren10 = val25.GetComponentsInChildren<CollisionWeapon>();
				Explosion[] componentsInChildren11 = val25.GetComponentsInChildren<Explosion>();
				ProjectileHit[] array7 = componentsInChildren9;
				foreach (ProjectileHit val26 in array7)
				{
					ProjectileHitAddEffect val27 = ((Component)val26).gameObject.AddComponent<ProjectileHitAddEffect>();
					val27.EffectPrefab = effect;
				}
				CollisionWeapon[] array8 = componentsInChildren10;
				foreach (CollisionWeapon val28 in array8)
				{
					MeleeWeaponAddEffect val29 = ((Component)val28).gameObject.AddComponent<MeleeWeaponAddEffect>();
					val29.EffectPrefab = effect;
					val29.ignoreTeamMates = true;
				}
				Explosion[] array9 = componentsInChildren11;
				foreach (Explosion val30 in array9)
				{
					if (!val30.onlyTeamMates)
					{
						AddObjectEffect val31 = ((Component)val30).gameObject.AddComponent<AddObjectEffect>();
						val31.EffectPrefab = effect;
						val31.OnlyOnce = true;
					}
				}
				projectileLauncher.objectToSpawn = val25;
				if (!LauncherToProjectileDict.ContainsKey(projectileLauncher))
				{
					LauncherToProjectileDict.Add(projectileLauncher, objectToSpawn2);
				}
			}
		}

		public void RemoveEffects()
		{
			foreach (Weapon item in Weapons.Where((Weapon x) => Object.op_Implicit((Object)(object)x)))
			{
				Weapon val = item;
				Weapon val2 = val;
				MeleeWeapon val3 = (MeleeWeapon)(object)((val2 is MeleeWeapon) ? val2 : null);
				if (val3 == null)
				{
					RangeWeapon val4 = (RangeWeapon)(object)((val2 is RangeWeapon) ? val2 : null);
					if (val4 != null && WeaponToProjectileDict.TryGetValue(val4, out var value))
					{
						val4.ObjectToSpawn = value;
					}
					continue;
				}
				CollisionWeapon[] componentsInChildren = ((Component)val3).GetComponentsInChildren<CollisionWeapon>();
				foreach (CollisionWeapon val5 in componentsInChildren)
				{
					if (WeaponToEffectDict.TryGetValue(val5, out var value2))
					{
						List<CollisionWeaponEffect> list = ((CollisionWeaponEffect[])GetField<CollisionWeapon>(val5, "meleeWeaponEffects")).ToList();
						list.Remove((CollisionWeaponEffect)(object)value2);
						SetField<CollisionWeapon>(val5, "meleeWeaponEffects", list.ToArray());
						Object.Destroy((Object)(object)value2);
					}
				}
				CollisionWeaponToggleable[] componentsInChildren2 = ((Component)val3).GetComponentsInChildren<CollisionWeaponToggleable>();
				foreach (CollisionWeaponToggleable collisionWeaponToggleable in componentsInChildren2)
				{
					if (ToggleableWeaponToEffectDict.TryGetValue(collisionWeaponToggleable, out var value3))
					{
						List<CollisionWeaponEffect> list2 = ((CollisionWeaponEffect[])GetField(collisionWeaponToggleable, "MeleeWeaponEffects")).ToList();
						list2.Remove((CollisionWeaponEffect)(object)value3);
						SetField(collisionWeaponToggleable, "MeleeWeaponEffects", list2.ToArray());
						Object.Destroy((Object)(object)value3);
					}
				}
			}
			foreach (SpookySwords item2 in SpookySwords.Where((SpookySwords x) => Object.op_Implicit((Object)(object)x)))
			{
				if (SpookyToProjectileDict.TryGetValue(item2, out var value4))
				{
					item2.sourceSword = value4;
				}
			}
			foreach (ProjectileLauncher item3 in ProjectileLaunchers.Where((ProjectileLauncher x) => Object.op_Implicit((Object)(object)x)))
			{
				if (LauncherToProjectileDict.TryGetValue(item3, out var value5))
				{
					item3.objectToSpawn = value5;
				}
			}
		}

		private static void PoolObject(GameObject gameObject)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			gameObject.transform.parent = Pool.transform;
			gameObject.transform.localPosition = Vector3.zero;
			SetHideFlagsChildren(Pool.transform, (HideFlags)61);
		}

		private static GameObject CloneAndPoolObject(GameObject obj)
		{
			GameObject val = Object.Instantiate<GameObject>(obj, Pool.transform);
			PoolObject(val);
			return val;
		}

		private static void SetHideFlagsChildren(Transform t, HideFlags hf = (HideFlags)52)
		{
			//IL_0017: 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)
			if (Object.op_Implicit((Object)(object)((Component)t).gameObject))
			{
				((Object)((Component)t).gameObject).hideFlags = hf;
			}
			if (t.childCount > 0)
			{
				for (int i = 0; i < t.childCount; i++)
				{
					SetHideFlagsChildren(t.GetChild(i), hf);
				}
			}
		}

		private static object GetField<T>(T self, string name) where T : class
		{
			FieldInfo field = typeof(T).GetField(name, (BindingFlags)(-1));
			return (field != null) ? field.GetValue(self) : null;
		}

		private static T SetField<T>(T self, string name, object value) where T : class
		{
			FieldInfo field = typeof(T).GetField(name, (BindingFlags)(-1));
			if (field != null)
			{
				field.SetValue(self, value);
			}
			return self;
		}
	}
	public class AddMountOnStart : MonoBehaviour
	{
		public List<GameObject> mountPositions = new List<GameObject>();

		private void Start()
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)((Component)this).GetComponent<RiderHolder>()))
			{
				return;
			}
			foreach (GameObject mountPosition in mountPositions)
			{
				mountPosition.SetActive(true);
			}
			Unit component = ((Component)this).GetComponent<Unit>();
			List<GameObject> list = new List<GameObject>();
			if (Object.op_Implicit((Object)(object)component.unitBlueprint) && component.unitBlueprint.UnitRiders != null && component.unitBlueprint.UnitRiders.Length != 0)
			{
				RiderHolder val = ((Component)this).gameObject.AddComponent<RiderHolder>();
				List<GameObject> list2 = new List<GameObject>();
				Unit val2 = default(Unit);
				for (int i = 0; i < component.unitBlueprint.UnitRiders.Length; i++)
				{
					GameObject[] array = component.unitBlueprint.UnitRiders[i].Spawn(((Component)this).transform.position, ((Component)this).transform.rotation, component.Team, ref val2, 1f, false, false, 0, (UnitPoolInfo?)null);
					if (component.CampaignUnit)
					{
						val2.SetCampaignUnit();
					}
					list2.Add(array[0]);
					list.AddRange(array);
					((Component)val2).gameObject.AddComponent<Mount>().EnterMount((UnitBlueprint)null, component, i);
					list.AddRange(array);
					val2.IsRider = true;
					if (component.RemoteInstanceId != 0)
					{
						val2.IsRiderWithLinkedMount = true;
					}
				}
				val.Addriders(list2);
			}
			ServiceLocator.GetService<RuntimeGarbageCollector>().AddGameObjects(list.ToArray());
			List<GameObject> list3 = component.spawnedObjects.ToList();
			list3.AddRange(list);
			component.spawnedObjects = list3.ToArray();
			Mount component2 = ((Component)this).GetComponent<Mount>();
			if (Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)component2.OtherData) && component2.IsMounted)
			{
				List<GameObject> list4 = component2.OtherData.unit.spawnedObjects.ToList();
				list4.AddRange(component.spawnedObjects);
				component2.OtherData.unit.spawnedObjects = list4.ToArray();
			}
		}
	}
	public class AddRigidbodyThenSinkOnDeath : MonoBehaviour
	{
		private Vector3 StartScale;

		private Unit OwnUnit;

		private bool HasDied;

		private Rigidbody Rig;

		[Header("Rigidbody Settings")]
		public bool addRigidbody;

		public float mass = 200f;

		public float drag;

		public float angularDrag;

		public RigidbodyInterpolation interpolation = (RigidbodyInterpolation)1;

		[Header("Sink Settings")]
		public float sinkDelay = 2f;

		public float sinkMultiplier = 0.3f;

		public bool scaleAfterDelay = true;

		public float scaleDelay = 15f;

		private float ScaleMultiplier;

		private void Start()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			OwnUnit = ((Component)((Component)this).transform.root).GetComponent<Unit>();
			OwnUnit.data.healthHandler.AddDieAction((Action)Die);
			StartScale = ((Component)this).transform.localScale;
		}

		public void Die()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			if (!HasDied)
			{
				Rig = (addRigidbody ? ((Component)this).gameObject.AddComponent<Rigidbody>() : ((Component)this).GetComponent<Rigidbody>());
				Rig.mass = mass;
				Rig.drag = drag;
				Rig.angularDrag = angularDrag;
				Rig.interpolation = interpolation;
				HasDied = true;
				((Component)this).transform.SetParent(((Component)OwnUnit.data).transform, true);
				((MonoBehaviour)this).StartCoroutine(DoSink());
			}
		}

		private IEnumerator DoSink()
		{
			yield return (object)new WaitForSeconds(sinkDelay);
			float t = 0f;
			while (t < 3f)
			{
				Rigidbody rig = Rig;
				rig.drag *= 2f;
				Vector3 velocity = Rig.velocity;
				if (((Vector3)(ref velocity)).magnitude < 1f)
				{
					t += Time.deltaTime;
				}
				yield return null;
			}
			Rig.isKinematic = true;
			t = 0f;
			while (t < 30f)
			{
				Transform transform = ((Component)this).transform;
				transform.position += Vector3.down * (Mathf.Clamp(t * 0.1f, 0f, 1f) * Time.deltaTime * sinkMultiplier);
				t += Time.deltaTime;
				if (scaleAfterDelay && t > scaleDelay)
				{
					ScaleMultiplier = Mathf.Clamp01(ScaleMultiplier + Time.deltaTime);
					((Component)this).transform.localScale = StartScale * Mathf.Lerp(1f, 0f, ScaleMultiplier);
				}
				yield return null;
			}
		}
	}
	public class AddRigsToAllRigs : MonoBehaviour
	{
		private void Start()
		{
			//IL_0082: 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)
			Unit component = ((Component)((Component)this).transform.root).GetComponent<Unit>();
			List<Rigidbody> list = new List<Rigidbody>(component.data.allRigs.AllRigs);
			List<Vector2> list2 = new List<Vector2>(component.data.allRigs.AllDrags);
			List<Vector2> list3 = new List<Vector2>(component.data.allRigs.defaultDrags);
			Rigidbody[] componentsInChildren = ((Component)this).GetComponentsInChildren<Rigidbody>();
			foreach (Rigidbody val in componentsInChildren)
			{
				list.Add(val);
				list2.Add(new Vector2(val.drag, val.angularDrag));
				list3.Add(new Vector2(val.drag, val.angularDrag));
			}
			component.data.allRigs.SetField<RigidbodyHolder>("allRigs", list.ToArray());
			component.data.allRigs.SetField<RigidbodyHolder>("allDrags", list2.ToArray());
			component.data.allRigs.defaultDrags = list3.ToArray();
		}
	}
	public class Afterimage : MonoBehaviour
	{
		private UnitSpawner Spawner;

		public Material imgMaterial;

		public GameObject poofEffect;

		public GameObject despawnEffect;

		public float fadeTime = 5f;

		public float destroyDelay = 0.2f;

		public float afterimageTargetingPriority = 0.1f;

		public bool useRootBlueprint = true;

		public bool disableAbilities = true;

		[Header("Team Color")]
		public bool useTeamColor;

		public Material imgMaterialRed;

		public Material imgMaterialBlue;

		public void Start()
		{
			Spawner = ((Component)this).GetComponent<UnitSpawner>();
			if (useRootBlueprint)
			{
				Spawner.unitBlueprint = ((Component)((Component)this).transform.root).GetComponent<Unit>().unitBlueprint;
			}
			UnitSpawner spawner = Spawner;
			spawner.spawnUnitAction = (Action<GameObject>)Delegate.Combine(spawner.spawnUnitAction, new Action<GameObject>(SpawnAfterimage));
		}

		public void SpawnAfterimage(GameObject unit)
		{
			((MonoBehaviour)this).StartCoroutine(Spawn(unit));
		}

		private IEnumerator Spawn(GameObject u)
		{
			((Object)u).name = "AFTERIMAGE";
			Unit unit = u.GetComponent<Unit>();
			((Component)unit.data).GetComponent<UnitColorHandler>().SetMaterial((!useTeamColor) ? imgMaterial : (((int)unit.Team == 0) ? imgMaterialRed : imgMaterialBlue));
			if (disableAbilities)
			{
				ConditionalEvent[] componentsInChildren = u.GetComponentsInChildren<ConditionalEvent>();
				foreach (ConditionalEvent move in componentsInChildren)
				{
					Object.Destroy((Object)(object)((Component)move).gameObject);
				}
				ProjectileDodgeMove[] componentsInChildren2 = u.GetComponentsInChildren<ProjectileDodgeMove>();
				foreach (ProjectileDodgeMove projectileDodge in componentsInChildren2)
				{
					Object.Destroy((Object)(object)((Component)projectileDodge).gameObject);
				}
			}
			GameObject spawnedPoof = Object.Instantiate<GameObject>(poofEffect, unit.data.mainRig.position, poofEffect.transform.rotation);
			TeamHolder.AddTeamHolder(spawnedPoof, unit, (TeamHolder)null);
			yield return (object)new WaitForSeconds(0.1f);
			Unit rootUnit = ((Component)((Component)this).transform.root).GetComponent<Unit>();
			if (Object.op_Implicit((Object)(object)rootUnit))
			{
				Object.Instantiate<GameObject>(poofEffect, rootUnit.data.mainRig.position, poofEffect.transform.rotation);
			}
			unit.api.forceSupressFromWinCondition = true;
			unit.targetingPriorityMultiplier = afterimageTargetingPriority;
			unit.api.UpdateECSValues();
			TeamSystem teamSystem = World.Active.GetOrCreateManager<TeamSystem>();
			Dictionary<Team, List<Unit>> winConditionUnits = (Dictionary<Team, List<Unit>>)teamSystem.GetField<TeamSystem>("m_winConditionUnits");
			winConditionUnits[unit.Team].Remove(unit);
			teamSystem.SetField<TeamSystem>("m_winConditionUnits", winConditionUnits);
			yield return (object)new WaitForSeconds(fadeTime - 0.1f);
			spawnedPoof = Object.Instantiate<GameObject>(Object.op_Implicit((Object)(object)despawnEffect) ? despawnEffect : poofEffect, unit.data.mainRig.position, poofEffect.transform.rotation);
			TeamHolder.AddTeamHolder(spawnedPoof, unit, (TeamHolder)null);
			yield return (object)new WaitForSeconds(destroyDelay);
			TrailRenderer[] componentsInChildren3 = u.GetComponentsInChildren<TrailRenderer>();
			foreach (TrailRenderer trail in componentsInChildren3)
			{
				((Component)trail).transform.SetParent((Transform)null);
				trail.emitting = false;
				((Component)trail).gameObject.AddComponent<RemoveAfterSeconds>().seconds = trail.time * 1.5f;
			}
			unit.DestroyUnit();
		}
	}
	public class AimForUnitTarget : MonoBehaviour
	{
		private Unit Unit;

		private Vector3 StartForward;

		public AnimationCurve lerpCurve;

		public float lerpSpeed;

		private void Start()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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)
			Unit = ((Component)((Component)this).transform.root).GetComponent<Unit>();
			StartForward = ((Component)this).transform.parent.InverseTransformDirection(((Component)this).transform.forward);
		}

		private void Update()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00b3: 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_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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Unit) && Object.op_Implicit((Object)(object)Unit.data) && Object.op_Implicit((Object)(object)Unit.data.targetData) && Object.op_Implicit((Object)(object)Unit.data.targetData.mainRig))
			{
				Vector3 val = ((Component)this).transform.parent.TransformDirection(StartForward);
				Vector3 val2 = Unit.data.targetData.mainRig.position - ((Component)this).transform.position;
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				normalized.y = 0f;
				float num = Vector3.Angle(normalized, val);
				((Component)this).transform.rotation = Quaternion.LookRotation(Vector3.Lerp(((Component)this).transform.forward, Vector3.Lerp(val, normalized, lerpCurve.Evaluate(num)), lerpSpeed * Time.deltaTime));
			}
		}
	}
	public class AimForRandomUnit : MonoBehaviour
	{
		private TeamHolder OwnTeamHolder;

		public float maxRange = 30f;

		public float spread;

		public bool useRandom = true;

		private void Start()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			OwnTeamHolder = ((Component)this).GetComponent<TeamHolder>();
			Unit val = SetTarget();
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			Rigidbody mainRig = val.data.mainRig;
			Compensation component = ((Component)this).GetComponent<Compensation>();
			MoveTransform component2 = ((Component)this).GetComponent<MoveTransform>();
			if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component2))
			{
				((Component)this).transform.rotation = Quaternion.LookRotation(component.GetCompensation(mainRig.position, mainRig.velocity, 0f) + 0.01f * spread * Random.insideUnitSphere);
				GameObject spawner = OwnTeamHolder.spawner;
				Unit val2 = ((spawner != null) ? spawner.GetComponent<Unit>() : null);
				GameObject spawnerWeapon = OwnTeamHolder.spawnerWeapon;
				RangeWeapon val3 = ((spawnerWeapon != null) ? spawnerWeapon.GetComponentInParent<RangeWeapon>() : null);
				if (Object.op_Implicit((Object)(object)val3) && val3.extraSpreadInMelee != 0f && Object.op_Implicit((Object)(object)val2) && val2.data.distanceToTarget < 5f)
				{
					((Component)this).transform.Rotate(val3.extraSpreadInMelee * Random.insideUnitSphere);
				}
				component2.Initialize();
			}
		}

		private Unit SetTarget()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Collider[] source = Physics.OverlapSphere(((Component)this).transform.position, maxRange, LayerMask.GetMask(new string[1] { "MainRig" }));
			Unit[] array = (from hit in source
				select ((Component)((Component)hit).transform.root).GetComponent<Unit>() into x
				where Object.op_Implicit((Object)(object)x) && !x.data.Dead && (!Object.op_Implicit((Object)(object)OwnTeamHolder) || x.Team != OwnTeamHolder.team)
				select x).OrderBy(delegate(Unit x)
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val = ((Component)x.data.mainRig).transform.position - ((Component)this).transform.position;
				return ((Vector3)(ref val)).magnitude;
			}).Distinct().ToArray();
			if (array.Length != 0)
			{
				return array[useRandom ? Random.Range(0, array.Length - 1) : 0];
			}
			return null;
		}
	}
	public class AssignMeshToParticleSystem : MonoBehaviour
	{
		public enum MeshType
		{
			MeshRenderer,
			SkinnedMeshRenderer,
			NonUnitMeshRenderer
		}

		private MeshRenderer[] AllMeshRenderers;

		private MeshRenderer MeshRenderer;

		private SkinnedMeshRenderer[] AllSkinnedMeshRenderers;

		private SkinnedMeshRenderer SkinnedMeshRend;

		private ParticleSystem[] ParticleSystems;

		private ParticleSystem Part;

		private bool MeshAssigned;

		public MeshType meshType;

		public UnityEvent findEvent;

		public bool disableMesh;

		public bool disableParticles;

		public bool play = true;

		private void Start()
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			Part = ((Component)this).GetComponent<ParticleSystem>();
			switch (meshType)
			{
			case MeshType.MeshRenderer:
			{
				AllMeshRenderers = ((Component)((Component)this).transform.root).GetComponentsInChildren<MeshRenderer>();
				MeshRenderer[] allMeshRenderers = AllMeshRenderers;
				foreach (MeshRenderer val2 in allMeshRenderers)
				{
					if (((Component)val2).CompareTag("UnitMesh") && !MeshAssigned)
					{
						MeshRenderer = val2;
						MeshAssigned = true;
					}
					if (disableMesh)
					{
						((Renderer)val2).enabled = false;
					}
				}
				if (Object.op_Implicit((Object)(object)MeshRenderer))
				{
					ShapeModule shape2 = Part.shape;
					((ShapeModule)(ref shape2)).meshRenderer = MeshRenderer;
					findEvent.Invoke();
					if (play)
					{
						Part.Play();
					}
				}
				if (!disableParticles)
				{
					return;
				}
				ParticleSystems = ((Component)((Component)this).transform.root).GetComponentsInChildren<ParticleSystem>();
				ParticleSystem[] particleSystems = ParticleSystems;
				foreach (ParticleSystem val3 in particleSystems)
				{
					if (!((Component)val3).CompareTag("DontRemove"))
					{
						val3.Stop();
					}
				}
				return;
			}
			case MeshType.SkinnedMeshRenderer:
			{
				AllSkinnedMeshRenderers = ((Component)((Component)this).transform.root).GetComponentsInChildren<SkinnedMeshRenderer>();
				SkinnedMeshRenderer[] allSkinnedMeshRenderers = AllSkinnedMeshRenderers;
				foreach (SkinnedMeshRenderer val in allSkinnedMeshRenderers)
				{
					if (((Component)val).CompareTag("UnitMesh"))
					{
						SkinnedMeshRend = val;
						break;
					}
				}
				if (Object.op_Implicit((Object)(object)SkinnedMeshRend))
				{
					ShapeModule shape = Part.shape;
					((ShapeModule)(ref shape)).skinnedMeshRenderer = SkinnedMeshRend;
					if (((Object)((Component)((Component)this).transform.root).gameObject).name.Contains("IceGiant"))
					{
						MainModule main = Part.main;
						((MainModule)(ref main)).startSizeMultiplier = 0.005f;
						((MainModule)(ref main)).startSpeedMultiplier = 0.005f;
					}
					findEvent.Invoke();
					if (play)
					{
						Part.Play();
					}
				}
				return;
			}
			}
			AllMeshRenderers = ((Component)((Component)this).transform.root).GetComponentsInChildren<MeshRenderer>();
			MeshRenderer[] allMeshRenderers2 = AllMeshRenderers;
			foreach (MeshRenderer val4 in allMeshRenderers2)
			{
				if (!MeshAssigned)
				{
					MeshRenderer = val4;
					MeshAssigned = true;
				}
				if (disableMesh)
				{
					((Renderer)val4).enabled = false;
				}
			}
			if (Object.op_Implicit((Object)(object)MeshRenderer))
			{
				ShapeModule shape3 = Part.shape;
				((ShapeModule)(ref shape3)).meshRenderer = MeshRenderer;
				findEvent.Invoke();
				if (play)
				{
					Part.Play();
				}
			}
		}
	}
	public class AttachHandMount : MonoBehaviour
	{
		public Rigidbody rigToHold;

		public Transform pivot;

		public bool attachLeftHand;

		public bool attachRightHand;
	}
	public class BoostAbilitySpeed : MonoBehaviour
	{
		public float multiplier = 0.025f;

		public float minimumCooldown;
	}
	public class CallCodeAnimationInRoot : MonoBehaviour
	{
		public AnimationUse animationType;

		public void CallAnimation(string objName)
		{
			//IL_0059: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected I4, but got Unknown
			if (((Component)((Component)this).transform.root).GetComponentsInChildren<CodeAnimation>() == null)
			{
				return;
			}
			CodeAnimation[] array = (from x in ((Component)((Component)this).transform.root).GetComponentsInChildren<CodeAnimation>()
				where ((Object)((Component)x).gameObject).name == objName
				select x).ToArray();
			if (array.Length != 0)
			{
				AnimationUse val = animationType;
				AnimationUse val2 = val;
				switch ((int)val2)
				{
				case 0:
					array[0].PlayIn();
					break;
				case 1:
					array[0].PlayOut();
					break;
				case 3:
					array[0].PlayBoop();
					break;
				case 2:
					break;
				}
			}
		}
	}
	public class CannotDrown : MonoBehaviour
	{
		public float upForceMultiplier = 1f;
	}
	public class ChangeLayer : MonoBehaviour
	{
		public void DoChange(int newLayer)
		{
			Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>();
			foreach (Collider val in componentsInChildren)
			{
				((Component)val).gameObject.layer = newLayer;
			}
		}
	}
	public class ChangeLayerOfChildren : MonoBehaviour
	{
		private RigidbodyHolder RigHolder;

		private List<Rigidbody> Rigs = new List<Rigidbody>();

		private List<int> Layers = new List<int>();

		private List<int> ColliderLayers = new List<int>();

		private List<Collider> Colliders = new List<Collider>();

		private bool ChangedLayer;

		public bool includeWeapons = true;

		public void Start()
		{
			Rigs.Clear();
			Colliders.Clear();
			ColliderLayers.Clear();
			RigHolder = ((Component)((Component)this).transform.root).GetComponentInChildren<RigidbodyHolder>();
			Rigs.AddRange(RigHolder.AllRigs);
			Colliders.AddRange(((Component)((Component)((Component)((Component)this).transform.root).GetComponentInChildren<DataHandler>()).transform).GetComponentsInChildren<Collider>());
			if (!includeWeapons)
			{
				return;
			}
			HoldingHandler componentInChildren = ((Component)((Component)this).transform.root).GetComponentInChildren<HoldingHandler>();
			HoldingHandlerMulti componentInChildren2 = ((Component)((Component)this).transform.root).GetComponentInChildren<HoldingHandlerMulti>();
			if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				if (Object.op_Implicit((Object)(object)componentInChildren.rightObject))
				{
					Rigs.Add(componentInChildren.rightObject.rig);
					Colliders.AddRange(((Component)componentInChildren.rightObject).GetComponentsInChildren<Collider>());
				}
				if (Object.op_Implicit((Object)(object)componentInChildren.leftObject))
				{
					Rigs.Add(componentInChildren.leftObject.rig);
					Colliders.AddRange(((Component)componentInChildren.leftObject).GetComponentsInChildren<Collider>());
				}
			}
			else
			{
				if (!Object.op_Implicit((Object)(object)componentInChildren2))
				{
					return;
				}
				foreach (GameObject spawnedWeapon in componentInChildren2.spawnedWeapons)
				{
					Rigs.Add(spawnedWeapon.GetComponent<Rigidbody>());
					Colliders.AddRange(spawnedWeapon.GetComponentsInChildren<Collider>());
				}
			}
		}

		public void ChangeLayer()
		{
			foreach (Rigidbody item in Rigs.Where((Rigidbody rig) => Object.op_Implicit((Object)(object)rig)))
			{
				Layers.Add(((Component)item).gameObject.layer);
				((Component)item).gameObject.layer = 20;
			}
			foreach (Collider item2 in Colliders.Where((Collider collider) => Object.op_Implicit((Object)(object)collider)))
			{
				ColliderLayers.Add(((Component)item2).gameObject.layer);
				((Component)item2).gameObject.layer = 20;
			}
			ChangedLayer = true;
		}

		public void ResetLayer()
		{
			if (!ChangedLayer)
			{
				return;
			}
			for (int i = 0; i < Rigs.Count; i++)
			{
				if (Object.op_Implicit((Object)(object)Rigs[i]))
				{
					((Component)Rigs[i]).gameObject.layer = Layers[i];
				}
			}
			for (int j = 0; j < Colliders.Count; j++)
			{
				if (Object.op_Implicit((Object)(object)Colliders[j]))
				{
					((Component)Colliders[j]).gameObject.layer = ColliderLayers[j];
				}
			}
			ChangedLayer = false;
		}
	}
	public class ChangeMaterial : MonoBehaviour
	{
		private readonly List<Material> OriginalMaterials = new List<Material>();

		private Team Team;

		private bool HasChanged;

		[Header("Material Settings")]
		public Renderer renderer;

		public int index;

		public Material newMaterial;

		[Header("Team Color Settings")]
		public Material redMaterial;

		public Material blueMaterial;

		public void Start()
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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)
			Material[] sharedMaterials = renderer.sharedMaterials;
			foreach (Material val in sharedMaterials)
			{
				OriginalMaterials.Add(Object.Instantiate<Material>(val));
			}
			Unit component = ((Component)((Component)this).transform.root).GetComponent<Unit>();
			TeamHolder component2 = ((Component)this).GetComponent<TeamHolder>();
			TeamHolder componentInParent = ((Component)this).GetComponentInParent<TeamHolder>();
			TeamHolder componentInChildren = ((Component)this).GetComponentInChildren<TeamHolder>();
			if (Object.op_Implicit((Object)(object)component))
			{
				Team = component.Team;
			}
			else if (Object.op_Implicit((Object)(object)component2))
			{
				Team = component2.team;
			}
			else if (Object.op_Implicit((Object)(object)componentInParent))
			{
				Team = componentInParent.team;
			}
			else if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				Team = componentInChildren.team;
			}
		}

		public void MaterialChange(float speed)
		{
			if (((Component)this).gameObject.activeSelf && ((Component)this).gameObject.activeInHierarchy)
			{
				((MonoBehaviour)this).StopAllCoroutines();
				HasChanged = true;
				((MonoBehaviour)this).StartCoroutine(DoMaterialChange(index, Object.Instantiate<Material>(renderer.materials[index]), newMaterial, speed));
			}
		}

		public void MaterialRevert(float speed)
		{
			if (((Component)this).gameObject.activeSelf && ((Component)this).gameObject.activeInHierarchy && HasChanged)
			{
				((MonoBehaviour)this).StopAllCoroutines();
				((MonoBehaviour)this).StartCoroutine(DoMaterialChange(index, newMaterial, OriginalMaterials[index], speed));
			}
		}

		public void MaterialTeamChange(float speed)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			if (((Component)this).gameObject.activeSelf && ((Component)this).gameObject.activeInHierarchy)
			{
				((MonoBehaviour)this).StopAllCoroutines();
				HasChanged = true;
				((MonoBehaviour)this).StartCoroutine(DoMaterialChange(index, Object.Instantiate<Material>(renderer.materials[index]), ((int)Team == 0) ? redMaterial : blueMaterial, speed));
			}
		}

		public void MaterialTeamRevert(float speed)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (((Component)this).gameObject.activeSelf && ((Component)this).gameObject.activeInHierarchy && HasChanged)
			{
				((MonoBehaviour)this).StopAllCoroutines();
				((MonoBehaviour)this).StartCoroutine(DoMaterialChange(index, ((int)Team == 0) ? redMaterial : blueMaterial, OriginalMaterials[index], speed));
			}
		}

		public void AllMaterialsChange(float speed)
		{
			if (((Component)this).gameObject.activeSelf && ((Component)this).gameObject.activeInHierarchy)
			{
				((MonoBehaviour)this).StopAllCoroutines();
				for (int i = 0; i < renderer.materials.Length; i++)
				{
					((MonoBehaviour)this).StartCoroutine(DoMaterialChange(i, Object.Instantiate<Material>(renderer.materials[i]), newMaterial, speed));
				}
			}
		}

		public void AllMaterialsRevert(float speed)
		{
			if (((Component)this).gameObject.activeSelf && ((Component)this).gameObject.activeInHierarchy)
			{
				((MonoBehaviour)this).StopAllCoroutines();
				for (int i = 0; i < renderer.materials.Length; i++)
				{
					((MonoBehaviour)this).StartCoroutine(DoMaterialChange(i, newMaterial, OriginalMaterials[i], speed));
				}
			}
		}

		public void AllMaterialsTeamChange(float speed)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if (((Component)this).gameObject.activeSelf && ((Component)this).gameObject.activeInHierarchy)
			{
				((MonoBehaviour)this).StopAllCoroutines();
				for (int i = 0; i < renderer.materials.Length; i++)
				{
					((MonoBehaviour)this).StartCoroutine(DoMaterialChange(i, Object.Instantiate<Material>(renderer.materials[i]), ((int)Team == 0) ? redMaterial : blueMaterial, speed));
				}
			}
		}

		public void AllMaterialsTeamRevert(float speed)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (((Component)this).gameObject.activeSelf && ((Component)this).gameObject.activeInHierarchy)
			{
				((MonoBehaviour)this).StopAllCoroutines();
				for (int i = 0; i < renderer.materials.Length; i++)
				{
					((MonoBehaviour)this).StartCoroutine(DoMaterialChange(i, ((int)Team == 0) ? redMaterial : blueMaterial, OriginalMaterials[i], speed));
				}
			}
		}

		public void Stop()
		{
			((MonoBehaviour)this).StopAllCoroutines();
		}

		private IEnumerator DoMaterialChange(int indexToLerp, Material materialToStartWith, Material matToLerpTo, float lerpSpeed)
		{
			float t = 0f;
			while (t < 1f && !Object.op_Implicit((Object)(object)((Component)((Component)this).transform.root).GetComponentsInChildren<UnitEffectBase>().ToList().Find((UnitEffectBase x) => x.effectID == 1987)))
			{
				t += Time.deltaTime * lerpSpeed;
				renderer.materials[indexToLerp].Lerp(materialToStartWith, matToLerpTo, Mathf.Clamp(t, 0f, 1f));
				yield return null;
			}
		}
	}
	public class ChangeOutline : MonoBehaviour
	{
		public Mode outlineMode;

		public Color outlineColor = Color.white;

		[Range(0f, 10f)]
		public float outlineWidth = 2f;

		public void Start()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			Outline component = ((Component)((Component)this).transform.root).GetComponent<Outline>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.OutlineMode = outlineMode;
				component.SetHighlightColor(outlineColor);
				component.OutlineWidth = outlineWidth;
			}
		}
	}
	public class ChangeRotationForce : MonoBehaviour
	{
		public float rotationForce = 25f;

		public bool ignoreY;

		private void Start()
		{
			Unit component = ((Component)((Component)this).transform.root).GetComponent<Unit>();
			if (Object.op_Implicit((Object)(object)component))
			{
				RotationHandler component2 = ((Component)component.data).GetComponent<RotationHandler>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					component2.rotationForce = rotationForce;
					component2.ignoreY = (ignoreY ? ignoreY : component2.ignoreY);
				}
			}
		}
	}
	public struct CircleTargetUnitEditor : IMovementComponent, IComponentData
	{
		public float minCircleDistance;

		public float maxCircleDistance;
	}
	[UpdateAfter(typeof(UpdateBarrier))]
	[UpdateBefore(typeof(PreLateUpdateBarrier))]
	public class CircleTargetUnitEditorSystem : JobComponentSystem
	{
		private struct Filter
		{
			public EntityArray Entities;

			public ComponentDataArray<Direction> Directions;

			[ReadOnly]
			public ComponentDataArray<CircleTargetUnitEditor> CircleTargets;

			[ReadOnly]
			public ComponentDataArray<HasTargetTag> HasTargetTags;

			[ReadOnly]
			public ComponentDataArray<TargetData> TargetDatas;

			[ReadOnly]
			public SubtractiveComponent<IsInPool> IsInPool;

			public readonly int Length;
		}

		private struct Job : IJobParallelFor
		{
			public EntityArray Entities;

			public ComponentDataArray<Direction> Directions;

			[ReadOnly]
			public ComponentDataArray<CircleTargetUnitEditor> CircleTargets;

			[ReadOnly]
			public ComponentDataArray<HasTargetTag> HasTargetTags;

			[ReadOnly]
			public ComponentDataArray<TargetData> TargetDatas;

			[ReadOnly]
			public SubtractiveComponent<IsInPool> IsInPool;

			public Concurrent CommandBuffer;

			public void Execute(int index)
			{
				//IL_0008: 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_0012: 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_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e0: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f3: 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_0100: Unknown result type (might be due to invalid IL or missing references)
				if (!(HasTargetTags[index].Target == Entity.Null))
				{
					Entity val = ((EntityArray)(ref Entities))[index];
					Direction val2 = Directions[index];
					CircleTargetUnitEditor circleTargetUnitEditor = CircleTargets[index];
					float distanceToTarget = TargetDatas[index].DistanceToTarget;
					if (distanceToTarget <= circleTargetUnitEditor.maxCircleDistance && distanceToTarget >= circleTargetUnitEditor.minCircleDistance)
					{
						float3 value = val2.Value;
						float3 val3 = default(float3);
						((float3)(ref val3))..ctor(value.x, 0f, value.z);
						float3 val4 = math.cross(math.normalize(val3), new float3(0f, 1f, 0f));
						float3 val5 = math.length(val3) * val4;
						val2.Value = new float3(val5.x, value.y, val5.z);
						((Concurrent)(ref CommandBuffer)).SetComponent<Direction>(index, val, val2);
					}
				}
			}
		}

		[Inject]
		private Filter m_filter;

		[Inject]
		private PreLateUpdateBarrier m_barrier;

		protected override JobHandle OnUpdate(JobHandle inputDeps)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown re