using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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; using HarmonyLib; using Landfall.TABS; using Landfall.TABS.AI.Components.Modifiers; using Landfall.TABS.UnitEditor; using Landfall.TABS.Workshop; using RunicSpells; using RunicSpellsScripts; using RunicSpellsUtilities; using SLMA; using TFBGames; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("RunicSpells")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("GeeztJeez")] [assembly: AssemblyProduct("RunicSpells")] [assembly: AssemblyCopyright("Copyright © Geezt Lifetime")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("7acfaef0-7669-4401-8bff-5a9a02e18c75")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace RunicSpells { public static class UManager { public class InitManager { public static void InitExplosions(Sprite icon) { } public static void InitEffects(Sprite icon) { } public static void InitCustomPrefabs(Sprite icon) { } public static void InitClothings(Sprite icon, string catNm = "Runic Spells", UTISeal.AssetType assetType = UTISeal.AssetType.Prop, TagType archType = (TagType)0) { } public static void InitWeapons(Sprite icon, string catNm = "Runic Spells", UTISeal.AssetType assetType = UTISeal.AssetType.Weapon, TagType archType = (TagType)0) { } public static void InitProjectiles(Sprite icon, string catNm = "Runic Spells", UTISeal.AssetType assetType = UTISeal.AssetType.Projectile, TagType archType = (TagType)0) { //IL_002c: 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_0086: Unknown result type (might be due to invalid IL or missing references) int startId = 632894532; UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("P_InstaBeamblastLaserSingular", UTISeal.Uti.LoBuGaOb("P_InstaBeamblastLaserSingular"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType); UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("P_InstaBeamblastLaserDouble", UTISeal.Uti.LoBuGaOb("P_InstaBeamblastLaserDouble"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType); UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("P_InstaBeamblastLaserTringular", UTISeal.Uti.LoBuGaOb("P_InstaBeamblastLaserTringular"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType); } public static void InitAbilities(Sprite icon, string catNm = "Runic Spells", UTISeal.AssetType assetType = UTISeal.AssetType.Ability, TagType archType = (TagType)0) { } public static void InitUnitBases(Sprite icon, string catNm = "Runic Spells", UTISeal.AssetType assetType = UTISeal.AssetType.UnitBase, TagType archType = (TagType)0) { } } public static string comment; public static void InitAssets(LandfallContentDatabase db) { Sprite icon = UTISeal.Uti.LoBuTex2Sprite("itemicon"); string catNm = "Runic Spells"; comment = "Custom Clothing"; InitManager.InitClothings(icon, catNm, UTISeal.AssetType.Prop, (TagType)0); comment = "Custom Weapons"; InitManager.InitWeapons(icon, catNm, UTISeal.AssetType.Weapon, (TagType)0); comment = "Custom Projectiles"; InitManager.InitProjectiles(icon, catNm, UTISeal.AssetType.Projectile, (TagType)0); comment = "Custom Abilities"; InitManager.InitAbilities(icon, catNm, UTISeal.AssetType.Ability, (TagType)0); comment = "Custom Unit Bases"; InitManager.InitUnitBases(icon, catNm, UTISeal.AssetType.UnitBase, (TagType)0); comment = "Custom Explosions"; InitManager.InitExplosions(icon); comment = "Custom Effects"; InitManager.InitEffects(icon); comment = "Custom Custom Prefabs"; InitManager.InitCustomPrefabs(icon); } public static void SetBlueprints(UnitBlueprint unit, LandfallContentDatabase db) { } public static void SetEffects(GameObject effect) { } public static void SetExplosion(GameObject explosion) { } public static void SetUnits(Unit unit, LandfallContentDatabase db) { } public static void SetWeapon(GameObject weapon, HandType hand, Team team, Unit unit, MeleeWeapon melee, RangeWeapon range, LandfallContentDatabase db) { } public static void SetProjectile(GameObject proj, ProjectileHit projhit, LandfallContentDatabase db) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b6: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Expected O, but got Unknown //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0242: 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_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Expected O, but got Unknown if ((Object)(object)proj == (Object)(object)UPool.MyPool.GetObject("P_InstaBeamblastLaserSingular")) { proj.AddComponent().widthCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[8] { new Keyframe(0f, 0f), new Keyframe(0.25f, 0.75f), new Keyframe(0.5f, 0.18f), new Keyframe(0.7f, 0.55f), new Keyframe(0.85f, 0.23f), new Keyframe(0.94f, 1f), new Keyframe(0.98f, 1f), new Keyframe(1.5f, 0f) }); proj.AddComponent(); } if ((Object)(object)proj == (Object)(object)UPool.MyPool.GetObject("P_InstaBeamblastLaserDouble")) { proj.AddComponent().widthCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[8] { new Keyframe(0f, 0f), new Keyframe(0.25f, 0.75f), new Keyframe(0.5f, 0.18f), new Keyframe(0.7f, 0.55f), new Keyframe(0.85f, 0.23f), new Keyframe(0.94f, 1f), new Keyframe(0.98f, 1f), new Keyframe(1.5f, 0f) }); proj.AddComponent(); } if ((Object)(object)proj == (Object)(object)UPool.MyPool.GetObject("P_InstaBeamblastLaserTringular")) { proj.AddComponent().widthCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[8] { new Keyframe(0f, 0f), new Keyframe(0.25f, 0.75f), new Keyframe(0.5f, 0.18f), new Keyframe(0.7f, 0.55f), new Keyframe(0.85f, 0.23f), new Keyframe(0.94f, 1f), new Keyframe(0.98f, 1f), new Keyframe(1.5f, 0f) }); proj.AddComponent(); } } public static void SetCombatMove(GameObject move, DodgeMove dodge, LandfallContentDatabase db) { } public static void SetClothes(GameObject cloth, CharacterItem ci, Renderer render, MeshRenderer mesh, SkinnedMeshRenderer skinnedMesh, LandfallContentDatabase db) { } public static void SetAllGameObject(GameObject gameObject, LandfallContentDatabase db) { } public static void InitUnitsAndFactions(LandfallContentDatabase db) { } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("GeeztJeez.RunicSpells", "RunicSpells", "1.0.0")] internal class Loader : BaseUnityPlugin { private bool initialized; public static bool enableDebug; public AssetBundle assetBundle; private static string modName; private void ApplyHarmony() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) try { new Harmony(modName).PatchAll(Assembly.GetExecutingAssembly()); Log("Harmony patched successfully!"); } catch (Exception ex) { LogError("Harmony patch failed: " + ex); LogWarning("Please contact Geezt Jeez or try reloading the game for proper installation..."); } } public AssetBundle LoadBundle(string assetBundleName) { Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(assetBundleName); if (manifestResourceStream == null) { return null; } if (!manifestResourceStream.CanRead) { return null; } return AssetBundle.LoadFromStream(manifestResourceStream); } public void LoadMod() { //IL_00d4: 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) SLMALoader.GetInstance(); LandfallContentDatabase landfallContentDatabase = ContentDatabase.Instance().LandfallContentDatabase; UTISeal.bundle = (assetBundle = LoadBundle("runicspellsassetbundle")); UManager.InitAssets(landfallContentDatabase); UManager.InitUnitsAndFactions(landfallContentDatabase); HashSet hashSet = new HashSet(); GameObject[] array = Resources.FindObjectsOfTypeAll(); foreach (GameObject val in array) { if ((Object)(object)val == (Object)null) { continue; } int instanceID = ((Object)val).GetInstanceID(); if (hashSet.Contains(instanceID)) { continue; } hashSet.Add(instanceID); if (Object.op_Implicit((Object)(object)val.GetComponent())) { Log("Currently editing Explosion : " + ((Object)val).name); UManager.SetExplosion(val); } if (Object.op_Implicit((Object)(object)val.GetComponent())) { Log("Currently editing Weapon : " + ((Object)val).name); UManager.SetWeapon(val, val.GetComponent(), val.GetComponent(), val.GetComponent(), val.GetComponent(), val.GetComponent(), landfallContentDatabase); if (Object.op_Implicit((Object)(object)val.GetComponent())) { MeleeWeapon componentInChildren = val.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.Validate(); } } if (Object.op_Implicit((Object)(object)val.GetComponent())) { RangeWeapon componentInChildren2 = val.GetComponentInChildren(); if ((Object)(object)componentInChildren2 != (Object)null) { componentInChildren2.Validate(); } } } if (Object.op_Implicit((Object)(object)val.GetComponent()) || Object.op_Implicit((Object)(object)val.GetComponent())) { Log("Currently editing Projectile : " + ((Object)val).name); UManager.SetProjectile(val, val.GetComponent(), landfallContentDatabase); } if (Object.op_Implicit((Object)(object)val.GetComponent())) { Log("Currently editing Effect : " + ((Object)val).name); UManager.SetEffects(val); } if (Object.op_Implicit((Object)(object)val.GetComponent())) { Log("Currently editing Unit : " + ((Object)val).name); UManager.SetUnits(val.GetComponent(), landfallContentDatabase); } if (Object.op_Implicit((Object)(object)val.GetComponent())) { Log("Currently editing Movement : " + ((Object)val).name); UManager.SetCombatMove(val, val.GetComponent(), landfallContentDatabase); } if (Object.op_Implicit((Object)(object)val.GetComponent())) { Log("Currently editing Clothing : " + ((Object)val).name); UManager.SetClothes(val, val.GetComponent(), val.GetComponent(), val.GetComponent(), val.GetComponent(), landfallContentDatabase); } if (Object.op_Implicit((Object)(object)val.GetComponentInChildren())) { Log("Current Validated Sound Effect : " + ((Object)val).name); PlaySoundEffect[] componentsInChildren = val.GetComponentsInChildren(); for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].Validate(); } } UManager.SetAllGameObject(val, landfallContentDatabase); Log("Current Debugged Game Object : " + ((Object)val).name); } UnitBlueprint[] array2 = Resources.FindObjectsOfTypeAll(); for (int k = 0; k < array2.Length; k++) { Log("Blueprint currently debugged : " + array2[k].Entity.Name); UManager.SetBlueprints(array2[k], landfallContentDatabase); array2[k].Validate(); } ServiceLocator.GetService().QuickRefresh((WorkshopContentType)5, (Action)null); } private void Awake() { try { ApplyHarmony(); ((MonoBehaviour)this).StartCoroutine(Call()); } catch (Exception ex) { LogError("Fatal error, mod loading failed: " + ex); LogWarning("Please contact Geezt Jeez or try reloading the game for proper installation..."); } } private IEnumerator Call() { if (!initialized) { yield return (object)new WaitUntil((Func)(() => (Object)(object)Object.FindObjectOfType() != (Object)null)); yield return (object)new WaitUntil((Func)(() => ServiceLocator.GetService() != null)); Log($"Loading {modName}!"); LoadMod(); initialized = true; Log($"{modName} Successfully loaded!"); } } public static void Log(string message) { if (enableDebug) { Debug.Log((object)$"[{modName}] [Log] : {message}"); } } public static void LogWarning(string message) { if (enableDebug) { Debug.LogWarning((object)$"[{modName}] [Warn] : {message}"); } } public static void LogError(string message) { if (enableDebug) { Debug.LogError((object)$"[{modName}] [Error] : {message}"); } } static Loader() { modName = "Runic Spells"; } } } namespace RunicSpellsUtilities { public sealed class UTISeal { public class Uti : MonoBehaviour { public static class PrimitiveHelper { private static Dictionary primitiveMeshes; public unsafe static GameObject CreatePrimitive(PrimitiveType type, bool withCollider) { //IL_0017: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0003: Unknown result type (might be due to invalid IL or missing references) if (withCollider) { return GameObject.CreatePrimitive(type); } GameObject val = new GameObject(((object)(*(PrimitiveType*)(&type))/*cast due to .constrained prefix*/).ToString()); val.AddComponent().sharedMesh = GetPrimitiveMesh(type); val.AddComponent(); return val; } public static Mesh GetPrimitiveMesh(PrimitiveType type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (!primitiveMeshes.ContainsKey(type)) { CreatePrimitiveMesh(type); } return primitiveMeshes[type]; } private static Mesh CreatePrimitiveMesh(PrimitiveType type) { //IL_0000: 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) GameObject obj = GameObject.CreatePrimitive(type); Mesh sharedMesh = obj.GetComponent().sharedMesh; Object.Destroy((Object)(object)obj); primitiveMeshes[type] = sharedMesh; return sharedMesh; } static PrimitiveHelper() { primitiveMeshes = new Dictionary(); } } public static class GameObjectHelper { public static GameObject InstantiateEmpty(string name, Vector3 position, Quaternion rotation, Transform parent) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.position = position; val.transform.rotation = rotation; val.transform.parent = parent; return val; } } public static class ICat { public static GameObject SetTag(GameObject item, string categoryName = "Expansionary", TagType tagType = (TagType)0) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_002e: Unknown result type (might be due to invalid IL or missing references) try { CharacterItem componentInChildren = item.GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren)) { componentInChildren.tags = new List { new Tag { tagType = tagType, value = categoryName } }; } } catch (Exception ex) { Loader.LogError(ex.ToString()); } return item; } } private const string UnitIDFileName = "ExpansionaryUnitIDs.cfg"; private static readonly Dictionary PersistentUnitIDs; private static bool unitIDsLoaded; private static Dictionary CombatMoves { get { Dictionary dictionary = HelpLibrary.m_combatMoves; if (dictionary == null) { dictionary = (HelpLibrary.m_combatMoves = new Dictionary()); } return dictionary; } } private static Dictionary CharacterProps { get { Dictionary dictionary = HelpLibrary.m_characterProps; if (dictionary == null) { dictionary = (HelpLibrary.m_characterProps = new Dictionary()); } return dictionary; } } private static Dictionary UnitBases { get { Dictionary dictionary = HelpLibrary.m_unitBases; if (dictionary == null) { dictionary = (HelpLibrary.m_unitBases = new Dictionary()); } return dictionary; } } private static Dictionary Factions { get { Dictionary dictionary = HelpLibrary.m_factions; if (dictionary == null) { dictionary = (HelpLibrary.m_factions = new Dictionary()); } return dictionary; } } private static Dictionary Weapons { get { Dictionary dictionary = HelpLibrary.m_weapons; if (dictionary == null) { dictionary = (HelpLibrary.m_weapons = new Dictionary()); } return dictionary; } } private static Dictionary Projectiles { get { Dictionary dictionary = HelpLibrary.m_projectiles; if (dictionary == null) { dictionary = (HelpLibrary.m_projectiles = new Dictionary()); } return dictionary; } } private static Dictionary Units { get { Dictionary dictionary = HelpLibrary.m_unitBlueprints; if (dictionary == null) { dictionary = (HelpLibrary.m_unitBlueprints = new Dictionary()); } return dictionary; } } private static string UnitIDFilePath => Path.Combine(Paths.ConfigPath, "ExpansionaryUnitIDs.cfg"); public AssetBundle LoadBundle(string assetBundleName) { Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(assetBundleName); if (manifestResourceStream == null) { Loader.LogError("[LoadBundle] Failed to find resource: " + assetBundleName); return null; } if (!manifestResourceStream.CanRead) { Loader.LogError("[LoadBundle] Resource stream is not readable: " + assetBundleName); return null; } return AssetBundle.LoadFromStream(manifestResourceStream); } public static Sprite LoBuTex2Sprite(string name) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0041: 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) Loader.Log("Loading the texture named: " + name); Texture2D val = (Texture2D)bundle.LoadAsset(name); ((Texture)val).filterMode = (FilterMode)0; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } public static GameObject LoBuGaOb(string name) { try { Loader.Log($"Loading object: {name}"); return bundle.LoadAsset(name); } catch (Exception ex) { Loader.LogError($"Exception found during loading object: {ex.ToString()}"); return null; } } public static AudioClip LoBuAudioClip(string name) { return bundle.LoadAsset(name); } public static Material LoBuMat(string name) { return bundle.LoadAsset(name); } public static int IDScn(AssetType type, int startId = 1) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) int num = Math.Max(1, startId); DatabaseID id = default(DatabaseID); ((DatabaseID)(ref id))..ctor(num); while (IsOccupied(type, id)) { Loader.LogWarning($"[IDChecker] ID {num} in use for {type}, trying {num + 1}..."); num++; ((DatabaseID)(ref id))..ctor(num); } Loader.Log($"[IDChecker] Found free ID for {type}: {num}"); return num; } private static bool IsOccupied(AssetType type, DatabaseID id) { //IL_0029: 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_0041: 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_0059: 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_0071: Unknown result type (might be due to invalid IL or missing references) return type switch { AssetType.Prop => CharacterProps.ContainsKey(id), AssetType.UnitBase => UnitBases.ContainsKey(id), AssetType.Faction => Factions.ContainsKey(id), AssetType.Ability => CombatMoves.ContainsKey(id), AssetType.Weapon => Weapons.ContainsKey(id), AssetType.Projectile => Projectiles.ContainsKey(id), AssetType.Unit => Units.ContainsKey(id), _ => throw new ArgumentOutOfRangeException("type", type, null), }; } public static Faction SetFactionHidden(Faction faction) { faction.ForceSetField("m_isSecret", true); faction.ForceSetField("m_lockSecrets", true); return faction; } public static Faction SetFaction(Faction faction, bool secret, bool lockSecrets, Color color, int index) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) faction.ForceSetField("m_isSecret", secret); faction.ForceSetField("m_lockSecrets", lockSecrets); faction.m_FactionColor = color; faction.index = index; return faction; } public static Mesh LoBuMesh(string name) { return bundle.LoadAsset(name); } public static UnitBlueprint CreateUnit(string name, UnitBlueprint unit, Faction faction, Sprite sprite) { //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)unit != (Object)null) { UnitBlueprint val = Object.Instantiate(unit); DatabaseEntity val2 = new DatabaseEntity((WorkshopContentType)0); int persistentUnitID = GetPersistentUnitID(name); val2.GUID = new DatabaseID(-2, persistentUnitID); OtherLibrary.SetField(val, "m_entity", (object)val2); Dictionary dictionary = (Dictionary)OtherLibrary.GetField(ContentDatabase.Instance().LandfallContentDatabase, "m_unitBlueprints"); if (dictionary.ContainsKey(val2.GUID)) { Loader.LogError("Unit ID collision for '" + name + "'. ID: " + persistentUnitID); return null; } dictionary.Add(val2.GUID, val); OtherLibrary.SetField(ContentDatabase.Instance().LandfallContentDatabase, "m_unitBlueprints", (object)dictionary); val.Entity.Name = name; ((Object)val).name = name; val.Entity.SpriteIcon = sprite; if ((Object)(object)faction != (Object)null && (Object)(object)val != (Object)null) { if (faction.Units == null) { faction.Units = (UnitBlueprint[])(object)new UnitBlueprint[1] { val }; } else { List list = faction.Units.ToList(); list.Add(val); faction.Units = list.ToArray(); } } Loader.Log("Created '" + name + "' with persistent ID " + persistentUnitID); return val; } UnitBlueprint val3 = Object.Instantiate((UnitBlueprint)SLMALoader.SDic["blueprints"]["UNIT_TRIBAL_CLUB"]); DatabaseEntity val4 = new DatabaseEntity((WorkshopContentType)0); int persistentUnitID2 = GetPersistentUnitID(name); val4.GUID = new DatabaseID(-2, persistentUnitID2); OtherLibrary.SetField(val3, "m_entity", (object)val4); ((Object)val3).name = name; val3.m_props = null; val3.RightWeapon = null; val3.MovementComponents = new List { (IMovementComponent)(object)default(KeepRangedDistance) }; ContentDatabase.Instance().AddUserUnitBlueprint(val3); Dictionary dictionary2 = (Dictionary)OtherLibrary.GetField(ContentDatabase.Instance().LandfallContentDatabase, "m_unitBlueprints"); if (dictionary2.ContainsKey(val4.GUID)) { Loader.LogError("Unit ID collision for '" + name + "'. ID: " + persistentUnitID2); return null; } dictionary2.Add(val4.GUID, val3); OtherLibrary.SetField(ContentDatabase.Instance().LandfallContentDatabase, "m_unitBlueprints", (object)dictionary2); val3.Entity.Name = name; ((Object)val3).name = name; val3.Entity.SpriteIcon = sprite; if ((Object)(object)faction != (Object)null && (Object)(object)val3 != (Object)null) { if (faction.Units == null) { faction.Units = (UnitBlueprint[])(object)new UnitBlueprint[1] { val3 }; } else { List list2 = faction.Units.ToList(); list2.Add(val3); faction.Units = list2.ToArray(); } } SLMATool.SLMADic.Add(name, val3); Loader.Log("Created '" + name + "' with persistent ID " + persistentUnitID2); return val3; } public static int GetPersistentUnitID(string unitName, int startId = 1) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) EnsureUnitIDsLoaded(); if (string.IsNullOrEmpty(unitName)) { throw new ArgumentException("Unit name cannot be null or empty.", "unitName"); } if (PersistentUnitIDs.TryGetValue(unitName, out var value)) { DatabaseID key = default(DatabaseID); ((DatabaseID)(ref key))..ctor(-2, value); if (!Units.TryGetValue(key, out var value2)) { Loader.Log($"[UnitID] Reusing saved ID {value} for unit '{unitName}'."); return value; } if ((Object)(object)value2 != (Object)null && value2.Entity != null && value2.Entity.Name == unitName) { Loader.Log($"[UnitID] ID {value} already belongs to '{unitName}'. Reusing it."); return value; } Loader.LogWarning($"[UnitID] Saved ID {value} for '{unitName}' is occupied by another unit. Searching for a new ID."); int num = FindFreePersistentUnitID(startId); PersistentUnitIDs[unitName] = num; SaveUnitIDs(); Loader.LogWarning($"[UnitID] Unit '{unitName}' was moved from ID {value} to ID {num}."); return num; } int num2 = FindFreePersistentUnitID(startId); PersistentUnitIDs.Add(unitName, num2); SaveUnitIDs(); Loader.Log($"[UnitID] Assigned new persistent ID {num2} to '{unitName}'."); return num2; } private static int FindFreePersistentUnitID(int startId) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) int num = Math.Max(1, startId); DatabaseID key = default(DatabaseID); while (true) { ((DatabaseID)(ref key))..ctor(-2, num); bool num2 = Units.ContainsKey(key); bool flag = IsPersistentIDReservedByAnotherUnit(num); if (!num2 && !flag) { break; } Loader.LogWarning($"[UnitID] Unit ID {num} is unavailable. Trying {num + 1}..."); num++; } Loader.Log($"[UnitID] Found free persistent unit ID: {num}"); return num; } private static bool IsPersistentIDReservedByAnotherUnit(int id) { foreach (KeyValuePair persistentUnitID in PersistentUnitIDs) { if (persistentUnitID.Value == id) { return true; } } return false; } private static void EnsureUnitIDsLoaded() { if (unitIDsLoaded) { return; } unitIDsLoaded = true; try { string unitIDFilePath = UnitIDFilePath; if (!File.Exists(unitIDFilePath)) { Loader.Log("[UnitID] No persistent unit ID file found. Creating a new registry."); SaveUnitIDs(); return; } string[] array = File.ReadAllLines(unitIDFilePath); foreach (string text in array) { if (string.IsNullOrWhiteSpace(text) || text.StartsWith("#")) { continue; } int num = text.IndexOf('\t'); if (num <= 0 || num >= text.Length - 1) { Loader.LogWarning("[UnitID] Ignoring malformed registry line: " + text); continue; } string text2 = UnescapeUnitName(text.Substring(0, num)); if (!int.TryParse(text.Substring(num + 1), out var result)) { Loader.LogWarning("[UnitID] Invalid ID in registry: " + text); } else if (result < 1) { Loader.LogWarning("[UnitID] Ignoring invalid ID " + result + " for unit '" + text2 + "'."); } else if (PersistentUnitIDs.ContainsKey(text2)) { Loader.LogWarning("[UnitID] Duplicate unit entry found for '" + text2 + "'. Keeping the first entry."); } else if (IsPersistentIDReservedByAnotherUnit(result)) { Loader.LogWarning("[UnitID] Duplicate ID " + result + " found in registry. Ignoring entry for '" + text2 + "'."); } else { PersistentUnitIDs.Add(text2, result); } } Loader.Log($"[UnitID] Loaded {PersistentUnitIDs.Count} persistent unit IDs."); } catch (Exception ex) { Loader.LogError("[UnitID] Failed to load persistent unit IDs: " + ex); } } private static void SaveUnitIDs() { try { string configPath = Paths.ConfigPath; if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } List list = new List(); list.Add("# Expansionary persistent unit IDs"); list.Add("# Unit NameID"); foreach (KeyValuePair persistentUnitID in PersistentUnitIDs) { list.Add(FormatUnitName(persistentUnitID.Key) + "\t" + persistentUnitID.Value); } File.WriteAllLines(UnitIDFilePath, list.ToArray()); } catch (Exception ex) { Loader.LogError("[UnitID] Failed to save persistent unit IDs: " + ex); } } private static string FormatUnitName(string value) { return value.Replace("\\", "\\\\").Replace("\t", "\\t").Replace("\r", "\\r") .Replace("\n", "\\n"); } private static string UnescapeUnitName(string value) { return value.Replace("\\n", "\n").Replace("\\r", "\r").Replace("\\t", "\t") .Replace("\\\\", "\\"); } public static bool TryGetPersistentUnitID(string unitName, out int id) { EnsureUnitIDsLoaded(); return PersistentUnitIDs.TryGetValue(unitName, out id); } public static bool HasPersistentUnitID(string unitName) { EnsureUnitIDsLoaded(); return PersistentUnitIDs.ContainsKey(unitName); } static Uti() { PersistentUnitIDs = new Dictionary(StringComparer.Ordinal); unitIDsLoaded = false; } } public enum AssetType { Prop, UnitBase, Faction, Ability, Weapon, Projectile, Unit } public static AssetBundle bundle; } public static class UTISttc { public static object ForceGetField(this T self, string name) where T : class { FieldInfo field = typeof(T).GetField(name, (BindingFlags)(-1)); if (field != null) { return field.GetValue(self); } return null; } public static T ForceSetField(this T self, string name, object value) where T : class { FieldInfo field = typeof(T).GetField(name, (BindingFlags)(-1)); if (field != null) { field.SetValue(self, value); } return self; } public static Component CatchOrAddComponent(Type typeToSeek, GameObject obj) { Component val = obj.GetComponentInChildren(typeToSeek, true); if ((Object)(object)val == (Object)null) { val = obj.AddComponent(typeToSeek); } return val; } public static T[] AddItem(this T[] source, T newValue) { if (source == null) { return new T[1] { newValue }; } int num = source.Length; Array.Resize(ref source, num + 1); source[num] = newValue; return source; } } } namespace RunicSpellsScripts { public class InstaBeamBehaviour : MonoBehaviour { public AnimationCurve widthCurve; public float duration = 0.5f; public float widthMultiplier; private float timer; private SpellTarget target; public float lerpAmount = 1000f; public DelayEvent delayEvent; private float peakTime; private bool peakTriggered; public float peakDuration = 0.1f; private LineRenderer[] lineRenderers; private void Update() { timer += Time.deltaTime; float num = timer / duration; float num2 = widthCurve.Evaluate(num); LineRenderer[] array = lineRenderers; for (int i = 0; i < array.Length; i++) { array[i].widthMultiplier = num2 * widthMultiplier; } if (!peakTriggered && num >= peakTime) { peakTriggered = true; if ((Object)(object)delayEvent != (Object)null) { delayEvent.Go(); } EnableDamage(setActive: true); } if (peakTriggered && num >= peakTime + peakDuration) { EnableDamage(setActive: false); } } public InstaBeamBehaviour() { widthMultiplier = 1f; } private void Start() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) lineRenderers = ((Component)this).GetComponentsInChildren(true); target = ((Component)((Component)this).transform.root).GetComponentInChildren(); delayEvent = ((Component)this).GetComponentInChildren(); EnableDamage(setActive: false); FindPeakTime(); LineRenderer[] array = lineRenderers; foreach (LineRenderer val in array) { val.SetPositions((Vector3[])(object)new Vector3[2] { ((Component)val).transform.position, ((Component)val).transform.position - ((Component)this).transform.position + Vector3.LerpUnclamped(((Component)this).transform.position, target.rig.position, lerpAmount) }); } } private void FindPeakTime() { peakTime = 0f; if (widthCurve == null || widthCurve.length == 0) { return; } Keyframe[] keys = widthCurve.keys; float num = float.MinValue; for (int i = 0; i < keys.Length; i++) { if (((Keyframe)(ref keys[i])).value > num) { num = ((Keyframe)(ref keys[i])).value; peakTime = ((Keyframe)(ref keys[i])).time; } } } public void EnableDamage(bool setActive) { BoxCollider[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).gameObject.SetActive(setActive); } } } public class DamageTriggerZoneBehaviour : MonoBehaviour { public Unit unit; public float damage = 2000f; public UnitEffectBase EffectPrefab; public string hitSoundName = "Effects/MagicMissileSmite"; public float hitSoundVolume = 1f; public float hitSoundPitch = 1f; public float timer = 10f; public TeamHolder teamHolder; public bool destroyOnHit; private readonly Dictionary lastHitTime = new Dictionary(128); private readonly HashSet activeUnits = new HashSet(); private float cleanupTimer; private const float cleanupInterval = 1f; private void Start() { if (!Object.op_Implicit((Object)(object)teamHolder)) { teamHolder = ((Component)((Component)this).transform.root).GetComponentInChildren(); } if (!Object.op_Implicit((Object)(object)unit)) { unit = ((Component)((Component)this).transform.root).GetComponentInChildren(); if (!Object.op_Implicit((Object)(object)unit) && Object.op_Implicit((Object)(object)teamHolder) && Object.op_Implicit((Object)(object)teamHolder.spawner)) { unit = teamHolder.spawner.GetComponentInChildren(); } } } private void OnTriggerStay(Collider other) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_0146: 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) Unit componentInChildren = ((Component)((Component)other).transform.root).GetComponentInChildren(); if (!Object.op_Implicit((Object)(object)componentInChildren) || (Object)(object)componentInChildren == (Object)(object)unit || componentInChildren.Team == unit.Team || (Object)(object)componentInChildren.data == (Object)null || componentInChildren.data.Dead || (Object)(object)componentInChildren.data.healthHandler == (Object)null) { return; } if (!lastHitTime.TryGetValue(componentInChildren, out var value)) { value = -999f; } if (!(Time.time - value >= timer)) { return; } lastHitTime[componentInChildren] = Time.time; if (!string.IsNullOrEmpty(hitSoundName)) { SoundPlayer service = ServiceLocator.GetService(); if ((Object)(object)service != (Object)null) { service.PlaySoundEffect(hitSoundName, hitSoundVolume, ((Component)other).transform.position, (MaterialType)0, (Transform)null, 0.5f); } } float num = damage; ((Damagable)componentInChildren.data.healthHandler).TakeDamage(num, ((Component)other).transform.position, unit, (DamageType)0); Rigidbody[] allRigs = componentInChildren.data.allRigs.AllRigs; foreach (Rigidbody val in allRigs) { ParticlePlayer service2 = ServiceLocator.GetService(); if ((Object)(object)service2 != (Object)null) { service2.PlayEffect(1, val.position, Vector3.up, (SkinnedMeshRenderer)null); } } if (Object.op_Implicit((Object)(object)EffectPrefab)) { Type type = ((object)EffectPrefab).GetType(); Component componentInChildren2 = ((Component)((Component)componentInChildren).transform).GetComponentInChildren(type); UnitEffectBase val2 = (UnitEffectBase)(object)((componentInChildren2 is UnitEffectBase) ? componentInChildren2 : null); if ((Object)(object)val2 == (Object)null) { GameObject obj = Object.Instantiate(((Component)EffectPrefab).gameObject, ((Component)componentInChildren).transform); obj.transform.position = componentInChildren.data.mainRig.position; UnitEffectBase componentInChildren3 = obj.GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren3)) { componentInChildren3.Ping(); componentInChildren3.DoEffect(); } } else { val2.Ping(); } } if (destroyOnHit) { Object.Destroy((Object)(object)((Component)this).gameObject); } } private void Update() { cleanupTimer += Time.deltaTime; if (cleanupTimer >= 1f) { cleanupTimer = 0f; CleanupDeadUnits(); } } private void OnTriggerEnter(Collider other) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) Unit componentInChildren = ((Component)((Component)other).transform.root).GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren) && (Object)(object)componentInChildren != (Object)(object)unit && componentInChildren.Team != unit.Team) { activeUnits.Add(componentInChildren); } } private void OnTriggerExit(Collider other) { Unit componentInChildren = ((Component)((Component)other).transform.root).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { activeUnits.Remove(componentInChildren); lastHitTime.Remove(componentInChildren); } } private void CleanupDeadUnits() { foreach (Unit activeUnit in activeUnits) { if ((Object)(object)activeUnit == (Object)null || (Object)(object)activeUnit.data == (Object)null || activeUnit.data.Dead) { lastHitTime.Remove(activeUnit); activeUnits.Remove(activeUnit); break; } } } } }