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(); m_data = ((Component)((Component)this).transform.root).gameObject.GetComponentInChildren(); m_originalMultiplier = m_movementHandler.multiplier; m_data.canFall = false; Balance componentInChildren = ((Component)((Component)this).transform.root).gameObject.GetComponentInChildren(); 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 dictionary = (Dictionary)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().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(); 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().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().positionOffset = new Vector3(0f, 5f, 0f); ModEffect modEffect = Mod.CreateEffect("bmbxg", "IceArrowEffect"); ((Component)modEffect.internalObject).GetComponentInChildren().effectAmount = 200f; modExplosion.internalObject.AddComponent().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(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().radius; modExplosion2.internalObject.GetComponentInChildren().radius = radius * 5f; ModEffect modEffect2 = Mod.CreateEffect("slbzkj", "Fear"); modExplosion2.internalObject.AddComponent().EffectPrefab = modEffect2.internalObject; modProjectile3.Explosions.Clear(); modProjectile3.Explosions.Add(modExplosion2); modWeapon3.internalObject.GetComponentInChildren().spawnPosition = (SpawnPosition)1; modWeapon3.internalObject.GetComponentInChildren().positionOffset = new Vector3(0f, 15f, 0f); modWeapon3.internalObject.GetComponentInChildren().useRandomDelay = false; modWeapon3.internalObject.GetComponentInChildren().maxProjectilesPerFrane = 30; modWeapon3.internalObject.GetComponentInChildren().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(); foreach (ParticleSystemRenderer val5 in componentsInChildren2) { List list = new List(); 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(); 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().effectAmount; ((Component)modEffect3.internalObject).GetComponentInChildren().effectAmount = effectAmount * 10f; modExplosion3.internalObject.AddComponent().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(); 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(); modBase3.internalObject.AddComponent(); 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(); modBase4.internalObject.AddComponent(); 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().effectAmount = 1000000f; ((Component)modEffect4.internalObject).GetComponentInChildren().iceMaterial = val11; modExplosion5.internalObject.AddComponent().EffectPrefab = modEffect4.internalObject; modProjectile4.Explosions.Add(modExplosion5); modExplosion4.Damage = float.PositiveInfinity; modExplosion4.Color(Color.black, 0.8f); modProjectile5.internalObject.AddComponent().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().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(); 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().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(); 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().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()); GameObject internalObject = modMove7.internalObject; CharacterItem component3 = internalObject.GetComponent(); internalObject.AddComponent(); component3.Entity.Name = "接近神之不死"; component3.Entity.GUID = new DatabaseID(5, -1145171); component3.tags[0] = new Tag((TagType)0, "接近神"); Dictionary dictionary2 = (Dictionary)landfallContentDatabase.GetField("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()); modMove8.internalObject.AddComponent(); 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()); modMove9.internalObject.AddComponent<放置抹杀>(); ModUnit modUnit17 = modFaction2.NewUnit("放置抹杀"); modUnit17.Moves.Add(modMove9); ModMove modMove10 = Mod.CreateMove("开战秒杀", "Self Copy"); Object.Destroy((Object)(object)modMove10.internalObject.GetComponent()); 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 boneDictionary; public static readonly Quaternion blenderToUnity; public static readonly string rootPath; public static Dictionary 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)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(); effects = Resources.FindObjectsOfTypeAll(); sprites = Resources.FindObjectsOfTypeAll(); unitSpawner = new ModExplosion(Mod.PoolObject(new GameObject("UnitSpawner", new Type[1] { typeof(UnitSpawner) }))); List source = (from z in (from z in language group z by z.Value into z where z.Count() > 1 select z).SelectMany((IGrouping> z) => z) select z.Key).ToList(); Dictionary dictionary = new Dictionary(); 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(GetFaction("Medieval")); val.Entity.GenerateNewID(); val.Entity.Name = "Base Faction"; val.Units = Array.Empty(); 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()).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().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()).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().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()).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() 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(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(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(string obj) { Object[] source = Resources.FindObjectsOfTypeAll(typeof(T)); return (T)(object)((IEnumerable)source).FirstOrDefault((Func)((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(this IEnumerable collection, Action action) { foreach (T item in collection) { action(item); } } public static void ForEach(this T[] array, Action action) { foreach (T obj in array) { action(obj); } } public static Dictionary Reverse(this Dictionary self) { Dictionary dictionary = new Dictionary(); 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(IEnumerable source, string name, Func 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() 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(); 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() != (Object)null; Dictionary dictionary = new Dictionary(); 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 source = ((Component)val2).GetComponents().ToList(); List removed = new List(); Material[] materials2 = val2.materials; List list = new List(); 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 list2 = ((Component)val4).GetComponents().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() != (Object)null) { MeshRenderer[] componentsInChildren = internalObject.GetComponentsInChildren(); foreach (MeshRenderer val in componentsInChildren) { ((Component)val).transform.localScale = scale; } } if (!((Object)(object)internalObject.GetComponentInChildren() != (Object)null)) { return; } Vector3 localScale = internalObject.transform.localScale; SkinnedMeshRenderer[] componentsInChildren2 = internalObject.GetComponentsInChildren(); foreach (SkinnedMeshRenderer val2 in componentsInChildren2) { val2.sharedMesh = Object.Instantiate(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(); 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(); List list = new List(); bool flag = false; LODGroup componentInChildren = gameObject.GetComponentInChildren(); 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().Entity.Name); } public static GameObject GetClothing(string name) { return FindVanillaObject(database.GetCharacterProps(), name, (GameObject c) => ((CharacterItem)c.GetComponentInChildren()).Entity.Name); } public static GameObject GetWeapon(string name) { return FindVanillaObject(database.GetWeapons(), name, (GameObject w) => ((CharacterItem)w.GetComponentInChildren()).Entity.Name); } public static GameObject GetMove(string name) { return FindVanillaObject(database.GetCombatMoves(), name, (GameObject m) => ((CharacterItem)m.GetComponentInChildren()).Entity.Name); } public static GameObject GetProjectile(string name) { GameObject gameObject = FindVanillaObject(database.GetProjectiles(), name, (GameObject p) => p.GetComponent().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 dictionary = (Dictionary)typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(fullDatabase.AssetLoader); Dictionary dictionary2 = (Dictionary)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 dictionary = (Dictionary)typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(fullDatabase.AssetLoader); Dictionary dictionary2 = (Dictionary)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> vanilla; private static Dictionary> 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>(); modified = new Dictionary>(); vanilla["bases"] = new Dictionary(); vanilla["units"] = new Dictionary(); vanilla["factions"] = new Dictionary(); vanilla["weapons"] = new Dictionary(); vanilla["clothes"] = new Dictionary(); vanilla["projectiles"] = new Dictionary(); vanilla["moves"] = new Dictionary(); vanilla["explosions"] = new Dictionary(); vanilla["icons"] = new Dictionary(); vanilla["effects"] = new Dictionary(); vanilla["models"] = new Dictionary(); modified["bases"] = new Dictionary(); modified["units"] = new Dictionary(); modified["factions"] = new Dictionary(); modified["weapons"] = new Dictionary(); modified["clothes"] = new Dictionary(); modified["projectiles"] = new Dictionary(); modified["moves"] = new Dictionary(); modified["explosions"] = new Dictionary(); modified["icons"] = new Dictionary(); modified["effects"] = new Dictionary(); modified["models"] = new Dictionary(); 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(obj, pool.transform); PoolObject(val); return val; } private static M CreateObject(string key, Func query, Action processClone, string name, string originalName) where M : ModdingClass { 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(string key, Func query, Func 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 { 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 { 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(); Type = (((Object)(object)renderer != (Object)null) ? ClothingType.Skinned : ClothingType.Static); item = internalObject.GetComponentInChildren(); } public override ModClothing Clone() { ModClothing modClothing = new ModClothing(internalObject) { Model = Model }; modClothing.Separate(); return modClothing; } public override void Separate() { } } public abstract class ModdingClass where T : ModdingClass { 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 { 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()); } public override void Separate() { } } public class ModExplosion : ModdingClass { 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(); } 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(); addEffect = internalObject.GetComponentInChildren(); } 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 { public Faction internalObject { get; private set; } public WrapperDelineation 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 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(UpdateBlueprints, Mod.GetUnit) { List = (from UnitBlueprint blueprint in internalObject.Units select new ModUnit(blueprint)).ToList() }; } public override ModFaction Clone() { Faction val = Object.Instantiate(internalObject); val.Entity.GenerateNewID(); val.Entity.Name = Utilities.IncrementName(Name); val.Units = Array.Empty(); 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 { 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 { 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(); } 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 { 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(); } rAddEffect.EffectPrefab = value?.internalObject; } else if (Type == ProjectileType.Physical) { if (!Object.op_Implicit((Object)(object)pAddEffect)) { pAddEffect = ((Component)pCollision).gameObject.AddComponent(); } pAddEffect.EffectPrefab = value?.internalObject; } } } public WrapperDelineation 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().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 explosions) { if (Type == ProjectileType.Regular) { rHit.objectsToSpawn = explosions.Cast().Select((Func)((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(); 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(); rHit = internalObject.GetComponentInChildren(); rMoveTransform = internalObject.GetComponentInChildren(); rAddEffect = internalObject.GetComponentInChildren(); pCollision = internalObject.GetComponentInChildren(); pAddForce = internalObject.GetComponentInChildren(); pAddEffect = internalObject.GetComponentInChildren(); pSpawner = internalObject.GetComponentInChildren(); Explosions = new WrapperDelineation(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 { 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(); } } public UnitBlueprint internalObject; private ModWeapon rightWeapon; private ModWeapon leftWeapon; private ModBase unitBase; private ModUnit rider; public WrapperDelineation Clothes { get; private set; } public WrapperDelineation 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("Riders", new UnitBlueprint[1] { rider.internalObject }); } else { internalObject.SetField("Riders", Array.Empty()); } } } private void UpdateClothing(List list) { internalObject.m_props = (from ModClothing clothing in list select clothing.internalObject).ToArray(); } private void UpdateMoves(List 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(UpdateClothing, Mod.GetClothing); Moves = new WrapperDelineation(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(); } 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(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 { 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(); } 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(); 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(); item = internalObject.GetComponentInChildren(); mCollision = internalObject.GetComponentInChildren(); mAddEffect = internalObject.GetComponentInChildren(); mSpawner = internalObject.GetComponentInChildren(); if (Object.op_Implicit((Object)(object)mAddEffect) && Object.op_Implicit((Object)(object)mAddEffect.EffectPrefab) && !isClone) { effect = new ModEffect(mAddEffect.EffectPrefab); } Melee = new ModMelee(this); Ranged = new ModRanged(this); Type = ((((object)weapon).GetType() == typeof(RangeWeapon)) ? WeaponType.Ranged : WeaponType.Melee); if (Type == WeaponType.Melee) { internalMelee = (MeleeWeapon)weapon; } else if (Type == WeaponType.Ranged) { internalRanged = (RangeWeapon)weapon; if ((Object)(object)internalRanged.ObjectToSpawn != (Object)null) { Ranged.Projectile = new ModProjectile(internalRanged.ObjectToSpawn); } } } public override ModWeapon Clone() { GameObject val = Mod.CloneAndPoolObject(internalObject); ((Object)val).name = Utilities.IncrementName(((Object)internalObject).name); ModWeapon modWeapon = new ModWeapon(val, isClone: true) { Model = Model }; modWeapon.Separate(); return modWeapon; } public override void Separate() { if (Type == WeaponType.Ranged) { Ranged.Projectile = Ranged.Projectile.Clone(); } else if (Type == WeaponType.Melee) { if (Effect != null) { Effect = Effect.Clone(); } if (Explosion != null) { Explosion = Explosion.Clone(); } } } } public class WrapperDelineation where T : ModdingClass { private List internalObject = new List(); private Action> onUpdate; private Func query; public List List { get { return ListGet(); } set { ListSet(value); } } public void Add(T item) { internalObject.Add(item); onUpdate(internalObject); } public void Add(string itemName) { T item = query(itemName); internalObject.Add(item); onUpdate(internalObject); } public void Add(params T[] items) { foreach (T item in items) { internalObject.Add(item); } onUpdate(internalObject); } public void Add(params string[] itemNames) { foreach (string arg in itemNames) { T item = query(arg); internalObject.Add(item); } onUpdate(internalObject); } public void AddCloned(T item) { internalObject.Add(item.Clone()); onUpdate(internalObject); } public void AddCloned(string itemName) { T val = query(itemName); internalObject.Add(val.Clone()); onUpdate(internalObject); } public void AddCloned(params T[] items) { foreach (T val in items) { internalObject.Add(val.Clone()); } onUpdate(internalObject); } public void AddCloned(params string[] itemNames) { foreach (string arg in itemNames) { T val = query(arg); internalObject.Add(val.Clone()); } onUpdate(internalObject); } public void Remove(T item) { internalObject.Remove(item); onUpdate(internalObject); } public void Remove(string itemName) { internalObject.Remove(internalObject.Where((T t) => itemName == Utilities.GetProperName(t.Name)).FirstOrDefault()); onUpdate(internalObject); } public void RemoveAll(T item) { internalObject.RemoveAll((T i) => i == item); onUpdate(internalObject); } public void RemoveAll(string itemName) { internalObject.Where((T t) => itemName == Utilities.GetProperName(t.Name)).ForEach(delegate(T t) { internalObject.Remove(t); }); onUpdate(internalObject); } public void Clear() { internalObject = new List(); onUpdate(internalObject); } private List ListGet() { return (from T item in internalObject select (item)).ToList(); } private void ListSet(List list) { internalObject.Clear(); foreach (T item in list) { internalObject.Add(item); } onUpdate(internalObject); } public WrapperDelineation(Action> onUpdate, Func query) { this.onUpdate = onUpdate; this.query = query; } } } namespace ApproachGod.AssetManagement { public static class AssetImporter { public static List Models { get; private set; } = new List(); public static List Sprites { get; private set; } = new List(); private static int[] GenerateRange(int floor, int ceiling) { List list = new List(); for (int i = floor; i < ceiling; i++) { list.Add(i); } return list.ToArray(); } public static string GetAttr(this XmlNode self, string name) { return (from XmlAttribute attr in (IEnumerable)self.Attributes where ((XmlNode)attr).Name == name select ((XmlNode)attr).Value).ToArray()[0]; } public static float[] GetFloats(string floats) { string[] source = floats.Split(new char[1] { ' ' }); return (from string number in source select float.Parse(number, CultureInfo.InvariantCulture)).ToArray(); } public static int[] GetInts(string ints) { string[] source = ints.Split(new char[1] { ' ' }); return (from string number in source select int.Parse(number, CultureInfo.InvariantCulture)).ToArray(); } public static Color GetColor(string floats) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) float[] array = (from float flt in GetFloats(floats) select Mathf.Pow(flt, 2.2f)).ToArray(); return new Color(array[0], array[1], array[2], array[3]); } public static Vector3[] GetVector3(string floats) { //IL_002d: 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) float[] floats2 = GetFloats(floats); Vector3[] array = (Vector3[])(object)new Vector3[floats2.Length / 3]; for (int i = 0; i < floats2.Length / 3; i++) { array[i] = new Vector3(floats2[3 * i], floats2[3 * i + 1], floats2[3 * i + 2]); } return array; } public static Vector2[] GetVector2(string floats) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) float[] floats2 = GetFloats(floats); Vector2[] array = (Vector2[])(object)new Vector2[floats2.Length / 2]; for (int i = 0; i < floats2.Length / 2; i++) { array[i] = new Vector2(floats2[2 * i], floats2[2 * i + 1]); } return array; } public static SpriteAsset ImportSprite(string filePath) { byte[] data = File.ReadAllBytes(filePath); string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath); return new SpriteAsset(fileNameWithoutExtension, data); } public static ModelAsset ImportModel(string filePath) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Expected O, but got Unknown //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) XmlDocument val = new XmlDocument(); val.Load(filePath); XmlNode documentElement = (XmlNode)(object)val.DocumentElement; XmlNamespaceManager val2 = new XmlNamespaceManager(val.NameTable); val2.AddNamespace("c", documentElement.GetAttr("xmlns")); Dictionary dictionary = new Dictionary(); XmlNodeList val3 = documentElement.SelectNodes("//c:library_effects/c:effect", val2); foreach (XmlNode item in val3) { XmlNode val4 = item; string key = val4.GetAttr("id").Split(new char[1] { '-' })[0]; string innerText = val4.SelectNodes("c:profile_COMMON/c:technique/c:lambert/c:diffuse/c:color", val2).Item(0).InnerText; Color color = GetColor(innerText); dictionary[key] = color; } XmlNodeList val5 = documentElement.SelectNodes("//c:library_geometries/c:geometry", val2); XmlNode val6 = val5.Item(0); string text = val6.GetAttr("name").Replace('.', '_'); string innerText2 = val6.SelectSingleNode("c:mesh/c:source[@id='" + text + "-mesh-positions']/c:float_array", val2).InnerText; string innerText3 = val6.SelectSingleNode("c:mesh/c:source[@id='" + text + "-mesh-normals']/c:float_array", val2).InnerText; string innerText4 = val6.SelectSingleNode("c:mesh/c:source[@id='" + text + "-mesh-map-0']/c:float_array", val2).InnerText; Vector3[] vector = GetVector3(innerText2); Vector3[] vector2 = GetVector3(innerText3); Vector2[] vector3 = GetVector2(innerText4); XmlNodeList val7 = val6.SelectNodes("c:mesh/c:triangles", val2); Dictionary dictionary2 = new Dictionary(); foreach (XmlNode item2 in val7) { XmlNode val8 = item2; string key2 = val8.GetAttr("material").Split(new char[1] { '-' })[0]; string innerText5 = val8.SelectSingleNode("c:p", val2).InnerText; int[] ints = GetInts(innerText5); dictionary2[key2] = ints; } IEnumerable enumerable = Array.Empty(); foreach (int[] value in dictionary2.Values) { enumerable = enumerable.Concat(value); } int[] array = enumerable.ToArray(); int[] array2 = new int[array.Length / 3]; int[] array3 = new int[array.Length / 3]; int[] array4 = new int[array.Length / 3]; for (int i = 0; i < array.Length / 3; i++) { array2[i] = array[i * 3]; array3[i] = array[i * 3 + 1]; array4[i] = array[i * 3 + 2]; } int[][] nvtBuffer = new int[array2.Length][]; List list = new List(); for (int j = 0; j < array2.Length; j++) { nvtBuffer[j] = new int[3] { array2[j], array3[j], array4[j] }; } int l; for (l = 0; l < nvtBuffer.Length; l++) { if (!list.Exists((int[] el) => el == nvtBuffer[l])) { list.Add(nvtBuffer[l]); } } int[][] array5 = list.ToArray(); Vector3[] array6 = (Vector3[])(object)new Vector3[array5.Length]; Vector3[] array7 = (Vector3[])(object)new Vector3[array5.Length]; Vector2[] array8 = (Vector2[])(object)new Vector2[array5.Length]; for (int num = 0; num < array5.Length; num++) { array6[num] = vector[array5[num][0]]; array7[num] = vector2[array5[num][1]]; array8[num] = vector3[array5[num][2]]; } ModelAsset modelAsset = new ModelAsset(); modelAsset.name = Path.GetFileNameWithoutExtension(filePath); modelAsset.vertices = array6; modelAsset.normals = array7; modelAsset.textures = array8; modelAsset.submeshes = new int[dictionary2.Count][]; modelAsset.materials = (Color[])(object)new Color[dictionary2.Count]; int num2 = 0; int num3 = 0; foreach (string key3 in dictionary2.Keys) { int num4 = dictionary2[key3].Length / 3; modelAsset.submeshes[num2] = GenerateRange(num3, num3 + num4); num3 += num4; modelAsset.materials[num2] = dictionary[key3]; num2++; } return modelAsset; } public static void Initialize() { //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected O, but got Unknown //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Expected O, but got Unknown //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Expected O, but got Unknown //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Expected O, but got Unknown //IL_0295: Unknown result type (might be due to invalid IL or missing references) string text = Path.Combine(Utilities.rootPath, "Assets"); if (!Directory.Exists(text)) { return; } if (Mod.DEV_MODE) { ModAssetBundle modAssetBundle = new ModAssetBundle(); string path = Path.Combine(text, "Sprites"); if (Directory.Exists(path)) { string[] files = Directory.GetFiles(path); List list = new List(); string[] array = files; foreach (string text2 in array) { if (text2.EndsWith(".png")) { list.Add(ImportSprite(text2)); } } modAssetBundle.sprites = list.ToArray(); } string path2 = Path.Combine(text, "Models"); if (Directory.Exists(path2)) { string[] files2 = Directory.GetFiles(path2); List list2 = new List(); string[] array2 = files2; foreach (string text3 in array2) { if (text3.EndsWith(".dae")) { list2.Add(ImportModel(text3)); } } modAssetBundle.models = list2.ToArray(); } byte[] bytes = SerializationUtility.SerializeValue(modAssetBundle, (DataFormat)0, (SerializationContext)null); File.WriteAllBytes(Path.Combine(text, "assets.bin"), bytes); } string path3 = Path.Combine(text, "assets.bin"); if (!File.Exists(path3)) { return; } byte[] array3 = File.ReadAllBytes(path3); ModAssetBundle modAssetBundle2 = SerializationUtility.DeserializeValue(array3, (DataFormat)0, (DeserializationContext)null); if (modAssetBundle2.models != null) { ModelAsset[] models = modAssetBundle2.models; foreach (ModelAsset modelAsset in models) { Mesh val = new Mesh(); val.Clear(); val.vertices = modelAsset.vertices; val.normals = modelAsset.normals; val.uv = modelAsset.textures; val.subMeshCount = modelAsset.submeshes.Length; GameObject val2 = new GameObject(modelAsset.name); MeshFilter val3 = val2.AddComponent(); MeshRenderer val4 = val2.AddComponent(); val3.mesh = val; Material[] array4 = (Material[])(object)new Material[modelAsset.submeshes.Length]; for (int l = 0; l < modelAsset.submeshes.Length; l++) { val.SetTriangles(modelAsset.submeshes[l], l); } for (int m = 0; m < modelAsset.materials.Length; m++) { Material val5 = new Material(Shader.Find("Standard")); val5.EnableKeyword("_EMISSION"); val5.color = modelAsset.materials[m]; val5.SetFloat("_Glossiness", 0f); array4[m] = val5; } ((Renderer)val4).materials = array4; Mod.PoolObject(val2); Models.Add(val2); } } if (modAssetBundle2.sprites != null) { SpriteAsset[] sprites = modAssetBundle2.sprites; foreach (SpriteAsset spriteAsset in sprites) { Texture2D val6 = new Texture2D(1, 1, (TextureFormat)5, false); ImageConversion.LoadImage(val6, spriteAsset.data); ((Object)val6).name = spriteAsset.name; ((Texture)val6).filterMode = (FilterMode)0; Sprite val7 = Sprite.Create(val6, new Rect(0f, 0f, (float)((Texture)val6).width, (float)((Texture)val6).height), Vector2.one / 2f); ((Object)val7).name = spriteAsset.name; Sprites.Add(val7); } } } } [Serializable] public sealed class ModAssetBundle { public ModelAsset[] models; public SpriteAsset[] sprites; } [Serializable] public sealed class ModelAsset { public string name; public Vector3[] vertices; public Vector3[] normals; public Vector2[] textures; public Color[] materials; public int[][] submeshes; } [Serializable] public sealed class SpriteAsset { public string name; public byte[] data; public SpriteAsset(string name, byte[] data) { this.name = name; this.data = data; } } } namespace ApproachGod.Approach { [RequireComponent(typeof(Unit))] public class BattleStartDarkSphere : GameStateListener { [Header("球体设置")] [Tooltip("球体最终半径")] public float maxRadius = 15f; [Tooltip("扩张时间(秒)")] public float expandDuration = 0.7f; [Tooltip("半透明红色材质(留空将使用默认材质)")] public Material sphereMaterial; [Tooltip("红色色调影响强度 (0-1)")] [Range(0f, 1f)] public float redTintIntensity = 0.5f; [Tooltip("球体细分段数")] [Range(8f, 64f)] public int sphereSegments = 32; private GameObject redSphere; private Renderer sphereRenderer; private Unit ownerUnit; private bool hasTriggered = false; private Team ownerTeam; private Dictionary originalUnitColors = new Dictionary(); private TeamSystem teamSystem; private void Start() { ownerUnit = ((Component)this).GetComponent(); } private void InitializeSphere() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) redSphere = new GameObject("BattleRedSphere"); redSphere.transform.SetParent(((Component)this).transform); redSphere.transform.localPosition = Vector3.zero; MeshFilter val = redSphere.AddComponent(); sphereRenderer = (Renderer)(object)redSphere.AddComponent(); val.mesh = CreateHighPolySphere(sphereSegments); sphereRenderer.material = sphereMaterial ?? CreateDefaultRedMaterial(); redSphere.transform.localScale = Vector3.zero; if (Object.op_Implicit((Object)(object)redSphere.GetComponent())) { Object.Destroy((Object)(object)redSphere.GetComponent()); } } private Mesh CreateHighPolySphere(int segments) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown Mesh val = new Mesh(); ((Object)val).name = "HighPolySphere"; GenerateSphereData(segments, out var vertices, out var triangles); val.vertices = vertices; val.triangles = triangles; val.RecalculateNormals(); val.RecalculateBounds(); return val; } private void GenerateSphereData(int segments, out Vector3[] vertices, out int[] triangles) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = new List(); for (int i = 0; i <= segments; i++) { float num = (float)Math.PI / 2f - (float)Math.PI * (float)i / (float)segments; float num2 = Mathf.Sin(num); float num3 = Mathf.Cos(num); for (int j = 0; j <= segments; j++) { float num4 = (float)Math.PI * 2f * (float)j / (float)segments; float num5 = num3 * Mathf.Cos(num4); float num6 = num3 * Mathf.Sin(num4); list.Add(new Vector3(num5, num6, num2)); } } int count = list.Count; for (int k = 0; k < segments; k++) { for (int l = 0; l < segments; l++) { int num7 = k * (segments + 1) + l; int num8 = num7 + (segments + 1); list2.Add(num7); list2.Add(num8 + 1); list2.Add(num8); list2.Add(num7); list2.Add(num7 + 1); list2.Add(num8 + 1); } } vertices = list.ToArray(); triangles = list2.ToArray(); } private Material CreateDefaultRedMaterial() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(Shader.Find("Standard")); val.SetColor("_Color", new Color(1f, 0.2f, 0.2f, 0.7f)); val.SetFloat("_Mode", 3f); val.SetInt("_SrcBlend", 5); val.SetInt("_DstBlend", 10); val.SetInt("_ZWrite", 0); val.DisableKeyword("_ALPHATEST_ON"); val.EnableKeyword("_ALPHABLEND_ON"); val.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val.renderQueue = 3000; val.SetInt("_Cull", 0); return val; } public override void OnEnterBattleState() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (!hasTriggered && (Object)(object)ownerUnit != (Object)null && ((Component)ownerUnit).gameObject.activeInHierarchy) { hasTriggered = true; ownerTeam = ownerUnit.Team; teamSystem = World.Active.GetOrCreateManager(); InitializeSphere(); ((MonoBehaviour)this).StartCoroutine(ExpandSphere()); ((MonoBehaviour)this).StartCoroutine(UpdateRedTintEffect()); } } public override void OnEnterPlacementState() { } private IEnumerator ExpandSphere() { float elapsed = 0f; Vector3 startScale = Vector3.zero; Vector3 targetScale = Vector3.one * 2f * maxRadius; while (elapsed < expandDuration) { elapsed += Time.deltaTime; float t = Mathf.Clamp01(elapsed / expandDuration); t = 1f - Mathf.Pow(1f - t, 3f); redSphere.transform.localScale = Vector3.Lerp(startScale, targetScale, t); yield return null; } redSphere.transform.localScale = targetScale; } private IEnumerator UpdateRedTintEffect() { while ((Object)(object)redSphere != (Object)null) { UpdateAffectedUnits(); yield return null; } ResetAllUnitTints(); } private void UpdateAffectedUnits() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) if (teamSystem == null) { return; } Vector3 position = redSphere.transform.position; float num = redSphere.transform.localScale.x / 2f; List allUnits = teamSystem.GetAllUnits(); List list = new List(); foreach (Unit key in originalUnitColors.Keys) { if ((Object)(object)key == (Object)null || key.data.Dead) { list.Add(key); } } foreach (Unit item in list) { originalUnitColors.Remove(item); } foreach (Unit item2 in allUnits) { if ((Object)(object)item2 == (Object)null || item2.data.Dead) { continue; } bool flag = Vector3.Distance(((Component)item2).transform.position, position) <= num; UnitColorHandler component = ((Component)item2).GetComponent(); if (flag && (Object)(object)component != (Object)null) { if (!originalUnitColors.ContainsKey(item2)) { CaptureOriginalColors(item2, component); } ApplyRedTint(component); } else if (!flag && originalUnitColors.ContainsKey(item2) && (Object)(object)component != (Object)null) { RestoreOriginalColors(item2, component); originalUnitColors.Remove(item2); } } } private void CaptureOriginalColors(Unit unit, UnitColorHandler colorHandler) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) originalUnitColors[unit] = colorHandler.effectColor; } private void RestoreOriginalColors(Unit unit, UnitColorHandler colorHandler) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (!originalUnitColors.TryGetValue(unit, out var value)) { return; } for (int num = colorHandler.colors.Count - 1; num >= 0; num--) { if (colorHandler.colors[num].colorName == "BattleSphereRedTint") { colorHandler.colors.RemoveAt(num); } } colorHandler.effectColor = value; colorHandler.UpdateColors(); } private void ApplyRedTint(UnitColorHandler colorHandler) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown string text = "BattleSphereRedTint"; bool flag = false; for (int i = 0; i < colorHandler.colors.Count; i++) { if (colorHandler.colors[i].colorName == text) { colorHandler.colors[i].currentValue = redTintIntensity; colorHandler.colors[i].color = new Color(1f, 0f, 0f, redTintIntensity); flag = true; break; } } if (!flag) { UnitColorInstance item = new UnitColorInstance { colorName = text, color = new Color(1f, 0f, 0f, redTintIntensity), currentValue = redTintIntensity, acceptWhenDead = false }; colorHandler.colors.Add(item); } colorHandler.UpdateColors(); } private void ResetAllUnitTints() { foreach (Unit key in originalUnitColors.Keys) { if ((Object)(object)key != (Object)null) { UnitColorHandler component = ((Component)key).GetComponent(); if ((Object)(object)component != (Object)null) { RestoreOriginalColors(key, component); } } } originalUnitColors.Clear(); } protected override void OnDestroy() { ((GameStateListener)this).OnDestroy(); if (Object.op_Implicit((Object)(object)redSphere)) { Object.Destroy((Object)(object)redSphere); } ResetAllUnitTints(); } } public class ddsl : MonoBehaviour { private Unit unit; private float time; private void Start() { unit = ((Component)((Component)this).transform.root).GetComponentInChildren(); } private void Update() { //IL_0080: 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) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)unit.data.targetData.unit != (Object)null)) { return; } time += Time.deltaTime; if (time >= 15f) { time = 0f; for (int i = 0; i < 20; i++) { Vector3 position = unit.data.targetData.unit.data.mainRig.position; position.y -= 15f; Quaternion val = Quaternion.LookRotation(((Component)unit.data.targetData.unit.data.mainRig).transform.forward); Quaternion val2 = Quaternion.Euler(0f, Random.Range(-10f, 10f), 0f); Quaternion val3 = val * val2; } } } } public class EnemyKiller : MonoBehaviour { private Unit unit; private void Start() { unit = ((Component)((Component)this).transform.root).GetComponentInChildren(); } private void Update() { if ((Object)(object)unit == (Object)null || (Object)(object)unit.data == (Object)null) { return; } Unit[] source = Object.FindObjectsOfType(); List list = source.Where((Unit target) => (Object)(object)target != (Object)null && (Object)(object)target != (Object)(object)unit && (Object)(object)target.data != (Object)null && Vector3.Distance(((Component)unit).transform.position, ((Component)target).transform.position) < 5f && target.data.team != unit.data.team && !target.dead).ToList(); foreach (Unit item in list) { item.data.Dead = true; item.dead = true; Object.Destroy((Object)(object)((Component)item).gameObject); } } } public class FixedDirectionProjectile : MonoBehaviour { public Vector3 fixedDirection = Vector3.forward; public float speed = 10f; private MoveTransform moveTransform; private Rigidbody rig; private void Start() { moveTransform = ((Component)this).GetComponent(); rig = ((Component)this).GetComponent(); SetFixedDirection(); } private void FixedUpdate() { SetFixedDirection(); } private void SetFixedDirection() { //IL_0007: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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) //IL_0070: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_004c: Unknown result type (might be due to invalid IL or missing references) Vector3 normalized = ((Vector3)(ref fixedDirection)).normalized; if ((Object)(object)moveTransform != (Object)null) { moveTransform.velocity = normalized * speed; if (moveTransform.rotationFollowVelocity) { ((Component)this).transform.rotation = Quaternion.LookRotation(normalized); } } if ((Object)(object)rig != (Object)null) { rig.velocity = normalized * speed; ((Component)this).transform.rotation = Quaternion.LookRotation(normalized); } } } public class ForcedVictory : MonoBehaviour { private Unit unit; private bool hasTriggeredVictory = false; private void Start() { unit = ((Component)((Component)this).transform.root).GetComponentInChildren(); if ((Object)(object)unit == (Object)null) { ((Behaviour)this).enabled = false; } } private void Update() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 if (!hasTriggeredVictory && (Object)(object)unit != (Object)null && (int)ServiceLocator.GetService().GameState == 1) { TriggerUnitTeamVictory(); hasTriggeredVictory = true; } } private void TriggerUnitTeamVictory() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)unit == (Object)null)) { Team team = unit.data.team; GameModeService service = ServiceLocator.GetService(); BaseGameMode val = ((service != null) ? service.CurrentGameMode : null); if (val != null) { Language currentLanguage = GetCurrentLanguage(); string localizedWinText = GetLocalizedWinText(team, currentLanguage); val.DecideWinner(team, localizedWinText); } } } private Language GetCurrentLanguage() { //IL_0047: 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_0041: Unknown result type (might be due to invalid IL or missing references) IPlayerPrefsPlatform service = ServiceLocator.GetService(); if (service != null) { int num = service.GetInt("VIDEO_LANGUAGE", 0); if (num >= 0 && num < Enum.GetValues(typeof(Language)).Length) { return (Language)num; } } return (Language)0; } private string GetLocalizedWinText(Team winningTeam, Language lang) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 bool flag = (int)winningTeam == 0; string text = (flag ? "blue" : "red"); if ((int)lang == 7) { string text2 = (flag ? "蓝" : "红"); return "打败" + text2 + "方"; } string text3 = (flag ? "Blue" : "Red"); return "Defeated the " + text3 + " Team"; } } public class NotDead : MonoBehaviour { [HarmonyPatch(typeof(GameObject), "SetActive")] public static class PreventSetActiveFalsePatch { private static bool Prefix(GameObject __instance, bool value) { if (!value) { Unit val = __instance.GetComponent() ?? __instance.GetComponentInParent() ?? __instance.GetComponentInChildren(); if ((Object)(object)val != (Object)null && immortalUnits.Contains(val)) { return false; } } return true; } } [HarmonyPatch(typeof(WinConditionPropagator), "ClearAllWinConditions")] public static class WinConditionClearPatch { private static bool Prefix() { return teamsWithImmortals.Count == 0; } } [HarmonyPatch(typeof(HealthHandler), "AddDieAction")] public static class HealthHandlerAddDieActionPatch { private static bool Prefix(HealthHandler __instance) { Unit value = Traverse.Create((object)__instance).Field("unit").GetValue(); if ((Object)(object)value != (Object)null && immortalUnits.Contains(value)) { return false; } return true; } } public static class RigidbodyStatePatch { [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPostfix] private static void PostfixUseGravity(Rigidbody __instance, bool value) { Unit componentInParent = ((Component)__instance).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && immortalUnits.Contains(componentInParent) && !value) { __instance.useGravity = true; } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPostfix] private static void PostfixIsKinematic(Rigidbody __instance, bool value) { Unit componentInParent = ((Component)__instance).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && immortalUnits.Contains(componentInParent) && value) { __instance.isKinematic = false; } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static class PreventRendererDisablePatch { private static bool Prefix(Renderer __instance, bool value) { if (!value) { Unit componentInParent = ((Component)__instance).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && immortalUnits.Contains(componentInParent)) { return false; } } return true; } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static class DeadPropertyPatch { private static bool Prefix(ref bool value, DataHandler __instance) { Unit val = ((__instance != null) ? ((Component)__instance).GetComponentInParent() : null); if ((Object)(object)val != (Object)null && immortalUnits.Contains(val)) { value = false; return false; } return true; } } [HarmonyPatch(typeof(HealthHandler), "Die", new Type[] { typeof(Unit) })] public static class HealthHandlerDieWithUnitPatch { private static bool Prefix(HealthHandler __instance) { Unit value = Traverse.Create((object)__instance).Field("unit").GetValue(); return (Object)(object)value == (Object)null || !immortalUnits.Contains(value); } } [HarmonyPatch(typeof(HealthHandler), "Die", new Type[] { typeof(bool) })] public static class HealthHandlerDieWithBoolPatch { private static bool Prefix(HealthHandler __instance) { Unit value = Traverse.Create((object)__instance).Field("unit").GetValue(); return (Object)(object)value == (Object)null || !immortalUnits.Contains(value); } } [HarmonyPatch(typeof(HealthHandler), "TakeDamage")] public static class HealthHandlerTakeDamagePatch { private static bool Prefix(HealthHandler __instance, ref float damage) { Unit value = Traverse.Create((object)__instance).Field("unit").GetValue(); if ((Object)(object)value != (Object)null && immortalUnits.Contains(value)) { damage = 0f; return false; } return true; } } [HarmonyPatch(typeof(HealthHandler), "Update")] public static class PreventFallOutPatch { private static void Postfix(HealthHandler __instance) { Unit value = Traverse.Create((object)__instance).Field("unit").GetValue(); if ((Object)(object)value != (Object)null && immortalUnits.Contains(value) && (Object)(object)value.data != (Object)null) { value.data.health = value.data.maxHealth; value.data.Dead = false; value.dead = false; } } } [HarmonyPatch(typeof(UnitAPI), "SetIsDead")] public static class UnitAPISetIsDeadPatch { private static bool Prefix(UnitAPI __instance) { Unit value = Traverse.Create((object)__instance).Field("m_unit").GetValue(); return (Object)(object)value == (Object)null || !immortalUnits.Contains(value); } } [HarmonyPatch(typeof(UnitCreatorGameMode), "OnUnitDied")] public static class GameModeOnUnitDiedPatch { private static bool Prefix(Unit unit) { return !immortalUnits.Contains(unit); } } [HarmonyPatch(typeof(TeamSystem), "TriggerUnitDeathAction")] public static class TeamSystemTriggerDeathPatch { private static bool Prefix(Unit unit) { return !immortalUnits.Contains(unit); } } [HarmonyPatch(typeof(SandboxGameMode), "OnWinnerDecided")] private static class VictoryCurtainPatch { private static bool Prefix(Team winningTeam, string winSubText) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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) Team val = (Team)((int)winningTeam == 0); Unit[] array = Resources.FindObjectsOfTypeAll(); foreach (Unit val2 in array) { if (immortalUnits.Contains(val2) && val2.Team == val) { return false; } } return true; } } private Unit unit; private static bool isPatched = false; public static HashSet immortalUnits = new HashSet(); public static Dictionary> blueprintToUnits = new Dictionary>(); public static HashSet teamsWithImmortals = new HashSet(); private void Start() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) unit = ((Component)((Component)this).transform.root).GetComponentInChildren(); if ((Object)(object)unit != (Object)null) { unit.data.maxHealth = unit.unitBlueprint.health; immortalUnits.Add(unit); teamsWithImmortals.Add(unit.Team); UpdateBlueprintMap(unit, add: true); ResetUnitState(unit); MonitorECSEntity(unit); ResetRigidbodyState(unit); ForceUnitVisible(unit); } } private void ResetRigidbodyState(Unit unit) { object obj; if (unit == null) { obj = null; } else { DataHandler data = unit.data; if (data == null) { obj = null; } else { RigidbodyHolder allRigs = data.allRigs; obj = ((allRigs != null) ? allRigs.AllRigs : null); } } if (obj == null) { return; } Rigidbody[] allRigs2 = unit.data.allRigs.AllRigs; foreach (Rigidbody val in allRigs2) { if ((Object)(object)val != (Object)null) { val.useGravity = true; val.isKinematic = false; } } } private void ResetUnitState(Unit unit) { unit.dead = false; if ((Object)(object)unit.data != (Object)null) { unit.data.Dead = false; unit.data.health = unit.data.maxHealth; unit.data.immunityForSeconds = float.MaxValue; } } private void MonitorECSEntity(Unit unit) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) GameObjectEntity component = ((Component)unit).GetComponent(); if ((Object)(object)component != (Object)null && component.EntityManager.HasComponent(component.Entity)) { component.EntityManager.RemoveComponent(component.Entity); } } private void Update() { if (!((Object)(object)unit == (Object)null)) { ResetUnitState(unit); EnsureEssentialComponents(unit); MonitorECSEntity(unit); MaintainTeamList(unit); ResetRigidbodyState(unit); ForceUnitVisible(unit); } } private void EnsureEssentialComponents(Unit unit) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((Component)unit).GetComponent() == (Object)null) { ((Component)unit).gameObject.AddComponent(); } if ((Object)(object)((Component)unit).GetComponent() == (Object)null) { DataHandler val = ((Component)unit).gameObject.AddComponent(); val.unit = unit; val.team = unit.Team; } if ((Object)(object)((Component)unit).GetComponent() == (Object)null) { ((Component)unit).gameObject.AddComponent(); } } private void MaintainTeamList(Unit unit) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) World active = World.Active; TeamSystem val = ((active != null) ? active.GetExistingManager() : null); if (val != null) { Dictionary> value = Traverse.Create((object)val).Field("m_winConditionUnits").GetValue>>(); if (value != null && !value[unit.Team].Contains(unit)) { value[unit.Team].Add(unit); } } } private void UpdateBlueprintMap(Unit unit, bool add) { if ((Object)(object)unit.unitBlueprint == (Object)null) { return; } if (add) { if (!blueprintToUnits.ContainsKey(unit.unitBlueprint)) { blueprintToUnits[unit.unitBlueprint] = new List(); } if (!blueprintToUnits[unit.unitBlueprint].Contains(unit)) { blueprintToUnits[unit.unitBlueprint].Add(unit); } } else if (blueprintToUnits.ContainsKey(unit.unitBlueprint)) { blueprintToUnits[unit.unitBlueprint].Remove(unit); if (blueprintToUnits[unit.unitBlueprint].Count == 0) { blueprintToUnits.Remove(unit.unitBlueprint); } } } private void ForceUnitVisible(Unit unit) { Transform val = ((Component)unit).transform; while ((Object)(object)val != (Object)null) { if (!((Component)val).gameObject.activeSelf) { ((Component)val).gameObject.SetActive(true); } val = val.parent; } Renderer[] componentsInChildren = ((Component)unit).GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren) { if (!val2.enabled) { val2.enabled = true; } val2.shadowCastingMode = (ShadowCastingMode)1; val2.receiveShadows = true; } } private void OnDestroy() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)unit != (Object)null) { immortalUnits.Remove(unit); UpdateBlueprintMap(unit, add: false); if (!immortalUnits.Any((Unit u) => u.Team == unit.Team)) { teamsWithImmortals.Remove(unit.Team); } } } } public class NeverDie : MonoBehaviour { private UnitBlueprint blueprint; private Vector3 spawnPos; private Quaternion spawnRot; private Team team; private bool destroyed; public Team Team => team; private void Start() { //IL_001b: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) Unit componentInParent = ((Component)this).GetComponentInParent(); blueprint = componentInParent.unitBlueprint; spawnPos = ((Component)componentInParent).transform.position; spawnRot = ((Component)componentInParent).transform.rotation; team = componentInParent.Team; } private void OnDestroy() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) if (!destroyed) { destroyed = true; GameStateManager service = ServiceLocator.GetService(); if ((int)service.GameState == 1 && !((Object)(object)blueprint == (Object)null)) { Unit val = default(Unit); blueprint.Spawn(spawnPos, spawnRot, team, ref val, 1f, false, true, 0, (UnitPoolInfo?)null); } } } } public class Patches { [HarmonyPatch(typeof(GameObject), "SetActive")] private static class SetActivePatch { private static bool Prefix(GameObject __instance) { return !HasNotDie(((Component)__instance.transform.root).GetComponent()); } } [HarmonyPatch(typeof(HealthHandler), "Die", new Type[] { typeof(Unit) })] private static class DiePatch { private static bool Prefix(HealthHandler __instance) { return !HasNotDie(((Component)((Component)__instance).transform.root).GetComponent()); } } [HarmonyPatch(typeof(SandboxGameMode), "OnWinnerDecided")] private static class BlockVictoryCurtainPatch { private static bool Prefix(Team winningTeam, string winSubText) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) Team val = (Team)((int)winningTeam == 0); Unit[] array = Resources.FindObjectsOfTypeAll(); foreach (Unit val2 in array) { if ((Object)(object)((Component)val2).GetComponentInChildren() != (Object)null) { if (((Component)val2).GetComponentInChildren().Team == val) { return false; } if (((Component)val2).GetComponentInChildren().Team == winningTeam) { IsLegitVictory = true; } } } return true; } private static void Postfix() { IsLegitVictory = false; } } [HarmonyPatch(typeof(BaseGameMode), "DecideWinner")] private static class BlockVictoryPatch { private static bool Prefix(Team winningTeam) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) Team val = (Team)((int)winningTeam == 0); Unit[] array = Resources.FindObjectsOfTypeAll(); foreach (Unit val2 in array) { if ((Object)(object)((Component)val2).GetComponentInChildren() != (Object)null && ((Component)val2).GetComponentInChildren().Team == val) { return false; } } return true; } } [HarmonyPatch(typeof(DataHandler), "set_Dead")] private static class DeadSetterPatch { private static bool Prefix(DataHandler __instance, bool value) { if (value && HasNotDie(__instance.unit)) { return false; } return true; } } [HarmonyPatch(typeof(DataHandler), "get_Dead")] private static class DeadGetterPatch { private static bool Prefix(DataHandler __instance, ref bool __result) { if (__result && HasNotDie(__instance.unit)) { __result = false; } return true; } } [HarmonyPatch(typeof(BaseGameMode), "OnUnitDied")] private static class OnUnitDiedPatch { private static bool Prefix(Unit unit) { return !HasNotDie(unit); } } [HarmonyPatch(typeof(TeamSystem), "TriggerUnitDeathAction")] private static class TriggerUnitDeathActionPatch { private static bool Prefix(Unit unit) { return !HasNotDie(unit); } } [HarmonyPatch(typeof(BattleManager), "CheckIfBattleOver")] private static class CheckIfBattleOverPatch { private static IEnumerable Transpiler(IEnumerable instructions) { FieldInfo deadField = AccessTools.Field(typeof(Unit), "dead"); MethodInfo isDead = AccessTools.Method(typeof(CheckIfBattleOverPatch), "IsDead", (Type[])null, (Type[])null); foreach (CodeInstruction ci in instructions) { int num; if (ci.opcode == OpCodes.Ldfld) { object operand = ci.operand; if (operand is FieldInfo fi) { num = ((fi == deadField) ? 1 : 0); goto IL_00e8; } } num = 0; goto IL_00e8; IL_00e8: if (num != 0) { yield return new CodeInstruction(OpCodes.Call, (object)isDead); } else { yield return ci; } } } private static bool IsDead(Unit unit) { if (HasNotDie(unit)) { return false; } return unit.dead; } } [HarmonyPatch(typeof(VerticalCurtainController), "PeekCurtains", new Type[] { })] private static class PeekGuard { private static bool Prefix() { Unit[] array = Resources.FindObjectsOfTypeAll(); foreach (Unit val in array) { if ((Object)(object)((Component)val).GetComponentInChildren() != (Object)null) { if (IsLegitVictory) { return true; } return false; } } return true; } } [HarmonyPatch(typeof(Object), "Destroy", new Type[] { typeof(Object), typeof(float) })] private static class GameObjectDestroyPatch { private static bool Prefix(Object obj) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Invalid comparison between Unknown and I4 if (obj is GameObject && (Object)(object)((Component)((GameObject)obj).transform.root).GetComponentInChildren() != (Object)null && (Object)(object)((Component)((GameObject)obj).transform.root).GetComponent() != (Object)null && (int)ServiceLocator.GetService().GameState == 1) { return false; } return true; } } [HarmonyPatch(typeof(Object), "DestroyImmediate", new Type[] { typeof(Object), typeof(bool) })] private static class DestroyImmediatePatch { private static bool Prefix(Object obj) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Invalid comparison between Unknown and I4 if (obj is GameObject && (Object)(object)((Component)((GameObject)obj).transform.root).GetComponentInChildren() != (Object)null && (Object)(object)((Component)((GameObject)obj).transform.root).GetComponent() != (Object)null && (int)ServiceLocator.GetService().GameState == 1) { return false; } return true; } } public static bool IsLegitVictory; private static bool HasNotDie(Unit unit) { return (Object)(object)unit != (Object)null && (Object)(object)((Component)((Component)unit).transform.root).GetComponentInChildren() != (Object)null; } } public class ReaperT : MonoBehaviour { public class AttackArm { public enum ArmState { Free, Holding } public GameObject targetObj; public GameObject restPosObj; public float lerpSpeed; public Vector3 smoothTargetPos; public Vector3 targetPos; public ArmState armState; public Unit heldUnit; public float counter; public bool hasDealtDamage; } public string swingRef; public string hitRef; private Transform targetTrans; private List attackArms = new List(); public AnimationCurve reachCurve; public AnimationCurve goBackToHoldCurve; public AnimationCurve goBackToHoldCurveFollowMainRigAmount; public AnimationCurve throwCurve; [SerializeField] private Renderer[] armRenderers; private float followMainRigAmount; private Unit unit; private float counter; private float snapSpeed; private void Start() { //IL_006d: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < ((Component)this).transform.childCount; i++) { AttackArm attackArm = new AttackArm(); attackArm.targetObj = ((Component)((Component)this).transform.GetChild(i).Find("Target")).gameObject; attackArm.restPosObj = ((Component)((Component)this).transform.GetChild(i).Find("RestPos")).gameObject; attackArm.lerpSpeed = Random.Range(0.5f, 1.5f); attackArm.smoothTargetPos = ((Component)this).transform.position; attackArm.targetPos = ((Component)this).transform.position; attackArms.Add(attackArm); } unit = ((Component)((Component)this).transform.root).GetComponent(); if (armRenderers != null && (Object)(object)unit != (Object)null) { unit.AddRenderersToShowHide(armRenderers); } targetTrans = ((Component)unit.data.mainRig).transform; ((Component)this).transform.SetParent((Transform)null); } private void Update() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)targetTrans == (Object)null || unit.data.Dead) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } ((Component)this).transform.SetPositionAndRotation(targetTrans.position, Quaternion.Lerp(((Component)this).transform.rotation, targetTrans.rotation, Time.deltaTime * 2.5f)); counter += Time.deltaTime; for (int i = 0; i < attackArms.Count; i++) { attackArms[i].counter += Time.deltaTime; Vector3 val = Vector3.Lerp(attackArms[i].smoothTargetPos, attackArms[i].targetPos, Time.deltaTime * 10f); if (attackArms[i].armState == AttackArm.ArmState.Free) { attackArms[i].targetPos = Vector3.Lerp(attackArms[i].targetPos, attackArms[i].restPosObj.transform.position + GetPerlinPos(attackArms[i].lerpSpeed) * 2f, Time.deltaTime * 3f * attackArms[i].lerpSpeed); attackArms[i].smoothTargetPos = val; snapSpeed = 0f; } else { snapSpeed += Time.deltaTime; attackArms[i].smoothTargetPos = Vector3.Lerp(val, attackArms[i].targetPos, snapSpeed); } attackArms[i].targetObj.transform.position = attackArms[i].smoothTargetPos; } if (counter > 0.5f) { CheckAttack(attackArms[Random.Range(0, attackArms.Count)]); } } private void FixedUpdate() { counter += Time.deltaTime; for (int i = 0; i < attackArms.Count; i++) { Hold(attackArms[i]); } } private void Hold(AttackArm attack) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)attack.heldUnit != (Object)null && (Object)(object)attack.heldUnit.data.mainRig != (Object)null && !attack.heldUnit.dead && !attack.hasDealtDamage) { ((Damagable)attack.heldUnit.data.healthHandler).TakeDamage(1000f, Vector3.up, (Unit)null, (DamageType)0); attack.hasDealtDamage = true; } } private void CheckAttack(AttackArm attack) { if (attack.armState != AttackArm.ArmState.Holding && Object.op_Implicit((Object)(object)unit.data.targetData) && !(unit.data.distanceToTarget > 5f)) { counter = 0f; attack.counter = 0f; attack.hasDealtDamage = false; ((MonoBehaviour)this).StartCoroutine(DoAttack(attack, unit.data.targetData.unit)); } } private IEnumerator DoAttack(AttackArm attack, Unit targetUnit) { attack.armState = AttackArm.ArmState.Holding; attack.heldUnit = targetUnit; float c = 0f; float t = AnimationCurveFunctions.GetAnimLength(reachCurve); if (swingRef != "") { ServiceLocator.GetService().PlaySoundEffect(swingRef, 1f, ((Component)this).transform.position, (MaterialType)0, (Transform)null, 1f); } while (c < t && Object.op_Implicit((Object)(object)targetUnit) && !targetUnit.dead) { Vector3 a = targetUnit.data.mainRig.position - attack.restPosObj.transform.position; attack.targetPos = attack.restPosObj.transform.position + a * reachCurve.Evaluate(c); c += Time.deltaTime; yield return null; } c = 0f; t = AnimationCurveFunctions.GetAnimLength(goBackToHoldCurve); bool secondAttackTriggered = false; if (Object.op_Implicit((Object)(object)targetUnit) && hitRef != "") { ServiceLocator.GetService().PlaySoundEffect(hitRef, 1f, ((Component)this).transform.position, (MaterialType)0, (Transform)null, 1f); } while (c < t && Object.op_Implicit((Object)(object)targetUnit) && !targetUnit.dead) { Vector3 a2 = targetUnit.data.mainRig.position - attack.restPosObj.transform.position; attack.targetPos = attack.restPosObj.transform.position + a2 * goBackToHoldCurve.Evaluate(c); if (c > t * 0.5f && !secondAttackTriggered) { secondAttackTriggered = true; ((MonoBehaviour)this).StartCoroutine(SecondAttack(attack, targetUnit)); } c += Time.deltaTime; yield return null; } attack.armState = AttackArm.ArmState.Free; attack.heldUnit = null; } private IEnumerator SecondAttack(AttackArm attack, Unit targetUnit) { if (!targetUnit.dead) { if (swingRef != "") { ServiceLocator.GetService().PlaySoundEffect(swingRef, 0.8f, ((Component)this).transform.position, (MaterialType)0, (Transform)null, 1f); } float c = 0f; float t = AnimationCurveFunctions.GetAnimLength(reachCurve) * 0.7f; attack.hasDealtDamage = false; while (c < t && Object.op_Implicit((Object)(object)targetUnit) && !targetUnit.dead) { Vector3 a = targetUnit.data.mainRig.position - attack.restPosObj.transform.position; attack.targetPos = attack.restPosObj.transform.position + a * reachCurve.Evaluate(c); c += Time.deltaTime; yield return null; } if (Object.op_Implicit((Object)(object)targetUnit) && hitRef != "") { ServiceLocator.GetService().PlaySoundEffect(hitRef, 0.8f, ((Component)this).transform.position, (MaterialType)0, (Transform)null, 1f); } } } private Vector3 GetPerlinPos(float input) { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) input *= 0.2f; Vector3 result = default(Vector3); ((Vector3)(ref result))..ctor(0f, 0f, 0f); result.x += Mathf.PerlinNoise(Time.time * input, 0f); result.y += Mathf.PerlinNoise(Time.time * input, Time.time * input); result.z += Mathf.PerlinNoise(0f, Time.time * input); result.x -= 0.5f; result.y -= 0.5f; result.z -= 0.5f; return result; } } public class ReaperWC { public static ModMove CloneSkillWithNewScript(ModMove originalMove, Type newScriptType) { ModMove modMove = originalMove.Clone(); GameObject internalObject = modMove.internalObject; Component component = internalObject.GetComponent("ReaperWings"); if ((Object)(object)component == (Object)null) { return modMove; } Object.Destroy((Object)(object)component); Component val = internalObject.AddComponent(newScriptType); if ((Object)(object)val == (Object)null) { return modMove; } CopyParametersWithReflection(component, val); return modMove; } private static void CopyParametersWithReflection(Component source, Component target) { Type type = ((object)source).GetType(); Type type2 = ((object)target).GetType(); CopyParameter(source, target, type, type2, "swingRef"); CopyParameter(source, target, type, type2, "hitRef"); CopyParameter(source, target, type, type2, "reachCurve"); CopyParameter(source, target, type, type2, "goBackToHoldCurve"); CopyParameter(source, target, type, type2, "goBackToHoldCurveFollowMainRigAmount"); CopyParameter(source, target, type, type2, "throwCurve"); CopyParameter(source, target, type, type2, "armRenderers"); } private static void CopyParameter(Component source, Component target, Type sourceType, Type targetType, string paramName) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown FieldInfo field = sourceType.GetField(paramName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { return; } FieldInfo field2 = targetType.GetField(paramName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 == null || !field2.FieldType.IsAssignableFrom(field.FieldType)) { return; } if (field.FieldType == typeof(AnimationCurve)) { AnimationCurve sourceCurve = (AnimationCurve)field.GetValue(source); field2.SetValue(target, CloneAnimationCurve(sourceCurve)); } else if (field.FieldType.IsGenericType && field.FieldType.GetGenericTypeDefinition() == typeof(List<>)) { object value = field.GetValue(source); if (value != null) { Type fieldType = field.FieldType; object obj = Activator.CreateInstance(fieldType); MethodInfo method = fieldType.GetMethod("AddRange"); method.Invoke(obj, new object[1] { value }); field2.SetValue(target, obj); } } else { field2.SetValue(target, field.GetValue(source)); } } private static AnimationCurve CloneAnimationCurve(AnimationCurve sourceCurve) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_008c: 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 (sourceCurve == null) { return null; } Keyframe[] array = (Keyframe[])(object)new Keyframe[sourceCurve.keys.Length]; for (int i = 0; i < sourceCurve.keys.Length; i++) { Keyframe val = sourceCurve.keys[i]; array[i] = new Keyframe(((Keyframe)(ref val)).time, ((Keyframe)(ref val)).value, ((Keyframe)(ref val)).inTangent, ((Keyframe)(ref val)).outTangent, ((Keyframe)(ref val)).inWeight, ((Keyframe)(ref val)).outWeight); } AnimationCurve val2 = new AnimationCurve(array); val2.preWrapMode = sourceCurve.preWrapMode; val2.postWrapMode = sourceCurve.postWrapMode; return val2; } } public class UpdateKill : MonoBehaviour { private Unit currentUnit; private TeamSystem teamSystem; private GameModeService gameModeService; private GameStateManager gameStateManager; private WinConditionPropagator winConditionPropagator; private bool hasTriggered = false; private bool isInitializing = false; private static FieldInfo dieActionField; private static FieldInfo isInvulnerableField; private static FieldInfo willBeRewivedField; private static FieldInfo aiEnabledField; private static MethodInfo transformDestroyMethod; private static MethodInfo objectDestroyMethod; static UpdateKill() { dieActionField = typeof(HealthHandler).GetField("DieAction", BindingFlags.Instance | BindingFlags.NonPublic); isInvulnerableField = typeof(HealthHandler).GetField("isInvulnerable", BindingFlags.Instance | BindingFlags.NonPublic); willBeRewivedField = typeof(HealthHandler).GetField("willBeRewived", BindingFlags.Instance | BindingFlags.NonPublic); aiEnabledField = typeof(Unit).GetField("m_aiEnabled", BindingFlags.Instance | BindingFlags.NonPublic); transformDestroyMethod = typeof(Transform).GetMethod("Destroy", BindingFlags.Instance | BindingFlags.NonPublic); objectDestroyMethod = typeof(Object).GetMethod("Destroy", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[2] { typeof(Object), typeof(bool) }, null); } private void Awake() { currentUnit = ((Component)((Component)this).transform.root).GetComponentInChildren(); ((MonoBehaviour)this).StartCoroutine(InitializeServices()); } private IEnumerator InitializeServices() { if (isInitializing) { yield break; } isInitializing = true; while (true) { if (gameStateManager == null) { try { gameStateManager = ServiceLocator.GetService(); } catch { } } if ((Object)(object)gameModeService == (Object)null) { try { gameModeService = ServiceLocator.GetService(); } catch { } } if (teamSystem == null) { try { UpdateKill updateKill = this; World active = World.Active; updateKill.teamSystem = ((active != null) ? active.GetExistingManager() : null); } catch { } } if (winConditionPropagator == null && (Object)(object)gameModeService != (Object)null) { try { UpdateKill updateKill2 = this; BaseGameMode currentGameMode = gameModeService.CurrentGameMode; updateKill2.winConditionPropagator = ((currentGameMode != null) ? currentGameMode.WinConditionPropagator : null); } catch { } } if (gameStateManager != null) { gameStateManager.GameStateChanged += OnGameStateChanged; CheckAndExecuteIfInBattle(); } if (gameStateManager != null && (Object)(object)gameModeService != (Object)null && teamSystem != null) { break; } yield return null; } isInitializing = false; } private void CheckAndExecuteIfInBattle() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 if (!hasTriggered) { GameStateManager obj = gameStateManager; if (obj != null && (int)obj.GameState == 1) { hasTriggered = true; InstantKillEnemies(); } } } private void OnGameStateChanged(GameState newState) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)newState == 1 && !hasTriggered) { hasTriggered = true; InstantKillEnemies(); } } private void InstantKillEnemies() { //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gameModeService == (Object)null) { try { gameModeService = ServiceLocator.GetService(); } catch { return; } } if (teamSystem == null) { World active = World.Active; teamSystem = ((active != null) ? active.GetExistingManager() : null); if (teamSystem == null) { return; } } if (winConditionPropagator == null) { GameModeService obj2 = gameModeService; if (((obj2 != null) ? obj2.CurrentGameMode : null) != null) { winConditionPropagator = gameModeService.CurrentGameMode.WinConditionPropagator; } } if (BoltNetwork.IsClient && !BoltNetwork.IsServer) { return; } Unit[] array = Resources.FindObjectsOfTypeAll(); Unit[] array2 = array; foreach (Unit val in array2) { if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeInHierarchy && (Object)(object)val != (Object)(object)currentUnit && (Object)(object)val.data != (Object)null && (Object)(object)currentUnit?.data != (Object)null && val.data.team != currentUnit.data.team) { DisableUnitActions(val); KillUnit彻底(val); } } } private void DisableUnitActions(Unit unit) { //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)unit == (Object)null) { return; } aiEnabledField?.SetValue(unit, false); WeaponHandler component = ((Component)unit).GetComponent(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; FieldInfo field = typeof(WeaponHandler).GetField("weapons", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null && field.GetValue(component) is IEnumerable enumerable) { foreach (object item in enumerable) { Component val = (Component)((item is Component) ? item : null); if (val != null) { val.gameObject.SetActive(false); } } } } if ((Object)(object)unit.data?.mainRig != (Object)null) { unit.data.mainRig.constraints = (RigidbodyConstraints)126; unit.data.mainRig.velocity = Vector3.zero; unit.data.mainRig.angularVelocity = Vector3.zero; unit.data.mainRig.Sleep(); } GeneralInput component2 = ((Component)unit).GetComponent(); if ((Object)(object)component2 != (Object)null) { ((Behaviour)component2).enabled = false; } Move component3 = ((Component)unit).GetComponent(); if ((Object)(object)component3 != (Object)null) { ((Behaviour)component3).enabled = false; } } private void KillUnit彻底(Unit unit) { if ((Object)(object)unit == (Object)null) { return; } DataHandler data = unit.data; if (data != null && data.Dead) { return; } HealthHandler val = unit.data?.healthHandler; if ((Object)(object)val == (Object)null) { return; } unit.data.immunityForSeconds = 0f; isInvulnerableField?.SetValue(val, false); unit.data.lifeTime = 100f; willBeRewivedField?.SetValue(val, false); Action action = null; if (dieActionField != null) { action = dieActionField.GetValue(val) as Action; dieActionField.SetValue(val, null); } try { unit.data.health = float.MinValue; unit.data.maxHealth = 0f; typeof(HealthHandler).GetMethod("Die", BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[1] { typeof(Unit) }, null)?.Invoke(val, new object[1]); unit.data.Dead = true; unit.dead = true; typeof(DataHandler).GetField("dead", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(unit.data, true); UnitAPI component = ((Component)unit).GetComponent(); if (component != null) { component.SetIsDead(); } } finally { if (action != null && dieActionField != null) { dieActionField.SetValue(val, action); } } TeamSystem obj = teamSystem; if (obj != null) { obj.TriggerUnitDeathAction(unit); } GameModeService obj2 = gameModeService; if (obj2 != null) { BaseGameMode currentGameMode = obj2.CurrentGameMode; if (currentGameMode != null) { currentGameMode.OnUnitDied(unit); } } WinConditionPropagator obj3 = winConditionPropagator; if (obj3 != null) { obj3.OnUnitDied(unit); } if (winConditionPropagator != null) { FieldInfo field = typeof(WinConditionPropagator).GetField("m_conditions", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null && field.GetValue(winConditionPropagator) is IEnumerable enumerable) { foreach (object item in enumerable) { item?.GetType().GetMethod("OnUnitDied", new Type[1] { typeof(Unit) })?.Invoke(item, new object[1] { unit }); } } } if (BoltNetwork.IsServer) { UnitDiedEvent val2 = UnitDiedEvent.Create((GlobalTargets)8, (ReliabilityModes)2); val2.UnitSmallNetworkId = unit.SmallNetworkId; ((Event)val2).Send(); } ForceEngineLevelDestruction(unit); } private void ForceEngineLevelDestruction(Unit unit) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown if ((Object)(object)unit == (Object)null || (Object)(object)((Component)unit).gameObject == (Object)null) { return; } GameObject gameObject = ((Component)unit).gameObject; Transform transform = gameObject.transform; List list = new List(); foreach (Transform item in transform) { Transform val = item; if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject != (Object)null) { list.Add(((Component)val).gameObject); } } transformDestroyMethod?.Invoke(transform, null); transform.parent = null; ((Object)gameObject).hideFlags = (HideFlags)61; foreach (GameObject item2 in list) { if ((Object)(object)item2 != (Object)null) { Object.DestroyImmediate((Object)(object)item2, true); } } Component[] components = gameObject.GetComponents(); Component[] array = components; foreach (Component val2 in array) { if ((Object)(object)val2 != (Object)null && !(val2 is Transform)) { Object.DestroyImmediate((Object)(object)val2, true); } } Renderer[] componentsInChildren = gameObject.GetComponentsInChildren(); Renderer[] array2 = componentsInChildren; foreach (Renderer val3 in array2) { if ((Object)(object)val3 != (Object)null) { val3.material = null; val3.enabled = false; } } MeshFilter[] componentsInChildren2 = gameObject.GetComponentsInChildren(); MeshFilter[] array3 = componentsInChildren2; foreach (MeshFilter val4 in array3) { if ((Object)(object)val4 != (Object)null) { val4.sharedMesh = null; } } objectDestroyMethod?.Invoke(null, new object[2] { gameObject, true }); GC.Collect(); GC.WaitForPendingFinalizers(); } private void OnDestroy() { if (gameStateManager != null) { gameStateManager.GameStateChanged -= OnGameStateChanged; } } } public class 光速 : MonoBehaviour { private Unit unit; private MovementHandler movementHandler; private WheelMovementHandler wheelMovementHandler; private DataHandler dataHandler; private StandingHandler standingHandler; private Animator selfAnimator; private List allUnits = new List(); private Dictionary originalMoveMultipliers = new Dictionary(); private Dictionary originalWheelMultipliers = new Dictionary(); private Dictionary originalAnimatorSpeeds = new Dictionary(); private float originalSelfOffset; private float originalStandingForce; private bool originalCanFall; private float originalContrast; private ColorGrading colorGrading; [Header("速度设置")] public float lightSpeedMultiplier = 30f; public float slowSpeedMultiplier = 0.05f; public float slowAnimationMultiplier = 0.2f; [Header("视觉增强")] [Range(0f, 2f)] public float contrastBoost = 1.5f; public float angularDragMultiplier = 5f; public float standingForceBoost = 2f; public float centerOfMassOffset = -0.5f; [Header("视觉效果")] public ParticleSystem speedTrail; public ParticleSystem lightStreaks; public PostProcessProfile postProcessProfile; private void Start() { unit = ((Component)((Component)this).transform.root).GetComponentInChildren(); if (Object.op_Implicit((Object)(object)unit)) { movementHandler = ((Component)unit).GetComponentInChildren(); wheelMovementHandler = ((Component)unit).GetComponentInChildren(); dataHandler = ((Component)unit).GetComponentInChildren(); standingHandler = ((Component)unit).GetComponentInChildren(); selfAnimator = ((Component)unit).GetComponentInChildren(); if (Object.op_Implicit((Object)(object)standingHandler)) { originalSelfOffset = standingHandler.selfOffset; originalStandingForce = standingHandler.standingData.standingForce; } if (Object.op_Implicit((Object)(object)dataHandler)) { originalCanFall = dataHandler.canFall; } } if (Object.op_Implicit((Object)(object)postProcessProfile) && postProcessProfile.TryGetSettings(ref colorGrading)) { originalContrast = ((ParameterOverride)(object)colorGrading.contrast).value; } RefreshAllUnits(); } private void Update() { //IL_0030: 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) if (Object.op_Implicit((Object)(object)unit) && Object.op_Implicit((Object)(object)dataHandler)) { Vector3 velocity = dataHandler.mainRig.velocity; bool isMoving = ((Vector3)(ref velocity)).magnitude > 0.1f; ApplyStableLightSpeed(isMoving); ApplySlowMotionToOthers(isMoving); UpdateContrast(isMoving); UpdateVisualEffects(isMoving); } } private void ApplyStableLightSpeed(bool isMoving) { if (isMoving) { if (Object.op_Implicit((Object)(object)movementHandler)) { movementHandler.multiplier = lightSpeedMultiplier; } if (Object.op_Implicit((Object)(object)wheelMovementHandler)) { wheelMovementHandler.multiplier = lightSpeedMultiplier; } } else { if (Object.op_Implicit((Object)(object)movementHandler)) { movementHandler.multiplier = 1f; } if (Object.op_Implicit((Object)(object)wheelMovementHandler)) { wheelMovementHandler.multiplier = 1f; } } } private void ApplySlowMotionToOthers(bool isMoving) { if (Time.frameCount % 60 == 0) { RefreshAllUnits(); } foreach (Unit allUnit in allUnits) { if ((Object)(object)allUnit == (Object)(object)unit || !Object.op_Implicit((Object)(object)allUnit)) { continue; } MovementHandler componentInChildren = ((Component)allUnit).GetComponentInChildren(); WheelMovementHandler componentInChildren2 = ((Component)allUnit).GetComponentInChildren(); Animator componentInChildren3 = ((Component)allUnit).GetComponentInChildren(); if (isMoving) { if (Object.op_Implicit((Object)(object)componentInChildren) && !originalMoveMultipliers.ContainsKey(allUnit)) { originalMoveMultipliers[allUnit] = componentInChildren.multiplier; } if (Object.op_Implicit((Object)(object)componentInChildren2) && !originalWheelMultipliers.ContainsKey(allUnit)) { originalWheelMultipliers[allUnit] = componentInChildren2.multiplier; } if (Object.op_Implicit((Object)(object)componentInChildren3) && !originalAnimatorSpeeds.ContainsKey(allUnit)) { originalAnimatorSpeeds[allUnit] = componentInChildren3.speed; } if (Object.op_Implicit((Object)(object)componentInChildren)) { componentInChildren.multiplier = slowSpeedMultiplier; } if (Object.op_Implicit((Object)(object)componentInChildren2)) { componentInChildren2.multiplier = slowSpeedMultiplier; } if (Object.op_Implicit((Object)(object)componentInChildren3)) { componentInChildren3.speed = slowAnimationMultiplier; } } else { if (Object.op_Implicit((Object)(object)componentInChildren) && originalMoveMultipliers.TryGetValue(allUnit, out var value)) { componentInChildren.multiplier = value; } if (Object.op_Implicit((Object)(object)componentInChildren2) && originalWheelMultipliers.TryGetValue(allUnit, out var value2)) { componentInChildren2.multiplier = value2; } if (Object.op_Implicit((Object)(object)componentInChildren3) && originalAnimatorSpeeds.TryGetValue(allUnit, out var value3)) { componentInChildren3.speed = value3; } } } } private void UpdateContrast(bool isMoving) { if (Object.op_Implicit((Object)(object)colorGrading)) { ((ParameterOverride)(object)colorGrading.contrast).value = (isMoving ? (originalContrast * contrastBoost) : originalContrast); } } private void UpdateVisualEffects(bool isMoving) { if (Object.op_Implicit((Object)(object)speedTrail)) { ToggleParticle(speedTrail, isMoving); } if (Object.op_Implicit((Object)(object)lightStreaks)) { ToggleParticle(lightStreaks, isMoving); } } private void ToggleParticle(ParticleSystem particle, bool play) { if (play && !particle.isPlaying) { particle.Play(); } else if (!play && particle.isPlaying) { particle.Stop(); } } private void RefreshAllUnits() { allUnits.Clear(); World active = World.Active; TeamSystem val = ((active != null) ? active.GetExistingManager() : null); if (val != null) { allUnits.AddRange(val.GetAllUnits()); } } private void OnDisable() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)dataHandler?.mainRig)) { dataHandler.mainRig.angularDrag = dataHandler.mainRig.angularDrag / angularDragMultiplier; dataHandler.mainRig.centerOfMass = Vector3.zero; } if (Object.op_Implicit((Object)(object)standingHandler)) { standingHandler.selfOffset = originalSelfOffset; standingHandler.standingData.standingForce = originalStandingForce; } if (Object.op_Implicit((Object)(object)dataHandler)) { dataHandler.canFall = originalCanFall; } if (Object.op_Implicit((Object)(object)selfAnimator)) { selfAnimator.speed = 1f; } foreach (Unit allUnit in allUnits) { ApplySlowMotionToOthers(isMoving: false); } if (Object.op_Implicit((Object)(object)colorGrading)) { ((ParameterOverride)(object)colorGrading.contrast).value = originalContrast; } } } public class 免疫友军 : ExplosionAddEffect { private Unit unit; private void Awake() { unit = ((Component)((Component)this).GetComponentInParent()).GetComponentInParent(); } public override void DoEffect(GameObject target) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) Unit component = ((Component)target.transform.root).GetComponent(); if (!((Object)(object)component != (Object)null) || component.Team != unit.Team) { ((ExplosionAddEffect)this).DoEffect(target); } } } public class 全图冰冻配置 : MonoBehaviour { public Unit unit; private ConditionalEvent conditionalEvent; private void Start() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0030: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown unit = ((Component)this).GetComponentInParent() ?? ((Component)this).GetComponent(); conditionalEvent = ((Component)this).GetComponent(); ConditionalEventInstance val = new ConditionalEventInstance { checkAutomatically = true }; EventCondition val2 = new EventCondition { conditionType = (ConditionType)0, valueType = (ValueType)0, value = 5f, startOnCD = false }; val.conditions = (EventCondition[])(object)new EventCondition[1] { val2 }; val.turnOnEvent = new UnityEvent(); val.turnOnEvent.AddListener(new UnityAction(冰冻)); ConditionalEventInstance[] first = (ConditionalEventInstance[])(((object)conditionalEvent.events) ?? ((object)new ConditionalEventInstance[0])); conditionalEvent.events = first.Concat((IEnumerable)(object)new ConditionalEventInstance[1] { val }).ToArray(); for (int i = 0; i < conditionalEvent.events.Length; i++) { conditionalEvent.events[i].NetworkId = i; } } private void 冰冻() { if ((Object)(object)unit != (Object)null) { 全图单位冰冻 全图单位冰冻2 = new 全图单位冰冻(); 全图单位冰冻2.全图单位冰冻执行(unit); } } } public class 全图单位冰冻 { public void 全图单位冰冻执行(Unit 自身单位) { //IL_0023: 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) Unit[] array = Object.FindObjectsOfType(); foreach (Unit val in array) { if ((Object)(object)val != (Object)null && val.data.team != 自身单位.data.team) { UnitEffectBase val2 = UnitEffectBase.AddEffectToTarget(((Component)((Component)val).transform.root).gameObject, Mod.GetEffect("IceUllrEffect").internalObject); if ((Object)(object)val2 != (Object)null) { val2.Ping(); } else { UnitEffectBase.AddEffectToTarget(((Component)((Component)val).transform.root).gameObject, Mod.GetEffect("IceUllrEffect").internalObject); } } } } } public class 无视距离帧伤触手 : MonoBehaviour { [Header("攻击效率设置")] [Tooltip("同时攻击的触手数量")] public int simultaneousAttacks = 2; [Tooltip("基础攻击间隔(秒)")] public float baseAttackCooldown = 0.05f; [Tooltip("每下攻击的伤害值")] public float attackDamage = 1000f; [Tooltip("攻击动画时长(秒)")] public float attackAnimationDuration = 0.2f; [Tooltip("攻击范围(单位)")] public float attackRange = float.PositiveInfinity; [Header("爆炸效果设置")] [Tooltip("攻击命中时产生的爆炸预制体")] public GameObject explosionPrefab; [Tooltip("爆炸效果持续时间(秒),超过此时间自动销毁")] public float explosionLifetime = 2f; public string swingRef; public string hitRef; private Transform targetTrans; private List attackArms = new List(); public AnimationCurve reachCurve; public AnimationCurve goBackToHoldCurve; public AnimationCurve goBackToHoldCurveFollowMainRigAmount; public AnimationCurve throwCurve; [SerializeField] private Renderer[] armRenderers; private float followMainRigAmount; private Unit unit; private float counter; private float snapSpeed; private void Start() { //IL_006d: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < ((Component)this).transform.childCount; i++) { AttackArm attackArm = new AttackArm(); attackArm.targetObj = ((Component)((Component)this).transform.GetChild(i).Find("Target")).gameObject; attackArm.restPosObj = ((Component)((Component)this).transform.GetChild(i).Find("RestPos")).gameObject; attackArm.lerpSpeed = Random.Range(0.5f, 1.5f); attackArm.smoothTargetPos = ((Component)this).transform.position; attackArm.targetPos = ((Component)this).transform.position; attackArms.Add(attackArm); } unit = ((Component)((Component)this).transform.root).GetComponent(); if (armRenderers != null && (Object)(object)unit != (Object)null) { unit.AddRenderersToShowHide(armRenderers); } targetTrans = ((Component)unit.data.mainRig).transform; ((Component)this).transform.SetParent((Transform)null); } private void Update() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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) if ((Object)(object)targetTrans == (Object)null || unit.data.Dead) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } ((Component)this).transform.SetPositionAndRotation(targetTrans.position, Quaternion.Lerp(((Component)this).transform.rotation, targetTrans.rotation, Time.deltaTime * 2.5f)); counter += Time.deltaTime; for (int i = 0; i < attackArms.Count; i++) { UpdateArmState(attackArms[i]); } TryInitiateMultipleAttacks(); } private void UpdateArmState(AttackArm attack) { //IL_0014: 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) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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) //IL_005c: 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_006b: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) attack.counter += Time.deltaTime; Vector3 val = Vector3.Lerp(attack.smoothTargetPos, attack.targetPos, Time.deltaTime * 15f); if (attack.armState == AttackArm.ArmState.Free) { attack.targetPos = Vector3.Lerp(attack.targetPos, attack.restPosObj.transform.position + GetPerlinPos(attack.lerpSpeed) * 2f, Time.deltaTime * 5f * attack.lerpSpeed); attack.smoothTargetPos = val; snapSpeed = 0f; } else if (attack.armState == AttackArm.ArmState.Attacking) { snapSpeed += Time.deltaTime * 5f; attack.smoothTargetPos = Vector3.Lerp(val, attack.targetPos, snapSpeed); } attack.targetObj.transform.position = attack.smoothTargetPos; } private void TryInitiateMultipleAttacks() { if (counter < baseAttackCooldown || !Object.op_Implicit((Object)(object)unit.data.targetData) || unit.data.distanceToTarget > attackRange) { return; } int num = 0; counter = 0f; foreach (AttackArm attackArm in attackArms) { if (num >= simultaneousAttacks) { break; } if (attackArm.armState == AttackArm.ArmState.Free && attackArm.counter > baseAttackCooldown) { attackArm.counter = 0f; ((MonoBehaviour)this).StartCoroutine(DoAttack(attackArm, unit.data.targetData.unit)); num++; } } } private IEnumerator DoAttack(AttackArm attack, Unit targetUnit) { attack.armState = AttackArm.ArmState.Attacking; float c = 0f; float t = attackAnimationDuration; bool hasExploded = false; if (swingRef != "") { ServiceLocator.GetService().PlaySoundEffect(swingRef, 1f, ((Component)this).transform.position, (MaterialType)0, (Transform)null, 1f); } while (c < t && Object.op_Implicit((Object)(object)targetUnit) && !targetUnit.dead && Object.op_Implicit((Object)(object)targetUnit.data.mainRig)) { Vector3 a = targetUnit.data.mainRig.position - attack.restPosObj.transform.position; attack.targetPos = attack.restPosObj.transform.position + a * reachCurve.Evaluate(c); if ((Object)(object)targetUnit != (Object)null && !targetUnit.dead) { ((Damagable)targetUnit.data.healthHandler).TakeDamage(attackDamage, Vector3.up, (Unit)null, (DamageType)0); if (!hasExploded && c > t * 0.5f) { SpawnExplosion(targetUnit.data.mainRig.position); hasExploded = true; } } c += Time.deltaTime; yield return null; } if (!hasExploded && Object.op_Implicit((Object)(object)targetUnit) && !targetUnit.dead) { SpawnExplosion(targetUnit.data.mainRig.position); } c = 0f; t = attackAnimationDuration * 0.7f; if (Object.op_Implicit((Object)(object)targetUnit) && !targetUnit.dead && hitRef != "") { ServiceLocator.GetService().PlaySoundEffect(hitRef, 1f, ((Component)this).transform.position, (MaterialType)0, (Transform)null, 1f); } while (c < t && Object.op_Implicit((Object)(object)targetUnit) && !targetUnit.dead && Object.op_Implicit((Object)(object)targetUnit.data.mainRig)) { Vector3 a2 = targetUnit.data.mainRig.position - attack.restPosObj.transform.position; attack.targetPos = attack.restPosObj.transform.position + a2 * goBackToHoldCurve.Evaluate(c); c += Time.deltaTime; yield return null; } attack.armState = AttackArm.ArmState.Free; } private void SpawnExplosion(Vector3 position) { //IL_0018: 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) if ((Object)(object)explosionPrefab != (Object)null) { GameObject val = Object.Instantiate(explosionPrefab, position, Quaternion.identity); Object.Destroy((Object)(object)val, explosionLifetime); } } private Vector3 GetPerlinPos(float input) { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) input *= 0.2f; Vector3 result = default(Vector3); ((Vector3)(ref result))..ctor(0f, 0f, 0f); result.x += Mathf.PerlinNoise(Time.time * input, 0f); result.y += Mathf.PerlinNoise(Time.time * input, Time.time * input); result.z += Mathf.PerlinNoise(0f, Time.time * input); result.x -= 0.5f; result.y -= 0.5f; result.z -= 0.5f; return result; } } public class AttackArm { public enum ArmState { Free, Attacking } public GameObject targetObj; public GameObject restPosObj; public float lerpSpeed; public Vector3 smoothTargetPos; public Vector3 targetPos; public ArmState armState; public float counter; } internal class 防高频碰撞 : MonoBehaviour { private class CollisionListener : MonoBehaviour { public Func OnProjectileCollision; private void OnCollisionEnter(Collision collision) { OnProjectileCollision?.Invoke(collision); } } private Unit unit; private int lastCollisionFrame = -2; private const int frameCooldown = 2; private void Start() { unit = ((Component)((Component)this).transform.root).GetComponentInChildren(); if ((Object)(object)unit != (Object)null) { Collider[] componentsInChildren = ((Component)unit).GetComponentsInChildren(); Collider[] array = componentsInChildren; foreach (Collider val in array) { CollisionListener collisionListener = ((Component)val).gameObject.AddComponent(); collisionListener.OnProjectileCollision = (Func)Delegate.Combine(collisionListener.OnProjectileCollision, new Func(CheckCollisionPermission)); } } } private void Update() { } private bool CheckCollisionPermission(Collision collision) { if ((Object)(object)((Component)collision.collider).GetComponent() == (Object)null) { return true; } int frameCount = Time.frameCount; if (frameCount - lastCollisionFrame >= 2) { lastCollisionFrame = frameCount; return true; } if (collision.contacts.Length != 0) { Collider otherCollider = ((ContactPoint)(ref collision.contacts[0])).otherCollider; Physics.IgnoreCollision(collision.collider, otherCollider, true); ((MonoBehaviour)this).Invoke("ReenableCollision", Time.deltaTime); } return false; } private void ReenableCollision() { } } public class 放置抹杀 : MonoBehaviour { private Unit myunit; private TeamSystem teamSystem; private GameModeService gameModeService; private Team team; private void Start() { //IL_0040: 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) myunit = ((Component)((Component)this).transform.root).GetComponentInChildren(); World active = World.Active; teamSystem = ((active != null) ? active.GetExistingManager() : null); gameModeService = ServiceLocator.GetService(); team = (Team)((int)myunit.Team == 0); 抹杀敌方(); } private void 抹杀敌方() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) List teamUnits = teamSystem.GetTeamUnits(team); foreach (Unit item in teamUnits) { item.data.health = float.MinValue; item.data.maxHealth = 0f; item.data.Dead = true; item.dead = true; typeof(DataHandler).GetField("dead", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(item.data, true); UnitAPI component = ((Component)item).GetComponent(); if (component != null) { component.SetIsDead(); } TeamSystem obj = teamSystem; if (obj != null) { obj.TriggerUnitDeathAction(item); } GameModeService obj2 = gameModeService; if (obj2 != null) { BaseGameMode currentGameMode = obj2.CurrentGameMode; if (currentGameMode != null) { currentGameMode.OnUnitDied(item); } } Object.DestroyImmediate((Object)(object)((Component)item).gameObject); gameModeService.CurrentGameMode.OnWinnerDecided(myunit.Team, ""); } } } public static class 蓝图补丁 { public static void apply(Harmony harmony) { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown MethodInfo method = typeof(UnitBlueprint).GetMethod("Spawn", new Type[9] { typeof(Vector3), typeof(Quaternion), typeof(Team), typeof(Unit).MakeByRefType(), typeof(float), typeof(bool), typeof(bool), typeof(int), typeof(UnitPoolInfo?) }); HarmonyMethod val = new HarmonyMethod(typeof(蓝图补丁).GetMethod("MyPrefix")); harmony.Patch((MethodBase)method, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static bool MyPrefix() { World active = World.Active; List list = ((active != null) ? active.GetExistingManager().GetAllUnits() : null); foreach (Unit item in list) { if (Object.op_Implicit((Object)(object)((Component)item).GetComponentInChildren<放置抹杀>())) { return false; } } return true; } } public class 战斗回调 { public static event Action GameStateChanged; public static void gameStateChanged(GameState newState) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) 战斗回调.GameStateChanged?.Invoke(newState); } } [HarmonyPatch(typeof(GameStateManager), "set_GameState")] internal static class GameStatePatch { private static void Prefix(GameState value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) 战斗回调.gameStateChanged(value); } } public class 开战秒杀 : MonoBehaviour { private Unit unit; private Team team; private TeamSystem teamSystem; private string redcolor = ColorUtility.ToHtmlStringRGB(new Color(14f / 15f, 22f / 51f, 0.4f, 1f)); private string bluecolor = ColorUtility.ToHtmlStringRGB(new Color(59f / 85f, 0.77254903f, 1f, 1f)); private string text; private void Start() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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) unit = ((Component)((Component)this).transform.root).GetComponentInChildren(); team = unit.Team; World active = World.Active; teamSystem = ((active != null) ? active.GetExistingManager() : null); string text = (((int)team == 0) ? redcolor : bluecolor); this.text = (((int)team == 0) ? ("红队胜利") : ("蓝队胜利")); 战斗回调.GameStateChanged += 杀; } private void 杀(GameState newState) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0069: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown if ((int)newState != 1) { return; } Patches.IsLegitVictory = true; ServiceLocator.GetService().CurrentGameMode.CurtainController.PeekCurtains(text, ""); Patches.IsLegitVictory = false; Unit[] array = Resources.FindObjectsOfTypeAll(); Unit[] array2 = array; foreach (Unit val in array2) { if (!((Object)(object)val != (Object)null) || !((Component)val).gameObject.activeInHierarchy || val.Team == team) { continue; } val.data.Dead = true; val.dead = true; TeamSystem obj = teamSystem; if (obj != null) { obj.TriggerUnitDeathAction(val); } GameObject gameObject = ((Component)val).gameObject; foreach (Transform item in gameObject.transform) { Transform val2 = item; Object.DestroyImmediate((Object)(object)((Component)val2).gameObject); } Object.DestroyImmediate((Object)(object)gameObject); } } private void OnDestroy() { 战斗回调.GameStateChanged -= 杀; } } }