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.3.0")]
[module: UnverifiableCode]
namespace RunicSpells
{
public static class UManager
{
public class InitManager
{
public static void InitExplosions(Sprite icon)
{
UPool.MyPool.AddObject("Exp_BlueFireWave", UTISeal.Uti.LoBuGaOb("Exp_BlueFireWave"), true, (HideFlags)52, icon, 0, true);
UPool.MyPool.AddObject("Exp_TornadoSpawn", UTISeal.Uti.LoBuGaOb("Exp_TornadoSpawn"), true, (HideFlags)52, icon, 0, true);
UPool.MyPool.AddObject("Exp_FlameDragon", UTISeal.Uti.LoBuGaOb("Exp_FlameDragon"), true, (HideFlags)52, icon, 0, true);
UPool.MyPool.AddObject("Exp_BlueFlameDragon", UTISeal.Uti.LoBuGaOb("Exp_BlueFlameDragon"), true, (HideFlags)52, icon, 0, true);
UPool.MyPool.AddObject("Exp_FlameVulcanic", UTISeal.Uti.LoBuGaOb("Exp_FlameVulcanic"), true, (HideFlags)52, icon, 0, true);
UPool.MyPool.AddObject("Exp_BlueFlameVulcanic", UTISeal.Uti.LoBuGaOb("Exp_BlueFlameVulcanic"), true, (HideFlags)52, icon, 0, true);
}
public static void InitEffects(Sprite icon)
{
UPool.MyPool.AddObject("Eff_BlueFire", UTISeal.Uti.LoBuGaOb("Eff_BlueFire"), true, (HideFlags)52, icon, 0, true);
}
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)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
int startId = 563545351;
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("RandomPosAttack", UTISeal.Uti.LoBuGaOb("RandomPosAttack"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
}
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)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: 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_01ee: 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_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: 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);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("P_WaterSpew", UTISeal.Uti.LoBuGaOb("P_WaterSpew"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("P_LightSword", UTISeal.Uti.LoBuGaOb("P_LightSword"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("P_WindDagger", UTISeal.Uti.LoBuGaOb("P_WindDagger"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("P_SlashProjectile", UTISeal.Uti.LoBuGaOb("P_SlashProjectile"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("P_BlueFireBall", UTISeal.Uti.LoBuGaOb("P_BlueFireBall"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("P_GiantFireBall", UTISeal.Uti.LoBuGaOb("P_GiantFireBall"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("P_GiantBlueFireBall", UTISeal.Uti.LoBuGaOb("P_GiantBlueFireBall"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("P_SwirlFireball", UTISeal.Uti.LoBuGaOb("P_SwirlFireball"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("P_BlueSwirlFireball", UTISeal.Uti.LoBuGaOb("P_BlueSwirlFireball"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("P_FlameDragon", UTISeal.Uti.LoBuGaOb("P_FlameDragon"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("P_BlueFlameDragon", UTISeal.Uti.LoBuGaOb("P_BlueFlameDragon"), 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)
{
//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)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: 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_01ee: 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_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
int startId = 83941214;
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("Move_WaterSpew", UTISeal.Uti.LoBuGaOb("Move_WaterSpew"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("Move_SingularLaserShot", UTISeal.Uti.LoBuGaOb("Move_SingularLaserShot"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("Move_DoubleLaserShot", UTISeal.Uti.LoBuGaOb("Move_DoubleLaserShot"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("Move_TringularLaserShot", UTISeal.Uti.LoBuGaOb("Move_TringularLaserShot"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("Move_BlueFireWave", UTISeal.Uti.LoBuGaOb("Move_BlueFireWave"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("Move_TornadoSpawn", UTISeal.Uti.LoBuGaOb("Move_TornadoSpawn"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("Move_ChargedGiantFireball", UTISeal.Uti.LoBuGaOb("Move_ChargedGiantFireball"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("Move_ChargedBlueGiantFireball", UTISeal.Uti.LoBuGaOb("Move_ChargedBlueGiantFireball"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("Move_SwirlFireball", UTISeal.Uti.LoBuGaOb("Move_SwirlFireball"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("Move_BlueSwirlFireball", UTISeal.Uti.LoBuGaOb("Move_BlueSwirlFireball"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("Move_FlameDragonCharge", UTISeal.Uti.LoBuGaOb("Move_FlameDragonCharge"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("Move_BlueFlameDragonCharge", UTISeal.Uti.LoBuGaOb("Move_BlueFlameDragonCharge"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("Move_FlameVulcanicSpawn", UTISeal.Uti.LoBuGaOb("Move_FlameVulcanicSpawn"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
UTISeal.Uti.ICat.SetTag(UPool.MyPool.AddObject("Move_BlueFlameVulcanicSpawn", UTISeal.Uti.LoBuGaOb("Move_BlueFlameVulcanicSpawn"), true, (HideFlags)52, icon, UTISeal.Uti.IDScn(assetType, startId), true), catNm, archType);
}
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 Effects";
InitManager.InitEffects(icon);
comment = "Custom Explosions";
InitManager.InitExplosions(icon);
comment = "Custom Custom Prefabs";
InitManager.InitCustomPrefabs(icon);
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);
}
public static void SetBlueprints(UnitBlueprint unit, LandfallContentDatabase db)
{
}
public static void SetEffects(GameObject effect)
{
if ((Object)(object)effect == (Object)(object)UPool.MyPool.GetObject("Eff_BlueFire"))
{
effect.AddComponent<CustomIceEffectBase>().iceMaterial = UTISeal.Uti.LoBuMat("BlueFireIceMaterial");
}
}
public static void SetExplosion(GameObject explosion)
{
if ((Object)(object)explosion == (Object)(object)UPool.MyPool.GetObject("Exp_BlueFlameVulcanic"))
{
AddObjectEffect[] componentsInChildren = explosion.GetComponentsInChildren<AddObjectEffect>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[i].EffectPrefab = (UnitEffectBase)(object)UPool.MyPool.GetObject("Eff_BlueFire").GetComponentInChildren<DamageOverTimeEffect>();
}
}
if ((Object)(object)explosion == (Object)(object)UPool.MyPool.GetObject("Exp_BlueFireWave"))
{
AddObjectEffect[] componentsInChildren2 = explosion.GetComponentsInChildren<AddObjectEffect>();
for (int j = 0; j < componentsInChildren2.Length; j++)
{
componentsInChildren2[j].EffectPrefab = (UnitEffectBase)(object)UPool.MyPool.GetObject("Eff_BlueFire").GetComponentInChildren<DamageOverTimeEffect>();
}
}
if ((Object)(object)explosion == (Object)(object)UPool.MyPool.GetObject("Exp_BlueFlameDragon"))
{
AddObjectEffect[] componentsInChildren3 = explosion.GetComponentsInChildren<AddObjectEffect>();
for (int k = 0; k < componentsInChildren3.Length; k++)
{
componentsInChildren3[k].EffectPrefab = (UnitEffectBase)(object)UPool.MyPool.GetObject("Eff_BlueFire").GetComponentInChildren<DamageOverTimeEffect>();
}
}
}
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)
{
if ((Object)(object)weapon == (Object)(object)UPool.MyPool.GetObject("RandomPosAttack"))
{
range.ObjectToSpawn = UPool.MyPool.GetObject("P_InstaBeamblastLaserSingular");
}
}
public static void SetProjectile(GameObject proj, ProjectileHit projhit, LandfallContentDatabase db)
{
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: 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_0227: 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_023d: 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_0253: 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_0269: 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_027d: Expected O, but got Unknown
//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_030e: Unknown result type (might be due to invalid IL or missing references)
//IL_0313: Unknown result type (might be due to invalid IL or missing references)
//IL_0324: Unknown result type (might be due to invalid IL or missing references)
//IL_0329: Unknown result type (might be due to invalid IL or missing references)
//IL_033a: Unknown result type (might be due to invalid IL or missing references)
//IL_033f: Unknown result type (might be due to invalid IL or missing references)
//IL_0350: Unknown result type (might be due to invalid IL or missing references)
//IL_0355: Unknown result type (might be due to invalid IL or missing references)
//IL_035a: Unknown result type (might be due to invalid IL or missing references)
//IL_0364: Expected O, but got Unknown
//IL_039d: Unknown result type (might be due to invalid IL or missing references)
//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
//IL_03df: Unknown result type (might be due to invalid IL or missing references)
//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
//IL_040b: Unknown result type (might be due to invalid IL or missing references)
//IL_0410: Unknown result type (might be due to invalid IL or missing references)
//IL_0421: Unknown result type (might be due to invalid IL or missing references)
//IL_0426: Unknown result type (might be due to invalid IL or missing references)
//IL_0437: Unknown result type (might be due to invalid IL or missing references)
//IL_043c: Unknown result type (might be due to invalid IL or missing references)
//IL_0441: Unknown result type (might be due to invalid IL or missing references)
//IL_044b: Expected O, but got Unknown
if ((Object)(object)proj == (Object)(object)UPool.MyPool.GetObject("P_BlueFlameDragon"))
{
SpawnObject[] componentsInChildren = proj.GetComponentsInChildren<SpawnObject>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[i].objectToSpawn = UPool.MyPool.GetObject("Exp_BlueFlameDragon");
}
}
if ((Object)(object)proj == (Object)(object)UPool.MyPool.GetObject("P_BlueSwirlFireball"))
{
AddObjectEffect[] componentsInChildren2 = proj.GetComponentsInChildren<AddObjectEffect>();
for (int j = 0; j < componentsInChildren2.Length; j++)
{
componentsInChildren2[j].EffectPrefab = (UnitEffectBase)(object)UPool.MyPool.GetObject("Eff_BlueFire").GetComponentInChildren<DamageOverTimeEffect>();
}
}
if ((Object)(object)proj == (Object)(object)UPool.MyPool.GetObject("P_GiantBlueFireBall"))
{
ProjectileHitAddEffectWithSize[] componentsInChildren3 = proj.GetComponentsInChildren<ProjectileHitAddEffectWithSize>();
for (int k = 0; k < componentsInChildren3.Length; k++)
{
componentsInChildren3[k].EffectPrefab = (UnitEffectBase)(object)UPool.MyPool.GetObject("Eff_BlueFire").GetComponentInChildren<DamageOverTimeEffect>();
}
AddObjectEffect[] componentsInChildren4 = proj.GetComponentsInChildren<AddObjectEffect>();
for (int l = 0; l < componentsInChildren4.Length; l++)
{
componentsInChildren4[l].EffectPrefab = (UnitEffectBase)(object)UPool.MyPool.GetObject("Eff_BlueFire").GetComponentInChildren<DamageOverTimeEffect>();
}
}
if ((Object)(object)proj == (Object)(object)UPool.MyPool.GetObject("P_BlueFireBall"))
{
ProjectileHitAddEffectWithSize[] componentsInChildren5 = proj.GetComponentsInChildren<ProjectileHitAddEffectWithSize>();
for (int m = 0; m < componentsInChildren5.Length; m++)
{
componentsInChildren5[m].EffectPrefab = (UnitEffectBase)(object)UPool.MyPool.GetObject("Eff_BlueFire").GetComponentInChildren<DamageOverTimeEffect>();
}
AddObjectEffect[] componentsInChildren6 = proj.GetComponentsInChildren<AddObjectEffect>();
for (int n = 0; n < componentsInChildren6.Length; n++)
{
componentsInChildren6[n].EffectPrefab = (UnitEffectBase)(object)UPool.MyPool.GetObject("Eff_BlueFire").GetComponentInChildren<DamageOverTimeEffect>();
}
}
if ((Object)(object)proj == (Object)(object)UPool.MyPool.GetObject("P_InstaBeamblastLaserSingular"))
{
proj.AddComponent<InstaBeamBehaviour>().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<DamageTriggerZoneBehaviour>();
}
if ((Object)(object)proj == (Object)(object)UPool.MyPool.GetObject("P_InstaBeamblastLaserDouble"))
{
proj.AddComponent<InstaBeamBehaviour>().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<DamageTriggerZoneBehaviour>();
}
if ((Object)(object)proj == (Object)(object)UPool.MyPool.GetObject("P_InstaBeamblastLaserTringular"))
{
proj.AddComponent<InstaBeamBehaviour>().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<DamageTriggerZoneBehaviour>();
}
}
public static void SetCombatMove(GameObject move, DodgeMove dodge, LandfallContentDatabase db)
{
if ((Object)(object)move == (Object)(object)UPool.MyPool.GetObject("Move_SingularLaserShot"))
{
move.GetComponentInChildren<SpawnObject>().objectToSpawn = UPool.MyPool.GetObject("P_InstaBeamblastLaserSingular");
}
if ((Object)(object)move == (Object)(object)UPool.MyPool.GetObject("Move_DoubleLaserShot"))
{
move.GetComponentInChildren<SpawnObject>().objectToSpawn = UPool.MyPool.GetObject("P_InstaBeamblastLaserDouble");
}
if ((Object)(object)move == (Object)(object)UPool.MyPool.GetObject("Move_TringularLaserShot"))
{
move.GetComponentInChildren<SpawnObject>().objectToSpawn = UPool.MyPool.GetObject("P_InstaBeamblastLaserTringular");
}
if ((Object)(object)move == (Object)(object)UPool.MyPool.GetObject("Move_BlueFireWave"))
{
move.GetComponentInChildren<SpawnObject>().objectToSpawn = UPool.MyPool.GetObject("Exp_BlueFireWave");
}
if ((Object)(object)move == (Object)(object)UPool.MyPool.GetObject("Move_BlueSwirlFireball"))
{
move.GetComponentInChildren<SpawnObject>().objectToSpawn = UPool.MyPool.GetObject("P_BlueSwirlFireball");
}
if ((Object)(object)move == (Object)(object)UPool.MyPool.GetObject("Move_BlueFlameDragonCharge"))
{
move.GetComponentInChildren<SpawnObject>().objectToSpawn = UPool.MyPool.GetObject("P_BlueFlameDragon");
}
if ((Object)(object)move == (Object)(object)UPool.MyPool.GetObject("Move_BlueFlameVulcanicSpawn"))
{
move.GetComponentInChildren<SpawnObject>().objectToSpawn = UPool.MyPool.GetObject("Exp_BlueFlameVulcanic");
}
if ((Object)(object)move == (Object)(object)UPool.MyPool.GetObject("Move_ChargedBlueGiantFireball"))
{
move.GetComponentInChildren<SpawnObject>().objectToSpawn = UPool.MyPool.GetObject("P_GiantBlueFireBall");
}
}
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.3")]
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<int> hashSet = new HashSet<int>();
GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
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<Explosion>()))
{
Log("Currently editing Explosion : " + ((Object)val).name);
UManager.SetExplosion(val);
}
if (Object.op_Implicit((Object)(object)val.GetComponent<WeaponItem>()))
{
Log("Currently editing Weapon : " + ((Object)val).name);
UManager.SetWeapon(val, val.GetComponent<HandType>(), val.GetComponent<Team>(), val.GetComponent<Unit>(), val.GetComponent<MeleeWeapon>(), val.GetComponent<RangeWeapon>(), landfallContentDatabase);
if (Object.op_Implicit((Object)(object)val.GetComponent<MeleeWeapon>()))
{
MeleeWeapon componentInChildren = val.GetComponentInChildren<MeleeWeapon>();
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.Validate();
}
}
if (Object.op_Implicit((Object)(object)val.GetComponent<RangeWeapon>()))
{
RangeWeapon componentInChildren2 = val.GetComponentInChildren<RangeWeapon>();
if ((Object)(object)componentInChildren2 != (Object)null)
{
componentInChildren2.Validate();
}
}
}
if (Object.op_Implicit((Object)(object)val.GetComponent<ProjectileHit>()) || Object.op_Implicit((Object)(object)val.GetComponent<Projectile>()))
{
Log("Currently editing Projectile : " + ((Object)val).name);
UManager.SetProjectile(val, val.GetComponent<ProjectileHit>(), landfallContentDatabase);
}
if (Object.op_Implicit((Object)(object)val.GetComponent<PlaySoundEffect>()))
{
Log("Currently editing Effect : " + ((Object)val).name);
UManager.SetEffects(val);
}
if (Object.op_Implicit((Object)(object)val.GetComponent<Unit>()))
{
Log("Currently editing Unit : " + ((Object)val).name);
UManager.SetUnits(val.GetComponent<Unit>(), landfallContentDatabase);
}
if (Object.op_Implicit((Object)(object)val.GetComponent<SpecialAbility>()))
{
Log("Currently editing Movement : " + ((Object)val).name);
UManager.SetCombatMove(val, val.GetComponent<DodgeMove>(), landfallContentDatabase);
}
if (Object.op_Implicit((Object)(object)val.GetComponent<PropItem>()))
{
Log("Currently editing Clothing : " + ((Object)val).name);
UManager.SetClothes(val, val.GetComponent<CharacterItem>(), val.GetComponent<Renderer>(), val.GetComponent<MeshRenderer>(), val.GetComponent<SkinnedMeshRenderer>(), landfallContentDatabase);
}
if (Object.op_Implicit((Object)(object)val.GetComponentInChildren<PlaySoundEffect>()))
{
Log("Current Validated Sound Effect : " + ((Object)val).name);
PlaySoundEffect[] componentsInChildren = val.GetComponentsInChildren<PlaySoundEffect>();
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<UnitBlueprint>();
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<CustomContentLoaderModIO>().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<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
yield return (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<ISaveLoaderService>() != null));
Debug.Log((object)$"Loading {modName}!");
LoadMod();
initialized = true;
Debug.Log((object)$"{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<PrimitiveType, Mesh> 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<MeshFilter>().sharedMesh = GetPrimitiveMesh(type);
val.AddComponent<MeshRenderer>();
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<MeshFilter>().sharedMesh;
Object.Destroy((Object)(object)obj);
primitiveMeshes[type] = sharedMesh;
return sharedMesh;
}
static PrimitiveHelper()
{
primitiveMeshes = new Dictionary<PrimitiveType, Mesh>();
}
}
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<CharacterItem>();
if (Object.op_Implicit((Object)(object)componentInChildren))
{
componentInChildren.tags = new List<Tag>
{
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<string, int> PersistentUnitIDs;
private static bool unitIDsLoaded;
private static Dictionary<DatabaseID, GameObject> CombatMoves
{
get
{
Dictionary<DatabaseID, GameObject> dictionary = HelpLibrary.m_combatMoves;
if (dictionary == null)
{
dictionary = (HelpLibrary.m_combatMoves = new Dictionary<DatabaseID, GameObject>());
}
return dictionary;
}
}
private static Dictionary<DatabaseID, GameObject> CharacterProps
{
get
{
Dictionary<DatabaseID, GameObject> dictionary = HelpLibrary.m_characterProps;
if (dictionary == null)
{
dictionary = (HelpLibrary.m_characterProps = new Dictionary<DatabaseID, GameObject>());
}
return dictionary;
}
}
private static Dictionary<DatabaseID, GameObject> UnitBases
{
get
{
Dictionary<DatabaseID, GameObject> dictionary = HelpLibrary.m_unitBases;
if (dictionary == null)
{
dictionary = (HelpLibrary.m_unitBases = new Dictionary<DatabaseID, GameObject>());
}
return dictionary;
}
}
private static Dictionary<DatabaseID, Faction> Factions
{
get
{
Dictionary<DatabaseID, Faction> dictionary = HelpLibrary.m_factions;
if (dictionary == null)
{
dictionary = (HelpLibrary.m_factions = new Dictionary<DatabaseID, Faction>());
}
return dictionary;
}
}
private static Dictionary<DatabaseID, GameObject> Weapons
{
get
{
Dictionary<DatabaseID, GameObject> dictionary = HelpLibrary.m_weapons;
if (dictionary == null)
{
dictionary = (HelpLibrary.m_weapons = new Dictionary<DatabaseID, GameObject>());
}
return dictionary;
}
}
private static Dictionary<DatabaseID, GameObject> Projectiles
{
get
{
Dictionary<DatabaseID, GameObject> dictionary = HelpLibrary.m_projectiles;
if (dictionary == null)
{
dictionary = (HelpLibrary.m_projectiles = new Dictionary<DatabaseID, GameObject>());
}
return dictionary;
}
}
private static Dictionary<DatabaseID, UnitBlueprint> Units
{
get
{
Dictionary<DatabaseID, UnitBlueprint> dictionary = HelpLibrary.m_unitBlueprints;
if (dictionary == null)
{
dictionary = (HelpLibrary.m_unitBlueprints = new Dictionary<DatabaseID, UnitBlueprint>());
}
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<GameObject>(name);
}
catch (Exception ex)
{
Loader.LogError($"Exception found during loading object: {ex.ToString()}");
return null;
}
}
public static AudioClip LoBuAudioClip(string name)
{
return bundle.LoadAsset<AudioClip>(name);
}
public static Material LoBuMat(string name)
{
return bundle.LoadAsset<Material>(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<Faction>("m_isSecret", true);
faction.ForceSetField<Faction>("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<Faction>("m_isSecret", secret);
faction.ForceSetField<Faction>("m_lockSecrets", lockSecrets);
faction.m_FactionColor = color;
faction.index = index;
return faction;
}
public static Mesh LoBuMesh(string name)
{
return bundle.LoadAsset<Mesh>(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<UnitBlueprint>(unit);
DatabaseEntity val2 = new DatabaseEntity((WorkshopContentType)0);
int persistentUnitID = GetPersistentUnitID(name);
val2.GUID = new DatabaseID(-2, persistentUnitID);
OtherLibrary.SetField<UnitBlueprint>(val, "m_entity", (object)val2);
Dictionary<DatabaseID, UnitBlueprint> dictionary = (Dictionary<DatabaseID, UnitBlueprint>)OtherLibrary.GetField<LandfallContentDatabase>(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<LandfallContentDatabase>(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<UnitBlueprint> 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>((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<UnitBlueprint>(val3, "m_entity", (object)val4);
((Object)val3).name = name;
val3.m_props = null;
val3.RightWeapon = null;
val3.MovementComponents = new List<IMovementComponent> { (IMovementComponent)(object)default(KeepRangedDistance) };
ContentDatabase.Instance().AddUserUnitBlueprint(val3);
Dictionary<DatabaseID, UnitBlueprint> dictionary2 = (Dictionary<DatabaseID, UnitBlueprint>)OtherLibrary.GetField<LandfallContentDatabase>(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<LandfallContentDatabase>(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<UnitBlueprint> 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<string, int> 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<string> list = new List<string>();
list.Add("# Expansionary persistent unit IDs");
list.Add("# Unit Name<TAB>ID");
foreach (KeyValuePair<string, int> 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<string, int>(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<T>(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<T>(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<T>(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;
public float lerpAmount = 1000f;
public DelayEvent delayEvent;
private float peakTime;
private bool peakTriggered;
public float peakDuration = 0.1f;
private LineRenderer[] lineRenderers;
private SpellTarget spellTarget;
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 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<BoxCollider>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
((Component)componentsInChildren[i]).gameObject.SetActive(setActive);
}
}
private void Start()
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: 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_0082: 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_0092: 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_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)
lineRenderers = ((Component)this).GetComponentsInChildren<LineRenderer>(true);
spellTarget = ((Component)((Component)this).transform.root).GetComponentInChildren<SpellTarget>();
delayEvent = ((Component)this).GetComponentInChildren<DelayEvent>();
EnableDamage(setActive: false);
FindPeakTime();
LineRenderer[] array = lineRenderers;
foreach (LineRenderer val in array)
{
val.widthMultiplier = 0f;
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, spellTarget.rig.position, lerpAmount)
});
}
}
}
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<Unit, float> lastHitTime = new Dictionary<Unit, float>(128);
private readonly HashSet<Unit> activeUnits = new HashSet<Unit>();
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<TeamHolder>();
}
if (!Object.op_Implicit((Object)(object)unit))
{
unit = ((Component)((Component)this).transform.root).GetComponentInChildren<Unit>();
if (!Object.op_Implicit((Object)(object)unit) && Object.op_Implicit((Object)(object)teamHolder) && Object.op_Implicit((Object)(object)teamHolder.spawner))
{
unit = teamHolder.spawner.GetComponentInChildren<Unit>();
}
}
}
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<Unit>();
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<SoundPlayer>();
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<ParticlePlayer>();
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<GameObject>(((Component)EffectPrefab).gameObject, ((Component)componentInChildren).transform);
obj.transform.position = componentInChildren.data.mainRig.position;
UnitEffectBase componentInChildren3 = obj.GetComponentInChildren<UnitEffectBase>();
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<Unit>();
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<Unit>();
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;
}
}
}
}
public class CustomIceEffectBase : MonoBehaviour
{
public float dragPerAmount = 1f;
public float removeDragSpeed = 2f;
public Material iceMaterial;
private RigidbodyHolder rigHolder;
private WeaponHandler weaponHandler;
private Unit unit;
private DataHandler data;
private DragHandler dragHandler;
private UnitColorHandler colorHandler;
private bool deathFlag;
private void Start()
{
PlaySound();
Transform root = ((Component)this).transform.root;
unit = ((Component)root).GetComponentInChildren<Unit>();
data = ((Component)root).GetComponentInChildren<DataHandler>();
rigHolder = ((Component)root).GetComponentInChildren<RigidbodyHolder>();
dragHandler = ((Component)root).GetComponentInChildren<DragHandler>();
colorHandler = ((Component)root).GetComponentInChildren<UnitColorHandler>();
weaponHandler = ((Component)root).GetComponentInChildren<WeaponHandler>();
}
public void PlaySound()
{
PlaySoundEffect component = ((Component)this).GetComponent<PlaySoundEffect>();
if ((Object)(object)component != (Object)null)
{
component.Go();
}
}
private void Update()
{
if (!Object.op_Implicit((Object)(object)data))
{
return;
}
if (!data.Dead)
{
for (int i = 0; i < rigHolder.AllDrags.Length; i++)
{
if (rigHolder.AllDrags[i].x > rigHolder.defaultDrags[i].x)
{
Vector2[] allDrags = rigHolder.AllDrags;
int num = i;
allDrags[num].x = allDrags[num].x - Time.deltaTime * removeDragSpeed;
}
if (rigHolder.AllDrags[i].y > rigHolder.defaultDrags[i].y)
{
Vector2[] allDrags2 = rigHolder.AllDrags;
int num2 = i;
allDrags2[num2].y = allDrags2[num2].y - Time.deltaTime * removeDragSpeed;
}
}
if (Object.op_Implicit((Object)(object)dragHandler))
{
dragHandler.UpdateDrag();
}
}
else
{
if (!data.Dead)
{
return;
}
ReplaceAllMaterials();
if (!deathFlag)
{
float num3 = data.health / data.maxHealth;
for (int j = 0; j < rigHolder.AllDrags.Length; j++)
{
Vector2[] allDrags3 = rigHolder.AllDrags;
int num4 = j;
allDrags3[num4].x = allDrags3[num4].x + num3 * dragPerAmount;
Vector2[] allDrags4 = rigHolder.AllDrags;
int num5 = j;
allDrags4[num5].y = allDrags4[num5].y + num3 * dragPerAmount;
}
PlaySound();
StandardDeath();
deathFlag = true;
}
if (Object.op_Implicit((Object)(object)dragHandler))
{
dragHandler.UpdateDrag();
}
}
}
private void StandardDeath()
{
//IL_001d: 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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: 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_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
PlaySound();
Joint[] componentsInChildren = ((Component)((Component)this).transform.root).GetComponentsInChildren<Joint>();
float num = 0f;
Vector3 val = Vector3.zero;
for (int i = 0; i < componentsInChildren.Length; i++)
{
Object.Destroy((Object)(object)componentsInChildren[i]);
}
for (int j = 0; j < data.allRigs.AllRigs.Length; j++)
{
Rigidbody val2 = data.allRigs.AllRigs[j];
if (!((Object)(object)val2 == (Object)null))
{
num += val2.mass;
val += val2.velocity / (float)data.allRigs.AllDrags.Length;
Object.Destroy((Object)(object)val2);
}
}
ReplaceAllMaterials();
if (Object.op_Implicit((Object)(object)weaponHandler))
{
if (Object.op_Implicit((Object)(object)weaponHandler.leftWeapon) && Object.op_Implicit((Object)(object)weaponHandler.leftWeapon.rigidbody))
{
Object.Destroy((Object)(object)weaponHandler.leftWeapon.rigidbody);
}
if (Object.op_Implicit((Object)(object)weaponHandler.rightWeapon) && Object.op_Implicit((Object)(object)weaponHandler.rightWeapon.rigidbody))
{
Object.Destroy((Object)(object)weaponHandler.rightWeapon.rigidbody);
}
}
Rigidbody val3 = ((Component)((Component)data).transform.root).gameObject.AddComponent<Rigidbody>();
data.mainRig = val3;
val3.mass = num * 3f;
val3.velocity = val;
((Component)val3).gameObject.AddComponent<SinkOnDeath>().Sink();
val3.drag = 1f;
val3.angularDrag = 1f;
val3.interpolation = (RigidbodyInterpolation)1;
Collider component = ((Component)val3).GetComponent<Collider>();
if (Object.op_Implicit((Object)(object)component))
{
Object.Destroy((Object)(object)component);
}
val3.ResetCenterOfMass();
data.healthHandler.Die((Unit)null);
}
private void ReplaceAllMaterials()
{
if ((Object)(object)iceMaterial == (Object)null)
{
return;
}
Transform root = ((Component)this).transform.root;
MeshRenderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<MeshRenderer>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
if (!((Object)(object)componentsInChildren[i] == (Object)null))
{
Material[] sharedMaterials = ((Renderer)componentsInChildren[i]).sharedMaterials;
for (int j = 0; j < sharedMaterials.Length; j++)
{
sharedMaterials[j] = iceMaterial;
}
((Renderer)componentsInChildren[i]).sharedMaterials = sharedMaterials;
}
}
SkinnedMeshRenderer[] componentsInChildren2 = ((Component)root).GetComponentsInChildren<SkinnedMeshRenderer>(true);
for (int k = 0; k < componentsInChildren2.Length; k++)
{
if (!((Object)(object)componentsInChildren2[k] == (Object)null))
{
Material[] sharedMaterials2 = ((Renderer)componentsInChildren2[k]).sharedMaterials;
for (int l = 0; l < sharedMaterials2.Length; l++)
{
sharedMaterials2[l] = iceMaterial;
}
((Renderer)componentsInChildren2[k]).sharedMaterials = sharedMaterials2;
}
}
}
}
}