Decompiled source of KorkiaBT v1.0.0

KorkiaBT.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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;
using HarmonyLib;
using Landfall.TABS;
using SLMA;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: 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 KorkiaBT;

[BepInPlugin("Korkia", "KorkiaBT", "1.0.0")]
internal class Loader : BaseUnityPlugin
{
	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.CodeAfterSpawn = ((GOSLMA.CodeAfterSpawn == null) ? new Action<Unit, LandfallContentDatabase>(UManager.CodeAfterSpawn) : ((Action<Unit, LandfallContentDatabase>)Delegate.Combine(new Action<Unit, LandfallContentDatabase>(UManager.CodeAfterSpawn), GOSLMA.CodeAfterSpawn)));
		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"));
		Debug.Log((object)SLMATool.super<UnitBlueprint>("Units")[2]);
	}
}
public class MyModItems : MonoBehaviour
{
	public static bool dupeon = true;

	private static Dictionary<string, Item> items;

	private static MyModItems instance { get; set; }

	public static MyModItems GetInstance()
	{
		//IL_0016: 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 static class UManager
{
	public static GameObject hbar;

	public static string modname = "Korkia's breaking tools";

	public static string modder = "Krokia";

	private static string com;

	public static void EditBlueprint(UnitBlueprint unit, LandfallContentDatabase db)
	{
		if (unit.Entity.Name == "Team breaker")
		{
			unit.health = 1f;
			unit.holdinigWithTwoHands = false;
			SLMATool.UnitCost(unit, 0);
		}
	}

	public static void EditClothes(GameObject cloth, CharacterItem item, PropItemData data, Unit unit, int index, LandfallContentDatabase db)
	{
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Expected O, but got Unknown
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Expected O, but got Unknown
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		Debug.Log((object)"Hey");
		if (!(unit.unitBlueprint.Entity.Name == "Team breaker"))
		{
			return;
		}
		Color color = default(Color);
		for (int i = 0; i <= unit.unitBlueprint.m_props.Length; i++)
		{
			TeamColor[] componentsInChildren = unit.unitBlueprint.m_props[i].GetComponentsInChildren<TeamColor>();
			foreach (TeamColor val in componentsInChildren)
			{
				((Color)(ref color))..ctor(Random.Range(0f, 255f) / 255f, Random.Range(0f, 255f) / 255f, Random.Range(0f, 255f) / 255f);
				val.redMaterial = new Material(val.redMaterial.shader);
				val.blueMaterial = new Material(val.blueMaterial.shader);
				val.redMaterial.color = color;
				val.blueMaterial.color = color;
			}
		}
	}

	public static void CodeAfterSpawn(Unit unit, LandfallContentDatabase db)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Invalid comparison between Unknown and I4
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Invalid comparison between Unknown and I4
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Expected O, but got Unknown
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Expected O, but got Unknown
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Invalid comparison between Unknown and I4
		//IL_029e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Invalid comparison between Unknown and I4
		//IL_028f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
		if (unit.unitBlueprint.Entity.Name == "Team breaker")
		{
			unit.unitBlueprint.UnitBase = UPool.MyPool.GetObject("Custom Unit Base");
			if ((int)unit.Team == 1)
			{
				unit.Team = (Team)0;
			}
			else if ((int)unit.Team == 0)
			{
				unit.Team = (Team)1;
			}
		}
		else if (unit.unitBlueprint.Entity.Name == "Duplicator" && MyModItems.dupeon)
		{
			Object.Instantiate<Unit>(unit);
		}
		if ((Object)(object)unit.unitBlueprint.UnitBase == (Object)(object)UPool.MyPool.GetObject("Custom Unit Base"))
		{
			GameObject @object = UPool.MyPool.GetObject("Custom Unit Base");
			@object.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);
			unit.targetingPriorityMultiplier = 2f;
			TeamColor[] componentsInChildren = @object.GetComponentsInChildren<TeamColor>();
			Color color = default(Color);
			foreach (TeamColor val in componentsInChildren)
			{
				((Color)(ref color))..ctor(Random.Range(0f, 255f) / 255f, Random.Range(0f, 255f) / 255f, Random.Range(0f, 255f) / 255f);
				val.redMaterial = new Material(val.redMaterial.shader);
				val.blueMaterial = new Material(val.blueMaterial.shader);
				val.redMaterial.color = color;
				val.blueMaterial.color = color;
			}
		}
		if (unit.unitBlueprint.Entity.Name == "Duplicator Stop")
		{
			MyModItems.dupeon = false;
		}
		if (unit.unitBlueprint.Entity.Name == "Duplicator Continue")
		{
			MyModItems.dupeon = true;
		}
		if (unit.unitBlueprint.Entity.Name == "Map Destroyer")
		{
			Object.Destroy((Object)(object)GameObject.Find("Map"));
			Object.Destroy((Object)(object)GameObject.Find("Props"));
		}
		hbar = GameObject.Find("Green");
		if ((int)unit.Team == 0)
		{
			((Graphic)hbar.GetComponent<Image>()).color = ((Component)unit).GetComponentsInChildren<TeamColor>()[0].redMaterial.color;
		}
		else if ((int)unit.Team == 1)
		{
			((Graphic)hbar.GetComponent<Image>()).color = ((Component)unit).GetComponentsInChildren<TeamColor>()[0].blueMaterial.color;
		}
		((Object)hbar).name = "gr";
	}

	public static void Init(LandfallContentDatabase db)
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Expected O, but got Unknown
		//IL_007d: Expected O, but got Unknown
		//IL_007d: Expected O, but got Unknown
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Expected O, but got Unknown
		//IL_00d8: Expected O, but got Unknown
		//IL_00d8: Expected O, but got Unknown
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: 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)
		//IL_0133: Expected O, but got Unknown
		//IL_0133: Expected O, but got Unknown
		//IL_0133: Expected O, but got Unknown
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Expected O, but got Unknown
		//IL_018e: Expected O, but got Unknown
		//IL_018e: Expected O, but got Unknown
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Expected O, but got Unknown
		//IL_01e9: Expected O, but got Unknown
		//IL_01e9: Expected O, but got Unknown
		//IL_0235: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Expected O, but got Unknown
		MyModItems.GetInstance();
		com = "——————————Fations and Units——————————";
		SLMATool.CreateFaction("Krokia's breaking faction", (UnitBlueprint[])null, (Sprite)null, 212);
		SLMATool.CreateUnit("Team breaker", (UnitBlueprint)SLMALoader.SDic["blueprints"]["UNIT_LEGACY_PEASANT"], (Faction)SLMATool.SLMADic["Krokia's breaking faction"], (Sprite)SLMALoader.SDic["sprites"]["TwitchModIcon"]);
		SLMATool.CreateUnit("Duplicator", (UnitBlueprint)SLMALoader.SDic["blueprints"]["UNIT_LEGACY_PEASANT"], (Faction)SLMATool.SLMADic["Krokia's breaking faction"], (Sprite)SLMALoader.SDic["sprites"]["TwitchModIcon"]);
		SLMATool.CreateUnit("Duplicator Stop", (UnitBlueprint)SLMALoader.SDic["blueprints"]["UNIT_LEGACY_PEASANT"], (Faction)SLMATool.SLMADic["Krokia's breaking faction"], (Sprite)SLMALoader.SDic["sprites"]["TwitchModIcon"]);
		SLMATool.CreateUnit("Duplicator Continue", (UnitBlueprint)SLMALoader.SDic["blueprints"]["UNIT_LEGACY_PEASANT"], (Faction)SLMATool.SLMADic["Krokia's breaking faction"], (Sprite)SLMALoader.SDic["sprites"]["TwitchModIcon"]);
		SLMATool.CreateUnit("Map Destroyer", (UnitBlueprint)SLMALoader.SDic["blueprints"]["UNIT_LEGACY_PEASANT"], (Faction)SLMATool.SLMADic["Krokia's breaking faction"], (Sprite)SLMALoader.SDic["sprites"]["TwitchModIcon"]);
		com = "——————————Weapons——————————";
		com = "——————————Effects——————————";
		com = "——————————Explosions——————————";
		com = "——————————UnitBases——————————";
		UPool.MyPool.AddObject("Custom Unit Base", (GameObject)SLMALoader.SDic["bases"]["Humanoid"], true, (HideFlags)52, (Sprite)null, 0, false);
		com = "——————————Projectiles——————————";
		com = "——————————Moves——————————";
	}

	public static void EditWeapons(GameObject weapon, Team team, Unit unit, MeleeWeapon melee, RangeWeapon range, LandfallContentDatabase db)
	{
		Debug.Log((object)weapon);
		HelpLibrary.AddMeleeEffect(weapon, (UnitEffectBase[])SLMALoader.SDic["effects"]["E_FireEffect"]);
	}
}