using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 HarmonyLib;
using Landfall.TABS;
using Landfall.TABS.AI.Components.Modifiers;
using Landfall.TABS.AI.Systems;
using Landfall.TABS.GameState;
using SLMA;
using Unity.Entities;
using UnityEngine;
using UnityEngine.Events;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Mod name")]
[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.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
public class Item : MonoBehaviour
{
public enum kind
{
Weapon,
Cloth,
Skill,
Unit,
Projectile,
Other
}
public string name;
public kind Kind;
}
namespace TABS_KingMod;
public class A
{
public static Sprite CreateSpriteFromEmbeddedResource(string resourceName)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
if (stream == null)
{
throw new ArgumentException("Embedded resource '" + resourceName + "' not found.", "resourceName");
}
Texture2D val = new Texture2D(4, 4);
byte[] array = new byte[stream.Length];
stream.Read(array, 0, (int)stream.Length);
((Texture)val).filterMode = (FilterMode)0;
ImageConversion.LoadImage(val, array);
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
}
}
public class harmonyPatch
{
[HarmonyPatch(typeof(HealthHandler))]
[HarmonyPatch("Die", new Type[] { typeof(Unit) })]
public static class HealthHandler_Die_Patch_Unit
{
private static bool Prefix(HealthHandler __instance, Unit damager)
{
Unit value = Traverse.Create((object)__instance).Field("unit").GetValue<Unit>();
if ((Object)(object)value != (Object)null && (Object)(object)value.unitBlueprint != (Object)null && value.unitBlueprint.Entity.Name == "king")
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(HealthHandler))]
[HarmonyPatch("Die", new Type[] { typeof(bool) })]
public static class HealthHandler_Die_Patch_Bool
{
private static bool Prefix(HealthHandler __instance, bool wasKilledRemotely)
{
Unit value = Traverse.Create((object)__instance).Field("unit").GetValue<Unit>();
if ((Object)(object)value != (Object)null && (Object)(object)value.unitBlueprint != (Object)null && value.unitBlueprint.Entity.Name == "king")
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(HealthHandler))]
[HarmonyPatch("SetInvulnerable")]
public static class HealthHandler_SetInvulnerable_Patch
{
private static void Postfix(HealthHandler __instance, bool invulnerable)
{
Unit value = Traverse.Create((object)__instance).Field("unit").GetValue<Unit>();
if ((Object)(object)value != (Object)null && (Object)(object)value.unitBlueprint != (Object)null && value.unitBlueprint.Entity.Name == "king")
{
__instance.SetInvulnerable(true);
}
}
}
[HarmonyPatch(typeof(HealthHandler))]
[HarmonyPatch("TakeDamage", new Type[]
{
typeof(float),
typeof(Vector3),
typeof(Unit),
typeof(DamageType)
})]
public static class HealthHandler_TakeDamage_Patch
{
private static bool Prefix(HealthHandler __instance, Unit damager, ref float damage)
{
object obj;
if (damager == null)
{
obj = null;
}
else
{
UnitBlueprint unitBlueprint = damager.unitBlueprint;
obj = ((unitBlueprint != null) ? unitBlueprint.Entity.Name : null);
}
if ((string?)obj == "king")
{
__instance.Die(damager);
DataHandler value = Traverse.Create((object)__instance).Field("data").GetValue<DataHandler>();
if ((Object)(object)value == (Object)null)
{
return false;
}
if (!value.Dead)
{
ForceDie(__instance, damager);
}
return false;
}
return true;
}
private static void ForceDie(HealthHandler instance, Unit damager)
{
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: Unknown result type (might be due to invalid IL or missing references)
//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
Traverse val = Traverse.Create((object)instance);
DataHandler value = val.Field("data").GetValue<DataHandler>();
if ((Object)(object)value == (Object)null || value.Dead)
{
return;
}
val.Field("DieAction").GetValue<Action>()?.Invoke();
UnityEvent value2 = val.Field("deathEvent").GetValue<UnityEvent>();
if (value2 != null)
{
value2.Invoke();
}
val.Field("UnitDied").GetValue<Action<Unit>>()?.Invoke(val.Field("unit").GetValue<Unit>());
Traverse val2 = val.Method("CheckDeathAchievements", new Type[1] { typeof(Unit) }, (object[])null);
val2.GetValue(new object[1] { damager });
value.Dead = true;
Unit unit = value.unit;
unit.dead = true;
UnitSounds value3 = val.Field("sounds").GetValue<UnitSounds>();
if ((Object)(object)value3 != (Object)null)
{
Vector3 val3 = (((Object)(object)value.mainRig != (Object)null) ? value.mainRig.position : Vector3.zero);
value3.PlayDeathSound(0.5f, val3);
}
HoldingHandler component = ((Component)instance).GetComponent<HoldingHandler>();
if ((Object)(object)component != (Object)null)
{
component.LetGoOfAll();
}
if (!val.Field("willBeRewived").GetValue<bool>())
{
GroundChecker[] componentsInChildren = ((Component)instance).GetComponentsInChildren<GroundChecker>();
GroundChecker[] array = componentsInChildren;
foreach (GroundChecker val4 in array)
{
Object.Destroy((Object)(object)val4);
}
RigidbodyHolder component2 = ((Component)instance).GetComponent<RigidbodyHolder>();
if ((Object)(object)component2 != (Object)null)
{
Rigidbody[] allRigs = component2.AllRigs;
Rigidbody[] array2 = allRigs;
foreach (Rigidbody val5 in array2)
{
if ((Object)(object)val5 != (Object)null)
{
((Component)val5).gameObject.layer = 9;
}
}
}
}
if (!(Random.value > 0.995f))
{
return;
}
Rigidbody mainRig = value.mainRig;
if (!((Object)(object)mainRig != (Object)null))
{
return;
}
Collider[] value4 = val.Field("colliders").GetValue<Collider[]>();
int num = Physics.OverlapSphereNonAlloc(mainRig.position, Random.Range(1f, 2f), value4);
for (int k = 0; k < num; k++)
{
GeneralInput componentInParent = ((Component)value4[k]).GetComponentInParent<GeneralInput>();
if ((Object)(object)componentInParent != (Object)null)
{
Unit componentInParent2 = ((Component)componentInParent).GetComponentInParent<Unit>();
if ((Object)(object)componentInParent2 != (Object)null && componentInParent2.Team == ((Component)((Component)instance).transform.root).GetComponent<Unit>().Team)
{
componentInParent.shift = true;
break;
}
}
}
}
}
[HarmonyPatch(typeof(HealthHandler))]
[HarmonyPatch("TakeDamage", new Type[]
{
typeof(float),
typeof(Vector3),
typeof(Unit),
typeof(DamageType)
})]
public static class HealthHandler_TakeDamage_Patch2
{
private static bool Prefix(HealthHandler __instance, Unit damager, ref float damage)
{
Unit value = Traverse.Create((object)__instance).Field("unit").GetValue<Unit>();
if ((Object)(object)value != (Object)null && (Object)(object)value.unitBlueprint != (Object)null && value.unitBlueprint.Entity.Name == "king")
{
return false;
}
return true;
}
}
public static Harmony harmony;
public DataHandler godDataHandler;
public harmonyPatch()
{
Awake();
Start();
}
public void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
harmony = new Harmony("com.TABS_Mod.com");
}
public void Start()
{
harmony.PatchAll();
Debug.Log((object)"补丁已全部运行");
}
}
public class Kill : GameStateListener
{
private Unit unit1;
private TeamSystem m_teamSystem;
private bool OnBattle;
public override void OnEnterBattleState()
{
OnBattle = true;
}
public override void OnEnterPlacementState()
{
}
public void Start()
{
Unit componentInParent = ((Component)this).GetComponentInParent<Unit>();
unit1 = componentInParent;
m_teamSystem = World.Active.GetOrCreateManager<TeamSystem>();
}
public void Update()
{
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Invalid comparison between Unknown and I4
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Invalid comparison between Unknown and I4
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: 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_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
if (OnBattle)
{
List<Unit> list = (((int)unit1.Team == 1) ? m_teamSystem.GetTeamUnits((Team)0) : m_teamSystem.GetTeamUnits((Team)1));
if (list.Count != 0)
{
list.Sort((Unit x, Unit y) => Vector3.Distance(unit1.data.mainRig.position, x.data.mainRig.position).CompareTo(Vector3.Distance(unit1.data.mainRig.position, y.data.mainRig.position)));
Unit val = list[0];
Vector3 position = val.data.mainRig.position;
for (int i = 0; i < unit1.data.allRigs.AllRigs.Length; i++)
{
unit1.data.allRigs.AllRigs[i].position = position;
}
val.data.healthHandler.Die(unit1);
val.dead = true;
val.data.health = 0f;
val.data.Dead = true;
}
return;
}
List<Unit> list2 = (((int)unit1.Team == 1) ? m_teamSystem.GetTeamUnits((Team)0) : m_teamSystem.GetTeamUnits((Team)1));
if (list2.Count != 0)
{
list2.Sort((Unit x, Unit y) => Vector3.Distance(unit1.data.mainRig.position, x.data.mainRig.position).CompareTo(Vector3.Distance(unit1.data.mainRig.position, y.data.mainRig.position)));
Unit val2 = list2[0];
Vector3 position2 = val2.data.mainRig.position;
for (int j = 0; j < unit1.data.allRigs.AllRigs.Length; j++)
{
unit1.data.allRigs.AllRigs[j].position = position2;
}
}
}
}
[BepInPlugin("TABS_KingMod", "TABS_KingMod", "1.0")]
public class ModCore : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <call>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public ModCore <>4__this;
private LandfallContentDatabase <landfallContentDatabase>5__1;
private UnitBlueprint[] <array>5__2;
private int <i>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <call>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<landfallContentDatabase>5__1 = null;
<array>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Expected O, but got Unknown
//IL_00ef: 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_005e: Expected O, but got Unknown
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>2__current = (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<ISaveLoaderService>() != null));
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
<>2__current = (object)new WaitForSecondsRealtime(0.3f);
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
SLMALoader.GetInstance();
<landfallContentDatabase>5__1 = ContentDatabase.Instance().LandfallContentDatabase;
UnitManager.Init(<landfallContentDatabase>5__1);
new Harmony(UnitManager.modname).PatchAll();
GOSLMA.EditWeapons = ((GOSLMA.EditWeapons == null) ? new Action<GameObject, Team, Unit, MeleeWeapon, RangeWeapon, LandfallContentDatabase>(UnitManager.EditWeapons) : ((Action<GameObject, Team, Unit, MeleeWeapon, RangeWeapon, LandfallContentDatabase>)Delegate.Combine(new Action<GameObject, Team, Unit, MeleeWeapon, RangeWeapon, LandfallContentDatabase>(UnitManager.EditWeapons), GOSLMA.EditWeapons)));
GOSLMA.EditClothes = ((GOSLMA.EditClothes == null) ? new Action<GameObject, CharacterItem, PropItemData, Unit, int, LandfallContentDatabase>(UnitManager.EditClothes) : ((Action<GameObject, CharacterItem, PropItemData, Unit, int, LandfallContentDatabase>)Delegate.Combine(new Action<GameObject, CharacterItem, PropItemData, Unit, int, LandfallContentDatabase>(UnitManager.EditClothes), GOSLMA.EditClothes)));
GOSLMA.EditCombatMoves = ((GOSLMA.EditCombatMoves == null) ? new Action<GameObject, int, Unit, LandfallContentDatabase>(UnitManager.EditCombatMoves) : ((Action<GameObject, int, Unit, LandfallContentDatabase>)Delegate.Combine(new Action<GameObject, int, Unit, LandfallContentDatabase>(UnitManager.EditCombatMoves), GOSLMA.EditCombatMoves)));
GOSLMA.CodeAfterSpawn = ((GOSLMA.CodeAfterSpawn == null) ? new Action<Unit, LandfallContentDatabase>(UnitManager.CodeAfterSpawn) : ((Action<Unit, LandfallContentDatabase>)Delegate.Combine(new Action<Unit, LandfallContentDatabase>(UnitManager.CodeAfterSpawn), GOSLMA.CodeAfterSpawn)));
GOSLMA.EditProjectiles = ((GOSLMA.EditProjectiles == null) ? new Action<GameObject, ProjectileHit, Unit, LandfallContentDatabase>(UnitManager.EditProjectiles) : ((Action<GameObject, ProjectileHit, Unit, LandfallContentDatabase>)Delegate.Combine(new Action<GameObject, ProjectileHit, Unit, LandfallContentDatabase>(UnitManager.EditProjectiles), GOSLMA.EditProjectiles)));
<array>5__2 = Resources.FindObjectsOfTypeAll<UnitBlueprint>();
<i>5__3 = 0;
while (<i>5__3 < <array>5__2.Length)
{
UnitManager.EditBlueprint(<array>5__2[<i>5__3], <landfallContentDatabase>5__1);
<i>5__3++;
}
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 void Awake()
{
((MonoBehaviour)this).StartCoroutine("call");
}
[IteratorStateMachine(typeof(<call>d__1))]
private IEnumerator call()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <call>d__1(0)
{
<>4__this = this
};
}
}
public class TABS_KingModItems : MonoBehaviour
{
private static Dictionary<string, Item> items;
private static TABS_KingModItems instance { get; set; }
public static TABS_KingModItems GetInstance()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)instance == (Object)null)
{
instance = new GameObject("TABS_KingModItems").AddComponent<TABS_KingModItems>();
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 static class UnitManager
{
public static string modname = "TABS_KingMod";
public static string modder = "Buchiyu";
private static string com;
public static void SetRiders(UnitBlueprint me, UnitBlueprint[] riders)
{
s.SetField<UnitBlueprint>(me, "Riders", (object)riders);
}
public static void EditBlueprint(UnitBlueprint unit, LandfallContentDatabase db)
{
}
public static void EditClothes(GameObject cloth, CharacterItem item, PropItemData data, Unit unit, int index, LandfallContentDatabase db)
{
}
public static void EditProjectiles(GameObject proj, ProjectileHit projhit, Unit unit, LandfallContentDatabase db)
{
}
public static void EditCombatMoves(GameObject move, int index, Unit unit, LandfallContentDatabase db)
{
}
public static void CodeAfterSpawn(Unit unit, LandfallContentDatabase db)
{
}
public static void Init(LandfallContentDatabase db)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Expected O, but got Unknown
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Expected O, but got Unknown
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Expected O, but got Unknown
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Expected O, but got Unknown
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0304: 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_006c: 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_0158: Unknown result type (might be due to invalid IL or missing references)
TABS_KingModItems.GetInstance();
int num = 64;
int num2 = 7;
float num3 = (float)num2 / 2f;
float num4 = (float)(num - 1) / 2f;
Texture2D val = new Texture2D(num, num, (TextureFormat)4, false);
for (int i = 0; i < num; i++)
{
for (int j = 0; j < num; j++)
{
float num5 = Mathf.Abs((float)j - num4);
float num6 = Mathf.Abs((float)i - num4);
if (num5 <= num3 || num6 <= num3)
{
val.SetPixel(j, i, Color.white);
}
else
{
val.SetPixel(j, i, Color.clear);
}
}
}
val.Apply();
Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f));
int num7 = 64;
int num8 = 7;
float num9 = (float)num8 / 2f;
float num10 = (float)(num7 - 1) / 2f;
Texture2D val3 = new Texture2D(num7, num7, (TextureFormat)4, false);
for (int k = 0; k < num7; k++)
{
for (int l = 0; l < num7; l++)
{
float num11 = Mathf.Abs((float)l - num10);
float num12 = Mathf.Abs((float)k - num10);
if (num11 <= num9 || num12 <= num9)
{
val3.SetPixel(l, k, Color.black);
}
else
{
val3.SetPixel(l, k, Color.clear);
}
}
}
val3.Apply();
Sprite val4 = Sprite.Create(val3, new Rect(0f, 0f, (float)num7, (float)num7), new Vector2(0.5f, 0.5f));
Faction val5 = SLMATool.CreateFaction("King", (UnitBlueprint[])null, val4, 6666);
UnitBlueprint val6 = SLMATool.CreateUnit("king", (UnitBlueprint)null, val5, val2);
UPool.MyPool.AddObject("Model", (GameObject)SLMALoader.SDic["bases"]["Humanoid"], true, (HideFlags)52, (Sprite)null, 99, true);
GameObject val7 = (GameObject)SLMALoader.SDic["weapons"]["Gauntlet"];
val7.AddComponent<Kill>();
val6.health = 8000f;
val6.RightWeapon = val7;
val6.LeftWeapon = (GameObject)SLMALoader.SDic["weapons"]["Gauntlet"];
val6.holdinigWithTwoHands = false;
val6.damageMultiplier = 1E+14f;
val6.healthMultiplier = 1f;
val6.minSizeRandom = 1f;
val6.maxSizeRandom = 1f;
val6.sizeMultiplier = 1f;
val6.movementSpeedMuiltiplier = 7.5f;
val6.attackSpeedMultiplier = 999f;
val6.MovementComponents = new List<IMovementComponent> { (IMovementComponent)(object)default(KeepPreferredDistance) };
val6.objectsToSpawnAsChildren = (GameObject[])(object)new GameObject[0];
SLMATool.UnitCost(val6, 9999999);
}
public static void EditWeapons(GameObject weapon, Team team, Unit unit, MeleeWeapon melee, RangeWeapon range, LandfallContentDatabase db)
{
}
}