Decompiled source of Wraith v1.12.1
Wraith.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using DM; using HarmonyLib; using Landfall.TABS; using Landfall.TABS.AI; using Landfall.TABS.AI.Systems; using Landfall.TABS.GameMode; using Landfall.TABS.GameState; using TFBGames; using UnityEngine; using UnityEngine.Rendering; using WHAT; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("Wraith")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("全身黑红紫、没有头、血量与伤害无限")] [assembly: AssemblyFileVersion("1.12.1.0")] [assembly: AssemblyInformationalVersion("1.12.1")] [assembly: AssemblyProduct("Wraith")] [assembly: AssemblyTitle("Wraith")] [assembly: AssemblyVersion("1.12.1.0")] namespace WHAT { public static class 的的了了 { public static string RainbowText(string text, int offset) { //IL_0029: 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) //IL_0049: 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_006b: 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_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_0188: 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) //IL_00a9: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_0159: Unknown result type (might be due to invalid IL or missing references) string text2 = ""; for (int i = 0; i < text.Length; i++) { float num = (float)((i + offset) % text.Length) / (float)text.Length; Color val = ((!(num < 1f / 7f)) ? ((!(num < 0.2857143f)) ? ((!(num < 0.42857143f)) ? ((!(num < 0.5714286f)) ? ((!(num < 0.71428573f)) ? ((!(num < 0.85714287f)) ? Color.Lerp(new Color(0f, 0.75f, 1f), Color.red, (num - 0.85714287f) * 7f) : Color.Lerp(Color.cyan, new Color(0f, 0.75f, 1f), (num - 0.71428573f) * 7f)) : Color.Lerp(Color.green, Color.cyan, (num - 0.5714286f) * 7f)) : Color.Lerp(new Color(0.5f, 1f, 0f), Color.green, (num - 0.42857143f) * 7f)) : Color.Lerp(Color.yellow, new Color(0.5f, 1f, 0f), (num - 0.2857143f) * 7f)) : Color.Lerp(new Color(1f, 0.5f, 0f), Color.yellow, (num - 1f / 7f) * 7f)) : Color.Lerp(Color.red, new Color(1f, 0.5f, 0f), num * 7f)); string arg = ColorUtility.ToHtmlStringRGB(val); text2 += $"<color=#{arg}>{text[i]}</color>"; } return text2; } } } namespace Wraith { [BepInPlugin("wraith.tabs.mod", "Wraith", "1.12.1")] public class Launcher : BaseUnityPlugin { public const string GUID = "wraith.tabs.mod"; public const string PluginName = "Wraith"; public const string Version = "1.12.1"; private void Awake() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown WraithDefense.Install(); GameObject val = new GameObject("wraith.tabs.mod"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<WraithHost>(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[无头将领] 已加载(等待内容数据库)"); } } public class WraithHost : MonoBehaviour { private static bool registered; private float nextTry; private float attachNext; private void Update() { if (!registered) { if (Time.unscaledTime < nextTry) { return; } nextTry = Time.unscaledTime + 0.5f; if (Ready()) { try { WraithContent.Register(); registered = true; } catch (Exception ex) { Debug.LogError((object)("[无头将领] 注册失败:" + ex)); } } } else { Attach(); } } private static bool Ready() { try { ContentDatabase val = ContentDatabase.Instance(); if (val == null || val.LandfallContentDatabase == null) { return false; } using IEnumerator<UnitBlueprint> enumerator = val.GetAllUnitBlueprints().GetEnumerator(); if (enumerator.MoveNext()) { _ = enumerator.Current; return true; } } catch { } return false; } private static bool IsOurs(Unit u) { if ((Object)(object)u == (Object)null || (Object)(object)u.unitBlueprint == (Object)null) { return false; } if ((Object)(object)WraithContent.Blueprint != (Object)null && (Object)(object)u.unitBlueprint == (Object)(object)WraithContent.Blueprint) { return true; } try { Faction faction = WraithContent.Faction; if ((Object)(object)faction != (Object)null && faction.Units != null && Array.IndexOf(faction.Units, u.unitBlueprint) >= 0) { return true; } } catch { } try { if (u.unitBlueprint.Entity != null && u.unitBlueprint.Entity.Name == "无头将领") { return true; } } catch { } return false; } private void Attach() { if (Time.unscaledTime < attachNext) { return; } attachNext = Time.unscaledTime + 0.4f; Unit[] array = Object.FindObjectsOfType<Unit>(); foreach (Unit val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.unitBlueprint == (Object)null) && val.unitBlueprint.Entity != null && IsOurs(val)) { WraithBody.Attach(val); } } } } public static class WraithContent { public const string FactionName = "X"; public const string UnitName = "无头将领"; private const int FactionId = 10001; public static Faction Faction; public static UnitBlueprint Blueprint; private const int WeaponId = 1386275079; private static readonly int[] WeaponColors = new int[4] { 44, 76, 79, 49 }; private static readonly int[] ClothIds = new int[11] { 253938956, 528053068, 1070973117, 1305854072, 1067677518, 366634457, 2025477200, 241985544, 483264105, 286947794, 1838205446 }; private static readonly int[][] ClothColors = new int[11][] { new int[1] { 76 }, new int[1] { 44 }, new int[3] { 46, 76, 76 }, new int[2] { 76, 46 }, new int[3] { 76, -1, -1 }, new int[1] { 46 }, new int[2] { -1, -1 }, new int[2] { -1, -1 }, new int[2] { 76, -1 }, new int[1] { 45 }, new int[2] { 46, 76 } }; public static void Register() { Faction = SLMATool.CreateFaction("X", (UnitBlueprint[])null, (Sprite)null, 10001); if ((Object)(object)Faction == (Object)null) { Debug.LogError((object)"[无头将领] 派系创建失败"); return; } Blueprint = SLMATool.CreateUnit("无头将领", (UnitBlueprint)null, Faction, WraithFx.Icon()); if ((Object)(object)Blueprint == (Object)null) { Debug.LogError((object)"[无头将领] CreateUnit 返回 null"); return; } try { Blueprint.health = float.PositiveInfinity; } catch { } try { Blueprint.healthMultiplier = 1f; } catch { } try { Blueprint.damageMultiplier = float.PositiveInfinity; } catch { } try { Blueprint.massMultiplier = 1f; } catch { } try { Blueprint.sizeMultiplier = 1.34f; } catch { } try { Blueprint.forceNoRandomSize = true; } catch { } try { Blueprint.LeftWeapon = null; } catch { } try { SLMATool.UnitCost(Blueprint, 0); } catch { } ApplyWeapon(Blueprint); ApplyClothes(Blueprint); string text = ((Blueprint.Entity != null) ? Blueprint.Entity.Name : "?"); string text2 = (((Object)(object)Blueprint.UnitBase != (Object)null) ? ((Object)Blueprint.UnitBase).name : "null"); Debug.Log((object)("[无头将领] 创建完成:Entity=" + text + " / 模型=" + text2 + " / 派系单位数=" + ((Faction.Units != null) ? Faction.Units.Length : (-1)))); } private static void ApplyWeapon(UnitBlueprint bp) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_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) try { GameObject val = FindWeapon(1386275079); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("[无头将领] 没找到 Jarl_Axe(ID " + 1386275079 + "),保持空手")); return; } bp.RightWeapon = val; bp.LeftWeapon = null; bp.holdinigWithTwoHands = true; PropItemData val2 = new PropItemData(); val2.m_positionOffset = Vector3.zero; val2.m_scale = Vector3.one; val2.m_colors = WeaponColors; val2.m_isTeamColor = new bool[WeaponColors.Length]; bp.RightWeaponData = val2; Debug.Log((object)("[无头将领] 武器已套用:" + ((Object)val).name + " / 双手持握 / 配色槽 " + WeaponColors.Length + " 个")); } catch (Exception ex) { Debug.LogError((object)("[无头将领] 武器异常:" + ex.Message)); } } private static GameObject FindWeapon(int id) { //IL_00e0: 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) try { Dictionary<string, Dictionary<string, object>> sDic = SLMALoader.SDic; if (sDic != null && sDic.ContainsKey("weapons")) { foreach (KeyValuePair<string, object> item in sDic["weapons"]) { object value = item.Value; GameObject val = (GameObject)((value is GameObject) ? value : null); if (!((Object)(object)val == (Object)null)) { WeaponItem val2 = val.GetComponent<WeaponItem>(); if ((Object)(object)val2 == (Object)null) { val2 = val.GetComponentInChildren<WeaponItem>(true); } if (!((Object)(object)val2 == (Object)null) && ((CharacterItem)val2).Entity != null && ((CharacterItem)val2).Entity.GUID.m_ID == id) { return val; } } } } } catch { } try { WeaponItem[] array = Resources.FindObjectsOfTypeAll<WeaponItem>(); foreach (WeaponItem val3 in array) { if (!((Object)(object)val3 == (Object)null) && ((CharacterItem)val3).Entity != null && ((CharacterItem)val3).Entity.GUID.m_ID == id) { return ((Component)val3).gameObject; } } } catch { } return null; } private static void ApplyClothes(UnitBlueprint bp) { //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_0044: 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_0050: Unknown result type (might be due to invalid IL or missing references) try { List<GameObject> list = new List<GameObject>(); List<PropItemData> list2 = new List<PropItemData>(); for (int i = 0; i < ClothIds.Length; i++) { GameObject val = FindCloth(ClothIds[i]); if (!((Object)(object)val == (Object)null)) { list.Add(val); int[] array = ClothColors[i]; PropItemData val2 = new PropItemData(); val2.m_positionOffset = Vector3.zero; val2.m_scale = Vector3.one; val2.m_colors = array; val2.m_isTeamColor = new bool[array.Length]; list2.Add(val2); } } if (list.Count == 0) { Debug.LogWarning((object)"[无头将领] 服装一件都没匹配到(SDic clothes 里没有这些 ID)"); return; } bp.m_props = list.ToArray(); bp.m_propData = list2.ToArray(); Debug.Log((object)("[无头将领] 服装已套用 " + list.Count + " / " + ClothIds.Length + " 件")); } catch (Exception ex) { Debug.LogError((object)("[无头将领] 服装异常:" + ex.Message)); } } private static GameObject FindCloth(int id) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) try { Dictionary<string, Dictionary<string, object>> sDic = SLMALoader.SDic; if (sDic == null || !sDic.ContainsKey("clothes")) { return null; } foreach (KeyValuePair<string, object> item in sDic["clothes"]) { object value = item.Value; GameObject val = (GameObject)((value is GameObject) ? value : null); if (!((Object)(object)val == (Object)null)) { PropItem val2 = val.GetComponent<PropItem>(); if ((Object)(object)val2 == (Object)null) { val2 = val.GetComponentInChildren<PropItem>(true); } if (!((Object)(object)val2 == (Object)null) && ((CharacterItem)val2).Entity != null && ((CharacterItem)val2).Entity.GUID.m_ID == id) { return val; } } } } catch { } return null; } } public class WraithBody : MonoBehaviour { private Unit unit; private DataHandler data; private bool built; private float retry; private float rehideNext; private int eyesMade; private Material eyeMaterial; private readonly List<Renderer> headRenderers = new List<Renderer>(); private static readonly Color Low = new Color(0.043f, 0f, 0.024f); private static readonly Color Mid = new Color(0.169f, 0f, 0.125f); private static readonly Color High = new Color(0.294f, 0.043f, 0.247f); private static Material handMat; private static Texture2D dotTex; public static void Attach(Unit u) { if (!((Object)(object)u == (Object)null) && !((Object)(object)((Component)u).GetComponent<WraithBody>() != (Object)null)) { ((Component)u).gameObject.AddComponent<WraithBody>(); ((Component)u).gameObject.AddComponent<WraithOutline>(); ((Component)u).gameObject.AddComponent<WraithSound>(); } } private void Start() { TryBuild(); } private void Update() { if (!built) { if (!(Time.unscaledTime < retry)) { retry = Time.unscaledTime + 0.25f; TryBuild(); } } else if (!((Object)(object)data == (Object)null)) { InfiniteHealth(); if (Time.unscaledTime >= rehideNext) { rehideNext = Time.unscaledTime + 0.5f; Rehide(); ShrinkHead(); } } } private void TryBuild() { if (built) { return; } if ((Object)(object)unit == (Object)null) { unit = ((Component)this).GetComponentInParent<Unit>(); } if ((Object)(object)unit == (Object)null) { unit = ((Component)this).GetComponent<Unit>(); } if (!((Object)(object)unit == (Object)null)) { data = unit.data; if (!((Object)(object)data == (Object)null)) { built = true; GameObject src = FindEyeSource(); Paint(); HideHead(); ScatterEyes(src); AddHandParticles(); ShrinkHead(); Debug.Log((object)("[Wraith] 外观就绪(眼睛 " + eyesMade + " 只)")); } } } private void Paint() { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Expected O, but got Unknown //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0238: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true); if (componentsInChildren.Length == 0) { return; } float num = float.MaxValue; float num2 = float.MinValue; Bounds bounds; for (int i = 0; i < componentsInChildren.Length; i++) { if (!((Object)(object)componentsInChildren[i] == (Object)null) && componentsInChildren[i].enabled) { float num3 = num; bounds = componentsInChildren[i].bounds; num = Mathf.Min(num3, ((Bounds)(ref bounds)).min.y); float num4 = num2; bounds = componentsInChildren[i].bounds; num2 = Mathf.Max(num4, ((Bounds)(ref bounds)).max.y); } } if (num2 <= num) { num = ((Component)this).transform.position.y; num2 = num + 2f; } foreach (Renderer val in componentsInChildren) { if ((Object)(object)val == (Object)null || !val.enabled || val is TrailRenderer || val is LineRenderer || val is ParticleSystemRenderer) { continue; } try { if ((Object)(object)((Component)val).GetComponentInParent<WeaponItem>() != (Object)null) { continue; } } catch { } bounds = val.bounds; float num5 = Mathf.Clamp01((((Bounds)(ref bounds)).center.y - num) / (num2 - num)); Color val2 = ((num5 < 0.5f) ? Color.Lerp(Low, Mid, num5 * 2f) : Color.Lerp(Mid, High, (num5 - 0.5f) * 2f)); Material[] materials = val.materials; foreach (Material val3 in materials) { if ((Object)(object)val3 == (Object)null) { continue; } try { val3.color = val2; } catch { } try { if (val3.HasProperty("_Color")) { val3.SetColor("_Color", val2); } } catch { } try { if (val3.HasProperty("_EmissionColor")) { val3.EnableKeyword("_EMISSION"); val3.SetColor("_EmissionColor", new Color(val2.r * 0.45f, 0f, val2.b * 0.45f)); } } catch { } } try { MaterialPropertyBlock val4 = new MaterialPropertyBlock(); val.GetPropertyBlock(val4); val4.SetColor("_Color", val2); val4.SetColor("_BaseColor", val2); val.SetPropertyBlock(val4); } catch { } } } private void HideHead() { headRenderers.Clear(); Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true); if ((Object)(object)data.head != (Object)null) { Renderer[] componentsInChildren2 = ((Component)data.head).GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { if (!IsCloth(componentsInChildren2[i])) { AddHead(componentsInChildren2[i]); } } } foreach (Renderer val in componentsInChildren) { if ((Object)(object)val == (Object)null || IsCloth(val)) { continue; } string text = ((Object)((Component)val).gameObject).name.ToLower(); if (text.Contains("head") || text.Contains("hair") || text.Contains("skull") || text.Contains("neck")) { AddHead(val); continue; } Transform parent = ((Component)val).transform.parent; while ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)((Component)this).transform) { if (((Object)parent).name.ToLower().Contains("head")) { AddHead(val); break; } parent = parent.parent; } } Rehide(); } private void AddHead(Renderer r) { if (!((Object)(object)r == (Object)null) && !(r is TrailRenderer) && !(r is LineRenderer) && !headRenderers.Contains(r)) { headRenderers.Add(r); } } private void Rehide() { bool bypass = WraithDefense.Bypass; WraithDefense.Bypass = true; try { for (int i = 0; i < headRenderers.Count; i++) { Renderer val = headRenderers[i]; if (!((Object)(object)val == (Object)null)) { try { val.enabled = false; } catch { } try { val.forceRenderingOff = true; } catch { } } } } finally { WraithDefense.Bypass = bypass; } } private void ShrinkHead() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)data == (Object)null) { return; } Transform head = data.head; if ((Object)(object)head == (Object)null) { return; } try { head.localScale = Vector3.zero; } catch { } } private static bool IsCloth(Renderer r) { if ((Object)(object)r == (Object)null) { return false; } try { if ((Object)(object)((Component)r).GetComponentInParent<PropItem>() != (Object)null) { return true; } } catch { } return false; } private GameObject FindEyeSource() { if ((Object)(object)data.head == (Object)null) { return null; } Renderer[] componentsInChildren = ((Component)data.head).GetComponentsInChildren<Renderer>(true); GameObject val = null; foreach (Renderer val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && !IsCloth(val2)) { if (((Object)((Component)val2).gameObject).name.ToLower().Contains("eye")) { eyeMaterial = val2.sharedMaterial; return ((Component)val2).gameObject; } if ((Object)(object)val == (Object)null) { val = ((Component)val2).gameObject; eyeMaterial = val2.sharedMaterial; } } } return val; } private void ScatterEyes(GameObject src) { //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015a: 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_0164: 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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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_00c9: 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) if ((Object)(object)src == (Object)null) { return; } Transform[] array = (Transform[])(object)new Transform[9] { data.torso, data.leftArm, data.rightArm, data.leftHand, data.rightHand, data.legLeft, data.legRight, data.footLeft, data.footRight }; foreach (Transform val in array) { if ((Object)(object)val == (Object)null) { continue; } Renderer componentInChildren = ((Component)val).GetComponentInChildren<Renderer>(); if ((Object)(object)componentInChildren == (Object)null) { continue; } Bounds bounds = componentInChildren.bounds; float num = Mathf.Max(0.06f, Mathf.Min(((Bounds)(ref bounds)).extents.x, ((Bounds)(ref bounds)).extents.y) * 0.55f); int num2 = (((Object)(object)val == (Object)(object)data.torso) ? 10 : 3); for (int j = 0; j < num2; j++) { Vector3 onUnitSphere = Random.onUnitSphere; onUnitSphere.y = Mathf.Abs(onUnitSphere.y) * 0.6f + 0.2f; ((Vector3)(ref onUnitSphere)).Normalize(); Vector3 val2 = ((Bounds)(ref bounds)).center + Vector3.Scale(onUnitSphere, ((Bounds)(ref bounds)).extents) * 1.02f; try { GameObject val3 = Object.Instantiate<GameObject>(src, val2, Quaternion.LookRotation(onUnitSphere), val); Rigidbody component = val3.GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } Collider[] componentsInChildren = val3.GetComponentsInChildren<Collider>(true); for (int k = 0; k < componentsInChildren.Length; k++) { if ((Object)(object)componentsInChildren[k] != (Object)null) { Object.Destroy((Object)(object)componentsInChildren[k]); } } MonoBehaviour[] componentsInChildren2 = val3.GetComponentsInChildren<MonoBehaviour>(true); for (int l = 0; l < componentsInChildren2.Length; l++) { if (!((Object)(object)componentsInChildren2[l] == (Object)null)) { string name = ((object)componentsInChildren2[l]).GetType().Name; if (!(name == "MeshRenderer") && !(name == "Transform")) { Object.Destroy((Object)(object)componentsInChildren2[l]); } } } Renderer[] componentsInChildren3 = val3.GetComponentsInChildren<Renderer>(true); for (int m = 0; m < componentsInChildren3.Length; m++) { if ((Object)(object)componentsInChildren3[m] == (Object)null) { continue; } componentsInChildren3[m].enabled = true; try { componentsInChildren3[m].forceRenderingOff = false; } catch { } if ((Object)(object)eyeMaterial != (Object)null) { try { componentsInChildren3[m].sharedMaterial = eyeMaterial; } catch { } } } ((Object)val3).name = "WraithEye"; val3.transform.localScale = val3.transform.localScale * Mathf.Clamp(num * 1.6f, 0.35f, 1.2f); eyesMade++; } catch { } } } } private void AddHandParticles() { AddHandParticles(((Object)(object)data.leftHand != (Object)null) ? data.leftHand : data.leftArm, "L"); AddHandParticles(((Object)(object)data.rightHand != (Object)null) ? data.rightHand : data.rightArm, "R"); } private void AddHandParticles(Transform hand, string side) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_005f: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00cf: 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_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) //IL_010e: 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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)hand == (Object)null) { return; } try { GameObject val = new GameObject("WraithHandFx_" + side); val.transform.SetParent(hand, false); val.transform.localPosition = Vector3.zero; ParticleSystem val2 = val.AddComponent<ParticleSystem>(); MainModule main = val2.main; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(0.85f); ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0.55f); ((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.16f); ((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0.72f, 0.12f, 1f, 0.95f), new Color(0.35f, 0.02f, 0.55f, 0.85f)); ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).maxParticles = 120; EmissionModule emission = val2.emission; ((EmissionModule)(ref emission)).enabled = true; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(28f); ShapeModule shape = val2.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = 0.09f; SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.EaseInOut(0f, 1f, 1f, 0.1f)); ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val3 = new Gradient(); val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(new Color(0.75f, 0.15f, 1f), 0f), new GradientColorKey(new Color(0.3f, 0.02f, 0.5f), 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[2] { new GradientAlphaKey(0.95f, 0f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val3); ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>(); component.renderMode = (ParticleSystemRenderMode)0; ((Renderer)component).material = ParticleMat(); ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; val2.Play(); } catch (Exception ex) { Debug.LogWarning((object)("[Wraith] 手部粒子失败:" + ex.Message)); } } private static Material ParticleMat() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown if ((Object)(object)handMat != (Object)null) { return handMat; } Shader val = Shader.Find("Particles/Standard Unlit"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Legacy Shaders/Particles/Additive"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Sprites/Default"); } handMat = new Material(val); ((Object)handMat).name = "WraithHandMat"; handMat.mainTexture = (Texture)(object)Dot(); return handMat; } private static Texture2D Dot() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)dotTex != (Object)null) { return dotTex; } dotTex = new Texture2D(32, 32, (TextureFormat)4, false); ((Texture)dotTex).wrapMode = (TextureWrapMode)1; Color32[] array = (Color32[])(object)new Color32[1024]; float num = 15.5f; for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { float num2 = ((float)j - num) / num; float num3 = ((float)i - num) / num; float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3); float num5 = Mathf.Clamp01(1f - num4); num5 *= num5; array[i * 32 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num5 * 255f)); } } dotTex.SetPixels32(array); dotTex.Apply(); return dotTex; } private void InfiniteHealth() { try { data.health = float.PositiveInfinity; if (data.maxHealth < 1E+09f) { data.maxHealth = float.PositiveInfinity; } } catch { } } } public static class WraithDefense { public const string HarmonyId = "wraith.tabs.mod.defense"; public static bool Bypass; private const float DeflectRange = 6f; private const float ScanInterval = 0.4f; private static readonly HashSet<int> ids = new HashSet<int>(); private static readonly List<Unit> ours = new List<Unit>(); private static readonly Collider[] hits = (Collider[])(object)new Collider[64]; private static readonly HashSet<int> deflected = new HashSet<int>(); private static GameObject host; private static GameStateManager gsm; private static bool active; private static float nextScan; private static float nextDestroyWin; private static float logTime; private static bool forcingWin; private static bool suppressRewrite; private static string forcedText; public static Unit Ours { get { if (ours.Count <= 0) { return null; } return ours[0]; } } public static bool Active => active; private static bool ReadBattleState() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 try { if (gsm == null) { gsm = ServiceLocator.GetService<GameStateManager>(); } return gsm != null && (int)gsm.GameState == 1; } catch { return false; } } public static void Install() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (!((Object)(object)host != (Object)null)) { ApplyPatches(); host = new GameObject("WraithDefense"); ((Object)host).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)host); host.AddComponent<DefenseHost>(); } } private static void ApplyPatches() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown Harmony val = new Harmony("wraith.tabs.mod.defense"); int num = 0; int num2 = 0; Type[] types = typeof(WraithDefense).Assembly.GetTypes(); foreach (Type type in types) { if (type.IsClass && type.GetCustomAttributes(typeof(HarmonyPatch), inherit: true).Length != 0) { try { val.CreateClassProcessor(type).Patch(); num++; } catch (Exception ex) { num2++; Debug.LogWarning((object)("[无头将领] 补丁 " + type.Name + " 没打上:" + ex.Message)); } } } Debug.Log((object)("[无头将领] 防御补丁 " + num + " 组生效,失败 " + num2 + " 组(仅战斗期生效)")); } public static void Log(string msg) { if (!(Time.unscaledTime - logTime < 1f)) { logTime = Time.unscaledTime; Debug.Log((object)("[无头将领] " + msg)); } } public static bool IsOurs(Unit u) { if ((Object)(object)u == (Object)null || (Object)(object)u.unitBlueprint == (Object)null) { return false; } if ((Object)(object)WraithContent.Blueprint != (Object)null && (Object)(object)u.unitBlueprint == (Object)(object)WraithContent.Blueprint) { return true; } try { Faction faction = WraithContent.Faction; if ((Object)(object)faction != (Object)null && faction.Units != null && Array.IndexOf(faction.Units, u.unitBlueprint) >= 0) { return true; } } catch { } try { if (u.unitBlueprint.Entity != null && u.unitBlueprint.Entity.Name == "无头将领") { return true; } } catch { } return false; } public static bool IsOurComponent(Component c) { if ((Object)(object)c == (Object)null) { return false; } try { Unit componentInParent = c.GetComponentInParent<Unit>(); if ((Object)(object)componentInParent != (Object)null && IsOurs(componentInParent)) { return true; } } catch { } return IsOursGo(c.gameObject); } private static bool IsOursGo(GameObject go) { if ((Object)(object)go == (Object)null || ids.Count == 0) { return false; } try { return ids.Contains(((Object)go).GetInstanceID()); } catch { return false; } } public static bool IsOursObject(Object o) { if (o == (Object)null || ids.Count == 0) { return false; } try { return ids.Contains(o.GetInstanceID()); } catch { return false; } } public static void Refresh() { bool flag = ReadBattleState(); if (flag != active) { active = flag; Debug.Log((object)(flag ? "[无头将领] 战斗开始 —— 怨念V2 + 外星农民防御已启用" : "[无头将领] 回到部署 —— 防御已关闭,可正常删除兵种")); } if (!(Time.unscaledTime < nextScan)) { nextScan = Time.unscaledTime + 0.4f; Scan(); } } private static void Scan() { ids.Clear(); ours.Clear(); Unit[] array = Object.FindObjectsOfType<Unit>(); foreach (Unit val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.data == (Object)null) && IsOurs(val) && !((Object)(object)((Component)val).GetComponent<WraithSummon>() != (Object)null)) { ours.Add(val); Protect(val); } } } private static void Protect(Unit u) { try { ids.Add(((Object)((Component)u).gameObject).GetInstanceID()); ids.Add(((Object)u).GetInstanceID()); if ((Object)(object)u.data != (Object)null) { ids.Add(((Object)u.data).GetInstanceID()); if ((Object)(object)u.data.healthHandler != (Object)null) { ids.Add(((Object)u.data.healthHandler).GetInstanceID()); } } Transform[] componentsInChildren = ((Component)u).GetComponentsInChildren<Transform>(true); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null) { ids.Add(((Object)((Component)componentsInChildren[i]).gameObject).GetInstanceID()); } } } catch { } } public static void TickAll() { if (!active) { WraithSkills.Reset(); return; } for (int num = ours.Count - 1; num >= 0; num--) { Unit val = ours[num]; if ((Object)(object)val == (Object)null) { ours.RemoveAt(num); } else { Tick(val); } } if (ours.Count > 0) { WraithSkills.Tick(ours[0]); } } private static void Tick(Unit u) { if ((Object)(object)u == (Object)null || (Object)(object)u.data == (Object)null) { return; } DataHandler data = u.data; try { u.dead = false; } catch { } try { if (data.Dead) { data.Dead = false; } } catch { } try { data.maxHealth = float.PositiveInfinity; data.health = float.PositiveInfinity; } catch { } try { data.ragdollControl = 1f; } catch { } try { data.muscleControl = 1f; } catch { } Deflect(u); } private static Vector3 Pos(Unit u) { //IL_0033: 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) Rigidbody val = (((Object)(object)u.data != (Object)null) ? u.data.mainRig : null); if (!((Object)(object)val != (Object)null)) { return ((Component)u).transform.position; } return val.position; } private static void Deflect(Unit me) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_000d: 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_0013: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //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_00ac: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Pos(me); Vector3 val2 = val + Vector3.up; int num; try { num = Physics.OverlapSphereNonAlloc(val2, 6f, hits, -1, (QueryTriggerInteraction)1); } catch { return; } for (int i = 0; i < num; i++) { Collider val3 = hits[i]; if ((Object)(object)val3 == (Object)null) { continue; } ProjectileHit componentInParent; try { componentInParent = ((Component)val3).GetComponentInParent<ProjectileHit>(); } catch { continue; } if ((Object)(object)componentInParent == (Object)null) { continue; } int instanceID = ((Object)componentInParent).GetInstanceID(); if (deflected.Contains(instanceID)) { continue; } GameObject gameObject = ((Component)componentInParent).gameObject; if ((Object)(object)gameObject == (Object)null) { continue; } Vector3 val4 = gameObject.transform.position - val; val4.y = 0f; if (((Vector3)(ref val4)).sqrMagnitude < 0.0001f) { val4 = Vector3.forward; } ((Vector3)(ref val4)).Normalize(); bool flag = false; try { MoveTransform component = gameObject.GetComponent<MoveTransform>(); if ((Object)(object)component != (Object)null) { component.velocity = val4 * Mathf.Max(((Vector3)(ref component.velocity)).magnitude, 45f); flag = true; } } catch { } try { Rigidbody component2 = gameObject.GetComponent<Rigidbody>(); if ((Object)(object)component2 != (Object)null) { Vector3 val5 = val4; Vector3 velocity = component2.velocity; component2.velocity = val5 * Mathf.Max(((Vector3)(ref velocity)).magnitude, 45f); flag = true; } } catch { } if (flag) { try { componentInParent.ResetTeam(); } catch { } deflected.Add(instanceID); } } if (deflected.Count > 256) { deflected.Clear(); } } public static void OnDestroyBlocked(string reason) { if (active && !(Time.unscaledTime < nextDestroyWin)) { nextDestroyWin = Time.unscaledTime + 2f; Log("拦截到销毁(" + reason + ")→ 强制胜利 + 清场"); ForceWinHard(); } } public static void ClearForcedText() { forcedText = null; } public static void ForceWinHard() { ForceWinHard("67"); } public static void ForceWinHard(string text) { if (forcingWin) { return; } forcingWin = true; try { ForceWin(text); KillAllEnemies(); } catch { } finally { forcingWin = false; } } private static void ForceWin(string text) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) forcedText = text; suppressRewrite = true; try { Unit val = Ours; if (!((Object)(object)val == (Object)null)) { GameModeService service = ServiceLocator.GetService<GameModeService>(); if (!((Object)(object)service == (Object)null) && service.CurrentGameMode != null) { service.CurrentGameMode.DecideWinner(val.Team, text); } } } catch { } finally { suppressRewrite = false; } } private static void KillAllEnemies() { //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_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_009f: Unknown result type (might be due to invalid IL or missing references) Unit val = Ours; if ((Object)(object)val == (Object)null || (Object)(object)val.data == (Object)null) { return; } Team team; try { team = val.Team; } catch { return; } Unit[] array = Object.FindObjectsOfType<Unit>(); foreach (Unit val2 in array) { if ((Object)(object)val2 == (Object)null || (Object)(object)val2 == (Object)(object)val || (Object)(object)val2.data == (Object)null) { continue; } bool flag; try { flag = val2.Team == team; } catch { continue; } if (flag) { continue; } try { if ((Object)(object)val2.data.healthHandler != (Object)null) { ((Damagable)val2.data.healthHandler).TakeDamage(1E+09f, Vector3.up, val, (DamageType)3); } } catch { } try { val2.DestroyUnit(); } catch { } } } public static void RewriteWinner(ref Team winningTeam, ref string text) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Invalid comparison between I4 and Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected I4, but got Unknown if (suppressRewrite || !active) { return; } Unit val = Ours; if ((Object)(object)val == (Object)null) { return; } try { string text2 = ((forcedText != null) ? forcedText : "67"); if ((int)winningTeam == (int)val.Team) { text = text2; return; } winningTeam = (Team)(int)val.Team; text = ((forcedText != null) ? forcedText : "6767"); } catch { } } } public class DefenseHost : MonoBehaviour { private void Update() { WraithDefense.Refresh(); WraithDefense.TickAll(); } } [HarmonyPatch(typeof(Unit), "DestroyUnit")] internal static class WD_PatchDestroyUnit { private static bool Prefix(Unit __instance) { try { if (!WraithDefense.Active || !WraithDefense.IsOurs(__instance)) { return true; } if ((Object)(object)((Component)__instance).GetComponent<WraithSummon>() != (Object)null) { return true; } WraithDefense.OnDestroyBlocked("DestroyUnit"); return false; } catch { return true; } } } [HarmonyPatch(typeof(HealthHandler), "Die", new Type[] { typeof(Unit) })] internal static class WD_PatchDieUnit { private static bool Prefix(HealthHandler __instance, Unit damager) { try { if (!WraithDefense.Active) { return true; } if (!WraithDefense.IsOurComponent((Component)(object)__instance)) { return true; } WraithDefense.Log("拦住了死亡判定"); return false; } catch { return true; } } } [HarmonyPatch(typeof(HealthHandler), "Die", new Type[] { typeof(bool) })] internal static class WD_PatchDieBool { private static bool Prefix(HealthHandler __instance) { try { if (!WraithDefense.Active) { return true; } return !WraithDefense.IsOurComponent((Component)(object)__instance); } catch { return true; } } } [HarmonyPatch(typeof(HealthHandler), "TakeDamage", new Type[] { typeof(float), typeof(Vector3), typeof(Unit), typeof(DamageType) })] internal static class WD_PatchTakeDamage { private static bool Prefix(HealthHandler __instance, ref float damage) { try { if (!WraithDefense.Active || WraithDefense.Bypass) { return true; } if (!WraithDefense.IsOurs(((Component)__instance).GetComponentInParent<Unit>())) { return true; } damage = 0f; return false; } catch { return true; } } } [HarmonyPatch(typeof(DataHandler), "set_Dead")] internal static class WD_PatchSetDead { private static bool Prefix(DataHandler __instance, bool value) { try { if (!value || !WraithDefense.Active) { return true; } return !WraithDefense.IsOurComponent((Component)(object)__instance); } catch { return true; } } } [HarmonyPatch(typeof(DataHandler), "get_Dead")] internal static class WD_PatchGetDead { private static void Postfix(DataHandler __instance, ref bool __result) { try { if (__result && WraithDefense.Active && WraithDefense.IsOurComponent((Component)(object)__instance)) { __result = false; } } catch { } } } [HarmonyPatch(typeof(Object), "Destroy", new Type[] { typeof(Object) })] internal static class WD_PatchDestroy { private static bool Prefix(Object obj) { return WD_Destroy.Allow(obj); } } [HarmonyPatch(typeof(Object), "Destroy", new Type[] { typeof(Object), typeof(float) })] internal static class WD_PatchDestroyDelayed { private static bool Prefix(Object obj) { return WD_Destroy.Allow(obj); } } [HarmonyPatch(typeof(Object), "DestroyImmediate", new Type[] { typeof(Object) })] internal static class WD_PatchDestroyImmediate { private static bool Prefix(Object obj) { return WD_Destroy.Allow(obj); } } internal static class WD_Destroy { internal static bool Allow(Object obj) { try { if (!WraithDefense.Active || obj == (Object)null) { return true; } if (!WraithDefense.IsOursObject(obj)) { return true; } WraithDefense.OnDestroyBlocked("Destroy"); return false; } catch { return true; } } } [HarmonyPatch(typeof(UnitAPI), "SetIsDead")] internal static class WD_PatchSetIsDead { private static bool Prefix(UnitAPI __instance) { try { if (!WraithDefense.Active) { return true; } return !WraithDefense.IsOurComponent((Component)(object)__instance); } catch { return true; } } } [HarmonyPatch(typeof(TeamSystem), "TriggerUnitDeathAction")] internal static class WD_PatchTriggerUnitDeath { private static bool Prefix(Unit unit) { try { if (!WraithDefense.Active) { return true; } return !WraithDefense.IsOurs(unit); } catch { return true; } } } [HarmonyPatch(typeof(UnitCreatorGameMode), "OnUnitDied")] internal static class WD_PatchOnUnitDied { private static bool Prefix(Unit unit) { try { return !WraithDefense.Active || !WraithDefense.IsOurs(unit); } catch { return true; } } } [HarmonyPatch(typeof(Collider), "set_enabled")] internal static class WD_PatchColliderEnabled { private static bool Prefix(Collider __instance, bool value) { try { if (value || !WraithDefense.Active || WraithDefense.Bypass) { return true; } return !WraithDefense.IsOurComponent((Component)(object)__instance); } catch { return true; } } } [HarmonyPatch(typeof(Renderer), "set_enabled")] internal static class WD_PatchRendererEnabled { private static bool Prefix(Renderer __instance, bool value) { try { if (value || !WraithDefense.Active || WraithDefense.Bypass) { return true; } if (__instance is TrailRenderer || __instance is LineRenderer) { return true; } return !WraithDefense.IsOurComponent((Component)(object)__instance); } catch { return true; } } } [HarmonyPatch(typeof(Rigidbody), "set_isKinematic")] internal static class WD_PatchKinematic { private static bool Prefix(Rigidbody __instance, bool value) { try { if (!value || !WraithDefense.Active || WraithDefense.Bypass) { return true; } return !WraithDefense.IsOurComponent((Component)(object)__instance); } catch { return true; } } } [HarmonyPatch(typeof(Rigidbody), "set_detectCollisions")] internal static class WD_PatchDetectCollisions { private static bool Prefix(Rigidbody __instance, bool value) { try { if (value || !WraithDefense.Active || WraithDefense.Bypass) { return true; } return !WraithDefense.IsOurComponent((Component)(object)__instance); } catch { return true; } } } [HarmonyPatch(typeof(Rigidbody), "set_useGravity")] internal static class WD_PatchUseGravity { private static bool Prefix(Rigidbody __instance, bool value) { try { if (value || !WraithDefense.Active || WraithDefense.Bypass) { return true; } return !WraithDefense.IsOurComponent((Component)(object)__instance); } catch { return true; } } } [HarmonyPatch(typeof(BaseGameMode), "DecideWinner")] internal static class WD_PatchDecideWinner { private static void Prefix(ref Team winningTeam, [HarmonyArgument(1)] ref string subText) { WraithDefense.RewriteWinner(ref winningTeam, ref subText); } } [HarmonyPatch(typeof(BaseGameMode), "OnWinnerDecided")] internal static class WD_PatchOnWinnerDecided { private static void Prefix(ref Team winningTeam, [HarmonyArgument(1)] ref string winSubText) { WraithDefense.RewriteWinner(ref winningTeam, ref winSubText); } } public static class WraithSkills { private enum SlamPhase { Idle, Rise, Fall } private class Maim { public Unit U; public Renderer[] Hidden; public GameObject[] Severed; public float AttackSpeed; public float Ragdoll; public float Muscle; public bool HasControl; } public const float SlamInterval = 6f; public const float MaimInterval = 5f; public const float SummonInterval = 8f; public const float EraseInterval = 7f; private const float StompScale = 1.5f; private const float StompRadius = 8f; private const float SlamHeight = 9f; private const float SlamRiseTime = 0.55f; private const float SlamFallTime = 0.38f; private const int MaimTargets = 5; private const float SeveredLife = 3f; private const int SummonCount = 3; public const float SummonLife = 8f; private const float TimeStopSpeed = 8f; private static readonly string[] SlashFx = new string[2] { "E_Shogun_Slash", "E_ColdSnap" }; private static readonly string[] EraseFx = new string[3] { "E_ExplosionBombDrop", "E_FireEffect", "E_Pharaoh" }; private static readonly string[] SummonFx = new string[2] { "E_Enrage", "E_FireEffect" }; private static readonly string[] StompFx = new string[2] { "E_ExplosionSamuraiGiantStomp", "E_ExplosionTreeGiant" }; private static SlamPhase slamPhase; private static float slamStart; private static Vector3 slamFrom; private static Vector3 slamTo; private static readonly List<Maim> maims = new List<Maim>(); private static readonly List<Unit> summons = new List<Unit>(); private static readonly List<Unit> buf = new List<Unit>(); private static readonly List<Vector3> before = new List<Vector3>(); private static float slamNext; private static float maimNext; private static float summonNext; private static float eraseNext; private static float nextClearCheck; private static bool sawEnemy; private static bool winFired; public static void Tick(Unit me) { if (WraithDefense.Active && !((Object)(object)me == (Object)null) && !((Object)(object)me.data == (Object)null)) { float unscaledTime = Time.unscaledTime; TimeStopMove(me); TickSlam(me); TickMaims(); CheckClear(me); if (slamPhase == SlamPhase.Idle && unscaledTime >= slamNext) { slamNext = unscaledTime + Mathf.Max(1f, 6f); StartSlam(me); } if (unscaledTime >= maimNext) { maimNext = unscaledTime + Mathf.Max(1f, 5f); CastMaim(me); } if (unscaledTime >= summonNext) { summonNext = unscaledTime + Mathf.Max(1f, 8f); CastSummon(me); } if (unscaledTime >= eraseNext) { eraseNext = unscaledTime + Mathf.Max(1f, 7f); CastErase(me); } } } public static void Reset() { RestoreAllMaims(); ClearSummons(); WraithDefense.ClearForcedText(); buf.Clear(); slamPhase = SlamPhase.Idle; slamNext = 0f; maimNext = 0f; summonNext = 0f; eraseNext = 0f; nextClearCheck = 0f; sawEnemy = false; winFired = false; } private static Vector3 P(Unit u) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((Component)u).transform.position; } private static List<Unit> Enemies(Unit me) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) buf.Clear(); Team team; try { team = me.Team; } catch { return buf; } Unit[] array = Object.FindObjectsOfType<Unit>(); foreach (Unit val in array) { if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)me || (Object)(object)val.data == (Object)null) { continue; } bool flag; try { flag = val.data.Dead; } catch { flag = false; } if (!flag) { bool flag2; try { flag2 = val.Team == team; } catch { continue; } if (!flag2) { buf.Add(val); } } } return buf; } private static Unit NearestEnemy(Unit me) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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) //IL_003e: Unknown result type (might be due to invalid IL or missing references) List<Unit> list = Enemies(me); Unit result = null; float num = float.MaxValue; Vector3 val = P(me); for (int i = 0; i < list.Count; i++) { if (!((Object)(object)list[i] == (Object)null)) { Vector3 val2 = P(list[i]) - val; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = list[i]; } } } return result; } private static void ShiftUnit(Unit u, Vector3 delta) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_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_0088: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref delta)).sqrMagnitude < 1E-08f) { return; } try { Rigidbody[] componentsInChildren = ((Component)u).GetComponentsInChildren<Rigidbody>(); before.Clear(); for (int i = 0; i < componentsInChildren.Length; i++) { before.Add(((Object)(object)componentsInChildren[i] != (Object)null) ? componentsInChildren[i].position : Vector3.zero); } Transform transform = ((Component)u).transform; transform.position += delta; for (int j = 0; j < componentsInChildren.Length; j++) { if ((Object)(object)componentsInChildren[j] != (Object)null) { componentsInChildren[j].position = before[j] + delta; } } } catch { } } private static void MoveTo(Unit u, Vector3 want) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: 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) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) Vector3 delta = want - P(u); if (!(((Vector3)(ref delta)).sqrMagnitude < 0.0001f)) { ShiftUnit(u, delta); } } private static void TimeStopMove(Unit me) { //IL_0027: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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 (Time.timeScale > 0.05f || slamPhase != SlamPhase.Idle) { return; } Unit val = NearestEnemy(me); if (!((Object)(object)val == (Object)null)) { Vector3 val2 = P(val) - P(me); val2.y = 0f; if (!(((Vector3)(ref val2)).sqrMagnitude < 0.01f)) { ((Vector3)(ref val2)).Normalize(); ShiftUnit(me, val2 * (8f * Time.unscaledDeltaTime)); } } } private static void StartSlam(Unit me) { //IL_0008: 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) //IL_0023: 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_0028: Unknown result type (might be due to invalid IL or missing references) Unit val = NearestEnemy(me); slamFrom = P(me); slamTo = (((Object)(object)val != (Object)null) ? P(val) : slamFrom); slamStart = Time.unscaledTime; slamPhase = SlamPhase.Rise; WraithDefense.Log("天降践踏:起跳"); } private static void TickSlam(Unit me) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if (slamPhase == SlamPhase.Idle || (Object)(object)me == (Object)null) { return; } float unscaledTime = Time.unscaledTime; if (slamPhase == SlamPhase.Rise) { float num = Mathf.Clamp01((unscaledTime - slamStart) / 0.55f); Vector3 want = slamFrom + Vector3.up * (9f * Mathf.SmoothStep(0f, 1f, num)); MoveTo(me, want); if (num >= 1f) { slamStart = unscaledTime; slamPhase = SlamPhase.Fall; } } else { float num2 = Mathf.Clamp01((unscaledTime - slamStart) / 0.38f); Vector3 want2 = Vector3.Lerp(slamFrom + Vector3.up * 9f, slamTo, num2 * num2); MoveTo(me, want2); if (num2 >= 1f) { slamPhase = SlamPhase.Idle; Land(me, slamTo); } } } private static void Land(Unit me, Vector3 at) { //IL_0005: 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) //IL_0051: 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_0057: Unknown result type (might be due to invalid IL or missing references) WraithFxLib.StompAny(StompFx, at, 1.5f, 3f); List<Unit> list = Enemies(me); float num = 64f; int num2 = 0; for (int i = 0; i < list.Count; i++) { Unit val = list[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val.data == (Object)null)) { Vector3 val2 = P(val) - at; if (!(((Vector3)(ref val2)).sqrMagnitude > num)) { ExecuteStomp(val, me); num2++; } } } WraithDefense.Log("天降践踏:落地," + 8f.ToString("F0") + " 米内 " + num2 + " 名敌人吃到 无限伤害 + 强制0血 + 强制死亡"); } private static void ExecuteStomp(Unit e, Unit me) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)e.data.healthHandler != (Object)null) { ((Damagable)e.data.healthHandler).TakeDamage(float.PositiveInfinity, Vector3.up, me, (DamageType)3); } } catch { } try { e.data.health = 0f; e.data.maxHealth = 0f; } catch { } try { e.data.Dead = true; } catch { } try { if ((Object)(object)e.data.healthHandler != (Object)null) { e.data.healthHandler.Die(me); } } catch { } try { e.DestroyUnit(); } catch { } } private static void CastMaim(Unit me) { List<Unit> list = Enemies(me); if (list.Count == 0) { return; } int num = Mathf.Min(5, list.Count); int num2 = 0; for (int i = 0; i < 30; i++) { if (num2 >= num) { break; } Unit val = list[Random.Range(0, list.Count)]; if ((Object)(object)val == (Object)null || (Object)(object)val.data == (Object)null) { continue; } bool flag = false; for (int j = 0; j < maims.Count; j++) { if ((Object)(object)maims[j].U == (Object)(object)val) { flag = true; break; } } if (!flag && MaimOne(val)) { num2++; } } if (num2 > 0) { WraithDefense.Log("斩肢瘫痪:砍了 " + num2 + " 名敌人的随机部位"); } } private static bool MaimOne(Unit e) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) try { List<Transform> list = new List<Transform>(); DataHandler data = e.data; Transform[] array = (Transform[])(object)new Transform[10] { data.head, data.torso, data.leftArm, data.rightArm, data.leftHand, data.rightHand, data.legLeft, data.legRight, data.footLeft, data.footRight }; for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null) { list.Add(array[i]); } } if (list.Count == 0) { return false; } Transform val = list[Random.Range(0, list.Count)]; Vector3 position = val.position; WraithFxLib.SlashAny(SlashFx, position, 2f); Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<Renderer>(true); for (int j = 0; j < componentsInChildren.Length; j++) { if ((Object)(object)componentsInChildren[j] != (Object)null) { try { componentsInChildren[j].enabled = false; } catch { } } } GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, position, val.rotation); ((Object)val2).name = "WraithSevered"; val2.transform.SetParent((Transform)null, true); MonoBehaviour[] componentsInChildren2 = val2.GetComponentsInChildren<MonoBehaviour>(true); for (int k = 0; k < componentsInChildren2.Length; k++) { if ((Object)(object)componentsInChildren2[k] != (Object)null) { try { Object.Destroy((Object)(object)componentsInChildren2[k]); } catch { } } } Collider[] componentsInChildren3 = val2.GetComponentsInChildren<Collider>(true); for (int l = 0; l < componentsInChildren3.Length; l++) { if ((Object)(object)componentsInChildren3[l] != (Object)null) { try { Object.Destroy((Object)(object)componentsInChildren3[l]); } catch { } } } Renderer[] componentsInChildren4 = val2.GetComponentsInChildren<Renderer>(true); for (int m = 0; m < componentsInChildren4.Length; m++) { if ((Object)(object)componentsInChildren4[m] != (Object)null) { try { componentsInChildren4[m].enabled = true; } catch { } } } Rigidbody val3 = val2.GetComponent<Rigidbody>(); if ((Object)(object)val3 == (Object)null) { val3 = val2.AddComponent<Rigidbody>(); } val3.velocity = Random.onUnitSphere * 6f + Vector3.up * 4f; val3.angularVelocity = Random.onUnitSphere * 9f; Object.Destroy((Object)(object)val2, 3f); WeaponHandler component = ((Component)e).GetComponent<WeaponHandler>(); float attackSpeed = (((Object)(object)component != (Object)null) ? component.attackSpeedMultiplier : 1f); float ragdollControl = data.ragdollControl; float muscleControl = data.muscleControl; bool hasControl = (Object)(object)data.input != (Object)null && data.input.hasControl; if ((Object)(object)component != (Object)null) { component.attackSpeedMultiplier = 0f; } data.ragdollControl = 0f; data.muscleControl = 0f; if ((Object)(object)data.input != (Object)null) { data.input.hasControl = false; } maims.Add(new Maim { U = e, Hidden = componentsInChildren, Severed = (GameObject[])(object)new GameObject[1] { val2 }, AttackSpeed = attackSpeed, Ragdoll = ragdollControl, Muscle = muscleControl, HasControl = hasControl }); return true; } catch { return false; } } private static void TickMaims() { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) for (int num = maims.Count - 1; num >= 0; num--) { Maim maim = maims[num]; if ((Object)(object)maim.U == (Object)null || (Object)(object)maim.U.data == (Object)null) { maims.RemoveAt(num); } else { try { WeaponHandler component = ((Component)maim.U).GetComponent<WeaponHandler>(); if ((Object)(object)component != (Object)null) { component.attackSpeedMultiplier = 0f; } maim.U.data.ragdollControl = 0f; maim.U.data.muscleControl = 0f; if ((Object)(object)maim.U.data.input != (Object)null) { maim.U.data.input.hasControl = false; } Rigidbody[] componentsInChildren = ((Component)maim.U).GetComponentsInChildren<Rigidbody>(); for (int i = 0; i < componentsInChildren.Length; i++) { if (!((Object)(object)componentsInChildren[i] == (Object)null)) { componentsInChildren[i].velocity = Vector3.zero; componentsInChildren[i].angularVelocity = Vector3.zero; } } } catch { } } } } private static void RestoreAllMaims() { for (int i = 0; i < maims.Count; i++) { RestoreOne(maims[i]); } maims.Clear(); } private static void RestoreOne(Maim m) { if (m == null) { return; } if (m.Hidden != null) { for (int i = 0; i < m.Hidden.Length; i++) { if ((Object)(object)m.Hidden[i] != (Object)null) { try { m.Hidden[i].enabled = true; } catch { } } } } if (m.Severed != null) { for (int j = 0; j < m.Severed.Length; j++) { if ((Object)(object)m.Severed[j] != (Object)null) { try { Object.Destroy((Object)(object)m.Severed[j]); } catch { } } } } if ((Object)(object)m.U == (Object)null || (Object)(object)m.U.data == (Object)null) { return; } try { WeaponHandler component = ((Component)m.U).GetComponent<WeaponHandler>(); if ((Object)(object)component != (Object)null) { component.attackSpeedMultiplier = ((m.AttackSpeed > 0f) ? m.AttackSpeed : 1f); } m.U.data.ragdollControl = m.Ragdoll; m.U.data.muscleControl = m.Muscle; if ((Object)(object)m.U.data.input != (Object)null) { m.U.data.input.hasControl = m.HasControl; } } catch { } } private static void CastSummon(Unit me) { //IL_0012: 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) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) UnitBlueprint blueprint = WraithContent.Blueprint; if ((Object)(object)blueprint == (Object)null) { return; } Team team; try { team = me.Team; } catch { return; } Vector3 val = P(me); int num = 0; Unit val3 = default(Unit); for (int i = 0; i < 3; i++) { float num2 = Random.Range(0f, (float)Math.PI * 2f); Vector3 val2 = val + new Vector3(Mathf.Cos(num2), 0f, Mathf.Sin(num2)) * Random.Range(2f, 4f); try { blueprint.Spawn(val2, Quaternion.identity, team, ref val3, 1f, false, true, 0, (UnitPoolInfo?)null); if (!((Object)(object)val3 == (Object)null)) { ((Component)val3).gameObject.AddComponent<WraithSummon>(); summons.Add(val3); WraithFxLib.SpawnAny(SummonFx, val2, 1.5f); num++; } } catch { } } if (num > 0) { WraithDefense.Log("影从召唤:召出 " + num + " 名无头将领,各存活 " + 8f.ToString("F0") + " 秒"); } } private static void ClearSummons() { for (int i = 0; i < summons.Count; i++) { Unit val = summons[i]; if (!((Object)(object)val == (Object)null)) { try { val.DestroyUnit(); } catch { } try { Object.Destroy((Object)(object)((Component)val).gameObject); } catch { } } } summons.Clear(); } private static void CastErase(Unit me) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) List<Unit> list = Enemies(me); if (list.Count == 0) { return; } int num = Mathf.Min(Random.Range(2, 5), list.Count); List<Unit> list2 = new List<Unit>(); for (int i = 0; i < 40; i++) { if (list2.Count >= num) { break; } Unit val = list[Random.Range(0, list.Count)]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val.data == (Object)null) && !list2.Contains(val)) { list2.Add(val); } } int num2 = 0; for (int j = 0; j < list2.Count; j++) { Unit val2 = list2[j]; try { WraithFxLib.BoomAny(EraseFx, P(val2), 1.2f, 2f); } catch { } EraseUnit(val2, me); num2++; } if (num2 > 0) { WraithDefense.Log("拳王抹除:销毁 " + num2 + " 名敌人(2~4 随机)"); } } private static void EraseUnit(Unit e, Unit me) { if ((Object)(object)e == (Object)null || (Object)(object)e.data == (Object)null) { return; } try { e.data.Dead = true; } catch { } try { if ((Object)(object)e.data.healthHandler != (Object)null) { e.data.healthHandler.Die(me); } } catch { } try { e.DestroyUnit(); } catch { } try { Object.Destroy((Object)(object)((Component)e).gameObject); } catch { } } private static void CheckClear(Unit me) { if (!winFired && !(Time.unscaledTime < nextClearCheck)) { nextClearCheck = Time.unscaledTime + 0.4f; if (Enemies(me).Count > 0) { sawEnemy = true; } else if (sawEnemy) { winFired = true; WraithDefense.ForceWinHard(WraithVictory.Text); WraithDefense.Log("敌人全灭 → 反拦截强制胜利(彩虹文本)"); } } } } public class WraithSummon : MonoBehaviour { private float dieAt; private bool done; private void Start() { dieAt = Time.unscaledTime + 8f; } private void Update() { if (done || Time.unscaledTime < dieAt) { return; } done = true; try { Unit component = ((Component)this).GetComponent<Unit>(); if ((Object)(object)component != (Object)null) { component.DestroyUnit(); } } catch { } Object.Destroy((Object)(object)((Component)this).gameObject); } } public class WraithSlashFade : MonoBehaviour { private LineRenderer lr; private float life; private float t; private Color c0; private Color c1; public void Init(LineRenderer line, float seconds) { //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) //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) lr = line; life = Mathf.Max(0.1f, seconds); if ((Object)(object)lr != (Object)null) { c0 = lr.startColor; c1 = lr.endColor; } } private void Update() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) t += Time.unscaledDeltaTime; float num = Mathf.Clamp01(t / life); float num2 = 1f - num; if ((Object)(object)lr != (Object)null) { Color startColor = c0; startColor.a *= num2; lr.startColor = startColor; Color endColor = c1; endColor.a *= num2; lr.endColor = endColor; try { lr.startWidth = 0.2f * (0.35f + 0.65f * num2); } catch { } } if (num >= 1f) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } public static class WraithVictory { public const string Plain = "HAHAHAHAHAHAHAHAHA"; public static string Text => 的的了了.RainbowText("HAHAHAHAHAHAHAHAHA", 0); } public static class WraithFxLib { private static readonly Dictionary<string, GameObject> cache = new Dictionary<string, GameObject>(); private static List<GameObject> all; private static float nextRescan; private static readonly string[] DictKeys = new string[5] { "effects", "explosions", "projectiles", "moves", "props" }; public static GameObject Prefab(string name) { if (cache.TryGetValue(name, out var value) && (Object)(object)value != (Object)null) { return value; } try { Dictionary<string, Dictionary<string, object>> sDic = SLMALoader.SDic; if (sDic != null) { for (int i = 0; i < DictKeys.Length; i++) { if (!sDic.ContainsKey(DictKeys[i])) { continue; } foreach (KeyValuePair<string, object> item in sDic[DictKeys[i]]) { if (string.Equals(Convert.ToString(item.Key), name, StringComparison.Ordinal)) { object value2 = item.Value; GameObject val = (GameObject)((value2 is GameObject) ? value2 : null); if ((Object)(object)val != (Object)null) { cache[name] = val; return val; } } } } } } catch { } string[] array = new string[4] { "", "Effects/", "Explosions/", "Projectiles/" }; for (int j = 0; j < array.Length; j++) { try { GameObject val2 = Resources.Load<GameObject>(array[j] + name); if ((Object)(object)val2 != (Object)null) { cache[name] = val2; return val2; } } catch { } } if (all == null || Time.unscaledTime >= nextRescan) { nextRescan = Time.unscaledTime + 2f; try { all = new List<GameObject>(Resources.FindObjectsOfTypeAll<GameObject>()); } catch { all = new List<GameObject>(); } } for (int k = 0; k < all.Count; k++) { GameObject val3 = all[k]; if (!((Object)(object)val3 == (Object)null) && !(((Object)val3).name != name) && !((Object)(object)val3.transform.parent != (Object)null)) { cache[name] = val3; return val3; } } return null; } public static void Spawn(string name, Vector3 at, float life) { //IL_0013: 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) GameObject val = Prefab(name); if ((Object)(object)val == (Object)null) { return; } try { GameObject val2 = Object.Instantiate<GameObject>(val, at, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f)); ((Object)val2).name = "WraithFx_" + name; UnitEffectBase val3 = val2.GetComponent<UnitEffectBase>(); if ((Object)(object)val3 == (Object)null) { val3 = val2.GetComponentInChildren<UnitEffectBase>(); } if ((Object)(object)val3 != (Object)null) { try { val3.ShouldSkipDeadTests = true; } catch { } try { val3.DoEffect(); } catch { } } Object.Destroy((Object)(object)val2, Mathf.Max(0.5f, life)); } catch { } } public static void SpawnAny(string[] names, Vector3 at, float life) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < names.Length; i++) { if ((Object)(object)Prefab(names[i]) != (Object)null) { Spawn(names[i], at, life); break; } } } public static void Slash(string name, Vector3 at, float life) { //IL_0047: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0278: 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_0071: 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) GameObject val = Prefab(name); if ((Object)(object)val == (Object)null) { return; } try { Camera main = Camera.main; Quaternion val2 = (((Object)(object)main != (Object)null) ? (((Component)main).transform.rotation * Quaternion.Euler(0f, 0f, Random.Range(-35f, 35f))) : Quaternion.Euler(0f, Random.Range(0f, 360f), 0f)); GameObject val3 = Object.Instantiate<GameObject>(val, at, val2); ((Object)val3).name = "WraithSlash_" + name; val3.SetActive(true); UnitEffectBase val4 = val3.GetComponent<UnitEffectBase>(); if ((Object)(object)val4 == (Object)null) { val4 = val3.GetComponentInChildren<UnitEffectBase>(); } if ((Object)(object)val4 != (Object)null) { try { val4.ShouldSkipDeadTests = true; } catch { } try { val4.DoEffect(); } catch { } } MonoBehaviour[] componentsInChildren = val3.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val5 in componentsInChildren) { if ((Object)(object)val5 == (Object)null || val5 is UnitEffectBase) { continue; } string name2 = ((object)val5).GetType().Name; switch (name2) { default: if (!(name2 == "UnitDontWalkFor")) { continue; } break; case "RemoveAfterSeconds": case "DelayEvent": case "GoToBodyPart": case "FindDataHandler": case "FreezeBody": break; } try { ((Behaviour)val5).enabled = false; } catch { } } Explosion[] componentsInChildren2 = val3.GetComponentsInChildren<Explosion>(true); for (int j = 0; j < componentsInChildren2.Length; j++) { if (!((Object)(object)componentsInChildren2[j] == (Object)null)) { try { componentsInChildren2[j].damage = 0f; } catch { } try { componentsInChildren2[j].force = 0f; } catch { } try { componentsInChildren2[j].Explode(); } catch { } } } Transform[] componentsInChildren3 = val3.GetComponentsInChildren<Transform>(true); for (int k = 0; k < componentsInChildren3.Length; k++) { if ((Object)(object)componentsInChildren3[k] != (Object)null && !((Component)componentsInChildren3[k]).gameObject.activeSelf) { try { ((Component)componentsInChildren3[k]).gameObject.SetActive(true); } catch { } } } Renderer[] componentsInChildren4 = val3.GetComponentsInChildren<Renderer>(true); for (int l = 0; l < componentsInChildren4.Length; l++) { if ((Object)(object)componentsInChildren4[l] != (Object)null) { try { componentsInChildren4[l].enabled = true; } catch { } } } val3.transform.localScale = Vector3.one * 1.6f; Object.Destroy((Object)(object)val3, Mathf.Max(0.5f, life)); } catch { } } public static void SlashAny(string[] names, Vector3 at, float life) { //IL_002e: 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) bool flag = false; for (int i = 0; i < names.Length; i++) { if (!((Object)(object)Prefab(names[i]) == (Object)null)) { Slash(names[i], at, life); flag = true; break; } } SlashTrail(at, life); if (!flag) { WraithDefense.Log("斩击:原版预制体没取到,已用程序刀光兜底"); } } private static void SlashTrail(Vector3 at, float life) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) try { Shader val = Shader.Find("Sprites/Default"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Particles/Standard Unlit"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Unlit/Color"); } if ((Object)(object)val == (Object)null) { return; } Camera main = Camera.main; Quaternion val2 = (((Object)(object)main != (Object)null) ? ((Component)main).transform.rotation : Quaternion.identity); float seconds = Mathf.Clamp(life, 0.35f, 0.8f); for (int i = 0; i < 2; i++) { GameObject val3 = new GameObject("WraithSlashTrail"); val3.transform.position = at; val3.transform.rotation = val2 * Quaternion.Euler(0f, 0f, (i == 0) ? (-38f) : 38f); val3.transform.localScale = Vector3.one * 1.6f; LineRenderer val4 = val3.AddComponent<LineRenderer>(); val4.useWorldSpace = false; val4.positionCount = 3; val4.SetPosition(0, new Vector3(-1.15f, 0.85f, 0f)); val4.SetPosition(1, new Vector3(0f, 0f, 0f)); val4.SetPosition(2, new Vector3(1.15f, -0.85f, 0f)); val4.startWidth = 0.2f; val4.endWidth = 0.01f; val4.numCapVertices = 3; val4.numCornerVertices = 3; val4.startColor = new Color(0.8f, 0.92f, 1f, 1f); val4.endColor = new Color(0.85f, 0.35f, 1f, 0f); Material val5 = new Material(val); try { val5.color = Color.white; } catch { } ((Renderer)val4).material = val5; val3.AddComponent<WraithSlashFade>().Init(val4, seconds); } } catch { } } public static void Boom(string name, Vector3 at, float scale, float life) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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) GameObject val = Prefab(name); if ((Object)(object)val == (Object)null) { return; } try { GameObject obj = Object.Instantiate<GameObject>(val, at, Quaternion.identity); ((Object)obj).name = "WraithBoom_" + name; obj.transform.localScale = Vector3.one * Mathf.Max(0.5f, scale); Object.Destroy((Object)(object)obj, Mathf.Max(0.5f, life)); } catch { } } public static void BoomAny(string[] names, Vector3 at, float scale, float life) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < names.Length; i++) { if ((Object)(object)Prefab(names[i]) != (Object)null) { Boom(names[i], at, scale, life); break; } } } public static void Stomp(string name, Vector3 at, float scale, float life) { //IL_0013: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) GameObject val = Prefab(name); if ((Object)(object)val == (Object)null) { return; } try { GameObject val2 = Object.Instantiate<GameObject>(val, at, Quaternion.Euler(90f, 0f, 0f)); ((Object)val2).name = "WraithStomp_" + name; val2.transform.localScale = Vector3.one * Mathf.Max(0.5f, scale); ApplyMapGroundMaterial[] componentsInChildren = val2.GetComponentsInChildren<ApplyMapGroundMaterial>(true); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null) { try { ((Behaviour)componentsInChildren[i]).enabled = false; } catch { } } } Explosion val3 = val2.GetComponent<Explosion>(); if ((Object)(object)val3 == (Object)null) { val3 = val2.GetComponentInChildren<Explosion>(); } if ((Object)(object)val3 != (Object)null) { try { val3.damage = 0f; } catch { } try { val3.force = 0f; } catch { } } Object.Destroy((Object)(object)val2, Mathf.Max(0.5f, life)); } catch { } } public static void StompAny(string[] names, Vector3 at, float scale, float life) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < names.Length; i++) { if ((Object)(object)Prefab(names[i]) != (Object)null) { Stomp(names[i], at, scale, life); break; } } } } public static class WraithFx { public static readonly Color OutlineColor = new Color(0.58f, 0.12f, 0.95f, 1f); private static Sprite icon; public static Sprite Icon() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0070: 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_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)icon != (Object)null) { return icon; } try { Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; Color32[] array = (Color32[])(object)new Color32[16384]; Color32 val2 = d