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 WanderersShelter v0.1.6
BepInEx/plugins/WanderersShelter/WanderersShelter.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Extensions; using Jotunn.Managers; using Jotunn.Utils; using Splatform; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; using WanderersShelter.Commands; using WanderersShelter.Config; using WanderersShelter.Items; using WanderersShelter.L10n; using WanderersShelter.Modules; using WanderersShelter.Patches; using WanderersShelter.Systems; [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: AssemblyCompany("WanderersShelter")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.6.0")] [assembly: AssemblyInformationalVersion("0.1.6+ef69ba0ba58884c99f4a1cab655a4f4c31d61ae8")] [assembly: AssemblyProduct("WanderersShelter")] [assembly: AssemblyTitle("WanderersShelter")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.6.0")] [module: UnverifiableCode] namespace WanderersShelter { [BepInPlugin("com.valheimmods100.wanderersshelter", "WanderersShelter", "0.1.6")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { public const string PluginGUID = "com.valheimmods100.wanderersshelter"; public const string PluginName = "WanderersShelter"; public const string PluginVersion = "0.1.6"; public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization(); internal static ConfigEntry<int> TentRecipeMult => TentConfig.RecipeMult; internal static ConfigEntry<bool> EnableFloor => TentConfig.EnableFloor; internal static ConfigEntry<bool> FlattenTerrain => TentConfig.FlattenTerrain; private void Awake() { //IL_0013: 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: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown TentConfig.Bind(((BaseUnityPlugin)this).Config); try { new Harmony("com.valheimmods100.wanderersshelter").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[WS] Harmony patches applied."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[WS] Harmony failed (plain camps only): " + ex.Message)); } CommandManager.Instance.AddConsoleCommand((ConsoleCommand)new WsTentCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)new WsInfoCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)new WsSkinCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)new WsPrefabsCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)new WsProbeCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)new WsFireCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)new WsUiStyleCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)new WsLayoutCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)new WsOwnCommand()); TentBundle.TryLoad(); PrefabManager.OnVanillaPrefabsAvailable += RegisterContent; TentKit.RegisterLocalization(); RegisterModuleLocalization(); ExtraLocalization.Register(); MenuLocalization.Register(); TentRPC.Register(); try { AccessPatches.Apply(new Harmony("com.valheimmods100.wanderersshelter")); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[WS] Access patches failed (open access): " + ex2.Message)); } GameObject val = new GameObject("WS_TentMenuHost"); Object.DontDestroyOnLoad((Object)(object)val); val.AddComponent<TentMenu.Host>(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"WanderersShelter 0.1.6 has landed"); ((BaseUnityPlugin)this).Logger.LogWarning((object)("[WS] build 0.1.6 " + BuildStamp())); } private static string BuildStamp() { try { string location = typeof(Plugin).Assembly.Location; if (!string.IsNullOrEmpty(location) && File.Exists(location)) { return File.GetLastWriteTimeUtc(location).ToString("yyyy-MM-dd'T'HH:mm") + "Z"; } } catch { } return "unknown"; } private void RegisterContent() { TentKit.Register(); TentGround.RegisterLeveler(); PrefabManager.OnVanillaPrefabsAvailable -= RegisterContent; } private void Update() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown TentRPC.Tick(); TentRegistry.AutoRebuildTick(); Player localPlayer = Player.m_localPlayer; if ((Object)localPlayer == (Object)null) { return; } ConfigEntry<KeyboardShortcut> packKey = TentConfig.PackKey; if (packKey == null) { return; } try { KeyboardShortcut value = packKey.Value; if (!((KeyboardShortcut)(ref value)).IsDown()) { return; } } catch { return; } if (!Console.IsVisible() && (!((Object)Chat.instance != (Object)null) || !Chat.instance.HasFocus())) { TentRPC.OpOwn(localPlayer, "pack", ""); } } private void RegisterModuleLocalization() { CustomLocalization localization = Localization; string text = "English"; localization.AddTranslation(ref text, new Dictionary<string, string> { { "$msg_ws_mod_built", "Built for the shelter." }, { "$msg_ws_mod_exists", "Already built in this shelter." }, { "$msg_ws_mod_missing", "Missing resources" }, { "$msg_ws_need_custom", "Needs the custom tent (bundle missing?)." }, { "$msg_ws_pack_storage", "Empty the shelter chest before packing." }, { "$msg_ws_upgraded", "Shelter upgraded." }, { "$msg_ws_level_max", "Shelter is already at max level." }, { "$msg_ws_decor_cap", "Enough decor: upgrade the shelter for more." }, { "$msg_ws_need_bench", "Build the workbench first." }, { "$msg_ws_need_forge", "Build the forge first." }, { "$msg_ws_chest_spilled", "No chest in the restored camp: stored items moved to your backpack." }, { "$msg_ws_not_owner", "This is someone else's shelter." }, { "$msg_ws_rpc_denied", "Server denied the action. Resources refunded." }, { "$msg_ws_rpc_timeout", "Server did not answer. Resources refunded, check the camp." }, { "$msg_ws_acc_denied", "The shelter owner closed access." }, { "$msg_ws_acc_set", "Access updated." }, { "$msg_ws_decor_removed", "Decor removed." }, { "$msg_ws_cook_max", "Spits at max (2)." }, { "$msg_ws_slot_busy_cook", "The fire spot is taken by the cauldron. Remove it to place spits." }, { "$msg_ws_slot_busy_cauldron", "The fire spot is taken by spits. Remove them to place the cauldron." }, { "$msg_ws_need_cauldron", "Place the cauldron first." }, { "$msg_ws_need_blackforge", "Build the black forge first." } }); CustomLocalization localization2 = Localization; text = "Ukrainian"; localization2.AddTranslation(ref text, new Dictionary<string, string> { { "$msg_ws_mod_built", "Збудовано для табору." }, { "$msg_ws_mod_exists", "Вже збудовано в цьому таборі." }, { "$msg_ws_mod_missing", "Бракує ресурсів" }, { "$msg_ws_need_custom", "Потрібен кастомний намет (нема бандла?)." }, { "$msg_ws_pack_storage", "Спочатку спорожни скриню табору." }, { "$msg_ws_upgraded", "Табір покращено." }, { "$msg_ws_level_max", "Табір уже максимального рівня." }, { "$msg_ws_decor_cap", "Декору досить: покращ табір для більшого." }, { "$msg_ws_need_bench", "Спочатку збудуй верстак." }, { "$msg_ws_need_forge", "Спочатку збудуй кузню." }, { "$msg_ws_chest_spilled", "У відновленому таборі нема скрині: речі зі сховища перекладено в наплічник." }, { "$msg_ws_not_owner", "Це чужий табір." }, { "$msg_ws_rpc_denied", "Сервер відхилив дію. Ресурси повернуто." }, { "$msg_ws_rpc_timeout", "Сервер не відповів. Ресурси повернуто, перевір табір." }, { "$msg_ws_acc_denied", "Власник табору закрив доступ." }, { "$msg_ws_acc_set", "Доступ оновлено." }, { "$msg_ws_decor_removed", "Декор прибрано." }, { "$msg_ws_cook_max", "Рожнів максимум (2)." }, { "$msg_ws_slot_busy_cook", "Місце над вогнем зайняте казаном. Прибери його, щоб поставити рожни." }, { "$msg_ws_slot_busy_cauldron", "Місце над вогнем зайняте рожнями. Прибери їх, щоб поставити казан." }, { "$msg_ws_need_cauldron", "Спочатку постав казан." }, { "$msg_ws_need_blackforge", "Спочатку збудуй чорну кузню." } }); } } } namespace WanderersShelter.Systems { internal static class BlueprintStash { private class Entry { public string Blueprint = ""; public string Inv = ""; public string Acc = ""; public string Own = ""; public Vector2i Slot = new Vector2i(-1, -1); } private static readonly Dictionary<long, Entry> Stash = new Dictionary<long, Entry>(); public static void Set(long playerId, string blueprint, string inv, Vector2i slot, string acc, string own) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) Stash[playerId] = new Entry { Blueprint = (blueprint ?? ""), Inv = (inv ?? ""), Acc = (acc ?? ""), Own = (own ?? ""), Slot = slot }; } public static bool Take(long playerId, out string blueprint, out string inv, out Vector2i slot, out string acc, out string own) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) blueprint = ""; inv = ""; acc = ""; own = ""; slot = new Vector2i(-1, -1); if (Stash.TryGetValue(playerId, out var value) && value != null) { Stash.Remove(playerId); blueprint = value.Blueprint; inv = value.Inv; acc = value.Acc; own = value.Own; slot = value.Slot; return true; } return false; } } internal static class ModuleSystem { internal static string LastMessageKey; public static void Say(Player player, MessageType type, string text) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (TentRPC.ServerExecuting) { if (!string.IsNullOrEmpty(text)) { LastMessageKey = text; } } else if (!((Object)player == (Object)null)) { try { ((Character)player).Message(type, text, 0, (Sprite)null, false); } catch (Exception ex) { Logger.LogWarning((object)("[WS] Say failed: " + ex.Message)); } } } public static void Refund(Player player, Dictionary<string, int> cost) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown if ((Object)player == (Object)null || cost == null || cost.Count == 0 || TentRPC.ServerExecuting) { return; } try { Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory == null || (Object)ObjectDB.instance == (Object)null) { return; } foreach (KeyValuePair<string, int> item in cost) { if (item.Value > 0) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(item.Key); if ((Object)itemPrefab == (Object)null) { Logger.LogWarning((object)("[WS] Refund: no item prefab '" + item.Key + "', skipped.")); } else { inventory.AddItem(itemPrefab, item.Value); } } } Logger.LogInfo((object)"[WS] Refunded consumed resources."); } catch (Exception ex) { Logger.LogWarning((object)("[WS] Refund failed: " + ex.Message)); } } public static bool HasResources(Player player, Dictionary<string, int> cost) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown if (TentRPC.ServerExecuting) { return true; } if ((Object)player == (Object)null || cost == null) { return false; } Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory == null) { return false; } foreach (KeyValuePair<string, int> item in cost) { if (CountAny(inventory, item.Key) < item.Value) { return false; } } return true; } public static bool Consume(Player player, Dictionary<string, int> cost) { if (TentRPC.ServerExecuting) { return true; } if (!HasResources(player, cost)) { return false; } Inventory inventory = ((Humanoid)player).GetInventory(); foreach (KeyValuePair<string, int> item in cost) { int num = item.Value; ItemData[] array = inventory.GetAllItems().ToArray(); ItemData[] array2 = array; foreach (ItemData val in array2) { if (num <= 0) { break; } if (NameMatches(val, item.Key) && val.m_stack > 0) { int num2 = Math.Min(val.m_stack, num); inventory.RemoveItem(val, num2); num -= num2; } } if (num > 0) { return false; } } return true; } public static int CountAny(Inventory inv, string prefabName) { int num = 0; if (inv == null) { return 0; } foreach (ItemData allItem in inv.GetAllItems()) { if (NameMatches(allItem, prefabName)) { num += allItem.m_stack; } } return num; } private static bool NameMatches(ItemData item, string prefabName) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown if (item == null || string.IsNullOrEmpty(prefabName)) { return false; } if ((Object)item.m_dropPrefab != (Object)null && ((Object)item.m_dropPrefab).name == prefabName) { return true; } string text = ((item.m_shared != null) ? item.m_shared.m_name : null); if (!string.IsNullOrEmpty(text)) { return text.Equals("$item_" + prefabName.ToLowerInvariant(), StringComparison.OrdinalIgnoreCase); } return false; } public static string MissingText(Player player, Dictionary<string, int> cost) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown List<string> list = new List<string>(); Inventory val = (((Object)player != (Object)null) ? ((Humanoid)player).GetInventory() : null); foreach (KeyValuePair<string, int> item in cost) { int num = ((val != null) ? CountAny(val, item.Key) : 0); if (num < item.Value) { list.Add($"{DisplayName(item.Key)} {num}/{item.Value}"); } } return string.Join(", ", list.ToArray()); } public static string DisplayName(string prefabName) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown try { if ((Object)ObjectDB.instance != (Object)null) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(prefabName); ItemDrop val = (((Object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null); string text = (((Object)val != (Object)null && val.m_itemData != null && val.m_itemData.m_shared != null) ? val.m_itemData.m_shared.m_name : null); if (!string.IsNullOrEmpty(text) && Localization.instance != null) { string text2 = Localization.instance.Localize(text); if (!string.IsNullOrEmpty(text2) && text2 != text) { return text2; } } } } catch { } return PrettyName(prefabName); } public static string PrettyName(string id) { if (1 == 0) { } string result = id switch { "Wood" => WsLoc.T("$ws_m_mat_wood"), "RoundWood" => WsLoc.T("$ws_m_mat_roundwood"), "FineWood" => WsLoc.T("$ws_m_mat_finewood"), "Stone" => WsLoc.T("$ws_m_mat_stone"), "BronzeNails" => WsLoc.T("$ws_m_mat_bronzenails"), "IronNails" => WsLoc.T("$ws_m_mat_ironnails"), "DeerHide" => WsLoc.T("$ws_m_mat_deerhide"), "LeatherScraps" => WsLoc.T("$ws_m_mat_leatherscraps"), "Flint" => WsLoc.T("$ws_m_mat_flint"), "Bronze" => WsLoc.T("$ws_m_mat_bronze"), "Iron" => WsLoc.T("$ws_m_mat_iron"), "Resin" => WsLoc.T("$ws_m_mat_resin"), "Coal" => WsLoc.T("$ws_m_mat_coal"), "Frostwood" => WsLoc.T("$ws_m_mat_sprucewood"), _ => id, }; if (1 == 0) { } return result; } public static Dictionary<string, int> PrefabCost(GameObject prefab, Dictionary<string, int> fallback) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown if ((Object)prefab != (Object)null) { Piece component = prefab.GetComponent<Piece>(); if ((Object)component != (Object)null && component.m_resources != null && component.m_resources.Length != 0) { Dictionary<string, int> dictionary = new Dictionary<string, int>(); Requirement[] resources = component.m_resources; Requirement[] array = resources; foreach (Requirement val in array) { if (val != null && !((Object)val.m_resItem == (Object)null) && val.m_amount > 0) { string text = (((Object)((Component)val.m_resItem).gameObject != (Object)null) ? ((Object)((Component)val.m_resItem).gameObject).name : ((Object)val.m_resItem).name); if (!string.IsNullOrEmpty(text)) { dictionary[text] = val.m_amount; } } } if (dictionary.Count > 0) { return dictionary; } } } return fallback; } public static GameObject FindVanillaPrefab(params string[] names) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown for (int i = 0; i < names.Length; i++) { GameObject prefab = Cache.GetPrefab<GameObject>(names[i]); if ((Object)prefab != (Object)null) { return prefab; } } return null; } public static GameObject PlaceModule(Player player, TentRecord record, Vector3 tentOrigin, Quaternion tentYaw, GameObject prefab, Vector3 localOffset, float localYawDeg, string moduleKind) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_001d: 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_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_002b: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0049: Unknown result type (might be due to invalid IL or missing references) if (record == null || (Object)prefab == (Object)null) { return null; } Vector3 pos = tentOrigin + tentYaw * localOffset; Quaternion rot = tentYaw * Quaternion.Euler(0f, localYawDeg, 0f); return PlaceModuleAt(player, record, prefab, pos, rot, moduleKind); } public static GameObject PlaceModuleAt(Player player, TentRecord record, GameObject prefab, Vector3 pos, Quaternion rot, string moduleKind) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_003b: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_004e: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) if ((Object)player == (Object)null) { return PlaceModuleAtAsOwner(record, TentRPC.ServerPid, prefab, pos, rot, moduleKind); } if (record == null || (Object)prefab == (Object)null) { return null; } GameObject val = Object.Instantiate<GameObject>(prefab, pos, rot); if ((Object)val == (Object)null) { return null; } Piece component = val.GetComponent<Piece>(); if ((Object)component != (Object)null) { try { component.SetCreator(TentRPC.PidOf(player), ((IUser)PlatformManager.DistributionPlatform.LocalUser).PlatformUserID); } catch (Exception ex) { Logger.LogWarning((object)("[WS] SetCreator fallback (creator unset): " + ex.Message)); } } WearNTear component2 = val.GetComponent<WearNTear>(); if ((Object)component2 != (Object)null) { component2.m_noSupportWear = false; component2.OnPlaced(); } IPlaced[] components = val.GetComponents<IPlaced>(); if (components != null) { IPlaced[] array = components; for (int i = 0; i < array.Length; i++) { array[i].OnPlaced(); } } TentState.Write(val.GetComponent<ZNetView>(), record.TentId, player.GetPlayerID(), record.TentLevel); TentState.WriteModKind(val.GetComponent<ZNetView>(), moduleKind); record.Pieces.Add(val); TentGround.MakeIndestructible(val); if (moduleKind != "starter:fire") { TentBundle.SetPieceLayer(val); } return val; } public static GameObject PlaceModuleAtAsOwner(TentRecord record, long ownerId, GameObject prefab, Vector3 pos, Quaternion rot, string moduleKind) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_0023: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) if (record == null || (Object)prefab == (Object)null) { return null; } GameObject val = Object.Instantiate<GameObject>(prefab, pos, rot); if ((Object)val == (Object)null) { return null; } Piece component = val.GetComponent<Piece>(); if ((Object)component != (Object)null) { try { component.SetCreator(ownerId, default(PlatformUserID)); } catch (Exception ex) { Logger.LogWarning((object)("[WS] SetCreator fallback (creator unset): " + ex.Message)); } } WearNTear component2 = val.GetComponent<WearNTear>(); if ((Object)component2 != (Object)null) { component2.m_noSupportWear = false; component2.OnPlaced(); } IPlaced[] components = val.GetComponents<IPlaced>(); if (components != null) { IPlaced[] array = components; for (int i = 0; i < array.Length; i++) { array[i].OnPlaced(); } } TentState.Write(val.GetComponent<ZNetView>(), record.TentId, ownerId, record.TentLevel); TentState.WriteModKind(val.GetComponent<ZNetView>(), moduleKind); record.Pieces.Add(val); TentGround.MakeIndestructible(val); if (moduleKind != "starter:fire") { TentBundle.SetPieceLayer(val); } return val; } public static void DestroyPiece(GameObject go) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown if ((Object)go == (Object)null || (Object)ZNetScene.instance == (Object)null) { return; } try { ZNetView component = go.GetComponent<ZNetView>(); if ((Object)component == (Object)null) { Object.Destroy((Object)(object)go); return; } if (!component.IsOwner()) { try { component.ClaimOwnership(); } catch (Exception ex) { Logger.LogWarning((object)("[WS] Claim before destroy failed: " + ex.Message)); } } ZNetScene.instance.Destroy(go); } catch (Exception ex2) { Logger.LogWarning((object)("[WS] Destroy failed: " + ex2.Message)); } } public static int DestroyZdoPieces(TentRecord record, string kindPrefix, int max) { if (record == null || ZDOMan.instance == null || max <= 0) { return 0; } List<ZDO> list = TentState.ModuleZdos(record.TentId, kindPrefix); if (list.Count == 0) { return 0; } list.Sort((ZDO a, ZDO b) => string.CompareOrdinal(b.GetString("ws_mod", ""), a.GetString("ws_mod", ""))); int num = 0; foreach (ZDO item in list) { if (num >= max) { break; } try { if (!item.IsOwner()) { item.SetOwner(ZDOMan.GetSessionID()); } ZDOMan.instance.DestroyZDO(item); num++; } catch (Exception ex) { Logger.LogWarning((object)("[WS] ZDO destroy failed: " + ex.Message)); } } return num; } public static int DestroyLocalPieceByKind(TentRecord record, string kindPrefix, int max) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown if (record == null || max <= 0 || string.IsNullOrEmpty(kindPrefix)) { return 0; } List<GameObject> list = new List<GameObject>(); foreach (GameObject piece in record.Pieces) { if ((Object)piece == (Object)null) { continue; } ZNetView component = piece.GetComponent<ZNetView>(); if (!((Object)component == (Object)null) && component.GetZDO() != null) { string text = component.GetZDO().GetString("ws_mod", ""); if (!string.IsNullOrEmpty(text) && text.StartsWith(kindPrefix)) { list.Add(piece); } } } list.Sort((GameObject a, GameObject b) => string.CompareOrdinal(b.GetComponent<ZNetView>().GetZDO().GetString("ws_mod", ""), a.GetComponent<ZNetView>().GetZDO().GetString("ws_mod", ""))); int num = 0; foreach (GameObject item in list) { if (num >= max) { break; } DestroyPiece(item); record.Pieces.Remove(item); num++; } return num; } public static void WriteRootModule(TentRecord record, string moduleKey, int level) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown TentRoot tentRoot = TentRoot.FindFor(record); if (!((Object)tentRoot == (Object)null)) { TentState.WriteModule(((Component)tentRoot).GetComponent<ZNetView>(), moduleKey, level); return; } ZDO val = TentState.FindRootZdo(record?.TentId); if (val != null) { val.Set(moduleKey, level); } } public static bool GetTentFrame(TentRecord record, out Vector3 origin, out Quaternion yaw) { //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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) origin = Vector3.zero; yaw = Quaternion.identity; TentRoot tentRoot = TentRoot.FindFor(record); if (!((Object)tentRoot == (Object)null)) { origin = ((Component)tentRoot).transform.position; yaw = ((Component)tentRoot).transform.rotation; return true; } ZDO val = TentState.FindRootZdo(record?.TentId); if (val != null) { origin = val.GetPosition(); yaw = val.GetRotation(); return true; } return false; } } internal static class TentAccess { public const string AccKey = "ws_acc"; public static readonly string[] Modules = TentAccessRules.Modules; private static readonly string[] Labels = new string[4] { "$ws_m_mod_workbench", "$ws_m_mod_forge", "$ws_m_acc_chest_wardrobe", "$ws_m_mod_bed" }; public static string Label(string module) { for (int i = 0; i < Modules.Length; i++) { if (Modules[i] == module) { return WsLoc.T(Labels[i]); } } return module ?? ""; } public static bool DefaultFor(string module) { return TentAccessRules.DefaultFor(module); } public static Dictionary<string, bool> Defaults() { return TentAccessRules.Defaults(); } public static Dictionary<string, bool> ReadAll(ZNetView rootView) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown try { ZDO val = (((Object)rootView != (Object)null) ? rootView.GetZDO() : null); if (val == null) { return Defaults(); } return TentAccessRules.ParseFlags(val.GetString("ws_acc", "")); } catch (Exception ex) { Logger.LogWarning((object)("[WS] Access read failed, defaults: " + ex.Message)); } return Defaults(); } public static void WriteAll(ZNetView rootView, Dictionary<string, bool> map) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown if ((Object)rootView == (Object)null || map == null) { return; } try { ZDO zDO = rootView.GetZDO(); if (zDO != null) { zDO.Set("ws_acc", PackFlags(map)); } } catch (Exception ex) { Logger.LogWarning((object)("[WS] Access write failed: " + ex.Message)); } } public static string PackFlags(Dictionary<string, bool> map) { return TentAccessRules.PackFlags(map); } public static string ModuleForKind(string kind) { return TentAccessRules.ModuleForKind(kind); } public static bool Allows(Player user, GameObject moduleGo) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown try { if ((Object)user == (Object)null || (Object)moduleGo == (Object)null) { return true; } ZNetView component = moduleGo.GetComponent<ZNetView>(); if (!TentState.TryRead(component, out var tentId, out var ownerId, out var _)) { return true; } ZDO val = (((Object)component != (Object)null) ? component.GetZDO() : null); string text = ModuleForKind((val != null) ? val.GetString("ws_mod", "") : ""); if (string.IsNullOrEmpty(text)) { return true; } long playerID = user.GetPlayerID(); if (ownerId == 0L || ownerId == playerID) { return true; } TentRegistry.Rebuild(); if (!TentRegistry.TryGetByTentId(tentId, out var rec) || rec == null) { return true; } TentRoot tentRoot = TentRoot.FindFor(rec); if ((Object)tentRoot == (Object)null) { return true; } bool flag = ReadAll(((Component)tentRoot).GetComponent<ZNetView>())[text]; if (!flag) { Logger.LogInfo((object)$"[WS] Access: {text} of tent {tentId} closed for player {playerID}."); } return flag; } catch (Exception ex) { Logger.LogWarning((object)("[WS] Access check failed (allowed): " + ex.Message)); return true; } } public static bool ApplySet(Player req, string tentId, string arg) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Expected O, but got Unknown if (((Object)req == (Object)null && !TentRPC.ServerExecuting) || string.IsNullOrEmpty(tentId) || string.IsNullOrEmpty(arg)) { return false; } string[] array = arg.Split(new char[1] { '=' }); if (array.Length != 2) { return false; } string text = array[0].Trim().ToLowerInvariant(); bool flag = array[1].Trim() == "1"; if (Array.IndexOf(Modules, text) < 0) { return false; } TentRegistry.Rebuild(); if (!TentRegistry.TryGetByTentId(tentId, out var rec) || rec == null) { ModuleSystem.Say(req, (MessageType)2, "$msg_ws_tent_nothing"); return false; } TentRoot tentRoot = TentRoot.FindFor(rec); ZNetView val = (((Object)tentRoot != (Object)null) ? ((Component)tentRoot).GetComponent<ZNetView>() : null); ZDO val2 = (((Object)val != (Object)null) ? val.GetZDO() : TentState.FindRootZdo(tentId)); long result = 0L; if (val2 != null) { long.TryParse(val2.GetString("ws_owner", "0"), out result); } if (val2 == null || result == 0) { ModuleSystem.Say(req, (MessageType)2, "$msg_ws_pack_unsafe"); return false; } if (result != TentRPC.PidOf(req)) { ModuleSystem.Say(req, (MessageType)2, "$msg_ws_not_owner"); return false; } Dictionary<string, bool> dictionary = (((Object)val != (Object)null) ? ReadAll(val) : TentAccessRules.ParseFlags(val2.GetString("ws_acc", ""))); dictionary[text] = flag; if ((Object)val != (Object)null) { WriteAll(val, dictionary); } else { val2.Set("ws_acc", PackFlags(dictionary)); } Logger.LogInfo((object)("[WS] Access: " + text + "=" + (flag ? "open" : "closed") + " in tent " + tentId + ".")); ModuleSystem.Say(req, (MessageType)2, "$msg_ws_acc_set"); return true; } public static void RestoreOrDefaults(TentRecord rec, string kitAcc) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown if (rec == null) { return; } try { TentRoot tentRoot = TentRoot.FindFor(rec); ZNetView val = (((Object)tentRoot != (Object)null) ? ((Component)tentRoot).GetComponent<ZNetView>() : null); if (!((Object)val == (Object)null)) { Dictionary<string, bool> map = Defaults(); if (!string.IsNullOrEmpty(kitAcc)) { map = TentAccessRules.ParseFlags(kitAcc); Logger.LogInfo((object)("[WS] Access restored from kit: " + kitAcc + ".")); } WriteAll(val, map); } } catch (Exception ex) { Logger.LogWarning((object)("[WS] Access restore failed: " + ex.Message)); } } } internal static class TentAccessRules { public static readonly string[] Modules = new string[4] { "workbench", "forge", "storage", "bed" }; public static bool DefaultFor(string module) { if (!(module == "workbench")) { return module == "forge"; } return true; } public static Dictionary<string, bool> Defaults() { Dictionary<string, bool> dictionary = new Dictionary<string, bool>(); string[] modules = Modules; foreach (string text in modules) { dictionary[text] = DefaultFor(text); } return dictionary; } public static string PackFlags(Dictionary<string, bool> map) { if (map == null) { map = Defaults(); } List<string> list = new List<string>(); string[] modules = Modules; foreach (string key in modules) { map.TryGetValue(key, out var value); list.Add(value ? "1" : "0"); } return string.Join(",", list.ToArray()); } public static Dictionary<string, bool> ParseFlags(string s) { Dictionary<string, bool> dictionary = Defaults(); if (string.IsNullOrEmpty(s)) { return dictionary; } string[] array = s.Split(new char[1] { ',' }); if (array.Length != Modules.Length) { return dictionary; } for (int i = 0; i < Modules.Length; i++) { dictionary[Modules[i]] = array[i].Trim() == "1"; } return dictionary; } public static string ModuleForKind(string kind) { if (string.IsNullOrEmpty(kind)) { return ""; } if (kind == "workbench" || kind.StartsWith("wbext")) { return "workbench"; } if (kind == "forge" || kind.StartsWith("forgeext")) { return "forge"; } if (kind == "blackforge" || kind.StartsWith("bfext")) { return "forge"; } if (kind == "storage") { return "storage"; } if (kind == "bed") { return "bed"; } return ""; } } internal static class TentBlueprint { public const string CustomKey = "ws_bp"; public const string InvKey = "ws_inv"; public const string DecorListKey = "ws_mod_decorlist"; public const string SlotKey = "ws_slot"; public static void WriteSlot(ZNetView rootView, Vector2i slot) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown if (!((Object)rootView == (Object)null)) { ZDO zDO = rootView.GetZDO(); if (zDO != null) { zDO.Set("ws_slot", slot.x + "," + slot.y); } } } public static Vector2i ReadSlot(ZNetView rootView) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_001d: 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_0034: 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_009f: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) Vector2i result = default(Vector2i); ((Vector2i)(ref result))..ctor(-1, -1); if ((Object)rootView == (Object)null) { return result; } ZDO zDO = rootView.GetZDO(); if (zDO == null) { return result; } string[] array = zDO.GetString("ws_slot", "").Split(new char[1] { ',' }); if (array.Length == 2 && int.TryParse(array[0], out var result2) && int.TryParse(array[1], out var result3) && result2 >= 0 && result3 >= 0) { return new Vector2i(result2, result3); } return result; } public static string Save(TentRecord rec) { if (rec == null) { return ""; } if (rec.TentLevel <= 1 && rec.WorkbenchLevel <= 0 && rec.StorageLevel <= 0 && rec.BedLevel <= 0 && rec.ForgeLevel <= 0 && rec.WbExt <= 0 && rec.BlackforgeLevel <= 0 && rec.CookCount <= 0 && rec.CauldronLevel <= 0 && (rec.DecorKinds == null || rec.DecorKinds.Count == 0)) { return ""; } string text = ((rec.DecorKinds != null) ? string.Join(",", rec.DecorKinds.ToArray()) : ""); return $"4|{rec.TentLevel}|{rec.WorkbenchLevel}|{rec.StorageLevel}|{rec.BedLevel}|{rec.ForgeLevel}|{rec.WbExt}|{rec.ForgeExt}|{rec.BlackforgeLevel}|{rec.BlackforgeExt}|{rec.CookCount}|{rec.CauldronLevel}|{rec.CaldExt}|{text}"; } public static bool TryParse(string s, out int tentLevel, out int wb, out int stor, out int bed, out int forge, out int wbext, out int forgeext, out int bf, out int bfext, out int cook, out int cauldron, out int caldext, out List<string> kinds) { tentLevel = 1; wb = 0; stor = 0; bed = 0; forge = 0; wbext = 0; forgeext = 0; bf = 0; bfext = 0; cook = 0; cauldron = 0; caldext = 0; kinds = new List<string>(); if (string.IsNullOrEmpty(s)) { return false; } string[] array = s.Split(new char[1] { '|' }); if (array.Length < 6 || (array[0] != "1" && array[0] != "2" && array[0] != "3" && array[0] != "4")) { return false; } int.TryParse(array[1], out tentLevel); int.TryParse(array[2], out wb); int.TryParse(array[3], out stor); int.TryParse(array[4], out bed); string text = ""; if (array[0] == "4" && array.Length >= 14) { int.TryParse(array[5], out forge); int.TryParse(array[6], out wbext); int.TryParse(array[7], out forgeext); int.TryParse(array[8], out bf); int.TryParse(array[9], out bfext); int.TryParse(array[10], out cook); int.TryParse(array[11], out cauldron); int.TryParse(array[12], out caldext); text = array[13]; } else if (array[0] == "3" && array.Length >= 9) { int.TryParse(array[5], out forge); int.TryParse(array[6], out wbext); int.TryParse(array[7], out forgeext); text = array[8]; } else if (array[0] == "2" && array.Length >= 9) { int.TryParse(array[5], out forge); int.TryParse(array[6], out wbext); int.TryParse(array[7], out forgeext); text = array[8]; } else if (array.Length >= 8) { int.TryParse(array[5], out forge); int.TryParse(array[6], out wbext); text = array[7]; } else { text = array[5]; } if (array[0] == "1" || array[0] == "2") { if (stor == 2) { stor = 3; } else if (stor == 3) { stor = 4; } } tentLevel = Mathf.Clamp(tentLevel, 1, 3); string[] array2 = text.Split(new char[1] { ',' }); for (int i = 0; i < array2.Length; i++) { string text2 = array2[i].Trim().ToLowerInvariant(); if (!string.IsNullOrEmpty(text2) && DecorModule.Catalog.ContainsKey(text2)) { kinds.Add(text2); } } return true; } public static void WriteKinds(ZNetView rootView, List<string> kinds) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown if (!((Object)rootView == (Object)null)) { ZDO zDO = rootView.GetZDO(); if (zDO != null) { zDO.Set("ws_mod_decorlist", (kinds != null) ? string.Join(",", kinds.ToArray()) : ""); } } } public static List<string> ReadKinds(ZNetView rootView) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown List<string> list = new List<string>(); if ((Object)rootView == (Object)null) { return list; } ZDO zDO = rootView.GetZDO(); if (zDO == null) { return list; } string[] array = zDO.GetString("ws_mod_decorlist", "").Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim().ToLowerInvariant(); if (!string.IsNullOrEmpty(text)) { list.Add(text); } } return list; } public static int Apply(Player player, TentRecord rec, int tentLevel, int wb, int stor, int bed, int forge, int wbext, int forgeext, int bf, int bfext, int cook, int cauldron, int caldext, List<string> kinds, string invData) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0230: 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) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027c: 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_0084: Expected O, but got Unknown //IL_00b9: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Expected O, but got Unknown //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Expected O, but got Unknown //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Expected O, but got Unknown //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Expected O, but got Unknown //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_05c8: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: Unknown result type (might be due to invalid IL or missing references) //IL_05cf: Unknown result type (might be due to invalid IL or missing references) //IL_04fd: Unknown result type (might be due to invalid IL or missing references) //IL_0509: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_051a: Unknown result type (might be due to invalid IL or missing references) //IL_051f: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_054c: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_0628: Unknown result type (might be due to invalid IL or missing references) //IL_0633: Expected O, but got Unknown //IL_0637: Unknown result type (might be due to invalid IL or missing references) //IL_0642: Expected O, but got Unknown //IL_0739: Unknown result type (might be due to invalid IL or missing references) //IL_0744: Expected O, but got Unknown //IL_0656: Unknown result type (might be due to invalid IL or missing references) //IL_0662: Unknown result type (might be due to invalid IL or missing references) //IL_0669: Unknown result type (might be due to invalid IL or missing references) //IL_066e: Unknown result type (might be due to invalid IL or missing references) //IL_0673: Unknown result type (might be due to invalid IL or missing references) //IL_0678: Unknown result type (might be due to invalid IL or missing references) //IL_0683: Unknown result type (might be due to invalid IL or missing references) //IL_069c: Unknown result type (might be due to invalid IL or missing references) //IL_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_07eb: Unknown result type (might be due to invalid IL or missing references) //IL_07ec: Unknown result type (might be due to invalid IL or missing references) //IL_07f2: Unknown result type (might be due to invalid IL or missing references) //IL_084b: Unknown result type (might be due to invalid IL or missing references) //IL_0856: Expected O, but got Unknown //IL_0756: Unknown result type (might be due to invalid IL or missing references) //IL_0757: Unknown result type (might be due to invalid IL or missing references) //IL_075c: Unknown result type (might be due to invalid IL or missing references) //IL_077c: Unknown result type (might be due to invalid IL or missing references) //IL_0787: Expected O, but got Unknown //IL_085a: Unknown result type (might be due to invalid IL or missing references) //IL_0865: Expected O, but got Unknown //IL_0a5a: Unknown result type (might be due to invalid IL or missing references) //IL_0a65: Expected O, but got Unknown //IL_0879: Unknown result type (might be due to invalid IL or missing references) //IL_0885: Unknown result type (might be due to invalid IL or missing references) //IL_088c: Unknown result type (might be due to invalid IL or missing references) //IL_0891: Unknown result type (might be due to invalid IL or missing references) //IL_0896: Unknown result type (might be due to invalid IL or missing references) //IL_089b: Unknown result type (might be due to invalid IL or missing references) //IL_08a6: Unknown result type (might be due to invalid IL or missing references) //IL_08bf: Unknown result type (might be due to invalid IL or missing references) //IL_08c8: Unknown result type (might be due to invalid IL or missing references) //IL_09ba: Unknown result type (might be due to invalid IL or missing references) //IL_09c5: Expected O, but got Unknown //IL_09d1: Unknown result type (might be due to invalid IL or missing references) //IL_09d2: Unknown result type (might be due to invalid IL or missing references) //IL_09dd: Unknown result type (might be due to invalid IL or missing references) //IL_09fa: Unknown result type (might be due to invalid IL or missing references) //IL_0a05: Expected O, but got Unknown if (rec == null || ((Object)player == (Object)null && !TentRPC.ServerExecuting)) { return 0; } if (!ModuleSystem.GetTentFrame(rec, out var origin, out var yaw)) { Logger.LogWarning((object)"[WS] Blueprint: no custom root, modules skipped."); return 0; } int num = 0; if (tentLevel > rec.TentLevel) { rec.TentLevel = tentLevel; TentRoot tentRoot = TentRoot.FindFor(rec); if ((Object)tentRoot != (Object)null) { TentState.Write(((Component)tentRoot).GetComponent<ZNetView>(), rec.TentId, rec.OwnerId, rec.TentLevel); } } if (wb > 0) { PlaceFree(player, rec, origin, yaw, WorkbenchModule.Prefab(), WorkbenchModule.Offset(), WorkbenchModule.YawDeg(), "workbench"); rec.WorkbenchLevel = 1; ModuleSystem.WriteRootModule(rec, "ws_mod_workbench", 1); } if (stor > 0) { int num2 = Mathf.Clamp(stor, 1, 6); PlaceFree(player, rec, origin, yaw, StorageModule.TierPrefab(num2), StorageModule.Offset(), StorageModule.YawForTier(num2), "storage"); rec.StorageLevel = num2; ModuleSystem.WriteRootModule(rec, "ws_mod_storage", num2); try { List<List<TentCodec.ItemSpec>> list = LoadInv(invData); if (list.Count > 0) { foreach (GameObject piece in rec.Pieces) { if ((Object)piece == (Object)null) { continue; } Container component = piece.GetComponent<Container>(); if ((Object)component != (Object)null) { List<TentCodec.ItemSpec> list2 = FillChest(component, list[0]); if (list2.Count > 0) { num += Spill(list2, player, origin); } break; } } } } catch (Exception ex) { Logger.LogWarning((object)("[WS] Chest restore failed: " + ex.Message)); } } if (bed > 0) { int num3 = Mathf.Clamp(bed, 1, 3); PlaceFree(player, rec, origin, yaw, BedModule.TierPrefab(num3), BedModule.OffsetFor(num3), BedModule.YawDeg(), "bed"); rec.BedLevel = num3; ModuleSystem.WriteRootModule(rec, "ws_mod_bed", num3); } if (forge > 0) { PlaceFree(player, rec, origin, yaw, ForgeModule.Prefab(), ForgeModule.Offset(), ForgeModule.YawDeg(), "forge"); rec.ForgeLevel = 1; ModuleSystem.WriteRootModule(rec, "ws_mod_forge", 1); } if (stor <= 0 && !string.IsNullOrEmpty(invData)) { try { List<TentCodec.ItemSpec> list3 = new List<TentCodec.ItemSpec>(); foreach (List<TentCodec.ItemSpec> item in LoadInv(invData)) { list3.AddRange(item); } int num4 = Spill(list3, player, origin); num += num4; Logger.LogInfo((object)$"[WS] Chest spill: {num4} stacks secured (no chest rebuilt)."); if (num4 > 0) { ModuleSystem.Say(player, (MessageType)2, "$msg_ws_chest_spilled"); } } catch (Exception ex2) { Logger.LogWarning((object)("[WS] Chest spill failed: " + ex2.Message)); } } GameObject val = WorkbenchModule.FindModule(rec, "workbench"); for (int i = 0; i < wbext && i < 4; i++) { GameObject val2 = ModuleSystem.FindVanillaPrefab("piece_workbench_ext" + (i + 1)); if (!((Object)val2 == (Object)null) && !((Object)val == (Object)null)) { Vector3 pos = val.transform.position + val.transform.rotation * WorkbenchModule.ExtOffset(i); pos.y = val.transform.position.y - 3f; ModuleSystem.PlaceModuleAt(player, rec, val2, pos, val.transform.rotation, "wbext" + (i + 1)); } } if (wbext > 0) { rec.WbExt = Math.Min(wbext, 4); ModuleSystem.WriteRootModule(rec, "ws_mod_wbext", rec.WbExt); } GameObject val3 = WorkbenchModule.FindModule(rec, "forge"); for (int j = 0; j < forgeext && j < 6; j++) { GameObject val4 = ModuleSystem.FindVanillaPrefab("forge_ext" + (j + 1)); if (!((Object)val4 == (Object)null) && !((Object)val3 == (Object)null)) { Vector3 pos2 = val3.transform.position + val3.transform.rotation * ForgeModule.ExtOffset(j); pos2.y = val3.transform.position.y - 3f; ModuleSystem.PlaceModuleAt(player, rec, val4, pos2, val3.transform.rotation, "forgeext" + (j + 1)); } } if (forgeext > 0) { rec.ForgeExt = Math.Min(forgeext, 6); ModuleSystem.WriteRootModule(rec, "ws_mod_forgeext", rec.ForgeExt); } if (bf > 0) { PlaceFree(player, rec, origin, yaw, BlackforgeModule.Prefab(), BlackforgeModule.Offset(), BlackforgeModule.YawDeg(), "blackforge"); rec.BlackforgeLevel = 1; ModuleSystem.WriteRootModule(rec, "ws_mod_blackforge", 1); } GameObject val5 = WorkbenchModule.FindModule(rec, "blackforge"); for (int k = 0; k < bfext && k < 5; k++) { GameObject val6 = ModuleSystem.FindVanillaPrefab(BlackforgeModule.ExtPrefabName(k)); if (!((Object)val6 == (Object)null) && !((Object)val5 == (Object)null)) { Vector3 pos3 = val5.transform.position + val5.transform.rotation * BlackforgeModule.ExtOffset(k); pos3.y = val5.transform.position.y - 3f; ModuleSystem.PlaceModuleAt(player, rec, val6, pos3, val5.transform.rotation, "bfext" + (k + 1)); } } if (bfext > 0) { rec.BlackforgeExt = Math.Min(bfext, 5); ModuleSystem.WriteRootModule(rec, "ws_mod_blackforgeext", rec.BlackforgeExt); } if (cook > 0) { GameObject val7 = ModuleSystem.FindVanillaPrefab("piece_cookingstation"); if ((Object)val7 != (Object)null) { for (int l = 0; l < cook && l < 2; l++) { if ((Object)ModuleSystem.PlaceModule(player, rec, origin, yaw, val7, CookModule.SlotFor(l), 186f, "cook:" + l) != (Object)null) { rec.CookCount++; } } if (rec.CookCount > 0) { ModuleSystem.WriteRootModule(rec, "ws_mod_cook", rec.CookCount); } } } if (cauldron > 0) { PlaceFree(player, rec, origin, yaw, CauldronModule.Prefab(), CauldronModule.Offset(), CauldronModule.YawDeg(), "cauldron"); rec.CauldronLevel = 1; ModuleSystem.WriteRootModule(rec, "ws_mod_cauldron", 1); } GameObject val8 = WorkbenchModule.FindModule(rec, "cauldron"); for (int m = 0; m < caldext && m < 6; m++) { GameObject val9 = ModuleSystem.FindVanillaPrefab(CauldronModule.ExtPrefabName(m)); if (!((Object)val9 == (Object)null) && !((Object)val8 == (Object)null)) { Vector3 pos4 = val8.transform.position + val8.transform.rotation * CauldronModule.ExtOffset(m); pos4.y = val8.transform.position.y - 3f; ModuleSystem.PlaceModuleAt(player, rec, val9, pos4, val8.transform.rotation, "caldext" + m); } } if (caldext > 0) { rec.CaldExt = Math.Min(caldext, 6); ModuleSystem.WriteRootModule(rec, "ws_mod_caldext", rec.CaldExt); } int decorCount = rec.DecorCount; int num5 = 0; if (kinds != null) { foreach (string kind in kinds) { if (num5 < decorCount && IsStarterKind(kind, num5)) { num5++; } else { if (!DecorModule.Catalog.TryGetValue(kind, out var value)) { continue; } GameObject val10 = ModuleSystem.FindVanillaPrefab(value); if (!((Object)val10 == (Object)null)) { if ((Object)ModuleSystem.PlaceModule(player, rec, origin, yaw, val10, DecorModule.SlotForKind(kind, rec.DecorCount), DecorModule.YawForKind(kind), "decor:" + kind) != (Object)null) { rec.DecorCount++; rec.DecorKinds.Add(kind); } num5++; } } } } TentRoot tentRoot2 = TentRoot.FindFor(rec); if ((Object)tentRoot2 != (Object)null) { ZNetView component2 = ((Component)tentRoot2).GetComponent<ZNetView>(); TentState.WriteModule(component2, "ws_mod_decor", rec.DecorCount); WriteKinds(component2, rec.DecorKinds); } Logger.LogInfo((object)$"[WS] Blueprint applied: tent={rec.TentId} level={rec.TentLevel} wb={rec.WorkbenchLevel} stor={rec.StorageLevel} bed={rec.BedLevel} forge={rec.ForgeLevel}+{rec.ForgeExt} decor={rec.DecorCount}."); return num; } private static bool IsStarterKind(string kind, int idx) { if (idx != 0 || !(kind == "rug_deer")) { if (idx == 1) { return kind == "rug_wolf"; } return false; } return true; } private static void PlaceFree(Player player, TentRecord rec, Vector3 origin, Quaternion yaw, GameObject prefab, Vector3 offset, float yawDeg, string kind) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //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_0034: Unknown result type (might be due to invalid IL or missing references) if ((Object)prefab == (Object)null) { Logger.LogWarning((object)("[WS] Blueprint: prefab missing for '" + kind + "', skipped.")); } else { ModuleSystem.PlaceModule(player, rec, origin, yaw, prefab, offset, yawDeg, kind); } } public static string SaveInv(TentRecord rec) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown List<string> list = new List<string>(); if (rec == null) { return ""; } foreach (GameObject piece in rec.Pieces) { if ((Object)piece == (Object)null) { continue; } Container component = piece.GetComponent<Container>(); if (!((Object)component == (Object)null)) { Inventory inventory = component.GetInventory(); if (inventory == null) { list.Add(""); } else { list.Add(SerializeInventory(inventory)); } } } return string.Join(";", list.ToArray()); } public static string SerializeInventory(Inventory inventory) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown if (inventory == null) { return ""; } List<TentCodec.ItemSpec> list = new List<TentCodec.ItemSpec>(); foreach (ItemData allItem in inventory.GetAllItems()) { if (allItem == null || allItem.m_stack <= 0) { continue; } string text = (((Object)allItem.m_dropPrefab != (Object)null) ? ((Object)allItem.m_dropPrefab).name : ""); if (string.IsNullOrEmpty(text)) { continue; } TentCodec.ItemSpec itemSpec = new TentCodec.ItemSpec { Name = text, Stack = allItem.m_stack, Quality = allItem.m_quality, Variant = allItem.m_variant, Durability = allItem.m_durability }; if (allItem.m_customData != null) { foreach (KeyValuePair<string, string> customDatum in allItem.m_customData) { itemSpec.Custom[customDatum.Key] = customDatum.Value; } } list.Add(itemSpec); } return TentCodec.PackItems(list); } public static List<List<TentCodec.ItemSpec>> LoadInv(string s) { return TentCodec.ParseInventories(s); } public static List<TentCodec.ItemSpec> FillChest(Container c, List<TentCodec.ItemSpec> items) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown List<TentCodec.ItemSpec> list = new List<TentCodec.ItemSpec>(); if ((Object)c == (Object)null || items == null) { if (items != null) { list.AddRange(items); } return list; } Inventory inventory = c.GetInventory(); if (inventory == null) { list.AddRange(items); return list; } int num = 0; foreach (TentCodec.ItemSpec item in items) { ItemData val = inventory.AddItem(item.Name, item.Stack, item.Quality, item.Variant, 0L, "", false, true); if (val == null) { list.Add(item); continue; } val.m_durability = item.Durability; if (item.Custom != null) { if (val.m_customData == null) { val.m_customData = new Dictionary<string, string>(); } foreach (KeyValuePair<string, string> item2 in item.Custom) { val.m_customData[item2.Key] = item2.Value; } } num++; } Logger.LogInfo((object)$"[WS] Chest restore: {num} stacks back in, {list.Count} overflow."); return list; } private static int Spill(List<TentCodec.ItemSpec> specs, Player player, Vector3 at) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_016e: Unknown result type (might be due to invalid IL or missing references) if (specs == null || specs.Count == 0) { return 0; } int num = 0; List<TentCodec.ItemSpec> list = new List<TentCodec.ItemSpec>(); Inventory val = ((!TentRPC.ServerExecuting && (Object)player != (Object)null) ? ((Humanoid)player).GetInventory() : null); foreach (TentCodec.ItemSpec spec in specs) { ItemData val2 = ((val != null) ? val.AddItem(spec.Name, spec.Stack, spec.Quality, spec.Variant, 0L, "", false, true) : null); if (val2 != null) { val2.m_durability = spec.Durability; if (spec.Custom != null) { if (val2.m_customData == null) { val2.m_customData = new Dictionary<string, string>(); } foreach (KeyValuePair<string, string> item in spec.Custom) { val2.m_customData[item.Key] = item.Value; } } num++; } else { list.Add(spec); } } if (list.Count > 0) { num += DropSpecsAt(at, list); } return num; } private static int DropSpecsAt(Vector3 at, List<TentCodec.ItemSpec> specs) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown int num = 0; if ((Object)ObjectDB.instance == (Object)null) { return 0; } foreach (TentCodec.ItemSpec spec in specs) { try { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(spec.Name); if ((Object)itemPrefab == (Object)null) { Logger.LogWarning((object)("[WS] Spill lost: no item prefab '" + spec.Name + "'.")); continue; } Vector3 val = at + new Vector3(Random.Range(-1f, 1f), 0.6f, Random.Range(-1f, 1f)); GameObject val2 = Object.Instantiate<GameObject>(itemPrefab, val, Quaternion.identity); if ((Object)val2 == (Object)null) { continue; } ItemDrop component = val2.GetComponent<ItemDrop>(); if ((Object)component != (Object)null && component.m_itemData != null) { component.m_itemData.m_stack = Math.Max(1, spec.Stack); component.m_itemData.m_quality = Math.Max(1, spec.Quality); component.m_itemData.m_variant = spec.Variant; component.m_itemData.m_durability = spec.Durability; if (spec.Custom != null) { if (component.m_itemData.m_customData == null) { component.m_itemData.m_customData = new Dictionary<string, string>(); } foreach (KeyValuePair<string, string> item in spec.Custom) { component.m_itemData.m_customData[item.Key] = item.Value; } } } num++; } catch (Exception ex) { Logger.LogWarning((object)("[WS] Spill drop failed: " + ex.Message)); } } if (num > 0) { Logger.LogInfo((object)("[WS] Spill: " + num + " stacks dropped at the tent.")); } return num; } } internal static class TentBundle { public const string BundleFileName = "wstent"; public const string PrefabName = "WS_Tent"; public const string FloorPrefabName = "WS_Floor"; private static AssetBundle _bundle; private static GameObject _tentPrefab; private static GameObject _floorPrefab; private static bool _tried; public static void TryLoad() { //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown if (_tried) { return; } _tried = true; try { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "wstent"); if (!File.Exists(text)) { Logger.LogInfo((object)"[WS] Bundle 'wstent' not found, using vanilla kitbash v1."); return; } _bundle = AssetBundle.LoadFromFile(text); if ((Object)_bundle == (Object)null) { Logger.LogWarning((object)("[WS] Failed to load AssetBundle: " + text + ". Kitbash fallback.")); return; } _tentPrefab = _bundle.LoadAsset<GameObject>("WS_Tent"); if ((Object)_tentPrefab == (Object)null) { Logger.LogWarning((object)"[WS] Prefab 'WS_Tent' not in bundle. Kitbash fallback."); return; } EnsureNetworking(_tentPrefab); try { PrefabManager.Instance.AddPrefab(new CustomPrefab(_tentPrefab, true)); Logger.LogInfo((object)"[WS] Custom tent prefab registered (survives save/reload)."); } catch (Exception ex) { Logger.LogWarning((object)("[WS] Tent prefab registration failed (tent may vanish on rejoin): " + ex.Message)); } _floorPrefab = _bundle.LoadAsset<GameObject>("WS_Floor"); if ((Object)_floorPrefab == (Object)null) { Logger.LogWarning((object)"[WS] Prefab 'WS_Floor' not in bundle (tent still works)."); } SceneManager.sceneLoaded += OnSceneLoadedRetry; TrySwapShader(); Logger.LogInfo((object)"[WS] Custom tent prefab loaded from bundle (WS_Tent)."); } catch (Exception ex2) { Logger.LogWarning((object)("[WS] Bundle load failed (kitbash fallback): " + ex2.Message)); } } public static bool HasCustomPrefab() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown return (Object)_tentPrefab != (Object)null; } public static GameObject GetPrefab() { return _tentPrefab; } public static GameObject GetFloorPrefab() { return _floorPrefab; } public static GameObject PlaceFloorDisc(GameObject prefab, Vector3 origin, Quaternion yaw) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_00bc: 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) GameObject val = Object.Instantiate<GameObject>(prefab, origin, yaw); if ((Object)val == (Object)null) { return null; } GameObject prefab2 = Cache.GetPrefab<GameObject>("wood_floor"); MeshRenderer val2 = (((Object)prefab2 != (Object)null) ? prefab2.GetComponentInChildren<MeshRenderer>() : null); MeshRenderer componentInChildren = val.GetComponentInChildren<MeshRenderer>(); if ((Object)componentInChildren != (Object)null && (Object)val2 != (Object)null && (Object)((Renderer)val2).sharedMaterial != (Object)null) { ((Renderer)componentInChildren).sharedMaterial = ((Renderer)val2).sharedMaterial; } else { Logger.LogWarning((object)"[WS] Vanilla wood_floor material not found, placeholder kept."); } BoxCollider val3 = val.AddComponent<BoxCollider>(); val3.size = new Vector3(14.4f, 0.3f, 14.4f); val3.center = new Vector3(0f, -0.03f, 0f); SetPieceLayer(val); return val; } internal static void EnsureNetworking(GameObject prefab) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown if (!((Object)prefab == (Object)null)) { ZNetView val = prefab.GetComponent<ZNetView>(); if ((Object)val == (Object)null) { val = prefab.AddComponent<ZNetView>(); } val.m_persistent = true; WearNTear val2 = prefab.GetComponent<WearNTear>(); if ((Object)val2 == (Object)null) { val2 = prefab.AddComponent<WearNTear>(); } val2.m_noSupportWear = false; val2.m_noRoofWear = false; val2.m_health = 1E+09f; val2.m_supports = false; val2.m_materialType = (MaterialType)0; if ((Object)prefab.GetComponent<TentRoot>() == (Object)null) { prefab.AddComponent<TentRoot>(); } if ((Object)prefab.GetComponentInChildren<Collider>() == (Object)null) { AddTentColliders(prefab); } SetPieceLayer(prefab); } } internal static void SetPieceLayer(GameObject root) { int num = LayerMask.NameToLayer("piece"); if (num < 0) { Logger.LogWarning((object)"[WS] Layer 'piece' missing, keeping Default."); return; } Transform[] componentsInChildren = root.GetComponentsInChildren<Transform>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).gameObject.layer = num; } } private static void AddTentColliders(GameObject prefab) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) AddBox(prefab, "Wall_FrontL", new Vector3(-4f, 4.2f, 4.75f), new Vector3(4f, 8.4f, 0.4f)); AddBox(prefab, "Wall_FrontR", new Vector3(4f, 4.2f, 4.75f), new Vector3(4f, 8.4f, 0.4f)); AddBox(prefab, "Wall_Back", new Vector3(0f, 4.2f, -5.2f), new Vector3(12f, 8.4f, 0.4f)); AddBox(prefab, "Wall_E", new Vector3(5.75f, 4.2f, 0f), new Vector3(0.4f, 8.4f, 12f)); AddBox(prefab, "Wall_W", new Vector3(-5.75f, 4.2f, 0f), new Vector3(0.4f, 8.4f, 12f)); AddBox(prefab, "Roof", new Vector3(0f, 9.35f, 0f), new Vector3(12.6f, 1f, 12.6f)); AddBox(prefab, "Floor", new Vector3(0f, 0.19f, 0f), new Vector3(11.6f, 0.3f, 11.6f)); } private static void AddBox(GameObject parent, string name, Vector3 center, Vector3 size) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0021: 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_0038: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent.transform, false); val.transform.localPosition = center; BoxCollider val2 = val.AddComponent<BoxCollider>(); val2.size = size; val2.center = Vector3.zero; } private static void OnSceneLoadedRetry(Scene scene, LoadSceneMode mode) { if (TrySwapShader()) { SceneManager.sceneLoaded -= OnSceneLoadedRetry; } } internal static bool TrySwapShader() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown try { if ((Object)_tentPrefab == (Object)null) { return false; } MeshRenderer componentInChildren = _tentPrefab.GetComponentInChildren<MeshRenderer>(); Material val = (((Object)componentInChildren != (Object)null) ? ((Renderer)componentInChildren).sharedMaterial : null); if ((Object)val == (Object)null) { return false; } Shader val2 = FindVanillaStandardShader(); if ((Object)val2 == (Object)null) { return false; } if (((Object)val.shader).GetInstanceID() == ((Object)val2).GetInstanceID()) { return true; } int instanceID = ((Object)val.shader).GetInstanceID(); val.shader = val2; val.SetTexture("_BumpMap", (Texture)null); val.SetTexture("_MetallicGlossMap", (Texture)null); val.SetFloat("_Metallic", 0f); val.SetInt("_Cull", 0); Logger.LogInfo((object)"[WS] Tent material double-sided (_Cull 0)."); Logger.LogInfo((object)$"[WS] Tent shader adopted from vanilla ({instanceID} -> {((Object)val2).GetInstanceID()}), bump OFF."); return true; } catch (Exception ex) { Logger.LogWarning((object)("[WS] Tent shader swap failed: " + ex.Message)); return false; } } private static Shader FindVanillaStandardShader() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown ZNetScene s_instance = ZNetScene.s_instance; if ((Object)s_instance == (Object)null) { return null; } Shader val = null; foreach (GameObject prefab in s_instance.m_prefabs) { if ((Object)prefab == (Object)null || ((Object)prefab).name.IndexOf("wood", StringComparison.OrdinalIgnoreCase) < 0) { continue; } MeshRenderer[] componentsInChildren = prefab.GetComponentsInChildren<MeshRenderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Material[] sharedMaterials = ((Renderer)componentsInChildren[i]).sharedMaterials; Material[] array = sharedMaterials; foreach (Material val2 in array) { if (!((Object)val2 == (Object)null) && !((Object)val2.shader == (Object)null)) { if (((Object)val2.shader).name == "Custom/Piece") { return val2.shader; } if ((Object)val == (Object)null && ((Object)val2.shader).name == "Standard") { val = val2.shader; } } } } } return val; } } internal static class TentCodec { internal class ItemSpec { public string Name = ""; public int Stack = 1; public int Quality = 1; public int Variant; public float Durability; public Dictionary<string, string> Custom = new Dictionary<string, string>(); public override string ToString() { return string.Format(CultureInfo.InvariantCulture, "{0} x{1} (q{2} v{3} d{4})", Name, Stack, Quality, Variant, Durability); } } public static string Esc(string s) { return (s ?? "").Replace("\\", "\\\\").Replace("|", "\\p").Replace(";", "\\s") .Replace("~", "\\t") .Replace("=", "\\e"); } public static List<string> SplitRaw(string s, char sep) { List<string> list = new List<string>(); if (s == null) { list.Add(""); return list; } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < s.Length; i++) { if (s[i] == '\\' && i + 1 < s.Length) { stringBuilder.Append(s[i]); stringBuilder.Append(s[i + 1]); i++; } else if (s[i] == sep) { list.Add(stringBuilder.ToString()); stringBuilder.Length = 0; } else { stringBuilder.Append(s[i]); } } list.Add(stringBuilder.ToString()); return list; } public static int IndexOfRaw(string s, char c) { if (s == null) { return -1; } for (int i = 0; i < s.Length; i++) { if (s[i] == '\\' && i + 1 < s.Length) { i++; } else if (s[i] == c) { return i; } } return -1; } public static string Decode(string s) { if (string.IsNullOrEmpty(s)) { return s ?? ""; } StringBuilder stringBuilder = new StringBuilder(s.Length); for (int i = 0; i < s.Length; i++) { if (s[i] == '\\' && i + 1 < s.Length) { char c = s[i + 1]; switch (c) { case 'p': stringBuilder.Append('|'); break; case 's': stringBuilder.Append(';'); break; case 't': stringBuilder.Append('~'); break; case 'e': stringBuilder.Append('='); break; case '\\': stringBuilder.Append('\\'); break; default: stringBuilder.Append('\\'); stringBuilder.Append(c); break; } i++; } else { stringBuilder.Append(s[i]); } } return stringBuilder.ToString(); } public static List<string> SplitEsc(string s, char sep) { List<string> list = SplitRaw(s, sep); for (int i = 0; i < list.Count; i++) { list[i] = Decode(list[i]); } return list; } public static string PackItems(List<ItemSpec> items) { if (items == null) { return ""; } List<string> list = new List<string>(); foreach (ItemSpec item in items) { if (item == null || item.Stack <= 0 || string.IsNullOrEmpty(item.Name)) { continue; } List<string> list2 = new List<string> { Esc(item.Name), item.Stack.ToString(CultureInfo.InvariantCulture), item.Quality.ToString(CultureInfo.InvariantCulture), item.Variant.ToString(CultureInfo.InvariantCulture), item.Durability.ToString(CultureInfo.InvariantCulture) }; foreach (KeyValuePair<string, string> item2 in item.Custom) { list2.Add(Esc(item2.Key) + "=" + Esc(item2.Value)); } list.Add(string.Join("|", list2.ToArray())); } return string.Join("~", list.ToArray()); } public static List<ItemSpec> ParseItems(string s) { List<ItemSpec> list = new List<ItemSpec>(); if (string.IsNullOrEmpty(s)) { return list; } foreach (string item in SplitRaw(s, '~')) { if (string.IsNullOrEmpty(item)) { continue; } List<string> list2 = SplitRaw(item, '|'); if (list2.Count < 5) { continue; } ItemSpec itemSpec = new ItemSpec { Name = Decode(list2[0]) }; int.TryParse(list2[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out itemSpec.Stack); int.TryParse(list2[2], NumberStyles.Integer, CultureInfo.InvariantCulture, out itemSpec.Quality); int.TryParse(list2[3], NumberStyles.Integer, CultureInfo.InvariantCulture, out itemSpec.Variant); float.TryParse(list2[4], NumberStyles.Float, CultureInfo.InvariantCulture, out itemSpec.Durability); for (int i = 5; i < list2.Count; i++) { int num = IndexOfRaw(list2[i], '='); if (num > 0) { itemSpec.Custom[Decode(list2[i].Substring(0, num))] = Decode(list2[i].Substring(num + 1)); } } if (itemSpec.Stack > 0) { list.Add(itemSpec); } } return list; } public static List<List<ItemSpec>> ParseInventories(string s) { List<List<ItemSpec>> list = new List<List<ItemSpec>>(); if (string.IsNullOrEmpty(s)) { return list; } foreach (string item in SplitRaw(s, ';')) { list.Add(ParseItems(item)); } return list; } } internal static class TentGround { public const string FloorPrefab = "wood_floor"; public const float FloorRadius = 6.5f; public const float FloorStep = 2f; public const float ClearRadius = 14f; private static GameObject _levelerPrefab; internal static GameObject PredictLeveler; public static int DestroyLocalLevelers() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown int num = 0; try { TerrainModifier[] array = Object.FindObjectsByType<TerrainModifier>((FindObjectsInactive)0, (FindObjectsSortMode)0); if (array == null) { return 0; } List<KeyValuePair<Vector3, float>> list = new List<KeyValuePair<Vector3, float>>(); TerrainModifier[] array2 = array; foreach (TerrainModifier val in array2) { if (!((Object)val == (Object)null)) { GameObject gameObject = ((Component)val).gameObject; if ((Object)gameObject != (Object)null && ((Object)gameObject).name.StartsWith("WS_Leveler")) { Vector3 position = gameObject.transform.position; float radius = val.GetRadius(); ((Behaviour)val).enabled = false; list.Add(new KeyValuePair<Vector3, float>(position, radius)); Object.Destroy((Object)(object)gameObject); num++; } } } foreach (KeyValuePair<Vector3, float> item in list) { PokeArea(item.Key, item.Value); } if ((Object)PredictLeveler != (Object)null) { Object.Destroy((Object)(object)PredictLeveler); PredictLeveler = null; } } catch (Exception ex) { Logger.LogWarning((object)("[WS] DestroyLocalLevelers failed: " + ex.GetType().Name)); } return num; } public static void RegisterLeveler() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) if ((Object)_levelerPrefab != (Object)null) { return; } try { GameObject val = new GameObject("WS_Leveler"); TerrainModifier val2 = val.AddComponent<TerrainModifier>(); val2.m_level = true; val2.m_levelRadius = 10f; val2.m_square = false; val2.m_smooth = true; val2.m_smoothRadius = 12f; val2.m_smoothPower = 2f; val2.m_levelOffset = 0f; val2.m_playerModifiction = true; val2.m_paintCleared = true; val2.m_paintRadius = 10f; val2.m_paintType = (PaintType)0; ((Behaviour)val2).enabled = false; _levelerPrefab = val; Logger.LogInfo((object)"[WS] WS_Leveler template ready (local-only, not a network prefab)."); } catch (Exception ex) { Logger.LogWarning((object)("[WS] Leveler registration failed (unlevelled deploy): " + ex.Message)); } } public static GameObject CreateLeveler(Vector3 origin, Quaternion yaw) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown GameObject val = BuildLeveler(origin, yaw); val.SetActive(true); ZNetView component = val.GetComponent<ZNetView>(); if ((Object)component != (Object)null) { Object.Destroy((Object)(object)component); } TerrainModifier val2 = val.GetComponent<TerrainModifier>(); if ((Object)val2 == (Object)null) { val2 = val.AddComponent<TerrainModifier>(); ConfigureLeveler(val2); Logger.LogWarning((object)"[WS] Leveler instance lacked TerrainModifier, re-added."); } ((Behaviour)val2).enabled = true; PokeLeveler(val2, immediate: false); return val; } private static GameObject BuildLeveler(Vector3 origin, Quaternion yaw) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0012: 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) GameObject val = new GameObject("WS_Leveler"); val.transform.position = origin; val.transform.rotation = yaw; TerrainModifier modifier = val.AddComponent<TerrainModifier>(); ConfigureLeveler(modifier); return val; } private static void ConfigureLeveler(TerrainModifier modifier) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) if (!((Object)modifier == (Object)null)) { modifier.m_level = true; modifier.m_levelRadius = 10f; modifier.m_square = false; modifier.m_smooth = true; modifier.m_smoothRadius = 12f; modifier.m_smoothPower = 2f; modifier.m_levelOffset = 0f; modifier.m_playerModifiction = true; modifier.m_paintCleared = true; modifier.m_paintRadius = 10f; modifier.m_paintType = (PaintType)0; } } internal static void PokeLeveler(TerrainModifier modifier, bool immediate) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown if ((Object)modifier == (Object)null) { return; } try { foreach (Heightmap allHeightmap in Heightmap.GetAllHeightmaps()) { if (!((Object)allHeightmap == (Object)null) && allHeightmap.TerrainVSModifier(modifier)) { allHeightmap.Poke((!immediate) ? 2 : 0, false); } } } catch (Exception ex) { Logger.LogWarning((object)("[WS] Leveler poke failed: " + ex.GetType().Name)); } } internal static void PokeArea(Vector3 center, float radius) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) try { foreach (Heightmap allHeightmap in Heightmap.GetAllHeightmaps()) { if (!((Object)allHeightmap == (Object)null) && allHeightmap.IsPointInside(center, radius + 4f)) { allHeightmap.Poke(0, false); } } } catch (Exception ex) { Logger.LogWarning((object)("[WS] Ground poke failed: " + ex.GetType().Name)); } } private static GameObject LegacyLeveler(Vector3 origin, Quaternion yaw) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) return BuildLeveler(origin, yaw); } public static int AddFloors(Vector3 origin, Quaternion yaw, Player player, TentRecord record) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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) //IL_009a: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = Cache.GetPrefab<GameObject>("wood_floor"); if ((Object)prefab == (Object)null) { Logger.LogWarning((object)"[WS] Floor prefab missing: wood_floor"); return 0; } long playerID = player.GetPlayerID(); int num = 0; float y = origin.y + 0.12f; for (float num2 = -7f; num2 <= 7f; num2 += 2f) { for (float num3 = -7f; num3 <= 7f; num3 += 2f) { if (num2 * num2 + num3 * num3 > 42.25f) { continue; } Vector3 val = origin + yaw * new Vector3(num2, 0f, num3); val.y = y; GameObject val2 = Object.Instantiate<GameObject>(prefab, val, yaw); if ((Object)val2 == (Object)null) { continue; } Piece component = val2.GetComponent<Piece>(); if ((Object)component != (Object)null) { component.SetCreator(playerID, ((IUser)PlatformManager.DistributionPlatform.LocalUser).PlatformUserID); } WearNTear component2 = val2.GetComponent<WearNTear>(); if ((Object)component2 != (Object)null) { component2.m_noSupportWear = false; component2.OnPlaced(); } IPlaced[] components = val2.GetComponents<IPlaced>(); if (components != null) { IPlaced[] array = components; for (int i = 0; i < array.Length; i++) { array[i].OnPlaced(); } } TentState.Write(val2.GetComponent<ZNetView>(), record.TentId, playerID, record.TentLevel); record.Pieces.Add(val2); MakeIndestructible(val2); num++; } } Logger.LogInfo((object)