Decompiled source of Holiday v2.1.0

Holiday.dll

Decompiled a week ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using Holiday.Properties;
using Landfall.TABS;
using Landfall.TABS.GameMode;
using Landfall.TABS.UnitEditor;
using Landfall.TABS.Workshop;
using TFBGames;
using TGCore;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Holiday")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Holiday")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("102b0c94-4c5a-4cb4-8215-24bce01cc4e8")]
[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 Holiday
{
	public class BreakIntoUnits : MonoBehaviour
	{
		private Unit OwnUnit;

		private bool Done;

		public UnitBlueprint topUnit;

		public UnitBlueprint middleUnit;

		public UnitBlueprint bottomUnit;

		public Rigidbody topPart;

		public Rigidbody middlePart;

		public Rigidbody bottomPart;

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

		public void BreakIntoParts()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			if (OwnUnit.data.healthHandler.willBeRewived && !Done)
			{
				GameObject[] array = topUnit.Spawn(topPart.position, topPart.rotation, OwnUnit.Team, 1f, (UnitPoolInfo?)null);
				GameObject[] array2 = middleUnit.Spawn(middlePart.position, middlePart.rotation, OwnUnit.Team, 1f, (UnitPoolInfo?)null);
				GameObject[] array3 = bottomUnit.Spawn(bottomPart.position, bottomPart.rotation, OwnUnit.Team, 1f, (UnitPoolInfo?)null);
				OwnUnit.data.healthHandler.willBeRewived = false;
				OwnUnit.data.hasBeenRevived = true;
				Done = true;
			}
		}
	}
	public class CookieCrumble : ProjectileSurfaceEffect
	{
		public enum CookieState
		{
			Default,
			Crumbled,
			Pushing,
			Crushing
		}

		[CompilerGenerated]
		private sealed class <DoCookieMovement>d__7 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public Vector3 pointToLerpTo;

			public GameObject objectToSpawn;

			public AnimationCurve curve;

			public float endDelay;

			public bool pointUp;

			public CookieCrumble <>4__this;

			private GameObject <spawnedCookie>5__1;

			private Vector3 <startPos>5__2;

			private Quaternion <startRot>5__3;

			private float <t>5__4;

			private float <endTime>5__5;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DoCookieMovement>d__7(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<spawnedCookie>5__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_014c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0152: Unknown result type (might be due to invalid IL or missing references)
				//IL_0168: Unknown result type (might be due to invalid IL or missing references)
				//IL_017f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0247: Unknown result type (might be due to invalid IL or missing references)
				//IL_0251: Expected O, but got Unknown
				//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_018d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0193: Unknown result type (might be due to invalid IL or missing references)
				//IL_0198: Unknown result type (might be due to invalid IL or missing references)
				//IL_019d: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (!Object.op_Implicit((Object)(object)<>4__this.ownUnit) || !Object.op_Implicit((Object)(object)<>4__this.ownUnit.data) || !Object.op_Implicit((Object)(object)<>4__this.ownUnit.data.targetMainRig) || !Object.op_Implicit((Object)(object)objectToSpawn))
					{
						return false;
					}
					<spawnedCookie>5__1 = Object.Instantiate<GameObject>(objectToSpawn, ((Component)<>4__this).transform.TransformPoint(<>4__this.modelOffset), ((Component)<>4__this).transform.rotation, ((Component)<>4__this.ownUnit).transform);
					<startPos>5__2 = <spawnedCookie>5__1.transform.position;
					<startRot>5__3 = <spawnedCookie>5__1.transform.rotation;
					<t>5__4 = 0f;
					<endTime>5__5 = ((Keyframe)(ref curve.keys[curve.keys.Length - 1])).time;
					goto IL_01f4;
				case 1:
					<>1__state = -1;
					goto IL_01f4;
				case 2:
					{
						<>1__state = -1;
						<>4__this.ChangeState();
						return false;
					}
					IL_01f4:
					if (<t>5__4 < <endTime>5__5 && Object.op_Implicit((Object)(object)<spawnedCookie>5__1) && Object.op_Implicit((Object)(object)<>4__this.ownUnit) && Object.op_Implicit((Object)(object)<>4__this.ownUnit.data))
					{
						<spawnedCookie>5__1.transform.position = Vector3.Lerp(<startPos>5__2, pointToLerpTo, curve.Evaluate(<t>5__4));
						<spawnedCookie>5__1.transform.rotation = Quaternion.Lerp(<startRot>5__3, pointUp ? Quaternion.LookRotation(Vector3.up) : Quaternion.LookRotation(pointToLerpTo - <startPos>5__2), curve.Evaluate(<t>5__4));
						<t>5__4 += Time.deltaTime;
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					<>2__current = (object)new WaitForSeconds(endDelay);
					<>1__state = 2;
					return true;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <DoCrumble>d__4 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public CookieCrumble <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DoCrumble>d__4(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					Object.Instantiate<GameObject>(<>4__this.crumbleObject, ((Component)<>4__this).transform.TransformPoint(<>4__this.modelOffset), ((Component)<>4__this).transform.rotation);
					<>2__current = (object)new WaitForSeconds(<>4__this.crumbleTime);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.health = <>4__this.maxHealth;
					<>4__this.ChangeState();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private Unit ownUnit;

		public CookieState currentState;

		public Vector3 modelOffset;

		public List<ConditionalEvent> movesToStun = new List<ConditionalEvent>();

		[Header("Default Settings")]
		public UnityEvent defaultEvent = new UnityEvent();

		[Header("Crumble Settings")]
		public UnityEvent crumbleEvent = new UnityEvent();

		public GameObject crumbleObject;

		public float crumbleTime;

		public float maxHealth = 500f;

		private float health;

		[Header("Push Settings")]
		public UnityEvent pushEvent = new UnityEvent();

		public GameObject pushObject;

		public AnimationCurve pushCurve;

		public float pushOffset = 5f;

		public float pushEndDelay;

		[Header("Crush Settings")]
		public UnityEvent crushEvent = new UnityEvent();

		public GameObject crushObject;

		public AnimationCurve crushCurve;

		public float crushOffset = 5f;

		public float crushEndDelay;

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

		public override bool DoEffect(HitData hit, GameObject projectile)
		{
			if (!Object.op_Implicit((Object)(object)ownUnit) || !Object.op_Implicit((Object)(object)ownUnit.data) || !Object.op_Implicit((Object)(object)ownUnit.data.targetMainRig) || currentState != 0)
			{
				return false;
			}
			if (Object.op_Implicit((Object)(object)projectile.GetComponent<ProjectileHit>()))
			{
				health -= projectile.GetComponent<ProjectileHit>().damage;
			}
			if (Object.op_Implicit((Object)(object)projectile.GetComponent<CollisionWeapon>()))
			{
				health -= projectile.GetComponent<CollisionWeapon>().damage;
			}
			if (health <= 0f)
			{
				health = 0f;
				Crumble();
			}
			return true;
		}

		public void ChangeState(CookieState state = CookieState.Default)
		{
			currentState = state;
			switch (state)
			{
			case CookieState.Default:
				defaultEvent.Invoke();
				break;
			case CookieState.Crumbled:
				crumbleEvent.Invoke();
				{
					foreach (ConditionalEvent item in movesToStun)
					{
						item.StunAllOfMyMovesFor(crumbleTime + 1f);
					}
					break;
				}
			case CookieState.Pushing:
				pushEvent.Invoke();
				{
					foreach (ConditionalEvent item2 in movesToStun)
					{
						item2.StunAllOfMyMovesFor(pushEndDelay + 2f);
					}
					break;
				}
			case CookieState.Crushing:
				crushEvent.Invoke();
				{
					foreach (ConditionalEvent item3 in movesToStun)
					{
						item3.StunAllOfMyMovesFor(crushEndDelay + 2f);
					}
					break;
				}
			default:
				defaultEvent.Invoke();
				break;
			}
		}

		public void Crumble()
		{
			if (Object.op_Implicit((Object)(object)ownUnit) && Object.op_Implicit((Object)(object)ownUnit.data) && Object.op_Implicit((Object)(object)ownUnit.data.targetMainRig) && currentState == CookieState.Default)
			{
				ChangeState(CookieState.Crumbled);
				((MonoBehaviour)this).StartCoroutine(DoCrumble());
			}
		}

		[IteratorStateMachine(typeof(<DoCrumble>d__4))]
		private IEnumerator DoCrumble()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DoCrumble>d__4(0)
			{
				<>4__this = this
			};
		}

		public void Crush()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)ownUnit) && Object.op_Implicit((Object)(object)ownUnit.data) && Object.op_Implicit((Object)(object)ownUnit.data.targetMainRig) && currentState == CookieState.Default)
			{
				ChangeState(CookieState.Crushing);
				((MonoBehaviour)this).StartCoroutine(DoCookieMovement(((Component)ownUnit.data.targetMainRig).transform.position + Vector3.up * crushOffset, crushObject, crushCurve, crushEndDelay, pointUp: true));
			}
		}

		public void Push()
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)ownUnit) && Object.op_Implicit((Object)(object)ownUnit.data) && Object.op_Implicit((Object)(object)ownUnit.data.targetMainRig) && currentState == CookieState.Default)
			{
				ChangeState(CookieState.Pushing);
				Vector3 position = ownUnit.data.mainRig.position;
				Vector3 forwardGroundNormal = ownUnit.data.forwardGroundNormal;
				float y = ownUnit.data.targetMainRig.position.y;
				((MonoBehaviour)this).StartCoroutine(DoCookieMovement(new Vector3(position.x, y, position.z) + new Vector3(forwardGroundNormal.x, 0f, forwardGroundNormal.z) * pushOffset, pushObject, pushCurve, pushEndDelay));
			}
		}

		[IteratorStateMachine(typeof(<DoCookieMovement>d__7))]
		private IEnumerator DoCookieMovement(Vector3 pointToLerpTo, GameObject objectToSpawn, AnimationCurve curve, float endDelay, bool pointUp = false)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DoCookieMovement>d__7(0)
			{
				<>4__this = this,
				pointToLerpTo = pointToLerpTo,
				objectToSpawn = objectToSpawn,
				curve = curve,
				endDelay = endDelay,
				pointUp = pointUp
			};
		}
	}
	public class BoulderBehavior : MonoBehaviour
	{
		public class HitByBoulder : MonoBehaviour
		{
		}

		private Rigidbody rig;

		private TeamHolder teamHolder;

		private List<FixedJoint> jointList = new List<FixedJoint>();

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

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

		private bool disabled;

		public float damage = 200f;

		public float breakForce = 30000f;

		private void Start()
		{
			rig = ((Component)this).GetComponent<Rigidbody>();
			teamHolder = ((Component)this).GetComponent<TeamHolder>();
		}

		public void OnCollisionEnter(Collision col)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			Unit component = ((Component)col.transform.root).GetComponent<Unit>();
			if (!disabled && Object.op_Implicit((Object)(object)col.rigidbody) && Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)teamHolder) && component.Team != teamHolder.team)
			{
				if (!Object.op_Implicit((Object)(object)((Component)component).GetComponent<HitByBoulder>()))
				{
					((Damagable)component.data.healthHandler).TakeDamage(damage, Vector3.zero, (Unit)null, (DamageType)0);
					((Component)component).gameObject.AddComponent<HitByBoulder>();
					hitList.Add(component);
				}
				if (!Object.op_Implicit((Object)(object)col.gameObject.GetComponent<HitByBoulder>()) && col.rigidbody.mass * 10f < rig.mass)
				{
					FixedJoint val = col.gameObject.AddComponent<FixedJoint>();
					((Joint)val).connectedBody = rig;
					((Joint)val).breakForce = breakForce;
					((Joint)val).breakTorque = breakForce;
					jointList.Add(val);
					col.gameObject.AddComponent<HitByBoulder>();
					rigList.Add(col.rigidbody);
				}
			}
		}

		public void DestroyJoints()
		{
			foreach (FixedJoint joint in jointList)
			{
				if (Object.op_Implicit((Object)(object)joint))
				{
					Object.Destroy((Object)(object)joint);
				}
			}
			jointList.Clear();
			foreach (Rigidbody rig in rigList)
			{
				if (Object.op_Implicit((Object)(object)rig) && Object.op_Implicit((Object)(object)((Component)rig).GetComponent<HitByBoulder>()))
				{
					Object.Destroy((Object)(object)((Component)rig).GetComponent<HitByBoulder>());
				}
			}
			rigList.Clear();
			foreach (Unit hit in hitList)
			{
				if (Object.op_Implicit((Object)(object)((Component)hit).GetComponent<HitByBoulder>()))
				{
					Object.Destroy((Object)(object)((Component)hit).GetComponent<HitByBoulder>());
				}
			}
			hitList.Clear();
			disabled = true;
		}
	}
	[BepInPlugin("teamgrad.holiday", "Holiday", "2.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class HolidayLauncher : TGMod
	{
		public HolidayLauncher()
		{
			new HolidayMain();
		}

		public override void SceneManager(Scene scene, LoadSceneMode loadSceneMode)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			if (((Scene)(ref scene)).name == "02_Lvl3_Farmer_Snow_VC")
			{
				GameObject val = new GameObject
				{
					name = "Secrets"
				};
				Object.Instantiate<GameObject>(HolidayMain.holiday.LoadAsset<GameObject>("SmoreKnight_Unlock"), val.transform, true);
				Object.Instantiate<GameObject>(HolidayMain.holiday.LoadAsset<GameObject>("SnowCannon_Unlock"), val.transform, true);
				Object.Instantiate<GameObject>(HolidayMain.holiday.LoadAsset<GameObject>("JollyBot_Unlock"), val.transform, true);
				if (!HolidayMain.HasWesternMap)
				{
					Object.Instantiate<GameObject>(HolidayMain.holiday.LoadAsset<GameObject>("Snowman_Unlock"), val.transform, true);
				}
			}
			if (((Scene)(ref scene)).name == "WesternChristmas")
			{
				GameObject val2 = new GameObject
				{
					name = "Secrets"
				};
				GameObject val3 = Object.Instantiate<GameObject>(HolidayMain.holiday.LoadAsset<GameObject>("Snowman_Unlock"), val2.transform, true);
				val3.transform.position = new Vector3(9.225f, 1.5f, 45.87f);
				val3.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f);
			}
		}
	}
	public class HolidayMain
	{
		public static AssetBundle holiday = AssetBundle.LoadFromMemory(Resources.holiday);

		public static bool HasWesternMap = Chainloader.PluginInfos.ContainsKey("org.bepinex.plugins.WesternHoliday");

		public HolidayMain()
		{
			Material[] array = holiday.LoadAllAssets<Material>();
			foreach (Material val in array)
			{
				if (Object.op_Implicit((Object)(object)Shader.Find(((Object)val.shader).name)))
				{
					val.shader = Shader.Find(((Object)val.shader).name);
				}
			}
			foreach (UnitBlueprint unit2 in from x in holiday.LoadAllAssets<UnitBlueprint>()
				where (Object)(object)x.UnitBase != (Object)null
				select x)
			{
				foreach (GameObject item3 in from unitBase in TGMain.landfallDb.GetUnitBases().ToList()
					where ((Object)unitBase).name == ((Object)unit2.UnitBase).name
					select unitBase)
				{
					unit2.UnitBase = item3;
				}
				foreach (GameObject item4 in TGMain.landfallDb.GetWeapons().ToList())
				{
					if (Object.op_Implicit((Object)(object)unit2.RightWeapon) && ((Object)item4).name == ((Object)unit2.RightWeapon).name)
					{
						unit2.RightWeapon = item4;
					}
					if (Object.op_Implicit((Object)(object)unit2.LeftWeapon) && ((Object)item4).name == ((Object)unit2.LeftWeapon).name)
					{
						unit2.LeftWeapon = item4;
					}
				}
			}
			Faction[] array2 = holiday.LoadAllAssets<Faction>();
			foreach (Faction val2 in array2)
			{
				UnitBlueprint[] source = (from x in val2.Units
					where Object.op_Implicit((Object)(object)x)
					orderby x.GetUnitCost(true)
					select x).ToArray();
				val2.Units = source.ToArray();
				foreach (Faction item5 in TGMain.landfallDb.GetFactions().ToList())
				{
					if (val2.Entity.Name == item5.Entity.Name + "_NEW")
					{
						List<UnitBlueprint> list = new List<UnitBlueprint>(item5.Units);
						list.AddRange(val2.Units);
						item5.Units = (from x in list
							where Object.op_Implicit((Object)(object)x)
							orderby x.GetUnitCost(true)
							select x).ToArray();
						Object.DestroyImmediate((Object)(object)val2);
					}
				}
			}
			TABSCampaignLevelAsset[] array3 = holiday.LoadAllAssets<TABSCampaignLevelAsset>();
			foreach (TABSCampaignLevelAsset lvl in array3)
			{
				Faction val3 = holiday.LoadAllAssets<Faction>().ToList().Find((Faction x) => ((Object)x).name.Contains("Holiday"));
				Faction val4 = TGMain.landfallDb.GetFactions().ToList().Find((Faction x) => ((Object)x).name.Contains("Secret"));
				List<UnitBlueprint> list2 = new List<UnitBlueprint>();
				List<Faction> list3 = new List<Faction>();
				if (((Object)lvl).name.Contains("HolidayLevel"))
				{
					lvl.MapAsset = TGMain.landfallDb.GetMapAssetsOrdered().ToList().Find((MapAsset x) => ((Object)x).name.Contains("Farmer_Snow"));
					list3.AddRange(from x in TGMain.landfallDb.GetFactions().ToList()
						where x.m_displayFaction
						select x);
					list3.Remove(val4);
				}
				else if (((Object)lvl).name.Contains("HolidaySpookyLevel"))
				{
					list3.Add(val3);
					list3.Add(val4);
					list2.AddRange(val3.Units);
					list2.Add(val4.Units.ToList().Find((UnitBlueprint x) => ((Object)x).name.Contains("SnowCannon")));
					list2.Add(val4.Units.ToList().Find((UnitBlueprint x) => ((Object)x).name.Contains("ToyRobot")));
					list2.Add(val4.Units.ToList().Find((UnitBlueprint x) => ((Object)x).name.Contains("SmoreKnight")));
					list2.Add(val4.Units.ToList().Find((UnitBlueprint x) => ((Object)x).name.Contains("Snowman")));
				}
				if (((Object)lvl).name.Contains("MapEquals"))
				{
					MapAsset val5 = TGMain.landfallDb.GetMapAssetsOrdered().ToList().Find((MapAsset x) => ((Object)x).name.Contains(((Object)lvl).name.Split(new string[1] { "MapEquals_" }, StringSplitOptions.RemoveEmptyEntries).Last()));
					if (Object.op_Implicit((Object)(object)val5))
					{
						lvl.MapAsset = val5;
					}
				}
				List<TABSLayoutUnit> list4 = new List<TABSLayoutUnit>();
				list4.AddRange(lvl.BlueUnits);
				list4.AddRange(lvl.RedUnits);
				foreach (TABSLayoutUnit unit in list4)
				{
					if (((Object)unit.m_unitBlueprint).name.Contains("_VANILLA"))
					{
						UnitBlueprint val6 = TGMain.landfallDb.GetUnitBlueprints().ToList().Find((UnitBlueprint x) => ((Object)x).name == ((Object)unit.m_unitBlueprint).name.Replace("_VANILLA", ""));
						if (Object.op_Implicit((Object)(object)val6))
						{
							unit.m_unitBlueprint = val6;
						}
					}
				}
				lvl.AllowedFactions = list3.ToArray();
				lvl.AllowedUnits = list2.ToArray();
			}
			foreach (PropItem item6 in from x in holiday.LoadAllAssets<GameObject>()
				select x.GetComponent<PropItem>())
			{
				if (!Object.op_Implicit((Object)(object)item6))
				{
					continue;
				}
				int num = (from rend in ((Component)item6).GetComponentsInChildren<MeshFilter>()
					where ((Component)rend).gameObject.activeSelf && ((Component)rend).gameObject.activeInHierarchy && rend.mesh.subMeshCount > 0 && Object.op_Implicit((Object)(object)((Component)rend).GetComponent<MeshRenderer>()) && ((Renderer)((Component)rend).GetComponent<MeshRenderer>()).enabled
					select rend).Sum((MeshFilter rend) => rend.mesh.subMeshCount) + (from rend in ((Component)item6).GetComponentsInChildren<SkinnedMeshRenderer>()
					where ((Component)rend).gameObject.activeSelf && rend.sharedMesh.subMeshCount > 0 && ((Renderer)rend).enabled
					select rend).Sum((SkinnedMeshRenderer rend) => rend.sharedMesh.subMeshCount);
				if (num > 0)
				{
					float item = 1f / (float)num;
					List<float> list5 = new List<float>();
					for (int l = 0; l < num - 1; l++)
					{
						list5.Add(item);
					}
					((CharacterItem)item6).SubmeshArea = list5.ToArray();
				}
			}
			foreach (WeaponItem item7 in from x in holiday.LoadAllAssets<GameObject>()
				select x.GetComponent<WeaponItem>())
			{
				if (!Object.op_Implicit((Object)(object)item7))
				{
					continue;
				}
				int num2 = (from rend in ((Component)item7).GetComponentsInChildren<MeshFilter>()
					where ((Component)rend).gameObject.activeSelf && ((Component)rend).gameObject.activeInHierarchy && rend.mesh.subMeshCount > 0 && Object.op_Implicit((Object)(object)((Component)rend).GetComponent<MeshRenderer>()) && ((Renderer)((Component)rend).GetComponent<MeshRenderer>()).enabled
					select rend).Sum((MeshFilter rend) => rend.mesh.subMeshCount) + (from rend in ((Component)item7).GetComponentsInChildren<SkinnedMeshRenderer>()
					where ((Component)rend).gameObject.activeSelf && rend.sharedMesh.subMeshCount > 0 && ((Renderer)rend).enabled
					select rend).Sum((SkinnedMeshRenderer rend) => rend.sharedMesh.subMeshCount);
				if (num2 > 0)
				{
					float item2 = 1f / (float)num2;
					List<float> list6 = new List<float>();
					for (int m = 0; m < num2 - 1; m++)
					{
						list6.Add(item2);
					}
					((CharacterItem)item7).SubmeshArea = list6.ToArray();
				}
			}
			AudioSource[] array4 = holiday.LoadAllAssets<AudioSource>();
			foreach (AudioSource val7 in array4)
			{
				val7.outputAudioMixerGroup = ServiceLocator.GetService<GameModeService>().AudioSettings.AudioMixer.outputAudioMixerGroup;
			}
			TGAddons.AddItems((IEnumerable<UnitBlueprint>)holiday.LoadAllAssets<UnitBlueprint>(), (IEnumerable<Faction>)holiday.LoadAllAssets<Faction>(), (IEnumerable<TABSCampaignAsset>)holiday.LoadAllAssets<TABSCampaignAsset>(), (IEnumerable<TABSCampaignLevelAsset>)holiday.LoadAllAssets<TABSCampaignLevelAsset>(), (IEnumerable<VoiceBundle>)holiday.LoadAllAssets<VoiceBundle>(), (IEnumerable<FactionIcon>)holiday.LoadAllAssets<FactionIcon>(), from x in holiday.LoadAllAssets<GameObject>()
				select x.GetComponent<Unit>(), from x in holiday.LoadAllAssets<GameObject>()
				select x.GetComponent<PropItem>(), from x in holiday.LoadAllAssets<GameObject>()
				select x.GetComponent<SpecialAbility>(), from x in holiday.LoadAllAssets<GameObject>()
				select x.GetComponent<WeaponItem>(), from x in holiday.LoadAllAssets<GameObject>()
				select x.GetComponent<ProjectileEntity>());
			TGMain.newSounds.AddRange(holiday.LoadAllAssets<SoundBank>());
		}
	}
	public class SnowballSpawner : MonoBehaviour
	{
		public GameObject objectToSpawn;

		public bool copyRotation;

		public void DoSpawn()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			Unit component = ((Component)((Component)this).transform.root).GetComponent<Unit>();
			if (Object.op_Implicit((Object)(object)objectToSpawn) && Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.data.targetMainRig))
			{
				GameObject val = Object.Instantiate<GameObject>(objectToSpawn, ((Component)this).transform.position, Quaternion.LookRotation(new Vector3(component.data.targetData.mainRig.position.x - component.data.mainRig.position.x, 0f, component.data.targetData.mainRig.position.z - component.data.mainRig.position.z)));
				if (copyRotation)
				{
					val.GetComponent<CopyRotationOfParent>().target.rotation = ((Component)this).transform.rotation;
				}
				TeamHolder.AddTeamHolder(val, ((Component)this).gameObject);
			}
		}
	}
	public class CopyRotationOfParent : MonoBehaviour
	{
		public Transform target;
	}
}
namespace Holiday.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

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

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

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

		internal Resources()
		{
		}
	}
}