Decompiled source of MeaninglessUnit v0.0.1

MeaninglessUnit.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using DM;
using FhpSLib.BundleModCore;
using HarmonyLib;
using Landfall.TABS;
using Landfall.TABS.AI.Systems;
using Landfall.TABS.GameMode;
using Landfall.TABS.GameState;
using Landfall.TABS.WinConditions;
using SLMA;
using Unity.Entities;
using UnityEngine;
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("Custom")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("made in SFT by FhpSlime")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3a45c3cf-230c-4310-952f-0887d4266a22")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace mys
{
	public static class UManager
	{
		public static string modname;

		public static string modder;

		private static string com;

		public static SLMABundleMod bundleMod;

		public static SLMABundleMod bundleMod1;

		static UManager()
		{
			modname = "SFT";
			modder = "FhpSlime";
		}

		public static void SetRiders(UnitBlueprint me, UnitBlueprint[] riders)
		{
			s.SetField<UnitBlueprint>(me, "Riders", (object)riders);
		}

		public static void EditBlueprint(UnitBlueprint unit, LandfallContentDatabase db)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			if (unit.Entity.Name == "Meaningless")
			{
				UPool.MyPool.AddObject("222", (GameObject)SLMALoader.SDic["bases"]["Humanoid"], true, (HideFlags)52, (Sprite)null, 0, false).AddComponent<NAN2>();
				unit.UnitBase = UPool.MyPool.GetObject("222");
				unit.health = 1f;
				unit.RightWeapon = null;
				SLMATool.UnitCost(unit, -1);
				unit.LeftWeapon = null;
				unit.m_props = (GameObject[])(object)new GameObject[0];
			}
			if (unit.Entity.Name == "Meaningless2")
			{
				GameObject obj = UPool.MyPool.AddObject("2222", (GameObject)SLMALoader.SDic["bases"]["Humanoid"], true, (HideFlags)52, (Sprite)null, 0, false);
				obj.AddComponent<NAN3>();
				obj.AddComponent<NAN1>();
				obj.AddComponent<NAN4>();
				unit.UnitBase = UPool.MyPool.GetObject("2222");
				unit.health = 1f;
				unit.RightWeapon = null;
				SLMATool.UnitCost(unit, -1);
				unit.LeftWeapon = null;
				unit.m_props = (GameObject[])(object)new GameObject[0];
			}
		}

		public static void EditClothes(GameObject cloth, CharacterItem item, PropItemData data, Unit unit, int index, LandfallContentDatabase db)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			Debug.Log((object)"Hey");
			if (unit.unitBlueprint.Entity.Name == "unit name")
			{
				Renderer[] componentsInChildren = cloth.GetComponentsInChildren<Renderer>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].materials = (Material[])(object)new Material[1] { (Material)SLMALoader.SDic["materials"]["Glow_Neon_Green_143734"] };
				}
			}
		}

		public static void EditProjectiles(GameObject proj, ProjectileHit projhit, Unit unit, LandfallContentDatabase db)
		{
		}

		public static void EditCombatMoves(GameObject move, int index, Unit unit, LandfallContentDatabase db)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_0070: 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)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Expected O, but got Unknown
			//IL_01f7: 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_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Expected O, but got Unknown
			if (unit.unitBlueprint.Entity.Name == "666" && Object.op_Implicit((Object)(object)move.GetComponentInChildren<DodgeMove>()) && index == 2)
			{
				move.GetComponentInChildren<DodgeMove>().moves[0].forceCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[5]
				{
					new Keyframe(0f, 0f),
					new Keyframe(1f, 1f),
					new Keyframe(2f, 1f),
					new Keyframe(0f, 0f),
					new Keyframe(0f, 0f)
				});
				move.GetComponentInChildren<DodgeMove>().forceMultiplier = -1f;
			}
			if (unit.unitBlueprint.Entity.Name == "666" && Object.op_Implicit((Object)(object)move.GetComponentInChildren<DodgeMove>()) && index == 3)
			{
				move.GetComponentInChildren<DodgeMove>().moves[0].forceCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[5]
				{
					new Keyframe(-1f, 1f),
					new Keyframe(1f, 1f),
					new Keyframe(5f, 4f),
					new Keyframe(0f, 0f),
					new Keyframe(0f, 0f)
				});
				move.GetComponentInChildren<DodgeMove>().forceMultiplier = -2f;
			}
			if (unit.unitBlueprint.Entity.Name == "666" && Object.op_Implicit((Object)(object)move.GetComponentInChildren<DodgeMove>()) && index == 4)
			{
				move.GetComponentInChildren<DodgeMove>().moves[0].forceCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[5]
				{
					new Keyframe(-1f, 1f),
					new Keyframe(1f, 1f),
					new Keyframe(5f, 4f),
					new Keyframe(0f, 0f),
					new Keyframe(0f, 0f)
				});
			}
		}

		public static void CodeAfterSpawn(Unit unit, LandfallContentDatabase db)
		{
			//IL_0028: 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)
			if (unit.unitBlueprint.Entity.Name == "unit name")
			{
				Transform head = unit.data.head;
				head.localScale *= 2f;
			}
		}

		public static void Init(LandfallContentDatabase db)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0061: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_00a9: Expected O, but got Unknown
			com = "Bundle Mod Init";
			com = "Bundle Mod Init";
			MyModItems.GetInstance();
			SLMATool.CreateUnit("Meaningless", (UnitBlueprint)SLMALoader.SDic["blueprints"]["UNIT_TRIBAL_THROWER_SPEAR"], (Faction)SLMALoader.SDic["factions"]["Secret"], (Sprite)null);
			SLMATool.CreateUnit("Meaningless2", (UnitBlueprint)SLMALoader.SDic["blueprints"]["UNIT_TRIBAL_THROWER_SPEAR"], (Faction)SLMALoader.SDic["factions"]["Secret"], (Sprite)null);
			com = "——————————Fations and Units——————————";
			com = "——————————Clothes——————————";
			com = "——————————Weapons——————————";
			com = "——————————Effects——————————";
			com = "——————————Explosions——————————";
			com = "——————————UnitBases——————————";
			com = "——————————Projectiles——————————";
			com = "——————————Moves——————————";
		}

		public static void EditWeapons(GameObject weapon, Team team, Unit unit, MeleeWeapon melee, RangeWeapon range, LandfallContentDatabase db)
		{
		}

		public static void SetMoveConditionalValue(this ConditionalEventInstance gameObject, ConditionType type, ValueType valuet, float value)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			bool flag = false;
			EventCondition[] conditions = gameObject.conditions;
			foreach (EventCondition val in conditions)
			{
				if (val.conditionType == type)
				{
					val.valueType = valuet;
					val.value = value;
					flag = true;
				}
			}
			if (!flag)
			{
				List<EventCondition> list = gameObject.conditions.ToList();
				list.Add(new EventCondition
				{
					conditionType = type,
					valueType = valuet,
					value = value
				});
				gameObject.conditions = list.ToArray();
			}
		}
	}
	[BepInPlugin("MLS", "MLS", "1.0.0")]
	internal class Loader : BaseUnityPlugin
	{
		public static bool BundleMode;

		private void Awake()
		{
			((MonoBehaviour)this).StartCoroutine("call");
		}

		private IEnumerator call()
		{
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
			yield return (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<ISaveLoaderService>() != null));
			yield return (object)new WaitForSecondsRealtime(0.3f);
			SLMALoader.GetInstance();
			LandfallContentDatabase landfallContentDatabase = ContentDatabase.Instance().LandfallContentDatabase;
			UManager.Init(landfallContentDatabase);
			new Harmony(UManager.modname).PatchAll();
			GOSLMA.EditWeapons = ((GOSLMA.EditWeapons == null) ? new Action<GameObject, Team, Unit, MeleeWeapon, RangeWeapon, LandfallContentDatabase>(UManager.EditWeapons) : ((Action<GameObject, Team, Unit, MeleeWeapon, RangeWeapon, LandfallContentDatabase>)Delegate.Combine(new Action<GameObject, Team, Unit, MeleeWeapon, RangeWeapon, LandfallContentDatabase>(UManager.EditWeapons), GOSLMA.EditWeapons)));
			GOSLMA.EditClothes = ((GOSLMA.EditClothes == null) ? new Action<GameObject, CharacterItem, PropItemData, Unit, int, LandfallContentDatabase>(UManager.EditClothes) : ((Action<GameObject, CharacterItem, PropItemData, Unit, int, LandfallContentDatabase>)Delegate.Combine(new Action<GameObject, CharacterItem, PropItemData, Unit, int, LandfallContentDatabase>(UManager.EditClothes), GOSLMA.EditClothes)));
			GOSLMA.EditCombatMoves = ((GOSLMA.EditCombatMoves == null) ? new Action<GameObject, int, Unit, LandfallContentDatabase>(UManager.EditCombatMoves) : ((Action<GameObject, int, Unit, LandfallContentDatabase>)Delegate.Combine(new Action<GameObject, int, Unit, LandfallContentDatabase>(UManager.EditCombatMoves), GOSLMA.EditCombatMoves)));
			GOSLMA.CodeAfterSpawn = ((GOSLMA.CodeAfterSpawn == null) ? new Action<Unit, LandfallContentDatabase>(UManager.CodeAfterSpawn) : ((Action<Unit, LandfallContentDatabase>)Delegate.Combine(new Action<Unit, LandfallContentDatabase>(UManager.CodeAfterSpawn), GOSLMA.CodeAfterSpawn)));
			GOSLMA.EditProjectiles = ((GOSLMA.EditProjectiles == null) ? new Action<GameObject, ProjectileHit, Unit, LandfallContentDatabase>(UManager.EditProjectiles) : ((Action<GameObject, ProjectileHit, Unit, LandfallContentDatabase>)Delegate.Combine(new Action<GameObject, ProjectileHit, Unit, LandfallContentDatabase>(UManager.EditProjectiles), GOSLMA.EditProjectiles)));
			UnitBlueprint[] array = Resources.FindObjectsOfTypeAll<UnitBlueprint>();
			for (int i = 0; i < array.Length; i++)
			{
				UManager.EditBlueprint(array[i], landfallContentDatabase);
			}
			Debug.Log((object)("Loaded " + UManager.modname + " Successfully"));
			Debug.Log((object)(UManager.modname + "is made in SFT by FhpSlime"));
			Debug.Log((object)(UManager.modder + "wished you a pleasant trip"));
		}

		static Loader()
		{
			BundleMode = true;
		}
	}
}
public class Item : MonoBehaviour
{
	public enum kind
	{
		Weapon,
		Cloth,
		Skill,
		Unit,
		Projectile,
		Other
	}

	public string name;

	public kind Kind;
}
namespace mys
{
	public class MyModItems : MonoBehaviour
	{
		private static Dictionary<string, Item> items;

		private static MyModItems instance { get; set; }

		public static MyModItems GetInstance()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)instance == (Object)null)
			{
				instance = new GameObject("MyModItems").AddComponent<MyModItems>();
				Object.DontDestroyOnLoad((Object)(object)instance);
			}
			return instance;
		}

		public void AddItem(Item item)
		{
			items.Add(item.name, item);
		}

		public Item GetItem(string name)
		{
			Item value = new Item
			{
				name = null,
				Kind = Item.kind.Other
			};
			items.TryGetValue(name, out value);
			return value;
		}
	}
}
public class Example : MonoBehaviour
{
	public GameObject prefab;

	private void Start()
	{
		if ((Object)(object)prefab != (Object)null)
		{
			Transform[] componentsInChildren = prefab.GetComponentsInChildren<Transform>();
			if (componentsInChildren.Length > 1)
			{
				_ = componentsInChildren[1];
			}
		}
	}
}
namespace mys
{
	public class NAN2 : MonoBehaviour
	{
		private Unit unit;

		private bool hasTriggered;

		private void Start()
		{
			unit = ((Component)this).GetComponent<Unit>();
			((MonoBehaviour)this).StartCoroutine(TriggerVictoryAfterDelay());
		}

		private IEnumerator TriggerVictoryAfterDelay()
		{
			yield return null;
			if (!hasTriggered)
			{
				TriggerVictory();
			}
		}

		private void TriggerVictory()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (!hasTriggered)
			{
				hasTriggered = true;
				GameModeService service = ServiceLocator.GetService<GameModeService>();
				if (!((Object)service == (Object)null) && service.CurrentGameMode != null)
				{
					BaseGameMode currentGameMode = service.CurrentGameMode;
					ClearOpposingTeamUnits(currentGameMode);
					ForceDestroyAllOpposingUnits();
					EnterBattleState();
					Team team = unit.Team;
					string text = "A meaningless victory";
					currentGameMode.DecideWinner(team, text);
				}
			}
		}

		private void ClearOpposingTeamUnits(BaseGameMode gameMode)
		{
			//IL_0006: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			Team val = (Team)(((int)unit.Team == 0) ? 1 : 0);
			Unit[] array = World.Active.GetExistingManager<TeamSystem>().GetTeamUnits(val).ToArray();
			int num = 0;
			Unit[] array2 = array;
			foreach (Unit val2 in array2)
			{
				if ((Object)val2 != (Object)null && (Object)((Component)val2).gameObject != (Object)null)
				{
					if (gameMode.Brush != null)
					{
						gameMode.Brush.RemoveUnitInternal(val2, val2.Team);
					}
					if ((Object)val2 != (Object)null && (Object)((Component)val2).gameObject != (Object)null)
					{
						ForceDestroyUnit(val2, val);
					}
					num++;
				}
			}
		}

		private void EnterBattleState()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			GameStateManager service = ServiceLocator.GetService<GameStateManager>();
			if (service != null && (int)service.GameState == 0)
			{
				service.EnterBattleState();
			}
		}

		private void ForceDestroyUnit(Unit unitToDestroy, Team team)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected O, but got Unknown
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			TeamSystem existingManager = World.Active.GetExistingManager<TeamSystem>();
			if (existingManager != null)
			{
				GameObjectEntity component = ((Component)unitToDestroy).GetComponent<GameObjectEntity>();
				if ((Object)(object)component != (Object)null)
				{
					existingManager.RemoveEntity(component.Entity, team, unitToDestroy);
				}
			}
			GameModeService service = ServiceLocator.GetService<GameModeService>();
			if ((Object)(object)service != (Object)null && service.CurrentGameMode != null && unitToDestroy.RuntimeReference != null)
			{
				service.CurrentGameMode.TeamLayouts.RemoveUnitFromLayout(team, (RuntimeReference)(object)unitToDestroy.RuntimeReference);
			}
			if ((Object)(object)service != (Object)null && service.CurrentGameMode != null)
			{
				service.CurrentGameMode.OnUnitRemoved(unitToDestroy, team);
			}
			if (unitToDestroy.spawnedObjects != null)
			{
				for (int num = unitToDestroy.spawnedObjects.Length - 1; num >= 0; num--)
				{
					if ((Object)unitToDestroy.spawnedObjects[num] != (Object)null)
					{
						Object.Destroy((Object)unitToDestroy.spawnedObjects[num]);
					}
				}
			}
			RiderHolder component2 = ((Component)unitToDestroy).GetComponent<RiderHolder>();
			if ((Object)(object)component2 != (Object)null)
			{
				for (int i = 0; i < component2.riders.Count; i++)
				{
					Unit component3 = component2.riders[i].GetComponent<Unit>();
					if ((Object)(object)component3 != (Object)null && service != null)
					{
						BaseGameMode currentGameMode = service.CurrentGameMode;
						if (currentGameMode != null)
						{
							currentGameMode.OnUnitRemoved(component3, team);
						}
					}
				}
			}
			if ((Object)((Component)unitToDestroy).gameObject != (Object)null)
			{
				Object.Destroy((Object)((Component)unitToDestroy).gameObject);
			}
		}

		private void ForceDestroyAllOpposingUnits()
		{
			//IL_0006: 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_0021: 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: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			Team val = (Team)(((int)unit.Team == 0) ? 1 : 0);
			TeamSystem existingManager = World.Active.GetExistingManager<TeamSystem>();
			Unit[] array;
			if (existingManager != null)
			{
				array = existingManager.GetTeamUnits(val).ToArray();
				foreach (Unit val2 in array)
				{
					if ((Object)val2 != (Object)null && (Object)((Component)val2).gameObject != (Object)null)
					{
						ForceDestroyUnit(val2, val);
					}
				}
			}
			array = Object.FindObjectsOfType<Unit>();
			foreach (Unit val3 in array)
			{
				if ((Object)val3 != (Object)null && (Object)((Component)val3).gameObject != (Object)null && val3.Team == val)
				{
					ForceDestroyUnit(val3, val);
				}
			}
			ForceDestroyAllUnitChildren();
		}

		private void ForceDestroyAllUnitChildren()
		{
			//IL_0006: 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_0017: 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: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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)
			Team val = (Team)(((int)unit.Team == 0) ? 1 : 0);
			Scene activeScene = SceneManager.GetActiveScene();
			GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects();
			for (int i = 0; i < rootGameObjects.Length; i++)
			{
				Unit[] componentsInChildren = rootGameObjects[i].GetComponentsInChildren<Unit>(true);
				foreach (Unit val2 in componentsInChildren)
				{
					if ((Object)val2 != (Object)null && (Object)((Component)val2).gameObject != (Object)null && val2.Team == val)
					{
						ForceDestroyUnit(val2, val);
					}
				}
			}
		}
	}
	public class NAN3 : MonoBehaviour
	{
		private HealthHandler healthHandler;

		private DataHandler dataHandler;

		private Unit unit;

		[Header("删除设置")]
		[Tooltip("是否完全删除HealthHandler组件")]
		public bool completelyRemoveHealthHandler = true;

		[Tooltip("是否禁用HealthHandler的Update方法")]
		public bool disableHealthHandlerUpdate = true;

		[Tooltip("是否禁用HealthHandler的TakeDamage方法")]
		public bool disableHealthHandlerTakeDamage = true;

		[Tooltip("是否禁用HealthHandler的Die方法")]
		public bool disableHealthHandlerDie = true;

		[Header("调试信息")]
		[SerializeField]
		public bool showDebugInfo = true;

		[Tooltip("是否清除DataHandler中的healthHandler引用")]
		public bool clearDataHandlerReference = true;

		private void Start()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			healthHandler = ((Component)this).GetComponentInChildren<HealthHandler>();
			dataHandler = ((Component)this).GetComponentInChildren<DataHandler>();
			unit = ((Component)this).GetComponentInChildren<Unit>();
			if ((Object)healthHandler == (Object)null)
			{
				Debug.LogWarning((object)"HealthHandlerRemover: 未找到HealthHandler组件");
				return;
			}
			if ((Object)dataHandler == (Object)null)
			{
				Debug.LogWarning((object)"HealthHandlerRemover: 未找到DataHandler组件");
				return;
			}
			if ((Object)unit == (Object)null)
			{
				Debug.LogWarning((object)"HealthHandlerRemover: 未找到Unit组件");
				return;
			}
			RemoveHealthHandlerFunctionality();
			if (showDebugInfo)
			{
				Debug.Log((object)("HealthHandlerRemover: 单位 " + ((Object)unit).name + " 的HealthHandler功能已被删除"));
			}
		}

		private void RemoveHealthHandlerFunctionality()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			if ((Object)healthHandler == (Object)null)
			{
				return;
			}
			if (clearDataHandlerReference)
			{
				ClearDataHandlerHealthHandlerReference();
			}
			if (completelyRemoveHealthHandler)
			{
				Object.Destroy((Object)healthHandler);
				healthHandler = null;
				if (showDebugInfo)
				{
					Debug.Log((object)("HealthHandlerRemover: 完全删除了单位 " + ((Object)unit).name + " 的HealthHandler组件"));
				}
			}
			else
			{
				((Behaviour)healthHandler).enabled = false;
				if (showDebugInfo)
				{
					Debug.Log((object)("HealthHandlerRemover: 禁用了单位 " + ((Object)unit).name + " 的HealthHandler组件"));
				}
			}
			if ((Object)dataHandler != (Object)null)
			{
				dataHandler.health = Mathf.Max(dataHandler.health, 1f);
				dataHandler.maxHealth = Mathf.Max(dataHandler.maxHealth, 1f);
				dataHandler.Dead = false;
			}
		}

		public void RemoveHealthHandlerCompletely()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			if ((Object)healthHandler != (Object)null)
			{
				Object.Destroy((Object)healthHandler);
				healthHandler = null;
				if (showDebugInfo)
				{
					Unit val = unit;
					Debug.Log((object)("HealthHandlerRemover: 完全删除了单位 " + (((Object)val != (Object)null) ? ((Object)val).name : null) + " 的HealthHandler组件"));
				}
			}
		}

		public void DisableHealthHandler()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			if ((Object)healthHandler != (Object)null)
			{
				((Behaviour)healthHandler).enabled = false;
				if (showDebugInfo)
				{
					Unit val = unit;
					Debug.Log((object)("HealthHandlerRemover: 禁用了单位 " + (((Object)val != (Object)null) ? ((Object)val).name : null) + " 的HealthHandler组件"));
				}
			}
		}

		public void EnableHealthHandler()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			if ((Object)healthHandler != (Object)null)
			{
				((Behaviour)healthHandler).enabled = true;
				if (showDebugInfo)
				{
					Unit val = unit;
					Debug.Log((object)("HealthHandlerRemover: 启用了单位 " + (((Object)val != (Object)null) ? ((Object)val).name : null) + " 的HealthHandler组件"));
				}
			}
		}

		public void SetHealth(float health)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			if ((Object)dataHandler != (Object)null)
			{
				dataHandler.health = Mathf.Max(health, 1f);
				dataHandler.maxHealth = Mathf.Max(dataHandler.maxHealth, health);
			}
		}

		public float GetHealth()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			DataHandler val = dataHandler;
			if ((Object)val == (Object)null)
			{
				return 0f;
			}
			return val.health;
		}

		public float GetMaxHealth()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			DataHandler val = dataHandler;
			if ((Object)val == (Object)null)
			{
				return 0f;
			}
			return val.maxHealth;
		}

		public bool IsHealthHandlerRemoved()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			if (!((Object)healthHandler == (Object)null))
			{
				return !((Behaviour)healthHandler).enabled;
			}
			return true;
		}

		private void OnDestroy()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			if (showDebugInfo)
			{
				Unit val = unit;
				Debug.Log((object)("HealthHandlerRemover: 组件已销毁,单位 " + (((Object)val != (Object)null) ? ((Object)val).name : null) + " 的HealthHandler处理已删除"));
			}
		}

		private void ClearDataHandlerHealthHandlerReference()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			if (!((Object)dataHandler != (Object)null))
			{
				return;
			}
			FieldInfo field = typeof(DataHandler).GetField("healthHandler", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				field.SetValue(dataHandler, null);
				if (showDebugInfo)
				{
					Debug.Log((object)("HealthHandlerRemover: 清除了单位 " + ((Object)unit).name + " 的DataHandler中healthHandler引用"));
				}
			}
			else
			{
				Debug.LogWarning((object)"HealthHandlerRemover: 无法找到DataHandler中的healthHandler字段");
			}
		}
	}
}
public class NAN1 : MonoBehaviour
{
	private void Update()
	{
		if (Object.op_Implicit((Object)(object)((Component)this).GetComponentInChildren<UnitEffectBase>()))
		{
			UnitEffectBase[] componentsInChildren = ((Component)this).GetComponentsInChildren<UnitEffectBase>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.Destroy((Object)(object)((Component)componentsInChildren[i]).gameObject);
			}
		}
	}
}
namespace mys
{
	public class NAN4 : MonoBehaviour
	{
		[Header("无实体状态设置")]
		[Tooltip("是否在启动时立即进入无实体状态")]
		public bool enablePhantomOnStart = true;

		[Tooltip("是否包含武器在无实体状态中")]
		public bool includeWeapons = true;

		[Tooltip("是否在死亡时自动退出无实体状态")]
		public bool disablePhantomOnDeath = true;

		[Tooltip("是否在组件销毁时恢复原始层")]
		public bool restoreLayersOnDestroy = true;

		[Header("调试信息")]
		[SerializeField]
		public bool showDebugInfo = true;

		private RigidbodyHolder rigidbodyHolder;

		private WeaponHandler weaponHandler;

		private DataHandler data;

		private HealthHandler healthHandler;

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

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

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

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

		private bool isPhantomState;

		private const int MAP_LAYER = 8;

		private const int PHANTOM_LAYER = 20;

		public bool IsPhantomStateActive => isPhantomState;

		public int RigidbodyCount => allRigidbodies.Count;

		public int ColliderCount => allColliders.Count;

		private void Start()
		{
			rigidbodyHolder = ((Component)((Component)this).transform.root).GetComponentInChildren<RigidbodyHolder>();
			weaponHandler = ((Component)((Component)this).transform.root).GetComponentInChildren<WeaponHandler>();
			data = ((Component)((Component)this).transform.root).GetComponentInChildren<DataHandler>();
			healthHandler = ((Component)((Component)this).transform.root).GetComponentInChildren<HealthHandler>();
			if ((Object)(object)rigidbodyHolder == (Object)null)
			{
				Debug.LogError((object)"PhantomStateComponent: 无法找到RigidbodyHolder组件!", (Object)(object)this);
				return;
			}
			if ((Object)(object)data == (Object)null)
			{
				Debug.LogError((object)"PhantomStateComponent: 无法找到DataHandler组件!", (Object)(object)this);
				return;
			}
			CollectAllRigidbodiesAndColliders();
			if (enablePhantomOnStart)
			{
				EnablePhantomState();
			}
			if ((Object)(object)healthHandler != (Object)null && disablePhantomOnDeath)
			{
				healthHandler.UnitDied += OnUnitDied;
			}
			if (showDebugInfo)
			{
				Debug.Log((object)$"PhantomStateComponent: 初始化完成,收集到 {allRigidbodies.Count} 个Rigidbody和 {allColliders.Count} 个Collider", (Object)(object)this);
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)healthHandler != (Object)null)
			{
				healthHandler.UnitDied -= OnUnitDied;
			}
			if (restoreLayersOnDestroy && isPhantomState)
			{
				RestoreOriginalLayers();
			}
		}

		private void CollectAllRigidbodiesAndColliders()
		{
			allRigidbodies.Clear();
			originalRigidbodyLayers.Clear();
			allColliders.Clear();
			originalColliderLayers.Clear();
			if ((Object)(object)rigidbodyHolder != (Object)null && rigidbodyHolder.AllRigs != null)
			{
				Rigidbody[] allRigs = rigidbodyHolder.AllRigs;
				foreach (Rigidbody val in allRigs)
				{
					if ((Object)(object)val != (Object)null)
					{
						allRigidbodies.Add(val);
						originalRigidbodyLayers.Add(((Component)val).gameObject.layer);
					}
				}
			}
			if (includeWeapons && (Object)(object)weaponHandler != (Object)null)
			{
				if ((Object)(object)weaponHandler.rightWeapon != (Object)null && (Object)(object)weaponHandler.rightWeapon.rigidbody != (Object)null)
				{
					allRigidbodies.Add(weaponHandler.rightWeapon.rigidbody);
					originalRigidbodyLayers.Add(((Component)weaponHandler.rightWeapon.rigidbody).gameObject.layer);
				}
				if ((Object)(object)weaponHandler.leftWeapon != (Object)null && (Object)(object)weaponHandler.leftWeapon.rigidbody != (Object)null)
				{
					allRigidbodies.Add(weaponHandler.leftWeapon.rigidbody);
					originalRigidbodyLayers.Add(((Component)weaponHandler.leftWeapon.rigidbody).gameObject.layer);
				}
			}
			if (!((Object)(object)data != (Object)null))
			{
				return;
			}
			Collider[] componentsInChildren = ((Component)((Component)data).transform).GetComponentsInChildren<Collider>();
			foreach (Collider val2 in componentsInChildren)
			{
				if ((Object)(object)val2 != (Object)null)
				{
					allColliders.Add(val2);
					originalColliderLayers.Add(((Component)val2).gameObject.layer);
				}
			}
		}

		public void EnablePhantomState()
		{
			if (isPhantomState)
			{
				if (showDebugInfo)
				{
					Debug.Log((object)"PhantomStateComponent: 已经处于无实体状态", (Object)(object)this);
				}
				return;
			}
			for (int i = 0; i < allRigidbodies.Count; i++)
			{
				if ((Object)(object)allRigidbodies[i] != (Object)null)
				{
					((Component)allRigidbodies[i]).gameObject.layer = 20;
				}
			}
			for (int j = 0; j < allColliders.Count; j++)
			{
				if ((Object)(object)allColliders[j] != (Object)null)
				{
					((Component)allColliders[j]).gameObject.layer = 20;
				}
			}
			isPhantomState = true;
			if (showDebugInfo)
			{
				Debug.Log((object)$"PhantomStateComponent: 已启用无实体状态,设置了 {allRigidbodies.Count} 个Rigidbody和 {allColliders.Count} 个Collider", (Object)(object)this);
			}
		}

		public void DisablePhantomState()
		{
			if (!isPhantomState)
			{
				if (showDebugInfo)
				{
					Debug.Log((object)"PhantomStateComponent: 已经退出无实体状态", (Object)(object)this);
				}
				return;
			}
			RestoreOriginalLayers();
			isPhantomState = false;
			if (showDebugInfo)
			{
				Debug.Log((object)"PhantomStateComponent: 已禁用无实体状态", (Object)(object)this);
			}
		}

		private void RestoreOriginalLayers()
		{
			for (int i = 0; i < allRigidbodies.Count && i < originalRigidbodyLayers.Count; i++)
			{
				if ((Object)(object)allRigidbodies[i] != (Object)null)
				{
					((Component)allRigidbodies[i]).gameObject.layer = originalRigidbodyLayers[i];
				}
			}
			for (int j = 0; j < allColliders.Count && j < originalColliderLayers.Count; j++)
			{
				if ((Object)(object)allColliders[j] != (Object)null)
				{
					((Component)allColliders[j]).gameObject.layer = originalColliderLayers[j];
				}
			}
			if (showDebugInfo)
			{
				Debug.Log((object)"PhantomStateComponent: 已恢复原始层", (Object)(object)this);
			}
		}

		private void OnUnitDied(Unit unit)
		{
			if (disablePhantomOnDeath && isPhantomState)
			{
				DisablePhantomState();
			}
		}

		public void TogglePhantomState()
		{
			if (isPhantomState)
			{
				DisablePhantomState();
			}
			else
			{
				EnablePhantomState();
			}
		}

		public bool IsPhantomState()
		{
			return isPhantomState;
		}

		public void RefreshReferences()
		{
			CollectAllRigidbodiesAndColliders();
			if (showDebugInfo)
			{
				Debug.Log((object)$"PhantomStateComponent: 已刷新引用,当前有 {allRigidbodies.Count} 个Rigidbody和 {allColliders.Count} 个Collider", (Object)(object)this);
			}
		}
	}
}