Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of AegisDome v1.1.515
AegisDome.dll
Decompiled a week 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.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; using Splatform; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AegisDome { public static class LocalizationHelper { private static string s_cachedLang = null; private static float s_lastLangCheck = -10f; public static string GetCurrentLanguage() { if (Time.unscaledTime - s_lastLangCheck > 2f) { s_lastLangCheck = Time.unscaledTime; s_cachedLang = ((Localization.instance != null) ? Localization.instance.GetSelectedLanguage() : PlayerPrefs.GetString("language", "English")); } return s_cachedLang ?? "English"; } public static string T(string english, string russian, string ukrainian, string spanish) { string currentLanguage = GetCurrentLanguage(); if (string.IsNullOrEmpty(currentLanguage)) { return english; } if (currentLanguage.IndexOf("Russian", StringComparison.OrdinalIgnoreCase) >= 0 || currentLanguage.IndexOf("Рус", StringComparison.OrdinalIgnoreCase) >= 0) { return russian; } if (currentLanguage.IndexOf("Ukrainian", StringComparison.OrdinalIgnoreCase) >= 0 || currentLanguage.IndexOf("Укр", StringComparison.OrdinalIgnoreCase) >= 0) { return ukrainian; } if (currentLanguage.IndexOf("Spanish", StringComparison.OrdinalIgnoreCase) >= 0 || currentLanguage.IndexOf("Español", StringComparison.OrdinalIgnoreCase) >= 0) { return spanish; } return english; } } [BepInPlugin("com.skarif.aegisdome", "AegisDome", "1.5.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class AegisDomePlugin : BaseUnityPlugin { public const string PluginGUID = "com.skarif.aegisdome"; public const string PluginName = "AegisDome"; public const string PluginVersion = "1.5.2"; public const string PiecePrefabName = "AegisDome_Runestone"; private Harmony m_harmony; public static AegisDomePlugin Instance { get; private set; } public static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger; public static GameObject AegisDomePrefab { get; set; } public static string PieceLocalizedName => T("AegisDome Runestone", "Рунный камень AegisDome", "Рунний камінь AegisDome", "Piedra rúnica AegisDome"); public static Sprite RunestonePinSprite { get; private set; } public static Sprite PencilSprite { get; private set; } public static Sprite MenuBgSprite { get; private set; } public static bool VisualEffectsEnabled { get; set; } = true; public static ConfigEntry<bool> EnableGlobalMapSyncConfig { get; private set; } public static bool EnableGlobalMapSync => EnableGlobalMapSyncConfig == null || EnableGlobalMapSyncConfig.Value; public static string T(string english, string russian, string ukrainian, string spanish) { return LocalizationHelper.T(english, russian, ukrainian, spanish); } private void Awake() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown Instance = this; EnableGlobalMapSyncConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Sync", "EnableGlobalMapSync", true, "Force synchronization of all AegisDome runestones to all clients regardless of sector distance."); RunestonePinSprite = LoadSpriteFromFileOrResource("RUNE_STONE.png"); PencilSprite = LoadSpriteFromFileOrResource("EDIT_ZONE.png"); MenuBgSprite = LoadSpriteFromFileOrResource("MENU.png"); SE_AegisDome.Init(); m_harmony = new Harmony("com.skarif.aegisdome"); SafePatch(typeof(AegisDomeBuildPatches)); SafePatch(typeof(AegisDomeMinimapPatches)); SafePatch(typeof(AegisDomeSpawnBlockPatches)); SafePatch(typeof(AegisDomeRaidPatches)); SafePatch(typeof(AegisDomeSessionPatches)); SafePatch(typeof(AegisDomeSyncPatches)); PrefabManager.OnVanillaPrefabsAvailable += RegisterAegisDomePiece; SceneManager.sceneUnloaded += OnSceneUnloaded; Log.LogInfo((object)"AegisDome v1.5.2 initialized successfully."); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AegisDomeConsoleCommand()); } private void Update() { SafeZoneManager.UpdateManager(Time.deltaTime); } private void OnDestroy() { SceneManager.sceneUnloaded -= OnSceneUnloaded; SafeZoneManager.ClearAllZones(); Harmony harmony = m_harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private static void OnSceneUnloaded(Scene scene) { SafeZoneManager.ClearAllZones(); } private void SafePatch(Type patchClass) { try { m_harmony.CreateClassProcessor(patchClass).Patch(); Log.LogInfo((object)("[AegisDome] Patch complete: " + patchClass.Name)); } catch (Exception arg) { Log.LogError((object)$"[AegisDome] Patch error {patchClass.Name}: {arg}"); } } public static Sprite LoadSpriteFromFileOrResource(string fileName) { //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown try { string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? ""; string[] array = new string[4] { Path.Combine(path, "icon", fileName), Path.Combine(Paths.PluginPath, "AegisDome", "icon", fileName), Path.Combine(Paths.PluginPath, "icon", fileName), Path.Combine(Directory.GetCurrentDirectory(), "icon", fileName) }; string[] array2 = array; foreach (string text in array2) { if (File.Exists(text)) { return CreateSpriteFromDisk(text); } } Assembly executingAssembly = Assembly.GetExecutingAssembly(); string[] manifestResourceNames = executingAssembly.GetManifestResourceNames(); foreach (string text2 in manifestResourceNames) { if (!text2.EndsWith(fileName, StringComparison.OrdinalIgnoreCase)) { continue; } using Stream stream = executingAssembly.GetManifestResourceStream(text2); if (stream != null) { byte[] array3 = new byte[stream.Length]; stream.Read(array3, 0, array3.Length); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (ImageConversion.LoadImage(val, array3)) { return PostProcessAndCreateSprite(val); } } } Log.LogWarning((object)("[AegisDome] Icon " + fileName + " not found, fallback generated.")); } catch (Exception arg) { Log.LogError((object)$"[AegisDome] Error loading icon {fileName}: {arg}"); } return Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, 4f, 4f), new Vector2(0.5f, 0.5f)); } private static Sprite CreateSpriteFromDisk(string fullPath) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown byte[] array = File.ReadAllBytes(fullPath); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (ImageConversion.LoadImage(val, array)) { return PostProcessAndCreateSprite(val); } return null; } private static Sprite PostProcessAndCreateSprite(Texture2D tex) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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) ((Texture)tex).wrapMode = (TextureWrapMode)1; ((Texture)tex).filterMode = (FilterMode)1; Color32[] pixels = tex.GetPixels32(); bool flag = false; for (int i = 0; i < pixels.Length; i++) { if (pixels[i].a > 0 && pixels[i].a < 15) { pixels[i] = new Color32((byte)0, (byte)0, (byte)0, (byte)0); flag = true; } } if (flag) { tex.SetPixels32(pixels); tex.Apply(false); } return Sprite.Create(tex, new Rect(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); } private void RegisterAegisDomePiece() { //IL_036b: 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_0480: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Expected O, but got Unknown //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_04f3: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Expected O, but got Unknown //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_0508: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Expected O, but got Unknown //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0546: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Expected O, but got Unknown //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_0567: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_057c: Expected O, but got Unknown //IL_057f: Unknown result type (might be due to invalid IL or missing references) //IL_0584: Unknown result type (might be due to invalid IL or missing references) //IL_0590: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_05a5: Expected O, but got Unknown //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05b9: Unknown result type (might be due to invalid IL or missing references) //IL_05c1: Unknown result type (might be due to invalid IL or missing references) //IL_05ce: Expected O, but got Unknown //IL_05d3: Unknown result type (might be due to invalid IL or missing references) //IL_05da: Expected O, but got Unknown PrefabManager.OnVanillaPrefabsAvailable -= RegisterAegisDomePiece; try { string text = null; string[] array = new string[7] { "Runestone_Meadows", "RuneStone", "Runestone_BlackForest", "Runestone_Swamps", "Runestone_Plains", "BossStone_Eikthyr", "Runestone_Boars" }; string[] array2 = array; foreach (string text2 in array2) { if ((Object)(object)PrefabManager.Instance.GetPrefab(text2) != (Object)null) { text = text2; break; } } if (string.IsNullOrEmpty(text)) { Log.LogError((object)"Base runestone prefab not found!"); return; } GameObject val = PrefabManager.Instance.CreateClonedPrefab("AegisDome_Runestone", text); if ((Object)(object)val == (Object)null) { Log.LogError((object)"Failed CreateClonedPrefab!"); return; } SpawnArea[] componentsInChildren = val.GetComponentsInChildren<SpawnArea>(true); foreach (SpawnArea val2 in componentsInChildren) { Object.DestroyImmediate((Object)(object)val2); } CreatureSpawner[] componentsInChildren2 = val.GetComponentsInChildren<CreatureSpawner>(true); foreach (CreatureSpawner val3 in componentsInChildren2) { Object.DestroyImmediate((Object)(object)val3); } RandomSpawn[] componentsInChildren3 = val.GetComponentsInChildren<RandomSpawn>(true); foreach (RandomSpawn val4 in componentsInChildren3) { Object.DestroyImmediate((Object)(object)val4); } Location[] componentsInChildren4 = val.GetComponentsInChildren<Location>(true); foreach (Location val5 in componentsInChildren4) { Object.DestroyImmediate((Object)(object)val5); } LODGroup[] componentsInChildren5 = val.GetComponentsInChildren<LODGroup>(true); foreach (LODGroup val6 in componentsInChildren5) { Object.DestroyImmediate((Object)(object)val6); } Component[] componentsInChildren6 = val.GetComponentsInChildren<Component>(true); foreach (Component val7 in componentsInChildren6) { if ((Object)(object)val7 == (Object)null || val7 is AegisDomeStone || val7 is Transform || val7 is MeshFilter || val7 is MeshRenderer || val7 is Collider || val7 is ZNetView) { continue; } if (val7 is Hoverable || val7 is Interactable) { MonoBehaviour val8 = (MonoBehaviour)(object)((val7 is MonoBehaviour) ? val7 : null); if (val8 != null) { Object.DestroyImmediate((Object)(object)val8); } continue; } string name = ((object)val7).GetType().Name; if (name.IndexOf("Rune", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Text", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Lore", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Read", StringComparison.OrdinalIgnoreCase) >= 0) { MonoBehaviour val9 = (MonoBehaviour)(object)((val7 is MonoBehaviour) ? val7 : null); if (val9 != null) { Object.DestroyImmediate((Object)(object)val9); } } } ZNetView val10 = val.GetComponent<ZNetView>() ?? val.AddComponent<ZNetView>(); val10.m_persistent = true; Piece val11 = val.GetComponent<Piece>() ?? val.AddComponent<Piece>(); val11.m_groundPiece = true; val11.m_clipGround = true; val11.m_groundOnly = true; WearNTear val12 = val.GetComponent<WearNTear>() ?? val.AddComponent<WearNTear>(); val12.m_health = 1500f; val12.m_materialType = (MaterialType)1; int layer = (val.layer = LayerMask.NameToLayer("piece")); Transform[] componentsInChildren7 = val.GetComponentsInChildren<Transform>(true); foreach (Transform val13 in componentsInChildren7) { ((Component)val13).gameObject.layer = layer; } MeshCollider[] componentsInChildren8 = val.GetComponentsInChildren<MeshCollider>(true); foreach (MeshCollider val14 in componentsInChildren8) { val14.convex = true; } if ((Object)(object)val.GetComponentInChildren<Collider>(true) == (Object)null) { CapsuleCollider val15 = val.AddComponent<CapsuleCollider>(); val15.height = 2.5f; val15.radius = 0.6f; val15.center = new Vector3(0f, 1.25f, 0f); } Renderer[] componentsInChildren9 = val.GetComponentsInChildren<Renderer>(true); foreach (Renderer val16 in componentsInChildren9) { val16.enabled = true; ((Component)val16).gameObject.SetActive(true); } val.AddComponent<AegisDomeStone>(); PieceConfig val17 = new PieceConfig { Name = PieceLocalizedName, Description = T("Creates a magical rune dome of arbitrary shape, blocking the spawn of darkness.", "Создает магический рунный купол произвольной формы, блокирующий спавн тьмы.", "Створює магічний рунний купол довільної форми, що блокує спавн темряви.", "Crea una cúpula rúnica mágica de forma personalizada que bloquea la aparición de la oscuridad."), PieceTable = PieceTables.Hammer, Category = PieceCategories.Misc, Icon = RunestonePinSprite }; val17.AddRequirement(new RequirementConfig { Item = "Stone", Amount = 45, Recover = true }); val17.AddRequirement(new RequirementConfig { Item = "Silver", Amount = 20, Recover = true }); val17.AddRequirement(new RequirementConfig { Item = "DragonTear", Amount = 1, Recover = true }); val17.AddRequirement(new RequirementConfig { Item = "Thunderstone", Amount = 1, Recover = true }); val17.AddRequirement(new RequirementConfig { Item = "TrophyCultist", Amount = 3, Recover = false }); val17.AddRequirement(new RequirementConfig { Item = "TrophyGoblinShaman", Amount = 1, Recover = false }); CustomPiece val18 = new CustomPiece(val, false, val17); PieceManager.Instance.AddPiece(val18); AegisDomePrefab = val; Log.LogInfo((object)"AegisDome_Runestone added to Hammer -> Misc."); } catch (Exception arg) { Log.LogError((object)$"Registration error AegisDome: {arg}"); } } } public class AegisDomeConsoleCommand : ConsoleCommand { public override string Name => "AegisDome"; public override string Help => "AegisDome commands:\n AegisDome nocost near <false|true> - Toggle infinite fuel on nearest stone (false = infinite)\n AegisDome nocost all <false|true> - Toggle infinite fuel on all stones (false = infinite)\n AegisDome visualEffect <false|true> - Disable/enable visual effects and despawn VFX"; public override void Run(string[] args) { //IL_0162: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) if (args == null || args.Length == 0) { PrintMessage(((ConsoleCommand)this).Help); return; } int num = 0; if (args[0].Equals("AegisDome", StringComparison.OrdinalIgnoreCase)) { num = 1; } if (args.Length <= num) { PrintMessage(((ConsoleCommand)this).Help); return; } string text = args[num].ToLowerInvariant(); if (text == "nocost" || text == "cost") { if (args.Length <= num + 1) { PrintMessage("Usage: AegisDome nocost <near|all> [false|true]"); return; } string text2 = args[num + 1].ToLowerInvariant(); string text3 = ((args.Length > num + 2) ? args[num + 2].ToLowerInvariant() : ""); bool flag = true; if (text3 == "true" || text3 == "on" || text3 == "1") { flag = false; } else if (text3 == "false" || text3 == "off" || text3 == "0") { flag = true; } Player localPlayer = Player.m_localPlayer; Vector3 playerPos = (((Object)(object)localPlayer != (Object)null) ? ((Component)localPlayer).transform.position : Vector3.zero); if (text2 == "near") { if ((Object)(object)localPlayer == (Object)null) { PrintMessage("[AegisDome] Player not found."); } else if (SafeZoneManager.SetNoCostNear(playerPos, flag)) { string msg = (flag ? AegisDomePlugin.T("AegisDome: Infinite fuel ENABLED (∞) for nearest stone.", "AegisDome: Бесконечное топливо ВКЛЮЧЕНО (∞) для ближайшего камня.", "AegisDome: Безкінечне паливо ВКЛЮЧЕНО (∞) для найближчого каменю.", "AegisDome: Combustible infinito ACTIVADO (∞) para la piedra cercana.") : AegisDomePlugin.T("AegisDome: Infinite fuel DISABLED for nearest stone.", "AegisDome: Бесконечное топливо ВЫКЛЮЧЕНО для ближайшего камня.", "AegisDome: Безкінечне паливо ВИМКНЕНО для найближчого каменю.", "AegisDome: Combustible infinito DESACTIVADO para la piedra cercana.")); PrintMessage(msg); } else { PrintMessage(AegisDomePlugin.T("[AegisDome] No runestones found nearby.", "[AegisDome] Рунный камень поблизости не найден.", "[AegisDome] Рунний камінь поблизу не знайдено.", "[AegisDome] No se encontró ninguna piedra rúnica cerca.")); } } else if (text2 == "all") { int num2 = SafeZoneManager.SetNoCostAll(flag); string msg2 = (flag ? AegisDomePlugin.T($"AegisDome: Infinite fuel ENABLED (∞) for all stones ({num2}).", $"AegisDome: Бесконечное топливо ВКЛЮЧЕНО (∞) для всех камней ({num2}).", $"AegisDome: Безкінечне паливо ВКЛЮЧЕНО (∞) для всіх каменів ({num2}).", $"AegisDome: Combustible infinito ACTIVADO (∞) para todas las piedras ({num2}).") : AegisDomePlugin.T($"AegisDome: Infinite fuel DISABLED for all stones ({num2}).", $"AegisDome: Бесконечное топливо ВЫКЛЮЧЕНО для всех камней ({num2}).", $"AegisDome: Безкінечне паливо ВИМКНЕНО для всіх каменів ({num2}).", $"AegisDome: Combustible infinito DESACTIVADO para todas las piedras ({num2}).")); PrintMessage(msg2); } else { PrintMessage("Usage: AegisDome nocost <near|all> [false|true]"); } } else if (text == "visualeffect" || text == "visualeffects" || text == "visual") { string text4 = ((args.Length > num + 1) ? args[num + 1].ToLowerInvariant() : ""); bool flag2 = !AegisDomePlugin.VisualEffectsEnabled; if (text4 == "false" || text4 == "off" || text4 == "0") { flag2 = false; } else if (text4 == "true" || text4 == "on" || text4 == "1") { flag2 = true; } AegisDomePlugin.VisualEffectsEnabled = flag2; SafeZoneManager.UpdateAllVisualEffects(); string msg3 = (flag2 ? AegisDomePlugin.T("AegisDome: Visual effects ENABLED.", "AegisDome: Визуальные эффекты ВКЛЮЧЕНЫ.", "AegisDome: Візуальні ефекти ВКЛЮЧЕНО.", "AegisDome: Efectos visuales ACTIVADOS.") : AegisDomePlugin.T("AegisDome: Visual effects DISABLED.", "AegisDome: Визуальные эффекты ОТКЛЮЧЕНЫ.", "AegisDome: Візуальні ефекти ВИМКНЕНО.", "AegisDome: Efectos visuales DESACTIVADOS.")); PrintMessage(msg3); } else { PrintMessage(((ConsoleCommand)this).Help); } } private static void PrintMessage(string msg) { if ((Object)(object)Console.instance != (Object)null) { Console.instance.Print(msg); } Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, msg, 0, (Sprite)null, false); } } } public class SE_AegisDome : StatusEffect { public const string EffectName = "SE_AegisDome"; public static readonly int EffectHash = StringExtensionMethods.GetStableHashCode("SE_AegisDome"); public static SE_AegisDome Instance { get; private set; } public static void Init() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown if ((Object)(object)Instance != (Object)null) { return; } Instance = ScriptableObject.CreateInstance<SE_AegisDome>(); ((Object)Instance).name = "SE_AegisDome"; ((StatusEffect)Instance).m_name = "AegisDome"; ((StatusEffect)Instance).m_icon = AegisDomePlugin.RunestonePinSprite; ((StatusEffect)Instance).m_tooltip = AegisDomePlugin.T("Rune dome protection: blocks the appearance and spawning of enemies.", "Защита рунного купола: блокирует появление и спавн врагов.", "Захист рунного купола: блокує появу та спавн ворогів.", "Protección de la cúpula rúnica: bloquea la aparición y el engendro de enemigos."); ((StatusEffect)Instance).m_ttl = 0f; try { ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)Instance, false)); } catch (Exception ex) { AegisDomePlugin.Log.LogWarning((object)("[AegisDome] ItemManager AddStatusEffect: " + ex.Message)); } } public override bool CanAdd(Character character) { return character is Player; } } public static class MinimapHelper { public static Vector3 ScreenToWorld(Minimap minimap, Vector3 mousePos) { //IL_0015: 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_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_001e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)minimap == (Object)null) { return Vector3.zero; } return minimap.ScreenToWorldPoint(mousePos); } public static void WorldToMap(Minimap minimap, Vector3 worldPos, out float mx, out float my) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)minimap == (Object)null) { mx = 0f; my = 0f; } else { minimap.WorldToMapPoint(worldPos, out mx, out my); } } } public static class MinimapExtensions { public static void WorldToMapPoint(this Minimap minimap, Vector3 p, out float mx, out float my) { //IL_0027: 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) if ((Object)(object)minimap == (Object)null) { mx = 0f; my = 0f; } else { int num = minimap.m_textureSize / 2; mx = (p.x / minimap.m_pixelSize + (float)num) / (float)minimap.m_textureSize; my = (p.z / minimap.m_pixelSize + (float)num) / (float)minimap.m_textureSize; } } public static Vector3 MapPointToWorld(this Minimap minimap, float mx, float my) { //IL_004e: 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_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_0056: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)minimap == (Object)null) { return Vector3.zero; } int num = minimap.m_textureSize / 2; mx = (mx * (float)minimap.m_textureSize - (float)num) * minimap.m_pixelSize; my = (my * (float)minimap.m_textureSize - (float)num) * minimap.m_pixelSize; return new Vector3(mx, 0f, my); } public static Vector3 ScreenToWorldPoint(this Minimap minimap, Vector3 mousePos) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_00bd: 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_00ba: 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_0061: 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_0067: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)minimap == (Object)null || (Object)(object)minimap.m_mapImageLarge == (Object)null) { return Vector3.zero; } Transform transform = ((Component)minimap.m_mapImageLarge).transform; RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null); Vector2 val2 = default(Vector2); if ((Object)(object)val != (Object)null && RectTransformUtility.ScreenPointToLocalPointInRectangle(val, Vector2.op_Implicit(mousePos), (Camera)null, ref val2)) { Vector2 val3 = Rect.PointToNormalized(val.rect, val2); Rect uvRect = minimap.m_mapImageLarge.uvRect; float mx = ((Rect)(ref uvRect)).xMin + val3.x * ((Rect)(ref uvRect)).width; float my = ((Rect)(ref uvRect)).yMin + val3.y * ((Rect)(ref uvRect)).height; return minimap.MapPointToWorld(mx, my); } return Vector3.zero; } } public static class SafeZoneGeometry { public static bool IsPointInPolygon(Vector2 point, Vector2[] polygon) { //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_0035: 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_003c: 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_004b: 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_005c: 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_0069: 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_0077: 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_0087: 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) if (polygon == null || polygon.Length < 3) { return false; } bool flag = false; int num = 0; int num2 = polygon.Length - 1; while (num < polygon.Length) { Vector2 val = polygon[num2]; Vector2 val2 = polygon[num]; if (val2.y > point.y != val.y > point.y && point.x < (val.x - val2.x) * (point.y - val2.y) / (val.y - val2.y) + val2.x) { flag = !flag; } num2 = num++; } return flag; } public static float CalculatePolygonAreaXZ(Vector2[] points) { if (points == null || points.Length < 3) { return 0f; } float num = 0f; int num2 = points.Length - 1; for (int i = 0; i < points.Length; i++) { num += (points[num2].x + points[i].x) * (points[num2].y - points[i].y); num2 = i; } return Mathf.Abs(num * 0.5f); } } public class SafeZoneData { public ZDOID StoneZDOID; public Vector3 StonePosition; public Vector2[] PolygonXZ; public Rect BoundingBox; public float Area; public float Fuel; public bool IsNoCost; public bool IsActive; public bool IsVisibleOnMap = true; public PinData MapPin; public GameObject VisualObject; } public static class AegisDomePinFilter { private static readonly FieldInfo s_pinUpdateRequiredField = AccessTools.Field(typeof(Minimap), "m_pinUpdateRequired"); private static readonly FieldInfo s_pinsField = AccessTools.Field(typeof(Minimap), "m_pins"); public static bool IsVisible { get; private set; } = true; public static bool IsAegisDomePin(PinData pin) { if (pin == null) { return false; } if ((Object)(object)pin.m_icon == (Object)(object)AegisDomePlugin.RunestonePinSprite) { return true; } if (!string.IsNullOrEmpty(pin.m_name) && pin.m_name.IndexOf("AegisDome", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } return false; } public static void ToggleVisibility() { IsVisible = !IsVisible; if ((Object)(object)Minimap.instance != (Object)null && s_pinUpdateRequiredField != null) { s_pinUpdateRequiredField.SetValue(Minimap.instance, true); } if ((Object)(object)Minimap.instance != (Object)null && s_pinsField != null && s_pinsField.GetValue(Minimap.instance) is List<PinData> list) { foreach (PinData item in list) { if (!IsAegisDomePin(item)) { continue; } if (!IsVisible) { if (item.m_name != "") { item.m_name = ""; } if ((Object)(object)item.m_uiElement != (Object)null && ((Component)item.m_uiElement).gameObject.activeSelf) { ((Component)item.m_uiElement).gameObject.SetActive(false); } if (item.m_NamePinData == null) { continue; } if ((Object)(object)item.m_NamePinData.PinNameGameObject != (Object)null && item.m_NamePinData.PinNameGameObject.activeSelf) { item.m_NamePinData.PinNameGameObject.SetActive(false); } TMP_Text pinNameText = item.m_NamePinData.PinNameText; if ((Object)(object)pinNameText != (Object)null) { if (pinNameText.text != "") { pinNameText.text = ""; } if (((Behaviour)pinNameText).enabled) { ((Behaviour)pinNameText).enabled = false; } } continue; } if (item.m_name != "AegisDome") { item.m_name = "AegisDome"; } if ((Object)(object)item.m_uiElement != (Object)null && !((Component)item.m_uiElement).gameObject.activeSelf) { ((Component)item.m_uiElement).gameObject.SetActive(true); } if (item.m_NamePinData != null && (Object)(object)item.m_NamePinData.PinNameText != (Object)null) { TMP_Text pinNameText2 = item.m_NamePinData.PinNameText; if (pinNameText2.text != "AegisDome") { pinNameText2.text = "AegisDome"; } if (!((Behaviour)pinNameText2).enabled) { ((Behaviour)pinNameText2).enabled = true; } } } } Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, IsVisible ? AegisDomePlugin.T("AegisDome pins are shown", "Метки AegisDome отображаются", "Мітки AegisDome відображаються", "Marcadores de AegisDome visibles") : AegisDomePlugin.T("AegisDome pins are hidden", "Метки AegisDome скрыты", "Мітки AegisDome приховані", "Marcadores de AegisDome ocultos"), 0, (Sprite)null, false); } } } public class AegisDomeWorldVisual : MonoBehaviour { private MeshFilter m_meshFilter; private MeshRenderer m_meshRenderer; private ParticleSystem m_particleSystem; private Material m_wallMaterial; private Material m_particleMaterial; private Rect m_bounds; private float m_cullTimer = 0f; private bool m_isNear = true; private bool m_isActiveDome = true; private int m_lastPolyHash = 0; private float m_transitionProgress = 1f; private bool m_isInitialized = false; private const float TransitionSpeed = 0.75f; private static readonly Color ColorActiveWall = new Color(0.18f, 0.82f, 1f); private static readonly Color ColorInactiveWall = new Color(0.92f, 0.22f, 0.15f); private static readonly Color ColorActiveParticles = new Color(0.4f, 0.9f, 1f, 0.85f); private static readonly Color ColorInactiveParticles = new Color(1f, 0.35f, 0.25f, 0.5f); private static Texture2D s_gradientTexture; private static readonly int s_terrainMask = LayerMask.GetMask(new string[4] { "terrain", "Default", "piece", "static_solid" }); private static Texture2D GetOrCreateGradientTexture() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s_gradientTexture != (Object)null) { return s_gradientTexture; } int num = 4; int num2 = 128; s_gradientTexture = new Texture2D(num, num2, (TextureFormat)4, false); ((Object)s_gradientTexture).name = "AegisDome_GradientTex"; ((Texture)s_gradientTexture).wrapMode = (TextureWrapMode)1; ((Texture)s_gradientTexture).filterMode = (FilterMode)1; Color[] array = (Color[])(object)new Color[num * num2]; Color val = default(Color); for (int i = 0; i < num2; i++) { float num3 = (float)i / (float)(num2 - 1); float num4; if (num3 < 0.08f) { num4 = Mathf.SmoothStep(0f, 1f, num3 / 0.08f); } else { float num5 = 1f - (num3 - 0.08f) / 0.92f; num4 = Mathf.Pow(Mathf.Clamp01(num5), 1.7f); } ((Color)(ref val))..ctor(1f, 1f, 1f, num4); for (int j = 0; j < num; j++) { array[i * num + j] = val; } } s_gradientTexture.SetPixels(array); s_gradientTexture.Apply(); return s_gradientTexture; } private static Material CreateBoundaryMaterial() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Legacy Shaders/Particles/Alpha Blended") ?? Shader.Find("Particles/Standard Unlit"); Material val2 = new Material(val); val2.mainTexture = (Texture)(object)GetOrCreateGradientTexture(); if (val2.HasProperty("_Mode")) { val2.SetFloat("_Mode", 2f); } if (val2.HasProperty("_BlendMode")) { val2.SetFloat("_BlendMode", 2f); } if (val2.HasProperty("_SrcBlend")) { val2.SetInt("_SrcBlend", 5); } if (val2.HasProperty("_DstBlend")) { val2.SetInt("_DstBlend", 10); } if (val2.HasProperty("_ZWrite")) { val2.SetInt("_ZWrite", 0); } if (val2.HasProperty("_Cull")) { val2.SetInt("_Cull", 0); } val2.DisableKeyword("_ALPHATEST_ON"); val2.EnableKeyword("_ALPHABLEND_ON"); val2.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val2.renderQueue = 3100; return val2; } private int ComputePolygonHash(Vector2[] poly) { if (poly == null) { return 0; } int num = 17; for (int i = 0; i < poly.Length; i++) { num = num * 31 + poly[i].x.GetHashCode(); num = num * 31 + poly[i].y.GetHashCode(); } return num; } public void Setup(Vector2[] polygon, Rect bounds, bool isActive) { //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) m_bounds = bounds; m_isActiveDome = isActive; if (!m_isInitialized) { m_transitionProgress = (isActive ? 1f : 0f); m_isInitialized = true; } if ((Object)(object)m_meshFilter == (Object)null) { m_meshFilter = ((Component)this).gameObject.GetComponent<MeshFilter>() ?? ((Component)this).gameObject.AddComponent<MeshFilter>(); } if ((Object)(object)m_meshRenderer == (Object)null) { m_meshRenderer = ((Component)this).gameObject.GetComponent<MeshRenderer>() ?? ((Component)this).gameObject.AddComponent<MeshRenderer>(); } if ((Object)(object)m_wallMaterial == (Object)null) { m_wallMaterial = CreateBoundaryMaterial(); ((Renderer)m_meshRenderer).material = m_wallMaterial; ((Renderer)m_meshRenderer).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)m_meshRenderer).receiveShadows = false; } int num = ComputePolygonHash(polygon); if (num != m_lastPolyHash || (Object)(object)m_meshFilter.sharedMesh == (Object)null) { m_lastPolyHash = num; if ((Object)(object)m_meshFilter.sharedMesh != (Object)null) { Object.Destroy((Object)(object)m_meshFilter.sharedMesh); m_meshFilter.sharedMesh = null; } Mesh val = BuildRibbonMesh(polygon); m_meshFilter.sharedMesh = val; SetupParticles(val, polygon); } } private Mesh BuildRibbonMesh(Vector2[] polygon) { //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_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_0049: 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_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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: 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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: 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_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Expected O, but got Unknown //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: 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_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_040f: 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_0426: 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) if (polygon == null || polygon.Length < 3) { return null; } List<Vector3> list = new List<Vector3>(polygon.Length * 8); for (int i = 0; i < polygon.Length; i++) { Vector2 val = polygon[i]; Vector2 val2 = polygon[(i + 1) % polygon.Length]; float num = Vector2.Distance(val, val2); int num2 = Mathf.Max(1, Mathf.CeilToInt(num / 1.5f)); for (int j = 0; j < num2; j++) { Vector2 val3 = Vector2.Lerp(val, val2, (float)j / (float)num2); float groundHeight = GetGroundHeight(val3.x, val3.y); list.Add(new Vector3(val3.x, groundHeight, val3.y)); } } int count = list.Count; if (count < 3) { return null; } int num3 = 4; int num4 = count * num3; Vector3[] array = (Vector3[])(object)new Vector3[num4]; Color[] array2 = (Color[])(object)new Color[num4]; Vector2[] array3 = (Vector2[])(object)new Vector2[num4]; List<int> list2 = new List<int>(count * 18); Vector2 val9 = default(Vector2); Vector3 val11 = default(Vector3); Vector3 val12 = default(Vector3); Vector3 val13 = default(Vector3); Vector3 val14 = default(Vector3); for (int k = 0; k < count; k++) { Vector3 val4 = list[k]; Vector3 val5 = list[(k + 1) % count]; Vector3 val6 = list[(k - 1 + count) % count]; Vector2 val7 = new Vector2(val4.x - val6.x, val4.z - val6.z); Vector2 normalized = ((Vector2)(ref val7)).normalized; val7 = new Vector2(val5.x - val4.x, val5.z - val4.z); Vector2 normalized2 = ((Vector2)(ref val7)).normalized; val7 = normalized + normalized2; Vector2 val8 = ((Vector2)(ref val7)).normalized; if (((Vector2)(ref val8)).sqrMagnitude < 0.001f) { val8 = normalized2; } ((Vector2)(ref val9))..ctor(0f - val8.y, val8.x); float num5 = Vector2.Dot(val9, new Vector2(0f - normalized.y, normalized.x)); float num6 = Mathf.Clamp((num5 > 0.1f) ? (1f / num5) : 1f, 0.6f, 1.6f); Vector2 val10 = val9 * (0.3f * num6); float num7 = val4.x - val10.x; float num8 = val4.z - val10.y; float num9 = val4.x + val10.x; float num10 = val4.z + val10.y; float groundHeight2 = GetGroundHeight(num7, num8); float groundHeight3 = GetGroundHeight(num9, num10); ((Vector3)(ref val11))..ctor(num7, groundHeight2 + 0.04f, num8); ((Vector3)(ref val12))..ctor(val4.x, val4.y + 0.06f, val4.z); ((Vector3)(ref val13))..ctor(num9, groundHeight3 + 0.04f, num10); ((Vector3)(ref val14))..ctor(val4.x, val4.y + 1.4f, val4.z); int num11 = k * num3; float num12 = (float)k / (float)count; array[num11] = val11; array2[num11] = new Color(1f, 1f, 1f, 0f); array3[num11] = new Vector2(num12, 0f); array[num11 + 1] = val12; array2[num11 + 1] = new Color(1f, 1f, 1f, 1f); array3[num11 + 1] = new Vector2(num12, 0.08f); array[num11 + 2] = val13; array2[num11 + 2] = new Color(1f, 1f, 1f, 0f); array3[num11 + 2] = new Vector2(num12, 0f); array[num11 + 3] = val14; array2[num11 + 3] = new Color(1f, 1f, 1f, 0f); array3[num11 + 3] = new Vector2(num12, 1f); } for (int l = 0; l < count; l++) { int num13 = l * num3; int num14 = (l + 1) % count * num3; AddQuad(list2, num13, num13 + 1, num14, num14 + 1); AddQuad(list2, num13 + 1, num13 + 2, num14 + 1, num14 + 2); AddQuad(list2, num13 + 1, num13 + 3, num14 + 1, num14 + 3); } Mesh val15 = new Mesh(); ((Object)val15).name = "AegisDome_BoundaryRibbon"; val15.vertices = array; val15.colors = array2; val15.uv = array3; val15.triangles = list2.ToArray(); val15.RecalculateBounds(); return val15; } private static void AddQuad(List<int> tris, int bl, int tl, int br, int tr) { tris.Add(bl); tris.Add(tl); tris.Add(br); tris.Add(tl); tris.Add(tr); tris.Add(br); } private static float GetGroundHeight(float x, float z) { //IL_001a: 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) //IL_005d: Unknown result type (might be due to invalid IL or missing references) float result = default(float); if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(new Vector3(x, 0f, z), ref result)) { return result; } RaycastHit val = default(RaycastHit); if (Physics.Raycast(new Vector3(x, 400f, z), Vector3.down, ref val, 800f, s_terrainMask)) { return ((RaycastHit)(ref val)).point.y; } return 30f; } private void SetupParticles(Mesh mesh, Vector2[] polygon) { //IL_004d: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_0131: 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) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_016c: 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) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown //IL_01b5: 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_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0207: 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_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0233: 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_0247: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Expected O, but got Unknown //IL_02bd: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)mesh == (Object)null)) { if ((Object)(object)m_particleSystem == (Object)null) { m_particleSystem = ((Component)this).gameObject.GetComponent<ParticleSystem>() ?? ((Component)this).gameObject.AddComponent<ParticleSystem>(); } MainModule main = m_particleSystem.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(2f, 3.5f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.08f, 0.22f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.06f, 0.12f); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Color.white); ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).maxParticles = 140; EmissionModule emission = m_particleSystem.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(Mathf.Clamp((float)polygon.Length * 2.5f, 10f, 35f)); ShapeModule shape = m_particleSystem.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)6; ((ShapeModule)(ref shape)).mesh = mesh; ((ShapeModule)(ref shape)).meshShapeType = (ParticleSystemMeshShapeType)2; VelocityOverLifetimeModule velocityOverLifetime = m_particleSystem.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(0f, 0f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0.12f, 0.35f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(0f, 0f); ColorOverLifetimeModule colorOverLifetime = m_particleSystem.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val = new Gradient(); val.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[4] { new GradientAlphaKey(0f, 0f), new GradientAlphaKey(0.85f, 0.25f), new GradientAlphaKey(0.85f, 0.65f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val); ParticleSystemRenderer component = ((Component)m_particleSystem).GetComponent<ParticleSystemRenderer>(); if ((Object)(object)component != (Object)null && (Object)(object)m_particleMaterial == (Object)null) { Shader val2 = Shader.Find("Sprites/Default") ?? Shader.Find("Particles/Standard Unlit"); m_particleMaterial = new Material(val2); m_particleMaterial.mainTexture = (Texture)(object)Texture2D.whiteTexture; m_particleMaterial.color = Color.white; ((Renderer)component).material = m_particleMaterial; component.renderMode = (ParticleSystemRenderMode)0; ((Renderer)component).sortingOrder = 10; } m_particleSystem.Play(); } } private void Update() { //IL_0137: 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_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_019a: 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) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) if (!AegisDomePlugin.VisualEffectsEnabled) { if ((Object)(object)m_meshRenderer != (Object)null && ((Renderer)m_meshRenderer).enabled) { ((Renderer)m_meshRenderer).enabled = false; } if ((Object)(object)m_particleSystem != (Object)null && m_particleSystem.isPlaying) { m_particleSystem.Stop(true, (ParticleSystemStopBehavior)0); } return; } m_cullTimer += Time.deltaTime; if (m_cullTimer >= 0.5f) { m_cullTimer = 0f; CheckDistance(); } if (m_isNear) { float num = (m_isActiveDome ? 1f : 0f); if (!Mathf.Approximately(m_transitionProgress, num)) { m_transitionProgress = Mathf.MoveTowards(m_transitionProgress, num, Time.deltaTime * 0.75f); } float num2 = Mathf.SmoothStep(0f, 1f, m_transitionProgress); if ((Object)(object)m_wallMaterial != (Object)null) { Color val = Color.Lerp(ColorInactiveWall, ColorActiveWall, num2); float num3 = Mathf.Lerp(1.6f, 2.2f, num2); float num4 = Mathf.Lerp(0.32f, 0.56f, num2); float num5 = Mathf.Lerp(0.08f, 0.16f, num2); float num6 = num4 + num5 * Mathf.Sin(Time.time * num3); m_wallMaterial.color = new Color(val.r, val.g, val.b, num6); } if ((Object)(object)m_particleMaterial != (Object)null) { m_particleMaterial.color = Color.Lerp(ColorInactiveParticles, ColorActiveParticles, num2); } } } private void CheckDistance() { //IL_001f: 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_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_0048: 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_007c: 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) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } Vector3 position = ((Component)localPlayer).transform.position; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(position.x, position.z); float num = Mathf.Max(0f, Mathf.Max(((Rect)(ref m_bounds)).xMin - val.x, val.x - ((Rect)(ref m_bounds)).xMax)); float num2 = Mathf.Max(0f, Mathf.Max(((Rect)(ref m_bounds)).yMin - val.y, val.y - ((Rect)(ref m_bounds)).yMax)); float num3 = num * num + num2 * num2; bool flag = num3 < 25600f; if (flag == m_isNear) { return; } m_isNear = flag; if ((Object)(object)m_meshRenderer != (Object)null) { ((Renderer)m_meshRenderer).enabled = m_isNear; } if ((Object)(object)m_particleSystem != (Object)null) { if (m_isNear) { m_particleSystem.Play(); } else { m_particleSystem.Pause(); } } } private void OnDestroy() { if ((Object)(object)m_meshFilter != (Object)null && (Object)(object)m_meshFilter.sharedMesh != (Object)null) { Object.Destroy((Object)(object)m_meshFilter.sharedMesh); m_meshFilter.sharedMesh = null; } if ((Object)(object)m_wallMaterial != (Object)null) { Object.Destroy((Object)(object)m_wallMaterial); m_wallMaterial = null; } if ((Object)(object)m_particleMaterial != (Object)null) { Object.Destroy((Object)(object)m_particleMaterial); m_particleMaterial = null; } } } public static class SafeZoneManager { private static readonly Dictionary<ZDOID, SafeZoneData> s_activeZones = new Dictionary<ZDOID, SafeZoneData>(); private static float s_statusEffectTimer = 0f; private const float StatusEffectInterval = 0.2f; private static Rect s_globalActiveBounds; private static bool s_hasActiveBounds = false; private static float s_creatureCleanupTimer = 0f; private static float s_fuelDrainTimer = 0f; private static float s_logTimer = -999f; private static readonly int VFX_SPAWN_SMALL_HASH = StringExtensionMethods.GetStableHashCode("vfx_spawn_small"); public static readonly HashSet<string> BossPrefabNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Eikthyr", "gd_king", "Bonemass", "Dragon", "GoblinKing", "SeekerQueen", "Fader", "KallFimbulbringer" }; public static readonly HashSet<string> ForbiddenLowTierTrophies = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "TrophyBoar", "TrophyDeer", "TrophyNeck", "TrophyGreyling", "TrophyEikthyr", "TrophyGreydwarf", "TrophyGreydwarfBrute", "TrophyGreydwarfShaman", "TrophySkeleton", "TrophyTroll", "TrophyTheElder" }; public static void RecalculateGlobalBounds() { //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) bool flag = true; float num = 0f; float num2 = 0f; float num3 = 0f; float num4 = 0f; foreach (SafeZoneData value in s_activeZones.Values) { if (!value.IsActive || value.PolygonXZ == null || value.PolygonXZ.Length < 3) { continue; } if (flag) { num = ((Rect)(ref value.BoundingBox)).xMin; num2 = ((Rect)(ref value.BoundingBox)).xMax; num3 = ((Rect)(ref value.BoundingBox)).yMin; num4 = ((Rect)(ref value.BoundingBox)).yMax; flag = false; continue; } if (((Rect)(ref value.BoundingBox)).xMin < num) { num = ((Rect)(ref value.BoundingBox)).xMin; } if (((Rect)(ref value.BoundingBox)).xMax > num2) { num2 = ((Rect)(ref value.BoundingBox)).xMax; } if (((Rect)(ref value.BoundingBox)).yMin < num3) { num3 = ((Rect)(ref value.BoundingBox)).yMin; } if (((Rect)(ref value.BoundingBox)).yMax > num4) { num4 = ((Rect)(ref value.BoundingBox)).yMax; } } s_hasActiveBounds = !flag; if (s_hasActiveBounds) { s_globalActiveBounds = Rect.MinMaxRect(num, num3, num2, num4); } } public static void PlaySFX(string sfxName, Vector3 position) { //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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNetScene.instance == (Object)null) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { float num = Vector3.Distance(((Component)localPlayer).transform.position, position); if (num > 80f) { return; } } GameObject prefab = ZNetScene.instance.GetPrefab(sfxName); if (!((Object)(object)prefab == (Object)null)) { GameObject val = Object.Instantiate<GameObject>(prefab, position, Quaternion.identity); AudioSource componentInChildren = val.GetComponentInChildren<AudioSource>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.spatialBlend = 1f; componentInChildren.maxDistance = Mathf.Max(componentInChildren.maxDistance, 55f); } } } [HarmonyPatch(typeof(Player), "PlacePiece")] [HarmonyPostfix] public static void Player_PlacePiece_Postfix(Piece piece) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)piece != (Object)null && ((Object)piece).name.StartsWith("AegisDome_Runestone", StringComparison.Ordinal)) { PlaySFX("sfx_malicious_ice_break", ((Component)piece).transform.position); } } private static void HandleBossInvasion(Character boss, SafeZoneData zone) { //IL_0055: 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_012e: Unknown result type (might be due to invalid IL or missing references) if (zone == null) { return; } zone.Fuel = 0f; zone.IsActive = false; if ((Object)(object)zone.VisualObject != (Object)null) { AegisDomeWorldVisual component = zone.VisualObject.GetComponent<AegisDomeWorldVisual>(); if ((Object)(object)component != (Object)null) { component.Setup(zone.PolygonXZ, zone.BoundingBox, isActive: false); } } if (ZDOMan.instance != null && !((ZDOID)(ref zone.StoneZDOID)).IsNone()) { ZDO zDO = ZDOMan.instance.GetZDO(zone.StoneZDOID); if (zDO != null && zDO.IsValid()) { if (!zDO.IsOwner() && (Object)(object)ZNet.instance != (Object)null) { zDO.SetOwner(ZDOMan.GetSessionID()); } zDO.Set(AegisDomeStone.HashFuel, 0f); zDO.Set(AegisDomeStone.HashActive, false); } } RecalculateGlobalBounds(); float num = Mathf.Max(250f, boss.GetMaxHealth() * 0.05f); boss.Heal(num, true); if (AegisDomePlugin.VisualEffectsEnabled) { SpawnVFX(((Component)boss).transform.position); } string text = AegisDomePlugin.T("The Fallen consumes the souls of subjects", "Павший использует души поданных", "Полеглий використовує душі підданих", "El Caído consume las almas de sus súbditos"); MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)2, text, 0, (Sprite)null, false, true); } LogThrottled("[AegisDome] '" + ((Object)((Component)boss).gameObject).name + "' healed by invading zone"); } public static bool IsBoss(Character c) { if ((Object)(object)c == (Object)null) { return false; } if (c.IsBoss()) { return true; } string prefabName = Utils.GetPrefabName(((Component)c).gameObject); return BossPrefabNames.Contains(prefabName); } public static void SpawnVFX(Vector3 position) { //IL_0039: 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) if (AegisDomePlugin.VisualEffectsEnabled && !((Object)(object)ZNetScene.instance == (Object)null)) { GameObject prefab = ZNetScene.instance.GetPrefab(VFX_SPAWN_SMALL_HASH); if ((Object)(object)prefab != (Object)null) { Object.Instantiate<GameObject>(prefab, position, Quaternion.identity); } } } public static void EnsureStatusEffectInObjectDB() { if (!((Object)(object)ObjectDB.instance == (Object)null) && !((Object)(object)SE_AegisDome.Instance == (Object)null) && !ObjectDB.instance.m_StatusEffects.Contains((StatusEffect)(object)SE_AegisDome.Instance)) { ObjectDB.instance.m_StatusEffects.Add((StatusEffect)(object)SE_AegisDome.Instance); } } public static void UpdateManager(float dt) { s_statusEffectTimer += dt; if (s_statusEffectTimer >= 0.2f) { s_statusEffectTimer = 0f; UpdatePlayerStatusEffect(); } s_fuelDrainTimer += dt; if (s_fuelDrainTimer >= 1f) { DrainFuelStep(s_fuelDrainTimer); s_fuelDrainTimer = 0f; } s_creatureCleanupTimer += dt; if (s_creatureCleanupTimer >= 1f) { s_creatureCleanupTimer = 0f; UpdateHostileDespawn(); } } private static void UpdatePlayerStatusEffect() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { return; } SEMan sEMan = ((Character)localPlayer).GetSEMan(); if (sEMan == null) { return; } if (IsInsideAnyActiveZone(((Component)localPlayer).transform.position)) { if (!sEMan.HaveStatusEffect(SE_AegisDome.EffectHash)) { EnsureStatusEffectInObjectDB(); if ((Object)(object)SE_AegisDome.Instance != (Object)null) { sEMan.AddStatusEffect((StatusEffect)(object)SE_AegisDome.Instance, false, 0, 0f, (short)(-1)); } else { sEMan.AddStatusEffect(SE_AegisDome.EffectHash, false, 0, 0f, (short)(-1)); } } } else if (sEMan.HaveStatusEffect(SE_AegisDome.EffectHash)) { sEMan.RemoveStatusEffect(SE_AegisDome.EffectHash, false); } } public static void RefreshAllPins() { //IL_002b: 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) if ((Object)(object)Minimap.instance == (Object)null) { return; } foreach (KeyValuePair<ZDOID, SafeZoneData> s_activeZone in s_activeZones) { EnsurePin(s_activeZone.Key, s_activeZone.Value.StonePosition); } } private static void DrainFuelStep(float deltaSeconds) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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) if (s_activeZones.Count == 0) { return; } bool flag = false; foreach (SafeZoneData value in s_activeZones.Values) { if (!value.IsActive || value.IsNoCost || value.Fuel <= 0f) { continue; } ZDO val = ((ZDOMan.instance != null && !((ZDOID)(ref value.StoneZDOID)).IsNone()) ? ZDOMan.instance.GetZDO(value.StoneZDOID) : null); if (val == null || !val.IsValid()) { continue; } if (val.IsOwner() || ((Object)(object)ZNet.instance != (Object)null && (ZNet.instance.IsServer() || !val.HasOwner()))) { float num = AegisDomeStone.CalculateFuelRate(value.Area); value.Fuel = Mathf.Max(0f, value.Fuel - num * deltaSeconds); if (value.Fuel <= 0f) { value.IsActive = false; flag = true; UpdateVisualState(value); PlaySFX("sfx_charred_death", value.StonePosition); } val.Set(AegisDomeStone.HashFuel, value.Fuel); val.Set(AegisDomeStone.HashActive, value.IsActive); continue; } value.Fuel = val.GetFloat(AegisDomeStone.HashFuel, value.Fuel); value.IsNoCost = val.GetBool(AegisDomeStone.HashNoCost, value.IsNoCost); bool flag2 = (value.IsNoCost || value.Fuel > 0f) && val.GetBool(AegisDomeStone.HashActive, value.IsActive); if (value.IsActive != flag2) { bool isActive = value.IsActive; value.IsActive = flag2; flag = true; UpdateVisualState(value); if (isActive && !flag2) { PlaySFX("sfx_charred_death", value.StonePosition); } } } if (flag) { RecalculateGlobalBounds(); } } public static string PolygonToString(Vector2[] points) { if (points == null || points.Length < 3) { return ""; } StringBuilder stringBuilder = new StringBuilder(points.Length * 22); for (int i = 0; i < points.Length; i++) { if (i > 0) { stringBuilder.Append(';'); } stringBuilder.Append(points[i].x.ToString("F2", CultureInfo.InvariantCulture)); stringBuilder.Append(','); stringBuilder.Append(points[i].y.ToString("F2", CultureInfo.InvariantCulture)); } return stringBuilder.ToString(); } public static Vector2[] ParsePolygonString(string str) { //IL_0089: 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) if (string.IsNullOrEmpty(str)) { return null; } try { string[] array = str.Split(';'); if (array.Length < 3) { return null; } Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length]; for (int i = 0; i < array.Length; i++) { string[] array3 = array[i].Split(','); if (array3.Length != 2) { return null; } float num = float.Parse(array3[0], CultureInfo.InvariantCulture); float num2 = float.Parse(array3[1], CultureInfo.InvariantCulture); array2[i] = new Vector2(num, num2); } return array2; } catch { return null; } } public static Rect MakeBounds(Vector2[] polygonXZ) { //IL_00e5: 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_00ee: Unknown result type (might be due to invalid IL or missing references) float num = float.MaxValue; float num2 = float.MinValue; float num3 = float.MaxValue; float num4 = float.MinValue; for (int i = 0; i < polygonXZ.Length; i++) { if (polygonXZ[i].x < num) { num = polygonXZ[i].x; } if (polygonXZ[i].x > num2) { num2 = polygonXZ[i].x; } if (polygonXZ[i].y < num3) { num3 = polygonXZ[i].y; } if (polygonXZ[i].y > num4) { num4 = polygonXZ[i].y; } } return Rect.MinMaxRect(num - 1f, num3 - 1f, num2 + 1f, num4 + 1f); } public static void LogThrottled(string message) { if (Time.time - s_logTimer < 3f) { return; } s_logTimer = Time.time; try { AegisDomePlugin.Log.LogInfo((object)message); } catch { } } public static void EnsurePin(ZDOID zdoid, Vector3 stonePos) { //IL_0023: 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_0051: 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)Minimap.instance == (Object)null) && !((ZDOID)(ref zdoid)).IsNone() && s_activeZones.TryGetValue(zdoid, out var value) && value.MapPin == null) { value.MapPin = Minimap.instance.AddPin(stonePos, (PinType)8, "AegisDome", false, false, 0L, default(PlatformUserID)); if (value.MapPin != null) { value.MapPin.m_icon = AegisDomePlugin.RunestonePinSprite; } } } public static bool HasZone(ZDOID zdoid) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return s_activeZones.ContainsKey(zdoid); } public static void RegisterZone(ZDOID zdoid, Vector3 stonePos, Vector2[] polygonXZ, float area, float fuel, bool isActive, bool isNoCost = false) { //IL_0023: 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_00c2: 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) //IL_00c9: 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_00d8: 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_011c: 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_0043: 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_013e: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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) if (polygonXZ == null || polygonXZ.Length < 3) { UnregisterZone(zdoid); return; } if (s_activeZones.TryGetValue(zdoid, out var value)) { bool flag = value.PolygonXZ != polygonXZ; value.StonePosition = stonePos; value.PolygonXZ = polygonXZ; if (flag) { value.BoundingBox = MakeBounds(polygonXZ); } value.Area = area; value.Fuel = fuel; value.IsNoCost = isNoCost; value.IsActive = isActive; UpdateVisualState(value); if (value.MapPin == null && (Object)(object)Minimap.instance != (Object)null) { EnsurePin(zdoid, stonePos); } RecalculateGlobalBounds(); return; } SafeZoneData safeZoneData = new SafeZoneData { StoneZDOID = zdoid, StonePosition = stonePos, PolygonXZ = polygonXZ, BoundingBox = MakeBounds(polygonXZ), Area = area, Fuel = fuel, IsNoCost = isNoCost, IsActive = isActive, IsVisibleOnMap = true, MapPin = null, VisualObject = null }; s_activeZones[zdoid] = safeZoneData; UpdateVisualState(safeZoneData); if ((Object)(object)Minimap.instance != (Object)null) { EnsurePin(zdoid, stonePos); } RecalculateGlobalBounds(); } private static void UpdateVisualState(SafeZoneData data) { //IL_0058: 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_0071: Expected O, but got Unknown //IL_007c: 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) if (data.PolygonXZ == null || data.PolygonXZ.Length < 3) { if ((Object)(object)data.VisualObject != (Object)null) { data.VisualObject.SetActive(false); } return; } if ((Object)(object)data.VisualObject == (Object)null) { data.VisualObject = new GameObject($"AegisDome_Visual_{data.StoneZDOID}"); data.VisualObject.transform.position = Vector3.zero; } data.VisualObject.SetActive(true); AegisDomeWorldVisual aegisDomeWorldVisual = data.VisualObject.GetComponent<AegisDomeWorldVisual>() ?? data.VisualObject.AddComponent<AegisDomeWorldVisual>(); aegisDomeWorldVisual.Setup(data.PolygonXZ, data.BoundingBox, data.IsActive); } public static void UpdateAllVisualEffects() { foreach (SafeZoneData value in s_activeZones.Values) { if (!((Object)(object)value.VisualObject != (Object)null)) { continue; } MeshRenderer component = value.VisualObject.GetComponent<MeshRenderer>(); if ((Object)(object)component != (Object)null) { ((Renderer)component).enabled = AegisDomePlugin.VisualEffectsEnabled; } ParticleSystem component2 = value.VisualObject.GetComponent<ParticleSystem>(); if ((Object)(object)component2 != (Object)null) { if (AegisDomePlugin.VisualEffectsEnabled) { component2.Play(); } else { component2.Stop(true, (ParticleSystemStopBehavior)0); } } } } public static bool SetNoCostNear(Vector3 playerPos, bool enableInfinite) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00f5: 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) AegisDomeStone[] array = Object.FindObjectsByType<AegisDomeStone>((FindObjectsSortMode)0); AegisDomeStone aegisDomeStone = null; float num = float.MaxValue; AegisDomeStone[] array2 = array; foreach (AegisDomeStone aegisDomeStone2 in array2) { float num2 = Vector3.Distance(playerPos, ((Component)aegisDomeStone2).transform.position); if (num2 < num) { num = num2; aegisDomeStone = aegisDomeStone2; } } if ((Object)(object)aegisDomeStone != (Object)null) { aegisDomeStone.SetNoCost(enableInfinite); RecalculateGlobalBounds(); return true; } ZDOID val = ZDOID.None; num = float.MaxValue; foreach (KeyValuePair<ZDOID, SafeZoneData> s_activeZone in s_activeZones) { float num3 = Vector3.Distance(playerPos, s_activeZone.Value.StonePosition); if (num3 < num) { num = num3; val = s_activeZone.Key; } } if (!((ZDOID)(ref val)).IsNone() && s_activeZones.TryGetValue(val, out var value)) { value.IsNoCost = enableInfinite; if (enableInfinite && value.PolygonXZ != null && value.PolygonXZ.Length >= 3) { value.IsActive = true; UpdateVisualState(value); } if (ZDOMan.instance != null) { ZDO zDO = ZDOMan.instance.GetZDO(val); if (zDO != null && zDO.IsValid()) { if (!zDO.IsOwner()) { zDO.SetOwner(ZDOMan.GetSessionID()); } zDO.Set(AegisDomeStone.HashNoCost, enableInfinite); if (enableInfinite) { zDO.Set(AegisDomeStone.HashActive, true); } } } RecalculateGlobalBounds(); return true; } return false; } public static int SetNoCostAll(bool enableInfinite) { //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_00cd: Unknown result type (might be due to invalid IL or missing references) int num = 0; AegisDomeStone[] array = Object.FindObjectsByType<AegisDomeStone>((FindObjectsSortMode)0); AegisDomeStone[] array2 = array; foreach (AegisDomeStone aegisDomeStone in array2) { aegisDomeStone.SetNoCost(enableInfinite); num++; } foreach (KeyValuePair<ZDOID, SafeZoneData> s_activeZone in s_activeZones) { s_activeZone.Value.IsNoCost = enableInfinite; if (enableInfinite && s_activeZone.Value.PolygonXZ != null && s_activeZone.Value.PolygonXZ.Length >= 3) { s_activeZone.Value.IsActive = true; UpdateVisualState(s_activeZone.Value); } if (ZDOMan.instance != null) { ZDOID key = s_activeZone.Key; if (!((ZDOID)(ref key)).IsNone()) { ZDO zDO = ZDOMan.instance.GetZDO(s_activeZone.Key); if (zDO != null && zDO.IsValid()) { if (!zDO.IsOwner()) { zDO.SetOwner(ZDOMan.GetSessionID()); } zDO.Set(AegisDomeStone.HashNoCost, enableInfinite); if (enableInfinite) { zDO.Set(AegisDomeStone.HashActive, true); } } } } num++; } RecalculateGlobalBounds(); return num; } public static void UnregisterZone(ZDOID zdoid) { //IL_0006: 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) if (s_activeZones.TryGetValue(zdoid, out var value)) { if (value.MapPin != null && (Object)(object)Minimap.instance != (Object)null) { Minimap.instance.RemovePin(value.MapPin); value.MapPin = null; } if ((Object)(object)value.VisualObject != (Object)null) { Object.Destroy((Object)(object)value.VisualObject); value.VisualObject = null; } s_activeZones.Remove(zdoid); RecalculateGlobalBounds(); } } public static void ClearAllZones() { if ((Object)(object)Minimap.instance != (Object)null) { foreach (KeyValuePair<ZDOID, SafeZoneData> s_activeZone in s_activeZones) { if (s_activeZone.Value.MapPin != null) { Minimap.instance.RemovePin(s_activeZone.Value.MapPin); s_activeZone.Value.MapPin = null; } } } foreach (KeyValuePair<ZDOID, SafeZoneData> s_activeZone2 in s_activeZones) { if ((Object)(object)s_activeZone2.Value.VisualObject != (Object)null) { Object.Destroy((Object)(object)s_activeZone2.Value.VisualObject); } } s_activeZones.Clear(); s_hasActiveBounds = false; } public static void SetZoneVisibility(ZDOID zdoid, bool visible) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (s_activeZones.TryGetValue(zdoid, out var value)) { value.IsVisibleOnMap = visible; } } public static bool IsInsideAnyActiveZone(Vector3 worldPos, out SafeZoneData foundZone) { //IL_0028: 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) //IL_0039: 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_005d: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) foundZone = null; if (!s_hasActiveBounds || s_activeZones.Count == 0) { return false; } Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(worldPos.x, worldPos.z); if (val.x < ((Rect)(ref s_globalActiveBounds)).xMin || val.x > ((Rect)(ref s_globalActiveBounds)).xMax || val.y < ((Rect)(ref s_globalActiveBounds)).yMin || val.y > ((Rect)(ref s_globalActiveBounds)).yMax) { return false; } foreach (SafeZoneData value in s_activeZones.Values) { if (!value.IsActive || !((Rect)(ref value.BoundingBox)).Contains(val) || !SafeZoneGeometry.IsPointInPolygon(val, value.PolygonXZ)) { continue; } foundZone = value; return true; } return false; } public static bool IsInsideAnyActiveZone(Vector3 worldPos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) SafeZoneData foundZone; return IsInsideAnyActiveZone(worldPos, out foundZone); } public static bool IsHostileFaction(Faction faction) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 return (int)faction == 2 || (int)faction == 3 || (int)faction == 4 || (int)faction == 7 || (int)faction == 5 || (int)faction == 13 || (int)faction == 6 || (int)faction == 9 || (int)faction == 8; } public static bool IsHostileCharacter(Character c) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)c == (Object)null || c.IsDead() || c.IsPlayer() || c.IsTamed()) { return false; } BaseAI baseAI = c.GetBaseAI(); if ((Object)(object)baseAI == (Object)null) { return false; } if (baseAI is AnimalAI) { return false; } if (baseAI is MonsterAI) { return true; } return IsHostileFaction(c.GetFaction()); } public static void AddFuelToZone(SafeZoneData zone, float amount) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (zone == null || ((ZDOID)(ref zone.StoneZDOID)).IsNone()) { return; } zone.Fuel += amount; if (ZDOMan.instance == null) { return; } ZDO zDO = ZDOMan.instance.GetZDO(zone.StoneZDOID); if (zDO != null && zDO.IsValid()) { if (!zDO.IsOwner()) { zDO.SetOwner(ZDOMan.GetSessionID()); } float num = zDO.GetFloat(AegisDomeStone.HashFuel, zone.Fuel); float num2 = num + amount; zDO.Set(AegisDomeStone.HashFuel, num2); zone.Fuel = num2; if (!zone.IsActive && (zone.IsNoCost || num2 > 0f)) { zone.IsActive = true; zDO.Set(AegisDomeStone.HashActive, true); UpdateVisualState(zone); RecalculateGlobalBounds(); } } } public static bool TryDespawnHostileCharacter(Character c) { //IL_002a: 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_007c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)c == (Object)null || !IsHostileCharacter(c)) { return false; } if (!IsInsideAnyActiveZone(((Component)c).transform.position, out var foundZone)) { return false; } if (IsBoss(c)) { HandleBossInvasion(c, foundZone); return false; } Vector3 position = ((Component)c).transform.position; if (AegisDomePlugin.VisualEffectsEnabled) { SpawnVFX(position); } AddFuelToZone(foundZone, 1800f); CharacterDrop component = ((Component)c).GetComponent<CharacterDrop>(); if ((Object)(object)component != (Object)null) { component.m_drops.Clear(); ((Behaviour)component).enabled = false; } c.m_defeatSetGlobalKey = ""; ZNetView component2 = ((Component)c).GetComponent<ZNetView>(); if ((Object)(object)component2 != (Object)null && component2.IsValid()) { component2.ClaimOwnership(); ZNetScene instance = ZNetScene.instance; if (instance != null) { instance.Destroy(((Component)c).gameObject); } } else { Object.Destroy((Object)(object)((Component)c).gameObject); } return true; } private static void UpdateHostileDespawn() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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) //IL_0094: 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_00ba: Unknown result type (might be due to invalid IL or missing references) if (!s_hasActiveBounds || s_activeZones.Count == 0) { return; } List<Character> allCharacters = Character.GetAllCharacters(); if (allCharacters == null || allCharacters.Count == 0) { return; } for (int num = allCharacters.Count - 1; num >= 0; num--) { Character val = allCharacters[num]; if (!((Object)(object)val == (Object)null) && !val.IsDead()) { Vector3 position = ((Component)val).transform.position; if (!(position.x < ((Rect)(ref s_globalActiveBounds)).xMin) && !(position.x > ((Rect)(ref s_globalActiveBounds)).xMax) && !(position.z < ((Rect)(ref s_globalActiveBounds)).yMin) && !(position.z > ((Rect)(ref s_globalActiveBounds)).yMax)) { TryDespawnHostileCharacter(val); } } } } public static Dictionary<ZDOID, SafeZoneData> GetAllZones() { return s_activeZones; } } public class AegisDomeStone : MonoBehaviour, Hoverable, Interactable { private ZNetView m_nview; private ZDOID m_zdoid = ZDOID.None; private float m_fuelAmount = 7200f; private float m_polygonArea = 0f; private Vector2[] m_polygonXZ; private string m_cachedPolyStr = ""; private bool m_isActive = false; private bool m_isNoCost = false; private bool m_isPieceDestroyed = false; private float m_lastSyncedFuel = -999f; private bool m_lastSyncedActive = false; private bool m_lastSyncedNoCost = false; private float m_lastHoverUpdate = -1f; private string m_cachedHoverText = ""; public static readonly int HashFuel = StringExtensionMethods.GetStableHashCode("AegisDome_Fuel"); public static readonly int HashArea = StringExtensionMethods.GetStableHashCode("AegisDome_Area"); public static readonly int HashPolyStr = StringExtensionMethods.GetStableHashCode("AegisDome_PolyStr"); public static readonly int HashActive = StringExtensionMethods.GetStableHashCode("AegisDome_Active"); public static readonly int HashNoCost = StringExtensionMethods.GetStableHashCode("AegisDome_NoCost"); private void Awake() { //IL_0047: 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) m_nview = ((Component)this).GetComponent<ZNetView>() ?? ((Component)this).GetComponentInParent<ZNetView>(); if ((Object)(object)m_nview != (Object)null && m_nview.GetZDO() != null) { m_zdoid = m_nview.GetZDO().m_uid; } WearNTear component = ((Component)this).GetComponent<WearNTear>(); if ((Object)(object)component != (Object)null) { component.m_onDestroyed = (Action)Delegate.Combine(component.m_onDestroyed, new Action(OnPieceDestroyed)); } } private void OnPieceDestroyed() { m_isPieceDestroyed = true; CleanupStone(pieceBrokenPermanently: true); } private void OnDestroy() { ((MonoBehaviour)this).CancelInvoke(); WearNTear component = ((Component)this).GetComponent<WearNTear>(); if ((Object)(object)component != (Object)null) { component.m_onDestroyed = (Action)Delegate.Remove(component.m_onDestroyed, new Action(OnPieceDestroyed)); } CleanupStone(m_isPieceDestroyed); } private void CleanupStone(bool pieceBrokenPermanently) { //IL_005b: 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) if ((Object)(object)AegisDomeMapEditor.ActiveStone == (Object)(object)this) { AegisDomeMapEditor.CloseEditor(closeLargeMap: true); } if (pieceBrokenPermanently && !((ZDOID)(ref m_zdoid)).IsNone()) { ZNetView nview = m_nview; ZDO val = ((nview != null) ? nview.GetZDO() : null) ?? ((ZDOMan.instance != null) ? ZDOMan.instance.GetZDO(m_zdoid) : null); if (val != null && val.IsValid()) { val.Set(HashPolyStr, ""); val.Set(HashActive, false); val.Set(HashFuel, 0f); val.Set(HashNoCost, false); } SafeZoneManager.UnregisterZone(m_zdoid); } } private void Start() { //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) if (((ZDOID)(ref m_zdoid)).IsNone() && (Object)(object)m_nview != (Object)null && m_nview.GetZDO() != null) { m_zdoid = m_nview.GetZDO().m_uid; } ZNetView nview = m_nview; ZDO val = ((nview != nul