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 LeviathanHall v0.1.1
LeviathanHall.dll
Decompiled 4 hours 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.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using Advize_PlantEasily; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: IgnoresAccessChecksTo("Advize_PlantEasily")] [assembly: IgnoresAccessChecksTo("assembly_googleanalytics")] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_lux")] [assembly: IgnoresAccessChecksTo("assembly_postprocessing")] [assembly: IgnoresAccessChecksTo("assembly_simplemeshcombine")] [assembly: IgnoresAccessChecksTo("assembly_sunshafts")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: AssemblyCompany("LeviathanHall")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.1.0")] [assembly: AssemblyInformationalVersion("0.1.1")] [assembly: AssemblyProduct("LeviathanHall")] [assembly: AssemblyTitle("LeviathanHall")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.1.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 LeviathanHall { internal static class BindingHorn { internal const string PrefabName = "LH_binding_horn"; private const string CloneFrom = "Wishbone"; private const string BoundKey = "LH_leviathan"; private const float BindRange = 60f; internal static void Register() { PrefabManager.OnVanillaPrefabsAvailable += Create; } private static void Create() { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) PrefabManager.OnVanillaPrefabsAvailable -= Create; try { GameObject val = PrefabManager.Instance.CreateClonedPrefab("LH_binding_horn", "Wishbone"); if ((Object)(object)val == (Object)null) { Plugin.Log.LogError((object)"Could not clone 'Wishbone' — binding horn not registered."); return; } ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null) { SharedData shared = component.m_itemData.m_shared; shared.m_itemType = (ItemType)18; shared.m_maxStackSize = 1; shared.m_equipDuration = 0.5f; shared.m_equipStatusEffect = null; AdoptCelebrationHornArt(shared); } ItemConfig val2 = new ItemConfig(); val2.Name = "Binding Horn"; val2.Description = "Carved from leviathan chitin. Press it to a willing beast's back and it will answer you."; val2.CraftingStation = CraftingStations.Workbench; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig { Item = "Chitin", Amount = 10, AmountPerLevel = 5 } }; CustomItem val3 = new CustomItem(val, false, val2); ItemManager.Instance.AddItem(val3); Plugin.Log.LogInfo((object)"Registered item 'LH_binding_horn'."); } catch (Exception arg) { Plugin.Log.LogError((object)string.Format("Failed registering {0}: {1}", "LH_binding_horn", arg)); } } private static void AdoptCelebrationHornArt(SharedData sh) { LogHornLikePrefabs(); ItemDrop val = FindHornOfCelebration(); if ((Object)(object)val == (Object)null || val.m_itemData.m_shared.m_icons == null || val.m_itemData.m_shared.m_icons.Length == 0) { Plugin.Log.LogWarning((object)"Horn art: Horn of Celebration not found — keeping the Wishbone icon."); return; } sh.m_icons = val.m_itemData.m_shared.m_icons; Plugin.Log.LogInfo((object)("Horn art: using the icon from '" + ((Object)val).name + "'.")); } private static ItemDrop FindHornOfCelebration() { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Invalid comparison between Unknown and I4 ItemDrop[] array = Resources.FindObjectsOfTypeAll<ItemDrop>(); foreach (ItemDrop val in array) { if (!((Object)(object)val == (Object)null) && val.m_itemData != null && val.m_itemData.m_shared != null) { string text = (((Object)val).name ?? "").ToLowerInvariant(); string text2 = val.m_itemData.m_shared.m_name ?? ""; string text3 = ((Localization.instance != null) ? Localization.instance.Localize(text2) : text2).ToLowerInvariant(); text2 = text2.ToLowerInvariant(); bool flag = text.Contains("horn") || text2.Contains("horn") || text3.Contains("horn"); bool flag2 = text.Contains("celebr") || text2.Contains("celebr") || text3.Contains("celebr"); bool flag3 = (int)val.m_itemData.m_shared.m_itemType == 6; if (flag && flag2 && !flag3) { Plugin.Log.LogInfo((object)("Horn art: matched '" + ((Object)val).name + "' ('" + text3 + "').")); return val; } } } return null; } private static void LogHornLikePrefabs() { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) ItemDrop[] array = Resources.FindObjectsOfTypeAll<ItemDrop>(); foreach (ItemDrop val in array) { if (!((Object)(object)val == (Object)null) && val.m_itemData != null && val.m_itemData.m_shared != null) { string text = ((Object)val).name ?? ""; string text2 = val.m_itemData.m_shared.m_name ?? ""; string text3 = ((Localization.instance != null) ? Localization.instance.Localize(text2) : text2); if (text.ToLowerInvariant().Contains("horn") || text3.ToLowerInvariant().Contains("horn")) { Plugin.Log.LogInfo((object)$"Horn art: candidate -> prefab '{text}' type={val.m_itemData.m_shared.m_itemType} name '{text3}'"); } } } } internal static bool IsHorn(ItemData item) { return item != null && (Object)(object)item.m_dropPrefab != (Object)null && Utils.GetPrefabName(item.m_dropPrefab) == "LH_binding_horn"; } internal static string GetBoundId(ItemData item) { if (item == null || item.m_customData == null) { return null; } string value; return (item.m_customData.TryGetValue("LH_leviathan", out value) && !string.IsNullOrEmpty(value)) ? value : null; } internal static void SetBoundId(ItemData item, string id) { if (item != null) { if (item.m_customData == null) { item.m_customData = new Dictionary<string, string>(); } item.m_customData["LH_leviathan"] = id ?? ""; } } internal static Leviathan FindLoaded(string hallId) { if (string.IsNullOrEmpty(hallId)) { return null; } Leviathan[] array = Object.FindObjectsByType<Leviathan>((FindObjectsSortMode)0); foreach (Leviathan val in array) { ZDO val2 = (((Object)(object)val.m_nview != (Object)null) ? val.m_nview.GetZDO() : null); if (val2 != null && Hall.GetId(val2) == hallId) { return val; } } return null; } internal static Leviathan SettledLeviathanUnderfoot(Player player) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return null; } Leviathan val = LeviathanAnchor.FindNearest(((Component)player).transform.position, 60f); if ((Object)(object)val == (Object)null || !LeviathanAnchor.IsAnchored(val)) { return null; } return val; } internal static bool IsBoundTo(ItemData horn, Leviathan lev) { if (horn == null || (Object)(object)lev == (Object)null) { return false; } ZDO val = (((Object)(object)lev.m_nview != (Object)null) ? lev.m_nview.GetZDO() : null); if (val == null) { return false; } string boundId = GetBoundId(horn); string id = Hall.GetId(val); return !string.IsNullOrEmpty(boundId) && boundId == id; } internal static void BindTo(Player player, ItemData horn, Leviathan lev) { if ((Object)(object)player == (Object)null || horn == null || (Object)(object)lev == (Object)null) { return; } ZDO val = (((Object)(object)lev.m_nview != (Object)null) ? lev.m_nview.GetZDO() : null); if (val == null) { Say("That leviathan is not settled enough to bind."); return; } string newId = Hall.EnsureId(val); string text = GetBoundId(horn); if (text == newId) { Plugin.Debug("Horn re-bound to the same leviathan; nothing to do."); return; } if (!string.IsNullOrEmpty(text) && !IsHallId(text)) { Plugin.Log.LogInfo((object)("Discarding legacy binding '" + text + "'.")); text = null; } if (!string.IsNullOrEmpty(text)) { Confirm("Rebind the horn?", "This horn already answers to another leviathan. Binding it here will forget the old one.", delegate { SetBoundId(horn, newId); HallRpc.RequestClaim(newId); Say("The horn answers to this leviathan now."); }); } else { SetBoundId(horn, newId); HallRpc.RequestClaim(newId); Say("The horn is bound. This leviathan will answer it."); } } private static bool IsHallId(string id) { if (string.IsNullOrEmpty(id) || id.Length != 32) { return false; } foreach (char c in id) { if ((c < '0' || c > '9') && (c < 'a' || c > 'f') && (c < 'A' || c > 'F')) { return false; } } return true; } internal static void Say(string msg) { MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)2, msg, 0, (Sprite)null, false, true); } } internal static void Confirm(string header, string body, Action onYes, Action onNo = null) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0040: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown if (UnifiedPopup.IsAvailable()) { UnifiedPopup.Push((PopupBase)new YesNoPopup(header, body, (PopupButtonCallback)delegate { UnifiedPopup.Pop(); onYes?.Invoke(); }, (PopupButtonCallback)delegate { UnifiedPopup.Pop(); onNo?.Invoke(); }, true, false)); } else { Say("Cannot ask right now — try again in a moment."); } } } internal static class Catalogue { private static readonly Type[] Interesting = new Type[20] { typeof(Piece), typeof(ItemDrop), typeof(Plant), typeof(Pickable), typeof(Container), typeof(Fireplace), typeof(CookingStation), typeof(CraftingStation), typeof(WearNTear), typeof(StaticPhysics), typeof(SnapToGround), typeof(EffectArea), typeof(TeleportWorld), typeof(Character), typeof(Tameable), typeof(Vagon), typeof(Destructible), typeof(Floating), typeof(TerrainOp), typeof(TerrainModifier) }; internal static string Write() { ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null || instance.m_prefabs == null) { throw new InvalidOperationException("No ZNetScene — load a world first."); } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Leviathan Hall — catalogue of the running game"); stringBuilder.AppendLine($"written {DateTime.Now:yyyy-MM-dd HH:mm}"); stringBuilder.AppendLine(); List<GameObject> list = new List<GameObject>(instance.m_prefabs); list.Sort((GameObject a, GameObject b) => string.CompareOrdinal(((Object)(object)a != (Object)null) ? ((Object)a).name : "", ((Object)(object)b != (Object)null) ? ((Object)b).name : "")); Prefabs(stringBuilder, list); ByComponent(stringBuilder, list); Items(stringBuilder, list); Pieces(stringBuilder, list); Clutter(stringBuilder); Shaders(stringBuilder, list); string text = Path.Combine(Paths.ConfigPath, "LeviathanHall-catalogue.txt"); File.WriteAllText(text, stringBuilder.ToString()); return text; } private static void Prefabs(StringBuilder text, List<GameObject> prefabs) { text.AppendLine("================ PREFABS ================"); text.AppendLine($"{prefabs.Count} prefabs, with the components this mod cares about."); text.AppendLine(); foreach (GameObject prefab in prefabs) { if ((Object)(object)prefab == (Object)null) { continue; } List<string> list = new List<string>(); Type[] interesting = Interesting; foreach (Type type in interesting) { if ((Object)(object)prefab.GetComponentInChildren(type, true) != (Object)null) { list.Add(type.Name); } } text.AppendLine((list.Count > 0) ? (((Object)prefab).name + " [" + string.Join(", ", list.ToArray()) + "]") : ((Object)prefab).name); } text.AppendLine(); } private static void ByComponent(StringBuilder text, List<GameObject> prefabs) { text.AppendLine("================ BY COMPONENT ================"); Type[] interesting = Interesting; foreach (Type type in interesting) { List<string> list = new List<string>(); foreach (GameObject prefab in prefabs) { if ((Object)(object)prefab != (Object)null && (Object)(object)prefab.GetComponentInChildren(type, true) != (Object)null) { list.Add(((Object)prefab).name); } } text.AppendLine(); text.AppendLine($"-- {type.Name} ({list.Count}) --"); foreach (string item in list) { text.AppendLine(" " + item); } } text.AppendLine(); } private static void Items(StringBuilder text, List<GameObject> prefabs) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) text.AppendLine("================ ITEMS ================"); foreach (GameObject prefab in prefabs) { if (!((Object)(object)prefab == (Object)null)) { ItemDrop component = prefab.GetComponent<ItemDrop>(); if (!((Object)(object)component == (Object)null) && component.m_itemData != null && component.m_itemData.m_shared != null) { SharedData shared = component.m_itemData.m_shared; text.AppendLine($"{((Object)prefab).name} \"{shared.m_name}\" type={shared.m_itemType} " + $"maxStack={shared.m_maxStackSize}"); } } } text.AppendLine(); } private static void Pieces(StringBuilder text, List<GameObject> prefabs) { text.AppendLine("================ PIECES ================"); foreach (GameObject prefab in prefabs) { if (!((Object)(object)prefab == (Object)null)) { Piece component = prefab.GetComponent<Piece>(); if (!((Object)(object)component == (Object)null)) { text.AppendLine(((Object)prefab).name + " \"" + component.m_name + "\" " + $"groundOnly={component.m_groundOnly} groundPiece={component.m_groundPiece} " + $"cultivatedOnly={component.m_cultivatedGroundOnly} noInWater={component.m_noInWater}"); } } } text.AppendLine(); } private static void Clutter(StringBuilder text) { //IL_014c: Unknown result type (might be due to invalid IL or missing references) text.AppendLine("================ CLUTTER ================"); ClutterSystem instance = ClutterSystem.instance; if ((Object)(object)instance == (Object)null || instance.m_clutter == null) { text.AppendLine("(no ClutterSystem loaded)"); text.AppendLine(); return; } foreach (Clutter item in instance.m_clutter) { if (item != null) { string text2 = item.m_name ?? (((Object)(object)item.m_prefab != (Object)null) ? ((Object)item.m_prefab).name : "?"); string text3 = "no prefab"; if ((Object)(object)item.m_prefab != (Object)null) { InstanceRenderer componentInChildren = item.m_prefab.GetComponentInChildren<InstanceRenderer>(true); text3 = (((Object)(object)componentInChildren != (Object)null) ? ("InstanceRenderer mesh=" + (((Object)(object)componentInChildren.m_mesh != (Object)null) ? ((Object)componentInChildren.m_mesh).name : "none") + " material=" + (((Object)(object)componentInChildren.m_material != (Object)null) ? ((Object)componentInChildren.m_material).name : "none")) : "plain renderer"); } text.AppendLine($"{text2} instanced={item.m_instanced} biome={item.m_biome} {text3}"); } } text.AppendLine(); } private static void Shaders(StringBuilder text, List<GameObject> prefabs) { //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Invalid comparison between Unknown and I4 //IL_01a0: Unknown result type (might be due to invalid IL or missing references) text.AppendLine("================ SHADERS ================"); SortedDictionary<string, Shader> sortedDictionary = new SortedDictionary<string, Shader>(StringComparer.Ordinal); foreach (GameObject prefab in prefabs) { if ((Object)(object)prefab == (Object)null) { continue; } Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if ((Object)(object)val == (Object)null || val.sharedMaterials == null) { continue; } Material[] sharedMaterials = val.sharedMaterials; foreach (Material val2 in sharedMaterials) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.shader == (Object)null) && !sortedDictionary.ContainsKey(((Object)val2.shader).name)) { sortedDictionary[((Object)val2.shader).name] = val2.shader; } } } } foreach (KeyValuePair<string, Shader> item in sortedDictionary) { text.AppendLine(); text.AppendLine("-- " + item.Key + " --"); Shader value = item.Value; int propertyCount = value.GetPropertyCount(); for (int k = 0; k < propertyCount; k++) { ShaderPropertyType propertyType = value.GetPropertyType(k); if ((int)propertyType == 0 || (int)propertyType == 4) { text.AppendLine($" {propertyType} {value.GetPropertyName(k)}"); } } } text.AppendLine(); } } internal class CatalogueCommand : ConsoleCommand { public override string Name => "lh_catalogue"; public override string Help => "lh_catalogue — write everything the game has loaded (prefabs, items, pieces, clutter, shaders) to a file beside the config, so it can be looked up later without playing."; public override bool IsCheat => false; public override void Run(string[] args) { try { string text = Catalogue.Write(); Console.instance.Print("Catalogue written to " + text); Plugin.Log.LogInfo((object)("Catalogue written to " + text)); } catch (Exception ex) { Console.instance.Print("Could not write the catalogue: " + ex.Message); Plugin.Log.LogError((object)$"Catalogue failed: {ex}"); } } } internal static class Commands { internal static void Register() { CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new SummonCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AnchorCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AdoptCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new TameCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new CheckCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new RipenCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new RaceTestCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new RescueCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new DumpCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new CatalogueCommand()); } } internal class SummonCommand : ConsoleCommand { public override string Name => "lh_summon"; public override string Help => "lh_summon [willing] — DEV: surface a leviathan in deep water nearby. Plain spawns an ordinary one that still rolls for willingness; 'willing' forces one that stays."; public override bool IsCheat => true; public override void Run(string[] args) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { Console.instance.Print("No player."); return; } if (!Ocean.TryFindSpot(((Component)localPlayer).transform.position, ((Component)localPlayer).transform.forward, out var spot, out var why)) { Console.instance.Print("<color=orange>" + why + "</color>"); return; } GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab("Leviathan") : null); if ((Object)(object)val == (Object)null) { Console.instance.Print("Leviathan prefab not found."); return; } bool flag = args.Length != 0 && args[0].Equals("willing", StringComparison.OrdinalIgnoreCase); GameObject val2 = Object.Instantiate<GameObject>(val, spot, Quaternion.identity); Leviathan component = val2.GetComponent<Leviathan>(); if ((Object)(object)component != (Object)null && flag) { LeviathanAnchor.SetAnchored(component, anchored: true); } float num = Ocean.DepthAt(spot); float num2 = Vector3.Distance(((Component)localPlayer).transform.position, spot); Console.instance.Print($"Leviathan surfaced {num2:0}m away in {num:0.#}m of water" + (flag ? ", forced willing — it will stay." : ". Mine it and see whether it minds.")); } } internal class AnchorCommand : ConsoleCommand { public override string Name => "lh_anchor"; public override string Help => "lh_anchor [on|off] — anchor or release the nearest leviathan."; public override bool IsCheat => true; public override void Run(string[] args) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { Console.instance.Print("No player."); return; } bool flag = args.Length == 0 || !args[0].Equals("off", StringComparison.OrdinalIgnoreCase); Leviathan val = LeviathanAnchor.FindNearest(((Component)localPlayer).transform.position, 200f); if ((Object)(object)val == (Object)null) { Console.instance.Print("No leviathan within 200m."); } else if (LeviathanAnchor.SetAnchored(val, flag)) { Console.instance.Print(flag ? "Leviathan anchored — it will not leave." : "Leviathan released."); } else { Console.instance.Print("Could not reach that leviathan's data."); } } } internal class AdoptCommand : ConsoleCommand { public override string Name => "lh_adopt"; public override string Help => "lh_adopt [reset] — register everything built on the nearest leviathan so it travels with it. 'reset' forgets the current members first and works it out again. Run while standing on the hall."; public override bool IsCheat => false; public override void Run(string[] args) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { Console.instance.Print("No player."); return; } Leviathan val = LeviathanAnchor.FindNearest(((Component)localPlayer).transform.position, 200f); if ((Object)(object)val == (Object)null) { Console.instance.Print("No leviathan within 200m."); return; } if (!LeviathanAnchor.IsAnchored(val)) { Console.instance.Print("That leviathan has not settled."); return; } bool reset = args.Length != 0 && args[0].Equals("reset", StringComparison.OrdinalIgnoreCase); int num = HallBuild.AdoptLoaded(val, reset); if (num < 0) { Console.instance.Print("<color=orange>Reset refused — nothing could be traced back to the leviathan, so the current members were left exactly as they were.</color>"); return; } if (num == 0) { Console.instance.Print("Nothing attached — a hall starts with a sea foundation laid on the creature's back."); return; } Console.instance.Print($"{num} object(s) now travel with this leviathan."); if (HallBuild.Left > 0) { Console.instance.Print($"<color=orange>{HallBuild.Left} piece(s) are attached to land and will stay behind. " + "Anything bridging the hall to the shore will break where it parts — take it down before calling.</color>"); } } } internal class TameCommand : ConsoleCommand { public override string Name => "lh_tame"; public override string Help => "lh_tame — DEV: settle the leviathan you are standing on immediately, no mining and no roll."; public override bool IsCheat => true; public override void Run(string[] args) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { Console.instance.Print("No player."); return; } Leviathan val = LeviathanAnchor.FindNearest(((Component)localPlayer).transform.position, 60f); if ((Object)(object)val == (Object)null) { Console.instance.Print("<color=orange>No leviathan within 60m — stand on its back first. Use lh_summon willing if there is none nearby.</color>"); } else if (LeviathanAnchor.IsAnchored(val)) { Console.instance.Print("That one has already settled. Equip a Binding Horn on its back to bind it."); } else if (!LeviathanAnchor.SetAnchored(val, anchored: true)) { Console.instance.Print("Could not reach that leviathan's data."); } else { Console.instance.Print("It settles, and stops riding the swell. Equip a Binding Horn on its back to bind it."); } } } internal class CheckCommand : ConsoleCommand { public override string Name => "lh_check"; public override string Help => "lh_check — list every hall member's offset from the leviathan, furthest first. Run before and after a reload to compare."; public override bool IsCheat => false; public override void Run(string[] args) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { Console.instance.Print("No player."); return; } Leviathan val = LeviathanAnchor.FindNearest(((Component)localPlayer).transform.position, 200f); if ((Object)(object)val == (Object)null) { Console.instance.Print("No leviathan within 200m."); return; } ZDO val2 = (((Object)(object)val.m_nview != (Object)null) ? val.m_nview.GetZDO() : null); if (val2 == null) { Console.instance.Print("Could not read that leviathan."); return; } string id = Hall.GetId(val2); if (string.IsNullOrEmpty(id)) { Console.instance.Print("That leviathan has no hall."); return; } Vector3 origin = val2.GetPosition(); List<ZDO> list = Hall.Members(id, val2.m_uid); Console.instance.Print($"Hall {id.Substring(0, 8)} at {origin} — {list.Count} member(s)."); Plugin.Log.LogInfo((object)$"lh_check: hall {id} origin {origin}, {list.Count} members."); list.Sort(delegate(ZDO a, ZDO b) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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) Vector3 val5 = b.GetPosition() - origin; float sqrMagnitude = ((Vector3)(ref val5)).sqrMagnitude; val5 = a.GetPosition() - origin; return sqrMagnitude.CompareTo(((Vector3)(ref val5)).sqrMagnitude); }); int num = 0; foreach (ZDO item in list) { Vector3 val3 = item.GetPosition() - origin; string text = (((Object)(object)ZNetScene.instance != (Object)null) ? Utils.GetPrefabName(ZNetScene.instance.GetPrefab(item.GetPrefab())) : item.GetPrefab().ToString()); GameObject val4 = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(item.GetPrefab()) : null); bool flag = (Object)(object)val4 != (Object)null && (Object)(object)val4.GetComponent<WearNTear>() != (Object)null; string text2 = ""; if (flag && Hall.TryExpected(item, val2, out var pos, out var _)) { float num2 = Vector3.Distance(item.GetPosition(), pos); if (num2 > 0.5f) { text2 = $" <color=orange>record says {num2:0}m away</color>"; } } Plugin.Log.LogInfo((object)$"lh_check: {text} offset {val3} dist {((Vector3)(ref val3)).magnitude:0.0}{text2}"); if (num++ < 12 || text2.Length > 0) { Console.instance.Print($" {((Vector3)(ref val3)).magnitude,6:0.0}m {text}{text2}"); } } if (list.Count > 12) { Console.instance.Print($" ...and {list.Count - 12} nearer. Full list is in the log."); } } } internal static class CropTest { internal static string HallFor(bool mustBeNear, out ZDO host) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) host = null; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { Console.instance.Print("No player."); return null; } Leviathan val = LeviathanAnchor.FindNearest(((Component)localPlayer).transform.position, 200f); if ((Object)(object)val != (Object)null && (Object)(object)val.m_nview != (Object)null) { host = val.m_nview.GetZDO(); string text = ((host != null) ? Hall.GetId(host) : null); if (!string.IsNullOrEmpty(text)) { return text; } } if (mustBeNear) { Console.instance.Print("No hall within 200m. This command works on loaded crops, so stand near it."); return null; } string text2 = BoundHall(); if (string.IsNullOrEmpty(text2)) { Console.instance.Print("No hall within 200m and no bound horn — equip the horn for the hall you mean."); return null; } host = Hall.FindHostZdo(text2); if (host == null) { Console.instance.Print("The horn's hall could not be found in this world."); return null; } return text2; } private static string BoundHall() { Player localPlayer = Player.m_localPlayer; Inventory val = (((Object)(object)localPlayer != (Object)null) ? ((Humanoid)localPlayer).GetInventory() : null); if (val == null) { return null; } foreach (ItemData allItem in val.GetAllItems()) { if (allItem != null && allItem.m_equipped && BindingHorn.IsHorn(allItem)) { string boundId = BindingHorn.GetBoundId(allItem); if (!string.IsNullOrEmpty(boundId)) { return boundId; } } } return null; } internal static List<Plant> Crops(string hall) { List<Plant> list = new List<Plant>(); Plant[] array = Object.FindObjectsByType<Plant>((FindObjectsSortMode)0); foreach (Plant val in array) { if ((Object)(object)val == (Object)null) { continue; } ZNetView component = ((Component)val).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { ZDO zDO = component.GetZDO(); if (zDO != null && !(zDO.GetString("LH_host", "") != hall)) { list.Add(val); } } } return list; } internal static int Ripen(string hall, out int grew) { grew = 0; List<Plant> list = Crops(hall); int num = 0; foreach (Plant item in list) { ZNetView component = ((Component)item).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner()) { num++; if ((Object)(object)item.Grow() != (Object)null) { grew++; } } } return num; } internal static void ReportRipe(string hall, ZDO host) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0089: Unknown result type (might be due to invalid IL or missing references) ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null || host == null) { return; } Vector3 position = host.GetPosition(); int num = 0; foreach (ZDO item in Hall.Members(hall, host.m_uid)) { GameObject prefab = instance.GetPrefab(item.GetPrefab()); if (!((Object)(object)prefab == (Object)null) && !((Object)(object)prefab.GetComponent<Pickable>() == (Object)null)) { float num2 = item.GetPosition().y - position.y; num++; string text = ((num2 > 5f) ? "ok" : "BELOW THE DECK — born mid-animation"); Console.instance.Print($" {Utils.GetPrefabName(prefab)} at {num2:0.0}m above the leviathan — {text}"); Plugin.Log.LogInfo((object)$"racetest: ripe crop {num2:0.0}m above the leviathan — {text}"); } } if (num == 0) { Console.instance.Print(" no ripe crops on the hall."); } } } internal class RipenCommand : ConsoleCommand { public override string Name => "lh_ripen"; public override string Help => "lh_ripen — DEV: make every crop on the nearby hall try to ripen now. Beats skiptime, which drags the whole world clock along."; public override bool IsCheat => true; public override void Run(string[] args) { ZDO host; string text = CropTest.HallFor(mustBeNear: true, out host); if (text != null) { int grew; int num = CropTest.Ripen(text, out grew); Console.instance.Print($"{num} crop(s) asked to ripen, {grew} did."); if (num > grew) { Console.instance.Print("The rest are not ready or not happy — check the log for why."); } } } } internal class RaceTestCommand : ConsoleCommand { public override string Name => "lh_racetest"; public override string Help => "lh_racetest — DEV: call the hall and force a crop to ripen in the middle of the rise, the one window that used to destroy it. Reports pass or fail itself. Stand off the hall; works at any range with a bound horn equipped."; public override bool IsCheat => true; public override void Run(string[] args) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00d6: 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) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { Console.instance.Print("No player."); return; } ZDO host; string hall = CropTest.HallFor(mustBeNear: false, out host); if (hall == null) { return; } int count = CropTest.Crops(hall).Count; Vector3 position = host.GetPosition(); Vector3 pos = position; bool flag = false; for (int i = 0; i < 8; i++) { if (flag) { break; } float num = (float)i * (float)Math.PI / 4f; Vector3 val = position + new Vector3(Mathf.Cos(num), 0f, Mathf.Sin(num)) * 70f; if (Hall.DestinationClear(hall, val, out var _)) { pos = val; flag = true; } } if (!flag) { Console.instance.Print("Nowhere clear within 70m to move it to — every direction is built up."); return; } float num2 = ((Plugin.SinkSeconds != null) ? Plugin.SinkSeconds.Value : 4f); float num3 = ((Plugin.RiseSeconds != null) ? Plugin.RiseSeconds.Value : 9f); Console.instance.Print((count > 0) ? $"Moving the hall 70m; {count} crop(s) will be forced to ripen mid-rise." : "Moving the hall 70m; its crops will be forced to ripen mid-rise once it arrives."); HallRpc.RequestRelocate(hall, pos); Scheduler.After(num2 + num3 * 0.5f, delegate { int grew; int num4 = CropTest.Ripen(hall, out grew); Console.instance.Print((num4 == 0) ? "mid-rise: no crops loaded yet — nothing to force. Try again from closer." : $"mid-rise: {num4} forced, {grew} ripened — expected 0."); Plugin.Log.LogInfo((object)$"racetest: mid-rise {num4} forced, {grew} ripened (expected 0)."); }); Scheduler.After(num2 + num3 + 4f, delegate { CropTest.Ripen(hall, out var grew); ZDO val2 = Hall.FindHostZdo(hall); Console.instance.Print($"after the rise: {grew} ripened. Where they landed:"); CropTest.ReportRipe(hall, (val2 != null) ? val2 : host); }); } } internal class RescueCommand : ConsoleCommand { public override string Name => "lh_rescue"; public override string Help => "lh_rescue — put crops back that are stuck below the deck. Stand near the hall."; public override bool IsCheat => false; public override void Run(string[] args) { //IL_0043: 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_0055: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) ZDO host; string text = CropTest.HallFor(mustBeNear: true, out host); if (text == null) { return; } ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { Console.instance.Print("No scene."); return; } Vector3 position = host.GetPosition(); int num = 0; int num2 = 0; int num3 = 0; foreach (ZDO item in Hall.Members(text, host.m_uid)) { GameObject prefab = instance.GetPrefab(item.GetPrefab()); if (!((Object)(object)prefab == (Object)null) && !((Object)(object)prefab.GetComponent<Pickable>() == (Object)null)) { Vector3 position2 = item.GetPosition(); Vector3 top; if (position2.y - position.y > 5f) { num3++; } else if (!Planter.TryTopAt(position2, out top)) { num2++; Plugin.Log.LogWarning((object)$"lh_rescue: '{Utils.GetPrefabName(prefab)}' at {position2} has no planter above it."); } else { Hall.MoveZdo(item, top + Vector3.up * 0.05f, item.GetRotation()); Hall.RecordOffset(item, host); num++; } } } Console.instance.Print($"{num} crop(s) put back, {num3} already in place" + ((num2 > 0) ? $", {num2} with no planter above them." : ".")); if (num2 > 0) { Console.instance.Print("The stranded ones are logged with their positions — their planter is gone."); } } } internal class DumpCommand : ConsoleCommand { private const int Screenful = 25; private int _shown; public override string Name => "lh_dump"; public override string Help => "lh_dump <what> [filter] — ask the game what it has. clutter | shader | piece | prefab | item | material | effectarea | growth | shield"; public override bool IsCheat => false; public override List<string> CommandOptionList() { return new List<string> { "clutter", "shader", "piece", "prefab", "item", "material", "effectarea", "growth", "shield" }; } private void Line(string text) { Plugin.Log.LogInfo((object)("lh_dump: " + text)); if (_shown < 25) { Console.instance.Print(text); _shown++; } else if (_shown == 25) { Console.instance.Print("… more in the log."); _shown++; } } private static bool Match(string name, string filter) { if (string.IsNullOrEmpty(filter)) { return true; } return !string.IsNullOrEmpty(name) && name.ToLowerInvariant().Contains(filter.ToLowerInvariant()); } public override void Run(string[] args) { _shown = 0; string text = ((args != null && args.Length != 0) ? args[0].ToLowerInvariant() : ""); string filter = ((args != null && args.Length > 1) ? args[1] : null); switch (text) { case "clutter": Clutter(filter); break; case "shader": Shaders(); break; case "piece": Pieces(filter); break; case "prefab": Prefabs(filter); break; case "item": Items(filter); break; case "material": Materials(filter); break; case "effectarea": Areas(); break; case "growth": Growths(); break; case "shield": Shields(); break; default: Console.instance.Print("lh_dump clutter | shader | piece | prefab | item | material | effectarea | growth | shield"); Console.instance.Print("A second word filters by substring, e.g. 'lh_dump prefab carrot'."); break; } } private void Clutter(string filter) { ClutterSystem instance = ClutterSystem.instance; if ((Object)(object)instance == (Object)null || instance.m_clutter == null) { Console.instance.Print("No ClutterSystem — load a world first."); return; } foreach (Clutter item in instance.m_clutter) { if (item == null) { continue; } string text = item.m_name ?? (((Object)(object)item.m_prefab != (Object)null) ? ((Object)item.m_prefab).name : "?"); if (Match(text, filter)) { string arg = "no prefab"; if ((Object)(object)item.m_prefab != (Object)null) { InstanceRenderer componentInChildren = item.m_prefab.GetComponentInChildren<InstanceRenderer>(true); arg = (((Object)(object)componentInChildren != (Object)null) ? ("InstanceRenderer mesh=" + (((Object)(object)componentInChildren.m_mesh != (Object)null) ? ((Object)componentInChildren.m_mesh).name : "none") + " mat=" + (((Object)(object)componentInChildren.m_material != (Object)null) ? ((Object)componentInChildren.m_material).name : "none")) : "plain renderer"); } Line($"clutter '{text}' instanced={item.m_instanced} {arg}"); } } } private void Shaders() { //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_0140: Invalid comparison between Unknown and I4 //IL_0156: Unknown result type (might be due to invalid IL or missing references) int num = 0; Piece[] array = Object.FindObjectsByType<Piece>((FindObjectsSortMode)0); foreach (Piece val in array) { if ((Object)(object)val == (Object)null || !Planter.IsOurs(((Component)val).gameObject)) { continue; } Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren) { if ((Object)(object)val2 == (Object)null || val2.sharedMaterials == null) { continue; } Material[] sharedMaterials = val2.sharedMaterials; foreach (Material val3 in sharedMaterials) { if ((Object)(object)val3 == (Object)null) { continue; } Shader shader = val3.shader; Line("'" + ((Object)val2).name + "' material '" + ((Object)val3).name + "' shader '" + (((Object)(object)shader != (Object)null) ? ((Object)shader).name : "none") + "'"); if ((Object)(object)shader == (Object)null) { continue; } int propertyCount = shader.GetPropertyCount(); for (int l = 0; l < propertyCount; l++) { ShaderPropertyType propertyType = shader.GetPropertyType(l); if ((int)propertyType == 0 || (int)propertyType == 4) { Line($" {propertyType} {shader.GetPropertyName(l)}"); } } } } num++; break; } if (num == 0) { Console.instance.Print("No dirt block loaded nearby — stand next to one."); } } private void Pieces(string filter) { ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null || instance.m_prefabs == null) { Console.instance.Print("No scene."); return; } foreach (GameObject prefab in instance.m_prefabs) { if (!((Object)(object)prefab == (Object)null)) { Piece component = prefab.GetComponent<Piece>(); if (!((Object)(object)component == (Object)null) && (Match(((Object)prefab).name, filter) || Match(component.m_name, filter))) { Line("piece '" + ((Object)prefab).name + "' — \"" + component.m_name + "\""); } } } } private void Prefabs(string filter) { ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null || instance.m_prefabs == null) { Console.instance.Print("No scene."); return; } foreach (GameObject prefab in instance.m_prefabs) { if (!((Object)(object)prefab == (Object)null) && Match(((Object)prefab).name, filter)) { Line("prefab '" + ((Object)prefab).name + "'"); } } } private void Items(string filter) { //IL_011d: Unknown result type (might be due to invalid IL or missing references) ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null || instance.m_prefabs == null) { Console.instance.Print("No scene."); return; } foreach (GameObject prefab in instance.m_prefabs) { if (!((Object)(object)prefab == (Object)null)) { ItemDrop component = prefab.GetComponent<ItemDrop>(); if (!((Object)(object)component == (Object)null) && component.m_itemData != null && component.m_itemData.m_shared != null && (Match(((Object)prefab).name, filter) || Match(component.m_itemData.m_shared.m_name, filter))) { Line("item '" + ((Object)prefab).name + "' — \"" + component.m_itemData.m_shared.m_name + "\" " + $"({component.m_itemData.m_shared.m_itemType})"); } } } } private void Materials(string filter) { if (string.IsNullOrEmpty(filter)) { Console.instance.Print("Give a filter — there are thousands. e.g. 'lh_dump material grass'."); return; } Material[] array = Resources.FindObjectsOfTypeAll<Material>(); foreach (Material val in array) { if (!((Object)(object)val == (Object)null) && Match(((Object)val).name, filter)) { Line("material '" + ((Object)val).name + "' shader '" + (((Object)(object)val.shader != (Object)null) ? ((Object)val.shader).name : "none") + "'"); } } } private void Shields() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_025b: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; Vector3 val = (((Object)(object)localPlayer != (Object)null) ? ((Component)localPlayer).transform.position : Vector3.zero); ShieldGenerator[] array = Object.FindObjectsByType<ShieldGenerator>((FindObjectsSortMode)0); Line($"{array.Length} shield generator(s) loaded."); ShieldGenerator[] array2 = array; foreach (ShieldGenerator val2 in array2) { if ((Object)(object)val2 == (Object)null) { continue; } Vector3 position = ((Component)val2).transform.position; Vector3 val3 = (((Object)(object)val2.m_shieldDome != (Object)null) ? val2.m_shieldDome.transform.position : position); float num = Vector3.Distance(position, val3); Line($" generator at {position}"); Line(string.Format(" dome at {0} — drift {1:0.0}m {2}", val3, num, (num < 0.5f) ? "(ok)" : "(THE BUBBLE IS NOT ON ITS GENERATOR)")); Line($" radius {val2.m_radius:0.0}, fuel {val2.GetFuel():0}/{val2.m_maxFuel}"); Line($" you are {Vector3.Distance(val3, val):0.0}m from the dome centre"); if (!((Object)(object)val2.m_shieldDome != (Object)null)) { continue; } GameObject shieldDome = val2.m_shieldDome; Renderer[] componentsInChildren = shieldDome.GetComponentsInChildren<Renderer>(true); int num2 = 0; Renderer[] array3 = componentsInChildren; foreach (Renderer val4 in array3) { if ((Object)(object)val4 != (Object)null && val4.enabled) { num2++; } } Line($" dome object '{((Object)shieldDome).name}' active={shieldDome.activeInHierarchy} " + "parent='" + (((Object)(object)shieldDome.transform.parent != (Object)null) ? ((Object)shieldDome.transform.parent).name : "NONE — it is a root object") + "'"); Line($" scale {shieldDome.transform.lossyScale.x:0.0} — {componentsInChildren.Length} renderer(s), {num2} enabled"); } Line(ShieldGenerator.IsInsideShield(val) ? "The game says you ARE inside a shield." : "The game says you are NOT inside a shield."); } private void Growths() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { Console.instance.Print("No player."); return; } Leviathan val = LeviathanAnchor.FindNearest(((Component)localPlayer).transform.position, 200f); if ((Object)(object)val == (Object)null) { Console.instance.Print("No leviathan within 200m."); return; } List<GameObject> list = Growth.Trees(val); ZDO zdo = (((Object)(object)val.m_nview != (Object)null) ? val.m_nview.GetZDO() : null); HashSet<int> hashSet = Growth.Cleared(zdo); Line($"{list.Count} piece(s) of growth matched; {hashSet.Count} already cleared."); for (int i = 0; i < list.Count; i++) { Line(string.Format(" [{0}] '{1}' {2}", i, ((Object)list[i]).name, hashSet.Contains(i) ? "CLEARED" : "standing")); } Line("-- every direct child of the leviathan --"); Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren<Transform>(true); foreach (Transform val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null && (Object)(object)val2.parent == (Object)(object)((Component)val).transform) { Line(" child '" + ((Object)val2).name + "'"); } } } private void Areas() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; Vector3 val = (((Object)(object)localPlayer != (Object)null) ? ((Component)localPlayer).transform.position : Vector3.zero); Line($"{EffectArea.s_BurningAreas.Count} burning area(s) registered; you are at {val}."); foreach (KeyValuePair<Bounds, EffectArea> s_BurningArea in EffectArea.s_BurningAreas) { Bounds key = s_BurningArea.Key; float num = Vector3.Distance(((Bounds)(ref key)).center, val); if (!(num > 60f)) { key = s_BurningArea.Key; string text = $" burning area centred {((Bounds)(ref key)).center} — {num:0.0}m away, "; key = s_BurningArea.Key; Line(text + $"contains you: {((Bounds)(ref key)).Contains(val)}"); } } } } internal static class Discovery { internal const string DecidedKey = "LH_decided"; internal static bool ResolveWilling(Leviathan lev) { //IL_0065: 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) ZNetView val = (((Object)(object)lev != (Object)null) ? lev.m_nview : null); ZDO val2 = (((Object)(object)val != (Object)null && val.IsValid()) ? val.GetZDO() : null); if (val2 == null) { return false; } if (val2.GetBool("LH_decided", false)) { return val2.GetBool("LH_anchored", false); } bool flag = IsWilling(val2.m_uid); if (val.IsOwner() || !val.HasOwner()) { val.ClaimOwnership(); val2.Set("LH_decided", true); val2.Set("LH_anchored", flag); } Plugin.Log.LogInfo((object)string.Format("Leviathan {0} decided: {1}.", val2.m_uid, flag ? "WILLING — it stays" : "unwilling — it leaves")); if (flag) { Announce(); } return flag; } private unsafe static bool IsWilling(ZDOID uid) { string text = ((object)(*(ZDOID*)(&uid))/*cast due to .constrained prefix*/).ToString(); uint num = 2166136261u; string text2 = text; foreach (char c in text2) { num ^= c; num *= 16777619; } int num2 = Mathf.Clamp(Plugin.WillingChance.Value, 0, 100); return num % 100 < (uint)num2; } private static void Announce() { MessageHud instance = MessageHud.instance; if (!((Object)(object)instance == (Object)null)) { instance.ShowMessage((MessageType)2, "The leviathan shudders beneath you... and settles.", 0, (Sprite)null, false, true); } } } internal static class EffectAreas { internal static int Refresh(GameObject go) { //IL_0054: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Invalid comparison between Unknown and I4 //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)go == (Object)null) { return 0; } int num = 0; EffectArea[] componentsInChildren = go.GetComponentsInChildren<EffectArea>(true); foreach (EffectArea val in componentsInChildren) { if ((Object)(object)val == (Object)null || (Object)(object)val.m_collider == (Object)null) { continue; } if ((val.m_type & 8) != 0 && EffectArea.s_BurningAreas.Remove(val.burnCloseToArea)) { Bounds bounds = val.m_collider.bounds; ((Bounds)(ref bounds)).Expand(new Vector3(0.25f, 0.25f, 0.25f)); val.burnCloseToArea = new KeyValuePair<Bounds, EffectArea>(bounds, val); EffectArea.s_BurningAreas.Add(val.burnCloseToArea); num++; } if ((val.m_type & 0x20) > 0) { if (EffectArea.s_noMonsterAreas.Remove(val.noMonsterArea)) { Bounds bounds2 = val.m_collider.bounds; val.noMonsterArea = new KeyValuePair<Bounds, EffectArea>(bounds2, val); EffectArea.s_noMonsterAreas.Add(val.noMonsterArea); num++; } if (EffectArea.s_noMonsterCloseToAreas.Remove(val.noMonsterCloseToArea)) { Bounds bounds3 = val.m_collider.bounds; ((Bounds)(ref bounds3)).Expand(new Vector3(15f, 15f, 15f)); val.noMonsterCloseToArea = new KeyValuePair<Bounds, EffectArea>(bounds3, val); EffectArea.s_noMonsterCloseToAreas.Add(val.noMonsterCloseToArea); } } } return num; } private static int Unshield(GameObject go) { if ((Object)(object)go == (Object)null) { return 0; } int num = 0; WearNTear[] componentsInChildren = go.GetComponentsInChildren<WearNTear>(true); foreach (WearNTear val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { val.m_shieldChangeID = 0; num++; } } return num; } private static int Recentre(GameObject go) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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 ((Object)(object)go == (Object)null) { return 0; } int num = 0; ShieldGenerator[] componentsInChildren = go.GetComponentsInChildren<ShieldGenerator>(true); foreach (ShieldGenerator val in componentsInChildren) { if ((Object)(object)val == (Object)null || (Object)(object)val.m_shieldDome == (Object)null) { continue; } Vector3 position = ((Component)val).transform.position; if (!(Vector3.Distance(val.m_shieldDome.transform.position, position) < 0.05f)) { val.m_shieldDome.transform.position = position; if (val.m_shieldDome.activeSelf) { val.m_shieldDome.SetActive(false); val.m_shieldDome.SetActive(true); } num++; } } return num; } internal static void RefreshHall(string hallId) { if (string.IsNullOrEmpty(hallId)) { return; } ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { return; } Physics.SyncTransforms(); int num = 0; int num2 = 0; int num3 = 0; foreach (KeyValuePair<ZDO, ZNetView> instance2 in instance.m_instances) { ZDO key = instance2.Key; ZNetView value = instance2.Value; if (key != null && !((Object)(object)value == (Object)null) && value.IsValid() && !(key.GetString("LH_host", "") != hallId)) { num += Refresh(((Component)value).gameObject); num2 += Unshield(((Component)value).gameObject); num3 += Recentre(((Component)value).gameObject); } } if (num > 0) { Plugin.Log.LogInfo((object)$"Re-registered {num} fire/ward area(s) at the new location."); } if (num2 > 0) { Plugin.Debug($"Made {num2} piece(s) re-check whether they are inside a shield."); } if (num3 > 0) { Plugin.Log.LogInfo((object)$"Put {num3} shield dome(s) back over their generator."); } } } internal static class FallPatches { [HarmonyPatch(typeof(SnapToGround), "Snap")] internal static class NoSnapPatch { private static bool Prefix(SnapToGround __instance) { return (Object)(object)__instance == (Object)null || !HallGround.Belongs(((Component)__instance).gameObject); } } [HarmonyPatch(typeof(StaticPhysics), "SUpdate")] internal static class SettlePatch { private static bool Prefix(StaticPhysics __instance) { return !HallGround.Belongs(((Component)__instance).gameObject); } } [HarmonyPatch(typeof(StaticPhysics), "FallUpdate")] internal static class StopFallPatch { private static bool Prefix(StaticPhysics __instance) { if (!HallGround.Belongs(((Component)__instance).gameObject)) { return true; } ((MonoBehaviour)__instance).CancelInvoke("FallUpdate"); __instance.StopFalling(); Plugin.Log.LogInfo((object)("Caught '" + Utils.GetPrefabName(((Component)__instance).gameObject) + "' falling off the hall — stopped it.")); return false; } } } internal static class Growth { internal const string ClearedKey = "LH_cleared"; internal const float Health = 80f; private static bool _described; private static readonly string[] Growthy = new string[10] { "tree", "fir", "pine", "birch", "beech", "oak", "bush", "shrub", "sapling", "stub" }; internal static void Prepare(Leviathan lev) { if ((Object)(object)lev == (Object)null) { return; } ZNetView nview = lev.m_nview; if ((Object)(object)nview == (Object)null || !nview.IsValid()) { return; } List<GameObject> list = Trees(lev); if (list.Count == 0) { return; } HashSet<int> hashSet = Cleared(nview.GetZDO()); for (int i = 0; i < list.Count; i++) { GameObject val = list[i]; if (hashSet.Contains(i)) { if (val.activeSelf) { val.SetActive(false); } continue; } if (!val.activeSelf) { val.SetActive(true); } ClearableTree clearableTree = val.GetComponent<ClearableTree>(); if ((Object)(object)clearableTree == (Object)null) { clearableTree = val.AddComponent<ClearableTree>(); } clearableTree.Bind(lev, i); } } internal static List<GameObject> Trees(Leviathan lev) { List<GameObject> list = new List<GameObject>(); if ((Object)(object)lev == (Object)null) { return list; } Describe(lev); Transform[] componentsInChildren = ((Component)lev).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)(object)((Component)lev).gameObject) { continue; } string text = (((Object)val).name ?? "").ToLowerInvariant(); bool flag = false; string[] growthy = Growthy; foreach (string value in growthy) { if (text.Contains(value)) { flag = true; break; } } if (!flag) { continue; } bool flag2 = false; Transform parent = val.parent; while ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)((Component)lev).transform) { string text2 = (((Object)parent).name ?? "").ToLowerInvariant(); string[] growthy2 = Growthy; foreach (string value2 in growthy2) { if (text2.Contains(value2)) { flag2 = true; break; } } if (flag2) { break; } parent = parent.parent; } if (!flag2) { list.Add(((Component)val).gameObject); } } list.Sort((GameObject a, GameObject b) => string.CompareOrdinal(Path(a.transform), Path(b.transform))); return list; } private static string Path(Transform t) { StringBuilder stringBuilder = new StringBuilder(((Object)t).name); Transform parent = t.parent; while ((Object)(object)parent != (Object)null) { stringBuilder.Insert(0, ((Object)parent).name + "/"); parent = parent.parent; } return stringBuilder.ToString(); } private static void Describe(Leviathan lev) { if (_described) { return; } _described = true; if (Plugin.Verbose == null || !Plugin.Verbose.Value) { return; } Transform[] componentsInChildren = ((Component)lev).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if ((Object)(object)val != (Object)null && (Object)(object)val.parent == (Object)(object)((Component)lev).transform) { Plugin.Log.LogInfo((object)("Leviathan child: '" + ((Object)val).name + "'")); } } } internal static HashSet<int> Cleared(ZDO zdo) { HashSet<int> hashSet = new HashSet<int>(); if (zdo == null) { return hashSet; } string text = zdo.GetString("LH_cleared", ""); if (string.IsNullOrEmpty(text)) { return hashSet; } string[] array = text.Split(new char[1] { ',' }); foreach (string s in array) { if (int.TryParse(s, out var result)) { hashSet.Add(result); } } return hashSet; } internal static void Remember(Leviathan lev, int index) { ZNetView val = (((Object)(object)lev != (Object)null) ? lev.m_nview : null); if ((Object)(object)val == (Object)null || !val.IsValid()) { return; } val.ClaimOwnership(); ZDO zDO = val.GetZDO(); if (zDO == null) { return; } HashSet<int> hashSet = Cleared(zDO); if (!hashSet.Add(index)) { return; } List<int> list = new List<int>(hashSet); list.Sort(); StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < list.Count; i++) { if (i > 0) { stringBuilder.Append(','); } stringBuilder.Append(list[i]); } zDO.Set("LH_cleared", stringBuilder.ToString()); Plugin.Log.LogInfo((object)$"Cleared growth {index} from the leviathan ({list.Count} gone)."); } } internal class ClearableTree : MonoBehaviour, IDestructible, Hoverable { private Leviathan _lev; private int _index = -1; private float _health = 80f; internal void Bind(Leviathan lev, int index) { _lev = lev; _index = index; } public DestructibleType GetDestructibleType() { return (DestructibleType)2; } public void Damage(HitData hit) { if (!((Object)(object)_lev == (Object)null) && _index >= 0 && hit != null) { _health -= hit.GetTotalDamage(); if (!(_health > 0f)) { Growth.Remember(_lev, _index); ((Component)this).gameObject.SetActive(false); } } } public string GetHoverText() { if ((Object)(object)_lev == (Object)null) { return ""; } return Localization.instance.Localize("Growth on the leviathan's back\n[<color=yellow><b>chop</b></color>] to clear it"); } public string GetHoverName() { return "Growth"; } public float GetHoverOffset() { return 2f; } } internal static class Hall { internal const string IdKey = "LH_id"; internal const string HostKey = "LH_host"; internal const string StowedKey = "LH_stowed"; internal const string SurfaceYKey = "LH_surfaceY"; internal const string LocalPosKey = "LH_lpos"; internal const string LocalRotKey = "LH_lrot"; internal static string EnsureId(ZDO zdo) { if (zdo == null) { return null; } string text = zdo.GetString("LH_id", ""); if (!string.IsNullOrEmpty(text)) { return text; } text = Guid.NewGuid().ToString("N"); zdo.Set("LH_id", text); return text; } internal static string GetId(ZDO zdo) { return (zdo == null) ? null : zdo.GetString("LH_id", ""); } internal static ZDO FindHostZdo(string hallId) { if (string.IsNullOrEmpty(hallId) || ZDOMan.instance == null) { return null; } foreach (KeyValuePair<ZDOID, ZDO> item in ZDOMan.instance.m_objectsByID) { ZDO value = item.Value; if (value != null && value.GetString("LH_id", "") == hallId) { return value; } } return null; } internal static List<ZDO> Members(string hallId, ZDOID hostUid) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) List<ZDO> list = new List<ZDO>(); if (ZDOMan.instance == null || string.IsNullOrEmpty(hallId)) { return list; } foreach (KeyValuePair<ZDOID, ZDO> item in ZDOMan.instance.m_objectsByID) { ZDO value = item.Value; if (value != null && value.IsValid() && !(value.m_uid == hostUid)) { string text = value.GetString("LH_host", ""); if (!string.IsNullOrEmpty(text) && !(text != hallId) && !IsExcluded(value)) { list.Add(value); } } } return list; } private static bool IsExcluded(ZDO zdo) { ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { return false; } GameObject prefab = instance.GetPrefab(zdo.GetPrefab()); if ((Object)(object)prefab == (Object)null) { return false; } if ((Object)(object)prefab.GetComponent<Player>() != (Object)null) { return true; } if ((Object)(object)prefab.GetComponent<Leviathan>() != (Object)null) { return true; } return false; } internal static int Relocate(string hallId, Vector3 newPos) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0076: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) ZDO val = FindHostZdo(hallId); if (val == null) { Plugin.Log.LogWarning((object)("Relocate: no leviathan with id " + hallId + ".")); return -1; } List<ZDO> list = Members(hallId, val.m_uid); RepairHost(val, list); Vector3 position = val.GetPosition(); Quaternion rotation = val.GetRotation(); List<ZDO> list2 = Passengers(hallId, list, position); List<Vector3> list3 = new List<Vector3>(list2.Count); foreach (ZDO item in list2) { list3.Add(item.GetPosition() - position); } foreach (ZDO item2 in list) { Vector3 val2 = item2.GetPosition() - position; MoveZdo(item2, newPos + val2, item2.GetRotation()); RecordOffset(item2, newPos, rotation); } float seconds = ((Plugin.RiseSeconds != null) ? Plugin.RiseSeconds.Value : 9f) + 0.3f; List<ZDO> carried = new List<ZDO>(list2); List<Vector3> offsets = new List<Vector3>(list3); Scheduler.After(seconds, delegate { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < carried.Count; i++) { ZDO val3 = carried[i]; if (val3 != null && val3.IsValid()) { MoveZdo(val3, newPos + offsets[i], val3.GetRotation()); } } if (carried.Count > 0) { Plugin.Log.LogInfo((object)$"Set down {carried.Count} passenger(s) on the hall."); } EffectAreas.RefreshHall(hallId); }); MoveZdo(val, newPos, rotation); Plugin.Log.LogInfo((object)($"Relocated hall {hallId}: host + {list.Count} object(s) " + $"and {list2.Count} passenger(s) from {position} to {newPos}.")); return list.Count; } internal static void RecordOffset(ZDO member, Vector3 hostPos, Quaternion hostRot) { //IL_000b: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (member != null) { Quaternion val = Quaternion.Inverse(hostRot); member.Set("LH_lpos", val * (member.GetPosition() - hostPos)); member.Set("LH_lrot", val * member.GetRotation()); } } internal static void RecordOffset(ZDO member, ZDO host) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (member != null && host != null) { RecordOffset(member, host.GetPosition(), host.GetRotation()); } } internal static bool IsStowed(ZDO host) { return host != null && host.GetBool("LH_stowed", false); } internal static int Submerge(string hallId) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0075: Unknown result type (might be due to invalid IL or missing references) ZDO val = FindHostZdo(hallId); if (val == null) { return -1; } if (IsStowed(val)) { return 0; } Vector3 position = val.GetPosition(); float num = ((Plugin.StowDepth != null) ? Plugin.StowDepth.Value : 60f); val.Set("LH_surfaceY", position.y); int num2 = Relocate(hallId, new Vector3(position.x, position.y - num, position.z)); if (num2 < 0) { return -1; } val.Set("LH_stowed", true); Plugin.Log.LogInfo((object)("Hall " + hallId.Substring(0, 8) + " submerged.")); return num2; } internal static int Surface(string hallId, Vector3? bringTo) { //IL_0058: 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_005d: 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_009e: Unknown result type (might be due to invalid IL or missing references) ZDO val = FindHostZdo(hallId); if (val == null) { return -1; } ZoneSystem instance = ZoneSystem.instance; float y = val.GetFloat("LH_surfaceY", ((Object)(object)instance != (Object)null) ? instance.m_waterLevel : 30f); Vector3 val2 = (Vector3)(((??)bringTo) ?? val.GetPosition()); val2.y = y; int num = Relocate(hallId, val2); if (num < 0) { return -1; } val.Set("LH_stowed", false); Plugin.Log.LogInfo((object)$"Hall {hallId.Substring(0, 8)} surfaced at {val2}."); return num; } internal static List<ZDO> Passengers(string hallId, List<ZDO> members, Vector3 hostPos) { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) List<ZDO> list = new List<ZDO>(); int num = 0; if (ZDOMan.instance == null) { return list; } if (Plugin.CarryPassengers == null || !Plugin.CarryPassengers.Value) { return list; } ZNetScene instance = ZNetScene.instance; float reach = 2.5f; float head = 4f; float num2 = ((Plugin.HallRadius != null) ? Plugin.HallRadius.Value : 48f); float num3 = num2 * num2; foreach (KeyValuePair<ZDOID, ZDO> item in ZDOMan.instance.m_objectsByID) { ZDO value = item.Value; if (value == null || !value.IsValid() || !string.IsNullOrEmpty(value.GetString("LH_host", ""))) { continue; } Vector3 position = value.GetPosition(); float num4 = position.x - hostPos.x; float num5 = position.z - hostPos.z; if (num4 * num4 + num5 * num5 > num3 || !CanRide(value, instance)) { continue; } if (!Aboard(position, members, hostPos, reach, head)) { num++; if (Plugin.Verbose != null && Plugin.Verbose.Value) { Plugin.Log.LogInfo((object)("Not carried: '" + Utils.GetPrefabName(instance.GetPrefab(value.GetPrefab())) + "' " + $"at {value.GetPosition()} — not standing on the hall.")); } } else { list.Add(value); } } if (num > 0) { Plugin.Log.LogWarning((object)($"{num} loose object(s) near the hall were NOT carried — " + "they were not judged to be standing on it.")); } return list; } internal static bool AnyoneAboard(List<ZDO> members, Vector3 hostPos, out int players, out int creatures) { //IL_009b: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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) players = 0; creatures = 0; if (ZDOMan.instance == null) { return false; } ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { return false; } float num = ((Plugin.HallRadius != null) ? Plugin.HallRadius.Value : 48f); float num2 = num * num; foreach (KeyValuePair<ZDOID, ZDO> item in ZDOMan.instance.m_objectsByID) { ZDO value = item.Value; if (value == null || !value.IsValid()) { continue; } Vector3 position = value.GetPosition(); float num3 = position.x - hostPos.x; float num4 = position.z - hostPos.z; if (num3 * num3 + num4 * num4 > num2) { continue; } GameObject prefab = instance.GetPrefab(value.GetPrefab()); if ((Object)(object)prefab == (Object)null) { continue; } bool flag = (Object)(object)prefab.GetComponent<Player>() != (Object)null; bool flag2 = !flag && (Object)(object)prefab.GetComponent<Character>() != (Object)null && value.GetBool(ZDOVars.s_tamed, false); if ((flag || flag2) && StandingOnDeck(position, members, 2.5f, 4f)) { if (flag) { players++; } else { creatures++; } } } return players > 0 || creatures > 0; } private static bool Aboard(Vector3 p, List<ZDO> members, Vector3 hostPos, float reach, float head) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0068: Unknown result type (might be due to invalid IL or missing references) if (StandingOnDeck(p, members, reach, head)) { return true; } float num = ((Plugin.BackReach != null) ? Plugin.BackReach.Value : 30f); float num2 = p.x - hostPos.x; float num3 = p.z - hostPos.z; if (num2 * num2 + num3 * num3 > num * num) { return false; } float num4 = p.y - hostPos.y; return num4 >= 6f && num4 <= 32f; } private static bool StandingOnDeck(Vector3 p, List<ZDO> members, float reach, float head) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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) float num = reach * reach; foreach (ZDO member in members) { Vector3 position = member.GetPosition(); float num2 = p.y - position.y; if (!(num2 < -0.5f) && !(num2 > head)) { float num3 = p.x - position.x; float num4 = p.z - position.z; if (num3 * num3 + num4 * num4 <= num) { return true; } } } return false; } private static bool CanRide(ZDO zdo, ZNetScene scene) { if ((Object)(object)scene == (Object)null) { return false; } GameObject prefab = scene.GetPrefab(zdo.GetPrefab()); if ((Object)(object)prefab == (Object)null) { return false; } if ((Object)(object)prefab.GetComponent<Player>() != (Object)null) { return false; } if ((Object)(object)prefab.GetComponent<Leviathan>() != (Object)null) { return false; } if ((Object)(object)prefab.GetComponent<ItemDrop>() != (Object)null) { return true; } if ((Object)(object)prefab.GetComponent<Vagon>() != (Object)null) { return true; } if ((Object)(object)prefab.GetComponent<Pickable>() != (Object)null) { return true; } Character component = prefab.GetComponent<Character>(); if ((Object)(object)component != (Object)null) { return zdo.GetBool(ZDOVars.s_tamed, false); } return false; } internal static bool OffsetLooksSane(ZDO member) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (member == null) { return false; } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(float.MaxValue, float.MaxValue, float.MaxValue); Vector3 vec = member.GetVec3("LH_lpos", val); if (vec == val) { return false; } float num = ((Plugin.HallRadius != null) ? Plugin.HallRadius.Value : 48f) * 4f; return ((Vector3)(ref vec)).magnitude <= num; } internal static bool TryExpected(ZDO member, ZDO host, out Vector3 pos, out Quaternion rot) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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) //IL_006e: 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_0079: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) pos = Vector3.zero; rot = Quaternion.identity; if (member == null || host == null) { return false; } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(float.MaxValue, float.MaxValue, float.MaxValue); Vector3 vec = member.GetVec3("LH_lpos", val); if (vec == val) { return false; } Quaternion rotation = host.GetRotation(); pos = host.GetPosition() + rotation * vec; rot = rotation * member.GetQuaternion("LH_lrot", Quaternion.identity); return true; } private static bool IsPortal(ZDO zdo) { Game instance = Game.instance; if ((Object)(object)instance != (Object)null && instance.PortalPrefabHash != null) { return instance.PortalPrefabHash.Contains(zdo.GetPrefab()); } ZNetScene instance2 = ZNetScene.instance; if ((Object)(object)instance2 == (Object)null) { return false; } GameObject prefab = instance2.GetPrefab(zdo.GetPrefab()); return (Object)(object)prefab != (Object)null && (Object)(object)prefab.GetComponent<TeleportWorld>() != (Object)null; } private unsafe static void RefilePortal(ZDO zdo, SectorIndex wasFiledUnder, Vector3 pos) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0196: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) ZDOMan instance = ZDOMan.instance; if (instance == null) { return; } SectorIndex sectorIndex = ZoneSystem.GetSectorIndex(pos); instance.RemoveFromSector(zdo, wasFiledUnder); if (!((object)(*(SectorIndex*)(§orIndex))/*cast due to .constrained prefix*/).Equals((object?)wasFiledUnder)) { instance.RemoveFromSector(zdo, sectorIndex); } Dictionary<SectorIndex, List<ZDO>> portalObjects = instance.m_portalObjects; if (portalObjects != null) { List<SectorIndex> list = new List<SectorIndex>(); foreach (KeyValuePair<SectorIndex, List<ZDO>> item in portalObjects) { if (item.Value != null && item.Value.Remove(zdo) && item.Value.Count == 0) { list.Add(item.Key); } } foreach (SectorIndex item2 in list) { portalObjects.Remove(item2); } if (!portalObjects.TryGetValue(sectorIndex, out var value) || value == null) { value = (portalObjects[sectorIndex] = new List<ZDO>()); } if (!value.Contains(zdo)) { value.Add(zdo); } } instance.SetDirtyPortals(); if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { instance.ZDOSectorInvalidated(zdo); } Plugin.Log.LogInfo((object)$"Re-filed portal {zdo.m_uid} -> sector {sectorIndex.Sector}, portal file marked stale."); } internal static int EnsureBuilt(string hallId, Vector3 near, float radius) { //IL_004b: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null || ZDOMan.instance == null) { return 0; } ZDO val = FindHostZdo(hallId); if (val == null) { return 0; } int num = 0; float num2 = radius * radius; foreach (ZDO item in Members(hallId, val.m_uid)) { Vector3 val2 = item.GetPosition() - near; if (!(((Vector3)(ref val2)).sqrMagnitude > num2) && !((Object)(object)instance.FindInstance(item) != (Object)null)) { instance.CreateObject(item); num++; } } if (num > 0) { Plugin.Log.LogInfo((object)$"Built {num} arrived object(s) the zone system did not."); } return num; } internal static bool DestinationClear(string hallId, Vector3 pos, out int blockers) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) blockers = 0; if (ZDOMan.instance == null) { return true; } ZNetScene instance = ZNetScene.instance; float num = ((Plugin.HallRadius != null) ? Plugin.HallRadius.Value : 48f); float num2 = num * num; float num3 = 60f; foreach (KeyValuePair<ZDOID, ZDO> item in ZDOMan.instance.m_objectsByID) { ZDO value = item.Value; if (value == null || !value.IsValid() || value.GetString("LH_host", "") == hallId) { continue; } Vector3 position = value.GetPosition(); if (Mathf.Abs(position.y - pos.y) > num3) { continue; } float num4 = position.x - pos.x; float num5 = position.z - pos.z; if (num4 * num4 + num5 * num5 > num2) { continue; } if ((Object)(object)instance != (Object)null) { GameObject prefab = instance.GetPrefab(value.GetPrefab()); if ((Object)(object)prefab == (Object)null || (Object)(object)prefab.GetComponent<Piece>() == (Object)null) { continue; } } blockers++; } return blockers == 0; } private static void RepairHost(ZDO host, List<ZDO> members) { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00e0: Unknown result type (might be due to invalid IL or missing references) ZoneSystem instance = ZoneSystem.instance; float num = (((Object)(object)instance != (Object)null) ? instance.m_waterLevel : 30f); Vector3 position = host.GetPosition(); if (Mathf.Abs(position.y - num) <= 200f || members.Count == 0) { return; } Vector3 val = Vector3.zero; foreach (ZDO member in members) { val += member.GetPosition(); } val /= (float)members.Count; val.y = num; Plugin.Log.LogWarning((object)$"Host position {position} is impossible — repairing to {val} from {members.Count} member(s)."); host.SetPosition(val); } internal static void MoveZdo(ZDO zdo, Vector3 pos, Quaternion rot) { //IL_0025: Unkno