using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BalrondBiomes; using BepInEx; using BepInEx.Logging; using HarmonyLib; using LitJson2; using UnityEngine; using UnityEngine.Audio; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("BalrondConstructions")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BalrondConstructions")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("cde312a0-cf19-4264-8616-e1c74774beed")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] public class OfferingStation : MonoBehaviour, Hoverable, Interactable { public string m_name = "Offer station"; public string m_useItemText = "Use"; public ItemDrop m_requiredItem; public int m_requiredItemAmount = 1; public string m_statusEffectName = ""; public bool m_spawnStatusEffect = true; public GameObject m_aoePrefab; public GameObject m_spawnPoint = null; public bool m_spawnItem = false; public ItemDrop m_itemPrefab; public Transform m_itemSpawnPoint; public string m_setGlobalKey = ""; public float m_SpawnDelay = 2f; public float m_spawnOffset = 0f; [Header("Effects")] public EffectList m_fuelAddedEffects = new EffectList(); public EffectList m_spawnStartEffects = new EffectList(); public EffectList m_spawnFinishEffects = new EffectList(); public GameObject m_enabledObject; public GameObject m_disabledObject; public GameObject m_haveFuelObject; public Transform m_roofCheckPoint; public bool m_requiresRoof = false; public bool m_canBeOutside = true; private float m_updateCoverTimer; public Switch m_addWoodSwitch; public bool m_useFuel = false; public ItemDrop m_fuelItem; public int m_maxFuel = 0; public float m_secPerFuel = 2000f; public bool m_requireFire = false; public Transform[] m_fireCheckPoints; public float m_fireCheckRadius = 0.25f; private bool m_blockedSmoke; public SmokeSpawner m_smokeSpawner; public Animator[] m_animators; private ZNetView m_nview; private string m_requiredItemName; private void Awake() { m_nview = ((Component)this).GetComponent(); if ((Object)(object)m_nview == (Object)null || m_nview.GetZDO() == null) { ZLog.Log((object)"Missing ZnetView Component"); return; } validateAoe(); m_requiredItemName = m_requiredItem.m_itemData.m_shared.m_name; if (Object.op_Implicit((Object)(object)m_addWoodSwitch)) { } ((MonoBehaviour)this).InvokeRepeating("UpdateOfferingStation", 1f, 1f); } private bool validateAoe() { if ((Object)(object)m_aoePrefab.GetComponent() == (Object)null) { ZLog.Log((object)"m_aoePrefab Missing Aoe Component"); return false; } return true; } public string GetHoverText() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, false, false)) { return Localization.instance.Localize(m_name + "\n$piece_noaccess"); } return Localization.instance.Localize(m_name + "\n[1-8] \n" + m_useItemText) + " " + Localization.instance.Localize(((Component)m_requiredItem).GetComponent().m_itemData.m_shared.m_name) + " amount: " + m_requiredItemAmount; } public string GetHoverName() { return m_name; } public bool Interact(Humanoid user, bool hold, bool alt) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if (hold || IsSpawnQueued()) { return false; } if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) { return true; } if (m_blockedSmoke) { ((Character)user).Message((MessageType)2, "Smoke blocked", 0, (Sprite)null); return false; } if (!IsActive()) { return false; } if (Spawn(GetSpawnPosition())) { ((Character)user).Message((MessageType)2, "$msg_offerdone", 0, (Sprite)null); if (Object.op_Implicit((Object)(object)m_itemSpawnPoint)) { m_fuelAddedEffects.Create(m_itemSpawnPoint.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1); } } return true; } public bool UseItem(Humanoid user, ItemData item) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) if (IsSpawnQueued()) { return true; } if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) { return true; } if (m_blockedSmoke) { ((Character)user).Message((MessageType)2, "Smoke blocked", 0, (Sprite)null); return false; } if (!IsActive()) { return false; } if ((Object)(object)m_requiredItem == (Object)null) { return false; } if (item.m_shared.m_name == m_requiredItemName) { int num = user.GetInventory().CountItems(m_requiredItemName, -1, true); if (num < m_requiredItemAmount) { ((Character)user).Message((MessageType)2, "$msg_incompleteoffering: " + Localization.instance.Localize(m_requiredItemName) + " " + num + " / " + m_requiredItemAmount, 0, (Sprite)null); return true; } if (m_spawnStatusEffect && (Object)(object)m_aoePrefab == (Object)null) { Debug.LogWarning((object)"Missing Status Effect Prefab[AoE]"); return true; } if (m_spawnItem && (Object)(object)m_itemPrefab == (Object)null) { Debug.LogWarning((object)"Missing ItemDrop Prefab"); return true; } bool flag = false; if (((Object)(object)m_aoePrefab != (Object)null && m_spawnStatusEffect) || ((Object)(object)m_itemPrefab != (Object)null && m_spawnItem)) { flag = Spawn(GetSpawnPosition()); } if (flag) { user.GetInventory().RemoveItem(item.m_shared.m_name, m_requiredItemAmount, -1, true); ((Character)user).ShowRemovedMessage(m_requiredItem.m_itemData, m_requiredItemAmount); ((Character)user).Message((MessageType)2, "$msg_offerdone", 0, (Sprite)null); if (Object.op_Implicit((Object)(object)m_itemSpawnPoint)) { m_fuelAddedEffects.Create(m_itemSpawnPoint.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1); } if (!string.IsNullOrEmpty(m_setGlobalKey)) { ZoneSystem.instance.SetGlobalKey(m_setGlobalKey); } } return flag; } ((Character)user).Message((MessageType)2, "$msg_offerwrong", 0, (Sprite)null); return true; } public bool IsActive() { return (m_maxFuel == 0 || (double)GetFuel() > 0.0) && !m_blockedSmoke; } private void UpdateGameObjectState() { bool flag = IsActive(); m_enabledObject.SetActive(flag); if (Object.op_Implicit((Object)(object)m_disabledObject)) { m_disabledObject.SetActive(!flag); } if (Object.op_Implicit((Object)(object)m_haveFuelObject)) { m_haveFuelObject.SetActive((double)GetFuel() > 0.0); } SetAnimation(flag); } private void SetAnimation(bool active) { Animator[] animators = m_animators; foreach (Animator val in animators) { if (((Component)val).gameObject.activeInHierarchy) { val.SetBool("active", active); val.SetFloat("activef", active ? 1f : 0f); } } } private float GetDeltaTime() { DateTime time = ZNet.instance.GetTime(); DateTime dateTime = new DateTime(m_nview.GetZDO().GetLong("StartTime", time.Ticks)); double totalSeconds = (time - dateTime).TotalSeconds; m_nview.GetZDO().Set("StartTime", time.Ticks); return (float)totalSeconds; } private void UpdateFuel(float dt) { if (m_useFuel) { float num = dt / m_secPerFuel; float num2 = GetFuel() - num; if ((double)num2 < 0.0) { num2 = 0f; } SetFuel(num2); } } private void RPC_AddFuel(long sender) { //IL_0034: 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) if (m_nview.IsOwner()) { SetFuel(GetFuel() + 1f); m_fuelAddedEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform, 1f, -1); } } private void UpdateOfferingStation() { if (m_nview.IsValid()) { } } private Vector3 GetSpawnPosition() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) return ((Object)(object)m_spawnPoint != (Object)null) ? m_spawnPoint.transform.position : ((Component)this).transform.position; } private bool Spawn(Vector3 point) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) m_spawnStartEffects.Create(point, Quaternion.identity, (Transform)null, 1f, -1); ((MonoBehaviour)this).Invoke("DelayedSpawn", m_SpawnDelay); return true; } private void UpdateSmoke() { if ((Object)(object)m_smokeSpawner != (Object)null) { m_blockedSmoke = m_smokeSpawner.IsBlocked(); } else { m_blockedSmoke = false; } } private float GetFuel() { return m_nview.GetZDO().GetFloat("fuel", 0f); } private void SetFuel(float fuel) { m_nview.GetZDO().Set("fuel", fuel); } private bool OnAddFuel(Switch sw, Humanoid user, ItemData item) { if (!m_useFuel) { ((Character)user).Message((MessageType)2, "No fuel required", 0, (Sprite)null); return false; } if (item != null && item.m_shared.m_name != m_fuelItem.m_itemData.m_shared.m_name) { ((Character)user).Message((MessageType)2, "$msg_wrongitem", 0, (Sprite)null); return false; } if (!user.GetInventory().HaveItem(m_fuelItem.m_itemData.m_shared.m_name, true)) { ((Character)user).Message((MessageType)2, "$msg_donthaveany " + m_fuelItem.m_itemData.m_shared.m_name, 0, (Sprite)null); return false; } ((Character)user).Message((MessageType)2, "$msg_added " + m_fuelItem.m_itemData.m_shared.m_name, 0, (Sprite)null); user.GetInventory().RemoveItem(m_fuelItem.m_itemData.m_shared.m_name, 1, -1, true); m_nview.InvokeRPC("AddFuel", Array.Empty()); return true; } private bool IsSpawnQueued() { return ((MonoBehaviour)this).IsInvoking("DelayedSpawn"); } private void DelayedSpawn() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) if (m_spawnStatusEffect) { Aoe component = Object.Instantiate(m_aoePrefab, GetSpawnPosition(), Quaternion.identity).GetComponent(); component.m_statusEffect = m_statusEffectName; } if (m_spawnItem) { Object.Instantiate(((Component)m_itemPrefab).gameObject, GetSpawnPosition(), Quaternion.identity); } m_spawnFinishEffects.Create(GetSpawnPosition(), Quaternion.identity, (Transform)null, 1f, -1); } } namespace BalrondBiomes { internal class BuildPieceList { public static string[] buildPieces = new string[343] { "ashwood_decowall_divider_bal", "ashwood_roof26_bal", "ashwood_roof45_bal", "ashwood_roof_icorner_45_bal", "ashwood_roof_icorner_left45_bal", "ashwood_roof_icorner_right45_bal", "ashwood_roof_ocorner_45_bal", "ashwood_roof_top45_bal", "ashwood_roof_top_quarter_bal", "ashwood_wall_beam_64_bal", "bg_stake_wall_bal", "bigstonepillar4m_bal", "bigstonepillar4m_reverse_bal", "blackmarble_1x1_enforced_bal", "blackmarble_2x2x1_bal", "blackmarble_2x2_enforced_bal", "blackmarble_beam_bal", "blackmarble_columnbase_bal", "blackmarble_columntop_bal", "blackmarble_creep_slope_inverted_2x2x1_bal", "blackmarble_floor4m_bal", "blackmarble_gate_bal", "blackmarble_head_big01_bal", "blackmarble_head_big02_bal", "blackmarble_long_stair_bal", "blackmarble_pole_bal", "blackmarble_roof27_bal", "blackmarble_slope1x2_bal", "blackmarble_slope1x2_inverted_bal", "blackmarble_stair_corner_bal", "blackmarble_stair_corner_left_bal", "blackmarble_stair_inner_bal", "blackmarble_stair_outer_bal", "blackmarble_stone_ladder_bal", "blackmarble_Wall_Window_2x2_bal", "BoneFragmentsFloorl1_bal", "BoneFragmentsFloorl2_bal", "bone_fence_bal", "bridge_end_bal", "bridge_floor_bal", "bronze_gate_left_bal", "bush_roof_bal", "bush_roof_icorner_bal", "bush_roof_ocorner_bal", "bush_roof_top_bal", "CheeseBlock_bal", "chitin_wall_spikes_bal", "ClayBeam_bal", "ClayCube_bal", "ClayPole_bal", "clayr_arch_bal", "ClayWall_bal", "ClayWall_half_bal", "ClayWall_quarter_bal", "Clay_arch45_bal", "clay_celling_bal", "clay_floor_2x2_bal", "clay_slab_wall4x4_bal", "clay_stair_bal", "coppermarble_1x1_enforced_bal", "coppermarble_head1_bal", "coppermarble_head2_bal", "copper_dropgate_large_bal", "Copper_Wall_Spikes_bal", "corewood_gate_large_bal", "core_wood_roof26_bal", "core_wood_stair_bal", "core_wood_wall_2_bal", "core_wood_wall_4_bal", "core_wood_wall_corner_bal", "core_wood_wall_deco2_bal", "core_wood_wall_deco4_bal", "wood_wall_log1m_bal", "wood_log_64_bal", "wood_pole_log1m_bal", "crystal_tile_floor_2x2_bal", "crystal_wall_2x2_bal", "darkwoodwall1m_bal", "darkwoodwall_bal", "darkwood_beam_26_deco_bal", "darkwood_beam_45_deco_bal", "darkwood_beam_64_bal", "darkwood_beam_deco_bal", "darkwood_gate_large_bal", "darkwood_pole_deco_bal", "darkwood_roof64_bal", "darkwood_roof_quarter_26_bal", "darkwood_roof_quarter_45_bal", "darkwood_roof_top_cap2_bal", "darkwood_roof_top_cap_bal", "darkwood_roof_top_center_bal", "darkwood_roof_top_half_45_bal", "darkwood_roof_top_half_bal", "decowall_bal", "decr_wall_half_bal", "dverger_gate_bal", "dvergr_secretdoor_bal", "emberwood_pillar2_bal", "emberwood_pillar4_bal", "fineood_wall_roof_26_bal", "finewood_arch_bottom_bal", "finewood_arch_top_bal", "finewood_beam2_bal", "finewood_beam4_bal", "finewood_beam_26_bal", "finewood_beam_45_bal", "finewood_beam_64_bal", "finewood_beam_bal", "finewood_floor1x1_bal", "finewood_floor2x2_bal", "finewood_frame_bal", "finewood_pole2_bal", "finewood_pole4_bal", "finewood_pole_bal", "finewood_stair_bal", "finewood_wall_1x1_bal", "finewood_wall_1x2_bal", "finewood_wall_2x1_bal", "finewood_wall_2x2_bal", "finewood_wall_arch_bal", "finewood_wall_cross_26_bal", "finewood_wall_cross_45_bal", "finewood_wall_cross_64_bal", "finewood_wall_roof_26_upsidedown_bal", "finewood_wall_roof_45_bal", "finewood_wall_roof_45_upsidedown_bal", "finewood_wall_roof_64_bal", "finewood_wall_roof_64_upsidedown_bal", "flametalchain_beam2_26_bal", "flametalchain_beam2_45_bal", "flametalchain_beam2_bal", "flametalchain_pole2_bal", "flametalchain_hook_bal", "flametalchain_hook_top_bal", "flametalchain_hook_wall_bal", "gabro_arch4m_bal", "gabro_barkwood_beam2_bal", "gabro_barkwood_beam_bal", "gabro_barkwood_pole2_bal", "gabro_barkwood_pole_26_bal", "gabro_barkwood_pole_45_bal", "gabro_barkwood_pole_bal", "gabro_bark_pillar_empty2m_bal", "gabro_bark_pillar_empty2m_reverse_bal", "gabro_bark_pillar_empty2m_side_bal", "gabro_beam4_bal", "gabro_clolumnbase_bal", "gabro_columntop_bal", "gabro_column_bal", "gabro_counter1x1_bal", "gabro_counter_corner_bal", "gabro_floor1x1_bal", "gabro_floor2x2_bal", "gabro_floor4x4_bal", "gabro_floor_slope26_bal", "gabro_floor_slope45_bal", "gabro_oriel4m_bal", "gabro_pass_1x3_bal", "gabro_pole4_bal", "gabro_stair_bal", "gabro_wall2x1_bal", "gabro_wall2x2_bal", "gabro_wall2x4_bal", "gabro_wall4x4_bal", "gabro_wall_1x1_thin_bal", "gabro_window1m_bal", "gabro_window2m_bal", "gabro_window_deco2m_bal", "gabro_window_glass_3m_bal", "gabro_window_large2m_bal", "gabro_window_round2m_bal", "gabro_window_triangle2m_bal", "giant_metal_gate_bal", "grausten_round_column_bal", "grausten_stair_corner_bal", "grausten_stair_corner_left_bal", "grausten_stair_inner_bal", "grausten_stair_outer_bal", "hardwood_door_bal", "hexwood_floor_4m_bal", "hexwood_floor_half_4m_bal", "iron_beam1_bal", "iron_beam_26_bal", "iron_beam_45_bal", "iron_beam_64_bal", "iron_beam_bal", "iron_pole1_bal", "iron_pole_bal", "iron_trim1_bal", "iron_trim_1_90_bal", "iron_trim_26_bal", "iron_trim_45_bal", "iron_trim_90_bal", "iron_trim_bal", "leather_roof_bal", "metalbar_1x2_bal", "obsidian_tile_floor_2x2_bal", "obsidian_wall_2x2_bal", "piece_grausten_pillar4_tip2_bal", "piece_grausten_pillar4_tip3_bal", "piece_grausten_pillar4_tip_bal", "piece_grausten_pillarbase_twisted_bal", "piece_grausten_pillarbase_twisted_reversed_bal", "piece_grausten_reinforced_wall_4x6_bal", "piece_grausten_roof_45_top_bal", "piece_grausten_twisted_pillarbase_bal", "piece_grausten_twisted_pillarbase_small_bal", "piece_grausten_twisted_pillartop_small_bal", "piece_grausten_twisted_pillar_small_bal", "piece_grausten_twist_arch_bal", "piece_hardwoodwall2m_bal", "piece_hardwood_floor2x2_bal", "Piece_hardwood_pillarbase_medium_bal", "Piece_hardwood_pillarbase_small_bal", "Piece_hardwood_pillarbase_tapered_bal", "Piece_hardwood_pillarbase_tapered_inverted_bal", "Piece_hardwood_pillarbeam_medium_bal", "Piece_hardwood_pillarbeam_small_bal", "Piece_hardwood_pillar_arch_bal", "Piece_hardwood_pillar_arch_small_bal", "piece_hardwood_roof_45_arch_bal", "piece_hardwood_roof_45_arch_corner2_bal", "piece_hardwood_roof_45_arch_corner_bal", "piece_hardwood_roof_45_bal", "piece_hardwood_roof_45_corner2_bal", "piece_hardwood_roof_45_corner_bal", "piece_hardwood_roof_45_top_bal", "piece_iron_fence_bal", "piece_iron_fence_small_bal", "piece_sharpstakes_big_bal", "plate_gate_bal", "rune_floor_bal", "spiked_copper_gate_left_bal", "spiked_copper_gate_right_bal", "stonemoss_tile_floor_2x2_bal", "stone_1x1_enforced_bal", "stone_arch4m_bal", "stone_beam2_bal", "stone_beam_bal", "stone_celling_bal", "stone_circle_arch_bal", "stone_floor4m_bal", "stone_floor_slope45_bal", "stone_floor_slope_bal", "stone_floor_triangle_bal", "stone_floor_trianlge_1x2m_bal", "stone_floor_trianlge_1x2m_reverse_bal", "stone_frame_bal", "stone_long_stair_bal", "stone_pillar6m1_bal", "stone_pillar6m3_bal", "stone_platform_bal", "stone_pole2_bal", "stone_pole_bal", "stone_railing_bal", "stone_roof27_bal", "stone_secretdoor_bal", "stone_slab_wall4x4_bal", "stone_stair_corner_bal", "stone_stair_corner_left_bal", "stone_stair_inner_bal", "stone_stair_outer_bal", "stone_stair_railing_bal", "stone_stair_railing_left_bal", "stone_stair_railing_right_bal", "stone_stepladder_bal", "stone_trim1_90_bal", "stone_trim1_bal", "stone_trim_26_bal", "stone_trim_45_bal", "stone_trim_90_bal", "stone_trim_bal", "stone_Wall_2x2_bal", "stone_window_bal", "tiledwood_floor_2x2_bal", "vigvisir_floor_bal", "woodiron_beam_64_bal", "woodwall4m_bal", "woodwall_1m_bal", "woodwall_deco_bal", "wood_arch_bal", "wood_beam4_bal", "wood_beam_64_bal", "wood_double_wall_roof_26_bal", "wood_dragon_dark_bal", "wood_fence_bal", "wood_floor4x4_bal", "wood_frame_decorative_bal", "wood_frame_window_bal", "wood_frame_window_half_bal", "wood_gate_cage_bal", "wood_gate_large_bal", "wood_hidden_gate_bal", "wood_iron_gate_large_bal", "wood_iron_log_beam4_bal", "wood_iron_log_pole4_bal", "wood_ledge_bal", "wood_long_stair_bal", "wood_pillar4_bal", "wood_plot_1m_bal", "wood_plot_3m_bal", "wood_plot_gate_bal", "wood_pole4_bal", "wood_railing_bal", "wood_ramp_bal", "wood_raven_bal", "wood_roof64_bal", "wood_roof64_corner_bottom_bal", "wood_roof64_corner_top_bal", "wood_roof64_icorner_bottom_bal", "wood_roof_flat_quarter_bal", "wood_roof_quad_top64_bal", "wood_roof_top_64_bal", "wood_roof_top_cap2_45_bal", "wood_roof_top_cap2_bal", "wood_roof_top_cap_45_bal", "wood_roof_top_cap_bal", "wood_roof_top_center_45_bal", "wood_roof_top_center_bal", "wood_roof_top_half_45_bal", "wood_roof_top_half_bal", "wood_roof_top_quarter_45_bal", "wood_roof_top_quarter_bal", "wood_spiralstair_bal", "wood_spiralstair_right_bal", "wood_trim1_90_bal", "wood_trim1_bal", "wood_trim_26_bal", "wood_trim_45_bal", "wood_trim_64_bal", "wood_trim_90_bal", "wood_trim_bal", "wood_wall_cross_64_bal", "wood_wall_roof_26to45gap2_bal", "wood_wall_roof_26to45gap3_bal", "wood_wall_roof_26to45_bal", "wood_wall_roof_64_bal", "wood_wall_roof_upsidedown_64_bal", "wood_window2m_bal", "wood_windowiron_bal", "woven_fence_bal", "Yggdrasil_wood_block_bal", "Yggdrasil_wood_pillar_bal" }; } } namespace BalrondConstructions { public class BalrondTranslator { public static Dictionary> translations = new Dictionary>(); public static Dictionary getLanguage(string language) { Dictionary result = null; try { result = translations[language]; } catch (Exception) { } return result; } } [Serializable] public class BalrondConverter : MonoBehaviour { [Serializable] public class ItemConversion { public ItemDrop m_from; public ItemDrop m_to; public int m_count; } public string m_name = "BalrondConverter"; public string prefabName = null; public string m_addOreTooltip = "Add Non-Base Wood"; public string m_emptyOreTooltip = "Pick up wood"; public Switch m_addWoodSwitch; public Switch m_addOreSwitch; public Switch m_emptyOreSwitch; public Transform m_outputPoint; public Transform m_roofCheckPoint; public GameObject m_enabledObject; public GameObject m_disabledObject; public GameObject m_haveFuelObject; public GameObject m_haveOreObject; public GameObject m_noOreObject; public Animator[] m_animators; public ItemDrop m_fuelItem; public int m_maxOre = 1; public int m_maxFuel = 1; public float m_fuelPerProduct = 0f; public float m_secPerProduct = 30f; public bool m_spawnStack = true; public bool m_requiresRoof = false; public Windmill m_windmill; public SmokeSpawner m_smokeSpawner; public float m_addOreAnimationDuration; public List m_conversion = new List(); public EffectList m_oreAddedEffects = new EffectList(); public EffectList m_fuelAddedEffects = new EffectList(); public EffectList m_produceEffects = new EffectList(); private ZNetView m_nview; private bool m_haveRoof; private bool m_blockedSmoke; private float m_addedOreTime = -1000f; private StringBuilder m_sb = new StringBuilder(); private void Awake() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown m_nview = ((Component)this).GetComponent(); if (!((Object)(object)m_nview == (Object)null) && m_nview.GetZDO() != null) { if (Object.op_Implicit((Object)(object)m_addOreSwitch)) { Switch addOreSwitch = m_addOreSwitch; addOreSwitch.m_onUse = (Callback)Delegate.Combine((Delegate?)(object)addOreSwitch.m_onUse, (Delegate?)new Callback(OnAddWood)); m_addOreSwitch.m_onHover = new TooltipCallback(OnHoverAddWood); } if (Object.op_Implicit((Object)(object)m_addWoodSwitch)) { Switch addWoodSwitch = m_addWoodSwitch; addWoodSwitch.m_onUse = (Callback)Delegate.Combine((Delegate?)(object)addWoodSwitch.m_onUse, (Delegate?)new Callback(OnAddPowerSource)); m_addWoodSwitch.m_onHover = new TooltipCallback(OnHoverAddPowerSource); } if (Object.op_Implicit((Object)(object)m_emptyOreSwitch)) { Switch emptyOreSwitch = m_emptyOreSwitch; emptyOreSwitch.m_onUse = (Callback)Delegate.Combine((Delegate?)(object)emptyOreSwitch.m_onUse, (Delegate?)new Callback(OnEmpty)); Switch emptyOreSwitch2 = m_emptyOreSwitch; emptyOreSwitch2.m_onHover = (TooltipCallback)Delegate.Combine((Delegate?)(object)emptyOreSwitch2.m_onHover, (Delegate?)new TooltipCallback(OnHoverEmptyOre)); } m_nview.Register("AddWood", (Action)RPC_AddWood); m_nview.Register("AddPowerSource", (Action)RPC_AddPowerSource); m_nview.Register("ConverterEmptyProcessed", (Action)RPC_ConverterEmptyProcessed); WearNTear component = ((Component)this).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.m_onDestroyed = (Action)Delegate.Combine(component.m_onDestroyed, new Action(OnDestroyed)); } ((MonoBehaviour)this).InvokeRepeating("UpdateBalrondConverter", 1f, 1f); } } private void DropAllItems() { //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0092: Unknown result type (might be due to invalid IL or missing references) SpawnProcessed(); if ((Object)(object)m_fuelItem != (Object)null) { float @float = m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f); if (@float > 1f) { for (int i = 0; i < (int)@float; i++) { Object.Instantiate(((Component)m_fuelItem).gameObject, ((Component)this).transform.position + Vector3.up + Random.insideUnitSphere * 0.3f, Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f)); } } } while (GetQueueSize() > 0) { string queuedOre = GetQueuedOre(); RemoveOneOre(); ItemConversion itemConversion = GetItemConversion(queuedOre); if (itemConversion != null) { Vector3 val = ((Component)this).transform.position + Vector3.up + Random.insideUnitSphere * 0.3f; Quaternion val2 = Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f); Object.Instantiate(((Component)itemConversion.m_from).gameObject, val, val2); } } } private void OnDestroyed() { if (m_nview.IsOwner()) { DropAllItems(); } } private bool IsItemAllowed(ItemData item) { return IsItemAllowed(((Object)item.m_dropPrefab).name); } private bool IsItemAllowed(string itemName) { foreach (ItemConversion item in m_conversion) { if (((Object)((Component)item.m_from).gameObject).name == itemName) { return true; } } return false; } private ItemData FindCookableItem(Inventory inventory) { foreach (ItemConversion item2 in m_conversion) { ItemData item = inventory.GetItem(((Object)((Component)item2.m_from).gameObject).name, -1, true); if (item != null) { return item; } } return null; } private bool OnAddWood(Switch sw, Humanoid user, ItemData item) { if (item == null) { item = FindCookableItem(user.GetInventory()); if (item == null) { ((Character)user).Message((MessageType)2, "$msg_noprocessableitems", 0, (Sprite)null); return false; } } if (!IsItemAllowed(((Object)item.m_dropPrefab).name)) { ((Character)user).Message((MessageType)2, "$msg_wontwork", 0, (Sprite)null); return false; } ZLog.Log((object)("trying to add " + item.m_shared.m_name)); if (GetQueueSize() >= m_maxOre) { ((Character)user).Message((MessageType)2, "$msg_itsfull", 0, (Sprite)null); return false; } ((Character)user).Message((MessageType)2, "$msg_added " + item.m_shared.m_name, 0, (Sprite)null); user.GetInventory().RemoveItem(item, 1); m_nview.InvokeRPC("AddWood", new object[1] { ((Object)item.m_dropPrefab).name }); m_addedOreTime = Time.time; if ((double)m_addOreAnimationDuration > 0.0) { SetAnimation(active: true); } return true; } private float GetBakeTimer() { return m_nview.GetZDO().GetFloat(ZDOVars.s_bakeTimer, 0f); } private void SetBakeTimer(float t) { m_nview.GetZDO().Set(ZDOVars.s_bakeTimer, t); } private float GetFuel() { return m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f); } private void SetFuel(float fuel) { m_nview.GetZDO().Set(ZDOVars.s_fuel, fuel); } private int GetQueueSize() { return m_nview.GetZDO().GetInt(ZDOVars.s_queued, 0); } private void RPC_AddWood(long sender, string name) { //IL_004d: 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) if (m_nview.IsOwner()) { if (!IsItemAllowed(name)) { ZLog.Log((object)("Item not allowed " + name)); return; } QueueOre(name); m_oreAddedEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1); ZLog.Log((object)("Added ore " + name)); } } private void QueueOre(string name) { int queueSize = GetQueueSize(); m_nview.GetZDO().Set("item" + queueSize, name); m_nview.GetZDO().Set(ZDOVars.s_queued, queueSize + 1, false); } private string GetQueuedOre() { return (GetQueueSize() == 0) ? "" : m_nview.GetZDO().GetString(ZDOVars.s_item0, ""); } private void RemoveOneOre() { int queueSize = GetQueueSize(); if (queueSize != 0) { for (int i = 0; i < queueSize; i++) { string @string = m_nview.GetZDO().GetString("item" + (i + 1), ""); m_nview.GetZDO().Set("item" + i, @string); } m_nview.GetZDO().Set(ZDOVars.s_queued, queueSize - 1, false); } } private bool OnEmpty(Switch sw, Humanoid user, ItemData item) { if (GetProcessedQueueSize() <= 0) { return false; } m_nview.InvokeRPC("ConverterEmptyProcessed", Array.Empty()); return true; } private void RPC_ConverterEmptyProcessed(long sender) { if (m_nview.IsOwner()) { SpawnProcessed(); } } private bool OnAddPowerSource(Switch sw, Humanoid user, ItemData item) { if (item != null && item.m_shared.m_name != m_fuelItem.m_itemData.m_shared.m_name) { ((Character)user).Message((MessageType)2, "$msg_wrongitem", 0, (Sprite)null); return false; } if ((double)GetFuel() > (double)(m_maxFuel - 1)) { ((Character)user).Message((MessageType)2, "$msg_itsfull", 0, (Sprite)null); return false; } if (!user.GetInventory().HaveItem(m_fuelItem.m_itemData.m_shared.m_name, true)) { ((Character)user).Message((MessageType)2, "$msg_donthaveany " + m_fuelItem.m_itemData.m_shared.m_name, 0, (Sprite)null); return false; } ((Character)user).Message((MessageType)2, "$msg_added " + m_fuelItem.m_itemData.m_shared.m_name, 0, (Sprite)null); user.GetInventory().RemoveItem(m_fuelItem.m_itemData.m_shared.m_name, 1, -1, true); m_nview.InvokeRPC("AddPowerSource", Array.Empty()); return true; } private void RPC_AddPowerSource(long sender) { //IL_0034: 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) if (m_nview.IsOwner()) { SetFuel(GetFuel() + 1f); m_fuelAddedEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform, 1f, -1); } } private double GetDeltaTime() { DateTime time = ZNet.instance.GetTime(); DateTime dateTime = new DateTime(m_nview.GetZDO().GetLong(ZDOVars.s_startTime, time.Ticks)); double totalSeconds = (time - dateTime).TotalSeconds; m_nview.GetZDO().Set(ZDOVars.s_startTime, time.Ticks); return totalSeconds; } private float GetAccumulator() { return m_nview.GetZDO().GetFloat(ZDOVars.s_accTime, 0f); } private void SetAccumulator(float t) { m_nview.GetZDO().Set(ZDOVars.s_accTime, t); } private void UpdateRoof() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (m_requiresRoof) { m_haveRoof = Cover.IsUnderRoof(m_roofCheckPoint.position); } } private void UpdateSmoke() { if ((Object)(object)m_smokeSpawner != (Object)null) { m_blockedSmoke = m_smokeSpawner.IsBlocked(); } else { m_blockedSmoke = false; } } private void UpdateBalrondConverter() { if (!m_nview.IsValid()) { return; } UpdateRoof(); UpdateSmoke(); UpdateState(); if (!m_nview.IsOwner()) { return; } double deltaTime = GetDeltaTime(); float num = GetAccumulator() + (float)deltaTime; if ((double)num > 3600.0) { num = 3600f; } float num2 = (Object.op_Implicit((Object)(object)m_windmill) ? m_windmill.GetPowerOutput() : 1f); while ((double)num >= 1.0) { num -= 1f; float fuel = GetFuel(); string queuedOre = GetQueuedOre(); if ((m_maxFuel != 0 && !((double)fuel > 0.0)) || (m_maxOre != 0 && !(queuedOre != "")) || !((double)m_secPerProduct > 0.0) || (m_requiresRoof && !m_haveRoof) || m_blockedSmoke) { continue; } float num3 = 1f * num2; if (m_maxFuel > 0) { float num4 = m_secPerProduct / m_fuelPerProduct; float num5 = fuel - num3 / num4; if ((double)num5 < 9.99999974737875E-05) { num5 = 0f; } SetFuel(num5); } if (queuedOre != "") { float num6 = GetBakeTimer() + num3; SetBakeTimer(num6); if ((double)num6 >= (double)m_secPerProduct) { SetBakeTimer(0f); RemoveOneOre(); QueueProcessed(queuedOre); } } } if (GetQueuedOre() == "" || ((double)m_maxFuel > 0.0 && (double)GetFuel() == 0.0)) { SpawnProcessed(); } SetAccumulator(num); } private void QueueProcessed(string ore) { if (!m_spawnStack) { Spawn(ore, 1); return; } string @string = m_nview.GetZDO().GetString(ZDOVars.s_spawnOre, ""); int @int = m_nview.GetZDO().GetInt(ZDOVars.s_spawnAmount, 0); if (@string.Length > 0) { if (@string != ore) { SpawnProcessed(); m_nview.GetZDO().Set(ZDOVars.s_spawnOre, ore); m_nview.GetZDO().Set(ZDOVars.s_spawnAmount, 1, false); return; } ItemConversion itemConversion = GetItemConversion(ore); int num = @int + itemConversion.m_count; if (itemConversion == null || num >= itemConversion.m_to.m_itemData.m_shared.m_maxStackSize) { Spawn(ore, num); m_nview.GetZDO().Set(ZDOVars.s_spawnOre, ""); m_nview.GetZDO().Set(ZDOVars.s_spawnAmount, 0, false); } else { m_nview.GetZDO().Set(ZDOVars.s_spawnAmount, num, false); } } else { m_nview.GetZDO().Set(ZDOVars.s_spawnOre, ore); m_nview.GetZDO().Set(ZDOVars.s_spawnAmount, 1, false); } } private void SpawnProcessed() { int @int = m_nview.GetZDO().GetInt(ZDOVars.s_spawnAmount, 0); if (@int > 0) { Spawn(m_nview.GetZDO().GetString(ZDOVars.s_spawnOre, ""), @int); m_nview.GetZDO().Set(ZDOVars.s_spawnOre, ""); m_nview.GetZDO().Set(ZDOVars.s_spawnAmount, 0, false); } } private int GetProcessedQueueSize() { return m_nview.GetZDO().GetInt(ZDOVars.s_spawnAmount, 0); } private void Spawn(string ore, int stack) { //IL_001f: 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_004d: 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) ItemConversion itemConversion = GetItemConversion(ore); if (itemConversion != null) { m_produceEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1); Object.Instantiate(((Component)itemConversion.m_to).gameObject, m_outputPoint.position, m_outputPoint.rotation).GetComponent().m_itemData.m_stack = stack; } } private ItemConversion GetItemConversion(string itemName) { foreach (ItemConversion item in m_conversion) { if (((Object)((Component)item.m_from).gameObject).name == itemName) { return item; } } return null; } private void UpdateState() { bool flag = IsActive(); m_enabledObject.SetActive(flag); if (Object.op_Implicit((Object)(object)m_disabledObject)) { m_disabledObject.SetActive(!flag); } if (Object.op_Implicit((Object)(object)m_haveFuelObject)) { m_haveFuelObject.SetActive((double)GetFuel() > 0.0 && !flag); } if (Object.op_Implicit((Object)(object)m_haveOreObject)) { m_haveOreObject.SetActive(GetQueueSize() > 0); } if (Object.op_Implicit((Object)(object)m_noOreObject)) { m_noOreObject.SetActive(GetQueueSize() == 0); } if ((double)m_addOreAnimationDuration > 0.0 && (double)Time.time - (double)m_addedOreTime < (double)m_addOreAnimationDuration) { flag = true; } SetAnimation(flag); } private void SetAnimation(bool active) { Animator[] animators = m_animators; foreach (Animator val in animators) { if (((Component)val).gameObject.activeInHierarchy) { val.SetBool("active", active); val.SetFloat("activef", active ? 1f : 0f); } } } public bool IsActive() { return (m_maxFuel == 0 || (double)GetFuel() > 0.0) && (m_maxOre == 0 || GetQueueSize() > 0) && (!m_requiresRoof || m_haveRoof) && !m_blockedSmoke; } private string OnHoverAddPowerSource() { return Localization.instance.Localize($"{m_name} ({m_fuelItem.m_itemData.m_shared.m_name} {Mathf.Ceil(GetFuel())}/{m_maxFuel})\n[$KEY_Use] Add {m_fuelItem.m_itemData.m_shared.m_name}"); } private string OnHoverEmptyOre() { return Localization.instance.Localize($"{m_name} ({GetProcessedQueueSize()} Ready) \n[$KEY_Use] {m_emptyOreTooltip}"); } private string OnHoverAddWood() { m_sb.Clear(); m_sb.Append($"{m_name} ({GetQueueSize()}/{m_maxOre}) "); if (m_requiresRoof && !m_haveRoof && (double)Mathf.Sin(Time.time * 10f) > 0.0) { m_sb.Append(" $piece_BalrondConverter_reqroof"); } m_sb.Append("\n[$KEY_Use] " + m_addOreTooltip); return Localization.instance.Localize(m_sb.ToString()); } } public class DatabaseAddMethods { public void AddItems(List items) { foreach (GameObject item in items) { AddItem(item); } } public void AddRecipes(List recipes) { foreach (Recipe recipe in recipes) { AddRecipe(recipe); } } public void AddStatuseffects(List statusEffects) { foreach (StatusEffect statusEffect in statusEffects) { AddStatus(statusEffect); } } private bool IsObjectDBValid() { return (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0 && ObjectDB.instance.m_recipes.Count != 0 && (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null; } private void AddStatus(StatusEffect status) { if (!IsObjectDBValid()) { return; } if ((Object)(object)status != (Object)null) { if ((Object)(object)ObjectDB.instance.GetStatusEffect(status.m_nameHash) == (Object)null) { ObjectDB.instance.m_StatusEffects.Add(status); } else { Debug.Log((object)(Launch.projectName + ": " + ((Object)status).name + " - Status already in the game")); } } else { Debug.LogError((object)(Launch.projectName + ": " + ((Object)status).name + " - Status not found")); } } private void AddRecipe(Recipe recipe) { if (!IsObjectDBValid()) { return; } if ((Object)(object)recipe != (Object)null) { if ((Object)(object)ObjectDB.instance.m_recipes.Find((Recipe x) => ((Object)x).name == ((Object)recipe).name) == (Object)null) { if ((Object)(object)recipe.m_item != (Object)null) { ObjectDB.instance.m_recipes.Add(recipe); } } else { Debug.Log((object)(Launch.projectName + ": " + ((Object)recipe).name + " - Recipe with this name already in the Game")); } } else { Debug.LogError((object)(Launch.projectName + ": " + ((Object)recipe).name + " - Recipe not found")); } } private void AddItem(GameObject newPrefab) { if (!IsObjectDBValid()) { return; } ItemDrop component = newPrefab.GetComponent(); if ((Object)(object)component != (Object)null) { if ((Object)(object)ObjectDB.instance.GetItemPrefab(((Object)newPrefab).name) == (Object)null) { ObjectDB.instance.m_items.Add(newPrefab); Dictionary dictionary = (Dictionary)typeof(ObjectDB).GetField("m_itemByHash", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ObjectDB.instance); dictionary[((Object)newPrefab).name.GetHashCode()] = newPrefab; } else { Debug.LogWarning((object)(Launch.projectName + ": " + ((Object)newPrefab).name + " - ItemDrop already exist")); } } else { Debug.LogError((object)(Launch.projectName + ": " + ((Object)newPrefab).name + " - ItemDrop not found on prefab")); } } } public class FxReplacment { private List allPrefabs; private string projectName = Launch.projectName; public void setInstance(List gameObjects) { allPrefabs = gameObjects; } public void ReplaceOnObject(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return; } SpawnArea component = gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { EffectList spawnEffects = component.m_spawnEffects; if (spawnEffects != null) { findEffectsAndChange(spawnEffects.m_effectPrefabs); } } Destructible component2 = gameObject.GetComponent(); if ((Object)(object)component2 != (Object)null) { EffectList hitEffect = component2.m_hitEffect; if (hitEffect != null) { findEffectsAndChange(hitEffect.m_effectPrefabs); } EffectList destroyedEffect = component2.m_destroyedEffect; if (destroyedEffect != null) { findEffectsAndChange(destroyedEffect.m_effectPrefabs); } } Projectile component3 = gameObject.GetComponent(); if ((Object)(object)component3 != (Object)null) { EffectList hitEffects = component3.m_hitEffects; if (hitEffects != null) { findEffectsAndChange(hitEffects.m_effectPrefabs); } EffectList hitWaterEffects = component3.m_hitWaterEffects; if (hitWaterEffects != null) { findEffectsAndChange(hitWaterEffects.m_effectPrefabs); } EffectList spawnOnHitEffects = component3.m_spawnOnHitEffects; if (spawnOnHitEffects != null) { findEffectsAndChange(spawnOnHitEffects.m_effectPrefabs); } } } public void ReplaceOnVegetation(GameObject gameObject) { Pickable component = gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { fixPlant(component); } Destructible component2 = gameObject.GetComponent(); if ((Object)(object)component2 != (Object)null) { fixPDestructable(component2); } MineRock5 component3 = gameObject.GetComponent(); if ((Object)(object)component3 != (Object)null) { fixMineRock5(component3); } MineRock component4 = gameObject.GetComponent(); if ((Object)(object)component4 != (Object)null) { fixMineRock(component4); } } private void fixPlant(Pickable pickable) { EffectList pickEffector = pickable.m_pickEffector; if (pickEffector != null) { findEffectsAndChange(pickEffector.m_effectPrefabs); } } private void fixPDestructable(Destructible minerock5) { EffectList hitEffect = minerock5.m_hitEffect; if (hitEffect != null) { findEffectsAndChange(hitEffect.m_effectPrefabs); } EffectList destroyedEffect = minerock5.m_destroyedEffect; if (destroyedEffect != null) { findEffectsAndChange(destroyedEffect.m_effectPrefabs); } } private void fixMineRock5(MineRock5 minerock5) { EffectList hitEffect = minerock5.m_hitEffect; if (hitEffect != null) { findEffectsAndChange(hitEffect.m_effectPrefabs); } EffectList destroyedEffect = minerock5.m_destroyedEffect; if (destroyedEffect != null) { findEffectsAndChange(destroyedEffect.m_effectPrefabs); } } private void fixMineRock(MineRock minerock5) { EffectList hitEffect = minerock5.m_hitEffect; if (hitEffect != null) { findEffectsAndChange(hitEffect.m_effectPrefabs); } EffectList destroyedEffect = minerock5.m_destroyedEffect; if (destroyedEffect != null) { findEffectsAndChange(destroyedEffect.m_effectPrefabs); } } public void ReplaceOnMonster(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { Debug.LogWarning((object)(projectName + ":: GameObject not found")); return; } Humanoid component = gameObject.GetComponent(); if ((Object)(object)component == (Object)null) { Debug.LogWarning((object)(projectName + ":: GameObject not found")); return; } EffectList dropEffects = component.m_dropEffects; if (dropEffects != null) { findEffectsAndChange(dropEffects.m_effectPrefabs); } EffectList backstabHitEffects = ((Character)component).m_backstabHitEffects; if (backstabHitEffects != null) { findEffectsAndChange(backstabHitEffects.m_effectPrefabs); } EffectList consumeItemEffects = component.m_consumeItemEffects; if (consumeItemEffects != null) { findEffectsAndChange(consumeItemEffects.m_effectPrefabs); } EffectList critHitEffects = ((Character)component).m_critHitEffects; if (critHitEffects != null) { findEffectsAndChange(critHitEffects.m_effectPrefabs); } EffectList deathEffects = ((Character)component).m_deathEffects; if (deathEffects != null) { findEffectsAndChange(deathEffects.m_effectPrefabs); } EffectList hitEffects = ((Character)component).m_hitEffects; if (hitEffects != null) { findEffectsAndChange(hitEffects.m_effectPrefabs); } EffectList jumpEffects = ((Character)component).m_jumpEffects; if (jumpEffects != null) { findEffectsAndChange(jumpEffects.m_effectPrefabs); } EffectList perfectBlockEffect = component.m_perfectBlockEffect; if (perfectBlockEffect != null) { findEffectsAndChange(perfectBlockEffect.m_effectPrefabs); } EffectList pickupEffects = component.m_pickupEffects; if (pickupEffects != null) { findEffectsAndChange(pickupEffects.m_effectPrefabs); } EffectList slideEffects = ((Character)component).m_slideEffects; if (slideEffects != null) { findEffectsAndChange(slideEffects.m_effectPrefabs); } EffectList tarEffects = ((Character)component).m_tarEffects; if (tarEffects != null) { findEffectsAndChange(tarEffects.m_effectPrefabs); } EffectList waterEffects = ((Character)component).m_waterEffects; if (waterEffects != null) { findEffectsAndChange(waterEffects.m_effectPrefabs); } FootStep component2 = gameObject.GetComponent(); if (!((Object)(object)component2 != (Object)null)) { return; } List effects = component2.m_effects; foreach (StepEffect item in effects) { GameObject[] effectPrefabs = item.m_effectPrefabs; List list = new List(); list.AddRange(effectPrefabs); for (int i = 0; i < list.Count; i++) { if ((Object)(object)list[i] != (Object)null) { string name = ((Object)list[i]).name; GameObject val = allPrefabs.Find((GameObject x) => ((Object)x).name == name); if (!((Object)(object)val == (Object)null)) { list[i] = val; } } } } } public void ReplaceOnItem(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return; } ItemDrop component = gameObject.GetComponent(); if (!((Object)(object)component == (Object)null)) { EffectList hitEffect = component.m_itemData.m_shared.m_hitEffect; if (hitEffect != null) { findEffectsAndChange(hitEffect.m_effectPrefabs); } EffectList hitTerrainEffect = component.m_itemData.m_shared.m_hitTerrainEffect; if (hitTerrainEffect != null) { findEffectsAndChange(hitTerrainEffect.m_effectPrefabs); } EffectList holdStartEffect = component.m_itemData.m_shared.m_holdStartEffect; if (holdStartEffect != null) { findEffectsAndChange(holdStartEffect.m_effectPrefabs); } EffectList trailStartEffect = component.m_itemData.m_shared.m_trailStartEffect; if (trailStartEffect != null) { findEffectsAndChange(trailStartEffect.m_effectPrefabs); } EffectList blockEffect = component.m_itemData.m_shared.m_blockEffect; if (blockEffect != null) { findEffectsAndChange(blockEffect.m_effectPrefabs); } } } public void ReplaceFxOnPiece(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return; } Piece component = gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { EffectList placeEffect = component.m_placeEffect; if (placeEffect != null) { findEffectsAndChange(placeEffect.m_effectPrefabs); } } WearNTear component2 = gameObject.GetComponent(); if ((Object)(object)component2 != (Object)null) { EffectList hitEffect = component2.m_hitEffect; if (hitEffect != null) { findEffectsAndChange(hitEffect.m_effectPrefabs); } } } private void findEffectsAndChange(EffectData[] effects) { if (effects == null || effects.Length == 0) { return; } foreach (EffectData val in effects) { if ((Object)(object)val.m_prefab != (Object)null) { string name = ((Object)val.m_prefab).name; GameObject val2 = allPrefabs.Find((GameObject x) => ((Object)x).name == name); if (!((Object)(object)val2 == (Object)null)) { val.m_prefab = val2; } } } } } public class ModResourceLoader { public AssetBundle assetBundle; public List buildPrefabs = new List(); public List plantPrefabs = new List(); public List itemPrefabs = new List(); public List monsterPrefabs = new List(); public List vegetationPrefabs = new List(); public List clutterPrefabs = new List(); public List locationPrefabs = new List(); public List roomPrefabs = new List(); public List vfxPrefabs = new List(); public List instructions = new List(); public List recipes = new List(); public List statusEffects = new List(); public StatusEffect newBarleyStatus = null; public ShaderReplacment shaderReplacment = new ShaderReplacment(); public Sprite newLogo = null; public void loadAssets() { assetBundle = GetAssetBundleFromResources("balrondconstructions"); string basePath = "Assets/Custom/BalrondConstructions/"; loadPieces(basePath); loadOther(basePath); loadInstructions(basePath); } public void AddPrefabsToZnetScene(ZNetScene zNetScene) { zNetScene.m_prefabs.AddRange(vegetationPrefabs); foreach (GameObject gm in itemPrefabs) { GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)gm).name); if ((Object)(object)val == (Object)null) { zNetScene.m_prefabs.Add(gm); } else { Debug.LogWarning((object)("Object exists: " + ((Object)gm).name)); } } foreach (GameObject gm2 in buildPrefabs) { GameObject val2 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)gm2).name); if ((Object)(object)val2 == (Object)null) { zNetScene.m_prefabs.Add(gm2); } else { Debug.LogWarning((object)("Object exists: " + ((Object)gm2).name)); } } foreach (GameObject gm3 in vfxPrefabs) { GameObject val3 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)gm3).name); if ((Object)(object)val3 == (Object)null) { zNetScene.m_prefabs.Add(gm3); } else { Debug.LogWarning((object)("Object exists: " + ((Object)gm3).name)); } } zNetScene.m_prefabs.RemoveAll((GameObject x) => (Object)(object)x == (Object)null); addPlantstoCultivator(zNetScene); setupBuildPiecesList(zNetScene); } private void setupBuildPiecesList(ZNetScene zNetScene) { string[] array = new string[4] { "Hammer", "HammerIron", "HammerDverger", "HammerBlackmetal" }; GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Hammer"); PieceTable buildPieces = val.GetComponent().m_itemData.m_shared.m_buildPieces; string[] array2 = array; foreach (string name in array2) { addBuildpiecesToOtherHammer(name, buildPieces, zNetScene); } List pieces = buildPieces.m_pieces; foreach (GameObject buildPrefab in buildPrefabs) { setupRavenGuide(buildPrefab, zNetScene.m_prefabs); AddToBuildList(buildPrefab, pieces); } } private void addBuildpiecesToOtherHammer(string name, PieceTable pieceTable, ZNetScene zNetScene) { GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == name); if (!((Object)(object)val == (Object)null)) { val.GetComponent().m_itemData.m_shared.m_buildPieces = pieceTable; } } public void setupRavenGuide(GameObject gameObject, List gameObjects) { GameObject val = null; Transform val2 = gameObject.transform.Find("GuidePoint"); if ((Object)(object)val2 == (Object)null) { return; } GameObject val3 = gameObjects.Find((GameObject x) => ((Object)x).name == "piece_workbench"); if ((Object)(object)val3 != (Object)null) { GameObject gameObject2 = ((Component)val3.transform.Find("GuidePoint")).gameObject; if ((Object)(object)gameObject2 != (Object)null) { GuidePoint component = gameObject2.GetComponent(); if ((Object)(object)component != (Object)null) { val = component.m_ravenPrefab; } } } if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)"Ravens not found"); } else { ((Component)val2).GetComponent().m_ravenPrefab = val; } } public void setupBuildPiecesListDB() { GameObject val = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "Hammer"); List pieces = val.GetComponent().m_itemData.m_shared.m_buildPieces.m_pieces; foreach (GameObject buildPrefab in buildPrefabs) { AddToBuildList(buildPrefab, pieces); } } private void AddToBuildList(GameObject prefab, List buildPieces) { if ((Object)(object)buildPieces.Find((GameObject x) => ((Object)x).name == ((Object)prefab).name) == (Object)null) { buildPieces.Add(prefab); } } private void addPlantstoCultivator(ZNetScene zNetScene) { GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Cultivator"); PieceTable buildPieces = val.GetComponent().m_itemData.m_shared.m_buildPieces; List pieces = buildPieces.m_pieces; foreach (GameObject plantPrefab in plantPrefabs) { pieces.Add(plantPrefab); } } private void loadStatusFromPotion() { string[] source = new string[0]; foreach (GameObject itemPrefab in itemPrefabs) { if (source.Contains(((Object)itemPrefab).name)) { ItemDrop component = itemPrefab.GetComponent(); SharedData shared = component.m_itemData.m_shared; checkForStatus(shared.m_consumeStatusEffect); checkForStatus(shared.m_setStatusEffect); checkForStatus(shared.m_equipStatusEffect); checkForStatus(shared.m_attackStatusEffect); } } Debug.Log((object)("Loaded Potion status: " + statusEffects.Count)); } private void checkForStatus(StatusEffect status) { if ((Object)(object)status != (Object)null) { statusEffects.Add(status); } } private AssetBundle GetAssetBundleFromResources(string filename) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename)); using Stream stream = executingAssembly.GetManifestResourceStream(name); return AssetBundle.LoadFromStream(stream); } private void loadPlants(string basePath) { string text = basePath + "Plants/"; string[] array = new string[0]; string[] array2 = array; foreach (string text2 in array2) { GameObject val = assetBundle.LoadAsset(text + text2 + ".prefab"); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("Could not find plant with name: " + text2)); continue; } ShaderReplacment.Replace(val); plantPrefabs.Add(val); } } private void loadPieces(string basePath) { string text = basePath + "Pieces/"; string[] buildPieces = BuildPieceList.buildPieces; string[] array = buildPieces; foreach (string text2 in array) { GameObject val = assetBundle.LoadAsset(text + text2 + ".prefab"); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("Could not find piece with name: " + text2)); continue; } ShaderReplacment.Replace(val); buildPrefabs.Add(val); } } private void loadInstructions(string basePath) { string text = basePath + "Instructions/"; string[] buildPieces = BuildPieceList.buildPieces; } private void loadItems(string basePath) { string text = basePath + "Items/"; string[] array = new string[0]; string[] array2 = array; foreach (string text2 in array2) { GameObject val = assetBundle.LoadAsset(text + text2 + ".prefab"); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("Could not find item with name: " + text2)); continue; } ShaderReplacment.Replace(val); itemPrefabs.Add(val); } } private void loadVegetation(string basePath) { string text = basePath + "Vegetation/"; string[] array = new string[0]; string[] array2 = array; foreach (string text2 in array2) { GameObject val = assetBundle.LoadAsset(text + text2 + ".prefab"); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("Could not find vegegation with name: " + text2)); continue; } ShaderReplacment.Replace(val); vegetationPrefabs.Add(val); } } private void loadOther(string basePath) { string text = basePath + "Other/"; string[] array = new string[1] { "sfx_queendoor_open1" }; string[] array2 = array; foreach (string text2 in array2) { GameObject val = assetBundle.LoadAsset(text + text2 + ".prefab"); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("Could not find object with name: " + text2)); continue; } ShaderReplacment.Replace(val); vfxPrefabs.Add(val); } } public void setupBlessedStone(ZNetScene zNetScene) { GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Blessed_Stone_Odin"); OfferingStation offeringStation = val.AddComponent(); offeringStation.m_aoePrefab = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Blessing_Aoe"); offeringStation.m_canBeOutside = true; offeringStation.m_requireFire = false; offeringStation.m_requiresRoof = false; offeringStation.m_requiredItem = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Iron").GetComponent(); offeringStation.m_requiredItemAmount = 2; offeringStation.m_spawnPoint = ((Component)val.transform.Find("spawnpoint")).gameObject; List list = new List(); list.AddRange(offeringStation.m_fuelAddedEffects.m_effectPrefabs); list.Add(createEffectListEffectData(zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "vfx_pray_accepted"))); offeringStation.m_fuelAddedEffects.m_effectPrefabs = list.ToArray(); List list2 = new List(); list2.AddRange(offeringStation.m_spawnFinishEffects.m_effectPrefabs); list2.Add(createEffectListEffectData(zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "fx_Blessing"))); offeringStation.m_spawnFinishEffects.m_effectPrefabs = list2.ToArray(); } public EffectData createEffectListEffectData(GameObject prefab) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown EffectData val = new EffectData(); val.m_prefab = prefab; val.m_variant = -1; val.m_enabled = true; return val; } public void setIronHook(ZNetScene zNetScene) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "piece_cookingstation_iron"); GameObject val2 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "piece_cookingstation"); ItemConversion val3 = new ItemConversion(); val3.m_from = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "BearMeat").GetComponent(); val3.m_to = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "BearMeatCooked").GetComponent(); val3.m_cookTime = 40f; ItemConversion val4 = new ItemConversion(); val4.m_from = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Potato").GetComponent(); val4.m_to = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "PotatoFried").GetComponent(); val4.m_cookTime = 30f; if ((Object)(object)val != (Object)null) { CookingStation component = val.GetComponent(); component.m_conversion.Add(val4); component.m_conversion.Add(val3); } if ((Object)(object)val2 != (Object)null) { CookingStation component2 = val2.GetComponent(); component2.m_conversion.Add(val4); component2.m_conversion.Add(val3); } } public void setupPickableDrops(ZNetScene zNetScene) { GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Pickable_MeadowsMeatPile01"); GameObject val2 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Pickable_MeadowsMeatPile02"); Pickable component = val.GetComponent(); Pickable component2 = val2.GetComponent(); GameObject item = getItem(zNetScene, "RawMeat"); if ((Object)(object)item != (Object)null) { component.m_itemPrefab = item; component2.m_itemPrefab = item; } createExtraDrops(component, zNetScene); createExtraDrops(component2, zNetScene); } private void createExtraDrops(Pickable pickable, ZNetScene zNetScene) { //IL_0043: 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_0077: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) List list = new List(); string name = ((Object)((Component)pickable).gameObject).name; string text = name; if (!(text == "Pickable_MeadowsMeatPile01")) { if (text == "Pickable_MeadowsMeatPile02") { list.Add(createDrop(zNetScene, "RawMeat", 1, 1, 0.4f)); list.Add(createDrop(zNetScene, "Coins", 5, 15, 0.2f)); list.Add(createDrop(zNetScene, "BoneFragments", 1, 3, 0.2f)); list.Add(createDrop(zNetScene, "NeckTail", 1, 2, 0.3f)); } } else { list.Add(createDrop(zNetScene, "RawMeat", 1, 1, 0.4f)); list.Add(createDrop(zNetScene, "DeerMeat", 1, 1, 0.2f)); list.Add(createDrop(zNetScene, "NeckTail", 1, 2, 0.3f)); list.Add(createDrop(zNetScene, "Honey", 1, 2, 0.1f)); } pickable.m_extraDrops.m_drops = list; } private DropData createDrop(ZNetScene zNetScene, string name, int min, int max, float chance) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) DropData result = default(DropData); result.m_stackMin = min; result.m_stackMax = max; result.m_weight = chance; result.m_item = getItem(zNetScene, name); return result; } private GameObject getItem(ZNetScene zNetScene, string name) { return zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == name); } public void setBalrondConverter(ZNetScene zNetScene) { GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "piece_sawmill"); GameObject val2 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "piece_leatherRack"); if ((Object)(object)val.GetComponent() == (Object)null) { Debug.LogWarning((object)"Setting up Sawmill"); transferSmelterToBalrondConverter(val, zNetScene); } if ((Object)(object)val2.GetComponent() == (Object)null) { Debug.LogWarning((object)"Setting up Leather Rack"); transferSmelterToBalrondConverter(val2, zNetScene); } } private void transferSmelterToBalrondConverter(GameObject gameObject, ZNetScene zNetScene) { Smelter component = gameObject.GetComponent(); BalrondConverter balrondConverter = gameObject.AddComponent(); balrondConverter.m_addOreAnimationDuration = 0f; balrondConverter.m_addOreSwitch = component.m_addOreSwitch; balrondConverter.m_addOreTooltip = component.m_addOreTooltip; balrondConverter.m_addWoodSwitch = component.m_addWoodSwitch; balrondConverter.m_animators = component.m_animators; balrondConverter.m_disabledObject = component.m_disabledObject; balrondConverter.m_emptyOreSwitch = component.m_emptyOreSwitch; balrondConverter.m_emptyOreTooltip = component.m_emptyOreTooltip; balrondConverter.m_enabledObject = component.m_enabledObject; balrondConverter.m_fuelAddedEffects = component.m_fuelAddedEffects; balrondConverter.m_fuelItem = component.m_fuelItem; balrondConverter.m_fuelPerProduct = component.m_fuelPerProduct; balrondConverter.m_haveFuelObject = component.m_haveFuelObject; balrondConverter.m_haveOreObject = component.m_haveOreObject; balrondConverter.m_maxFuel = component.m_maxFuel; balrondConverter.m_maxOre = component.m_maxOre; balrondConverter.m_name = component.m_name; balrondConverter.m_noOreObject = component.m_noOreObject; balrondConverter.m_oreAddedEffects = component.m_oreAddedEffects; balrondConverter.m_outputPoint = component.m_outputPoint; balrondConverter.m_produceEffects = component.m_produceEffects; balrondConverter.m_requiresRoof = component.m_requiresRoof; balrondConverter.m_roofCheckPoint = component.m_roofCheckPoint; balrondConverter.m_windmill = component.m_windmill; balrondConverter.m_secPerProduct = component.m_secPerProduct; balrondConverter.m_smokeSpawner = component.m_smokeSpawner; balrondConverter.m_spawnStack = component.m_spawnStack; Object.DestroyImmediate((Object)(object)component); if (((Object)gameObject).name == "piece_sawmill") { balrondConverter.m_maxFuel = 1; balrondConverter.m_maxOre = 10; balrondConverter.m_fuelItem = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "SawBlade").GetComponent(); balrondConverter.m_fuelPerProduct = 0.01f; balrondConverter.prefabName = "piece_sawmill"; } if (((Object)gameObject).name == "piece_leatherRack") { balrondConverter.m_maxFuel = 10; balrondConverter.m_maxOre = 10; balrondConverter.m_fuelItem = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "IronNails").GetComponent(); balrondConverter.m_fuelPerProduct = 1f; balrondConverter.prefabName = "piece_leatherRack"; } } public static List ShuffleIntList(List list) { Random random = new Random(); List list2 = new List(); int count = list.Count; for (int i = 0; i < count; i++) { int index = random.Next(0, list.Count); list2.Add(list[index]); list.Remove(list[index]); } return list2; } } public class ShaderReplacment { public static List prefabsToReplaceShader = new List(); public static List materialsInPrefabs = new List(); public string[] shaderlist = new string[49] { "Custom/AlphaParticle", "Custom/Blob", "Custom/Bonemass", "Custom/Clouds", "Custom/Creature", "Custom/Decal", "Custom/Distortion", "Custom/Flow", "Custom/FlowOpaque", "Custom/Grass", "Custom/GuiScroll", "Custom/Heightmap", "Custom/icon", "Custom/InteriorSide", "Custom/LitGui", "Custom/LitParticles", "Custom/mapshader", "Custom/ParticleDecal", "Custom/Piece", "Custom/Player", "Custom/Rug", "Custom/ShadowBlob", "Custom/SkyboxProcedural", "Custom/SkyObject", "Custom/StaticRock", "Custom/Tar", "Custom/Trilinearmap", "Custom/UI/BGBlur", "Custom/Vegetation", "Custom/Water", "Custom/WaterBottom", "Custom/WaterMask", "Custom/Yggdrasil", "Custom/Yggdrasil/root", "Hidden/BlitCopyHDRTonemap", "Hidden/Dof/DepthOfFieldHdr", "Hidden/Dof/DX11Dof", "Hidden/Internal-Loading", "Hidden/Internal-UIRDefaultWorld", "Hidden/SimpleClear", "Hidden/SunShaftsComposite", "Lux Lit Particles/ Bumped", "Lux Lit Particles/ Tess Bumped", "Particles/Standard Surface2", "Particles/Standard Unlit2", "Standard TwoSided", "ToonDeferredShading2017", "Unlit/DepthWrite", "Unlit/Lighting" }; public static List shaders = new List(); private static readonly HashSet CachedShaders = new HashSet(); public static bool debug = true; public static Shader findShader(string name) { Shader[] array = Resources.FindObjectsOfTypeAll(); if (array.Length == 0) { Debug.LogWarning((object)"SHADER LIST IS EMPTY!"); return null; } if (debug) { } return shaders.Find((Shader x) => ((Object)x).name == name); } public static Shader GetShaderByName(string name) { return shaders.Find((Shader x) => ((Object)x).name == name.Trim()); } public static void debugShaderList(List shadersRes) { foreach (Shader shadersRe in shadersRes) { Debug.LogWarning((object)("SHADER NAME IS: " + ((Object)shadersRe).name)); } debug = false; } public static void Replace(GameObject gameObject) { prefabsToReplaceShader.Add(gameObject); GetMaterialsInPrefab(gameObject); } public static void GetMaterialsInPrefab(GameObject gameObject) { Renderer[] componentsInChildren = gameObject.GetComponentsInChildren(true); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { Material[] sharedMaterials = val.sharedMaterials; if (sharedMaterials == null || sharedMaterials.Length == 0) { continue; } Material[] array2 = sharedMaterials; foreach (Material val2 in array2) { if ((Object)(object)val2 != (Object)null) { materialsInPrefabs.Add(val2); } } } } public static void getMeShaders() { AssetBundle[] array = Resources.FindObjectsOfTypeAll(); AssetBundle[] array2 = array; foreach (AssetBundle val in array2) { IEnumerable enumerable3; try { IEnumerable enumerable2; if (!val.isStreamedSceneAssetBundle || !Object.op_Implicit((Object)(object)val)) { IEnumerable enumerable = val.LoadAllAssets(); enumerable2 = enumerable; } else { enumerable2 = from shader in ((IEnumerable)val.GetAllAssetNames()).Select((Func)val.LoadAsset) where (Object)(object)shader != (Object)null select shader; } enumerable3 = enumerable2; } catch (Exception) { continue; } if (enumerable3 == null) { continue; } foreach (Shader item in enumerable3) { CachedShaders.Add(item); } } } public static void runMaterialFix() { getMeShaders(); shaders.AddRange(CachedShaders); foreach (Material materialsInPrefab in materialsInPrefabs) { Shader shader = materialsInPrefab.shader; if (!((Object)(object)shader == (Object)null)) { string name = ((Object)shader).name; if (!(name == "Standard") && name.Contains("Balrond")) { setProperValue(materialsInPrefab, name); } } } } private static void setProperValue(Material material, string shaderName) { string name = shaderName.Replace("Balrond", "Custom"); name = checkNaming(name); Shader shaderByName = GetShaderByName(name); if ((Object)(object)shaderByName == (Object)null) { Debug.LogWarning((object)("Shader not found " + name)); } else { material.shader = shaderByName; } } private static string checkNaming(string name) { string result = name; if (name.Contains("Bumped")) { result = name.Replace("Custom", "Lux Lit Particles"); } if (name.Contains("Tess Bumped")) { result = name.Replace("Custom", "Lux Lit Particles"); } if (name.Contains("Standard Surface")) { result = name.Replace("Custom", "Particles"); result = result.Replace("Standard Surface2", "Standard Surface"); } if (name.Contains("Standard Unlit")) { result = name.Replace("Custom", "Particles"); result = result.Replace("Standard Unlit", "Standard Unlit2"); result = result.Replace("Standard Unlit22", "Standard Unlit2"); } return result; } } public class TableMapper { public static CraftingStation cauldron; public static CraftingStation workbench; public static CraftingStation heavyWorkbench; public static CraftingStation forge; public static CraftingStation ironworks; public static CraftingStation blackforge; public static CraftingStation stoneCutter; public static CraftingStation artisian; public static CraftingStation magetable; public static CraftingStation runeforge; public static CraftingStation tannery; public static CraftingStation fletcher; public static CraftingStation grill; public static CraftingStation alchemylab; public static List pieces = new List(); public static void setupTables(List list) { pieces = list; prepareTables(); } private static CraftingStation FindStation(List list, string name, CraftingStation alt = null) { GameObject val = list.Find((GameObject x) => ((Object)x).name == name); if ((Object)(object)val != (Object)null) { return val.GetComponent(); } Debug.LogWarning((object)("TableMapper - Station not found: " + name + " using: " + ((Object)alt).name)); if ((Object)(object)alt != (Object)null) { return alt; } return null; } private static void prepareTables() { cauldron = FindStation(pieces, "piece_cauldron"); workbench = FindStation(pieces, "piece_workbench"); heavyWorkbench = FindStation(pieces, "piece_heavy_workbench_bal", workbench); forge = FindStation(pieces, "forge"); ironworks = FindStation(pieces, "piece_metalworks_bal", forge); blackforge = FindStation(pieces, "blackforge"); stoneCutter = FindStation(pieces, "piece_stonecutter"); artisian = FindStation(pieces, "piece_artisanstation"); runeforge = FindStation(pieces, "piece_runeforge_bal", blackforge); magetable = FindStation(pieces, "piece_magetable"); fletcher = FindStation(pieces, "piece_fletcher_bal", workbench); } } public class JsonLoader { public string defaultPath = string.Empty; public void loadJson() { LoadTranslations(); justDefaultPath(); } public void justDefaultPath() { string configPath = Paths.ConfigPath; string text = Path.Combine(configPath, "BalrondConstructions-translation/"); defaultPath = text; } public void createDefaultPath() { string configPath = Paths.ConfigPath; string path = Path.Combine(configPath, "BalrondConstructions-translation/"); if (!Directory.Exists(path)) { CreateFolder(path); } defaultPath = path; } private string[] jsonFilePath(string folderName, string extension) { string configPath = Paths.ConfigPath; string path = Path.Combine(configPath, "BalrondConstructions-translation/"); if (!Directory.Exists(path)) { CreateFolder(path); } return Directory.GetFiles(path, extension); } private static void CreateFolder(string path) { try { Directory.CreateDirectory(path); } catch (Exception ex) { Debug.Log((object)("BalrondConstructions: Error creating folder: " + ex.Message)); } } private void LoadTranslations() { int num = 0; string[] array = jsonFilePath("Translation", "*.json"); foreach (string text in array) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text); string json = File.ReadAllText(text); JsonData jsonData = JsonMapper.ToObject(json); Dictionary dictionary = new Dictionary(); foreach (string key in jsonData.Keys) { dictionary[key] = jsonData[key].ToString(); } if (dictionary != null) { BalrondTranslator.translations.Add(fileNameWithoutExtension, dictionary); num++; } else { Debug.LogError((object)("BalrondConstructions: Loading FAILED file: " + text)); } } } } [BepInPlugin("balrond.astafaraios.BalrondConstructions", "BalrondConstructions", "1.4.0")] public class Launch : BaseUnityPlugin { [HarmonyPatch(typeof(FejdStartup), "SetupGui")] private static class FejdStartup_SetupGUI { private static void Postfix() { try { if (Localization.instance != null) { string selectedLanguage = Localization.instance.GetSelectedLanguage(); Dictionary translations = GetTranslations(selectedLanguage); AddTranslations(translations); } } catch (Exception ex) { if (Log != null) { Log.LogError((object)("FejdStartup.SetupGui Postfix failed: " + ex)); } } } } [HarmonyPriority(800)] [HarmonyPatch(typeof(Localization), "SetupLanguage")] private static class Translation_SetupLanguage { private static void Prefix(Localization __instance, string language) { try { Dictionary translations = GetTranslations(language); AddTranslations(translations, __instance); } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Localization.SetupLanguage Prefix failed: " + ex)); } } } } [HarmonyPriority(800)] [HarmonyPatch(typeof(Localization), "LoadCSV")] private static class Translation_LoadCSV { private static void Prefix(Localization __instance, string language) { try { Dictionary translations = GetTranslations(language); AddTranslations(translations, __instance); } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Localization.LoadCSV Prefix failed: " + ex)); } } } } [HarmonyPatch(typeof(AudioMan), "Awake")] private static class AudioMan_Awake_Patch { private static void Postfix(AudioMan __instance) { try { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.m_masterMixer == (Object)null) { return; } AudioMixerGroup outputAudioMixerGroup = __instance.m_masterMixer.outputAudioMixerGroup; if ((Object)(object)outputAudioMixerGroup == (Object)null) { return; } foreach (List allPrefabGroup in GetAllPrefabGroups()) { if (allPrefabGroup == null) { continue; } foreach (GameObject item in allPrefabGroup) { if ((Object)(object)item == (Object)null) { continue; } AudioSource[] componentsInChildren; try { componentsInChildren = item.GetComponentsInChildren(true); } catch { continue; } if (componentsInChildren == null || componentsInChildren.Length == 0) { continue; } foreach (AudioSource val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { val.outputAudioMixerGroup = outputAudioMixerGroup; } } } } } catch (Exception ex) { if (Log != null) { Log.LogError((object)("AudioMan.Awake Postfix failed: " + ex)); } } } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] public static class Object_CopyOtherDB_Path { public static void Postfix() { try { SafeSetupDatabaseContent(sortRecipes: false); } catch (Exception ex) { if (Log != null) { Log.LogError((object)("ObjectDB.CopyOtherDB Postfix failed: " + ex)); } } } } [HarmonyPatch(typeof(ObjectDB), "Awake")] public static class ObjectDB_Awake_Path { public static void Postfix() { try { SafeSetupDatabaseContent(sortRecipes: true); } catch (Exception ex) { if (Log != null) { Log.LogError((object)("ObjectDB.Awake Postfix failed: " + ex)); } } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] public static class ZNetScene_Awake_Path { public static void Prefix(ZNetScene __instance) { if ((Object)(object)__instance == (Object)null) { Debug.LogWarning((object)(projectName + ": No ZNetScene found")); return; } try { modResourceLoader.AddPrefabsToZnetScene(__instance); } catch (Exception ex) { if (Log != null) { Log.LogError((object)("AddPrefabsToZnetScene failed: " + ex)); } } if (hasSpawned) { return; } try { if (__instance.m_prefabs != null) { buildPieceBuilder.SetupBuildPieces(__instance.m_prefabs); } } catch (Exception ex2) { if (Log != null) { Log.LogError((object)("SetupBuildPieces failed: " + ex2)); } } if (IsDedicatedServer()) { return; } try { ShaderReplacment.runMaterialFix(); } catch (Exception ex3) { if (Log != null) { Log.LogError((object)("runMaterialFix failed: " + ex3)); } } hasSpawned = true; } } public const string PluginGUID = "balrond.astafaraios.BalrondConstructions"; public const string PluginName = "BalrondConstructions"; public const string PluginVersion = "1.4.0"; private static Harmony _harmony; internal static ManualLogSource Log; public static readonly ModResourceLoader modResourceLoader = new ModResourceLoader(); public static readonly DatabaseAddMethods databaseAddMethods = new DatabaseAddMethods(); public static readonly BuildPieceBuilder buildPieceBuilder = new BuildPieceBuilder(); public static readonly JsonLoader jsonLoader = new JsonLoader(); public static GameObject gui; public static GameObject gui2; public static string projectName = "BalrondConstructions"; public static GameObject RootObject; public static GameObject PrefabContainer; public static bool hasSpawned = false; private void Awake() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; try { SafeLoadJson(); CreatePrefabContainer(); SafeLoadAssets(); if (_harmony == null) { _harmony = new Harmony("balrond.astafaraios.BalrondConstructions"); } _harmony.PatchAll(); Log.LogInfo((object)"BalrondConstructions loaded successfully."); } catch (Exception ex) { Log.LogError((object)("Error during Awake: " + ex)); } } private void OnDestroy() { try { if (_harmony != null) { _harmony.UnpatchSelf(); } } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Error during OnDestroy: " + ex)); } } } private static void SafeLoadJson() { try { jsonLoader.loadJson(); } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failed to load JSON data: " + ex)); } } } private static void SafeLoadAssets() { try { modResourceLoader.loadAssets(); } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failed to load assets: " + ex)); } } } public void CreatePrefabContainer() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown try { if ((Object)(object)RootObject == (Object)null) { RootObject = new GameObject("_ValheimReforgedRoot"); Object.DontDestroyOnLoad((Object)(object)RootObject); } if ((Object)(object)PrefabContainer == (Object)null) { PrefabContainer = new GameObject("Prefabs"); PrefabContainer.transform.SetParent(RootObject.transform, false); PrefabContainer.SetActive(false); } } catch (Exception ex) { if (Log != null) { Log.LogError((object)("CreatePrefabContainer failed: " + ex)); } } } public static GameObject cloneMe(GameObject source, string name) { if ((Object)(object)source == (Object)null) { if (Log != null) { Log.LogWarning((object)"cloneMe called with null source."); } return null; } if ((Object)(object)PrefabContainer == (Object)null) { if (Log != null) { Log.LogWarning((object)"cloneMe called but PrefabContainer is null."); } return null; } try { GameObject val = Object.Instantiate(source, PrefabContainer.transform); ((Object)val).name = (string.IsNullOrEmpty(name) ? ((Object)source).name : name); fixMaterials(val, source); val.SetActive(true); return val; } catch (Exception ex) { if (Log != null) { Log.LogError((object)("cloneMe failed: " + ex)); } return null; } } public static GameObject fixMaterials(GameObject clone, GameObject source) { if ((Object)(object)clone == (Object)null || (Object)(object)source == (Object)null) { return clone; } try { MeshRenderer[] componentsInChildren = source.GetComponentsInChildren(true); MeshRenderer[] componentsInChildren2 = clone.GetComponentsInChildren(true); if (componentsInChildren == null || componentsInChildren2 == null || componentsInChildren.Length == 0 || componentsInChildren2.Length == 0) { return clone; } Dictionary dictionary = new Dictionary(StringComparer.Ordinal); foreach (MeshRenderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !string.IsNullOrEmpty(((Object)val).name) && !dictionary.ContainsKey(((Object)val).name)) { dictionary.Add(((Object)val).name, val); } } foreach (MeshRenderer val2 in componentsInChildren2) { if (!((Object)(object)val2 == (Object)null) && !string.IsNullOrEmpty(((Object)val2).name) && dictionary.TryGetValue(((Object)val2).name, out var value) && !((Object)(object)value == (Object)null)) { ((Renderer)val2).materials = ((Renderer)value).sharedMaterials; ((Renderer)val2).sharedMaterials = ((Renderer)value).sharedMaterials; } } } catch (Exception ex) { if (Log != null) { Log.LogError((object)("fixMaterials failed: " + ex)); } } return clone; } private static bool IsObjectDBValid() { try { if ((Object)(object)ObjectDB.instance == (Object)null) { return false; } if (ObjectDB.instance.m_items == null || ObjectDB.instance.m_items.Count == 0) { return false; } if (ObjectDB.instance.m_recipes == null || ObjectDB.instance.m_recipes.Count == 0) { return false; } return (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null; } catch (Exception ex) { if (Log != null) { Log.LogWarning((object)("IsObjectDBValid failed: " + ex)); } return false; } } private static bool IsDedicatedServer() { try { return (Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated(); } catch (Exception ex) { if (Log != null) { Log.LogWarning((object)("Dedicated server check failed: " + ex)); } return false; } } private static Dictionary GetTranslations(string language) { try { Dictionary result = BalrondTranslator.getLanguage("English"); if (!string.IsNullOrEmpty(language) && !string.Equals(language, "English", StringComparison.OrdinalIgnoreCase)) { Dictionary language2 = BalrondTranslator.getLanguage(language); if (language2 != null) { result = language2; } else { Debug.Log((object)("BalrondConstructions: Did not find translation file for '" + language + "', loading English")); } } return result; } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failed to get translations for language '" + language + "': " + ex)); } return null; } } private static void AddTranslations(Dictionary translations, Localization localizationInstance = null) { if (translations == null || translations.Count == 0) { return; } try { Localization val = localizationInstance ?? Localization.instance; if (val == null) { return; } foreach (KeyValuePair translation in translations) { if (!string.IsNullOrEmpty(translation.Key)) { val.AddWord(translation.Key, translation.Value ?? string.Empty); } } } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failed to add translations: " + ex)); } } } private static void SafeSetupDatabaseContent(bool sortRecipes) { if (!IsObjectDBValid()) { return; } try { modResourceLoader.setupBuildPiecesListDB(); } catch (Exception ex) { if (Log != null) { Log.LogError((object)("setupBuildPiecesListDB failed: " + ex)); } } try { if (modResourceLoader.itemPrefabs != null) { databaseAddMethods.AddItems(modResourceLoader.itemPrefabs); } } catch (Exception ex2) { if (Log != null) { Log.LogError((object)("AddItems failed: " + ex2)); } } try { if (modResourceLoader.statusEffects != null) { databaseAddMethods.AddStatuseffects(modResourceLoader.statusEffects); } } catch (Exception ex3) { if (Log != null) { Log.LogError((object)("AddStatuseffects failed: " + ex3)); } } try { if (modResourceLoader.recipes != null) { databaseAddMethods.AddRecipes(modResourceLoader.recipes); } } catch (Exception ex4) { if (Log != null) { Log.LogError((object)("AddRecipes failed: " + ex4)); } } if (!sortRecipes) { return; } try { if ((Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_recipes != null) { ObjectDB.instance.m_recipes.Sort(SortByScore); } } catch (Exception ex5) { if (Log != null) { Log.LogError((object)("Recipe sorting failed: " + ex5)); } } } private static int SortByScore(Recipe p1, Recipe p2) { if (p1 == p2) { return 0; } if ((Object)(object)p1 == (Object)null) { return -1; } if ((Object)(object)p2 == (Object)null) { return 1; } if ((Object)(object)p1.m_item == (Object)null && (Object)(object)p2.m_item == (Object)null) { return 0; } if ((Object)(object)p1.m_item == (Object)null) { return -1; } if ((Object)(object)p2.m_item == (Object)null) { return 1; } string strA = ((Object)p1.m_item).name ?? string.Empty; string strB = ((Object)p2.m_item).name ?? string.Empty; return string.Compare(strA, strB, StringComparison.Ordinal); } private static IEnumerable> GetAllPrefabGroups() { if (modResourceLoader != null) { if (modResourceLoader.itemPrefabs != null) { yield return modResourceLoader.itemPrefabs; } if (modResourceLoader.buildPrefabs != null) { yield return modResourceLoader.buildPrefabs; } if (modResourceLoader.monsterPrefabs != null) { yield return modResourceLoader.monsterPrefabs; } if (modResourceLoader.vfxPrefabs != null) { yield return modResourceLoader.vfxPrefabs; } if (modResourceLoader.vegetationPrefabs != null) { yield return modResourceLoader.vegetationPrefabs; } } } } [Serializable] public class MappedEffectList { public List pieceEffect; public List destroyedEffects; public List hitEffects; public List switchEffect; public List blockEffect; public List equipEffect; public List hitEffect; public List hitTerrainEffect; public List holdStartEffect; public List startEffect; public List trailStartEffect; public List triggerEffect; public List unequipEffect; public EffectList createEffectListFromInfo(List list) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown EffectList val = new EffectList(); List list2 = new List(); val.m_effectPrefabs = list2.ToArray(); return val; } private EffectData createEffectData(EffectInfo info) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown EffectData val = new EffectData(); val.m_inheritParentRotation = info.inheritRotation; val.m_multiplyParentVisualScale = info.multiplyScale; val.m_childTransform = info.childName; val.m_inheritParentScale = info.inheritScale; val.m_variant = info.variant; val.m_scale = info.scale; val.m_attach = info.attach; val.m_follow = info.follow; val.m_prefab = ZNetScene.instance.m_prefabs.Find((GameObject x) => ((Object)x).name == info.name); return val; } } [Serializable] public struct EffectInfo { public string name; public bool enabled; public int variant; public bool attach; public bool follow; public bool inheritRotation; public bool inheritScale; public bool multiplyScale; public bool radnomRotation; public bool scale; public string childName; public EffectInfo(string name, bool enabled = true, int variant = -1, bool attach = false, bool follow = false, bool inheritRotation = false, bool inheritScale = false, bool multiplyScale = false, bool radnomRotation = false, bool scale = false, string childName = null) { this.name = name; this.enabled = enabled; this.variant = variant; this.attach = attach; this.follow = follow; this.inheritRotation = inheritRotation; this.inheritScale = inheritScale; this.multiplyScale = multiplyScale; this.radnomRotation = radnomRotation; this.scale = scale; this.childName = childName; } } public class BuildPieceBuilder { private List list; private string[] piecesNames = BuildPieceList.buildPieces; public void SetupBuildPieces(List list) { TableMapper.setupTables(list); this.list = list; string[] array = piecesNames; foreach (string name in array) { GameObject val = list.Find((GameObject x) => ((Object)x).name == name); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("Cant find buildpiece with name: " + name)); } else { EditBuildPiece(val); } } } private void EditBuildPiece(GameObject gameObject) { //IL_6751: Unknown result type (might be due to invalid IL or missing references) //IL_470f: Unknown result type (might be due to invalid IL or missing references) //IL_5b07: Unknown result type (might be due to invalid IL or missing references) //IL_4849: Unknown result type (might be due to invalid IL or missing references) //IL_581d: Unknown result type (might be due to invalid IL or missing references) //IL_3e77: Unknown result type (might be due to invalid IL or missing references) //IL_3a46: Unknown result type (might be due to invalid IL or missing references) //IL_5d93: Unknown result type (might be due to invalid IL or missing references) //IL_3c15: Unknown result type (might be due to invalid IL or missing references) //IL_39d4: Unknown result type (might be due to invalid IL or missing references) //IL_69cf: Unknown result type (might be due to invalid IL or missing references) //IL_6ecb: Unknown result type (might be due to invalid IL or missing references) //IL_5772: Unknown result type (might be due to invalid IL or missing references) //IL_6438: Unknown result type (might be due to invalid IL or missing references) //IL_4dff: Unknown result type (might be due to invalid IL or missing references) //IL_67d3: Unknown result type (might be due to invalid IL or missing references) //IL_3ec4: Unknown result type (might be due to invalid IL or missing references) //IL_3acd: Unknown result type (might be due to invalid IL or missing references) //IL_6f60: Unknown result type (might be due to invalid IL or missing references) //IL_4d8d: Unknown result type (might be due to invalid IL or missing references) //IL_65ee: Unknown result type (might be due to invalid IL or missing references) //IL_65bf: Unknown result type (might be due to invalid IL or missing references) //IL_4ee6: Unknown result type (might be due to invalid IL or missing references) //IL_6648: Unknown result type (might be due to invalid IL or missing references) //IL_54fd: Unknown result type (might be due to invalid IL or missing references) //IL_3a93: Unknown result type (might be due to invalid IL or missing references) //IL_3f11: Unknown result type (might be due to invalid IL or missing references) //IL_399b: Unknown result type (might be due to invalid IL or missing references) //IL_5655: Unknown result type (might be due to invalid IL or missing references) //IL_5739: Unknown result type (might be due to invalid IL or missing references) //IL_40b1: Unknown result type (might be due to invalid IL or missing references) //IL_4c6e: Unknown result type (might be due to invalid IL or missing references) //IL_59e7: Unknown result type (might be due to invalid IL or missing references) //IL_588f: Unknown result type (might be due to invalid IL or missing references) //IL_6675: Unknown result type (might be due to invalid IL or missing references) //IL_6dbb: Unknown result type (might be due to invalid IL or missing references) //IL_4f73: Unknown result type (might be due to invalid IL or missing references) //IL_6d34: Unknown result type (might be due to invalid IL or missing references) //IL_47fc: Unknown result type (might be due to invalid IL or missing references) //IL_4029: Unknown result type (might be due to invalid IL or missing references) //IL_593b: Unknown result type (might be due to invalid IL or missing references) //IL_4515: Unknown result type (might be due to invalid IL or missing references) //IL_56c7: Unknown result type (might be due to invalid IL or missing references) //IL_68dc: Unknown result type (might be due to invalid IL or missing references) //IL_4056: Unknown result type (might be due to invalid IL or missing references) //IL_6a56: Unknown result type (might be due to invalid IL or missing references) //IL_64ba: Unknown result type (might be due to invalid IL or missing references) //IL_4932: Unknown result type (might be due to invalid IL or missing references) //IL_58c8: Unknown result type (might be due to invalid IL or missing references) //IL_501e: Unknown result type (might be due to invalid IL or missing references) //IL_5e05: Unknown result type (might be due to invalid IL or missing references) //IL_6e44: Unknown result type (might be due to invalid IL or missing references) //IL_6d61: Unknown result type (might be due to invalid IL or missing references) //IL_55e2: Unknown result type (might be due to invalid IL or missing references) //IL_5f01: Unknown result type (might be due to invalid IL or missing references) //IL_4b86: Unknown result type (might be due to invalid IL or missing references) //IL_6dea: Unknown result type (might be due to invalid IL or missing references) //IL_5b7b: Unknown result type (might be due to invalid IL or missing references) //IL_4e4c: Unknown result type (might be due to invalid IL or missing references) //IL_66a2: Unknown result type (might be due to invalid IL or missing references) //IL_4897: Unknown result type (might be due to invalid IL or missing references) //IL_6f22: Unknown result type (might be due to invalid IL or missing references) //IL_3915: Unknown result type (might be due to invalid IL or missing references) //IL_5fb8: Unknown result type (might be due to invalid IL or missing references) //IL_469a: Unknown result type (might be due to invalid IL or missing references) //IL_5c2e: Unknown result type (might be due to invalid IL or missing references) //IL_5974: Unknown result type (might be due to invalid IL or missing references) //IL_53f0: Unknown result type (might be due to invalid IL or missing references) //IL_4ca7: Unknown result type (might be due to invalid IL or missing references) //IL_5537: Unknown result type (might be due to invalid IL or missing references) //IL_5e66: Unknown result type (might be due to invalid IL or missing references) //IL_627e: Unknown result type (might be due to invalid IL or missing references) //IL_6975: Unknown result type (might be due to invalid IL or missing references) //IL_57ab: Unknown result type (might be due to invalid IL or missing references) //IL_3c64: Unknown result type (might be due to invalid IL or missing references) //IL_4fac: Unknown result type (might be due to invalid IL or missing references) //IL_4a19: Unknown result type (might be due to invalid IL or missing references) //IL_42bb: Unknown result type (might be due to invalid IL or missing references) //IL_5570: Unknown result type (might be due to invalid IL or missing references) //IL_4ad8: Unknown result type (might be due to invalid IL or missing references) //IL_5d5a: Unknown result type (might be due to invalid IL or missing references) //IL_5cb6: Unknown result type (might be due to invalid IL or missing references) //IL_48e5: Unknown result type (might be due to invalid IL or missing references) //IL_4309: Unknown result type (might be due to invalid IL or missing references) //IL_4453: Unknown result type (might be due to invalid IL or missing references) //IL_3962: Unknown result type (might be due to invalid IL or missing references) //IL_66cf: Unknown result type (might be due to invalid IL or missing references) //IL_6cf3: Unknown result type (might be due to invalid IL or missing references) //IL_57e4: Unknown result type (might be due to invalid IL or missing references) //IL_6e17: Unknown result type (might be due to invalid IL or missing references) //IL_5b41: Unknown result type (might be due to invalid IL or missing references) //IL_4a52: Unknown result type (might be due to invalid IL or missing references) //IL_44b4: Unknown result type (might be due to invalid IL or missing references) //IL_62ab: Unknown result type (might be due to invalid IL or missing references) //IL_64fb: Unknown result type (might be due to invalid IL or missing references) //IL_5c68: Unknown result type (might be due to invalid IL or missing references) //IL_3a0d: Unknown result type (might be due to invalid IL or missing references) //IL_6a83: Unknown result type (might be due to invalid IL or missing references) //IL_3b79: Unknown result type (might be due to invalid IL or missing references) //IL_4112: Unknown result type (might be due to invalid IL or missing references) //IL_6479: Unknown result type (might be due to invalid IL or missing references) //IL_43a5: Unknown result type (might be due to invalid IL or missing references) //IL_69fc: Unknown result type (might be due to invalid IL or missing references) //IL_532f: Unknown result type (might be due to invalid IL or missing references) //IL_3b40: Unknown result type (might be due to invalid IL or missing references) //IL_568e: Unknown result type (might be due to invalid IL or missing references) //IL_49cc: Unknown result type (might be due to invalid IL or missing references) //IL_41d3: Unknown result type (might be due to invalid IL or missing references) //IL_4d54: Unknown result type (might be due to invalid IL or missing references) //IL_6ef8: Unknown result type (might be due to invalid IL or missing references) //IL_54c4: Unknown result type (might be due to invalid IL or missing references) //IL_4e99: Unknown result type (might be due to invalid IL or missing references) //IL_4084: Unknown result type (might be due to invalid IL or missing references) //IL_50b8: Unknown result type (might be due to invalid IL or missing references) //IL_497f: Unknown result type (might be due to invalid IL or missing references) //IL_69a2: Unknown result type (might be due to invalid IL or missing references) //IL_38c8: Unknown result type (might be due to invalid IL or missing references) //IL_5dcc: Unknown result type (might be due to invalid IL or missing references) //IL_3ffb: Unknown result type (might be due to invalid IL or missing references) //IL_6591: Unknown result type (might be due to invalid IL or missing references) //IL_5a81: Unknown result type (might be due to invalid IL or missing references) //IL_4d1a: Unknown result type (might be due to invalid IL or missing references) //IL_6b03: Unknown result type (might be due to invalid IL or missing references) //IL_68af: Unknown result type (might be due to invalid IL or missing references) //IL_5119: Unknown result type (might be due to invalid IL or missing references) //IL_4c35: Unknown result type (might be due to invalid IL or missing references) //IL_6792: Unknown result type (might be due to invalid IL or missing references) //IL_5297: Unknown result type (might be due to invalid IL or missing references) //IL_5902: Unknown result type (might be due to invalid IL or missing references) //IL_6210: Unknown result type (might be due to invalid IL or missing references) //IL_548a: Unknown result type (might be due to invalid IL or missing references) //IL_661b: Unknown result type (might be due to invalid IL or missing references) //IL_6d8e: Unknown result type (might be due to invalid IL or missing references) //IL_506b: Unknown result type (might be due to invalid IL or missing references) //IL_4fe5: Unknown result type (might be due to invalid IL or missing references) //IL_3cb1: Unknown result type (might be due to invalid IL or missing references) //IL_686e: Unknown result type (might be due to invalid IL or missing references) //IL_653c: Unknown result type (might be due to invalid IL or missing references) //IL_52d9: Unknown result type (might be due to invalid IL or missing references) //IL_3b07: Unknown result type (might be due to invalid IL or missing references) //IL_4be8: Unknown result type (might be due to invalid IL or missing references) //IL_6a29: Unknown result type (might be due to invalid IL or missing references) //IL_3bc6: Unknown result type (might be due to invalid IL or missing references) //IL_53b7: Unknown result type (might be due to invalid IL or missing references) //IL_640b: Unknown result type (might be due to invalid IL or missing references) //IL_5d21: Unknown result type (might be due to invalid IL or missing references) //IL_59ad: Unknown result type (might be due to invalid IL or missing references) //IL_3f73: Unknown result type (might be due to invalid IL or missing references) //IL_63c8: Unknown result type (might be due to invalid IL or missing references) //IL_6bc4: Unknown result type (might be due to invalid IL or missing references) //IL_6330: Unknown result type (might be due to invalid IL or missing references) //IL_55a9: Unknown result type (might be due to invalid IL or missing references) //IL_4dc6: Unknown result type (might be due to invalid IL or missing references) //IL_6e71: Unknown result type (might be due to invalid IL or missing references) //IL_5700: Unknown result type (might be due to invalid IL or missing references) //IL_5ba8: Unknown result type (might be due to invalid IL or missing references) //IL_6800: Unknown result type (might be due to invalid IL or missing references) //IL_518e: Unknown result type (might be due to invalid IL or missing references) //IL_6948: Unknown result type (might be due to invalid IL or missing references) //IL_6c05: Unknown result type (might be due to invalid IL or missing references) //IL_4ce1: Unknown result type (might be due to invalid IL or missing references) //IL_3fcd: Unknown result type (might be due to invalid IL or missing references) //IL_4f33: Unknown result type (might be due to invalid IL or missing references) //IL_623d: Unknown result type (might be due to invalid IL or missing references) //IL_3d8c: Unknown result type (might be due to invalid IL or missing references) //IL_45b0: Unknown result type (might be due to invalid IL or missing references) //IL_543d: Unknown result type (might be due to invalid IL or missing references) //IL_6387: Unknown result type (might be due to invalid IL or missing references) //IL_3fa0: Unknown result type (might be due to invalid IL or missing references) //IL_561b: Unknown result type (might be due to invalid IL or missing references) //IL_4625: Unknown result type (might be due to invalid IL or missing references) //IL_5f62: Unknown result type (might be due to invalid IL or missing references) //IL_4b4c: Unknown result type (might be due to invalid IL or missing references) //IL_6710: Unknown result type (might be due to invalid IL or missing references) //IL_426e: Unknown result type (might be due to invalid IL or missing references) //IL_4199: Unknown result type (might be due to invalid IL or missing references) //IL_3df0: Unknown result type (might be due to invalid IL or missing references) //IL_415f: Unknown result type (might be due to invalid IL or missing references) //IL_62ed: Unknown result type (might be due to invalid IL or missing references) //IL_6c46: Unknown result type (might be due to invalid IL or missing references) //IL_537e: Unknown result type (might be due to invalid IL or missing references) //IL_3e2a: Unknown result type (might be due to invalid IL or missing references) //IL_6b83: Unknown result type (might be due to invalid IL or missing references) //IL_4406: Unknown result type (might be due to invalid IL or missing references) //IL_4a9f: Unknown result type (might be due to invalid IL or missing references) //IL_4b12: Unknown result type (might be due to invalid IL or missing references) //IL_4357: Unknown result type (might be due to invalid IL or missing references) //IL_4563: Unknown result type (might be due to invalid IL or missing references) //IL_5a34: Unknown result type (might be due to invalid IL or missing references) //IL_5856: Unknown result type (might be due to invalid IL or missing references) //IL_4785: Unknown result type (might be due to invalid IL or missing references) //IL_5be1: Unknown result type (might be due to invalid IL or missing references) //IL_6e9e: Unknown result type (might be due to invalid IL or missing references) //IL_420d: Unknown result type (might be due to invalid IL or missing references) //IL_5ace: Unknown result type (might be due to invalid IL or missing references) //IL_6cc6: Unknown result type (might be due to invalid IL or missing references) //IL_5256: Unknown result type (might be due to invalid IL or missing references) Piece component = gameObject.gameObject.GetComponent(); SetStation(component, TableMapper.stoneCutter); switch (((Object)gameObject).name) { case "wood_spiralstair_bal": case "wood_spiralstair_right_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 4); component.m_category = (PieceCategory)2; break; case "ashwood_roof_icorner_left45_bal": case "ashwood_roof_icorner_right45_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Blackwood", 1); AddResources(component, "Grausten", 1); component.m_category = (PieceCategory)2; break; case "ashwood_roof26_bal": case "ashwood_roof45_bal": case "ashwood_roof_icorner_45_bal": case "ashwood_roof_ocorner_45_bal": case "ashwood_roof_top45_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Blackwood", 2); AddResources(component, "Grausten", 1); component.m_category = (PieceCategory)2; break; case "finewood_beam_bal": case "finewood_floor1x1_bal": case "finewood_pole_bal": case "finewood_wall_1x1_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "FineWood", 1); component.m_category = (PieceCategory)2; break; case "finewood_frame_bal": case "finewood_pole4_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "FineWood", 3); component.m_category = (PieceCategory)2; break; case "finewood_wall_cross_64_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "FineWood", 2); component.m_category = (PieceCategory)2; break; case "finewood_arch_bottom_bal": case "finewood_arch_top_bal": case "finewood_beam2_bal": case "finewood_beam4_bal": case "finewood_beam_26_bal": case "finewood_beam_45_bal": case "finewood_beam_64_bal": case "finewood_floor2x2_bal": case "finewood_pole2_bal": case "finewood_stair_bal": case "finewood_wall_1x2_bal": case "finewood_wall_2x1_bal": case "finewood_wall_2x2_bal": case "finewood_wall_arch_bal": case "finewood_wall_cross_26_bal": case "finewood_wall_cross_45_bal": case "fineood_wall_roof_26_bal": case "finewood_wall_roof_26_upsidedown_bal": case "finewood_wall_roof_45_bal": case "finewood_wall_roof_45_upsidedown_bal": case "finewood_wall_roof_64_upsidedown_bal": case "finewood_wall_roof_64_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "FineWood", 2); component.m_category = (PieceCategory)2; break; case "Yggdrasil_wood_block_bal": case "Yggdrasil_wood_pillar_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "YggdrasilWood", 5); AddResources(component, "Eitr", 1); component.m_category = (PieceCategory)2; break; case "BoneFragmentsFloorl1_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BoneFragments", 10); component.m_category = (PieceCategory)2; break; case "BoneFragmentsFloorl2_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BoneFragments", 20); component.m_category = (PieceCategory)2; break; case "wood_beam_64_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 2); component.m_category = (PieceCategory)2; break; case "wood_wall_roof_64_bal": case "wood_wall_roof_upsidedown_64_bal": case "wood_wall_cross_64_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 2); component.m_category = (PieceCategory)2; break; case "wood_ledge_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 2); AddResources(component, "WoodNails_bal", 4, "FineWood", 1); component.m_category = (PieceCategory)2; break; case "wood_gate_large_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 20); AddResources(component, "WoodNails_bal", 16, "FineWood", 3); component.m_category = (PieceCategory)2; break; case "corewood_gate_large_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "RoundLog", 16); AddResources(component, "WoodNails_bal", 12, "Wood", 3); component.m_category = (PieceCategory)2; break; case "wood_hidden_gate_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 8); AddResources(component, "WoodNails_bal", 8, "FineWood", 2); component.m_category = (PieceCategory)2; break; case "wood_raven_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "FineWood", 5); break; case "wood_dragon_dark_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "FineWood", 5); AddResources(component, "Tar", 1); break; case "copper_dropgate_large_bal": SetStation(component, TableMapper.forge); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "MechanicalSpring", 1); AddResources(component, "Copper", 10); AddResources(component, "WoodNails_bal", 16, "FineWood", 3); component.m_category = (PieceCategory)3; break; case "wood_iron_gate_large_bal": SetStation(component, TableMapper.forge); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 20); AddResources(component, "WoodNails_bal", 16, "FineWood", 3); AddResources(component, "IronNails", 44); component.m_category = (PieceCategory)2; break; case "stone_circle_arch_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 20); component.m_category = (PieceCategory)3; break; case "darkwood_roof64_bal": case "darkwood_beam_26_deco_bal": case "darkwood_beam_45_deco_bal": case "darkwood_beam_64_bal": case "darkwood_beam_deco_bal": case "darkwood_pole_deco_bal": case "darkwood_roof_quarter_45_bal": case "darkwood_roof_quarter_26_bal": case "darkwood_roof_top_half_45_bal": case "darkwood_roof_top_half_bal": SetStation(component, TableMapper.workbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 1); AddResources(component, "Tar", 1); component.m_category = (PieceCategory)2; break; case "darkwoodwall1m_bal": SetStation(component, TableMapper.workbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 1); AddResources(component, "Tar", 1); component.m_category = (PieceCategory)2; break; case "darkwoodwall_bal": case "darkwood_roof_top_cap_bal": case "darkwood_roof_top_cap2_bal": case "darkwood_roof_top_center_bal": SetStation(component, TableMapper.workbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 2); AddResources(component, "Tar", 1); component.m_category = (PieceCategory)2; break; case "darkwood_gate_large_bal": SetStation(component, TableMapper.forge); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 30); AddResources(component, "Iron", 8); AddResources(component, "Tar", 4); component.m_category = (PieceCategory)2; break; case "grausten_round_column_bal": SetStation(component, TableMapper.stoneCutter); AddResources(component, "Grausten", 6); component.m_category = (PieceCategory)3; break; case "piece_grausten_roof_45_top_bal": SetStation(component, TableMapper.stoneCutter); AddResources(component, "Grausten", 5); component.m_category = (PieceCategory)3; break; case "piece_grausten_reinforced_wall_4x6_bal": SetStation(component, TableMapper.stoneCutter); AddResources(component, "Grausten", 24); component.m_category = (PieceCategory)3; break; case "piece_grausten_pillarbase_twisted_reversed_bal": case "piece_grausten_pillar4_tip2_bal": case "piece_grausten_pillar4_tip3_bal": case "piece_grausten_pillar4_tip_bal": case "piece_grausten_pillarbase_twisted_bal": case "piece_grausten_roof_arch_big_bal": case "piece_grausten_roof_beam_small_bal": case "piece_grausten_stair_curved_bal": case "piece_grausten_twist_arch_bal": case "piece_grausten_twisted_pillarbase_bal": SetStation(component, TableMapper.stoneCutter); AddResources(component, "Grausten", 9); component.m_category = (PieceCategory)3; break; case "piece_grausten_twisted_pillar_small_bal": case "piece_grausten_twisted_pillartop_small_bal": case "piece_grausten_twisted_pillarbase_small_bal": SetStation(component, TableMapper.stoneCutter); AddResources(component, "Grausten", 5); component.m_category = (PieceCategory)3; break; case "grausten_gate": SetStation(component, TableMapper.stoneCutter); AddResources(component, "Grausten", 12); component.m_category = (PieceCategory)3; break; case "grausten_stair_corner_bal": case "grausten_stair_corner_left_bal": case "grausten_stair_inner_bal": case "grausten_stair_outer_bal": SetStation(component, TableMapper.stoneCutter); AddResources(component, "Grausten", 8); component.m_category = (PieceCategory)3; break; case "bone_fence_bal": SetStation(component, TableMapper.workbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BoneFragments", 5); AddResources(component, "WoodNails_bal", 4, "Wood", 1); AddResources(component, "LeatherScraps", 1); component.m_category = (PieceCategory)2; break; case "woodwall4m_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 5); AddResources(component, "WoodNails_bal", 8, "FineWood", 1); component.m_category = (PieceCategory)2; break; case "Hearth_1x3_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 9); component.m_category = (PieceCategory)3; break; case "Hearth_2x2_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 11); component.m_category = (PieceCategory)3; break; case "Hearth_2x3_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 13); component.m_category = (PieceCategory)3; break; case "dverger_gate_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 6); AddResources(component, "Iron", 6); AddResources(component, "MechanicalSpring", 1); component.m_category = (PieceCategory)3; break; case "stone_celling_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 6); AddResources(component, "Wood", 2); component.m_category = (PieceCategory)3; break; case "stone_window_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 10); AddResources(component, "Wood", 1); component.m_category = (PieceCategory)3; break; case "stone_secretdoor_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 20); AddResources(component, "MechanicalSpring", 1); component.m_category = (PieceCategory)3; break; case "dvergr_secretdoor_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 13); AddResources(component, "MechanicalSpring", 1); component.m_category = (PieceCategory)3; break; case "giant_metal_gate_bal": SetStation(component, TableMapper.forge); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 6); AddResources(component, "Iron", 6); AddResources(component, "MechanicalSpring", 1); component.m_category = (PieceCategory)3; break; case "gabro_barkwood_pole_bal": case "gabro_barkwood_beam_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Gabro_bal", 1, "Flint", 2); AddResources(component, "ElderBark", 1); component.m_category = (PieceCategory)3; break; case "gabro_barkwood_beam2_bal": case "gabro_barkwood_pole2_bal": case "gabro_barkwood_pole_26_bal": case "gabro_barkwood_pole_45_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Gabro_bal", 1, "Flint", 2); AddResources(component, "Stone", 1); AddResources(component, "ElderBark", 1); component.m_category = (PieceCategory)3; break; case "gabro_bark_pillar_empty2m_reverse_bal": case "gabro_bark_pillar_empty2m_side_bal": case "gabro_bark_pillar_empty2m_bal": case "gabro_counter1x1_bal": case "gabro_counter_corner_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Gabro_bal", 2, "Flint", 4); AddResources(component, "Stone", 2); AddResources(component, "ElderBark", 2); component.m_category = (PieceCategory)3; break; case "gabro_arch4m_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Gabro_bal", 8, "Flint", 16); AddResources(component, "Stone", 4); component.m_category = (PieceCategory)3; break; case "gabro_floor1x1_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Gabro_bal", 2, "Flint", 4); AddResources(component, "Stone", 1); component.m_category = (PieceCategory)3; break; case "gabro_window1m_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Gabro_bal", 2, "Flint", 4); AddResources(component, "Stone", 1); AddResources(component, "Crystal", 1); AddResources(component, "Iron", 1); component.m_category = (PieceCategory)3; break; case "gabro_window2m_bal": case "gabro_window_large2m_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Gabro_bal", 4, "Flint", 8); AddResources(component, "Stone", 2); AddResources(component, "Crystal", 1); AddResources(component, "Iron", 1); component.m_category = (PieceCategory)3; break; case "gabro_window_round2m_bal": case "gabro_window_triangle2m_bal": case "gabro_window_deco2m_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Gabro_bal", 4, "Flint", 8); AddResources(component, "Stone", 2); AddResources(component, "Crystal", 1); AddResources(component, "Wood", 2); component.m_category = (PieceCategory)3; break; case "gabro_window_glass_3m_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Gabro_bal", 6, "Flint", 12); AddResources(component, "Stone", 3); AddResources(component, "Crystal", 2); AddResources(component, "Wood", 3); component.m_category = (PieceCategory)3; break; case "gabro_oriel4m_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Gabro_bal", 10, "Flint", 20); AddResources(component, "Stone", 6); AddResources(component, "Crystal", 3); AddResources(component, "Wood", 8); component.m_category = (PieceCategory)3; break; case "gabro_clolumnbase_bal": case "gabro_columntop_bal": case "gabro_wall2x2_bal": case "gabro_pole4_bal": case "gabro_beam4_bal": case "gabro_stair_bal": case "gabro_floor2x2_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Gabro_bal", 4, "Flint", 8); AddResources(component, "Stone", 2); component.m_category = (PieceCategory)3; break; case "gabro_wall4x4_bal": case "gabro_floor4x4_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Gabro_bal", 8, "Flint", 16); AddResources(component, "Stone", 4); component.m_category = (PieceCategory)3; break; case "gabro_column_bal": case "gabro_pass_1x3_bal": case "gabro_wall2x4_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Gabro_bal", 6, "Flint", 12); AddResources(component, "Stone", 3); component.m_category = (PieceCategory)3; break; case "gabro_wall_1x1_thin_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Gabro_bal", 2, "Flint", 4); AddResources(component, "Stone", 1); component.m_category = (PieceCategory)3; break; case "gabro_wall2x1_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Gabro_bal", 3, "Flint", 6); AddResources(component, "Stone", 2); component.m_category = (PieceCategory)3; break; case "gabro_floor_slope26_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Gabro_bal", 3, "Flint", 6); AddResources(component, "Stone", 2); component.m_category = (PieceCategory)3; break; case "gabro_floor_slope45_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Gabro_bal", 3, "Flint", 6); AddResources(component, "Stone", 2); component.m_category = (PieceCategory)3; break; case "blackmarble_columnbase_bal": case "blackmarble_columntop_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 4); component.m_category = (PieceCategory)3; break; case "wood_windowiron_bal": SetStation(component, TableMapper.forge); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 2); AddResources(component, "IronNails", 4); component.m_category = (PieceCategory)2; break; case "blackmarble_beam_bal": case "blackmarble_pole_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 2); component.m_category = (PieceCategory)3; break; case "blackmarble_gate_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 20); component.m_category = (PieceCategory)3; break; case "spiked_copper_gate_left_bal": case "spiked_copper_gate_right_bal": SetStation(component, TableMapper.forge); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Copper", 20); component.m_category = (PieceCategory)3; break; case "blackmarble_floor4m_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 12); component.m_category = (PieceCategory)3; break; case "blackmarble_lantern_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 12); AddResources(component, "Crystal", 4); AddResources(component, "Wisp", 1); component.m_category = (PieceCategory)3; setFireplaceFuelItem(component, "Wisp"); break; case "blackmarble_roof27_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 6); component.m_category = (PieceCategory)3; break; case "blackmarble_stone_ladder_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 4); component.m_category = (PieceCategory)3; break; case "blackmarble_stair_inner_bal": case "blackmarble_stair_outer_bal": case "blackmarble_2x2x1_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 6); component.m_category = (PieceCategory)3; break; case "blackmarble_long_stair_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 16); component.m_category = (PieceCategory)3; break; case "blackmarble_Wall_Window_2x2_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 4); component.m_category = (PieceCategory)3; break; case "blackmarble_platform4m_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 20); component.m_category = (PieceCategory)3; break; case "blackmarble_stair_corner_bal": case "blackmarble_stair_corner_left_bal": case "blackmarble_head_big01_bal": case "blackmarble_head_big02_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 8); component.m_category = (PieceCategory)3; break; case "blackmarble_creep_slope_inverted_2x2x1_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 2); component.m_category = (PieceCategory)3; break; case "blackmarble_slope1x2_inverted_bal": case "blackmarble_slope1x2_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 2); component.m_category = (PieceCategory)3; break; case "blackmarble_1x1_enforced_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 2); AddResources(component, "CopperScrap", 1); component.m_category = (PieceCategory)3; break; case "blackmarble_2x2_enforced_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 8); AddResources(component, "Copper", 2); component.m_category = (PieceCategory)3; break; case "coppermarble_1x1_enforced_bal": case "coppermarble_head1_bal": case "coppermarble_head2_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 1); AddResources(component, "Bronze", 1); component.m_category = (PieceCategory)3; break; case "metalbar_1x2_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 1); AddResources(component, "Copper", 2); component.m_category = (PieceCategory)3; break; case "stone_1x1_enforced_bal": component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 3); AddResources(component, "CopperScrap", 1); component.m_category = (PieceCategory)3; break; case "wood_log_64_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "RoundLog", 2); component.m_category = (PieceCategory)2; break; case "crystal_tile_floor_2x2_bal": case "crystal_wall_2x2_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Crystal", 3); component.m_category = (PieceCategory)3; break; case "obsidian_tile_floor_2x2_bal": case "obsidian_wall_2x2_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Obsidian", 3); component.m_category = (PieceCategory)3; break; case "emberwood_pillar2_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "RoundLog", 3); AddResources(component, "Flint", 2); component.m_category = (PieceCategory)2; break; case "emberwood_pillar4_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "RoundLog", 6); AddResources(component, "Flint", 4); component.m_category = (PieceCategory)2; break; case "piece_braziercolumn_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 8); AddResources(component, "Iron", 2); AddResources(component, "Coal", 2); component.m_category = (PieceCategory)3; setFireplaceFuelItem(component, "Coal"); break; case "plate_gate_bal": SetStation(component, TableMapper.forge); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "FineWood", 4); AddResources(component, "Iron", 2); AddResources(component, "BlackMetal", 4); component.m_category = (PieceCategory)3; break; case "tiledwood_floor_2x2_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; if (itemExists("HardWood_bal")) { AddResources(component, "Wood", 1); AddResources(component, "HardWood_bal", 1); AddResources(component, "Tar", 1); AddResources(component, "FineWood", 1); } else { AddResources(component, "Wood", 2); AddResources(component, "Tar", 1); AddResources(component, "FineWood", 2); } component.m_category = (PieceCategory)2; break; case "wood_arch_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 2); AddResources(component, "WoodNails_bal", 4, "RoundLog", 1); component.m_category = (PieceCategory)2; break; case "wood_fence_bal": SetStation(component, TableMapper.workbench); AddResources(component, "Wood", 1); AddResources(component, "WoodNails_bal", 12, "FineWood", 1); component.m_category = (PieceCategory)2; break; case "woven_fence_bal": SetStation(component, TableMapper.workbench); AddResources(component, "Wood", 1); AddResources(component, "WoodNails_bal", 12, "FineWood", 1); AddResources(component, "StrawThread_bal", 1, "RoundLog", 1); component.m_category = (PieceCategory)2; break; case "wood_floor4x4_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 10); AddResources(component, "WoodNails_bal", 16, "FineWood", 4); component.m_category = (PieceCategory)2; break; case "wood_plot_1m_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 2); component.m_category = (PieceCategory)2; break; case "wood_plot_3m_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 4); component.m_category = (PieceCategory)2; break; case "wood_plot_gate_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 2); AddResources(component, "WoodNails_bal", 4, "BronzeNails", 2); component.m_category = (PieceCategory)2; break; case "rune_floor_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 8); AddResources(component, "Crystal", 4); component.m_category = (PieceCategory)3; break; case "stone_floor4m_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 12); component.m_category = (PieceCategory)3; break; case "stone_floor_trianlge_1x2m_bal": case "stone_floor_trianlge_1x2m_reverse_bal": case "stone_floor_triangle_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 3); component.m_category = (PieceCategory)3; break; case "stone_long_stair_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 16); component.m_category = (PieceCategory)3; break; case "stone_beam_bal": case "stone_pole_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 2); component.m_category = (PieceCategory)3; break; case "stone_pole2_bal": case "stone_beam2_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 4); component.m_category = (PieceCategory)3; break; case "stone_railing_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 3); component.m_category = (PieceCategory)3; break; case "stone_roof27_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 6); component.m_category = (PieceCategory)3; break; case "bronze_gate_left_bal": SetStation(component, TableMapper.forge); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Bronze", 20); component.m_category = (PieceCategory)3; break; case "iron_beam1_bal": case "iron_pole1_bal": SetStation(component, TableMapper.forge); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Iron", 1); component.m_category = (PieceCategory)3; break; case "iron_beam_64_bal": case "iron_beam_bal": case "iron_beam_26_bal": case "iron_beam_45_bal": case "iron_pole_bal": SetStation(component, TableMapper.forge); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Iron", 2); component.m_category = (PieceCategory)3; break; case "iron_trim_1_90_bal": case "iron_trim1_bal": SetStation(component, TableMapper.forge); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "IronNails", 2); component.m_category = (PieceCategory)3; break; case "iron_trim_bal": case "iron_trim_26_bal": case "iron_trim_45_bal": case "iron_trim_90_bal": SetStation(component, TableMapper.forge); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "IronNails", 4); component.m_category = (PieceCategory)3; break; case "stone_trim1_90_bal": case "stone_trim1_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 1); component.m_category = (PieceCategory)3; break; case "stone_trim_26_bal": case "stone_trim_45_bal": case "stone_trim_90_bal": case "stone_trim_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 2); component.m_category = (PieceCategory)3; break; case "wood_trim1_bal": case "wood_trim1_90_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "WoodNails_bal", 2, "Wood", 1); component.m_category = (PieceCategory)2; break; case "wood_trim_bal": case "wood_trim_64_bal": case "wood_trim_90_bal": case "wood_trim_26_bal": case "wood_trim_45_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "WoodNails_bal", 4, "Wood", 1); component.m_category = (PieceCategory)2; break; case "stone_Wall_Window_2x2_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 5); component.m_category = (PieceCategory)3; break; case "stone_Wall_2x2_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 6); component.m_category = (PieceCategory)3; break; case "stone_Wall_Archgate_2x2_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 4); component.m_category = (PieceCategory)3; break; case "stone_Wall_Window_2x4_thick_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 14); component.m_category = (PieceCategory)3; break; case "stone_Wall_Window_2x4_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 7); component.m_category = (PieceCategory)3; break; case "stone_Wall_2x4_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 8); component.m_category = (PieceCategory)3; break; case "stone_Wall_Archgate_2x4_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 6); component.m_category = (PieceCategory)3; break; case "bigstonepillar4m_bal": case "bigstonepillar4m_reverse_bal": case "stone_pillar6m1_bal": case "stone_pillar6m2_bal": case "stone_pillar6m3_bal": case "stone_pillar6m4_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 10); component.m_category = (PieceCategory)3; break; case "stone_frame_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 8); AddResources(component, "Copper", 2); component.m_category = (PieceCategory)3; break; case "hexwood_floor_4m_bal": SetStation(component, TableMapper.forge); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "YggdrasilWood", 6); AddResources(component, "Copper", 2); component.m_category = (PieceCategory)3; break; case "hexwood_floor_half_4m_bal": SetStation(component, TableMapper.forge); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "YggdrasilWood", 3); AddResources(component, "Copper", 1); component.m_category = (PieceCategory)3; break; case "stone_stair_corner_bal": case "stone_stair_corner_left_bal": case "stone_stair_outer_bal": case "stone_stair_inner_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 8); component.m_category = (PieceCategory)3; break; case "stone_stair_railing_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 10); component.m_category = (PieceCategory)3; break; case "stone_stair_railing_right_bal": case "stone_stair_railing_left_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 9); component.m_category = (PieceCategory)3; break; case "stone_arch4m_bal": SetStation(component, TableMapper.stoneCutter); AddResources(component, "Stone", 7); component.m_category = (PieceCategory)3; break; case "stone_stepladder_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 5); component.m_category = (PieceCategory)3; break; case "stonemoss_tile_floor_2x2_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 6); AddResources(component, "Moss_bal", 2); component.m_category = (PieceCategory)3; break; case "stone_platform_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 10); component.m_category = (PieceCategory)3; break; case "vigvisir_floor_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 10); AddResources(component, "Coal", 5); component.m_category = (PieceCategory)3; break; case "piece_hardwood_floor2x2_bal": case "piece_hardwoodwall2m_bal": component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "HardWood_bal", 2, "FineWood", 3); SetStation(component, TableMapper.heavyWorkbench); break; case "Piece_hardwood_pillar_arch_bal": component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "HardWood_bal", 3, "FineWood", 4); SetStation(component, TableMapper.heavyWorkbench); component.m_category = (PieceCategory)2; break; case "Piece_hardwood_pillar_arch_small_bal": component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "HardWood_bal", 1, "FineWood", 2); SetStation(component, TableMapper.heavyWorkbench); component.m_category = (PieceCategory)2; break; case "Piece_hardwood_pillarbase_tapered_bal": case "Piece_hardwood_pillarbase_tapered_inverted_bal": component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "HardWood_bal", 3, "FineWood", 4); SetStation(component, TableMapper.heavyWorkbench); component.m_category = (PieceCategory)2; break; case "Piece_hardwood_pillarbeam_medium_bal": case "Piece_hardwood_pillarbase_medium_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "HardWood_bal", 2, "FineWood", 3); component.m_category = (PieceCategory)2; break; case "Piece_hardwood_pillarbeam_small_bal": case "Piece_hardwood_pillarbase_small_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "HardWood_bal", 1, "FineWood", 2); component.m_category = (PieceCategory)2; break; case "piece_hardwood_roof_45_bal": case "piece_hardwood_roof_45_arch_bal": case "piece_hardwood_roof_45_arch_corner_bal": case "piece_hardwood_roof_45_arch_corner2_bal": case "piece_hardwood_roof_45_corner_bal": case "piece_hardwood_roof_45_corner2_bal": case "piece_hardwood_roof_45_top_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "HardWood_bal", 2, "FineWood", 3); AddResources(component, "WoodNails_bal", 4, "Wood", 1); AddResources(component, "ClayBrick_bal", 2, "Flint", 2); component.m_category = (PieceCategory)2; break; case "bridge_end_bal": case "bridge_floor_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "WoodNails_bal", 4, "Wood", 1); AddResources(component, "FineWood", 2); AddResources(component, "BronzeNails", 4); break; case "wood_hatchdoor_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 5); AddResources(component, "WoodNails_bal", 4, "FineWood", 1); component.m_category = (PieceCategory)2; break; case "hardwood_door_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "HardWood_bal", 3, "FineWood", 5); AddResources(component, "WoodNails_bal", 4, "Wood", 2); AddResources(component, "IronScrap", 2); component.m_category = (PieceCategory)2; break; case "bg_stake_wall_bal": SetStation(component, TableMapper.workbench); AddResources(component, "RoundLog", 8); AddResources(component, "Wood", 2); AddResources(component, "WoodNails_bal", 16, "FineWood", 3); component.m_category = (PieceCategory)0; break; case "wood_windiron_bal": SetStation(component, TableMapper.forge); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 3); AddResources(component, "IronNails", 3); break; case "wood_window2m_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 6); if (itemExists("WoodNails_bal")) { AddResources(component, "WoodNails_bal", 6); } else { AddResources(component, "FineWood", 1); } break; case "wood_roof64_icorner_bottom_bal": case "wood_roof64_corner_top_bal": case "wood_roof64_corner_bottom_bal": case "wood_roof_quad_top64_bal": case "wood_roof_quad_peak64_bal": case "wood_roof64_bal": case "wood_roof_top_64_bal": case "wood_roof_top_quarter_45_bal": case "wood_roof_top_quarter_bal": case "wood_roof_top_half_bal": case "wood_roof_top_half_45_bal": case "wood_roof_flat_quarter_bal": SetStation(component, TableMapper.heavyWorkbench); if (itemExists("Straw_bal")) { AddResources(component, "Straw_bal", 1); AddResources(component, "Wood", 1); } else { AddResources(component, "Wood", 2); } break; case "wood_roof_top_center_45_bal": case "wood_roof_top_cap_45_bal": case "wood_roof_top_cap2_45_bal": case "wood_roof_top_cap_bal": case "wood_roof_top_cap2_bal": case "wood_roof_top_center_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 3); if (itemExists("WoodNails_bal")) { AddResources(component, "Straw_bal", 1); } break; case "CheeseBlock_bal": SetStation(component, TableMapper.cauldron); ((Behaviour)component).enabled = false; if (itemExists("Cheese_bal")) { ((Behaviour)component).enabled = true; AddResources(component, "Cheese_bal", 2); } else { AddResources(component, "SwordCheat", 1); } break; case "bush_roof_bal": case "bush_roof_icorner_bal": case "bush_roof_ocorner_bal": case "bush_roof_top_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 2); if (itemExists("WoodNails_bal")) { AddResources(component, "WoodNails_bal", 4); AddResources(component, "Moss_bal", 1); } break; case "piece_iron_fence_bal": SetStation(component, TableMapper.forge); AddResources(component, "DarksteelNails_bal", 8, "IronNails", 8); component.m_category = (PieceCategory)3; break; case "piece_iron_fence_small_bal": SetStation(component, TableMapper.forge); AddResources(component, "DarksteelNails_bal", 4, "IronNails", 4); component.m_category = (PieceCategory)3; break; case "wood_railing_bal": case "wood_ramp_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "WoodNails_bal", 4, "FineWood", 1); AddResources(component, "Wood", 2); component.m_category = (PieceCategory)2; break; case "wood_double_wall_roof_26_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 4); component.m_category = (PieceCategory)2; break; case "wood_long_stair_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "WoodNails_bal", 16, "FineWood", 2); AddResources(component, "Wood", 5); component.m_category = (PieceCategory)2; break; case "Copper_Wall_Spikes_bal": SetStation(component, TableMapper.forge); AddResources(component, "Copper", 15); AddResources(component, "BronzeNails", 18); component.m_category = (PieceCategory)0; break; case "piece_sharpstakes_big_bal": SetStation(component, TableMapper.workbench); AddResources(component, "WoodNails_bal", 34, "FineWood", 4); AddResources(component, "Wood", 5); AddResources(component, "RoundLog", 10); component.m_category = (PieceCategory)0; break; case "core_wood_roof26_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "WoodNails_bal", 4, "Wood", 1); AddResources(component, "RoundLog", 4); component.m_category = (PieceCategory)2; break; case "core_wood_stair_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "WoodNails_bal", 16, "Wood", 4); AddResources(component, "RoundLog", 10); component.m_category = (PieceCategory)2; break; case "wood_wall_log1m_bal": case "wood_pole_log1m_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "RoundLog", 1); component.m_category = (PieceCategory)2; break; case "core_wood_wall_corner_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "RoundLog", 4); AddResources(component, "WoodNails_bal", 6, "Wood", 1); component.m_category = (PieceCategory)2; break; case "core_wood_wall_deco2_bal": case "core_wood_wall_2_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "RoundLog", 2); AddResources(component, "WoodNails_bal", 4, "Wood", 1); component.m_category = (PieceCategory)2; break; case "core_wood_wall_deco4_bal": case "core_wood_wall_4_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "WoodNails_bal", 4, "Wood", 1); AddResources(component, "RoundLog", 4); component.m_category = (PieceCategory)2; break; case "wood_iron_log_beam4_bal": case "wood_iron_log_pole4_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "RoundLog", 2); AddResources(component, "Iron", 1); component.m_category = (PieceCategory)2; break; case "leather_roof_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 1); AddResources(component, "WoodNails_bal", 4, "FineWood", 1); AddResources(component, "LeatherScraps", 1); component.m_category = (PieceCategory)2; break; case "stone_slab_wall4x4_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Stone", 20); component.m_category = (PieceCategory)3; break; case "clay_slab_wall4x4_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Clay_bal", 16, "Flint", 10); component.m_category = (PieceCategory)3; break; case "clay_celling_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Clay_bal", 4, "Flint", 4); component.m_category = (PieceCategory)3; break; case "ClayBeam_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Clay_bal", 2, "Flint", 2); component.m_category = (PieceCategory)3; break; case "ClayCube_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Clay_bal", 3, "Flint", 4); component.m_category = (PieceCategory)3; break; case "ClayPole_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Clay_bal", 2, "Flint", 2); component.m_category = (PieceCategory)3; break; case "Clay_arch45_bal": case "clayr_arch_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Clay_bal", 2, "Flint", 2); component.m_category = (PieceCategory)3; break; case "ClayWall_quarter_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 1); AddResources(component, "Clay_bal", 1, "Flint", 2); component.m_category = (PieceCategory)3; break; case "ClayWall_half_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 1); AddResources(component, "Clay_bal", 2, "Flint", 3); component.m_category = (PieceCategory)3; break; case "ClayWall_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 2); AddResources(component, "Clay_bal", 3, "Flint", 4); component.m_category = (PieceCategory)3; break; case "clay_floor_2x2_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 2); AddResources(component, "Clay_bal", 3, "Flint", 4); component.m_category = (PieceCategory)3; break; case "clay_stair_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Clay_bal", 3, "Flint", 4); component.m_category = (PieceCategory)3; break; case "wood_gate_cage_bal": SetStation(component, TableMapper.heavyWorkbench); if (itemExists("WoodNails_bal")) { AddResources(component, "Wood", 10); AddResources(component, "WoodNails_bal", 4); } else { AddResources(component, "Wood", 12); } component.m_category = (PieceCategory)2; break; case "woodiron_beam_64_bal": SetStation(component, TableMapper.forge); AddResources(component, "Wood", 2); AddResources(component, "Iron", 1); component.m_category = (PieceCategory)2; break; case "ashwood_wall_beam_64_bal": case "ashwood_decowall_divider_bal": SetStation(component, TableMapper.workbench); AddResources(component, "Blackwood", 2); component.m_category = (PieceCategory)2; break; case "woodwall_deco_bal": SetStation(component, TableMapper.heavyWorkbench); if (itemExists("WoodNails_bal")) { AddResources(component, "Wood", 2); AddResources(component, "WoodNails_bal", 4); } else { AddResources(component, "Wood", 3); } component.m_category = (PieceCategory)2; break; case "wood_frame_decorative_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 3); component.m_category = (PieceCategory)2; break; case "wood_frame_window_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 2); component.m_category = (PieceCategory)2; break; case "wood_frame_window_half_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 1); component.m_category = (PieceCategory)2; break; case "woodwall_1m_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 1); component.m_category = (PieceCategory)2; break; case "wood_wall_roof_26to45gap3_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 3); component.m_category = (PieceCategory)2; break; case "wood_wall_roof_26to45gap2_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 2); component.m_category = (PieceCategory)2; break; case "wood_wall_roof_26to45_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 1); component.m_category = (PieceCategory)2; break; case "wood_beam4_bal": SetStation(component, TableMapper.heavyWorkbench); if (itemExists("WoodNails_bal")) { AddResources(component, "Wood", 4); AddResources(component, "WoodNails_bal", 4); } else { AddResources(component, "FineWood", 2); AddResources(component, "Wood", 2); } component.m_category = (PieceCategory)2; break; case "wood_pillar4_bal": SetStation(component, TableMapper.heavyWorkbench); if (itemExists("WoodNails_bal")) { AddResources(component, "Wood", 4); AddResources(component, "WoodNails_bal", 4); } else { AddResources(component, "FineWood", 2); AddResources(component, "Wood", 2); } component.m_category = (PieceCategory)2; break; case "chitin_wall_spikes_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 1); AddResources(component, "Chitin", 2); component.m_category = (PieceCategory)2; break; case "decr_wall_half_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "FineWood", 1); AddResources(component, "WoodNails_bal", 4, "Wood", 1); component.m_category = (PieceCategory)2; break; case "decowall_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "FineWood", 1); AddResources(component, "StrawThread_bal", 2, "Wood", 1); component.m_category = (PieceCategory)2; break; case "wood_pole4_bal": SetStation(component, TableMapper.heavyWorkbench); if (itemExists("WoodNails_bal")) { AddResources(component, "Wood", 3); AddResources(component, "WoodNails_bal", 2); } else { AddResources(component, "FineWood", 1); AddResources(component, "Wood", 2); } component.m_category = (PieceCategory)2; break; case "stone_floor_slope45_bal": case "stone_floor_slope_bal": SetStation(component, TableMapper.stoneCutter); AddResources(component, "Stone", 3); component.m_category = (PieceCategory)3; break; case "flametalchain_hook_bal": case "flametalchain_hook_top_bal": case "flametalchain_hook_wall_bal": SetStation(component, TableMapper.blackforge); AddResources(component, "FlametalNew", 1); AddResources(component, "Grausten", 1); component.m_category = (PieceCategory)3; break; case "flametalchain_beam2_26_bal": case "flametalchain_beam2_45_bal": case "flametalchain_beam2_bal": case "flametalchain_pole2_bal": SetStation(component, TableMapper.blackforge); AddResources(component, "FlametalNew", 1); component.m_category = (PieceCategory)3; break; case "bluebasalt_floor1x1_bal": SetStation(component, TableMapper.blackforge); AddResources(component, "BlueBasalt_bal", 2, "Grausten", 3); component.m_category = (PieceCategory)3; break; case "bluebasalt_floor2x2_bal": SetStation(component, TableMapper.blackforge); AddResources(component, "BlueBasalt_bal", 5, "Grausten", 6); component.m_category = (PieceCategory)3; break; case "bluebasalt_floor4m_bal": case "bluebasalt_gate_bal": SetStation(component, TableMapper.blackforge); AddResources(component, "BlueBasalt_bal", 16, "Grausten", 18); component.m_category = (PieceCategory)3; break; case "bluebasalt_column_bal": case "bluebasalt_column_reverse_bal": case "bluebasalt_pillar_bal": case "bluebasalt_pillar_reverse_bal": SetStation(component, TableMapper.blackforge); AddResources(component, "BlueBasalt_bal", 5, "Grausten", 6); component.m_category = (PieceCategory)3; break; case "bluebasalt_pillar_crown_bal": case "bluebasalt_pillar_crown_reverse_bal": SetStation(component, TableMapper.blackforge); AddResources(component, "BlueBasalt_bal", 3, "Grausten", 4); component.m_category = (PieceCategory)3; break; case "bluebasalt_pillar_top_bal": SetStation(component, TableMapper.blackforge); AddResources(component, "BlueBasalt_bal", 2, "Grausten", 3); component.m_category = (PieceCategory)3; break; case "bluebasalt_Pillar_base_bal": SetStation(component, TableMapper.blackforge); AddResources(component, "BlueBasalt_bal", 4, "Grausten", 5); component.m_category = (PieceCategory)3; break; case "bluebasalt_wall2x2_bal": SetStation(component, TableMapper.blackforge); AddResources(component, "BlueBasalt_bal", 4, "Grausten", 5); component.m_category = (PieceCategory)3; break; case "bluebasalt_wall_2x3_bal": case "bluebasalt_Wall_Window_2x4_bal": SetStation(component, TableMapper.blackforge); AddResources(component, "BlueBasalt_bal", 6, "Grausten", 6); component.m_category = (PieceCategory)3; break; case "bluebasalt_stair_bal": SetStation(component, TableMapper.blackforge); AddResources(component, "BlueBasalt_bal", 6, "Grausten", 6); component.m_category = (PieceCategory)3; break; case "bluebasalt_spiralstair_bal": case "bluebasalt_spiralstair_right_bal": SetStation(component, TableMapper.blackforge); AddResources(component, "BlueBasalt_bal", 4, "Grausten", 5); AddResources(component, "FlametalNew", 1); component.m_category = (PieceCategory)3; break; } } private void SetStation(Piece piece, CraftingStation station) { piece.m_craftingStation = station; } private void AddResources(Piece piece, string itemName, int amount, string altItem = "", int altAmount = 0) { List list = new List(); list.AddRange(piece.m_resources); Requirement item = createReq(itemName, amount, altItem, altAmount); list.Add(item); piece.m_resources = list.ToArray(); } private Requirement createReq(string name, int amount, string altItem = "", int altAmount = 0) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown Requirement val = new Requirement(); val.m_recover = true; GameObject val2 = list.Find((GameObject x) => ((Object)x).name == name); if ((Object)(object)val2 != (Object)null) { ItemDrop component = val2.GetComponent(); val.m_amount = amount; val.m_amountPerLevel = 0; val.m_resItem = component; } else { val2 = FindItem(list, altItem); ItemDrop component2 = val2.GetComponent(); val.m_amount = altAmount; val.m_amountPerLevel = 0; val.m_resItem = component2; } return val; } private bool itemExists(string name) { GameObject val = list.Find((GameObject x) => ((Object)x).name == name); if ((Object)(object)val != (Object)null) { return true; } return false; } private GameObject FindItem(List list, string name, bool isStation = false) { GameObject val = list.Find((GameObject x) => ((Object)x).name == name); if ((Object)(object)val != (Object)null) { return val; } if ((Object)(object)val == (Object)null && isStation) { return null; } Debug.LogWarning((object)(Launch.projectName + ": Item Not Found - " + name + ", Replaced With Wood")); return list.Find((GameObject x) => ((Object)x).name == "Wood"); } private CraftingStation FindStation(List list, string name) { GameObject val = FindItem(list, name, isStation: true); if ((Object)(object)val != (Object)null) { return val.GetComponent(); } return null; } private void setFireplaceFuelItem(Piece piece, string name, int startFuel = -1, int maxFuel = -1, float secPerFuel = -1f) { Fireplace component = ((Component)piece).GetComponent(); component.m_fuelItem = FindItem(list, name).GetComponent(); component.m_startFuel = ((startFuel != -1) ? ((float)startFuel) : component.m_startFuel); component.m_maxFuel = ((maxFuel != -1) ? ((float)maxFuel) : component.m_maxFuel); component.m_secPerFuel = ((secPerFuel != -1f) ? secPerFuel : component.m_secPerFuel); } } public class Resource { public int amount = 1; public int amountPerLevel = 0; public bool recovery = true; public ItemDrop itemDrop; public Requirement pieceConfig; public string item = "Wood"; public Resource() { } public Resource(string item, int amount, int amountPerLevel = 0, bool recovery = true) { this.item = item; this.amount = amount; this.amountPerLevel = amountPerLevel; this.recovery = recovery; } public void setItemDrop(GameObject prefab) { if ((Object)(object)prefab.GetComponent() != (Object)null) { itemDrop = prefab.GetComponent(); } else { Debug.LogWarning((object)("DVERGER FURNITURE: NO ITEM DROP FOUND on prefab name: " + ((Object)prefab).name)); } } public Requirement getPieceConfig() { //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_0013: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_003e: Expected O, but got Unknown Requirement val = new Requirement { m_resItem = itemDrop, m_amount = amount, m_amountPerLevel = amountPerLevel, m_recover = recovery }; Requirement result = val; pieceConfig = val; return result; } } public class ReferenceMapper { public static void MappBuildPieceEffectsFromTarget(GameObject gameObject, string sourceName, List list, bool isTable = false) { GameObject val = list.Find((GameObject x) => ((Object)x).name == sourceName); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("Didnt found source name: " + sourceName)); return; } Piece component = gameObject.GetComponent(); Piece component2 = val.GetComponent(); WearNTear component3 = gameObject.GetComponent(); WearNTear component4 = val.GetComponent(); component.m_placeEffect = component2.m_placeEffect; component3.m_hitEffect = component4.m_hitEffect; component3.m_destroyedEffect = component4.m_destroyedEffect; component3.m_switchEffect = component4.m_switchEffect; if (isTable) { CraftingStation component5 = gameObject.GetComponent(); CraftingStation component6 = val.GetComponent(); component5.m_craftItemDoneEffects = component6.m_craftItemDoneEffects; component5.m_craftItemEffects = component6.m_craftItemEffects; component5.m_repairItemDoneEffects = component6.m_repairItemDoneEffects; component5.m_repairItemDoneEffects = component6.m_repairItemDoneEffects; } } public static void CreateEffectsForList(EffectList effectList, List effectNames, bool clear = false) { List list = new List(); if (!clear) { list.AddRange(effectList.m_effectPrefabs); } foreach (string effectName in effectNames) { EffectInfo info = new EffectInfo(effectName); EffectData item = createEffectData(info); list.Add(item); } effectList.m_effectPrefabs = list.ToArray(); } private static EffectData createEffectData(EffectInfo info) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown EffectData val = new EffectData(); val.m_inheritParentRotation = info.inheritRotation; val.m_multiplyParentVisualScale = info.multiplyScale; val.m_childTransform = info.childName; val.m_inheritParentScale = info.inheritScale; val.m_variant = info.variant; val.m_scale = info.scale; val.m_attach = info.attach; val.m_follow = info.follow; val.m_prefab = ZNetScene.instance.m_prefabs.Find((GameObject x) => ((Object)x).name == info.name); return val; } public static void MappFromTextFile(GameObject gameObject, MappedEffectList mappedEffectList) { } } } namespace BalrondConstructions.CustomComponents { public class BalrondItemBundle : MonoBehaviour { public ItemDrop itemDrop; private void Awake() { itemDrop = ((Component)this).GetComponent(); } public void getCustomData() { } } public class BalrondPackager : MonoBehaviour { [Serializable] public class PackagerConversion { public List m_requirements; public ItemDrop m_result; public int m_resultAmount = 1; public int m_priority; [Tooltip("True: Requires only one of the list of ingredients to be able to produce the result. False: All of the ingredients are required.")] public bool m_requireOnlyOneIngredient; public int AttemptCraft(Inventory inv, List toAdd) { int num = int.MaxValue; int num2 = 0; Requirement requirement = null; foreach (Requirement requirement2 in m_requirements) { int num3 = inv.CountItems(requirement2.m_resItem.m_itemData.m_shared.m_name, -1, true) / requirement2.m_amount; if (num3 == 0 && !m_requireOnlyOneIngredient) { return 0; } if (num3 > num2) { num2 = num3; requirement = requirement2; } if (num3 < num) { num = num3; } } int num4 = (m_requireOnlyOneIngredient ? num2 : num); if (num4 == 0) { return 0; } if (m_requireOnlyOneIngredient) { inv.RemoveItem(requirement.m_resItem.m_itemData.m_shared.m_name, requirement.m_amount * num4, -1, true); } else { foreach (Requirement requirement3 in m_requirements) { inv.RemoveItem(requirement3.m_resItem.m_itemData.m_shared.m_name, requirement3.m_amount * num4, -1, true); } } int num5 = num4 * m_resultAmount; for (int i = 0; i < num5; i++) { toAdd.Add(m_result); } return num5; } } [Serializable] public class Requirement { public ItemDrop m_resItem; public int m_amount = 1; } public enum Response { Fail, Success, Conversion, Empty } public Switch m_incinerateSwitch; public Container m_container; public Animator m_leverAnim; public GameObject m_lightingAOEs; public EffectList m_leverEffects = new EffectList(); public float m_effectDelayMin = 5f; public float m_effectDelayMax = 7f; [Header("Conversion")] public List m_conversions; public ItemDrop m_defaultResult; public int m_defaultCost = 1; private ZNetView m_nview; private bool isInUse; private void Awake() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown Switch incinerateSwitch = m_incinerateSwitch; incinerateSwitch.m_onUse = (Callback)Delegate.Combine((Delegate?)(object)incinerateSwitch.m_onUse, (Delegate?)new Callback(OnIncinerate)); Switch incinerateSwitch2 = m_incinerateSwitch; incinerateSwitch2.m_onHover = (TooltipCallback)Delegate.Combine((Delegate?)(object)incinerateSwitch2.m_onHover, (Delegate?)new TooltipCallback(GetLeverHoverText)); m_conversions.Sort((PackagerConversion a, PackagerConversion b) => b.m_priority.CompareTo(a.m_priority)); m_nview = ((Component)this).GetComponent(); if (!((Object)(object)m_nview == (Object)null) && m_nview.GetZDO() != null) { m_nview.Register("RPC_RequestIncinerate", (Action)RPC_RequestIncinerate); m_nview.Register("RPC_IncinerateRespons", (Action)RPC_IncinerateRespons); m_nview.Register("RPC_AnimateLever", (Action)RPC_AnimateLever); m_nview.Register("RPC_AnimateLeverReturn", (Action)RPC_AnimateLeverReturn); } } private void StopAOE() { isInUse = false; } public string GetLeverHoverText() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) ? Localization.instance.Localize("$piece_incinerator\n$piece_noaccess") : Localization.instance.Localize("[$KEY_Use] $piece_pulllever"); } private bool OnIncinerate(Switch sw, Humanoid user, ItemData item) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (!m_nview.IsValid() || !m_nview.HasOwner() || !PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) { return false; } m_nview.InvokeRPC("RPC_RequestIncinerate", new object[1] { Game.instance.GetPlayerProfile().GetPlayerID() }); return true; } private void RPC_RequestIncinerate(long uid, long playerID) { ZLog.Log((object)("Player " + uid + " wants to incinerate " + ((Object)((Component)this).gameObject).name + " im: " + ZDOMan.GetSessionID())); if (!m_nview.IsOwner()) { ZLog.Log((object)" but im not the owner"); } else if (m_container.IsInUse() || isInUse) { m_nview.InvokeRPC(uid, "RPC_IncinerateRespons", new object[1] { 0 }); ZLog.Log((object)" but it's in use"); } else if (m_container.GetInventory().NrOfItems() == 0) { m_nview.InvokeRPC(uid, "RPC_IncinerateRespons", new object[1] { 3 }); ZLog.Log((object)" but it's empty"); } else { ((MonoBehaviour)this).StartCoroutine(Incinerate(uid)); } } private IEnumerator Incinerate(long uid) { BalrondPackager incinerator = this; incinerator.isInUse = true; incinerator.m_nview.InvokeRPC(ZNetView.Everybody, "RPC_AnimateLever", Array.Empty()); incinerator.m_leverEffects.Create(((Component)incinerator).transform.position, ((Component)incinerator).transform.rotation, (Transform)null, 1f, -1); yield return (object)new WaitForSeconds(Random.Range(incinerator.m_effectDelayMin, incinerator.m_effectDelayMax)); incinerator.m_nview.InvokeRPC(ZNetView.Everybody, "RPC_AnimateLeverReturn", Array.Empty()); if (!incinerator.m_nview.IsValid() || !incinerator.m_nview.IsOwner() || incinerator.m_container.IsInUse()) { incinerator.isInUse = false; yield break; } ((MonoBehaviour)incinerator).Invoke("StopAOE", 4f); Object.Instantiate(incinerator.m_lightingAOEs, ((Component)incinerator).transform.position, ((Component)incinerator).transform.rotation); Inventory inventory = incinerator.m_container.GetInventory(); List toAdd = new List(); int num1 = 0; foreach (PackagerConversion conversion in incinerator.m_conversions) { num1 += conversion.AttemptCraft(inventory, toAdd); } if ((Object)(object)incinerator.m_defaultResult != (Object)null && incinerator.m_defaultCost > 0) { int num2 = inventory.NrOfItemsIncludingStacks() / incinerator.m_defaultCost; num1 += num2; int index = 0; while (index < num2) { toAdd.Add(incinerator.m_defaultResult); int num3 = index + 1; index = num3; } } inventory.RemoveAll(); foreach (ItemDrop itemDrop in toAdd) { inventory.AddItem(((Component)itemDrop).gameObject, 1); } incinerator.m_nview.InvokeRPC(uid, "RPC_IncinerateRespons", new object[1] { (num1 <= 0) ? 1 : 2 }); } private void RPC_IncinerateRespons(long uid, int r) { if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { ((Character)Player.m_localPlayer).Message((MessageType)2, r switch { 1 => "$piece_incinerator_success", 2 => "$piece_incinerator_conversion", 3 => "$piece_incinerator_empty", _ => "$piece_incinerator_fail", }, 0, (Sprite)null); } } private void RPC_AnimateLever(long uid) { ZLog.Log((object)"DO THE THING WITH THE LEVER!"); m_leverAnim.SetBool("Pulled", true); } private void RPC_AnimateLeverReturn(long uid) { ZLog.Log((object)"Lever return"); m_leverAnim.SetBool("Pulled", false); } } } namespace LitJson2 { internal enum JsonType { None, Object, Array, String, Int, Long, Double, Boolean } internal interface IJsonWrapper : IList, IOrderedDictionary, IDictionary, ICollection, IEnumerable { bool IsArray { get; } bool IsBoolean { get; } bool IsDouble { get; } bool IsInt { get; } bool IsLong { get; } bool IsObject { get; } bool IsString { get; } bool GetBoolean(); double GetDouble(); int GetInt(); JsonType GetJsonType(); long GetLong(); string GetString(); void SetBoolean(bool val); void SetDouble(double val); void SetInt(int val); void SetJsonType(JsonType type); void SetLong(long val); void SetString(string val); string ToJson(); void ToJson(JsonWriter writer); } internal class JsonData : IJsonWrapper, IList, IOrderedDictionary, IDictionary, ICollection, IEnumerable, IEquatable { private IList inst_array; private bool inst_boolean; private double inst_double; private int inst_int; private long inst_long; private IDictionary inst_object; private string inst_string; private string json; private JsonType type; private IList> object_list; public int Count => EnsureCollection().Count; public bool IsArray => type == JsonType.Array; public bool IsBoolean => type == JsonType.Boolean; public bool IsDouble => type == JsonType.Double; public bool IsInt => type == JsonType.Int; public bool IsLong => type == JsonType.Long; public bool IsObject => type == JsonType.Object; public bool IsString => type == JsonType.String; public ICollection Keys { get { EnsureDictionary(); return inst_object.Keys; } } int ICollection.Count => Count; bool ICollection.IsSynchronized => EnsureCollection().IsSynchronized; object ICollection.SyncRoot => EnsureCollection().SyncRoot; bool IDictionary.IsFixedSize => EnsureDictionary().IsFixedSize; bool IDictionary.IsReadOnly => EnsureDictionary().IsReadOnly; ICollection IDictionary.Keys { get { EnsureDictionary(); IList list = new List(); foreach (KeyValuePair item in object_list) { list.Add(item.Key); } return (ICollection)list; } } ICollection IDictionary.Values { get { EnsureDictionary(); IList list = new List(); foreach (KeyValuePair item in object_list) { list.Add(item.Value); } return (ICollection)list; } } bool IJsonWrapper.IsArray => IsArray; bool IJsonWrapper.IsBoolean => IsBoolean; bool IJsonWrapper.IsDouble => IsDouble; bool IJsonWrapper.IsInt => IsInt; bool IJsonWrapper.IsLong => IsLong; bool IJsonWrapper.IsObject => IsObject; bool IJsonWrapper.IsString => IsString; bool IList.IsFixedSize => EnsureList().IsFixedSize; bool IList.IsReadOnly => EnsureList().IsReadOnly; object IDictionary.this[object key] { get { return EnsureDictionary()[key]; } set { if (!(key is string)) { throw new ArgumentException("The key has to be a string"); } JsonData value2 = ToJsonData(value); this[(string)key] = value2; } } object IOrderedDictionary.this[int idx] { get { EnsureDictionary(); return object_list[idx].Value; } set { EnsureDictionary(); JsonData value2 = ToJsonData(value); KeyValuePair keyValuePair = object_list[idx]; inst_object[keyValuePair.Key] = value2; KeyValuePair value3 = new KeyValuePair(keyValuePair.Key, value2); object_list[idx] = value3; } } object IList.this[int index] { get { return EnsureList()[index]; } set { EnsureList(); JsonData value2 = ToJsonData(value); this[index] = value2; } } public JsonData this[string prop_name] { get { EnsureDictionary(); return inst_object[prop_name]; } set { EnsureDictionary(); KeyValuePair keyValuePair = new KeyValuePair(prop_name, value); if (inst_object.ContainsKey(prop_name)) { for (int i = 0; i < object_list.Count; i++) { if (object_list[i].Key == prop_name) { object_list[i] = keyValuePair; break; } } } else { object_list.Add(keyValuePair); } inst_object[prop_name] = value; json = null; } } public JsonData this[int index] { get { EnsureCollection(); if (type == JsonType.Array) { return inst_array[index]; } return object_list[index].Value; } set { EnsureCollection(); if (type == JsonType.Array) { inst_array[index] = value; } else { KeyValuePair keyValuePair = object_list[index]; KeyValuePair value2 = new KeyValuePair(keyValuePair.Key, value); object_list[index] = value2; inst_object[keyValuePair.Key] = value; } json = null; } } public JsonData() { } public JsonData(bool boolean) { type = JsonType.Boolean; inst_boolean = boolean; } public JsonData(double number) { type = JsonType.Double; inst_double = number; } public JsonData(int number) { type = JsonType.Int; inst_int = number; } public JsonData(long number) { type = JsonType.Long; inst_long = number; } public JsonData(object obj) { if (obj is bool) { type = JsonType.Boolean; inst_boolean = (bool)obj; return; } if (obj is double) { type = JsonType.Double; inst_double = (double)obj; return; } if (obj is int) { type = JsonType.Int; inst_int = (int)obj; return; } if (obj is long) { type = JsonType.Long; inst_long = (long)obj; return; } if (obj is string) { type = JsonType.String; inst_string = (string)obj; return; } throw new ArgumentException("Unable to wrap the given object with JsonData"); } public JsonData(string str) { type = JsonType.String; inst_string = str; } public static implicit operator JsonData(bool data) { return new JsonData(data); } public static implicit operator JsonData(double data) { return new JsonData(data); } public static implicit operator JsonData(int data) { return new JsonData(data); } public static implicit operator JsonData(long data) { return new JsonData(data); } public static implicit operator JsonData(string data) { return new JsonData(data); } public static explicit operator bool(JsonData data) { if (data.type != JsonType.Boolean) { throw new InvalidCastException("Instance of JsonData doesn't hold a double"); } return data.inst_boolean; } public static explicit operator double(JsonData data) { if (data.type != JsonType.Double) { throw new InvalidCastException("Instance of JsonData doesn't hold a double"); } return data.inst_double; } public static explicit operator int(JsonData data) { if (data.type != JsonType.Int) { throw new InvalidCastException("Instance of JsonData doesn't hold an int"); } return data.inst_int; } public static explicit operator long(JsonData data) { if (data.type != JsonType.Long) { throw new InvalidCastException("Instance of JsonData doesn't hold an int"); } return data.inst_long; } public static explicit operator string(JsonData data) { if (data.type != JsonType.String) { throw new InvalidCastException("Instance of JsonData doesn't hold a string"); } return data.inst_string; } void ICollection.CopyTo(Array array, int index) { EnsureCollection().CopyTo(array, index); } void IDictionary.Add(object key, object value) { JsonData value2 = ToJsonData(value); EnsureDictionary().Add(key, value2); KeyValuePair item = new KeyValuePair((string)key, value2); object_list.Add(item); json = null; } void IDictionary.Clear() { EnsureDictionary().Clear(); object_list.Clear(); json = null; } bool IDictionary.Contains(object key) { return EnsureDictionary().Contains(key); } IDictionaryEnumerator IDictionary.GetEnumerator() { return ((IOrderedDictionary)this).GetEnumerator(); } void IDictionary.Remove(object key) { EnsureDictionary().Remove(key); for (int i = 0; i < object_list.Count; i++) { if (object_list[i].Key == (string)key) { object_list.RemoveAt(i); break; } } json = null; } IEnumerator IEnumerable.GetEnumerator() { return EnsureCollection().GetEnumerator(); } bool IJsonWrapper.GetBoolean() { if (type != JsonType.Boolean) { throw new InvalidOperationException("JsonData instance doesn't hold a boolean"); } return inst_boolean; } double IJsonWrapper.GetDouble() { if (type != JsonType.Double) { throw new InvalidOperationException("JsonData instance doesn't hold a double"); } return inst_double; } int IJsonWrapper.GetInt() { if (type != JsonType.Int) { throw new InvalidOperationException("JsonData instance doesn't hold an int"); } return inst_int; } long IJsonWrapper.GetLong() { if (type != JsonType.Long) { throw new InvalidOperationException("JsonData instance doesn't hold a long"); } return inst_long; } string IJsonWrapper.GetString() { if (type != JsonType.String) { throw new InvalidOperationException("JsonData instance doesn't hold a string"); } return inst_string; } void IJsonWrapper.SetBoolean(bool val) { type = JsonType.Boolean; inst_boolean = val; json = null; } void IJsonWrapper.SetDouble(double val) { type = JsonType.Double; inst_double = val; json = null; } void IJsonWrapper.SetInt(int val) { type = JsonType.Int; inst_int = val; json = null; } void IJsonWrapper.SetLong(long val) { type = JsonType.Long; inst_long = val; json = null; } void IJsonWrapper.SetString(string val) { type = JsonType.String; inst_string = val; json = null; } string IJsonWrapper.ToJson() { return ToJson(); } void IJsonWrapper.ToJson(JsonWriter writer) { ToJson(writer); } int IList.Add(object value) { return Add(value); } void IList.Clear() { EnsureList().Clear(); json = null; } bool IList.Contains(object value) { return EnsureList().Contains(value); } int IList.IndexOf(object value) { return EnsureList().IndexOf(value); } void IList.Insert(int index, object value) { EnsureList().Insert(index, value); json = null; } void IList.Remove(object value) { EnsureList().Remove(value); json = null; } void IList.RemoveAt(int index) { EnsureList().RemoveAt(index); json = null; } IDictionaryEnumerator IOrderedDictionary.GetEnumerator() { EnsureDictionary(); return new OrderedDictionaryEnumerator(object_list.GetEnumerator()); } void IOrderedDictionary.Insert(int idx, object key, object value) { string text = (string)key; JsonData value2 = (this[text] = ToJsonData(value)); KeyValuePair item = new KeyValuePair(text, value2); object_list.Insert(idx, item); } void IOrderedDictionary.RemoveAt(int idx) { EnsureDictionary(); inst_object.Remove(object_list[idx].Key); object_list.RemoveAt(idx); } private ICollection EnsureCollection() { if (type == JsonType.Array) { return (ICollection)inst_array; } if (type == JsonType.Object) { return (ICollection)inst_object; } throw new InvalidOperationException("The JsonData instance has to be initialized first"); } private IDictionary EnsureDictionary() { if (type == JsonType.Object) { return (IDictionary)inst_object; } if (type != 0) { throw new InvalidOperationException("Instance of JsonData is not a dictionary"); } type = JsonType.Object; inst_object = new Dictionary(); object_list = new List>(); return (IDictionary)inst_object; } private IList EnsureList() { if (type == JsonType.Array) { return (IList)inst_array; } if (type != 0) { throw new InvalidOperationException("Instance of JsonData is not a list"); } type = JsonType.Array; inst_array = new List(); return (IList)inst_array; } private JsonData ToJsonData(object obj) { if (obj == null) { return null; } if (obj is JsonData) { return (JsonData)obj; } return new JsonData(obj); } private static void WriteJson(IJsonWrapper obj, JsonWriter writer) { if (obj == null) { writer.Write(null); } else if (obj.IsString) { writer.Write(obj.GetString()); } else if (obj.IsBoolean) { writer.Write(obj.GetBoolean()); } else if (obj.IsDouble) { writer.Write(obj.GetDouble()); } else if (obj.IsInt) { writer.Write(obj.GetInt()); } else if (obj.IsLong) { writer.Write(obj.GetLong()); } else if (obj.IsArray) { writer.WriteArrayStart(); foreach (object item in (IEnumerable)obj) { WriteJson((JsonData)item, writer); } writer.WriteArrayEnd(); } else { if (!obj.IsObject) { return; } writer.WriteObjectStart(); foreach (DictionaryEntry item2 in (IDictionary)obj) { writer.WritePropertyName((string)item2.Key); WriteJson((JsonData)item2.Value, writer); } writer.WriteObjectEnd(); } } public int Add(object value) { JsonData value2 = ToJsonData(value); json = null; return EnsureList().Add(value2); } public void Clear() { if (IsObject) { ((IDictionary)this).Clear(); } else if (IsArray) { ((IList)this).Clear(); } } public bool Equals(JsonData x) { if (x == null) { return false; } if (x.type != type) { return false; } return type switch { JsonType.None => true, JsonType.Object => inst_object.Equals(x.inst_object), JsonType.Array => inst_array.Equals(x.inst_array), JsonType.String => inst_string.Equals(x.inst_string), JsonType.Int => inst_int.Equals(x.inst_int), JsonType.Long => inst_long.Equals(x.inst_long), JsonType.Double => inst_double.Equals(x.inst_double), JsonType.Boolean => inst_boolean.Equals(x.inst_boolean), _ => false, }; } public JsonType GetJsonType() { return type; } public void SetJsonType(JsonType type) { if (this.type != type) { switch (type) { case JsonType.Object: inst_object = new Dictionary(); object_list = new List>(); break; case JsonType.Array: inst_array = new List(); break; case JsonType.String: inst_string = null; break; case JsonType.Int: inst_int = 0; break; case JsonType.Long: inst_long = 0L; break; case JsonType.Double: inst_double = 0.0; break; case JsonType.Boolean: inst_boolean = false; break; } this.type = type; } } public string ToJson() { if (json != null) { return json; } StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.Validate = false; WriteJson(this, jsonWriter); json = stringWriter.ToString(); return json; } public void ToJson(JsonWriter writer) { bool validate = writer.Validate; writer.Validate = false; WriteJson(this, writer); writer.Validate = validate; } public override string ToString() { return type switch { JsonType.Array => "JsonData array", JsonType.Boolean => inst_boolean.ToString(), JsonType.Double => inst_double.ToString(), JsonType.Int => inst_int.ToString(), JsonType.Long => inst_long.ToString(), JsonType.Object => "JsonData object", JsonType.String => inst_string, _ => "Uninitialized JsonData", }; } } internal class OrderedDictionaryEnumerator : IDictionaryEnumerator, IEnumerator { private IEnumerator> list_enumerator; public object Current => Entry; public DictionaryEntry Entry { get { KeyValuePair current = list_enumerator.Current; return new DictionaryEntry(current.Key, current.Value); } } public object Key => list_enumerator.Current.Key; public object Value => list_enumerator.Current.Value; public OrderedDictionaryEnumerator(IEnumerator> enumerator) { list_enumerator = enumerator; } public bool MoveNext() { return list_enumerator.MoveNext(); } public void Reset() { list_enumerator.Reset(); } } internal class JsonException : ApplicationException { public JsonException() { } internal JsonException(ParserToken token) : base($"Invalid token '{token}' in input string") { } internal JsonException(ParserToken token, Exception inner_exception) : base($"Invalid token '{token}' in input string", inner_exception) { } internal JsonException(int c) : base($"Invalid character '{(char)c}' in input string") { } internal JsonException(int c, Exception inner_exception) : base($"Invalid character '{(char)c}' in input string", inner_exception) { } public JsonException(string message) : base(message) { } public JsonException(string message, Exception inner_exception) : base(message, inner_exception) { } } internal struct PropertyMetadata { public MemberInfo Info; public bool IsField; public Type Type; } internal struct ArrayMetadata { private Type element_type; private bool is_array; private bool is_list; public Type ElementType { get { if (element_type == null) { return typeof(JsonData); } return element_type; } set { element_type = value; } } public bool IsArray { get { return is_array; } set { is_array = value; } } public bool IsList { get { return is_list; } set { is_list = value; } } } internal struct ObjectMetadata { private Type element_type; private bool is_dictionary; private IDictionary properties; public Type ElementType { get { if (element_type == null) { return typeof(JsonData); } return element_type; } set { element_type = value; } } public bool IsDictionary { get { return is_dictionary; } set { is_dictionary = value; } } public IDictionary Properties { get { return properties; } set { properties = value; } } } internal delegate void ExporterFunc(object obj, JsonWriter writer); internal delegate void ExporterFunc(T obj, JsonWriter writer); internal delegate object ImporterFunc(object input); internal delegate TValue ImporterFunc(TJson input); internal delegate IJsonWrapper WrapperFactory(); internal class JsonMapper { private static int max_nesting_depth; private static IFormatProvider datetime_format; private static IDictionary base_exporters_table; private static IDictionary custom_exporters_table; private static IDictionary> base_importers_table; private static IDictionary> custom_importers_table; private static IDictionary array_metadata; private static readonly object array_metadata_lock; private static IDictionary> conv_ops; private static readonly object conv_ops_lock; private static IDictionary object_metadata; private static readonly object object_metadata_lock; private static IDictionary> type_properties; private static readonly object type_properties_lock; private static JsonWriter static_writer; private static readonly object static_writer_lock; static JsonMapper() { array_metadata_lock = new object(); conv_ops_lock = new object(); object_metadata_lock = new object(); type_properties_lock = new object(); static_writer_lock = new object(); max_nesting_depth = 100; array_metadata = new Dictionary(); conv_ops = new Dictionary>(); object_metadata = new Dictionary(); type_properties = new Dictionary>(); static_writer = new JsonWriter(); datetime_format = DateTimeFormatInfo.InvariantInfo; base_exporters_table = new Dictionary(); custom_exporters_table = new Dictionary(); base_importers_table = new Dictionary>(); custom_importers_table = new Dictionary>(); RegisterBaseExporters(); RegisterBaseImporters(); } private static void AddArrayMetadata(Type type) { if (array_metadata.ContainsKey(type)) { return; } ArrayMetadata value = default(ArrayMetadata); value.IsArray = type.IsArray; if (type.GetInterface("System.Collections.IList") != null) { value.IsList = true; } PropertyInfo[] properties = type.GetProperties(); foreach (PropertyInfo propertyInfo in properties) { if (!(propertyInfo.Name != "Item")) { ParameterInfo[] indexParameters = propertyInfo.GetIndexParameters(); if (indexParameters.Length == 1 && indexParameters[0].ParameterType == typeof(int)) { value.ElementType = propertyInfo.PropertyType; } } } lock (array_metadata_lock) { try { array_metadata.Add(type, value); } catch (ArgumentException) { } } } private static void AddObjectMetadata(Type type) { if (object_metadata.ContainsKey(type)) { return; } ObjectMetadata value = default(ObjectMetadata); if (type.GetInterface("System.Collections.IDictionary") != null) { value.IsDictionary = true; } value.Properties = new Dictionary(); PropertyInfo[] properties = type.GetProperties(); foreach (PropertyInfo propertyInfo in properties) { if (propertyInfo.Name == "Item") { ParameterInfo[] indexParameters = propertyInfo.GetIndexParameters(); if (indexParameters.Length == 1 && indexParameters[0].ParameterType == typeof(string)) { value.ElementType = propertyInfo.PropertyType; } } else { PropertyMetadata value2 = default(PropertyMetadata); value2.Info = propertyInfo; value2.Type = propertyInfo.PropertyType; value.Properties.Add(propertyInfo.Name, value2); } } FieldInfo[] fields = type.GetFields(); foreach (FieldInfo fieldInfo in fields) { PropertyMetadata value3 = default(PropertyMetadata); value3.Info = fieldInfo; value3.IsField = true; value3.Type = fieldInfo.FieldType; value.Properties.Add(fieldInfo.Name, value3); } lock (object_metadata_lock) { try { object_metadata.Add(type, value); } catch (ArgumentException) { } } } private static void AddTypeProperties(Type type) { if (type_properties.ContainsKey(type)) { return; } IList list = new List(); PropertyInfo[] properties = type.GetProperties(); foreach (PropertyInfo propertyInfo in properties) { if (!(propertyInfo.Name == "Item")) { PropertyMetadata item = default(PropertyMetadata); item.Info = propertyInfo; item.IsField = false; list.Add(item); } } FieldInfo[] fields = type.GetFields(); foreach (FieldInfo info in fields) { PropertyMetadata item2 = default(PropertyMetadata); item2.Info = info; item2.IsField = true; list.Add(item2); } lock (type_properties_lock) { try { type_properties.Add(type, list); } catch (ArgumentException) { } } } private static MethodInfo GetConvOp(Type t1, Type t2) { lock (conv_ops_lock) { if (!conv_ops.ContainsKey(t1)) { conv_ops.Add(t1, new Dictionary()); } } if (conv_ops[t1].ContainsKey(t2)) { return conv_ops[t1][t2]; } MethodInfo method = t1.GetMethod("op_Implicit", new Type[1] { t2 }); lock (conv_ops_lock) { try { conv_ops[t1].Add(t2, method); return method; } catch (ArgumentException) { return conv_ops[t1][t2]; } } } private static object ReadValue(Type inst_type, JsonReader reader) { reader.Read(); if (reader.Token == JsonToken.ArrayEnd) { return null; } Type underlyingType = Nullable.GetUnderlyingType(inst_type); Type type = underlyingType ?? inst_type; if (reader.Token == JsonToken.Null) { if (inst_type.IsClass || underlyingType != null) { return null; } throw new JsonException($"Can't assign null to an instance of type {inst_type}"); } if (reader.Token == JsonToken.Double || reader.Token == JsonToken.Int || reader.Token == JsonToken.Long || reader.Token == JsonToken.String || reader.Token == JsonToken.Boolean) { Type type2 = reader.Value.GetType(); if (type.IsAssignableFrom(type2)) { return reader.Value; } if (custom_importers_table.ContainsKey(type2) && custom_importers_table[type2].ContainsKey(type)) { ImporterFunc importerFunc = custom_importers_table[type2][type]; return importerFunc(reader.Value); } if (base_importers_table.ContainsKey(type2) && base_importers_table[type2].ContainsKey(type)) { ImporterFunc importerFunc2 = base_importers_table[type2][type]; return importerFunc2(reader.Value); } if (type.IsEnum) { return Enum.ToObject(type, reader.Value); } MethodInfo convOp = GetConvOp(type, type2); if (convOp != null) { return convOp.Invoke(null, new object[1] { reader.Value }); } throw new JsonException($"Can't assign value '{reader.Value}' (type {type2}) to type {inst_type}"); } object obj = null; if (reader.Token == JsonToken.ArrayStart) { AddArrayMetadata(inst_type); ArrayMetadata arrayMetadata = array_metadata[inst_type]; if (!arrayMetadata.IsArray && !arrayMetadata.IsList) { throw new JsonException($"Type {inst_type} can't act as an array"); } IList list; Type elementType; if (!arrayMetadata.IsArray) { list = (IList)Activator.CreateInstance(inst_type); elementType = arrayMetadata.ElementType; } else { list = new ArrayList(); elementType = inst_type.GetElementType(); } while (true) { object obj2 = ReadValue(elementType, reader); if (obj2 == null && reader.Token == JsonToken.ArrayEnd) { break; } list.Add(obj2); } if (arrayMetadata.IsArray) { int count = list.Count; obj = Array.CreateInstance(elementType, count); for (int i = 0; i < count; i++) { ((Array)obj).SetValue(list[i], i); } } else { obj = list; } } else if (reader.Token == JsonToken.ObjectStart) { AddObjectMetadata(type); ObjectMetadata objectMetadata = object_metadata[type]; obj = Activator.CreateInstance(type); while (true) { reader.Read(); if (reader.Token == JsonToken.ObjectEnd) { break; } string text = (string)reader.Value; if (objectMetadata.Properties.ContainsKey(text)) { PropertyMetadata propertyMetadata = objectMetadata.Properties[text]; if (propertyMetadata.IsField) { ((FieldInfo)propertyMetadata.Info).SetValue(obj, ReadValue(propertyMetadata.Type, reader)); continue; } PropertyInfo propertyInfo = (PropertyInfo)propertyMetadata.Info; if (propertyInfo.CanWrite) { propertyInfo.SetValue(obj, ReadValue(propertyMetadata.Type, reader), null); } else { ReadValue(propertyMetadata.Type, reader); } } else if (!objectMetadata.IsDictionary) { if (!reader.SkipNonMembers) { throw new JsonException($"The type {inst_type} doesn't have the property '{text}'"); } ReadSkip(reader); } else { ((IDictionary)obj).Add(text, ReadValue(objectMetadata.ElementType, reader)); } } } return obj; } private static IJsonWrapper ReadValue(WrapperFactory factory, JsonReader reader) { reader.Read(); if (reader.Token == JsonToken.ArrayEnd || reader.Token == JsonToken.Null) { return null; } IJsonWrapper jsonWrapper = factory(); if (reader.Token == JsonToken.String) { jsonWrapper.SetString((string)reader.Value); return jsonWrapper; } if (reader.Token == JsonToken.Double) { jsonWrapper.SetDouble((double)reader.Value); return jsonWrapper; } if (reader.Token == JsonToken.Int) { jsonWrapper.SetInt((int)reader.Value); return jsonWrapper; } if (reader.Token == JsonToken.Long) { jsonWrapper.SetLong((long)reader.Value); return jsonWrapper; } if (reader.Token == JsonToken.Boolean) { jsonWrapper.SetBoolean((bool)reader.Value); return jsonWrapper; } if (reader.Token == JsonToken.ArrayStart) { jsonWrapper.SetJsonType(JsonType.Array); while (true) { IJsonWrapper jsonWrapper2 = ReadValue(factory, reader); if (jsonWrapper2 == null && reader.Token == JsonToken.ArrayEnd) { break; } jsonWrapper.Add(jsonWrapper2); } } else if (reader.Token == JsonToken.ObjectStart) { jsonWrapper.SetJsonType(JsonType.Object); while (true) { reader.Read(); if (reader.Token == JsonToken.ObjectEnd) { break; } string key = (string)reader.Value; jsonWrapper[key] = ReadValue(factory, reader); } } return jsonWrapper; } private static void ReadSkip(JsonReader reader) { ToWrapper(() => new JsonMockWrapper(), reader); } private static void RegisterBaseExporters() { base_exporters_table[typeof(byte)] = delegate(object obj, JsonWriter writer) { writer.Write(Convert.ToInt32((byte)obj)); }; base_exporters_table[typeof(char)] = delegate(object obj, JsonWriter writer) { writer.Write(Convert.ToString((char)obj)); }; base_exporters_table[typeof(DateTime)] = delegate(object obj, JsonWriter writer) { writer.Write(Convert.ToString((DateTime)obj, datetime_format)); }; base_exporters_table[typeof(decimal)] = delegate(object obj, JsonWriter writer) { writer.Write((decimal)obj); }; base_exporters_table[typeof(sbyte)] = delegate(object obj, JsonWriter writer) { writer.Write(Convert.ToInt32((sbyte)obj)); }; base_exporters_table[typeof(short)] = delegate(object obj, JsonWriter writer) { writer.Write(Convert.ToInt32((short)obj)); }; base_exporters_table[typeof(ushort)] = delegate(object obj, JsonWriter writer) { writer.Write(Convert.ToInt32((ushort)obj)); }; base_exporters_table[typeof(uint)] = delegate(object obj, JsonWriter writer) { writer.Write(Convert.ToUInt64((uint)obj)); }; base_exporters_table[typeof(ulong)] = delegate(object obj, JsonWriter writer) { writer.Write((ulong)obj); }; } private static void RegisterBaseImporters() { ImporterFunc importer = (object input) => Convert.ToByte((int)input); RegisterImporter(base_importers_table, typeof(int), typeof(byte), importer); importer = (object input) => Convert.ToUInt64((int)input); RegisterImporter(base_importers_table, typeof(int), typeof(ulong), importer); importer = (object input) => Convert.ToSByte((int)input); RegisterImporter(base_importers_table, typeof(int), typeof(sbyte), importer); importer = (object input) => Convert.ToInt16((int)input); RegisterImporter(base_importers_table, typeof(int), typeof(short), importer); importer = (object input) => Convert.ToUInt16((int)input); RegisterImporter(base_importers_table, typeof(int), typeof(ushort), importer); importer = (object input) => Convert.ToUInt32((int)input); RegisterImporter(base_importers_table, typeof(int), typeof(uint), importer); importer = (object input) => Convert.ToSingle((int)input); RegisterImporter(base_importers_table, typeof(int), typeof(float), importer); importer = (object input) => Convert.ToDouble((int)input); RegisterImporter(base_importers_table, typeof(int), typeof(double), importer); importer = (object input) => Convert.ToDecimal((double)input); RegisterImporter(base_importers_table, typeof(double), typeof(decimal), importer); importer = (object input) => Convert.ToUInt32((long)input); RegisterImporter(base_importers_table, typeof(long), typeof(uint), importer); importer = (object input) => Convert.ToChar((string)input); RegisterImporter(base_importers_table, typeof(string), typeof(char), importer); importer = (object input) => Convert.ToDateTime((string)input, datetime_format); RegisterImporter(base_importers_table, typeof(string), typeof(DateTime), importer); } private static void RegisterImporter(IDictionary> table, Type json_type, Type value_type, ImporterFunc importer) { if (!table.ContainsKey(json_type)) { table.Add(json_type, new Dictionary()); } table[json_type][value_type] = importer; } private static void WriteValue(object obj, JsonWriter writer, bool writer_is_private, int depth) { if (depth > max_nesting_depth) { throw new JsonException($"Max allowed object depth reached while trying to export from type {obj.GetType()}"); } if (obj == null) { writer.Write(null); return; } if (obj is IJsonWrapper) { if (writer_is_private) { writer.TextWriter.Write(((IJsonWrapper)obj).ToJson()); } else { ((IJsonWrapper)obj).ToJson(writer); } return; } if (obj is string) { writer.Write((string)obj); return; } if (obj is double) { writer.Write((double)obj); return; } if (obj is int) { writer.Write((int)obj); return; } if (obj is bool) { writer.Write((bool)obj); return; } if (obj is long) { writer.Write((long)obj); return; } if (obj is Array) { writer.WriteArrayStart(); foreach (object item in (Array)obj) { WriteValue(item, writer, writer_is_private, depth + 1); } writer.WriteArrayEnd(); return; } if (obj is IList) { writer.WriteArrayStart(); foreach (object item2 in (IList)obj) { WriteValue(item2, writer, writer_is_private, depth + 1); } writer.WriteArrayEnd(); return; } if (obj is IDictionary) { writer.WriteObjectStart(); foreach (DictionaryEntry item3 in (IDictionary)obj) { writer.WritePropertyName((string)item3.Key); WriteValue(item3.Value, writer, writer_is_private, depth + 1); } writer.WriteObjectEnd(); return; } Type type = obj.GetType(); if (custom_exporters_table.ContainsKey(type)) { ExporterFunc exporterFunc = custom_exporters_table[type]; exporterFunc(obj, writer); return; } if (base_exporters_table.ContainsKey(type)) { ExporterFunc exporterFunc2 = base_exporters_table[type]; exporterFunc2(obj, writer); return; } if (obj is Enum) { Type underlyingType = Enum.GetUnderlyingType(type); if (underlyingType == typeof(long) || underlyingType == typeof(uint) || underlyingType == typeof(ulong)) { writer.Write((ulong)obj); } else { writer.Write((int)obj); } return; } AddTypeProperties(type); IList list = type_properties[type]; writer.WriteObjectStart(); foreach (PropertyMetadata item4 in list) { if (item4.IsField) { writer.WritePropertyName(item4.Info.Name); WriteValue(((FieldInfo)item4.Info).GetValue(obj), writer, writer_is_private, depth + 1); continue; } PropertyInfo propertyInfo = (PropertyInfo)item4.Info; if (propertyInfo.CanRead) { writer.WritePropertyName(item4.Info.Name); WriteValue(propertyInfo.GetValue(obj, null), writer, writer_is_private, depth + 1); } } writer.WriteObjectEnd(); } public static string ToJson(object obj) { lock (static_writer_lock) { static_writer.Reset(); WriteValue(obj, static_writer, writer_is_private: true, 0); return static_writer.ToString(); } } public static void ToJson(object obj, JsonWriter writer) { WriteValue(obj, writer, writer_is_private: false, 0); } public static JsonData ToObject(JsonReader reader) { return (JsonData)ToWrapper(() => new JsonData(), reader); } public static JsonData ToObject(TextReader reader) { JsonReader reader2 = new JsonReader(reader); return (JsonData)ToWrapper(() => new JsonData(), reader2); } public static JsonData ToObject(string json) { return (JsonData)ToWrapper(() => new JsonData(), json); } public static T ToObject(JsonReader reader) { return (T)ReadValue(typeof(T), reader); } public static T ToObject(TextReader reader) { JsonReader reader2 = new JsonReader(reader); return (T)ReadValue(typeof(T), reader2); } public static T ToObject(string json) { JsonReader reader = new JsonReader(json); return (T)ReadValue(typeof(T), reader); } public static IJsonWrapper ToWrapper(WrapperFactory factory, JsonReader reader) { return ReadValue(factory, reader); } public static IJsonWrapper ToWrapper(WrapperFactory factory, string json) { JsonReader reader = new JsonReader(json); return ReadValue(factory, reader); } public static void RegisterExporter(ExporterFunc exporter) { ExporterFunc value = delegate(object obj, JsonWriter writer) { exporter((T)obj, writer); }; custom_exporters_table[typeof(T)] = value; } public static void RegisterImporter(ImporterFunc importer) { ImporterFunc importer2 = (object input) => importer((TJson)input); RegisterImporter(custom_importers_table, typeof(TJson), typeof(TValue), importer2); } public static void UnregisterExporters() { custom_exporters_table.Clear(); } public static void UnregisterImporters() { custom_importers_table.Clear(); } } internal class JsonMockWrapper : IJsonWrapper, IList, IOrderedDictionary, IDictionary, ICollection, IEnumerable { public bool IsArray => false; public bool IsBoolean => false; public bool IsDouble => false; public bool IsInt => false; public bool IsLong => false; public bool IsObject => false; public bool IsString => false; bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; object IList.this[int index] { get { return null; } set { } } int ICollection.Count => 0; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => null; bool IDictionary.IsFixedSize => true; bool IDictionary.IsReadOnly => true; ICollection IDictionary.Keys => null; ICollection IDictionary.Values => null; object IDictionary.this[object key] { get { return null; } set { } } object IOrderedDictionary.this[int idx] { get { return null; } set { } } public bool GetBoolean() { return false; } public double GetDouble() { return 0.0; } public int GetInt() { return 0; } public JsonType GetJsonType() { return JsonType.None; } public long GetLong() { return 0L; } public string GetString() { return ""; } public void SetBoolean(bool val) { } public void SetDouble(double val) { } public void SetInt(int val) { } public void SetJsonType(JsonType type) { } public void SetLong(long val) { } public void SetString(string val) { } public string ToJson() { return ""; } public void ToJson(JsonWriter writer) { } int IList.Add(object value) { return 0; } void IList.Clear() { } bool IList.Contains(object value) { return false; } int IList.IndexOf(object value) { return -1; } void IList.Insert(int i, object v) { } void IList.Remove(object value) { } void IList.RemoveAt(int index) { } void ICollection.CopyTo(Array array, int index) { } IEnumerator IEnumerable.GetEnumerator() { return null; } void IDictionary.Add(object k, object v) { } void IDictionary.Clear() { } bool IDictionary.Contains(object key) { return false; } void IDictionary.Remove(object key) { } IDictionaryEnumerator IDictionary.GetEnumerator() { return null; } IDictionaryEnumerator IOrderedDictionary.GetEnumerator() { return null; } void IOrderedDictionary.Insert(int i, object k, object v) { } void IOrderedDictionary.RemoveAt(int i) { } } internal enum JsonToken { None, ObjectStart, PropertyName, ObjectEnd, ArrayStart, ArrayEnd, Int, Long, Double, String, Boolean, Null } internal class JsonReader { private static IDictionary> parse_table; private Stack automaton_stack; private int current_input; private int current_symbol; private bool end_of_json; private bool end_of_input; private Lexer lexer; private bool parser_in_string; private bool parser_return; private bool read_started; private TextReader reader; private bool reader_is_owned; private bool skip_non_members; private object token_value; private JsonToken token; public bool AllowComments { get { return lexer.AllowComments; } set { lexer.AllowComments = value; } } public bool AllowSingleQuotedStrings { get { return lexer.AllowSingleQuotedStrings; } set { lexer.AllowSingleQuotedStrings = value; } } public bool SkipNonMembers { get { return skip_non_members; } set { skip_non_members = value; } } public bool EndOfInput => end_of_input; public bool EndOfJson => end_of_json; public JsonToken Token => token; public object Value => token_value; static JsonReader() { PopulateParseTable(); } public JsonReader(string json_text) : this(new StringReader(json_text), owned: true) { } public JsonReader(TextReader reader) : this(reader, owned: false) { } private JsonReader(TextReader reader, bool owned) { if (reader == null) { throw new ArgumentNullException("reader"); } parser_in_string = false; parser_return = false; read_started = false; automaton_stack = new Stack(); automaton_stack.Push(65553); automaton_stack.Push(65543); lexer = new Lexer(reader); end_of_input = false; end_of_json = false; skip_non_members = true; this.reader = reader; reader_is_owned = owned; } private static void PopulateParseTable() { parse_table = new Dictionary>(); TableAddRow(ParserToken.Array); TableAddCol(ParserToken.Array, 91, 91, 65549); TableAddRow(ParserToken.ArrayPrime); TableAddCol(ParserToken.ArrayPrime, 34, 65550, 65551, 93); TableAddCol(ParserToken.ArrayPrime, 91, 65550, 65551, 93); TableAddCol(ParserToken.ArrayPrime, 93, 93); TableAddCol(ParserToken.ArrayPrime, 123, 65550, 65551, 93); TableAddCol(ParserToken.ArrayPrime, 65537, 65550, 65551, 93); TableAddCol(ParserToken.ArrayPrime, 65538, 65550, 65551, 93); TableAddCol(ParserToken.ArrayPrime, 65539, 65550, 65551, 93); TableAddCol(ParserToken.ArrayPrime, 65540, 65550, 65551, 93); TableAddRow(ParserToken.Object); TableAddCol(ParserToken.Object, 123, 123, 65545); TableAddRow(ParserToken.ObjectPrime); TableAddCol(ParserToken.ObjectPrime, 34, 65546, 65547, 125); TableAddCol(ParserToken.ObjectPrime, 125, 125); TableAddRow(ParserToken.Pair); TableAddCol(ParserToken.Pair, 34, 65552, 58, 65550); TableAddRow(ParserToken.PairRest); TableAddCol(ParserToken.PairRest, 44, 44, 65546, 65547); TableAddCol(ParserToken.PairRest, 125, 65554); TableAddRow(ParserToken.String); TableAddCol(ParserToken.String, 34, 34, 65541, 34); TableAddRow(ParserToken.Text); TableAddCol(ParserToken.Text, 91, 65548); TableAddCol(ParserToken.Text, 123, 65544); TableAddRow(ParserToken.Value); TableAddCol(ParserToken.Value, 34, 65552); TableAddCol(ParserToken.Value, 91, 65548); TableAddCol(ParserToken.Value, 123, 65544); TableAddCol(ParserToken.Value, 65537, 65537); TableAddCol(ParserToken.Value, 65538, 65538); TableAddCol(ParserToken.Value, 65539, 65539); TableAddCol(ParserToken.Value, 65540, 65540); TableAddRow(ParserToken.ValueRest); TableAddCol(ParserToken.ValueRest, 44, 44, 65550, 65551); TableAddCol(ParserToken.ValueRest, 93, 65554); } private static void TableAddCol(ParserToken row, int col, params int[] symbols) { parse_table[(int)row].Add(col, symbols); } private static void TableAddRow(ParserToken rule) { parse_table.Add((int)rule, new Dictionary()); } private void ProcessNumber(string number) { int result2; long result3; ulong result4; if ((number.IndexOf('.') != -1 || number.IndexOf('e') != -1 || number.IndexOf('E') != -1) && double.TryParse(number, out var result)) { token = JsonToken.Double; token_value = result; } else if (int.TryParse(number, out result2)) { token = JsonToken.Int; token_value = result2; } else if (long.TryParse(number, out result3)) { token = JsonToken.Long; token_value = result3; } else if (ulong.TryParse(number, out result4)) { token = JsonToken.Long; token_value = result4; } else { token = JsonToken.Int; token_value = 0; } } private void ProcessSymbol() { if (current_symbol == 91) { token = JsonToken.ArrayStart; parser_return = true; } else if (current_symbol == 93) { token = JsonToken.ArrayEnd; parser_return = true; } else if (current_symbol == 123) { token = JsonToken.ObjectStart; parser_return = true; } else if (current_symbol == 125) { token = JsonToken.ObjectEnd; parser_return = true; } else if (current_symbol == 34) { if (parser_in_string) { parser_in_string = false; parser_return = true; return; } if (token == JsonToken.None) { token = JsonToken.String; } parser_in_string = true; } else if (current_symbol == 65541) { token_value = lexer.StringValue; } else if (current_symbol == 65539) { token = JsonToken.Boolean; token_value = false; parser_return = true; } else if (current_symbol == 65540) { token = JsonToken.Null; parser_return = true; } else if (current_symbol == 65537) { ProcessNumber(lexer.StringValue); parser_return = true; } else if (current_symbol == 65546) { token = JsonToken.PropertyName; } else if (current_symbol == 65538) { token = JsonToken.Boolean; token_value = true; parser_return = true; } } private bool ReadToken() { if (end_of_input) { return false; } lexer.NextToken(); if (lexer.EndOfInput) { Close(); return false; } current_input = lexer.Token; return true; } public void Close() { if (!end_of_input) { end_of_input = true; end_of_json = true; if (reader_is_owned) { reader.Close(); } reader = null; } } public bool Read() { if (end_of_input) { return false; } if (end_of_json) { end_of_json = false; automaton_stack.Clear(); automaton_stack.Push(65553); automaton_stack.Push(65543); } parser_in_string = false; parser_return = false; token = JsonToken.None; token_value = null; if (!read_started) { read_started = true; if (!ReadToken()) { return false; } } while (true) { if (parser_return) { if (automaton_stack.Peek() == 65553) { end_of_json = true; } return true; } current_symbol = automaton_stack.Pop(); ProcessSymbol(); if (current_symbol == current_input) { if (!ReadToken()) { break; } continue; } int[] array; try { array = parse_table[current_symbol][current_input]; } catch (KeyNotFoundException inner_exception) { throw new JsonException((ParserToken)current_input, inner_exception); } if (array[0] != 65554) { for (int num = array.Length - 1; num >= 0; num--) { automaton_stack.Push(array[num]); } } } if (automaton_stack.Peek() != 65553) { throw new JsonException("Input doesn't evaluate to proper JSON text"); } if (parser_return) { return true; } return false; } } internal enum Condition { InArray, InObject, NotAProperty, Property, Value } internal class WriterContext { public int Count; public bool InArray; public bool InObject; public bool ExpectingValue; public int Padding; } internal class JsonWriter { private static NumberFormatInfo number_format; private WriterContext context; private Stack ctx_stack; private bool has_reached_end; private char[] hex_seq; private int indentation; private int indent_value; private StringBuilder inst_string_builder; private bool pretty_print; private bool validate; private TextWriter writer; public int IndentValue { get { return indent_value; } set { indentation = indentation / indent_value * value; indent_value = value; } } public bool PrettyPrint { get { return pretty_print; } set { pretty_print = value; } } public TextWriter TextWriter => writer; public bool Validate { get { return validate; } set { validate = value; } } static JsonWriter() { number_format = NumberFormatInfo.InvariantInfo; } public JsonWriter() { inst_string_builder = new StringBuilder(); writer = new StringWriter(inst_string_builder); Init(); } public JsonWriter(StringBuilder sb) : this(new StringWriter(sb)) { } public JsonWriter(TextWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } this.writer = writer; Init(); } private void DoValidation(Condition cond) { if (!context.ExpectingValue) { context.Count++; } if (!validate) { return; } if (has_reached_end) { throw new JsonException("A complete JSON symbol has already been written"); } switch (cond) { case Condition.InArray: if (!context.InArray) { throw new JsonException("Can't close an array here"); } break; case Condition.InObject: if (!context.InObject || context.ExpectingValue) { throw new JsonException("Can't close an object here"); } break; case Condition.NotAProperty: if (context.InObject && !context.ExpectingValue) { throw new JsonException("Expected a property"); } break; case Condition.Property: if (!context.InObject || context.ExpectingValue) { throw new JsonException("Can't add a property here"); } break; case Condition.Value: if (!context.InArray && (!context.InObject || !context.ExpectingValue)) { throw new JsonException("Can't add a value here"); } break; } } private void Init() { has_reached_end = false; hex_seq = new char[4]; indentation = 0; indent_value = 4; pretty_print = false; validate = true; ctx_stack = new Stack(); context = new WriterContext(); ctx_stack.Push(context); } private static void IntToHex(int n, char[] hex) { for (int i = 0; i < 4; i++) { int num = n % 16; if (num < 10) { hex[3 - i] = (char)(48 + num); } else { hex[3 - i] = (char)(65 + (num - 10)); } n >>= 4; } } private void Indent() { if (pretty_print) { indentation += indent_value; } } private void Put(string str) { if (pretty_print && !context.ExpectingValue) { for (int i = 0; i < indentation; i++) { writer.Write(' '); } } writer.Write(str); } private void PutNewline() { PutNewline(add_comma: true); } private void PutNewline(bool add_comma) { if (add_comma && !context.ExpectingValue && context.Count > 1) { writer.Write(','); } if (pretty_print && !context.ExpectingValue) { writer.Write('\n'); } } private void PutString(string str) { Put(string.Empty); writer.Write('"'); int length = str.Length; for (int i = 0; i < length; i++) { switch (str[i]) { case '\n': writer.Write("\\n"); continue; case '\r': writer.Write("\\r"); continue; case '\t': writer.Write("\\t"); continue; case '"': case '\\': writer.Write('\\'); writer.Write(str[i]); continue; case '\f': writer.Write("\\f"); continue; case '\b': writer.Write("\\b"); continue; } if (str[i] >= ' ' && str[i] <= '~') { writer.Write(str[i]); continue; } IntToHex(str[i], hex_seq); writer.Write("\\u"); writer.Write(hex_seq); } writer.Write('"'); } private void Unindent() { if (pretty_print) { indentation -= indent_value; } } public override string ToString() { if (inst_string_builder == null) { return string.Empty; } return inst_string_builder.ToString(); } public void Reset() { has_reached_end = false; ctx_stack.Clear(); context = new WriterContext(); ctx_stack.Push(context); if (inst_string_builder != null) { inst_string_builder.Remove(0, inst_string_builder.Length); } } public void Write(bool boolean) { DoValidation(Condition.Value); PutNewline(); Put(boolean ? "true" : "false"); context.ExpectingValue = false; } public void Write(decimal number) { DoValidation(Condition.Value); PutNewline(); Put(Convert.ToString(number, number_format)); context.ExpectingValue = false; } public void Write(double number) { DoValidation(Condition.Value); PutNewline(); string text = Convert.ToString(number, number_format); Put(text); if (text.IndexOf('.') == -1 && text.IndexOf('E') == -1) { writer.Write(".0"); } context.ExpectingValue = false; } public void Write(int number) { DoValidation(Condition.Value); PutNewline(); Put(Convert.ToString(number, number_format)); context.ExpectingValue = false; } public void Write(long number) { DoValidation(Condition.Value); PutNewline(); Put(Convert.ToString(number, number_format)); context.ExpectingValue = false; } public void Write(string str) { DoValidation(Condition.Value); PutNewline(); if (str == null) { Put("null"); } else { PutString(str); } context.ExpectingValue = false; } [CLSCompliant(false)] public void Write(ulong number) { DoValidation(Condition.Value); PutNewline(); Put(Convert.ToString(number, number_format)); context.ExpectingValue = false; } public void WriteArrayEnd() { DoValidation(Condition.InArray); PutNewline(add_comma: false); ctx_stack.Pop(); if (ctx_stack.Count == 1) { has_reached_end = true; } else { context = ctx_stack.Peek(); context.ExpectingValue = false; } Unindent(); Put("]"); } public void WriteArrayStart() { DoValidation(Condition.NotAProperty); PutNewline(); Put("["); context = new WriterContext(); context.InArray = true; ctx_stack.Push(context); Indent(); } public void WriteObjectEnd() { DoValidation(Condition.InObject); PutNewline(add_comma: false); ctx_stack.Pop(); if (ctx_stack.Count == 1) { has_reached_end = true; } else { context = ctx_stack.Peek(); context.ExpectingValue = false; } Unindent(); Put("}"); } public void WriteObjectStart() { DoValidation(Condition.NotAProperty); PutNewline(); Put("{"); context = new WriterContext(); context.InObject = true; ctx_stack.Push(context); Indent(); } public void WritePropertyName(string property_name) { DoValidation(Condition.Property); PutNewline(); PutString(property_name); if (pretty_print) { if (property_name.Length > context.Padding) { context.Padding = property_name.Length; } for (int num = context.Padding - property_name.Length; num >= 0; num--) { writer.Write(' '); } writer.Write(": "); } else { writer.Write(':'); } context.ExpectingValue = true; } } internal class FsmContext { public bool Return; public int NextState; public Lexer L; public int StateStack; } internal class Lexer { private delegate bool StateHandler(FsmContext ctx); private static int[] fsm_return_table; private static StateHandler[] fsm_handler_table; private bool allow_comments; private bool allow_single_quoted_strings; private bool end_of_input; private FsmContext fsm_context; private int input_buffer; private int input_char; private TextReader reader; private int state; private StringBuilder string_buffer; private string string_value; private int token; private int unichar; public bool AllowComments { get { return allow_comments; } set { allow_comments = value; } } public bool AllowSingleQuotedStrings { get { return allow_single_quoted_strings; } set { allow_single_quoted_strings = value; } } public bool EndOfInput => end_of_input; public int Token => token; public string StringValue => string_value; static Lexer() { PopulateFsmTables(); } public Lexer(TextReader reader) { allow_comments = true; allow_single_quoted_strings = true; input_buffer = 0; string_buffer = new StringBuilder(128); state = 1; end_of_input = false; this.reader = reader; fsm_context = new FsmContext(); fsm_context.L = this; } private static int HexValue(int digit) { switch (digit) { case 65: case 97: return 10; case 66: case 98: return 11; case 67: case 99: return 12; case 68: case 100: return 13; case 69: case 101: return 14; case 70: case 102: return 15; default: return digit - 48; } } private static void PopulateFsmTables() { fsm_handler_table = new StateHandler[28] { State1, State2, State3, State4, State5, State6, State7, State8, State9, State10, State11, State12, State13, State14, State15, State16, State17, State18, State19, State20, State21, State22, State23, State24, State25, State26, State27, State28 }; fsm_return_table = new int[28] { 65542, 0, 65537, 65537, 0, 65537, 0, 65537, 0, 0, 65538, 0, 0, 0, 65539, 0, 0, 65540, 65541, 65542, 0, 0, 65541, 65542, 0, 0, 0, 0 }; } private static char ProcessEscChar(int esc_char) { switch (esc_char) { case 34: case 39: case 47: case 92: return Convert.ToChar(esc_char); case 110: return '\n'; case 116: return '\t'; case 114: return '\r'; case 98: return '\b'; case 102: return '\f'; default: return '?'; } } private static bool State1(FsmContext ctx) { while (ctx.L.GetChar()) { if (ctx.L.input_char == 32 || (ctx.L.input_char >= 9 && ctx.L.input_char <= 13)) { continue; } if (ctx.L.input_char >= 49 && ctx.L.input_char <= 57) { ctx.L.string_buffer.Append((char)ctx.L.input_char); ctx.NextState = 3; return true; } switch (ctx.L.input_char) { case 34: ctx.NextState = 19; ctx.Return = true; return true; case 44: case 58: case 91: case 93: case 123: case 125: ctx.NextState = 1; ctx.Return = true; return true; case 45: ctx.L.string_buffer.Append((char)ctx.L.input_char); ctx.NextState = 2; return true; case 48: ctx.L.string_buffer.Append((char)ctx.L.input_char); ctx.NextState = 4; return true; case 102: ctx.NextState = 12; return true; case 110: ctx.NextState = 16; return true; case 116: ctx.NextState = 9; return true; case 39: if (!ctx.L.allow_single_quoted_strings) { return false; } ctx.L.input_char = 34; ctx.NextState = 23; ctx.Return = true; return true; case 47: if (!ctx.L.allow_comments) { return false; } ctx.NextState = 25; return true; default: return false; } } return true; } private static bool State2(FsmContext ctx) { ctx.L.GetChar(); if (ctx.L.input_char >= 49 && ctx.L.input_char <= 57) { ctx.L.string_buffer.Append((char)ctx.L.input_char); ctx.NextState = 3; return true; } int num = ctx.L.input_char; if (num == 48) { ctx.L.string_buffer.Append((char)ctx.L.input_char); ctx.NextState = 4; return true; } return false; } private static bool State3(FsmContext ctx) { while (ctx.L.GetChar()) { if (ctx.L.input_char >= 48 && ctx.L.input_char <= 57) { ctx.L.string_buffer.Append((char)ctx.L.input_char); continue; } if (ctx.L.input_char == 32 || (ctx.L.input_char >= 9 && ctx.L.input_char <= 13)) { ctx.Return = true; ctx.NextState = 1; return true; } switch (ctx.L.input_char) { case 44: case 93: case 125: ctx.L.UngetChar(); ctx.Return = true; ctx.NextState = 1; return true; case 46: ctx.L.string_buffer.Append((char)ctx.L.input_char); ctx.NextState = 5; return true; case 69: case 101: ctx.L.string_buffer.Append((char)ctx.L.input_char); ctx.NextState = 7; return true; default: return false; } } return true; } private static bool State4(FsmContext ctx) { ctx.L.GetChar(); if (ctx.L.input_char == 32 || (ctx.L.input_char >= 9 && ctx.L.input_char <= 13)) { ctx.Return = true; ctx.NextState = 1; return true; } switch (ctx.L.input_char) { case 44: case 93: case 125: ctx.L.UngetChar(); ctx.Return = true; ctx.NextState = 1; return true; case 46: ctx.L.string_buffer.Append((char)ctx.L.input_char); ctx.NextState = 5; return true; case 69: case 101: ctx.L.string_buffer.Append((char)ctx.L.input_char); ctx.NextState = 7; return true; default: return false; } } private static bool State5(FsmContext ctx) { ctx.L.GetChar(); if (ctx.L.input_char >= 48 && ctx.L.input_char <= 57) { ctx.L.string_buffer.Append((char)ctx.L.input_char); ctx.NextState = 6; return true; } return false; } private static bool State6(FsmContext ctx) { while (ctx.L.GetChar()) { if (ctx.L.input_char >= 48 && ctx.L.input_char <= 57) { ctx.L.string_buffer.Append((char)ctx.L.input_char); continue; } if (ctx.L.input_char == 32 || (ctx.L.input_char >= 9 && ctx.L.input_char <= 13)) { ctx.Return = true; ctx.NextState = 1; return true; } switch (ctx.L.input_char) { case 44: case 93: case 125: ctx.L.UngetChar(); ctx.Return = true; ctx.NextState = 1; return true; case 69: case 101: ctx.L.string_buffer.Append((char)ctx.L.input_char); ctx.NextState = 7; return true; default: return false; } } return true; } private static bool State7(FsmContext ctx) { ctx.L.GetChar(); if (ctx.L.input_char >= 48 && ctx.L.input_char <= 57) { ctx.L.string_buffer.Append((char)ctx.L.input_char); ctx.NextState = 8; return true; } switch (ctx.L.input_char) { case 43: case 45: ctx.L.string_buffer.Append((char)ctx.L.input_char); ctx.NextState = 8; return true; default: return false; } } private static bool State8(FsmContext ctx) { while (ctx.L.GetChar()) { if (ctx.L.input_char >= 48 && ctx.L.input_char <= 57) { ctx.L.string_buffer.Append((char)ctx.L.input_char); continue; } if (ctx.L.input_char == 32 || (ctx.L.input_char >= 9 && ctx.L.input_char <= 13)) { ctx.Return = true; ctx.NextState = 1; return true; } int num = ctx.L.input_char; if (num == 44 || num == 93 || num == 125) { ctx.L.UngetChar(); ctx.Return = true; ctx.NextState = 1; return true; } return false; } return true; } private static bool State9(FsmContext ctx) { ctx.L.GetChar(); int num = ctx.L.input_char; if (num == 114) { ctx.NextState = 10; return true; } return false; } private static bool State10(FsmContext ctx) { ctx.L.GetChar(); int num = ctx.L.input_char; if (num == 117) { ctx.NextState = 11; return true; } return false; } private static bool State11(FsmContext ctx) { ctx.L.GetChar(); int num = ctx.L.input_char; if (num == 101) { ctx.Return = true; ctx.NextState = 1; return true; } return false; } private static bool State12(FsmContext ctx) { ctx.L.GetChar(); int num = ctx.L.input_char; if (num == 97) { ctx.NextState = 13; return true; } return false; } private static bool State13(FsmContext ctx) { ctx.L.GetChar(); int num = ctx.L.input_char; if (num == 108) { ctx.NextState = 14; return true; } return false; } private static bool State14(FsmContext ctx) { ctx.L.GetChar(); int num = ctx.L.input_char; if (num == 115) { ctx.NextState = 15; return true; } return false; } private static bool State15(FsmContext ctx) { ctx.L.GetChar(); int num = ctx.L.input_char; if (num == 101) { ctx.Return = true; ctx.NextState = 1; return true; } return false; } private static bool State16(FsmContext ctx) { ctx.L.GetChar(); int num = ctx.L.input_char; if (num == 117) { ctx.NextState = 17; return true; } return false; } private static bool State17(FsmContext ctx) { ctx.L.GetChar(); int num = ctx.L.input_char; if (num == 108) { ctx.NextState = 18; return true; } return false; } private static bool State18(FsmContext ctx) { ctx.L.GetChar(); int num = ctx.L.input_char; if (num == 108) { ctx.Return = true; ctx.NextState = 1; return true; } return false; } private static bool State19(FsmContext ctx) { while (ctx.L.GetChar()) { switch (ctx.L.input_char) { case 34: ctx.L.UngetChar(); ctx.Return = true; ctx.NextState = 20; return true; case 92: ctx.StateStack = 19; ctx.NextState = 21; return true; } ctx.L.string_buffer.Append((char)ctx.L.input_char); } return true; } private static bool State20(FsmContext ctx) { ctx.L.GetChar(); int num = ctx.L.input_char; if (num == 34) { ctx.Return = true; ctx.NextState = 1; return true; } return false; } private static bool State21(FsmContext ctx) { ctx.L.GetChar(); switch (ctx.L.input_char) { case 117: ctx.NextState = 22; return true; case 34: case 39: case 47: case 92: case 98: case 102: case 110: case 114: case 116: ctx.L.string_buffer.Append(ProcessEscChar(ctx.L.input_char)); ctx.NextState = ctx.StateStack; return true; default: return false; } } private static bool State22(FsmContext ctx) { int num = 0; int num2 = 4096; ctx.L.unichar = 0; while (ctx.L.GetChar()) { if ((ctx.L.input_char >= 48 && ctx.L.input_char <= 57) || (ctx.L.input_char >= 65 && ctx.L.input_char <= 70) || (ctx.L.input_char >= 97 && ctx.L.input_char <= 102)) { ctx.L.unichar += HexValue(ctx.L.input_char) * num2; num++; num2 /= 16; if (num == 4) { ctx.L.string_buffer.Append(Convert.ToChar(ctx.L.unichar)); ctx.NextState = ctx.StateStack; return true; } continue; } return false; } return true; } private static bool State23(FsmContext ctx) { while (ctx.L.GetChar()) { switch (ctx.L.input_char) { case 39: ctx.L.UngetChar(); ctx.Return = true; ctx.NextState = 24; return true; case 92: ctx.StateStack = 23; ctx.NextState = 21; return true; } ctx.L.string_buffer.Append((char)ctx.L.input_char); } return true; } private static bool State24(FsmContext ctx) { ctx.L.GetChar(); int num = ctx.L.input_char; if (num == 39) { ctx.L.input_char = 34; ctx.Return = true; ctx.NextState = 1; return true; } return false; } private static bool State25(FsmContext ctx) { ctx.L.GetChar(); switch (ctx.L.input_char) { case 42: ctx.NextState = 27; return true; case 47: ctx.NextState = 26; return true; default: return false; } } private static bool State26(FsmContext ctx) { while (ctx.L.GetChar()) { if (ctx.L.input_char == 10) { ctx.NextState = 1; return true; } } return true; } private static bool State27(FsmContext ctx) { while (ctx.L.GetChar()) { if (ctx.L.input_char == 42) { ctx.NextState = 28; return true; } } return true; } private static bool State28(FsmContext ctx) { while (ctx.L.GetChar()) { if (ctx.L.input_char != 42) { if (ctx.L.input_char == 47) { ctx.NextState = 1; return true; } ctx.NextState = 27; return true; } } return true; } private bool GetChar() { if ((input_char = NextChar()) != -1) { return true; } end_of_input = true; return false; } private int NextChar() { if (input_buffer != 0) { int result = input_buffer; input_buffer = 0; return result; } return reader.Read(); } public bool NextToken() { fsm_context.Return = false; while (true) { StateHandler stateHandler = fsm_handler_table[state - 1]; if (!stateHandler(fsm_context)) { throw new JsonException(input_char); } if (end_of_input) { return false; } if (fsm_context.Return) { break; } state = fsm_context.NextState; } string_value = string_buffer.ToString(); string_buffer.Remove(0, string_buffer.Length); token = fsm_return_table[state - 1]; if (token == 65542) { token = input_char; } state = fsm_context.NextState; return true; } private void UngetChar() { input_buffer = input_char; } } internal enum ParserToken { None = 65536, Number, True, False, Null, CharSeq, Char, Text, Object, ObjectPrime, Pair, PairRest, Array, ArrayPrime, Value, ValueRest, String, End, Epsilon } }