Decompiled source of ApproachGod v1.2.0
ApproachGod.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Xml; using ApproachGod.Approach; using ApproachGod.AssetManagement; using ApproachGod.TABSSimp; using BepInEx; using DM; using HarmonyLib; using Landfall.TABC; using Landfall.TABS; using Landfall.TABS.AI; using Landfall.TABS.AI.Components; using Landfall.TABS.AI.Components.Modifiers; using Landfall.TABS.AI.Systems; using Landfall.TABS.GameMode; using Landfall.TABS.GameState; using Landfall.TABS.UnitEditor; using Landfall.TABS.WinConditions; using Photon.Bolt; using Sirenix.Serialization; using TFBGames; using Unity.Entities; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.Rendering.PostProcessing; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ModdingForDummies")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ModdingForDummies")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("1619c49c-bc45-486c-bbca-6b52cef4f478")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] public class FlashSpeed : MonoBehaviour { public float speedMultiplier = 15f; private MovementHandler m_movementHandler; private DataHandler m_data; private float m_originalMultiplier; private void Start() { m_movementHandler = ((Component)((Component)this).transform.root).gameObject.GetComponentInChildren<MovementHandler>(); m_data = ((Component)((Component)this).transform.root).gameObject.GetComponentInChildren<DataHandler>(); m_originalMultiplier = m_movementHandler.multiplier; m_data.canFall = false; Balance componentInChildren = ((Component)((Component)this).transform.root).gameObject.GetComponentInChildren<Balance>(); componentInChildren.forceMultiplier = 10f; componentInChildren.allowedTorsoAngle = 180f; componentInChildren.allowedLegAngle = 180f; componentInChildren.allowedFootDistance = 180f; } private void FixedUpdate() { m_movementHandler.multiplier = (m_data.Dead ? m_originalMultiplier : (m_originalMultiplier * speedMultiplier)); } } namespace ApproachGod { [BepInPlugin("indeed.AbsurdWarriorsAdded", "Absurd Warriors Added", "1.1.1")] public class Launcher : BaseUnityPlugin { public Launcher() { Debug.Log((object)"Starting Absurd Warriors Added!"); AssetImporter.Initialize(); new Main(); } } public class Main : Mod { private string comment; public Main() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_050c: Unknown result type (might be due to invalid IL or missing references) //IL_063f: Unknown result type (might be due to invalid IL or missing references) //IL_0645: Unknown result type (might be due to invalid IL or missing references) //IL_065c: Unknown result type (might be due to invalid IL or missing references) //IL_0663: Expected O, but got Unknown //IL_0679: Unknown result type (might be due to invalid IL or missing references) //IL_06a7: Unknown result type (might be due to invalid IL or missing references) //IL_06b1: Unknown result type (might be due to invalid IL or missing references) //IL_06fa: Unknown result type (might be due to invalid IL or missing references) //IL_0704: Expected O, but got Unknown //IL_0775: Unknown result type (might be due to invalid IL or missing references) //IL_077b: Invalid comparison between Unknown and I4 //IL_07b9: Unknown result type (might be due to invalid IL or missing references) //IL_07c3: Expected O, but got Unknown //IL_092c: Unknown result type (might be due to invalid IL or missing references) //IL_0933: Expected O, but got Unknown //IL_0a37: Unknown result type (might be due to invalid IL or missing references) //IL_0b37: Unknown result type (might be due to invalid IL or missing references) //IL_0b6f: Unknown result type (might be due to invalid IL or missing references) //IL_0b76: Expected O, but got Unknown //IL_0b7d: Unknown result type (might be due to invalid IL or missing references) //IL_0be7: Unknown result type (might be due to invalid IL or missing references) //IL_0c03: Unknown result type (might be due to invalid IL or missing references) //IL_0c08: Unknown result type (might be due to invalid IL or missing references) //IL_0cc4: Unknown result type (might be due to invalid IL or missing references) //IL_0cc9: Unknown result type (might be due to invalid IL or missing references) //IL_0d7e: Unknown result type (might be due to invalid IL or missing references) //IL_0ec9: Unknown result type (might be due to invalid IL or missing references) //IL_0f1d: Unknown result type (might be due to invalid IL or missing references) //IL_0fb0: Unknown result type (might be due to invalid IL or missing references) //IL_0fc9: Unknown result type (might be due to invalid IL or missing references) //IL_0ff0: Unknown result type (might be due to invalid IL or missing references) //IL_0dea: Unknown result type (might be due to invalid IL or missing references) //IL_0df0: Invalid comparison between Unknown and I4 comment = "CHANGE THIS TO FALSE BEFORE RELEASING YOUR MOD!!!"; Mod.DEV_MODE = false; Harmony val = new Harmony("com.approach.immortalunit"); val.PatchAll(); 蓝图补丁.apply(val); ContentDatabase val2 = ContentDatabase.Instance(); Dictionary<DatabaseID, Object> dictionary = (Dictionary<DatabaseID, Object>)typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(val2.AssetLoader); LandfallContentDatabase landfallContentDatabase = val2.LandfallContentDatabase; GameObject combatMove = val2.LandfallContentDatabase.GetCombatMove(new DatabaseID(-1, 627043504)); ModMove modMove = new ModMove(combatMove); ModFaction modFaction = Mod.CreateFaction("ApproachGod"); ModUnit modUnit = modFaction.NewUnit("触"); modUnit.Icon = Mod.GetIcon("Torch"); ModMove move = Mod.GetMove("Reaper Wings"); modUnit.Cost = 100000; ModMove item = ReaperWC.CloneSkillWithNewScript(move, typeof(ReaperT)); modUnit.Moves.Add(item); modUnit.Moves.Add("Hover"); modUnit.Health = 100000f; ModWeapon modWeapon = Mod.CreateWeapon("天降爆炸", "Throw Dark Peasant"); ModProjectile modProjectile = Mod.CreateProjectile("爆炸雷电", "Zeus' Bolt"); modWeapon.Ranged.Projectile = modProjectile; modWeapon.internalObject.GetComponentInChildren<RangeWeapon>().positionOffset = new Vector3(0f, 20f, 0f); modWeapon.Ranged.ProjectileAmount = 18; modWeapon.Ranged.Spread = 60f; modProjectile.Explosion = Mod.GetExplosion("ReaperDeath"); ModUnit modUnit2 = modFaction.NewUnit("爆"); modUnit2.Icon = Mod.GetIcon("Zeus"); modUnit2.Cost = 6666; modUnit2.Health = 10000f; modUnit2.RightWeapon = modWeapon; modUnit2.LeftWeapon = modWeapon; ModUnit modUnit3 = modFaction.NewUnit("不死"); modUnit3.Icon = Mod.GetIcon("Wobbler"); ModBase modBase = Mod.CreateBase("不死之身", "Wobbler 2"); modBase.internalObject.AddComponent<NotDead>(); modUnit3.Base = modBase; modUnit3.Health = 666666f; modUnit3.Cost = 9999999; modUnit3.SizeRange = new Vector2(1f, 1f); ModUnit modUnit4 = modFaction.NewUnit("神触手"); modUnit4.Icon = Mod.GetIcon("Protector"); ModMove item2 = ReaperWC.CloneSkillWithNewScript(move, typeof(无视距离帧伤触手)); modUnit4.Health = 100000f; modUnit4.Mass = 50f; modUnit4.Moves.Add(item2); modUnit4.Cost = 114514; ModWeapon modWeapon2 = Mod.CreateWeapon("冰矛", "Spear Throw"); modWeapon2.internalObject.GetComponentInChildren<RangeWeapon>().spawnPosition = (SpawnPosition)1; ModProjectile modProjectile2 = Mod.CreateProjectile("bmpsw", "Spear"); ModExplosion modExplosion = Mod.CreateExplosion("BMBZ", "ExplosionSamuraiGiantStomp"); modProjectile2.Explosions.Add(modExplosion); modWeapon2.Ranged.Projectile = modProjectile2; modWeapon2.AttackSpeed = 1f; modWeapon2.internalObject.GetComponentInChildren<RangeWeapon>().positionOffset = new Vector3(0f, 5f, 0f); ModEffect modEffect = Mod.CreateEffect("bmbxg", "IceArrowEffect"); ((Component)modEffect.internalObject).GetComponentInChildren<Effect_IceArrow>().effectAmount = 200f; modExplosion.internalObject.AddComponent<ExplosionAddEffect>().EffectPrefab = modEffect.internalObject; ModUnit modUnit5 = modFaction.NewUnit("冰矛"); modUnit5.Health = 10000f; modUnit5.RightWeapon = modWeapon2; modUnit5.TwoHanded = false; modUnit5.Mass = 20f; ModWeapon modWeapon3 = Mod.CreateWeapon("tjsl", "Throw Dark Peasant"); ModProjectile modProjectile3 = Mod.CreateProjectile("tjdsl", "Zeus' Bolt"); ModExplosion modExplosion2 = Mod.CreateExplosion("slbz", "ExplosionSamuraiGiantStomp"); ApplyMapGroundMaterial[] componentsInChildren = modExplosion2.internalObject.GetComponentsInChildren<ApplyMapGroundMaterial>(true); ApplyMapGroundMaterial[] array = componentsInChildren; foreach (ApplyMapGroundMaterial val3 in array) { ((Behaviour)val3).enabled = false; } modExplosion2.Color(new Color(1f, 0f, 1f), 0.8f); float radius = modExplosion2.internalObject.GetComponentInChildren<Explosion>().radius; modExplosion2.internalObject.GetComponentInChildren<Explosion>().radius = radius * 5f; ModEffect modEffect2 = Mod.CreateEffect("slbzkj", "Fear"); modExplosion2.internalObject.AddComponent<ExplosionAddEffect>().EffectPrefab = modEffect2.internalObject; modProjectile3.Explosions.Clear(); modProjectile3.Explosions.Add(modExplosion2); modWeapon3.internalObject.GetComponentInChildren<RangeWeapon>().spawnPosition = (SpawnPosition)1; modWeapon3.internalObject.GetComponentInChildren<RangeWeapon>().positionOffset = new Vector3(0f, 15f, 0f); modWeapon3.internalObject.GetComponentInChildren<RangeWeapon>().useRandomDelay = false; modWeapon3.internalObject.GetComponentInChildren<RangeWeapon>().maxProjectilesPerFrane = 30; modWeapon3.internalObject.GetComponentInChildren<RangeWeapon>().delayPerSpawn = 0f; modProjectile3.Explosions.Add(modExplosion2); modWeapon3.Ranged.Projectile = modProjectile3; modWeapon3.Ranged.Spread = 10f; modWeapon3.Ranged.ProjectileAmount = 30; ModUnit modUnit6 = modFaction.NewUnit("BMKL"); modUnit6.Health = 70000f; modUnit6.Size = 1.4f; modUnit6.RightWeapon = Mod.CreateWeapon("bmzq", "Ice Giant Punch"); modUnit6.RightWeapon.Damage = 8000f; modUnit6.LeftWeapon = modWeapon3; modUnit6.Mass = 50f; modUnit6.Moves.Add("Knight Charge", "Giant Foot Stomp", "Big Headbutt"); modUnit6.internalObject.MovementComponents.Clear(); modUnit6.internalObject.MovementComponents.Add((IMovementComponent)(object)default(NeverStopRunning)); Material val4 = new Material(Shader.Find("Standard")); val4.SetColor("_Color", new Color(1f, 0f, 1f)); val4.EnableKeyword("_EMISSION"); val4.SetColor("_EmissionColor", new Color(1f, 0f, 1f) * 1f); ParticleSystemRenderer[] componentsInChildren2 = modExplosion2.internalObject.GetComponentsInChildren<ParticleSystemRenderer>(); foreach (ParticleSystemRenderer val5 in componentsInChildren2) { List<Material> list = new List<Material>(); Material[] materials = ((Renderer)val5).materials; foreach (Material val6 in materials) { list.Add(new Material(val4)); } ((Renderer)val5).materials = list.ToArray(); } ModMove modMove2 = Mod.CreateMove("cjjsgd", "Teacher Parry"); ConditionalEvent component = modMove2.internalObject.GetComponent<ConditionalEvent>(); ConditionalEventInstance val7 = component.events[0]; EventCondition[] conditions = val7.conditions; foreach (EventCondition val8 in conditions) { if ((int)val8.conditionType == 0) { val8.value = 0f; val8.extraRandomCooldown = 0f; val8.counter = 0f; break; } } ModMove modMove3 = new ModMove(new GameObject()); modMove3.internalObject.AddComponent<防高频碰撞>(); ModWeapon rightWeapon = Mod.CreateWeapon("剑1", "Teacher Sword"); ModUnit modUnit7 = modFaction.NewUnit("格挡"); modUnit7.Health = 1000f; modUnit7.RightWeapon = rightWeapon; modUnit7.Moves.Add(modMove2, modMove3); ModUnit modUnit8 = modFaction.NewUnit("加强冰巨", "Ice Giant"); modUnit8.Moves.Clear(); ModWeapon modWeapon4 = Mod.CreateWeapon("bq", "Ice Giant Punch"); ModExplosion modExplosion3 = Mod.CreateExplosion("bjqjbz", "ExplosionIceGiant"); ModEffect modEffect3 = Mod.CreateEffect("bingjubing", "IceArrowEffect"); float effectAmount = ((Component)modEffect3.internalObject).GetComponentInChildren<Effect_IceArrow>().effectAmount; ((Component)modEffect3.internalObject).GetComponentInChildren<Effect_IceArrow>().effectAmount = effectAmount * 10f; modExplosion3.internalObject.AddComponent<ExplosionAddEffect>().EffectPrefab = modEffect3.internalObject; modWeapon4.Explosion = modExplosion3; modUnit8.RightWeapon = modWeapon4; modUnit8.LeftWeapon = modWeapon4; modUnit8.Health = 16000f; ModUnit modUnit9 = modFaction.NewUnit("光速"); ModBase modBase2 = Mod.CreateBase("gsst", "Wobbler 2"); modBase2.internalObject.AddComponent<光速>(); modUnit9.Health = 3000f; modUnit9.Base = modBase2; GameObject val9 = new GameObject(); ConditionalEvent val10 = val9.AddComponent<ConditionalEvent>(); val9.AddComponent<全图冰冻配置>(); ModMove modMove4 = new ModMove(val9); ModUnit modUnit10 = modFaction.NewUnit("冰神"); modUnit10.Health = 6000f; modUnit10.Moves.Add(modMove4, modMove); modUnit10.RightWeapon = Mod.GetWeapon("Ice King Sword"); modUnit10.TwoHanded = true; modUnit10.Mass = 4f; ModFaction modFaction2 = Mod.CreateFaction("Above God"); ModBase modBase3 = Mod.CreateBase("超越", "Wobbler 2"); modBase3.internalObject.AddComponent<NotDead>(); modBase3.internalObject.AddComponent<ForcedVictory>(); ModUnit modUnit11 = modFaction2.NewUnit("嘘"); modUnit11.Icon = Mod.GetIcon("Shouter"); modUnit11.Base = modBase3; modUnit11.Cost = int.MaxValue; modUnit11.Health = 114514f; modUnit11.SizeRange = new Vector2(1f, 1f); ModUnit modUnit12 = modFaction2.NewUnit("逆天"); modUnit12.Icon = Mod.GetIcon("Wheat Wobbler"); ModBase modBase4 = Mod.CreateBase("逆天模型", "Wobbler 2"); modBase4.internalObject.AddComponent<NotDead>(); modBase4.internalObject.AddComponent<UpdateKill>(); modUnit12.Base = modBase4; modUnit12.Health = float.PositiveInfinity; modUnit12.Cost = int.MaxValue; ModUnit modUnit13 = modFaction2.NewUnit("黑暗"); modUnit13.Icon = Mod.GetIcon("Dark Peasent"); ModWeapon modWeapon5 = Mod.CreateWeapon("暗黑打击", "Throw Dark Peasant"); ModProjectile modProjectile4 = Mod.CreateProjectile("ahbz", "Dark Peasant 2"); ModProjectile modProjectile5 = Mod.CreateProjectile("ahbz2", "Dark Peasant 2"); ModExplosion modExplosion4 = Mod.CreateExplosion("暗黑爆炸3", "ExplosionTreeGiant"); modProjectile4.Explosions.Clear(); ModExplosion modExplosion5 = Mod.CreateExplosion("habd", "ExplosionIceGiant"); modExplosion5.Color(Color.black); modExplosion5.Size = 10f; ModEffect modEffect4 = Mod.CreateEffect("ahbd", "IceArrowEffect"); Material val11 = new Material(Shader.Find("Standard")); val11.SetColor("_Color", Color.black); ((Component)modEffect4.internalObject).GetComponentInChildren<Effect_IceArrow>().effectAmount = 1000000f; ((Component)modEffect4.internalObject).GetComponentInChildren<Effect_IceArrow>().iceMaterial = val11; modExplosion5.internalObject.AddComponent<ExplosionAddEffect>().EffectPrefab = modEffect4.internalObject; modProjectile4.Explosions.Add(modExplosion5); modExplosion4.Damage = float.PositiveInfinity; modExplosion4.Color(Color.black, 0.8f); modProjectile5.internalObject.AddComponent<FixedDirectionProjectile>().fixedDirection = Vector3.down; modProjectile5.Explosions.Add(modExplosion4); ModExplosion modExplosion6 = new ModExplosion(modProjectile5.internalObject); ModMove modMove5 = ReaperWC.CloneSkillWithNewScript(move, typeof(无视距离帧伤触手)); modMove5.internalObject.GetComponentInChildren<无视距离帧伤触手>().baseAttackCooldown = 1f; modMove5.internalObject.GetComponentInChildren<无视距离帧伤触手>().attackAnimationDuration = 1f; modMove5.internalObject.GetComponentInChildren<无视距离帧伤触手>().simultaneousAttacks = 1; modMove5.internalObject.GetComponentInChildren<无视距离帧伤触手>().attackDamage = float.PositiveInfinity; modMove5.internalObject.GetComponentInChildren<无视距离帧伤触手>().explosionPrefab = modExplosion6.internalObject; modWeapon5.internalObject.GetComponentInChildren<RangeWeapon>().positionOffset = new Vector3(0f, 30f, 0f); modWeapon5.Ranged.ProjectileAmount = 1; modWeapon5.AttackSpeed = 1f; modUnit13.Health = float.PositiveInfinity; modUnit13.Cost = 9999999; modUnit13.Mass = float.PositiveInfinity; modUnit13.RightWeapon = modWeapon5; modUnit13.LeftWeapon = modWeapon5; modUnit13.internalObject.damageMultiplier = 100f; modWeapon5.Ranged.Projectile = modProjectile4; modUnit13.Moves.Add(Mod.GetMove("Dark Peasant Hands")); modUnit13.Moves.Add(modMove5); ModMove modMove6 = Mod.CreateMove("瞬移", "Assassin Poof"); modMove6.Color(Color.white); ConditionalEvent component2 = modMove6.internalObject.GetComponent<ConditionalEvent>(); ModUnit modUnit14 = modFaction2.NewUnit("伪神"); if ((Object)(object)component2 != (Object)null) { ConditionalEventInstance[] events = component2.events; foreach (ConditionalEventInstance val12 in events) { EventCondition[] conditions2 = val12.conditions; foreach (EventCondition val13 in conditions2) { if ((int)val13.conditionType == 0) { val13.value = 2f; } } } } modUnit14.Health = float.MaxValue; ModWeapon modWeapon6 = Mod.CreateWeapon("zq", "Ballooner Grab"); ModExplosion modExplosion7 = Mod.CreateExplosion("zqbz", "ExplosionIceGiant"); modExplosion7.internalObject.AddComponent<ExplosionAddEffect>().EffectPrefab = Mod.GetEffect("IceBreathEffect").internalObject; modExplosion7.internalObject.AddComponent<免疫友军>(); modWeapon6.Explosion = modExplosion7; modExplosion7.Damage = float.PositiveInfinity; int num = 5; for (int num2 = 0; num2 < num; num2++) { MeleeWeaponSpawn val14 = modWeapon6.internalObject.AddComponent<MeleeWeaponSpawn>(); val14.objectToSpawn = modExplosion7.internalObject; ((Behaviour)val14).enabled = true; val14.pos = (Pos)1; val14.cd = 0f; } ModBase modBase5 = Mod.CreateBase("bsdssx", "Wobbler 2"); modBase5.internalObject.GetComponentInChildren<HealthHandler>().SetInvulnerable(true); modUnit14.SizeRange = new Vector2(1f, 1f); modUnit14.Cost = 0; modUnit14.Moves.Add(modMove6); modUnit14.RightWeapon = modWeapon6; modUnit14.LeftWeapon = modWeapon6; ModMove modMove7 = Mod.CreateMove("超级不死", "Self Copy"); Object.Destroy((Object)(object)modMove7.internalObject.GetComponent<AddMeleeCopy>()); GameObject internalObject = modMove7.internalObject; CharacterItem component3 = internalObject.GetComponent<CharacterItem>(); internalObject.AddComponent<NeverDie>(); component3.Entity.Name = "接近神之不死"; component3.Entity.GUID = new DatabaseID(5, -1145171); component3.tags[0] = new Tag((TagType)0, "接近神"); Dictionary<DatabaseID, GameObject> dictionary2 = (Dictionary<DatabaseID, GameObject>)landfallContentDatabase.GetField<LandfallContentDatabase>("m_combatMoves"); dictionary2.Add(component3.Entity.GUID, ((Component)component3).gameObject); ModUnit modUnit15 = modFaction2.NewUnit("真·不死"); modUnit15.Moves.Add(new ModMove(internalObject)); ModMove modMove8 = Mod.CreateMove("极速", "Self Copy"); Object.Destroy((Object)(object)modMove8.internalObject.GetComponent<AddMeleeCopy>()); modMove8.internalObject.AddComponent<FlashSpeed>(); ModUnit modUnit16 = modFaction.NewUnit("极速"); modUnit16.Speed = 3f; modUnit16.TurnSpeed *= 5f; modUnit16.RightWeapon = Mod.GetWeapon("Super Boxer's Glove"); modUnit16.LeftWeapon = Mod.GetWeapon("Super Boxer's Glove"); modUnit16.Health = 5000f; modUnit16.Moves.Add(modMove8); ModMove modMove9 = Mod.CreateMove("放置抹杀", "Self Copy"); Object.Destroy((Object)(object)modMove9.internalObject.GetComponent<AddMeleeCopy>()); modMove9.internalObject.AddComponent<放置抹杀>(); ModUnit modUnit17 = modFaction2.NewUnit("放置抹杀"); modUnit17.Moves.Add(modMove9); ModMove modMove10 = Mod.CreateMove("开战秒杀", "Self Copy"); Object.Destroy((Object)(object)modMove10.internalObject.GetComponent<AddMeleeCopy>()); modMove10.internalObject.AddComponent<开战秒杀>(); ModUnit modUnit18 = modFaction2.NewUnit("开战秒杀"); modUnit18.Moves.Add(modMove7); modUnit18.Moves.Add(modMove10); } } public static class Utilities { private static readonly string[] sanitizationFilter; private static readonly Dictionary<GearType, string[]> boneDictionary; public static readonly Quaternion blenderToUnity; public static readonly string rootPath; public static Dictionary<string, string> language; public static readonly ContentDatabase fullDatabase; public static readonly LandfallContentDatabase database; public static Explosion[] explosions; public static UnitEffectBase[] effects; public static Sprite[] sprites; public static readonly ModExplosion unitSpawner; public static readonly ModFaction baseFaction; static Utilities() { //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Expected O, but got Unknown //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) sanitizationFilter = new string[33] { "Icon_Legacy_", "Icons_128x128_", "Icons_", "Icon_", "CP_", "P_", "E_", " Prefabs_VB", " Effects_VB", "_1", "_2", "_3", " (1)", " (2)", " (3)", " (4)", " (5)", " (6)", "B_", "Move_", "Leg_", "1_", "12_", "15_", "6__", "7_", "14_", "2_", "8_", "10_", "16_", "5_", "3_" }; boneDictionary = new Dictionary<GearType, string[]> { { (GearType)0, new string[1] { "M_Head" } }, { (GearType)1, new string[1] { "M_Neck" } }, { (GearType)2, new string[2] { "M_Shoulder_Right", "M_Shoulder_Left" } }, { (GearType)3, new string[1] { "M_Torso" } }, { (GearType)4, new string[2] { "M_Arm_Right", "M_Arm_Left" } }, { (GearType)5, new string[2] { "M_Wrist_Right", "M_Wrist_Left" } }, { (GearType)7, new string[1] { "M_Waist" } }, { (GearType)8, new string[2] { "M_Leg_Right", "M_Leg_Left" } }, { (GearType)9, new string[2] { "M_Foot_Right", "M_Foot_Left" } } }; blenderToUnity = Quaternion.Euler(-90f, 0f, 0f); rootPath = Directory.GetParent(Assembly.GetExecutingAssembly().Location)?.ToString(); language = Localizer.GetLanguage((Language)0); fullDatabase = ContentDatabase.Instance(); database = ContentDatabase.Instance().LandfallContentDatabase; explosions = Resources.FindObjectsOfTypeAll<Explosion>(); effects = Resources.FindObjectsOfTypeAll<UnitEffectBase>(); sprites = Resources.FindObjectsOfTypeAll<Sprite>(); unitSpawner = new ModExplosion(Mod.PoolObject(new GameObject("UnitSpawner", new Type[1] { typeof(UnitSpawner) }))); List<string> source = (from z in (from z in language group z by z.Value into z where z.Count() > 1 select z).SelectMany((IGrouping<string, KeyValuePair<string, string>> z) => z) select z.Key).ToList(); Dictionary<string, int> dictionary = new Dictionary<string, int>(); foreach (string item in source.Where((string v) => language[v] != null && language[v] != string.Empty)) { if (!dictionary.ContainsKey(language[item])) { dictionary.Add(language[item], 1); continue; } dictionary[language[item]]++; language[item] = language[item] + " " + dictionary[language[item]]; } Faction val = Object.Instantiate<Faction>(GetFaction("Medieval")); val.Entity.GenerateNewID(); val.Entity.Name = "Base Faction"; val.Units = Array.Empty<UnitBlueprint>(); val.index = database.GetFactions().ToList().Count; val.m_FactionColor = HexColor("#888888"); val.m_displayFaction = false; AddFactionToDatabase(val); baseFaction = new ModFaction(val); if (Mod.DEV_MODE) { string text = Path.Combine(rootPath, "MFDPrints"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } string contents = string.Join(Environment.NewLine, from GameObject weapon in database.GetWeapons() where (Object)(object)weapon != (Object)null select GetProperName(((CharacterItem)weapon.GetComponentInChildren<WeaponItem>()).Entity.Name)); File.WriteAllText(Path.Combine(text, "weapons.txt"), contents); string contents2 = string.Join(Environment.NewLine, from GameObject unitBase in database.GetUnitBases() where (Object)(object)unitBase != (Object)null select GetProperName(unitBase.GetComponentInChildren<Unit>().Entity.Name)); File.WriteAllText(Path.Combine(text, "bases.txt"), contents2); string contents3 = string.Join(Environment.NewLine, from GameObject clothing in database.GetCharacterProps() where (Object)(object)clothing != (Object)null select GetProperName(((CharacterItem)clothing.GetComponentInChildren<PropItem>()).Entity.Name)); File.WriteAllText(Path.Combine(text, "clothing.txt"), contents3); string contents4 = string.Join(Environment.NewLine, from IDatabaseEntity unit in database.GetUnitBlueprints() select GetProperName(unit.Entity.Name)); File.WriteAllText(Path.Combine(text, "unit.txt"), contents4); string contents5 = string.Join(Environment.NewLine, from IDatabaseEntity faction in database.GetFactions() select GetProperName(faction.Entity.Name)); File.WriteAllText(Path.Combine(text, "factions.txt"), contents5); string contents6 = string.Join(Environment.NewLine, from Explosion explosion in explosions where (Object)(object)explosion != (Object)null select GetProperName(((Object)((Component)explosion).gameObject).name)); File.WriteAllText(Path.Combine(text, "explosions.txt"), contents6); string contents7 = string.Join(Environment.NewLine, from UnitEffectBase effect in effects where (Object)(object)effect != (Object)null select GetProperName(((Object)((Component)effect).gameObject).name)); File.WriteAllText(Path.Combine(text, "effects.txt"), contents7); string contents8 = string.Join(Environment.NewLine, from GameObject projectile in database.GetProjectiles() select GetProperName(projectile.GetComponentInChildren<ProjectileEntity>().Entity.Name)); File.WriteAllText(Path.Combine(text, "projectiles.txt"), contents8); string contents9 = string.Join(Environment.NewLine, from GameObject move in database.GetCombatMoves() select GetProperName(((CharacterItem)move.GetComponentInChildren<SpecialAbility>()).Entity.Name)); File.WriteAllText(Path.Combine(text, "moves.txt"), contents9); string contents10 = string.Join(Environment.NewLine, from FactionIcon icon in fullDatabase.GetFactionIcons() select GetProperName(icon.Entity.Name)); File.WriteAllText(Path.Combine(text, "icons.txt"), contents10); string contents11 = string.Join(Environment.NewLine, from Sprite icon in Resources.FindObjectsOfTypeAll<Sprite>() select GetProperName(((Object)icon).name)); File.WriteAllText(Path.Combine(text, "iconsExtra.txt"), contents11); } } public static object CallMethod(this object o, string methodName, params object[] args) { MethodInfo method = o.GetType().GetMethod(methodName, (BindingFlags)(-1)); if (method != null) { return method.Invoke(o, args); } Debug.Log((object)("Call Method " + methodName + " nulled")); return null; } public static object GetField<T>(this T instance, string fieldName, BindingFlags flags = (BindingFlags)(-1)) { FieldInfo field = typeof(T).GetField(fieldName, flags); try { field.GetValue(instance); } catch { Debug.Log((object)$"(GetField) Failed to get field '{fieldName}' for object '{typeof(T)}'. Try using manual BindingFlags."); } return field.GetValue(instance); } public static void SetField<T>(this T instance, string fieldName, object newValue, BindingFlags flags = (BindingFlags)(-1)) { FieldInfo field = typeof(T).GetField(fieldName, flags); Debug.Log((object)field); try { field.SetValue(instance, newValue); } catch { Debug.Log((object)$"(SetField) Failed to set field '{fieldName}' for object '{typeof(T)}'. Try using manual BindingFlags."); } } public static Transform SetHideFlagsChildren(this Transform t, HideFlags hf = (HideFlags)52) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)((Component)t).gameObject)) { ((Object)((Component)t).gameObject).hideFlags = hf; } if (t.childCount > 0) { for (int i = 0; i < t.childCount; i++) { t.GetChild(i).SetHideFlagsChildren(hf); } } return t; } public static Sprite CreateSprite(string path) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(path)) { return null; } if (!File.Exists(path)) { return null; } byte[] array = File.ReadAllBytes(path); Texture2D val = new Texture2D(1, 1); ImageConversion.LoadImage(val, array); ((Texture)val).filterMode = (FilterMode)0; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f), 1f); } public static bool NullCheck(this object self, string flag = "Object") { Debug.Log((object)("[NULLCHECK] " + flag + " is " + ((self == null) ? "NULL" : "REAL") + "!")); return self == null; } public static T GetResourcesObj<T>(string obj) { Object[] source = Resources.FindObjectsOfTypeAll(typeof(T)); return (T)(object)((IEnumerable<Object>)source).FirstOrDefault((Func<Object, bool>)((Object x) => x.name.Contains(obj))); } public static string IncrementName(string name) { return name.Contains(";") ? (name.Split(new char[1] { ';' })[0] + int.Parse(name.Split(new char[1] { ';' })[1]) + 1) : (name + ";1"); } public static void ForEach<T>(this IEnumerable<T> collection, Action<T> action) { foreach (T item in collection) { action(item); } } public static void ForEach<T>(this T[] array, Action<T> action) { foreach (T obj in array) { action(obj); } } public static Dictionary<V, U> Reverse<U, V>(this Dictionary<U, V> self) { Dictionary<V, U> dictionary = new Dictionary<V, U>(); foreach (U key in self.Keys) { dictionary[self[key]] = key; } return dictionary; } public static Color HexColor(string hexCode) { //IL_002c: 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_0030: Unknown result type (might be due to invalid IL or missing references) hexCode = (hexCode.StartsWith("#") ? hexCode : ("#" + hexCode)).ToUpper(); Color result = default(Color); ColorUtility.TryParseHtmlString(hexCode, ref result); return result; } public static T FindVanillaObject<T>(IEnumerable<T> source, string name, Func<T, string> getName) { return source.FirstOrDefault((T o) => name == GetProperName(getName(o))); } public static string GetProperName(string name) { string text = null; if (language.ContainsKey(name)) { text = language[name]; } else { text = name; string[] array = sanitizationFilter; foreach (string oldValue in array) { text = text.Replace(oldValue, ""); } } return text; } public static string DeepString(this GameObject self) { string text = "\nGameObject '" + ((Object)self).name + "':\n{\n\tComponents:\n\t{\n"; text = string.Concat(text, string.Concat(from Component component in self.GetComponents<Component>() select "\t\t" + ((object)component).GetType().Name + "\n")); text += "\t}\n"; if (self.transform.childCount > 0) { text += "\tChildren:\n\t{\n"; text = string.Concat(text, string.Concat(from Transform child in (IEnumerable)self.transform select ((Component)child).gameObject.DeepString().Replace("\n", "\n\t\t"))); text += "\n\t}\n"; } return text + "}\n"; } public static void PlaceMeshOnBone(SkinnedMeshRenderer renderer, GameObject mesh, GearType gearType) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) string text = boneDictionary[gearType][0]; Transform[] bones = renderer.bones; foreach (Transform val in bones) { if (((Object)val).name == text) { mesh.transform.parent = ((Component)val).transform; mesh.transform.localPosition = Vector3.zero; mesh.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f); } } } public static void SetMeshRenderers(GameObject gameObject, bool enabled) { Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>(); for (int i = 0; i < componentsInChildren.Length; i++) { Type type = ((object)componentsInChildren[i]).GetType(); if (type == typeof(MeshRenderer) || type == typeof(SkinnedMeshRenderer)) { componentsInChildren[i].enabled = enabled; } } } public static void SetObjectColor(GameObject colorObject, int index, Color color, float glow) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_0182: Unknown result type (might be due to invalid IL or missing references) Renderer[] bestRenderers = GetBestRenderers(colorObject); Renderer bestRenderer = GetBestRenderer(colorObject); bool flag = (Object)(object)colorObject.GetComponentInChildren<LODGroup>() != (Object)null; Dictionary<Color, Material> dictionary = new Dictionary<Color, Material>(); Material[] materials = bestRenderer.materials; Material val = new Material(Shader.Find("Standard")); val.color = color; if (glow > 0f) { val.EnableKeyword("_EMISSION"); val.SetColor("_EmissionColor", val.color * glow); } val.SetFloat("_Glossiness", 0f); if (!Object.op_Implicit((Object)(object)bestRenderer)) { return; } for (int i = 0; i < materials.Length; i++) { if (i == index) { dictionary[materials[i].color] = val; } } if (bestRenderers == null || bestRenderers.Length == 0) { return; } if (flag) { Renderer[] array = bestRenderers; foreach (Renderer val2 in array) { List<TeamColor> source = ((Component)val2).GetComponents<TeamColor>().ToList(); List<TeamColor> removed = new List<TeamColor>(); Material[] materials2 = val2.materials; List<Material> list = new List<Material>(); int k; for (k = 0; k < materials2.Length; k++) { Material val3 = null; if (dictionary.ContainsKey(materials2[k].color)) { val3 = dictionary[materials2[k].color]; } if ((Object)(object)val3 != (Object)null) { list.Add(val3); foreach (TeamColor item in source.Where((TeamColor tc) => !removed.Contains(tc) && tc.materialID == k)) { removed.Add(item); Object.DestroyImmediate((Object)(object)item); } } else { list.Add(materials2[k]); } } val2.materials = list.ToArray(); } return; } int num = 0; Renderer[] array2 = bestRenderers; foreach (Renderer val4 in array2) { Material[] materials3 = val4.materials; List<TeamColor> list2 = ((Component)val4).GetComponents<TeamColor>().ToList(); for (int num3 = 0; num3 < materials3.Length; num3++) { if (num + num3 != index) { continue; } materials3[num3] = val; foreach (TeamColor item2 in list2) { if (item2.materialID == num3) { Object.DestroyImmediate((Object)(object)item2); } } } num++; val4.materials = materials3; } } public static void SetClothScale(ModClothing clothing, Vector3 scale) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) GameObject internalObject = clothing.internalObject; if ((Object)(object)internalObject.GetComponentInChildren<MeshRenderer>() != (Object)null) { MeshRenderer[] componentsInChildren = internalObject.GetComponentsInChildren<MeshRenderer>(); foreach (MeshRenderer val in componentsInChildren) { ((Component)val).transform.localScale = scale; } } if (!((Object)(object)internalObject.GetComponentInChildren<SkinnedMeshRenderer>() != (Object)null)) { return; } Vector3 localScale = internalObject.transform.localScale; SkinnedMeshRenderer[] componentsInChildren2 = internalObject.GetComponentsInChildren<SkinnedMeshRenderer>(); foreach (SkinnedMeshRenderer val2 in componentsInChildren2) { val2.sharedMesh = Object.Instantiate<Mesh>(val2.sharedMesh); Mesh sharedMesh = val2.sharedMesh; ((Object)sharedMesh).name = clothing.Name + "sharedmesh"; Vector3[] vertices = sharedMesh.vertices; if (vertices == null) { vertices = sharedMesh.vertices; } Debug.Log((object)("baseVertices " + vertices.Length)); Vector3[] array = (Vector3[])(object)new Vector3[vertices.Length]; for (int k = 0; k < array.Length; k++) { Vector3 val3 = vertices[k]; val3.x /= localScale.x; val3.y /= localScale.y; val3.z /= localScale.z; val3.x *= scale.x; val3.y *= scale.y; val3.z *= scale.z; array[k] = val3; } internalObject.transform.localScale = scale; sharedMesh.vertices = array; sharedMesh.RecalculateBounds(); val2.sharedMesh = sharedMesh; } } public static Renderer GetBestRenderer(GameObject gameObject, Type rendererType = null) { if (rendererType == null) { rendererType = typeof(Renderer); } else if (!rendererType.IsSubclassOf(typeof(Renderer))) { return null; } Renderer val = null; Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>(); bool flag = false; Renderer[] array = componentsInChildren; foreach (Renderer val2 in array) { if (((object)val2).GetType() == rendererType || rendererType == typeof(Renderer)) { string name = ((Object)((Component)val2).gameObject).name; if (name.Contains("LOD0")) { val = val2; flag = true; } else if (name.Contains("CP_") && !flag) { val = val2; flag = true; } else if (name.ToLower().Contains(((Object)gameObject.gameObject).name.ToLower()) && !flag) { val = val2; } else if (!Object.op_Implicit((Object)(object)val) && name != "RightHand" && name != "LeftHand" && !flag) { val = val2; } } } return val; } public static Renderer[] GetBestRenderers(GameObject gameObject, Type rendererType = null) { if (rendererType == null) { rendererType = typeof(Renderer); } else if (!rendererType.IsSubclassOf(typeof(Renderer))) { return null; } Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>(); List<Renderer> list = new List<Renderer>(); bool flag = false; LODGroup componentInChildren = gameObject.GetComponentInChildren<LODGroup>(); if (Object.op_Implicit((Object)(object)componentInChildren)) { flag = true; list.AddRange(componentInChildren.GetLODs().SelectMany((LOD lod) => lod.renderers)); } Renderer[] array = componentsInChildren; foreach (Renderer val in array) { if (!list.Contains(val) && (((object)val).GetType() == rendererType || rendererType == typeof(Renderer))) { string name = ((Object)gameObject).name; if (name.Contains("LOD") && ((Object)((Component)val).transform.parent).name.ToLower().Contains("base")) { list.Add(val); flag = true; } else if (name.Contains("LOD")) { list.Add(val); flag = true; } else if (name.Contains("CP_") && !flag) { list.Add(val); flag = true; } else if (name.ToLower().Contains(((Object)gameObject).name.ToLower()) && !flag) { list.Add(val); } else if (list.Count <= 0 && name != "RightHand" && name != "LeftHand" && !flag) { list.Add(val); } } } return list.ToArray(); } public static GameObject GetUnitBase(string name) { return FindVanillaObject(database.GetUnitBases(), name, (GameObject ub) => ub.GetComponentInChildren<Unit>().Entity.Name); } public static GameObject GetClothing(string name) { return FindVanillaObject(database.GetCharacterProps(), name, (GameObject c) => ((CharacterItem)c.GetComponentInChildren<PropItem>()).Entity.Name); } public static GameObject GetWeapon(string name) { return FindVanillaObject(database.GetWeapons(), name, (GameObject w) => ((CharacterItem)w.GetComponentInChildren<WeaponItem>()).Entity.Name); } public static GameObject GetMove(string name) { return FindVanillaObject(database.GetCombatMoves(), name, (GameObject m) => ((CharacterItem)m.GetComponentInChildren<SpecialAbility>()).Entity.Name); } public static GameObject GetProjectile(string name) { GameObject gameObject = FindVanillaObject(database.GetProjectiles(), name, (GameObject p) => p.GetComponent<ProjectileEntity>().Entity.Name).gameObject; return ((Object)(object)gameObject != (Object)null) ? gameObject.gameObject : null; } public static GameObject GetExplosion(string name) { Explosion val = FindVanillaObject(explosions, name, (Explosion e) => ((Object)((Component)e).gameObject).name); return ((Object)(object)val != (Object)null) ? ((Component)val).gameObject : null; } public static UnitEffectBase GetEffect(string name) { return FindVanillaObject(effects, name, (UnitEffectBase e) => ((Object)((Component)e).gameObject).name); } public static Sprite GetIcon(string name) { FactionIcon val = FindVanillaObject(fullDatabase.GetFactionIcons(), name, (FactionIcon i) => i.Entity.Name); if ((Object)(object)val != (Object)null) { return val.Entity.SpriteIcon; } Sprite val2 = FindVanillaObject(AssetImporter.Sprites, name, (Sprite s) => ((Object)s).name); if ((Object)(object)val2 != (Object)null) { return val2; } return FindVanillaObject(sprites, name, (Sprite s) => ((Object)s).name); } public static UnitBlueprint GetUnit(string name) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) UnitBlueprint val = FindVanillaObject(database.GetUnitBlueprints(), name, (UnitBlueprint u) => u.Entity.Name); return ((Object)(object)val != (Object)null) ? database.GetUnitBlueprint(val.Entity.GUID) : null; } public static Faction GetFaction(string name) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) Faction val = FindVanillaObject(database.GetFactions(), name, (Faction f) => f.Entity.Name); return ((Object)(object)val != (Object)null) ? database.GetFaction(val.Entity.GUID) : null; } public static void AddUnitToDatabase(UnitBlueprint unit) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) Dictionary<DatabaseID, Object> dictionary = (Dictionary<DatabaseID, Object>)typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(fullDatabase.AssetLoader); Dictionary<DatabaseID, UnitBlueprint> dictionary2 = (Dictionary<DatabaseID, UnitBlueprint>)typeof(LandfallContentDatabase).GetField("m_unitBlueprints", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(database); if (!dictionary2.ContainsKey(unit.Entity.GUID)) { dictionary2.Add(unit.Entity.GUID, unit); dictionary.Add(unit.Entity.GUID, (Object)(object)unit); } typeof(LandfallContentDatabase).GetField("m_unitBlueprints", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(database, dictionary2); typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(fullDatabase.AssetLoader, dictionary); } public static void AddFactionToDatabase(Faction faction) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) Dictionary<DatabaseID, Object> dictionary = (Dictionary<DatabaseID, Object>)typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(fullDatabase.AssetLoader); Dictionary<DatabaseID, Faction> dictionary2 = (Dictionary<DatabaseID, Faction>)typeof(LandfallContentDatabase).GetField("m_factions", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(database); if (!dictionary2.ContainsKey(faction.Entity.GUID)) { dictionary2.Add(faction.Entity.GUID, faction); dictionary.Add(faction.Entity.GUID, (Object)(object)faction); } typeof(LandfallContentDatabase).GetField("m_factions", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(database, dictionary2); typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(fullDatabase.AssetLoader, dictionary); } public static GameObject GetModel(string name) { GameObject val = FindVanillaObject(AssetImporter.Models, name, (GameObject m) => ((Object)m.gameObject).name); return ((Object)(object)val != (Object)null) ? val.gameObject : null; } public static void SetFlagsChildren(Transform child, HideFlags flag) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) ((Object)((Component)child).gameObject).hideFlags = flag; for (int i = 0; i < child.childCount; i++) { SetFlagsChildren(child.GetChild(i), flag); } } } } namespace ApproachGod.TABSSimp { public abstract class Mod { private const string KEY_BASES = "bases"; private const string KEY_UNITS = "units"; private const string KEY_FACTIONS = "factions"; private const string KEY_WEAPONS = "weapons"; private const string KEY_CLOTHES = "clothes"; private const string KEY_PROJECTILES = "projectiles"; private const string KEY_MOVES = "moves"; private const string KEY_EXPLOSIONS = "explosions"; private const string KEY_ICONS = "icons"; private const string KEY_EFFECTS = "effects"; private const string KEY_MODELS = "models"; private static Dictionary<string, Dictionary<string, object>> vanilla; private static Dictionary<string, Dictionary<string, object>> modified; private static GameObject pool; public static bool DEV_MODE { get; set; } static Mod() { //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Expected O, but got Unknown DEV_MODE = false; vanilla = new Dictionary<string, Dictionary<string, object>>(); modified = new Dictionary<string, Dictionary<string, object>>(); vanilla["bases"] = new Dictionary<string, object>(); vanilla["units"] = new Dictionary<string, object>(); vanilla["factions"] = new Dictionary<string, object>(); vanilla["weapons"] = new Dictionary<string, object>(); vanilla["clothes"] = new Dictionary<string, object>(); vanilla["projectiles"] = new Dictionary<string, object>(); vanilla["moves"] = new Dictionary<string, object>(); vanilla["explosions"] = new Dictionary<string, object>(); vanilla["icons"] = new Dictionary<string, object>(); vanilla["effects"] = new Dictionary<string, object>(); vanilla["models"] = new Dictionary<string, object>(); modified["bases"] = new Dictionary<string, object>(); modified["units"] = new Dictionary<string, object>(); modified["factions"] = new Dictionary<string, object>(); modified["weapons"] = new Dictionary<string, object>(); modified["clothes"] = new Dictionary<string, object>(); modified["projectiles"] = new Dictionary<string, object>(); modified["moves"] = new Dictionary<string, object>(); modified["explosions"] = new Dictionary<string, object>(); modified["icons"] = new Dictionary<string, object>(); modified["effects"] = new Dictionary<string, object>(); modified["models"] = new Dictionary<string, object>(); GameObject val = new GameObject("Pool") { hideFlags = (HideFlags)61 }; val.transform.position = Vector3.down * -1000f; pool = val; pool.SetActive(false); } public static GameObject PoolObject(GameObject gameObject) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) gameObject.transform.parent = pool.transform; gameObject.transform.localPosition = Vector3.zero; pool.transform.SetHideFlagsChildren((HideFlags)61); return gameObject; } public static GameObject CloneAndPoolObject(GameObject obj) { GameObject val = Object.Instantiate<GameObject>(obj, pool.transform); PoolObject(val); return val; } private static M CreateObject<M>(string key, Func<string, M> query, Action<M> processClone, string name, string originalName) where M : ModdingClass<M> { M val = null; M val2 = query(originalName); if (val2 != null) { val = val2.Clone(); processClone?.Invoke(val); val.Name = name; modified[key][name] = val; } return val; } private static M GetObject<M, R>(string key, Func<string, R> query, Func<R, M> generate, string name) { M val = default(M); if (modified[key].ContainsKey(name)) { val = (M)modified[key][name]; } else if (vanilla[key].ContainsKey(name)) { val = (M)vanilla[key][name]; } else { R val2 = query(name); if (val2 != null) { val = generate(val2); vanilla[key][name] = val; } } if (val == null) { Debug.LogError((object)("[MFD] Could not find '" + name + "' in '" + key + "'.")); } return val; } public static ModUnit GetUnit(string name) { return GetObject("units", Utilities.GetUnit, (UnitBlueprint u) => new ModUnit(u), name); } public static ModUnit CreateUnit(string name, string originalName = null) { return CreateObject("units", GetUnit, delegate(ModUnit mu) { if (originalName == null) { mu.Clothes.Clear(); } }, name, (originalName == null) ? "Peasant" : originalName); } public static ModFaction GetFaction(string name) { return GetObject("factions", Utilities.GetFaction, (Faction f) => new ModFaction(f), name); } public static ModFaction CreateFaction(string name, string originalName = null) { return CreateObject("factions", GetFaction, delegate(ModFaction mf) { mf.Units.Clear(); mf.Visible = true; }, name, (originalName == null) ? "Base Faction" : originalName); } public static ModWeapon GetWeapon(string name) { return GetObject("weapons", Utilities.GetWeapon, (GameObject w) => new ModWeapon(w), name); } public static ModWeapon CreateWeapon(string name, string originalName) { return CreateObject("weapons", GetWeapon, null, name, originalName); } public static ModClothing GetClothing(string name) { return GetObject("clothes", Utilities.GetClothing, (GameObject c) => new ModClothing(c), name); } public static ModClothing CreateClothing(string name, string originalName) { return CreateObject("clothes", GetClothing, null, name, originalName); } public static ModMove GetMove(string name) { return GetObject("moves", Utilities.GetMove, (GameObject m) => new ModMove(m), name); } public static ModMove CreateMove(string name, string originalName) { return CreateObject("moves", GetMove, null, name, originalName); } public static ModProjectile GetProjectile(string name) { return GetObject("projectiles", Utilities.GetProjectile, (GameObject p) => new ModProjectile(p), name); } public static ModProjectile CreateProjectile(string name, string originalName) { return CreateObject("projectiles", GetProjectile, null, name, originalName); } public static ModExplosion GetExplosion(string name) { return GetObject("explosions", Utilities.GetExplosion, (GameObject e) => new ModExplosion(e), name); } public static ModExplosion CreateExplosion(string name, string originalName) { return CreateObject("explosions", GetExplosion, null, name, originalName); } public static ModEffect GetEffect(string name) { return GetObject("effects", Utilities.GetEffect, (UnitEffectBase e) => new ModEffect(e), name); } public static ModEffect CreateEffect(string name, string originalName) { return CreateObject("effects", GetEffect, null, name, originalName); } public static ModBase GetBase(string name) { return GetObject("bases", Utilities.GetUnitBase, (GameObject b) => new ModBase(b), name); } public static ModBase CreateBase(string name, string originalName) { return CreateObject("bases", GetBase, null, name, originalName); } public static ModModel GetModel(string name) { return GetObject("models", Utilities.GetModel, (GameObject m) => new ModModel(m), name); } public static ModModel CreateModel(string name, string originalName) { return CreateObject("models", GetModel, null, name, originalName); } public static Sprite GetIcon(string name) { return GetObject("icons", Utilities.GetIcon, (Sprite s) => s, name); } } public class ModBase : ModdingClass<ModBase> { public GameObject internalObject { get; private set; } public override string Name { get { return ((Object)internalObject.gameObject).name; } set { ((Object)internalObject.gameObject).name = value; } } public override void ColorInternal(int index, Color color, float glow = 0f) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Utilities.SetObjectColor(internalObject, index, color, glow); } public ModBase(GameObject unitBase) { internalObject = unitBase; } public override ModBase Clone() { GameObject unitBase = Mod.CloneAndPoolObject(internalObject); return new ModBase(unitBase); } public override void Separate() { } } public enum ClothingType { Static, Skinned } public class ModClothing : ModdingClass<ModClothing> { private PropItem item; private SkinnedMeshRenderer renderer; private ModModel model; public GameObject internalObject { get; private set; } public ClothingType Type { get; private set; } public override string Name { get { return ((CharacterItem)item).Entity.Name; } set { ((CharacterItem)item).Entity.Name = value; } } public ModModel Model { get { return model; } set { //IL_0065: 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_00c2: Unknown result type (might be due to invalid IL or missing references) if (value != null) { Utilities.SetMeshRenderers(internalObject, enabled: false); model = value.Clone(); if (Type == ClothingType.Static) { model.internalObject.transform.parent = internalObject.transform; model.internalObject.transform.localPosition = Vector3.zero; model.internalObject.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f); } else if (Type == ClothingType.Skinned) { Utilities.PlaceMeshOnBone(renderer, model.internalObject, ((CharacterItem)item).GearT); } } else { if (model != null) { Utilities.SetMeshRenderers(internalObject, enabled: true); } model = null; } } } public float Size { get { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector3 localScale = internalObject.transform.localScale; return (localScale.x + localScale.y + localScale.z) / 3f; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) Utilities.SetClothScale(this, Vector3.one * value); } } public Vector3 Scale { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return internalObject.transform.localScale; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Utilities.SetClothScale(this, value); } } public override void ColorInternal(int index, Color color, float glow = 0f) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (model == null) { Utilities.SetObjectColor(internalObject, index, color, glow); } else { model.Color(index, color, glow); } } public ModClothing(GameObject prop) { internalObject = Mod.CloneAndPoolObject(prop); renderer = internalObject.GetComponentInChildren<SkinnedMeshRenderer>(); Type = (((Object)(object)renderer != (Object)null) ? ClothingType.Skinned : ClothingType.Static); item = internalObject.GetComponentInChildren<PropItem>(); } public override ModClothing Clone() { ModClothing modClothing = new ModClothing(internalObject) { Model = Model }; modClothing.Separate(); return modClothing; } public override void Separate() { } } public abstract class ModdingClass<T> where T : ModdingClass<T> { public abstract string Name { get; set; } public abstract T Clone(); public abstract void Separate(); public abstract void ColorInternal(int index, Color color, float glow = 0f); public void Color(Color color, float glow = 0f) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ColorInternal(0, color, glow); } public void Color(string color, float glow = 0f) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) Color(0, Utilities.HexColor(color), glow); } public void Color(int index, Color color, float glow = 0f) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ColorInternal(index, color, glow); } public void Color(int index, string color, float glow = 0f) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) Color(index, Utilities.HexColor(color), glow); } public void Colors(params Color[] colors) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < colors.Length; i++) { Color(i, colors[i]); } } public void Colors(params string[] colors) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < colors.Length; i++) { Color(i, Utilities.HexColor(colors[i])); } } public void Colors(params (Color color, float glow)[] colors) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < colors.Length; i++) { Color(i, colors[i].color, colors[i].glow); } } public void Colors(params (string color, float glow)[] colors) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < colors.Length; i++) { Color(i, Utilities.HexColor(colors[i].color), colors[i].glow); } } } public class ModEffect : ModdingClass<ModEffect> { public UnitEffectBase internalObject { get; private set; } public override string Name { get { return ((Object)((Component)internalObject).gameObject).name; } set { ((Object)((Component)internalObject).gameObject).name = value; } } public override void ColorInternal(int index, Color color, float glow = 0f) { } public ModEffect(UnitEffectBase effect) { internalObject = effect; } public override ModEffect Clone() { GameObject val = Mod.CloneAndPoolObject(((Component)internalObject).gameObject); return new ModEffect(val.GetComponent<UnitEffectBase>()); } public override void Separate() { } } public class ModExplosion : ModdingClass<ModExplosion> { private Explosion explosion; private ExplosionAddEffect addEffect; private ModEffect effect; public GameObject internalObject { get; private set; } public override string Name { get { return ((Object)internalObject).name; } set { ((Object)internalObject).name = value; } } public float Damage { get { if (Object.op_Implicit((Object)(object)explosion)) { return explosion.damage; } return 0f; } set { if (Object.op_Implicit((Object)(object)explosion)) { explosion.damage = value; } } } public float Force { get { if (Object.op_Implicit((Object)(object)explosion)) { return explosion.force; } return 0f; } set { if (Object.op_Implicit((Object)(object)explosion)) { explosion.force = value; } } } public ForceDirection ForceDirection { get { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)explosion)) { return explosion.forceDirection; } return (ForceDirection)0; } set { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)explosion)) { explosion.forceDirection = value; } } } public float Radius { get { if (Object.op_Implicit((Object)(object)explosion)) { return explosion.radius; } return 0f; } set { if (Object.op_Implicit((Object)(object)explosion)) { explosion.radius = value; } } } public ModEffect Effect { get { return effect; } set { effect = value; if (!Object.op_Implicit((Object)(object)addEffect)) { addEffect = internalObject.AddComponent<ExplosionAddEffect>(); } if (value != null) { addEffect.EffectPrefab = value.internalObject; } else { addEffect.EffectPrefab = null; } } } public float Size { get { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector3 localScale = internalObject.transform.localScale; return (localScale.x + localScale.y + localScale.z) / 3f; } set { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) internalObject.transform.localScale = Vector3.one * value; } } public Vector3 Scale { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return internalObject.transform.localScale; } set { //IL_000b: Unknown result type (might be due to invalid IL or missing references) internalObject.transform.localScale = value; } } public override void ColorInternal(int index, Color color, float glow = 0f) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Utilities.SetObjectColor(internalObject, index, color, glow); } public ModExplosion(GameObject explosionObject) { internalObject = explosionObject; explosion = internalObject.GetComponentInChildren<Explosion>(); addEffect = internalObject.GetComponentInChildren<ExplosionAddEffect>(); } public override ModExplosion Clone() { GameObject explosionObject = Mod.CloneAndPoolObject(internalObject); ModExplosion modExplosion = new ModExplosion(explosionObject); if (Effect != null) { modExplosion.Effect = Effect; } return modExplosion; } public override void Separate() { if (Effect != null) { Effect = Effect.Clone(); } } } public class ModFaction : ModdingClass<ModFaction> { public Faction internalObject { get; private set; } public WrapperDelineation<ModUnit> Units { get; private set; } public UnitBlueprint[] Blueprints => Units.List.Select((ModUnit w) => w.internalObject).ToArray(); public override string Name { get { return internalObject.Entity.Name; } set { internalObject.Entity.Name = value; } } public bool Visible { get { return internalObject.m_displayFaction; } set { internalObject.m_displayFaction = value; } } public Sprite Icon { get { return internalObject.Entity.SpriteIcon; } set { internalObject.Entity.SetSpriteIcon(value); } } private void UpdateBlueprints(List<ModUnit> units) { internalObject.Units = (from ModUnit unit in units select unit.internalObject).ToArray(); } public ModUnit NewUnit(string name, string originalName = null) { ModUnit modUnit = Mod.CreateUnit(name, originalName); Units.Add(modUnit); return modUnit; } public override void ColorInternal(int index, Color color, float glow = 0f) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) internalObject.m_FactionColor = color; } public ModFaction(Faction faction) { internalObject = faction; Units = new WrapperDelineation<ModUnit>(UpdateBlueprints, Mod.GetUnit) { List = (from UnitBlueprint blueprint in internalObject.Units select new ModUnit(blueprint)).ToList() }; } public override ModFaction Clone() { Faction val = Object.Instantiate<Faction>(internalObject); val.Entity.GenerateNewID(); val.Entity.Name = Utilities.IncrementName(Name); val.Units = Array.Empty<UnitBlueprint>(); val.index = Utilities.database.GetFactions().ToList().Count; Utilities.AddFactionToDatabase(val); ModFaction modFaction = new ModFaction(val); modFaction.Separate(); return modFaction; } public override void Separate() { Units.List = (from ModUnit unit in Units.List select unit.Clone()).ToList(); } } public class ModModel : ModdingClass<ModModel> { private Vector3 position; private Quaternion rotation; public GameObject internalObject { get; private set; } public override string Name { get { return ((Object)internalObject.gameObject).name; } set { ((Object)internalObject.gameObject).name = value; } } public Vector3 Position { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return position; } set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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) position = value; internalObject.transform.localPosition = position; } } public Quaternion Rotation { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return rotation; } set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_001e: Unknown result type (might be due to invalid IL or missing references) rotation = value; internalObject.transform.localRotation = Utilities.blenderToUnity * rotation; } } public override void ColorInternal(int index, Color color, float glow = 0f) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Utilities.SetObjectColor(internalObject, index, color, glow); } public ModModel(GameObject model) { internalObject = model; } public override ModModel Clone() { GameObject model = Mod.CloneAndPoolObject(internalObject); return new ModModel(model); } public override void Separate() { } } public class ModMove : ModdingClass<ModMove> { private SpecialAbility specialAbility; public GameObject internalObject { get; private set; } public override string Name { get { return ((CharacterItem)specialAbility).Entity.Name; } set { ((CharacterItem)specialAbility).Entity.Name = value; } } public override void ColorInternal(int index, Color color, float glow = 0f) { } public ModMove(GameObject move) { internalObject = move; specialAbility = move.GetComponentInChildren<SpecialAbility>(); } public override ModMove Clone() { GameObject move = Mod.CloneAndPoolObject(internalObject); return new ModMove(move); } public override void Separate() { } } public enum ProjectileType { Regular, Physical, Other } public class ModProjectile : ModdingClass<ModProjectile> { private ProjectileEntity projectileEntity; private ProjectileHit rHit; private MoveTransform rMoveTransform; private ProjectileHitAddEffect rAddEffect; private CollisionWeapon pCollision; private AddForce pAddForce; private MeleeWeaponAddEffect pAddEffect; private MeleeWeaponSpawn pSpawner; private ModModel model; private ModEffect effect; private ModUnit unit; public GameObject internalObject { get; private set; } public override string Name { get { return projectileEntity.Entity.Name; } set { projectileEntity.Entity.Name = value; } } public ProjectileType Type { get; private set; } public ModModel Model { get { return model; } set { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (value != null) { Utilities.SetMeshRenderers(internalObject, enabled: false); model = value.Clone(); model.internalObject.transform.parent = internalObject.transform; model.internalObject.transform.localPosition = Vector3.zero; model.internalObject.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f); } else { if (model != null) { Utilities.SetMeshRenderers(internalObject, enabled: true); } model = null; } } } public ModEffect Effect { get { return effect; } set { effect = value; if (Type == ProjectileType.Regular) { if (!Object.op_Implicit((Object)(object)rAddEffect)) { rAddEffect = ((Component)rHit).gameObject.AddComponent<ProjectileHitAddEffect>(); } rAddEffect.EffectPrefab = value?.internalObject; } else if (Type == ProjectileType.Physical) { if (!Object.op_Implicit((Object)(object)pAddEffect)) { pAddEffect = ((Component)pCollision).gameObject.AddComponent<MeleeWeaponAddEffect>(); } pAddEffect.EffectPrefab = value?.internalObject; } } } public WrapperDelineation<ModExplosion> Explosions { get; private set; } public ModExplosion Explosion { get { ModExplosion result = null; if (Explosions.List.Count > 0) { result = Explosions.List[0]; } return result; } set { Explosions.Clear(); if (value != null) { Explosions.Add(value); } } } public ModUnit Unit { get { return unit; } set { unit = value; Explosions.Clear(); ModExplosion modExplosion = Utilities.unitSpawner.Clone(); modExplosion.internalObject.GetComponent<UnitSpawner>().unitBlueprint = unit.internalObject; Explosions.Add(modExplosion); } } public float Damage { get { if (Type == ProjectileType.Regular) { return rHit.damage; } if (Type == ProjectileType.Physical) { return pCollision.damage; } return 0f; } set { if (Type == ProjectileType.Regular) { rHit.damage = value; } else if (Type == ProjectileType.Physical) { pCollision.damage = value; } } } public float Force { get { if (Type == ProjectileType.Regular) { return rHit.force; } if (Type == ProjectileType.Physical) { return pCollision.onImpactForce; } return 0f; } set { if (Type == ProjectileType.Regular) { rHit.force = value; } else if (Type == ProjectileType.Physical) { pCollision.onImpactForce = value; } } } public float Speed { get { if (Type == ProjectileType.Regular) { return rMoveTransform.selfImpulse.z; } if (Type == ProjectileType.Physical) { return pAddForce.force.z; } return 0f; } set { if (Type == ProjectileType.Regular) { rMoveTransform.selfImpulse.z = value; } else if (Type == ProjectileType.Physical) { pAddForce.force.z = value; } } } public float Size { get { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector3 localScale = internalObject.transform.localScale; return (localScale.x + localScale.y + localScale.z) / 3f; } set { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) internalObject.transform.localScale = Vector3.one * value; } } public Vector3 Scale { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return internalObject.transform.localScale; } set { //IL_000b: Unknown result type (might be due to invalid IL or missing references) internalObject.transform.localScale = value; } } public void UpdateImpact(List<ModExplosion> explosions) { if (Type == ProjectileType.Regular) { rHit.objectsToSpawn = explosions.Cast<ModExplosion>().Select((Func<ModExplosion, ObjectToSpawn>)((ModExplosion explosion) => new ObjectToSpawn { objectToSpawn = explosion.internalObject })).ToArray(); } else if (Type == ProjectileType.Physical && explosions.Count > 0) { if (Object.op_Implicit((Object)(object)pSpawner)) { pSpawner.objectToSpawn = explosions[0].internalObject; return; } pSpawner = ((Component)pCollision).gameObject.AddComponent<MeleeWeaponSpawn>(); pSpawner.objectToSpawn = explosions[0].internalObject; } } public override void ColorInternal(int index, Color color, float glow = 0f) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Utilities.SetObjectColor(internalObject, index, color, glow); } public ModProjectile(GameObject projectile, bool isClone = false) { internalObject = projectile; projectileEntity = internalObject.GetComponentInChildren<ProjectileEntity>(); rHit = internalObject.GetComponentInChildren<ProjectileHit>(); rMoveTransform = internalObject.GetComponentInChildren<MoveTransform>(); rAddEffect = internalObject.GetComponentInChildren<ProjectileHitAddEffect>(); pCollision = internalObject.GetComponentInChildren<CollisionWeapon>(); pAddForce = internalObject.GetComponentInChildren<AddForce>(); pAddEffect = internalObject.GetComponentInChildren<MeleeWeaponAddEffect>(); pSpawner = internalObject.GetComponentInChildren<MeleeWeaponSpawn>(); Explosions = new WrapperDelineation<ModExplosion>(UpdateImpact, Mod.GetExplosion); if (Object.op_Implicit((Object)(object)rHit)) { Type = ProjectileType.Regular; } else if (Object.op_Implicit((Object)(object)pCollision)) { Type = ProjectileType.Physical; } else { Type = ProjectileType.Other; } if (Type == ProjectileType.Regular) { ObjectToSpawn[] objectsToSpawn = rHit.objectsToSpawn; foreach (ObjectToSpawn val in objectsToSpawn) { if (val != null) { Explosions.Add(new ModExplosion(val.objectToSpawn)); } } if (Object.op_Implicit((Object)(object)rAddEffect) && Object.op_Implicit((Object)(object)rAddEffect.EffectPrefab) && !isClone) { effect = new ModEffect(rAddEffect.EffectPrefab); } } else if (Type == ProjectileType.Physical) { if (Object.op_Implicit((Object)(object)pSpawner) && Object.op_Implicit((Object)(object)pSpawner.objectToSpawn)) { Explosions.Add(new ModExplosion(pSpawner.objectToSpawn)); } if (Object.op_Implicit((Object)(object)pAddEffect) && Object.op_Implicit((Object)(object)pAddEffect.EffectPrefab) && !isClone) { effect = new ModEffect(pAddEffect.EffectPrefab); } } } public override ModProjectile Clone() { GameObject projectile = Mod.CloneAndPoolObject(internalObject); ModProjectile modProjectile = new ModProjectile(projectile, isClone: true); modProjectile.Explosions.List = Explosions.List; modProjectile.Model = Model; ModProjectile modProjectile2 = modProjectile; string name = Utilities.IncrementName(modProjectile2.projectileEntity.Entity.Name); modProjectile2.projectileEntity.Entity.Name = name; ((Object)modProjectile2.internalObject).name = name; if (Effect != null) { modProjectile2.Effect = Effect; } modProjectile2.Separate(); return modProjectile2; } public override void Separate() { if (Effect != null) { Effect = Effect.Clone(); } Explosions.List = (from ModExplosion explosion in Explosions.List select explosion.Clone()).ToList(); } } public class ModUnit : ModdingClass<ModUnit> { public class ModVoice { public UnitBlueprint internalObject { get; private set; } public string Death { get { return internalObject.voiceBundle.DeathRef; } set { internalObject.voiceBundle.DeathRef = value; } } public string Alive { get { return internalObject.voiceBundle.VocalRef; } set { internalObject.voiceBundle.VocalRef = value; } } public float Pitch { get { return internalObject.VoicePitch; } set { internalObject.VoicePitch = value; } } public ModVoice(UnitBlueprint blueprint) { internalObject = blueprint; internalObject.voiceBundle = ScriptableObject.CreateInstance<VoiceBundle>(); } } public UnitBlueprint internalObject; private ModWeapon rightWeapon; private ModWeapon leftWeapon; private ModBase unitBase; private ModUnit rider; public WrapperDelineation<ModClothing> Clothes { get; private set; } public WrapperDelineation<ModMove> Moves { get; private set; } public ModVoice Voice { get; private set; } public override string Name { get { return internalObject.Entity.Name; } set { internalObject.Entity.Name = value; } } public Sprite Icon { get { return internalObject.Entity.SpriteIcon; } set { internalObject.Entity.SetSpriteIcon(value); } } public float Health { get { return internalObject.health; } set { internalObject.health = value; } } public float Speed { get { return internalObject.movementSpeedMuiltiplier; } set { internalObject.movementSpeedMuiltiplier = value; } } public float TurnSpeed { get { return internalObject.TurnSpeed; } set { if ((Object)(object)internalObject.turningData != (Object)null) { internalObject.turningData.TurnSpeed = value; } internalObject.turnSpeed = value; } } public float Mass { get { return internalObject.massMultiplier; } set { internalObject.massMultiplier = value; } } public float Balance { get { return internalObject.balanceMultiplier; } set { internalObject.balanceMultiplier = value; } } public float BalanceStrength { get { return internalObject.balanceForceMultiplier; } set { internalObject.balanceForceMultiplier = value; } } public float Priority { get { return internalObject.targetingPriorityMultiplier; } set { internalObject.targetingPriorityMultiplier = value; } } public float Size { get { return internalObject.sizeMultiplier; } set { internalObject.sizeMultiplier = value; } } public bool TwoHanded { get { return internalObject.holdinigWithTwoHands; } set { internalObject.holdinigWithTwoHands = value; } } public int Cost { get { return (int)internalObject.GetUnitCost(true); } set { internalObject.useCustomCost = true; internalObject.customCost = value; } } public ModWeapon RightWeapon { get { return rightWeapon; } set { if (value != null) { rightWeapon = value; internalObject.RightWeapon = rightWeapon.internalObject; } } } public ModWeapon LeftWeapon { get { return leftWeapon; } set { if (value != null) { leftWeapon = value; internalObject.LeftWeapon = leftWeapon.internalObject; } } } public ModBase Base { get { return unitBase; } set { unitBase = value; internalObject.UnitBase = unitBase.internalObject; } } public Vector2 SizeRange { get { //IL_0016: Unknown result type (might be due to invalid IL or missing references) return new Vector2(internalObject.minSizeRandom, internalObject.maxSizeRandom); } set { //IL_0007: 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) internalObject.minSizeRandom = value.x; internalObject.maxSizeRandom = value.y; } } public ModUnit Rider { get { return rider; } set { rider = value; if (rider != null) { internalObject.SetField<UnitBlueprint>("Riders", new UnitBlueprint[1] { rider.internalObject }); } else { internalObject.SetField<UnitBlueprint>("Riders", Array.Empty<UnitBlueprint>()); } } } private void UpdateClothing(List<ModClothing> list) { internalObject.m_props = (from ModClothing clothing in list select clothing.internalObject).ToArray(); } private void UpdateMoves(List<ModMove> list) { internalObject.objectsToSpawnAsChildren = (from ModMove move in list select move.internalObject).ToArray(); } public override void ColorInternal(int index, Color color, float glow = 0f) { } public ModUnit(UnitBlueprint blueprint) { internalObject = blueprint; Clothes = new WrapperDelineation<ModClothing>(UpdateClothing, Mod.GetClothing); Moves = new WrapperDelineation<ModMove>(UpdateMoves, Mod.GetMove); Voice = new ModVoice(blueprint); if (internalObject.m_props != null) { Clothes.List = (from GameObject prop in internalObject.m_props where (Object)(object)prop != (Object)null select new ModClothing(prop)).ToList(); } else { internalObject.m_props = Array.Empty<GameObject>(); } if (Object.op_Implicit((Object)(object)internalObject.RightWeapon)) { RightWeapon = new ModWeapon(internalObject.RightWeapon); } if (Object.op_Implicit((Object)(object)internalObject.LeftWeapon)) { LeftWeapon = new ModWeapon(internalObject.LeftWeapon); } } public override ModUnit Clone() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) string name = Utilities.IncrementName(Name); UnitBlueprint val = Object.Instantiate<UnitBlueprint>(internalObject); val.Entity.GUID = DatabaseID.NewID(); val.Entity.Name = name; Utilities.AddUnitToDatabase(val); ModUnit modUnit = new ModUnit(val); modUnit.Clothes.List = Clothes.List; modUnit.Moves.List = Moves.List; modUnit.Rider = Rider; modUnit.Cost = Cost; ModUnit modUnit2 = modUnit; modUnit2.Separate(); return modUnit2; } public override void Separate() { if (RightWeapon != null) { RightWeapon = RightWeapon.Clone(); } if (LeftWeapon != null) { LeftWeapon = LeftWeapon.Clone(); } Clothes.List = (from ModClothing clothing in Clothes.List select clothing.Clone()).ToList(); Moves.List = (from ModMove move in Moves.List select move.Clone()).ToList(); } } public enum WeaponType { Melee, Ranged } public class ModWeapon : ModdingClass<ModWeapon> { public class ModMelee { private readonly ModWeapon internalWeapon; public float SwingSpeed { get { return (internalWeapon.Type == WeaponType.Melee) ? internalWeapon.internalMelee.curveForce : 0f; } set { if (internalWeapon.Type == WeaponType.Melee) { internalWeapon.internalMelee.curveForce = value; } } } public Vector3 SwingDirection { get { //IL_001f: 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) return (internalWeapon.Type == WeaponType.Melee) ? internalWeapon.internalMelee.swingDirection : Vector3.zero; } set { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (internalWeapon.Type == WeaponType.Melee) { internalWeapon.internalMelee.swingDirection = value; } } } public float Impact { get { return (internalWeapon.Type == WeaponType.Melee) ? internalWeapon.mCollision.impactMultiplier : 0f; } set { if (internalWeapon.Type == WeaponType.Melee) { internalWeapon.mCollision.impactMultiplier = value; } } } public ModMelee(ModWeapon weapon) { internalWeapon = weapon; } } public class ModRanged { private readonly ModWeapon internalWeapon; public ModProjectile Projectile { get { return internalWeapon.projectile; } set { if (internalWeapon.Type == WeaponType.Ranged) { internalWeapon.projectile = value; internalWeapon.internalRanged.ObjectToSpawn = internalWeapon.projectile.internalObject; } } } public ModUnit UnitProjectile { get { return internalWeapon.unit; } set { internalWeapon.unit = value; if (internalWeapon.Type == WeaponType.Ranged) { Projectile = null; internalWeapon.internalRanged.unitToSpawn = internalWeapon.unit.internalObject; } } } public int Ammo { get { if (internalWeapon.Type == WeaponType.Ranged) { return internalWeapon.internalRanged.magSize; } return 0; } set { if (internalWeapon.Type == WeaponType.Ranged) { internalWeapon.internalRanged.magSize = value; } } } public int ProjectileAmount { get { if (internalWeapon.Type == WeaponType.Ranged) { return internalWeapon.internalRanged.numberOfObjects; } return 0; } set { if (internalWeapon.Type == WeaponType.Ranged) { internalWeapon.internalRanged.numberOfObjects = value; } } } public float Spread { get { if (internalWeapon.Type == WeaponType.Ranged) { return internalWeapon.internalRanged.spread; } return 0f; } set { if (internalWeapon.Type == WeaponType.Ranged) { internalWeapon.internalRanged.spread = value; } } } public float Recoil { get { if (internalWeapon.Type == WeaponType.Ranged) { return internalWeapon.internalRanged.shootRecoil; } return 0f; } set { if (internalWeapon.Type == WeaponType.Ranged) { internalWeapon.internalRanged.shootRecoil = value; internalWeapon.internalRanged.torsoRecoil = value * 0.1f; } } } public ModRanged(ModWeapon weapon) { internalWeapon = weapon; } } private WeaponItem item; private Weapon weapon; private RangeWeapon internalRanged; private MeleeWeapon internalMelee; private CollisionWeapon mCollision; private MeleeWeaponSpawn mSpawner; private MeleeWeaponAddEffect mAddEffect; private ModEffect effect; private ModExplosion explosion; private ModModel model; public ModMelee Melee; private ModProjectile projectile; private ModUnit unit; public ModRanged Ranged; public GameObject internalObject { get; private set; } public override string Name { get { return ((CharacterItem)item).Entity.Name; } set { ((CharacterItem)item).Entity.Name = value; } } public WeaponType Type { get; private set; } public float Cooldown { get { return weapon.internalCooldown; } set { weapon.internalCooldown = value; } } public float AttackSpeed { get { return 1f / weapon.internalCooldown; } set { weapon.internalCooldown = 1f / value; } } public float AttackRange { get { return weapon.maxRange; } set { weapon.maxRange = value; } } public float AttackAngle { get { return weapon.maxAngle; } set { weapon.maxAngle = value; } } public bool StartCooldown { get { return weapon.startOnCooldown; } set { weapon.startOnCooldown = value; } } public float Damage { get { if (Type == WeaponType.Melee) { return mCollision.damage; } if (Type == WeaponType.Ranged) { return Ranged.Projectile.Damage; } return 0f; } set { if (Type == WeaponType.Melee) { mCollision.damage = value; } else if (Type == WeaponType.Ranged) { Ranged.Projectile.Damage = value; } } } public float Force { get { if (Type == WeaponType.Melee) { return mCollision.onImpactForce; } if (Type == WeaponType.Ranged) { return projectile.Force; } return 0f; } set { if (Type == WeaponType.Melee) { mCollision.onImpactForce = value; } else if (Type == WeaponType.Ranged) { projectile.Force = value; } } } public ModEffect Effect { get { if (Type == WeaponType.Melee) { return effect; } if (Type == WeaponType.Ranged) { return Ranged.Projectile.Effect; } return null; } set { effect = value; if (Type == WeaponType.Melee) { effect = value; if (!Object.op_Implicit((Object)(object)mAddEffect)) { mAddEffect = internalObject.AddComponent<MeleeWeaponAddEffect>(); } bool flag = effect != null && Object.op_Implicit((Object)(object)effect.internalObject); if (flag) { mAddEffect.EffectPrefab = effect.internalObject; } else { mAddEffect.EffectPrefab = null; } ((Behaviour)mAddEffect).enabled = flag; } else if (Type == WeaponType.Ranged) { Ranged.Projectile.Effect = value; } } } public ModExplosion Explosion { get { if (Type == WeaponType.Melee) { return explosion; } if (Type == WeaponType.Ranged && projectile != null) { return projectile.Explosion; } return null; } set { //IL_0044: Unknown result type (might be due to invalid IL or missing references) explosion = value; if (Type == WeaponType.Melee) { if (!Object.op_Implicit((Object)(object)mSpawner)) { mSpawner = internalObject.AddComponent<MeleeWeaponSpawn>(); mSpawner.pos = (Pos)1; } bool flag = explosion != null && Object.op_Implicit((Object)(object)explosion.internalObject); if (flag) { mSpawner.objectToSpawn = explosion.internalObject; } else { mSpawner.objectToSpawn = null; } ((Behaviour)mSpawner).enabled = flag; } else if (Type == WeaponType.Ranged && projectile != null) { projectile.Explosion = value; } } } public ModModel Model { get { return model; } set { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (value != null) { Utilities.SetMeshRenderers(internalObject, enabled: false); model = value.Clone(); model.internalObject.transform.parent = internalObject.transform; model.internalObject.transform.localPosition = Vector3.zero; model.internalObject.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f); } else { if (model != null) { Utilities.SetMeshRenderers(internalObject, enabled: true); } model = null; } } } public float Size { get { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector3 localScale = internalObject.transform.localScale; return (localScale.x + localScale.y + localScale.z) / 3f; } set { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) internalObject.transform.localScale = Vector3.one * value; } } public Vector3 Scale { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return internalObject.transform.localScale; } set { //IL_000b: Unknown result type (might be due to invalid IL or missing references) internalObject.transform.localScale = value; } } public override void ColorInternal(int index, Color color, float glow = 0f) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (model == null) { Utilities.SetObjectColor(internalObject, index, color, glow); } else { model.Color(index, color, glow); } } public ModWeapon(GameObject weaponObject, bool isClone = false) { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown internalObject = weaponObject; weapon = internalObject.GetComponentInChildren<Weapon>(); item = internalObject.GetComponentInChildren<WeaponItem>(); mCollision = internalObject.GetComponentInChildren<CollisionWeapon>(); mAddEffect = internalObject.GetComponentInChildren<MeleeWeaponAddEffect>(); mSpawner = internalObject.GetComponentInChildren<MeleeWeaponSpawn>(); if (Object.op_Implicit