Decompiled source of ColonialFaction v1.0.0

Colonial.dll

Decompiled 6 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Xml;
using BepInEx;
using DM;
using Landfall.TABS;
using Landfall.TABS.AI.Components.Modifiers;
using Landfall.TABS.UnitEditor;
using ModdingForDummies;
using ModdingForDummies.AssetManagement;
using ModdingForDummies.TABSSimp;
using Sirenix.Serialization;
using UnityEngine;
using XAmountOfUnits.TABSSimp;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ModdingForDummies")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ModdingForDummies")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1619c49c-bc45-486c-bbca-6b52cef4f478")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace XAmountOfUnits.TABSSimp
{
	public class ModUnit : ModdingClass<ModUnit>
	{
		public class ModVoice
		{
			public UnitBlueprint internalObject { get; private set; }

			public string Death
			{
				get
				{
					return internalObject.voiceBundle.DeathRef;
				}
				set
				{
					internalObject.voiceBundle.DeathRef = value;
				}
			}

			public string Alive
			{
				get
				{
					return internalObject.voiceBundle.VocalRef;
				}
				set
				{
					internalObject.voiceBundle.VocalRef = value;
				}
			}

			public float Pitch
			{
				get
				{
					return internalObject.VoicePitch;
				}
				set
				{
					internalObject.VoicePitch = value;
				}
			}

			public ModVoice(UnitBlueprint blueprint)
			{
				internalObject = blueprint;
				internalObject.voiceBundle = ScriptableObject.CreateInstance<VoiceBundle>();
			}
		}

		public UnitBlueprint internalObject;

		private ModWeapon rightWeapon;

		private ModWeapon leftWeapon;

		private bool rangedMovement;

		private ModBase UnitBase;

		private ModUnit rider;

		public WrapperDelineation<ModClothing> Clothes { get; private set; }

		public WrapperDelineation<ModMove> Moves { get; private set; }

		public ModVoice Voice { get; private set; }

		public override string Name
		{
			get
			{
				return internalObject.Entity.Name;
			}
			set
			{
				internalObject.Entity.Name = value;
			}
		}

		public Sprite Icon
		{
			get
			{
				return internalObject.Entity.SpriteIcon;
			}
			set
			{
				internalObject.Entity.SetSpriteIcon(value);
			}
		}

		public float Health
		{
			get
			{
				return internalObject.health;
			}
			set
			{
				internalObject.health = value;
			}
		}

		public float Speed
		{
			get
			{
				return internalObject.movementSpeedMuiltiplier;
			}
			set
			{
				internalObject.movementSpeedMuiltiplier = value;
			}
		}

		public float TurnSpeed
		{
			get
			{
				return internalObject.TurnSpeed;
			}
			set
			{
				if ((Object)(object)internalObject.turningData != (Object)null)
				{
					internalObject.turningData.TurnSpeed = value;
				}
				internalObject.turnSpeed = value;
			}
		}

		public float Mass
		{
			get
			{
				return internalObject.massMultiplier;
			}
			set
			{
				internalObject.massMultiplier = value;
			}
		}

		public float Balance
		{
			get
			{
				return internalObject.balanceMultiplier;
			}
			set
			{
				internalObject.balanceMultiplier = value;
			}
		}

		public float BalanceStrength
		{
			get
			{
				return internalObject.balanceForceMultiplier;
			}
			set
			{
				internalObject.balanceForceMultiplier = value;
			}
		}

		public float Priority
		{
			get
			{
				return internalObject.targetingPriorityMultiplier;
			}
			set
			{
				internalObject.targetingPriorityMultiplier = value;
			}
		}

		public float Size
		{
			get
			{
				return internalObject.sizeMultiplier;
			}
			set
			{
				internalObject.sizeMultiplier = value;
			}
		}

		public bool TwoHanded
		{
			get
			{
				return internalObject.holdinigWithTwoHands;
			}
			set
			{
				internalObject.holdinigWithTwoHands = value;
			}
		}

		public int Cost
		{
			get
			{
				return (int)internalObject.GetUnitCost(true);
			}
			set
			{
				internalObject.useCustomCost = true;
				internalObject.customCost = value;
			}
		}

		public ModWeapon RightWeapon
		{
			get
			{
				return rightWeapon;
			}
			set
			{
				if (value != null)
				{
					rightWeapon = value;
					internalObject.RightWeapon = rightWeapon.internalObject;
				}
			}
		}

		public ModWeapon LeftWeapon
		{
			get
			{
				return leftWeapon;
			}
			set
			{
				if (value != null)
				{
					leftWeapon = value;
					internalObject.LeftWeapon = leftWeapon.internalObject;
				}
			}
		}

		public bool RangedMovement
		{
			get
			{
				return rangedMovement;
			}
			set
			{
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: 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)
				internalObject.MovementComponents.Clear();
				if (value)
				{
					internalObject.MovementComponents.Add((IMovementComponent)(object)default(KeepRangedDistance));
				}
				else
				{
					internalObject.MovementComponents.Add((IMovementComponent)(object)default(KeepPreferredDistance));
				}
			}
		}

		public ModBase Base
		{
			get
			{
				return UnitBase;
			}
			set
			{
				UnitBase = value;
				internalObject.UnitBase = UnitBase.internalObject;
			}
		}

		public Vector2 SizeRange
		{
			get
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				return new Vector2(internalObject.minSizeRandom, internalObject.maxSizeRandom);
			}
			set
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				internalObject.minSizeRandom = value.x;
				internalObject.maxSizeRandom = value.y;
			}
		}

		public ModUnit Rider
		{
			get
			{
				return rider;
			}
			set
			{
				rider = value;
				if (rider != null)
				{
					internalObject.SetField<UnitBlueprint>("Riders", new UnitBlueprint[1] { rider.internalObject });
				}
				else
				{
					internalObject.SetField<UnitBlueprint>("Riders", Array.Empty<UnitBlueprint>());
				}
			}
		}

		private void UpdateClothing(List<ModClothing> list)
		{
			internalObject.m_props = (from ModClothing clothing in list
				select clothing.internalObject).ToArray();
		}

		private void UpdateMoves(List<ModMove> list)
		{
			internalObject.objectsToSpawnAsChildren = (from ModMove move in list
				select move.internalObject).ToArray();
		}

		public override void ColorInternal(int index, Color color, float glow = 0f)
		{
		}

		public ModUnit(UnitBlueprint blueprint)
		{
			internalObject = blueprint;
			Clothes = new WrapperDelineation<ModClothing>(UpdateClothing, Mod.GetClothing);
			Moves = new WrapperDelineation<ModMove>(UpdateMoves, Mod.GetMove);
			Voice = new ModVoice(blueprint);
			if (internalObject.m_props != null)
			{
				Clothes.List = (from GameObject prop in internalObject.m_props
					where (Object)(object)prop != (Object)null
					select new ModClothing(prop)).ToList();
			}
			else
			{
				internalObject.m_props = Array.Empty<GameObject>();
			}
			if (Object.op_Implicit((Object)(object)internalObject.RightWeapon))
			{
				RightWeapon = new ModWeapon(internalObject.RightWeapon);
			}
			if (Object.op_Implicit((Object)(object)internalObject.LeftWeapon))
			{
				LeftWeapon = new ModWeapon(internalObject.LeftWeapon);
			}
		}

		public override ModUnit Clone()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			string name = Utilities.IncrementName(Name);
			UnitBlueprint val = Object.Instantiate<UnitBlueprint>(internalObject);
			val.Entity.GUID = DatabaseID.NewID();
			val.Entity.Name = name;
			Utilities.AddUnitToDatabase(val);
			ModUnit modUnit = new ModUnit(val);
			modUnit.Clothes.List = Clothes.List;
			modUnit.Moves.List = Moves.List;
			modUnit.Rider = Rider;
			modUnit.Cost = Cost;
			ModUnit modUnit2 = modUnit;
			modUnit2.Separate();
			return modUnit2;
		}

		public override void Separate()
		{
			if (RightWeapon != null)
			{
				RightWeapon = RightWeapon.Clone();
			}
			if (LeftWeapon != null)
			{
				LeftWeapon = LeftWeapon.Clone();
			}
			Clothes.List = (from ModClothing clothing in Clothes.List
				select clothing.Clone()).ToList();
			Moves.List = (from ModMove move in Moves.List
				select move.Clone()).ToList();
		}
	}
}
namespace ModdingForDummies
{
	[BepInPlugin("myname.myfirstmod", "Colonial Faction", "1.0.0")]
	public class Launcher : BaseUnityPlugin
	{
		public Launcher()
		{
			Debug.Log((object)"Starting My First Mod!");
			AssetImporter.Initialize();
			new Main();
		}
	}
	public class Main : Mod
	{
		private string comment;

		public Main()
		{
			comment = "CHANGE THIS TO FALSE BEFORE RELEASING YOUR MOD!!!";
			Mod.DEV_MODE = false;
			ModFaction modFaction = Mod.CreateFaction("Colonial");
			modFaction.Icon = Mod.GetIcon("Hillary");
			modFaction.Color("#666666");
			ModFaction modFaction2 = Mod.CreateFaction("Riders");
			modFaction2.Color("#cfcfcf");
			modFaction2.Visible = false;
			ModUnit modUnit = modFaction.NewUnit("Recruit");
			modUnit.Health = 80f;
			modUnit.Cost = 70;
			modUnit.Icon = Mod.GetIcon("Halfling");
			ModWeapon modWeapon = Mod.CreateWeapon("recurit dagger", "Gladius");
			modWeapon.Cooldown = 2f;
			modWeapon.Damage = 25f;
			ModWeapon modWeapon2 = Mod.CreateWeapon("recurit grab", "Halfling Grab");
			modWeapon2.Cooldown = 1.5f;
			modWeapon2.AttackRange = 1f;
			modWeapon2.Damage = 12f;
			modUnit.LeftWeapon = modWeapon2;
			modUnit.RightWeapon = modWeapon;
			ModClothing modClothing = Mod.CreateClothing("Rev backpack03", "Renaissance backpack 00");
			modClothing.Color(0, "#6b371b");
			modUnit.Clothes.Add("TABG wig 00", "TABG carolean uniform 00", "TABG carolean pants 00", "TABG carolean shoes 01", "Rev backpack03");
			ModUnit modUnit2 = modFaction.NewUnit("Frontliner");
			modUnit2.Health = 180f;
			modUnit2.Cost = 180;
			modUnit2.Icon = Mod.GetIcon("Sword");
			ModWeapon modWeapon3 = Mod.CreateWeapon("Frontliner Sword", "Swift Sword");
			modWeapon3.Cooldown = 1.5f;
			modWeapon3.AttackRange = 2.5f;
			modWeapon3.StartCooldown = false;
			modWeapon3.Damage = 140f;
			modUnit2.RightWeapon = modWeapon3;
			modUnit2.LeftWeapon = modWeapon3;
			modUnit2.Clothes.Add("TABG wig 00", "TABG carolean uniform 00", "TABG carolean pants 00", "TABG carolean shoes 01", "World War backpack 00");
			modUnit2.Moves.Add("Halfling Jump");
			ModUnit modUnit3 = modFaction.NewUnit("Colonist");
			modUnit3.Health = 180f;
			modUnit3.Cost = 350;
			modUnit3.TwoHanded = true;
			modUnit3.Icon = Mod.GetIcon("Musket");
			modUnit3.RangedMovement = true;
			ModWeapon modWeapon4 = Mod.CreateWeapon("Colonist Musket", "Musket - Bayonet");
			modWeapon4.Cooldown = 11f;
			modWeapon4.Ranged.Recoil = 100f;
			modUnit3.RightWeapon = modWeapon4;
			modUnit3.Clothes.Add("TABG bicorne hat 00", "TABG carolean uniform 00", "TABG carolean pants 00", "TABG carolean shoes 01", "Wild West belt 00");
			ModUnit modUnit4 = modFaction.NewUnit("Bayoneter");
			modUnit4.Health = 200f;
			modUnit4.Cost = 500;
			modUnit4.TwoHanded = true;
			modUnit4.Speed *= 2f;
			modUnit4.Icon = Mod.GetIcon("Pike");
			ModWeapon modWeapon5 = Mod.CreateWeapon("bayonet", "Infantry Spear");
			modWeapon5.Cooldown = 3f;
			modWeapon5.AttackRange = 2f;
			modWeapon5.Damage = 180f;
			modUnit4.RightWeapon = modWeapon5;
			ModClothing modClothing2 = Mod.CreateClothing("Rev backpack01", "Renaissance backpack 00");
			modClothing2.Color(0, "#6b371b");
			modUnit4.Clothes.Add("TABG bicorne hat 00", "TABG carolean uniform 00", "TABG carolean pants 00", "TABG carolean shoes 01", "Wild West moustache 04", "Rev backpack01");
			modUnit4.Moves.Add("Painter Dodge", "Headbutt");
			ModUnit modUnit5 = modFaction.NewUnit("Line breaker");
			modUnit5.Health = 350f;
			modUnit5.Cost = 800;
			modUnit5.Icon = Mod.GetIcon("Flintlock");
			modUnit5.Size = 1.1f;
			modUnit5.Speed = 1.2f;
			modUnit5.Mass = 1.2f;
			ModExplosion modExplosion = Mod.CreateExplosion("Flintlock Bomb", "ExplosionBombCannon");
			modExplosion.Radius /= 2f;
			modExplosion.Size = 1f;
			ModWeapon modWeapon6 = Mod.CreateWeapon("line breaker Flintlock", "Flintlock - Drop");
			modWeapon6.Explosion = modExplosion;
			modWeapon6.Cooldown = 6f;
			modWeapon6.Ranged.Recoil = 8f;
			modWeapon6.Damage = 180f;
			ModWeapon modWeapon7 = Mod.CreateWeapon("line breaker Sword", "Swift Sword");
			modWeapon7.Cooldown = 3f;
			modWeapon7.AttackRange = 2f;
			modWeapon7.StartCooldown = false;
			modWeapon7.Damage = 120f;
			modUnit5.RightWeapon = modWeapon6;
			modUnit5.LeftWeapon = modWeapon7;
			ModClothing modClothing3 = Mod.CreateClothing("Rev backpack", "Renaissance backpack 00");
			modClothing3.Color(0, "#6b371b");
			ModClothing modClothing4 = Mod.CreateClothing("Bomb Belt", "Pirate belt 07");
			modClothing4.Color(0, "#a65a24");
			modUnit5.Clothes.Add("TABG wig 00", "TABG carolean uniform 00", "TABG carolean pants 00", "TABG carolean shoes 01", "TABG bicorne hat 00", "Rev backpack", "Bomb Belt");
			modUnit5.Moves.Add("Pirate Kick", "Foolish Jump", "Explosive Death");
			ModUnit modUnit6 = modFaction2.NewUnit("Cannon Boy Rider");
			modUnit6.Health = 250f;
			modUnit6.Clothes.Add("TABG bicorne hat 00", "TABG carolean uniform 00", "TABG carolean pants 00", "TABG carolean shoes 01");
			ModUnit modUnit7 = modFaction.NewUnit("Cannon Boy");
			modUnit7.Cost = 1200;
			modUnit7.Health = 400f;
			modUnit7.Size = 1.1f;
			modUnit7.Icon = Mod.GetIcon("Cannon");
			modUnit7.Base = Mod.GetBase("Cannon 2");
			modUnit7.TwoHanded = true;
			modUnit7.Rider = modUnit6;
			modUnit7.RangedMovement = true;
			ModWeapon modWeapon8 = Mod.CreateWeapon("Cannon Barrel", "Cannonball");
			modWeapon8.Damage = 250f;
			modWeapon8.Cooldown = 6.5f;
			modWeapon8.AttackRange = 25f;
			modWeapon8.Effect = Mod.GetEffect("FireArrowEffect");
			modWeapon8.Explosion = Mod.GetExplosion("Blackbeardslam");
			modUnit7.RightWeapon = modWeapon8;
			modUnit7.Moves.Add("Explosive Death");
			ModUnit modUnit8 = modFaction.NewUnit("Washington");
			modUnit8.Health = 1200f;
			modUnit8.Cost = 2000;
			modUnit8.Icon = Mod.GetIcon("Teacher");
			modUnit8.Size = 1.3f;
			modUnit8.Mass = 20f;
			ModWeapon modWeapon9 = Mod.CreateWeapon("Washington's Sword", "Teacher Sword");
			modWeapon9.Cooldown = 0.5f;
			modWeapon9.AttackRange = 2f;
			modWeapon9.StartCooldown = false;
			modWeapon9.Damage = 180f;
			modWeapon9.Effect = Mod.GetEffect("FireArrowEffect");
			modUnit8.RightWeapon = modWeapon9;
			modUnit8.LeftWeapon = modWeapon9;
			modUnit8.Clothes.Add("TABG carolean hat 00", "TABG carolean uniform 00", "TABG carolean pants 00", "TABG carolean shoes 01", "TABG wig 00");
			modUnit8.Moves.Add("Pirate Kick", "Teacher Parry", "Quickdraw Projectile Dodge", "Order units: Charge");
		}
	}
	public static class Utilities
	{
		private static readonly string[] sanitizationFilter;

		private static readonly Dictionary<GearType, string[]> boneDictionary;

		public static readonly Quaternion blenderToUnity;

		public static readonly string rootPath;

		public static Dictionary<string, string> language;

		public static readonly ContentDatabase fullDatabase;

		public static readonly LandfallContentDatabase database;

		public static Explosion[] explosions;

		public static UnitEffectBase[] effects;

		public static Sprite[] sprites;

		public static readonly ModExplosion unitSpawner;

		public static readonly ModFaction baseFaction;

		static Utilities()
		{
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Expected O, but got Unknown
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			sanitizationFilter = new string[33]
			{
				"Icon_Legacy_", "Icons_128x128_", "Icons_", "Icon_", "CP_", "P_", "E_", " Prefabs_VB", " Effects_VB", "_1",
				"_2", "_3", " (1)", " (2)", " (3)", " (4)", " (5)", " (6)", "B_", "Move_",
				"Leg_", "1_", "12_", "15_", "6__", "7_", "14_", "2_", "8_", "10_",
				"16_", "5_", "3_"
			};
			boneDictionary = new Dictionary<GearType, string[]>
			{
				{
					(GearType)0,
					new string[1] { "M_Head" }
				},
				{
					(GearType)1,
					new string[1] { "M_Neck" }
				},
				{
					(GearType)2,
					new string[2] { "M_Shoulder_Right", "M_Shoulder_Left" }
				},
				{
					(GearType)3,
					new string[1] { "M_Torso" }
				},
				{
					(GearType)4,
					new string[2] { "M_Arm_Right", "M_Arm_Left" }
				},
				{
					(GearType)5,
					new string[2] { "M_Wrist_Right", "M_Wrist_Left" }
				},
				{
					(GearType)7,
					new string[1] { "M_Waist" }
				},
				{
					(GearType)8,
					new string[2] { "M_Leg_Right", "M_Leg_Left" }
				},
				{
					(GearType)9,
					new string[2] { "M_Foot_Right", "M_Foot_Left" }
				}
			};
			blenderToUnity = Quaternion.Euler(-90f, 0f, 0f);
			rootPath = Directory.GetParent(Assembly.GetExecutingAssembly().Location)?.ToString();
			language = Localizer.GetLanguage((Language)0);
			fullDatabase = ContentDatabase.Instance();
			database = ContentDatabase.Instance().LandfallContentDatabase;
			explosions = Resources.FindObjectsOfTypeAll<Explosion>();
			effects = Resources.FindObjectsOfTypeAll<UnitEffectBase>();
			sprites = Resources.FindObjectsOfTypeAll<Sprite>();
			unitSpawner = new ModExplosion(Mod.PoolObject(new GameObject("UnitSpawner", new Type[1] { typeof(UnitSpawner) })));
			List<string> source = (from z in (from z in language
					group z by z.Value into z
					where z.Count() > 1
					select z).SelectMany((IGrouping<string, KeyValuePair<string, string>> z) => z)
				select z.Key).ToList();
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			foreach (string item in source.Where((string v) => language[v] != null && language[v] != string.Empty))
			{
				if (!dictionary.ContainsKey(language[item]))
				{
					dictionary.Add(language[item], 1);
					continue;
				}
				dictionary[language[item]]++;
				language[item] = language[item] + " " + dictionary[language[item]];
			}
			Faction val = Object.Instantiate<Faction>(GetFaction("Medieval"));
			val.Entity.GenerateNewID();
			val.Entity.Name = "Base Faction";
			val.Units = Array.Empty<UnitBlueprint>();
			val.index = database.GetFactions().ToList().Count;
			val.m_FactionColor = HexColor("#888888");
			val.m_displayFaction = false;
			AddFactionToDatabase(val);
			baseFaction = new ModFaction(val);
			if (Mod.DEV_MODE)
			{
				string text = Path.Combine(rootPath, "MFDPrints");
				if (!Directory.Exists(text))
				{
					Directory.CreateDirectory(text);
				}
				string contents = string.Join(Environment.NewLine, from GameObject weapon in database.GetWeapons()
					where (Object)(object)weapon != (Object)null
					select GetProperName(((CharacterItem)weapon.GetComponentInChildren<WeaponItem>()).Entity.Name));
				File.WriteAllText(Path.Combine(text, "weapons.txt"), contents);
				string contents2 = string.Join(Environment.NewLine, from GameObject unitBase in database.GetUnitBases()
					where (Object)(object)unitBase != (Object)null
					select GetProperName(unitBase.GetComponentInChildren<Unit>().Entity.Name));
				File.WriteAllText(Path.Combine(text, "bases.txt"), contents2);
				string contents3 = string.Join(Environment.NewLine, from GameObject clothing in database.GetCharacterProps()
					where (Object)(object)clothing != (Object)null
					select GetProperName(((CharacterItem)clothing.GetComponentInChildren<PropItem>()).Entity.Name));
				File.WriteAllText(Path.Combine(text, "clothing.txt"), contents3);
				string contents4 = string.Join(Environment.NewLine, from IDatabaseEntity unit in database.GetUnitBlueprints()
					select GetProperName(unit.Entity.Name));
				File.WriteAllText(Path.Combine(text, "unit.txt"), contents4);
				string contents5 = string.Join(Environment.NewLine, from IDatabaseEntity faction in database.GetFactions()
					select GetProperName(faction.Entity.Name));
				File.WriteAllText(Path.Combine(text, "factions.txt"), contents5);
				string contents6 = string.Join(Environment.NewLine, from Explosion explosion in explosions
					where (Object)(object)explosion != (Object)null
					select GetProperName(((Object)((Component)explosion).gameObject).name));
				File.WriteAllText(Path.Combine(text, "explosions.txt"), contents6);
				string contents7 = string.Join(Environment.NewLine, from UnitEffectBase effect in effects
					where (Object)(object)effect != (Object)null
					select GetProperName(((Object)((Component)effect).gameObject).name));
				File.WriteAllText(Path.Combine(text, "effects.txt"), contents7);
				string contents8 = string.Join(Environment.NewLine, from GameObject projectile in database.GetProjectiles()
					select GetProperName(projectile.GetComponentInChildren<ProjectileEntity>().Entity.Name));
				File.WriteAllText(Path.Combine(text, "projectiles.txt"), contents8);
				string contents9 = string.Join(Environment.NewLine, from GameObject move in database.GetCombatMoves()
					select GetProperName(((CharacterItem)move.GetComponentInChildren<SpecialAbility>()).Entity.Name));
				File.WriteAllText(Path.Combine(text, "moves.txt"), contents9);
				string contents10 = string.Join(Environment.NewLine, from FactionIcon icon in fullDatabase.GetFactionIcons()
					select GetProperName(icon.Entity.Name));
				File.WriteAllText(Path.Combine(text, "icons.txt"), contents10);
				string contents11 = string.Join(Environment.NewLine, from Sprite icon in Resources.FindObjectsOfTypeAll<Sprite>()
					select GetProperName(((Object)icon).name));
				File.WriteAllText(Path.Combine(text, "iconsExtra.txt"), contents11);
			}
		}

		public static object CallMethod(this object o, string methodName, params object[] args)
		{
			MethodInfo method = o.GetType().GetMethod(methodName, (BindingFlags)(-1));
			if (method != null)
			{
				return method.Invoke(o, args);
			}
			Debug.Log((object)("Call Method " + methodName + " nulled"));
			return null;
		}

		public static object GetField<T>(this T instance, string fieldName, BindingFlags flags = (BindingFlags)(-1))
		{
			FieldInfo field = typeof(T).GetField(fieldName, flags);
			try
			{
				field.GetValue(instance);
			}
			catch
			{
				Debug.Log((object)$"(GetField) Failed to get field '{fieldName}' for object '{typeof(T)}'. Try using manual BindingFlags.");
			}
			return field.GetValue(instance);
		}

		public static void SetField<T>(this T instance, string fieldName, object newValue, BindingFlags flags = (BindingFlags)(-1))
		{
			FieldInfo field = typeof(T).GetField(fieldName, flags);
			Debug.Log((object)field);
			try
			{
				field.SetValue(instance, newValue);
			}
			catch
			{
				Debug.Log((object)$"(SetField) Failed to set field '{fieldName}' for object '{typeof(T)}'. Try using manual BindingFlags.");
			}
		}

		public static Transform SetHideFlagsChildren(this Transform t, HideFlags hf = 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++)
				{
					t.GetChild(i).SetHideFlagsChildren(hf);
				}
			}
			return t;
		}

		public static Sprite CreateSprite(string path)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(path))
			{
				return null;
			}
			if (!File.Exists(path))
			{
				return null;
			}
			byte[] array = File.ReadAllBytes(path);
			Texture2D val = new Texture2D(1, 1);
			ImageConversion.LoadImage(val, array);
			((Texture)val).filterMode = (FilterMode)0;
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f), 1f);
		}

		public static bool NullCheck(this object self, string flag = "Object")
		{
			Debug.Log((object)("[NULLCHECK] " + flag + " is " + ((self == null) ? "NULL" : "REAL") + "!"));
			return self == null;
		}

		public static T GetResourcesObj<T>(string obj)
		{
			Object[] source = Resources.FindObjectsOfTypeAll(typeof(T));
			return (T)(object)((IEnumerable<Object>)source).FirstOrDefault((Func<Object, bool>)((Object x) => x.name.Contains(obj)));
		}

		public static string IncrementName(string name)
		{
			return name.Contains(";") ? (name.Split(new char[1] { ';' })[0] + int.Parse(name.Split(new char[1] { ';' })[1]) + 1) : (name + ";1");
		}

		public static void ForEach<T>(this IEnumerable<T> collection, Action<T> action)
		{
			foreach (T item in collection)
			{
				action(item);
			}
		}

		public static void ForEach<T>(this T[] array, Action<T> action)
		{
			foreach (T obj in array)
			{
				action(obj);
			}
		}

		public static Dictionary<V, U> Reverse<U, V>(this Dictionary<U, V> self)
		{
			Dictionary<V, U> dictionary = new Dictionary<V, U>();
			foreach (U key in self.Keys)
			{
				dictionary[self[key]] = key;
			}
			return dictionary;
		}

		public static Color HexColor(string hexCode)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			hexCode = (hexCode.StartsWith("#") ? hexCode : ("#" + hexCode)).ToUpper();
			Color result = default(Color);
			ColorUtility.TryParseHtmlString(hexCode, ref result);
			return result;
		}

		public static T FindVanillaObject<T>(IEnumerable<T> source, string name, Func<T, string> getName)
		{
			return source.FirstOrDefault((T o) => name == GetProperName(getName(o)));
		}

		public static string GetProperName(string name)
		{
			string text = null;
			if (language.ContainsKey(name))
			{
				text = language[name];
			}
			else
			{
				text = name;
				string[] array = sanitizationFilter;
				foreach (string oldValue in array)
				{
					text = text.Replace(oldValue, "");
				}
			}
			return text;
		}

		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 void PlaceMeshOnBone(SkinnedMeshRenderer renderer, GameObject mesh, GearType gearType)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			string text = boneDictionary[gearType][0];
			Transform[] bones = renderer.bones;
			foreach (Transform val in bones)
			{
				if (((Object)val).name == text)
				{
					mesh.transform.parent = ((Component)val).transform;
					mesh.transform.localPosition = Vector3.zero;
					mesh.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
				}
			}
		}

		public static void SetMeshRenderers(GameObject gameObject, bool enabled)
		{
			Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Type type = ((object)componentsInChildren[i]).GetType();
				if (type == typeof(MeshRenderer) || type == typeof(SkinnedMeshRenderer))
				{
					componentsInChildren[i].enabled = enabled;
				}
			}
		}

		public static void SetObjectColor(GameObject colorObject, int index, Color color, float glow)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] bestRenderers = GetBestRenderers(colorObject);
			Renderer bestRenderer = GetBestRenderer(colorObject);
			bool flag = (Object)(object)colorObject.GetComponentInChildren<LODGroup>() != (Object)null;
			Dictionary<Color, Material> dictionary = new Dictionary<Color, Material>();
			Material[] materials = bestRenderer.materials;
			Material val = new Material(Shader.Find("Standard"));
			val.color = color;
			if (glow > 0f)
			{
				val.EnableKeyword("_EMISSION");
				val.SetColor("_EmissionColor", val.color * glow);
			}
			val.SetFloat("_Glossiness", 0f);
			if (!Object.op_Implicit((Object)(object)bestRenderer))
			{
				return;
			}
			for (int j = 0; j < materials.Length; j++)
			{
				if (j == index)
				{
					dictionary[materials[j].color] = val;
				}
			}
			if (bestRenderers == null || bestRenderers.Length == 0)
			{
				return;
			}
			if (flag)
			{
				Renderer[] array = bestRenderers;
				foreach (Renderer val2 in array)
				{
					List<TeamColor> source = ((Component)val2).GetComponents<TeamColor>().ToList();
					List<TeamColor> removed = new List<TeamColor>();
					Material[] materials2 = val2.materials;
					List<Material> list = new List<Material>();
					int i;
					for (i = 0; i < materials2.Length; i++)
					{
						Material val3 = null;
						if (dictionary.ContainsKey(materials2[i].color))
						{
							val3 = dictionary[materials2[i].color];
						}
						if ((Object)(object)val3 != (Object)null)
						{
							list.Add(val3);
							foreach (TeamColor item in source.Where((TeamColor tc) => !removed.Contains(tc) && tc.materialID == i))
							{
								removed.Add(item);
								Object.DestroyImmediate((Object)(object)item);
							}
						}
						else
						{
							list.Add(materials2[i]);
						}
					}
					val2.materials = list.ToArray();
				}
				return;
			}
			int num = 0;
			Renderer[] array2 = bestRenderers;
			foreach (Renderer val4 in array2)
			{
				Material[] materials3 = val4.materials;
				List<TeamColor> list2 = ((Component)val4).GetComponents<TeamColor>().ToList();
				for (int m = 0; m < materials3.Length; m++)
				{
					if (num + m != index)
					{
						continue;
					}
					materials3[m] = val;
					foreach (TeamColor item2 in list2)
					{
						if (item2.materialID == m)
						{
							Object.DestroyImmediate((Object)(object)item2);
						}
					}
				}
				num++;
				val4.materials = materials3;
			}
		}

		public static void SetClothScale(ModClothing clothing, Vector3 scale)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			GameObject internalObject = clothing.internalObject;
			if ((Object)(object)internalObject.GetComponentInChildren<MeshRenderer>() != (Object)null)
			{
				MeshRenderer[] componentsInChildren = internalObject.GetComponentsInChildren<MeshRenderer>();
				foreach (MeshRenderer val in componentsInChildren)
				{
					((Component)val).transform.localScale = scale;
				}
			}
			if (!((Object)(object)internalObject.GetComponentInChildren<SkinnedMeshRenderer>() != (Object)null))
			{
				return;
			}
			Vector3 localScale = internalObject.transform.localScale;
			SkinnedMeshRenderer[] componentsInChildren2 = internalObject.GetComponentsInChildren<SkinnedMeshRenderer>();
			foreach (SkinnedMeshRenderer val2 in componentsInChildren2)
			{
				val2.sharedMesh = Object.Instantiate<Mesh>(val2.sharedMesh);
				Mesh sharedMesh = val2.sharedMesh;
				((Object)sharedMesh).name = clothing.Name + "sharedmesh";
				Vector3[] vertices = sharedMesh.vertices;
				if (vertices == null)
				{
					vertices = sharedMesh.vertices;
				}
				Debug.Log((object)("baseVertices " + vertices.Length));
				Vector3[] array = (Vector3[])(object)new Vector3[vertices.Length];
				for (int k = 0; k < array.Length; k++)
				{
					Vector3 val3 = vertices[k];
					val3.x /= localScale.x;
					val3.y /= localScale.y;
					val3.z /= localScale.z;
					val3.x *= scale.x;
					val3.y *= scale.y;
					val3.z *= scale.z;
					array[k] = val3;
				}
				internalObject.transform.localScale = scale;
				sharedMesh.vertices = array;
				sharedMesh.RecalculateBounds();
				val2.sharedMesh = sharedMesh;
			}
		}

		public static Renderer GetBestRenderer(GameObject gameObject, Type rendererType = null)
		{
			if (rendererType == null)
			{
				rendererType = typeof(Renderer);
			}
			else if (!rendererType.IsSubclassOf(typeof(Renderer)))
			{
				return null;
			}
			Renderer val = null;
			Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>();
			bool flag = false;
			Renderer[] array = componentsInChildren;
			foreach (Renderer val2 in array)
			{
				if (((object)val2).GetType() == rendererType || rendererType == typeof(Renderer))
				{
					string name = ((Object)((Component)val2).gameObject).name;
					if (name.Contains("LOD0"))
					{
						val = val2;
						flag = true;
					}
					else if (name.Contains("CP_") && !flag)
					{
						val = val2;
						flag = true;
					}
					else if (name.ToLower().Contains(((Object)gameObject.gameObject).name.ToLower()) && !flag)
					{
						val = val2;
					}
					else if (!Object.op_Implicit((Object)(object)val) && name != "RightHand" && name != "LeftHand" && !flag)
					{
						val = val2;
					}
				}
			}
			return val;
		}

		public static Renderer[] GetBestRenderers(GameObject gameObject, Type rendererType = null)
		{
			if (rendererType == null)
			{
				rendererType = typeof(Renderer);
			}
			else if (!rendererType.IsSubclassOf(typeof(Renderer)))
			{
				return null;
			}
			Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>();
			List<Renderer> list = new List<Renderer>();
			bool flag = false;
			LODGroup componentInChildren = gameObject.GetComponentInChildren<LODGroup>();
			if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				flag = true;
				list.AddRange(componentInChildren.GetLODs().SelectMany((LOD lod) => lod.renderers));
			}
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				if (!list.Contains(val) && (((object)val).GetType() == rendererType || rendererType == typeof(Renderer)))
				{
					string name = ((Object)gameObject).name;
					if (name.Contains("LOD") && ((Object)((Component)val).transform.parent).name.ToLower().Contains("base"))
					{
						list.Add(val);
						flag = true;
					}
					else if (name.Contains("LOD"))
					{
						list.Add(val);
						flag = true;
					}
					else if (name.Contains("CP_") && !flag)
					{
						list.Add(val);
						flag = true;
					}
					else if (name.ToLower().Contains(((Object)gameObject).name.ToLower()) && !flag)
					{
						list.Add(val);
					}
					else if (list.Count <= 0 && name != "RightHand" && name != "LeftHand" && !flag)
					{
						list.Add(val);
					}
				}
			}
			return list.ToArray();
		}

		public static GameObject GetUnitBase(string name)
		{
			return FindVanillaObject(database.GetUnitBases(), name, (GameObject ub) => ub.GetComponentInChildren<Unit>().Entity.Name);
		}

		public static GameObject GetClothing(string name)
		{
			return FindVanillaObject(database.GetCharacterProps(), name, (GameObject c) => ((CharacterItem)c.GetComponentInChildren<PropItem>()).Entity.Name);
		}

		public static GameObject GetWeapon(string name)
		{
			return FindVanillaObject(database.GetWeapons(), name, (GameObject w) => ((CharacterItem)w.GetComponentInChildren<WeaponItem>()).Entity.Name);
		}

		public static GameObject GetMove(string name)
		{
			return FindVanillaObject(database.GetCombatMoves(), name, (GameObject m) => ((CharacterItem)m.GetComponentInChildren<SpecialAbility>()).Entity.Name);
		}

		public static GameObject GetProjectile(string name)
		{
			GameObject gameObject = FindVanillaObject(database.GetProjectiles(), name, (GameObject p) => p.GetComponent<ProjectileEntity>().Entity.Name).gameObject;
			return ((Object)(object)gameObject != (Object)null) ? gameObject.gameObject : null;
		}

		public static GameObject GetExplosion(string name)
		{
			Explosion val = FindVanillaObject(explosions, name, (Explosion e) => ((Object)((Component)e).gameObject).name);
			return ((Object)(object)val != (Object)null) ? ((Component)val).gameObject : null;
		}

		public static UnitEffectBase GetEffect(string name)
		{
			return FindVanillaObject(effects, name, (UnitEffectBase e) => ((Object)((Component)e).gameObject).name);
		}

		public static Sprite GetIcon(string name)
		{
			FactionIcon val = FindVanillaObject(fullDatabase.GetFactionIcons(), name, (FactionIcon i) => i.Entity.Name);
			if ((Object)(object)val != (Object)null)
			{
				return val.Entity.SpriteIcon;
			}
			Sprite val2 = FindVanillaObject(AssetImporter.Sprites, name, (Sprite s) => ((Object)s).name);
			if ((Object)(object)val2 != (Object)null)
			{
				return val2;
			}
			return FindVanillaObject(sprites, name, (Sprite s) => ((Object)s).name);
		}

		public static UnitBlueprint GetUnit(string name)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			UnitBlueprint val = FindVanillaObject(database.GetUnitBlueprints(), name, (UnitBlueprint u) => u.Entity.Name);
			return ((Object)(object)val != (Object)null) ? database.GetUnitBlueprint(val.Entity.GUID) : null;
		}

		public static Faction GetFaction(string name)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			Faction val = FindVanillaObject(database.GetFactions(), name, (Faction f) => f.Entity.Name);
			return ((Object)(object)val != (Object)null) ? database.GetFaction(val.Entity.GUID) : null;
		}

		public static void AddUnitToDatabase(UnitBlueprint unit)
		{
			//IL_0059: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<DatabaseID, Object> dictionary = (Dictionary<DatabaseID, Object>)typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(fullDatabase.AssetLoader);
			Dictionary<DatabaseID, UnitBlueprint> dictionary2 = (Dictionary<DatabaseID, UnitBlueprint>)typeof(LandfallContentDatabase).GetField("m_unitBlueprints", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(database);
			if (!dictionary2.ContainsKey(unit.Entity.GUID))
			{
				dictionary2.Add(unit.Entity.GUID, unit);
				dictionary.Add(unit.Entity.GUID, (Object)(object)unit);
			}
			typeof(LandfallContentDatabase).GetField("m_unitBlueprints", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(database, dictionary2);
			typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(fullDatabase.AssetLoader, dictionary);
		}

		public static void AddFactionToDatabase(Faction faction)
		{
			//IL_0059: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<DatabaseID, Object> dictionary = (Dictionary<DatabaseID, Object>)typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(fullDatabase.AssetLoader);
			Dictionary<DatabaseID, Faction> dictionary2 = (Dictionary<DatabaseID, Faction>)typeof(LandfallContentDatabase).GetField("m_factions", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(database);
			if (!dictionary2.ContainsKey(faction.Entity.GUID))
			{
				dictionary2.Add(faction.Entity.GUID, faction);
				dictionary.Add(faction.Entity.GUID, (Object)(object)faction);
			}
			typeof(LandfallContentDatabase).GetField("m_factions", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(database, dictionary2);
			typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(fullDatabase.AssetLoader, dictionary);
		}

		public static GameObject GetModel(string name)
		{
			GameObject val = FindVanillaObject(AssetImporter.Models, name, (GameObject m) => ((Object)m.gameObject).name);
			return ((Object)(object)val != (Object)null) ? val.gameObject : null;
		}

		public static void SetFlagsChildren(Transform child, HideFlags flag)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			((Object)((Component)child).gameObject).hideFlags = flag;
			for (int i = 0; i < child.childCount; i++)
			{
				SetFlagsChildren(child.GetChild(i), flag);
			}
		}
	}
}
namespace ModdingForDummies.TABSSimp
{
	public abstract class Mod
	{
		private const string KEY_BASES = "bases";

		private const string KEY_UNITS = "units";

		private const string KEY_FACTIONS = "factions";

		private const string KEY_WEAPONS = "weapons";

		private const string KEY_CLOTHES = "clothes";

		private const string KEY_PROJECTILES = "projectiles";

		private const string KEY_MOVES = "moves";

		private const string KEY_EXPLOSIONS = "explosions";

		private const string KEY_ICONS = "icons";

		private const string KEY_EFFECTS = "effects";

		private const string KEY_MODELS = "models";

		private static Dictionary<string, Dictionary<string, object>> vanilla;

		private static Dictionary<string, Dictionary<string, object>> modified;

		private static GameObject pool;

		public static bool DEV_MODE { get; protected set; }

		static Mod()
		{
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Expected O, but got Unknown
			DEV_MODE = true;
			vanilla = new Dictionary<string, Dictionary<string, object>>();
			modified = new Dictionary<string, Dictionary<string, object>>();
			vanilla["bases"] = new Dictionary<string, object>();
			vanilla["units"] = new Dictionary<string, object>();
			vanilla["factions"] = new Dictionary<string, object>();
			vanilla["weapons"] = new Dictionary<string, object>();
			vanilla["clothes"] = new Dictionary<string, object>();
			vanilla["projectiles"] = new Dictionary<string, object>();
			vanilla["moves"] = new Dictionary<string, object>();
			vanilla["explosions"] = new Dictionary<string, object>();
			vanilla["icons"] = new Dictionary<string, object>();
			vanilla["effects"] = new Dictionary<string, object>();
			vanilla["models"] = new Dictionary<string, object>();
			modified["bases"] = new Dictionary<string, object>();
			modified["units"] = new Dictionary<string, object>();
			modified["factions"] = new Dictionary<string, object>();
			modified["weapons"] = new Dictionary<string, object>();
			modified["clothes"] = new Dictionary<string, object>();
			modified["projectiles"] = new Dictionary<string, object>();
			modified["moves"] = new Dictionary<string, object>();
			modified["explosions"] = new Dictionary<string, object>();
			modified["icons"] = new Dictionary<string, object>();
			modified["effects"] = new Dictionary<string, object>();
			modified["models"] = new Dictionary<string, object>();
			GameObject val = new GameObject("Pool")
			{
				hideFlags = (HideFlags)61
			};
			val.transform.position = Vector3.down * -1000f;
			pool = val;
			pool.SetActive(false);
		}

		public static GameObject 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;
			pool.transform.SetHideFlagsChildren((HideFlags)61);
			return gameObject;
		}

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

		private static M CreateObject<M>(string key, Func<string, M> query, Action<M> processClone, string name, string originalName) where M : ModdingClass<M>
		{
			M val = null;
			M val2 = query(originalName);
			if (val2 != null)
			{
				val = val2.Clone();
				processClone?.Invoke(val);
				val.Name = name;
				modified[key][name] = val;
			}
			return val;
		}

		private static M GetObject<M, R>(string key, Func<string, R> query, Func<R, M> generate, string name)
		{
			M val = default(M);
			if (modified[key].ContainsKey(name))
			{
				val = (M)modified[key][name];
			}
			else if (vanilla[key].ContainsKey(name))
			{
				val = (M)vanilla[key][name];
			}
			else
			{
				R val2 = query(name);
				if (val2 != null)
				{
					val = generate(val2);
					vanilla[key][name] = val;
				}
			}
			if (val == null)
			{
				Debug.LogError((object)("[MFD] Could not find '" + name + "' in '" + key + "'."));
			}
			return val;
		}

		public static ModUnit GetUnit(string name)
		{
			return GetObject("units", Utilities.GetUnit, (UnitBlueprint u) => new ModUnit(u), name);
		}

		public static ModUnit CreateUnit(string name, string originalName = null)
		{
			return CreateObject("units", GetUnit, delegate(ModUnit mu)
			{
				if (originalName == null)
				{
					mu.Clothes.Clear();
				}
			}, name, (originalName == null) ? "Peasant" : originalName);
		}

		public static ModFaction GetFaction(string name)
		{
			return GetObject("factions", Utilities.GetFaction, (Faction f) => new ModFaction(f), name);
		}

		public static ModFaction CreateFaction(string name, string originalName = null)
		{
			return CreateObject("factions", GetFaction, delegate(ModFaction mf)
			{
				mf.Units.Clear();
				mf.Visible = true;
			}, name, (originalName == null) ? "Base Faction" : originalName);
		}

		public static ModWeapon GetWeapon(string name)
		{
			return GetObject("weapons", Utilities.GetWeapon, (GameObject w) => new ModWeapon(w), name);
		}

		public static ModWeapon CreateWeapon(string name, string originalName)
		{
			return CreateObject("weapons", GetWeapon, null, name, originalName);
		}

		public static ModClothing GetClothing(string name)
		{
			return GetObject("clothes", Utilities.GetClothing, (GameObject c) => new ModClothing(c), name);
		}

		public static ModClothing CreateClothing(string name, string originalName)
		{
			return CreateObject("clothes", GetClothing, null, name, originalName);
		}

		public static ModMove GetMove(string name)
		{
			return GetObject("moves", Utilities.GetMove, (GameObject m) => new ModMove(m), name);
		}

		public static ModMove CreateMove(string name, string originalName)
		{
			return CreateObject("moves", GetMove, null, name, originalName);
		}

		public static ModProjectile GetProjectile(string name)
		{
			return GetObject("projectiles", Utilities.GetProjectile, (GameObject p) => new ModProjectile(p), name);
		}

		public static ModProjectile CreateProjectile(string name, string originalName)
		{
			return CreateObject("projectiles", GetProjectile, null, name, originalName);
		}

		public static ModExplosion GetExplosion(string name)
		{
			return GetObject("explosions", Utilities.GetExplosion, (GameObject e) => new ModExplosion(e), name);
		}

		public static ModExplosion CreateExplosion(string name, string originalName)
		{
			return CreateObject("explosions", GetExplosion, null, name, originalName);
		}

		public static ModEffect GetEffect(string name)
		{
			return GetObject("effects", Utilities.GetEffect, (UnitEffectBase e) => new ModEffect(e), name);
		}

		public static ModEffect CreateEffect(string name, string originalName)
		{
			return CreateObject("effects", GetEffect, null, name, originalName);
		}

		public static ModBase GetBase(string name)
		{
			return GetObject("bases", Utilities.GetUnitBase, (GameObject b) => new ModBase(b), name);
		}

		public static ModBase CreateBase(string name, string originalName)
		{
			return CreateObject("bases", GetBase, null, name, originalName);
		}

		public static ModModel GetModel(string name)
		{
			return GetObject("models", Utilities.GetModel, (GameObject m) => new ModModel(m), name);
		}

		public static ModModel CreateModel(string name, string originalName)
		{
			return CreateObject("models", GetModel, null, name, originalName);
		}

		public static Sprite GetIcon(string name)
		{
			return GetObject("icons", Utilities.GetIcon, (Sprite s) => s, name);
		}
	}
	public class ModBase : ModdingClass<ModBase>
	{
		public GameObject internalObject { get; private set; }

		public override string Name
		{
			get
			{
				return ((Object)internalObject.gameObject).name;
			}
			set
			{
				((Object)internalObject.gameObject).name = value;
			}
		}

		public override void ColorInternal(int index, Color color, float glow = 0f)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Utilities.SetObjectColor(internalObject, index, color, glow);
		}

		public ModBase(GameObject unitBase)
		{
			internalObject = unitBase;
		}

		public override ModBase Clone()
		{
			GameObject unitBase = Mod.CloneAndPoolObject(internalObject);
			return new ModBase(unitBase);
		}

		public override void Separate()
		{
		}
	}
	public enum ClothingType
	{
		Static,
		Skinned
	}
	public class ModClothing : ModdingClass<ModClothing>
	{
		private PropItem item;

		private SkinnedMeshRenderer renderer;

		private ModModel model;

		public GameObject internalObject { get; private set; }

		public ClothingType Type { get; private set; }

		public override string Name
		{
			get
			{
				return ((CharacterItem)item).Entity.Name;
			}
			set
			{
				((CharacterItem)item).Entity.Name = value;
			}
		}

		public ModModel Model
		{
			get
			{
				return model;
			}
			set
			{
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_008f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
				if (value != null)
				{
					Utilities.SetMeshRenderers(internalObject, enabled: false);
					model = value.Clone();
					if (Type == ClothingType.Static)
					{
						model.internalObject.transform.parent = internalObject.transform;
						model.internalObject.transform.localPosition = Vector3.zero;
						model.internalObject.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
					}
					else if (Type == ClothingType.Skinned)
					{
						Utilities.PlaceMeshOnBone(renderer, model.internalObject, ((CharacterItem)item).GearT);
					}
				}
				else
				{
					if (model != null)
					{
						Utilities.SetMeshRenderers(internalObject, enabled: true);
					}
					model = null;
				}
			}
		}

		public float Size
		{
			get
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				Vector3 localScale = internalObject.transform.localScale;
				return (localScale.x + localScale.y + localScale.z) / 3f;
			}
			set
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				Utilities.SetClothScale(this, Vector3.one * value);
			}
		}

		public Vector3 Scale
		{
			get
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				return internalObject.transform.localScale;
			}
			set
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				Utilities.SetClothScale(this, value);
			}
		}

		public override void ColorInternal(int index, Color color, float glow = 0f)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (model == null)
			{
				Utilities.SetObjectColor(internalObject, index, color, glow);
			}
			else
			{
				model.Color(index, color, glow);
			}
		}

		public ModClothing(GameObject prop)
		{
			internalObject = Mod.CloneAndPoolObject(prop);
			renderer = internalObject.GetComponentInChildren<SkinnedMeshRenderer>();
			Type = (((Object)(object)renderer != (Object)null) ? ClothingType.Skinned : ClothingType.Static);
			item = internalObject.GetComponentInChildren<PropItem>();
		}

		public override ModClothing Clone()
		{
			ModClothing modClothing = new ModClothing(internalObject)
			{
				Model = Model
			};
			modClothing.Separate();
			return modClothing;
		}

		public override void Separate()
		{
		}
	}
	public abstract class ModdingClass<T> where T : ModdingClass<T>
	{
		public abstract string Name { get; set; }

		public abstract T Clone();

		public abstract void Separate();

		public abstract void ColorInternal(int index, Color color, float glow = 0f);

		public void Color(Color color, float glow = 0f)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			ColorInternal(0, color, glow);
		}

		public void Color(string color, float glow = 0f)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			Color(0, Utilities.HexColor(color), glow);
		}

		public void Color(int index, Color color, float glow = 0f)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			ColorInternal(index, color, glow);
		}

		public void Color(int index, string color, float glow = 0f)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			Color(index, Utilities.HexColor(color), glow);
		}

		public void Colors(params Color[] colors)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < colors.Length; i++)
			{
				Color(i, colors[i]);
			}
		}

		public void Colors(params string[] colors)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < colors.Length; i++)
			{
				Color(i, Utilities.HexColor(colors[i]));
			}
		}

		public void Colors(params (Color color, float glow)[] colors)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < colors.Length; i++)
			{
				Color(i, colors[i].color, colors[i].glow);
			}
		}

		public void Colors(params (string color, float glow)[] colors)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < colors.Length; i++)
			{
				Color(i, Utilities.HexColor(colors[i].color), colors[i].glow);
			}
		}
	}
	public class ModEffect : ModdingClass<ModEffect>
	{
		public UnitEffectBase internalObject { get; private set; }

		public override string Name
		{
			get
			{
				return ((Object)((Component)internalObject).gameObject).name;
			}
			set
			{
				((Object)((Component)internalObject).gameObject).name = value;
			}
		}

		public override void ColorInternal(int index, Color color, float glow = 0f)
		{
		}

		public ModEffect(UnitEffectBase effect)
		{
			internalObject = effect;
		}

		public override ModEffect Clone()
		{
			GameObject val = Mod.CloneAndPoolObject(((Component)internalObject).gameObject);
			return new ModEffect(val.GetComponent<UnitEffectBase>());
		}

		public override void Separate()
		{
		}
	}
	public class ModExplosion : ModdingClass<ModExplosion>
	{
		private Explosion explosion;

		private ExplosionAddEffect addEffect;

		private ModEffect effect;

		public GameObject internalObject { get; private set; }

		public override string Name
		{
			get
			{
				return ((Object)internalObject).name;
			}
			set
			{
				((Object)internalObject).name = value;
			}
		}

		public float Damage
		{
			get
			{
				if (Object.op_Implicit((Object)(object)explosion))
				{
					return explosion.damage;
				}
				return 0f;
			}
			set
			{
				if (Object.op_Implicit((Object)(object)explosion))
				{
					explosion.damage = value;
				}
			}
		}

		public float Force
		{
			get
			{
				if (Object.op_Implicit((Object)(object)explosion))
				{
					return explosion.force;
				}
				return 0f;
			}
			set
			{
				if (Object.op_Implicit((Object)(object)explosion))
				{
					explosion.force = value;
				}
			}
		}

		public ForceDirection ForceDirection
		{
			get
			{
				//IL_001f: 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_001b: 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)
				if (Object.op_Implicit((Object)(object)explosion))
				{
					return explosion.forceDirection;
				}
				return (ForceDirection)0;
			}
			set
			{
				//IL_0016: 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)
				if (Object.op_Implicit((Object)(object)explosion))
				{
					explosion.forceDirection = value;
				}
			}
		}

		public float Radius
		{
			get
			{
				if (Object.op_Implicit((Object)(object)explosion))
				{
					return explosion.radius;
				}
				return 0f;
			}
			set
			{
				if (Object.op_Implicit((Object)(object)explosion))
				{
					explosion.radius = value;
				}
			}
		}

		public ModEffect Effect
		{
			get
			{
				return effect;
			}
			set
			{
				effect = value;
				if (!Object.op_Implicit((Object)(object)addEffect))
				{
					addEffect = internalObject.AddComponent<ExplosionAddEffect>();
				}
				if (value != null)
				{
					addEffect.EffectPrefab = value.internalObject;
				}
				else
				{
					addEffect.EffectPrefab = null;
				}
			}
		}

		public float Size
		{
			get
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				Vector3 localScale = internalObject.transform.localScale;
				return (localScale.x + localScale.y + localScale.z) / 3f;
			}
			set
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				internalObject.transform.localScale = Vector3.one * value;
			}
		}

		public Vector3 Scale
		{
			get
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				return internalObject.transform.localScale;
			}
			set
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				internalObject.transform.localScale = value;
			}
		}

		public override void ColorInternal(int index, Color color, float glow = 0f)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Utilities.SetObjectColor(internalObject, index, color, glow);
		}

		public ModExplosion(GameObject explosionObject)
		{
			internalObject = explosionObject;
			explosion = internalObject.GetComponentInChildren<Explosion>();
			addEffect = internalObject.GetComponentInChildren<ExplosionAddEffect>();
		}

		public override ModExplosion Clone()
		{
			GameObject explosionObject = Mod.CloneAndPoolObject(internalObject);
			ModExplosion modExplosion = new ModExplosion(explosionObject);
			if (Effect != null)
			{
				modExplosion.Effect = Effect;
			}
			return modExplosion;
		}

		public override void Separate()
		{
			if (Effect != null)
			{
				Effect = Effect.Clone();
			}
		}
	}
	public class ModFaction : ModdingClass<ModFaction>
	{
		public Faction internalObject { get; private set; }

		public WrapperDelineation<ModUnit> Units { get; private set; }

		public UnitBlueprint[] Blueprints => Units.List.Select((ModUnit w) => w.internalObject).ToArray();

		public override string Name
		{
			get
			{
				return internalObject.Entity.Name;
			}
			set
			{
				internalObject.Entity.Name = value;
			}
		}

		public bool Visible
		{
			get
			{
				return internalObject.m_displayFaction;
			}
			set
			{
				internalObject.m_displayFaction = value;
			}
		}

		public Sprite Icon
		{
			get
			{
				return internalObject.Entity.SpriteIcon;
			}
			set
			{
				internalObject.Entity.SetSpriteIcon(value);
			}
		}

		private void UpdateBlueprints(List<ModUnit> units)
		{
			internalObject.Units = (from ModUnit unit in units
				select unit.internalObject).ToArray();
		}

		public ModUnit NewUnit(string name, string originalName = null)
		{
			ModUnit modUnit = Mod.CreateUnit(name, originalName);
			Units.Add(modUnit);
			return modUnit;
		}

		public override void ColorInternal(int index, Color color, float glow = 0f)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			internalObject.m_FactionColor = color;
		}

		public ModFaction(Faction faction)
		{
			internalObject = faction;
			Units = new WrapperDelineation<ModUnit>(UpdateBlueprints, Mod.GetUnit)
			{
				List = (from UnitBlueprint blueprint in internalObject.Units
					select new ModUnit(blueprint)).ToList()
			};
		}

		public override ModFaction Clone()
		{
			Faction val = Object.Instantiate<Faction>(internalObject);
			val.Entity.GenerateNewID();
			val.Entity.Name = Utilities.IncrementName(Name);
			val.Units = Array.Empty<UnitBlueprint>();
			val.index = Utilities.database.GetFactions().ToList().Count;
			Utilities.AddFactionToDatabase(val);
			ModFaction modFaction = new ModFaction(val);
			modFaction.Separate();
			return modFaction;
		}

		public override void Separate()
		{
			Units.List = (from ModUnit unit in Units.List
				select unit.Clone()).ToList();
		}
	}
	public class ModModel : ModdingClass<ModModel>
	{
		private Vector3 position;

		private Quaternion rotation;

		public GameObject internalObject { get; private set; }

		public override string Name
		{
			get
			{
				return ((Object)internalObject.gameObject).name;
			}
			set
			{
				((Object)internalObject.gameObject).name = value;
			}
		}

		public Vector3 Position
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return position;
			}
			set
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: 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)
				position = value;
				internalObject.transform.localPosition = position;
			}
		}

		public Quaternion Rotation
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return rotation;
			}
			set
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				rotation = value;
				internalObject.transform.localRotation = Utilities.blenderToUnity * rotation;
			}
		}

		public override void ColorInternal(int index, Color color, float glow = 0f)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Utilities.SetObjectColor(internalObject, index, color, glow);
		}

		public ModModel(GameObject model)
		{
			internalObject = model;
		}

		public override ModModel Clone()
		{
			GameObject model = Mod.CloneAndPoolObject(internalObject);
			return new ModModel(model);
		}

		public override void Separate()
		{
		}
	}
	public class ModMove : ModdingClass<ModMove>
	{
		private SpecialAbility specialAbility;

		public GameObject internalObject { get; private set; }

		public override string Name
		{
			get
			{
				return ((CharacterItem)specialAbility).Entity.Name;
			}
			set
			{
				((CharacterItem)specialAbility).Entity.Name = value;
			}
		}

		public override void ColorInternal(int index, Color color, float glow = 0f)
		{
		}

		public ModMove(GameObject move)
		{
			internalObject = move;
			specialAbility = move.GetComponentInChildren<SpecialAbility>();
		}

		public override ModMove Clone()
		{
			GameObject move = Mod.CloneAndPoolObject(internalObject);
			return new ModMove(move);
		}

		public override void Separate()
		{
		}
	}
	public enum ProjectileType
	{
		Regular,
		Physical,
		Other
	}
	public class ModProjectile : ModdingClass<ModProjectile>
	{
		private ProjectileEntity projectileEntity;

		private ProjectileHit rHit;

		private MoveTransform rMoveTransform;

		private ProjectileHitAddEffect rAddEffect;

		private CollisionWeapon pCollision;

		private AddForce pAddForce;

		private MeleeWeaponAddEffect pAddEffect;

		private MeleeWeaponSpawn pSpawner;

		private ModModel model;

		private ModEffect effect;

		private ModUnit unit;

		public GameObject internalObject { get; private set; }

		public override string Name
		{
			get
			{
				return projectileEntity.Entity.Name;
			}
			set
			{
				projectileEntity.Entity.Name = value;
			}
		}

		public ProjectileType Type { get; private set; }

		public ModModel Model
		{
			get
			{
				return model;
			}
			set
			{
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				if (value != null)
				{
					Utilities.SetMeshRenderers(internalObject, enabled: false);
					model = value.Clone();
					model.internalObject.transform.parent = internalObject.transform;
					model.internalObject.transform.localPosition = Vector3.zero;
					model.internalObject.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
				}
				else
				{
					if (model != null)
					{
						Utilities.SetMeshRenderers(internalObject, enabled: true);
					}
					model = null;
				}
			}
		}

		public ModEffect Effect
		{
			get
			{
				return effect;
			}
			set
			{
				effect = value;
				if (Type == ProjectileType.Regular)
				{
					if (!Object.op_Implicit((Object)(object)rAddEffect))
					{
						rAddEffect = ((Component)rHit).gameObject.AddComponent<ProjectileHitAddEffect>();
					}
					rAddEffect.EffectPrefab = value?.internalObject;
				}
				else if (Type == ProjectileType.Physical)
				{
					if (!Object.op_Implicit((Object)(object)pAddEffect))
					{
						pAddEffect = ((Component)pCollision).gameObject.AddComponent<MeleeWeaponAddEffect>();
					}
					pAddEffect.EffectPrefab = value?.internalObject;
				}
			}
		}

		public WrapperDelineation<ModExplosion> Explosions { get; private set; }

		public ModExplosion Explosion
		{
			get
			{
				ModExplosion result = null;
				if (Explosions.List.Count > 0)
				{
					result = Explosions.List[0];
				}
				return result;
			}
			set
			{
				Explosions.Clear();
				if (value != null)
				{
					Explosions.Add(value);
				}
			}
		}

		public ModUnit Unit
		{
			get
			{
				return unit;
			}
			set
			{
				unit = value;
				Explosions.Clear();
				ModExplosion modExplosion = Utilities.unitSpawner.Clone();
				modExplosion.internalObject.GetComponent<UnitSpawner>().unitBlueprint = unit.internalObject;
				Explosions.Add(modExplosion);
			}
		}

		public float Damage
		{
			get
			{
				if (Type == ProjectileType.Regular)
				{
					return rHit.damage;
				}
				if (Type == ProjectileType.Physical)
				{
					return pCollision.damage;
				}
				return 0f;
			}
			set
			{
				if (Type == ProjectileType.Regular)
				{
					rHit.damage = value;
				}
				else if (Type == ProjectileType.Physical)
				{
					pCollision.damage = value;
				}
			}
		}

		public float Force
		{
			get
			{
				if (Type == ProjectileType.Regular)
				{
					return rHit.force;
				}
				if (Type == ProjectileType.Physical)
				{
					return pCollision.onImpactForce;
				}
				return 0f;
			}
			set
			{
				if (Type == ProjectileType.Regular)
				{
					rHit.force = value;
				}
				else if (Type == ProjectileType.Physical)
				{
					pCollision.onImpactForce = value;
				}
			}
		}

		public float Speed
		{
			get
			{
				if (Type == ProjectileType.Regular)
				{
					return rMoveTransform.selfImpulse.z;
				}
				if (Type == ProjectileType.Physical)
				{
					return pAddForce.force.z;
				}
				return 0f;
			}
			set
			{
				if (Type == ProjectileType.Regular)
				{
					rMoveTransform.selfImpulse.z = value;
				}
				else if (Type == ProjectileType.Physical)
				{
					pAddForce.force.z = value;
				}
			}
		}

		public float Size
		{
			get
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				Vector3 localScale = internalObject.transform.localScale;
				return (localScale.x + localScale.y + localScale.z) / 3f;
			}
			set
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				internalObject.transform.localScale = Vector3.one * value;
			}
		}

		public Vector3 Scale
		{
			get
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				return internalObject.transform.localScale;
			}
			set
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				internalObject.transform.localScale = value;
			}
		}

		public void UpdateImpact(List<ModExplosion> explosions)
		{
			if (Type == ProjectileType.Regular)
			{
				rHit.objectsToSpawn = explosions.Cast<ModExplosion>().Select((Func<ModExplosion, ObjectToSpawn>)((ModExplosion explosion) => new ObjectToSpawn
				{
					objectToSpawn = explosion.internalObject
				})).ToArray();
			}
			else if (Type == ProjectileType.Physical && explosions.Count > 0)
			{
				if (Object.op_Implicit((Object)(object)pSpawner))
				{
					pSpawner.objectToSpawn = explosions[0].internalObject;
					return;
				}
				pSpawner = ((Component)pCollision).gameObject.AddComponent<MeleeWeaponSpawn>();
				pSpawner.objectToSpawn = explosions[0].internalObject;
			}
		}

		public override void ColorInternal(int index, Color color, float glow = 0f)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Utilities.SetObjectColor(internalObject, index, color, glow);
		}

		public ModProjectile(GameObject projectile, bool isClone = false)
		{
			internalObject = projectile;
			projectileEntity = internalObject.GetComponentInChildren<ProjectileEntity>();
			rHit = internalObject.GetComponentInChildren<ProjectileHit>();
			rMoveTransform = internalObject.GetComponentInChildren<MoveTransform>();
			rAddEffect = internalObject.GetComponentInChildren<ProjectileHitAddEffect>();
			pCollision = internalObject.GetComponentInChildren<CollisionWeapon>();
			pAddForce = internalObject.GetComponentInChildren<AddForce>();
			pAddEffect = internalObject.GetComponentInChildren<MeleeWeaponAddEffect>();
			pSpawner = internalObject.GetComponentInChildren<MeleeWeaponSpawn>();
			Explosions = new WrapperDelineation<ModExplosion>(UpdateImpact, Mod.GetExplosion);
			if (Object.op_Implicit((Object)(object)rHit))
			{
				Type = ProjectileType.Regular;
			}
			else if (Object.op_Implicit((Object)(object)pCollision))
			{
				Type = ProjectileType.Physical;
			}
			else
			{
				Type = ProjectileType.Other;
			}
			if (Type == ProjectileType.Regular)
			{
				ObjectToSpawn[] objectsToSpawn = rHit.objectsToSpawn;
				foreach (ObjectToSpawn val in objectsToSpawn)
				{
					if (val != null)
					{
						Explosions.Add(new ModExplosion(val.objectToSpawn));
					}
				}
				if (Object.op_Implicit((Object)(object)rAddEffect) && Object.op_Implicit((Object)(object)rAddEffect.EffectPrefab) && !isClone)
				{
					effect = new ModEffect(rAddEffect.EffectPrefab);
				}
			}
			else if (Type == ProjectileType.Physical)
			{
				if (Object.op_Implicit((Object)(object)pSpawner) && Object.op_Implicit((Object)(object)pSpawner.objectToSpawn))
				{
					Explosions.Add(new ModExplosion(pSpawner.objectToSpawn));
				}
				if (Object.op_Implicit((Object)(object)pAddEffect) && Object.op_Implicit((Object)(object)pAddEffect.EffectPrefab) && !isClone)
				{
					effect = new ModEffect(pAddEffect.EffectPrefab);
				}
			}
		}

		public override ModProjectile Clone()
		{
			GameObject projectile = Mod.CloneAndPoolObject(internalObject);
			ModProjectile modProjectile = new ModProjectile(projectile, isClone: true);
			modProjectile.Explosions.List = Explosions.List;
			modProjectile.Model = Model;
			ModProjectile modProjectile2 = modProjectile;
			string name = Utilities.IncrementName(modProjectile2.projectileEntity.Entity.Name);
			modProjectile2.projectileEntity.Entity.Name = name;
			((Object)modProjectile2.internalObject).name = name;
			if (Effect != null)
			{
				modProjectile2.Effect = Effect;
			}
			modProjectile2.Separate();
			return modProjectile2;
		}

		public override void Separate()
		{
			if (Effect != null)
			{
				Effect = Effect.Clone();
			}
			Explosions.List = (from ModExplosion explosion in Explosions.List
				select explosion.Clone()).ToList();
		}
	}
	public enum WeaponType
	{
		Melee,
		Ranged
	}
	public class ModWeapon : ModdingClass<ModWeapon>
	{
		public class ModMelee
		{
			private readonly ModWeapon internalWeapon;

			public float SwingSpeed
			{
				get
				{
					return (internalWeapon.Type == WeaponType.Melee) ? internalWeapon.internalMelee.curveForce : 0f;
				}
				set
				{
					if (internalWeapon.Type == WeaponType.Melee)
					{
						internalWeapon.internalMelee.curveForce = value;
					}
				}
			}

			public Vector3 SwingDirection
			{
				get
				{
					//IL_001f: 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)
					return (internalWeapon.Type == WeaponType.Melee) ? internalWeapon.internalMelee.swingDirection : Vector3.zero;
				}
				set
				{
					//IL_001e: Unknown result type (might be due to invalid IL or missing references)
					//IL_001f: Unknown result type (might be due to invalid IL or missing references)
					if (internalWeapon.Type == WeaponType.Melee)
					{
						internalWeapon.internalMelee.swingDirection = value;
					}
				}
			}

			public float Impact
			{
				get
				{
					return (internalWeapon.Type == WeaponType.Melee) ? internalWeapon.mCollision.impactMultiplier : 0f;
				}
				set
				{
					if (internalWeapon.Type == WeaponType.Melee)
					{
						internalWeapon.mCollision.impactMultiplier = value;
					}
				}
			}

			public ModMelee(ModWeapon weapon)
			{
				internalWeapon = weapon;
			}
		}

		public class ModRanged
		{
			private readonly ModWeapon internalWeapon;

			public ModProjectile Projectile
			{
				get
				{
					return internalWeapon.projectile;
				}
				set
				{
					if (internalWeapon.Type == WeaponType.Ranged)
					{
						internalWeapon.projectile = value;
						internalWeapon.internalRanged.ObjectToSpawn = internalWeapon.projectile.internalObject;
					}
				}
			}

			public ModUnit UnitProjectile
			{
				get
				{
					return internalWeapon.unit;
				}
				set
				{
					internalWeapon.unit = value;
					if (internalWeapon.Type == WeaponType.Ranged)
					{
						Projectile = null;
						internalWeapon.internalRanged.unitToSpawn = internalWeapon.unit.internalObject;
					}
				}
			}

			public int Ammo
			{
				get
				{
					if (internalWeapon.Type == WeaponType.Ranged)
					{
						return internalWeapon.internalRanged.magSize;
					}
					return 0;
				}
				set
				{
					if (internalWeapon.Type == WeaponType.Ranged)
					{
						internalWeapon.internalRanged.magSize = value;
					}
				}
			}

			public int ProjectileAmount
			{
				get
				{
					if (internalWeapon.Type == WeaponType.Ranged)
					{
						return internalWeapon.internalRanged.numberOfObjects;
					}
					return 0;
				}
				set
				{
					if (internalWeapon.Type == WeaponType.Ranged)
					{
						internalWeapon.internalRanged.numberOfObjects = value;
					}
				}
			}

			public float Spread
			{
				get
				{
					if (internalWeapon.Type == WeaponType.Ranged)
					{
						return internalWeapon.internalRanged.spread;
					}
					return 0f;
				}
				set
				{
					if (internalWeapon.Type == WeaponType.Ranged)
					{
						internalWeapon.internalRanged.spread = value;
					}
				}
			}

			public float Recoil
			{
				get
				{
					if (internalWeapon.Type == WeaponType.Ranged)
					{
						return internalWeapon.internalRanged.shootRecoil;
					}
					return 0f;
				}
				set
				{
					if (internalWeapon.Type == WeaponType.Ranged)
					{
						internalWeapon.internalRanged.shootRecoil = value;
						internalWeapon.internalRanged.torsoRecoil = value * 0.1f;
					}
				}
			}

			public ModRanged(ModWeapon weapon)
			{
				internalWeapon = weapon;
			}
		}

		private WeaponItem item;

		private Weapon weapon;

		private RangeWeapon internalRanged;

		private MeleeWeapon internalMelee;

		private CollisionWeapon mCollision;

		private MeleeWeaponSpawn mSpawner;

		private MeleeWeaponAddEffect mAddEffect;

		private ModEffect effect;

		private ModExplosion explosion;

		private ModModel model;

		public ModMelee Melee;

		private ModProjectile projectile;

		private ModUnit unit;

		public ModRanged Ranged;

		public GameObject internalObject { get; private set; }

		public override string Name
		{
			get
			{
				return ((CharacterItem)item).Entity.Name;
			}
			set
			{
				((CharacterItem)item).Entity.Name = value;
			}
		}

		public WeaponType Type { get; private set; }

		public float Cooldown
		{
			get
			{
				return weapon.internalCooldown;
			}
			set
			{
				weapon.internalCooldown = value;
			}
		}

		public float AttackSpeed
		{
			get
			{
				return 1f / weapon.internalCooldown;
			}
			set
			{
				weapon.internalCooldown = 1f / value;
			}
		}

		public float AttackRange
		{
			get
			{
				return weapon.maxRange;
			}
			set
			{
				weapon.maxRange = value;
			}
		}

		public float AttackAngle
		{
			get
			{
				return weapon.maxAngle;
			}
			set
			{
				weapon.maxAngle = value;
			}
		}

		public bool StartCooldown
		{
			get
			{
				return weapon.startOnCooldown;
			}
			set
			{
				weapon.startOnCooldown = value;
			}
		}

		public float Damage
		{
			get
			{
				if (Type == WeaponType.Melee)
				{
					return mCollision.damage;
				}
				if (Type == WeaponType.Ranged)
				{
					return Ranged.Projectile.Damage;
				}
				return 0f;
			}
			set
			{
				if (Type == WeaponType.Melee)
				{
					mCollision.damage = value;
				}
				else if (Type == WeaponType.Ranged)
				{
					Ranged.Projectile.Damage = value;
				}
			}
		}

		public float Force
		{
			get
			{
				if (Type == WeaponType.Melee)
				{
					return mCollision.onImpactForce;
				}
				if (Type == WeaponType.Ranged)
				{
					return projectile.Force;
				}
				return 0f;
			}
			set
			{
				if (Type == WeaponType.Melee)
				{
					mCollision.onImpactForce = value;
				}
				else if (Type == WeaponType.Ranged)
				{
					projectile.Force = value;
				}
			}
		}

		public ModEffect Effect
		{
			get
			{
				if (Type == WeaponType.Melee)
				{
					return effect;
				}
				if (Type == WeaponType.Ranged)
				{
					return Ranged.Projectile.Effect;
				}
				return null;
			}
			set
			{
				effect = value;
				if (Type == WeaponType.Melee)
				{
					effect = value;
					if (!Object.op_Implicit((Object)(object)mAddEffect))
					{
						mAddEffect = internalObject.AddComponent<MeleeWeaponAddEffect>();
					}
					bool flag = effect != null && Object.op_Implicit((Object)(object)effect.internalObject);
					if (flag)
					{
						mAddEffect.EffectPrefab = effect.internalObject;
					}
					else
					{
						mAddEffect.EffectPrefab = null;
					}
					((Behaviour)mAddEffect).enabled = flag;
				}
				else if (Type == WeaponType.Ranged)
				{
					Ranged.Projectile.Effect = value;
				}
			}
		}

		public ModExplosion Explosion
		{
			get
			{
				if (Type == WeaponType.Melee)
				{
					return explosion;
				}
				if (Type == WeaponType.Ranged && projectile != null)
				{
					return projectile.Explosion;
				}
				return null;
			}
			set
			{
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				explosion = value;
				if (Type == WeaponType.Melee)
				{
					if (!Object.op_Implicit((Object)(object)mSpawner))
					{
						mSpawner = internalObject.AddComponent<MeleeWeaponSpawn>();
						mSpawner.pos = (Pos)1;
					}
					bool flag = explosion != null && Object.op_Implicit((Object)(object)explosion.internalObject);
					if (flag)
					{
						mSpawner.objectToSpawn = explosion.internalObject;
					}
					else
					{
						mSpawner.objectToSpawn = null;
					}
					((Behaviour)mSpawner).enabled = flag;
				}
				else if (Type == WeaponType.Ranged && projectile != null)
				{
					projectile.Explosion = value;
				}
			}
		}

		public ModModel Model
		{
			get
			{
				return model;
			}
			set
			{
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				if (value != null)
				{
					Utilities.SetMeshRenderers(internalObject, enabled: false);
					model = value.Clone();
					model.internalObject.transform.parent = internalObject.transform;
					model.internalObject.transform.localPosition = Vector3.zero;
					model.internalObject.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
				}
				else
				{
					if (model != null)
					{
						Utilities.SetMeshRenderers(internalObject, enabled: true);
					}
					model = null;
				}
			}
		}

		public float Size
		{
			get
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				Vector3 localScale = internalObject.transform.localScale;
				return (localScale.x + localScale.y + localScale.z) / 3f;
			}
			set
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				internalObject.transform.localScale = Vector3.one * value;
			}
		}

		public Vector3 Scale
		{
			get
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				return internalObject.transform.localScale;
			}
			set
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				internalObject.transform.localScale = value;
			}
		}

		public override void ColorInternal(int index, Color color, float glow = 0f)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (model == null)
			{
				Utilities.SetObjectColor(internalObject, index, color, glow);
			}
			else
			{
				model.Color(index, color, glow);
			}
		}

		public ModWeapon(GameObject weaponObject, bool isClone = false)
		{
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Expected O, but got Unknown
			internalObject = weaponObject;
			weapon = internalObject.GetComponentInChildren<Weapon>();
			item = internalObject.GetComponentInChildren<WeaponItem>();
			mCollision = internalObject.GetComponentInChildren<CollisionWeapon>();
			mAddEffect = internalObject.GetComponentInChildren<MeleeWeaponAddEffect>();
			mSpawner = internalObject.GetComponentInChildren<MeleeWeaponSpawn>();
			if (Object.op_Implicit((Object)(object)mAddEffect) && Object.op_Implicit((Object)(object)mAddEffect.EffectPrefab) && !isClone)
			{
				effect = new ModEffect(mAddEffect.EffectPrefab);
			}
			Melee = new ModMelee(this);
			Ranged = new ModRanged(this);
			Type = ((((object)weapon).GetType() == typeof(RangeWeapon)) ? WeaponType.Ranged : WeaponType.Melee);
			if (Type == WeaponType.Melee)
			{
				internalMelee = (MeleeWeapon)weapon;
			}
			else if (Type == WeaponType.Ranged)
			{
				internalRanged = (RangeWeapon)weapon;
				if ((Object)(object)internalRanged.ObjectToSpawn != (Object)null)
				{
					Ranged.Projectile = new ModProjectile(internalRanged.ObjectToSpawn);
				}
			}
		}

		public override ModWeapon Clone()
		{
			GameObject val = Mod.CloneAndPoolObject(internalObject);
			((Object)val).name = Utilities.IncrementName(((Object)internalObject).name);
			ModWeapon modWeapon = new ModWeapon(val, isClone: true)
			{
				Model = Model
			};
			modWeapon.Separate();
			return modWeapon;
		}

		public override void Separate()
		{
			if (Type == WeaponType.Ranged)
			{
				Ranged.Projectile = Ranged.Projectile.Clone();
			}
			else if (Type == WeaponType.Melee)
			{
				if (Effect != null)
				{
					Effect = Effect.Clone();
				}
				if (Explosion != null)
				{
					Explosion = Explosion.Clone();
				}
			}
		}
	}
	public class WrapperDelineation<T> where T : ModdingClass<T>
	{
		private List<T> internalObject = new List<T>();

		private Action<List<T>> onUpdate;

		private Func<string, T> query;

		public List<T> List
		{
			get
			{
				return ListGet();
			}
			set
			{
				ListSet(value);
			}
		}

		public void Add(T item)
		{
			internalObject.Add(item);
			onUpdate(internalObject);
		}

		public void Add(string itemName)
		{
			T item = query(itemName);
			internalObject.Add(item);
			onUpdate(internalObject);
		}

		public void Add(params T[] items)
		{
			foreach (T item in items)
			{
				internalObject.Add(item);
			}
			onUpdate(internalObject);
		}

		public void Add(params string[] itemNames)
		{
			foreach (string arg in itemNames)
			{
				T item = query(arg);
				internalObject.Add(item);
			}
			onUpdate(internalObject);
		}

		public void AddCloned(T item)
		{
			internalObject.Add(item.Clone());
			onUpdate(internalObject);
		}

		public void AddCloned(string itemName)
		{
			T val = query(itemName);
			internalObject.Add(val.Clone());
			onUpdate(internalObject);
		}

		public void AddCloned(params T[] items)
		{
			foreach (T val in items)
			{
				internalObject.Add(val.Clone());
			}
			onUpdate(internalObject);
		}

		public void AddCloned(params string[] itemNames)
		{
			foreach (string arg in itemNames)
			{
				T val = query(arg);
				internalObject.Add(val.Clone());
			}
			onUpdate(internalObject);
		}

		public void Remove(T item)
		{
			internalObject.Remove(item);
			onUpdate(internalObject);
		}

		public void Remove(string itemName)
		{
			internalObject.Remove(internalObject.Where((T t) => itemName == Utilities.GetProperName(t.Name)).FirstOrDefault());
			onUpdate(internalObject);
		}

		public void RemoveAll(T item)
		{
			internalObject.RemoveAll((T i) => i == item);
			onUpdate(internalObject);
		}

		public void RemoveAll(string itemName)
		{
			internalObject.Where((T t) => itemName == Utilities.GetProperName(t.Name)).ForEach(delegate(T t)
			{
				internalObject.Remove(t);
			});
			onUpdate(internalObject);
		}

		public void Clear()
		{
			internalObject = new List<T>();
			onUpdate(internalObject);
		}

		private List<T> ListGet()
		{
			return (from T item in internalObject
				select (item)).ToList();
		}

		private void ListSet(List<T> list)
		{
			internalObject.Clear();
			foreach (T item in list)
			{
				internalObject.Add(item);
			}
			onUpdate(internalObject);
		}

		public WrapperDelineation(Action<List<T>> onUpdate, Func<string, T> query)
		{
			this.onUpdate = onUpdate;
			this.query = query;
		}
	}
}
namespace ModdingForDummies.AssetManagement
{
	public static class AssetImporter
	{
		public static List<GameObject> Models { get; private set; } = new List<GameObject>();


		public static List<Sprite> Sprites { get; private set; } = new List<Sprite>();


		private static int[] GenerateRange(int floor, int ceiling)
		{
			List<int> list = new List<int>();
			for (int i = floor; i < ceiling; i++)
			{
				list.Add(i);
			}
			return list.ToArray();
		}

		public static string GetAttr(this XmlNode self, string name)
		{
			return (from XmlAttribute attr in self.Attributes
				where attr.Name == name
				select attr.Value).ToArray()[0];
		}

		public static float[] GetFloats(string floats)
		{
			string[] source = floats.Split(new char[1] { ' ' });
			return (from string number in source
				select float.Parse(number, CultureInfo.InvariantCulture)).ToArray();
		}

		public static int[] GetInts(string ints)
		{
			string[] source = ints.Split(new char[1] { ' ' });
			return (from string number in source
				select int.Parse(number, CultureInfo.InvariantCulture)).ToArray();
		}

		public static Color GetColor(string floats)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			float[] array = (from float flt in GetFloats(floats)
				select Mathf.Pow(flt, 2.2f)).ToArray();
			return new Color(array[0], array[1], array[2], array[3]);
		}

		public static Vector3[] GetVector3(string floats)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			float[] floats2 = GetFloats(floats);
			Vector3[] array = (Vector3[])(object)new Vector3[floats2.Length / 3];
			for (int i = 0; i < floats2.Length / 3; i++)
			{
				array[i] = new Vector3(floats2[3 * i], floats2[3 * i + 1], floats2[3 * i + 2]);
			}
			return array;
		}

		public static Vector2[] GetVector2(string floats)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			float[] floats2 = GetFloats(floats);
			Vector2[] array = (Vector2[])(object)new Vector2[floats2.Length / 2];
			for (int i = 0; i < floats2.Length / 2; i++)
			{
				array[i] = new Vector2(floats2[2 * i], floats2[2 * i + 1]);
			}
			return array;
		}

		public static SpriteAsset ImportSprite(string filePath)
		{
			byte[] data = File.ReadAllBytes(filePath);
			string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath);
			return new SpriteAsset(fileNameWithoutExtension, data);
		}

		public static ModelAsset ImportModel(string filePath)
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0430: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
			XmlDocument xmlDocument = new XmlDocument();
			xmlDocument.Load(filePath);
			XmlNode documentElement = xmlDocument.DocumentElement;
			XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(xmlDocument.NameTable);
			xmlNamespaceManager.AddNamespace("c", documentElement.GetAttr("xmlns"));
			Dictionary<string, Color> dictionary = new Dictionary<string, Color>();
			XmlNodeList xmlNodeList = documentElement.SelectNodes("//c:library_effects/c:effect", xmlNamespaceManager);
			foreach (XmlNode item in xmlNodeList)
			{
				string key = item.GetAttr("id").Split(new char[1] { '-' })[0];
				string innerText = item.SelectNodes("c:profile_COMMON/c:technique/c:lambert/c:diffuse/c:color", xmlNamespaceManager).Item(0).InnerText;
				Color color = GetColor(innerText);
				dictionary[key] = color;
			}
			XmlNodeList xmlNodeList2 = documentElement.SelectNodes("//c:library_geometries/c:geometry", xmlNamespaceManager);
			XmlNode xmlNode2 = xmlNodeList2.Item(0);
			string text = xmlNode2.GetAttr("name").Replace('.', '_');
			string innerText2 = xmlNode2.SelectSingleNode("c:mesh/c:source[@id='" + text + "-mesh-positions']/c:float_array", xmlNamespaceManager).InnerText;
			string innerText3 = xmlNode2.SelectSingleNode("c:mesh/c:source[@id='" + text + "-mesh-normals']/c:float_array", xmlNamespaceManager).InnerText;
			string innerText4 = xmlNode2.SelectSingleNode("c:mesh/c:source[@id='" + text + "-mesh-map-0']/c:float_array", xmlNamespaceManager).InnerText;
			Vector3[] vector = GetVector3(innerText2);
			Vector3[] vector2 = GetVector3(innerText3);
			Vector2[] vector3 = GetVector2(innerText4);
			XmlNodeList xmlNodeList3 = xmlNode2.SelectNodes("c:mesh/c:triangles", xmlNamespaceManager);
			Dictionary<string, int[]> dictionary2 = new Dictionary<string, int[]>();
			foreach (XmlNode item2 in xmlNodeList3)
			{
				string key2 = item2.GetAttr("material").Split(new char[1] { '-' })[0];
				string innerText5 = item2.SelectSingleNode("c:p", xmlNamespaceManager).InnerText;
				int[] ints = GetInts(innerText5);
				dictionary2[key2] = ints;
			}
			IEnumerable<int> enumerable = Array.Empty<int>();
			foreach (int[] value in dictionary2.Values)
			{
				enumerable = enumerable.Concat(value);
			}
			int[] array = enumerable.ToArray();
			int[] array2 = new int[array.Length / 3];
			int[] array3 = new int[array.Length / 3];
			int[] array4 = new int[array.Length / 3];
			for (int j = 0; j < array.Length / 3; j++)
			{
				array2[j] = array[j * 3];
				array3[j] = array[j * 3 + 1];
				array4[j] = array[j * 3 + 2];
			}
			int[][] nvtBuffer = new int[array2.Length][];
			List<int[]> list = new List<int[]>();
			for (int k = 0; k < array2.Length; k++)
			{
				nvtBuffer[k] = new int[3]
				{
					array2[k],
					array3[k],
					array4[k]
				};
			}
			int i;
			for (i = 0; i < nvtBuffer.Length; i++)
			{
				if (!list.Exists((int[] el) => el == nvtBuffer[i]))
				{
					list.Add(nvtBuffer[i]);
				}
			}
			int[][] array5 = list.ToArray();
			Vector3[] array6 = (Vector3[])(object)new Vector3[array5.Length];
			Vector3[] array7 = (Vector3[])(object)new Vector3[array5.Length];
			Vector2[] array8 = (Vector2[])(object)new Vector2[array5.Length];
			for (int l = 0; l < array5.Length; l++)
			{
				array6[l] = vector[array5[l][0]];
				array7[l] = vector2[array5[l][1]];
				array8[l] = vector3[array5[l][2]];
			}
			ModelAsset modelAsset = new ModelAsset();
			modelAsset.name = Path.GetFileNameWithoutExtension(filePath);
			modelAsset.vertices = array6;
			modelAsset.normals = array7;
			modelAsset.textures = array8;
			modelAsset.submeshes = new int[dictionary2.Count][];
			modelAsset.materials = (Color[])(object)new Color[dictionary2.Count];
			int num = 0;
			int num2 = 0;
			foreach (string key3 in dictionary2.Keys)
			{
				int num3 = dictionary2[key3].Length / 3;
				modelAsset.submeshes[num] = GenerateRange(num2, num2 + num3);
				num2 += num3;
				modelAsset.materials[num] = dictionary[key3];
				num++;
			}
			return modelAsset;
		}

		public static void Initialize()
		{
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Expected O, but got Unknown
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Expected O, but got Unknown
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Expected O, but got Unknown
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Expected O, but got Unknown
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			string text = Path.Combine(Utilities.rootPath, "Assets");
			if (!Directory.Exists(text))
			{
				return;
			}
			if (Mod.DEV_MODE)
			{
				ModAssetBundle modAssetBundle = new ModAssetBundle();
				string path = Path.Combine(text, "Sprites");
				if (Directory.Exists(path))
				{
					string[] files = Directory.GetFiles(path);
					List<SpriteAsset> list = new List<SpriteAsset>();
					string[] array = files;
					foreach (string text2 in array)
					{
						if (text2.EndsWith(".png"))
						{
							list.Add(ImportSprite(text2));
						}
					}
					modAssetBundle.sprites = list.ToArray();
				}
				string path2 = Path.Combine(text, "Models");
				if (Directory.Exists(path2))
				{
					string[] files2 = Directory.GetFiles(path2);
					List<ModelAsset> list2 = new List<ModelAsset>();
					string[] array2 = files2;
					foreach (string text3 in array2)
					{
						if (text3.EndsWith(".dae"))
						{
							list2.Add(ImportModel(text3));
						}
					}
					modAssetBundle.models = list2.ToArray();
				}
				byte[] bytes = SerializationUtility.SerializeValue<ModAssetBundle>(modAssetBundle, (DataFormat)0, (SerializationContext)null);
				File.WriteAllBytes(Path.Combine(text, "assets.bin"), bytes);
			}
			string path3 = Path.Combine(text, "assets.bin");
			if (!File.Exists(path3))
			{
				return;
			}
			byte[] array3 = File.ReadAllBytes(path3);
			ModAssetBundle modAssetBundle2 = SerializationUtility.DeserializeValue<ModAssetBundle>(array3, (DataFormat)0, (DeserializationContext)null);