Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of balrond furniture reborn v1.2.0
plugins/BalrondFurnitureReborn.dll
Decompiled 3 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.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 BepInEx; using HarmonyLib; using LitJson2; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("BalrondFurnitureReborn")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BalrondFurnitureReborn")] [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] namespace BalrondFurnitureReborn { public class BalrondPlanter : MonoBehaviour, Interactable, Hoverable { private const string ZDO_FlowerKey = "BalrondPlanterName"; private const string UseItemText = "$tag_plantherbseed_bal"; public EffectList m_openEffects = new EffectList(); public EffectList m_closeEffects = new EffectList(); public bool m_checkGuardStone = true; public string m_name = "$tag_plantherb_bal"; public GameObject m_toggle; private Dictionary<string, GameObject> m_flowerObjects; private ZNetView m_nview; private string currentFlowerName = string.Empty; private static readonly string[] flowerList = new string[30] { "Carrot", "CarrotSeeds", "Onion", "OnionSeeds", "Snowleaf_bal", "Moss_bal", "Cabbage_bal", "CabbageSeeds_bal", "CabbageLeaf_bal", "Yarrow_bal", "Plantain_bal", "Lavender_bal", "Sage_bal", "Dandelion", "Thistle", "EnrichedSoil_bal", "Mint_bal", "Garlic", "GarlicSeeds_bal", "Apple", "AppleSeeds", "AcaiSeeds_bal", "CypressSeeds_bal", "PoplarSeeds_bal", "YggTreeSeed_bal", "StrawSeeds_bal", "Straw_bal", "SwampTreeSeeds_bal", "WillowSeeds_bal", "BirchSeeds" }; private void Awake() { m_nview = ((Component)this).GetComponent<ZNetView>(); if (!((Object)(object)m_nview == (Object)null) && m_nview.IsValid()) { if ((Object)(object)m_toggle == (Object)null) { ZLog.LogWarning((object)("BalrondPlanter: Missing m_toggle object on " + ((Object)((Component)this).gameObject).name)); return; } m_nview.Register<string>("RequestTogglePlant", (Action<long, string>)RPC_RequestTogglePlant); currentFlowerName = m_nview.GetZDO().GetString("BalrondPlanterName", string.Empty); CacheFlowerObjects(); ((MonoBehaviour)this).InvokeRepeating("UpdateUseVisual", 0f, 5f); } } private void CacheFlowerObjects() { m_flowerObjects = new Dictionary<string, GameObject>(StringComparer.Ordinal); string[] array = flowerList; foreach (string text in array) { Transform val = m_toggle.transform.Find(text); if ((Object)(object)val != (Object)null) { m_flowerObjects[text] = ((Component)val).gameObject; ((Component)val).gameObject.SetActive(false); } } } private void RPC_RequestTogglePlant(long sender, string plantName) { ZLog.Log((object)$"BalrondPlanter: RPC_RequestTogglePlant by {sender}, plant={plantName}"); if (!m_nview.IsOwner()) { ZLog.Log((object)"RPC_RequestTogglePlant: Not owner, aborting."); return; } if (!HasAccess()) { ZLog.Log((object)"RPC_RequestTogglePlant: No access."); return; } m_nview.GetZDO().SetOwner(sender); SetToggle(plantName); } public void SetToggle(string plantName) { if (m_nview.IsOwner()) { currentFlowerName = plantName ?? string.Empty; m_nview.GetZDO().Set("BalrondPlanterName", currentFlowerName); UpdateUseVisual(); } } private bool HasAccess() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) return !m_checkGuardStone || PrivateArea.CheckAccess(((Component)this).transform.position, 0f, false, false); } private void UpdateUseVisual() { foreach (KeyValuePair<string, GameObject> flowerObject in m_flowerObjects) { flowerObject.Value.SetActive(flowerObject.Key == currentFlowerName); } } public string GetHoverText() { if (!m_nview.IsValid()) { return string.Empty; } if (!HasAccess()) { return Localization.instance.Localize(m_name + "\n $piece_noaccess"); } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(m_name); stringBuilder.AppendLine("[<color=yellow><b>1-8</b></color>] $tag_plantherbseed_bal"); if (!string.IsNullOrEmpty(currentFlowerName) && currentFlowerName != "EnrichedSoil_bal") { stringBuilder.AppendLine("[ $tag_currentflower_bal ] " + currentFlowerName); stringBuilder.AppendLine("[<color=yellow><b>$KEY_Use</b></color>] $tag_clearplanter_bal"); } else { stringBuilder.AppendLine("$tag_nothingplanted_bal"); } return Localization.instance.Localize(stringBuilder.ToString()); } public string GetHoverName() { return Localization.instance.Localize(m_name); } public bool Interact(Humanoid character, bool hold, bool alt) { if (hold) { return false; } if (!HasAccess()) { return true; } if (string.IsNullOrEmpty(currentFlowerName) || currentFlowerName == "EnrichedSoil_bal") { ((Character)character).Message((MessageType)2, "$tag_nothingtoclear_bal", 0, (Sprite)null); return true; } ((Character)character).Message((MessageType)2, "$tag_plantedcleared_bal", 0, (Sprite)null); m_nview.InvokeRPC("RequestTogglePlant", new object[1] { "EnrichedSoil_bal" }); return true; } public bool UseItem(Humanoid user, ItemData item) { if (!HasAccess()) { return true; } if ((Object)(object)item?.m_dropPrefab == (Object)null) { return false; } if (flowerList.Contains(((Object)item.m_dropPrefab).name)) { ((Character)user).Message((MessageType)2, Localization.instance.Localize("$tag_planted_bal" + item.m_shared.m_name), 0, (Sprite)null); m_nview.InvokeRPC("RequestTogglePlant", new object[1] { ((Object)item.m_dropPrefab).name }); return true; } ((Character)user).Message((MessageType)2, "$msg_wrongitem", 0, (Sprite)null); return false; } } public class BalrondToggle : MonoBehaviour, Interactable, Hoverable { public EffectList m_openEffects = new EffectList(); public EffectList m_closeEffects = new EffectList(); public bool isActive = false; public bool m_checkGuardStone = true; public string m_name = "toggle shelfs"; public GameObject m_toggle; private ZNetView m_nview; private void Awake() { m_nview = ((Component)this).GetComponent<ZNetView>(); if (m_nview.GetZDO() == null) { return; } if ((Object)(object)m_toggle == (Object)null) { ZLog.Log((object)("Missing Toggle object: " + ((Object)((Component)this).gameObject).name)); return; } if (Object.op_Implicit((Object)(object)m_nview) && (Object)(object)m_toggle != (Object)null) { m_nview.Register<long>("RequestToggle", (Action<long, long>)RPC_RequestToggle); } ((MonoBehaviour)this).InvokeRepeating("UpdateUseVisual", 0f, 1f); } private void RPC_RequestToggle(long uid, long playerID) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) ZLog.Log((object)("Player " + uid + " wants to toggle " + ((Object)((Component)this).gameObject).name + " im: " + ZDOMan.GetSessionID())); if (!m_nview.IsOwner()) { ZLog.Log((object)" but im not the owner"); return; } if (m_checkGuardStone && !PrivateArea.CheckAccess(((Component)this).transform.position, 0f, false, false)) { ZLog.Log((object)" not yours"); return; } ZDOMan.instance.ForceSendZDO(uid, m_nview.GetZDO().m_uid); m_nview.GetZDO().SetOwner(uid); SetToggle(!isActive); } public void SetToggle(bool inUse) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (m_nview.IsOwner() && isActive != inUse) { isActive = inUse; UpdateUseVisual(); if (inUse) { m_openEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1); } else { m_closeEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1); } } } private void UpdateUseVisual() { bool active; if (m_nview.IsOwner()) { active = isActive; m_nview.GetZDO().Set(ZDOVars.s_inUse, isActive ? 1 : 0, false); } else { active = m_nview.GetZDO().GetInt(ZDOVars.s_inUse, 0) == 1; } m_toggle.SetActive(active); } public string GetHoverText() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (!m_nview.IsValid()) { return ""; } if (m_checkGuardStone && !PrivateArea.CheckAccess(((Component)this).transform.position, 0f, false, false)) { return Localization.instance.Localize(m_name + "\n$piece_noaccess"); } return Localization.instance.Localize("Shelfs\n[<color=yellow><b>$KEY_Use</b></color>] " + m_name); } public string GetHoverName() { return m_name; } public bool Interact(Humanoid character, bool hold, bool alt) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (hold) { return false; } if (m_checkGuardStone && !PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) { return true; } long playerID = Game.instance.GetPlayerProfile().GetPlayerID(); m_nview.InvokeRPC("RequestToggle", new object[1] { playerID }); return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } } public class BalrondTranslator { public static Dictionary<string, Dictionary<string, string>> translations = new Dictionary<string, Dictionary<string, string>>(); public static Dictionary<string, string> getLanguage(string language) { Dictionary<string, string> result = null; try { result = translations[language]; } catch (Exception) { } return result; } } internal class BuildPieceList { public static string[] buildPieces = new string[127] { "itemstand26_inner_bal", "itemstand26_outer_bal", "itemstand45_inner_bal", "itemstand45_outer_bal", "clutter_bookset1_bal", "clutter_bookset2_bal", "clutter_bookset3_bal", "clutter_bottleset_bal", "clutter_cupset_bal", "clutter_cupset2_bal", "clutter_tableset_bal", "clutter_deskknife_bal", "hardwood_crate_bal", "Hearth_1x3_bal", "Hearth_2x3_bal", "Hearth_2x2_bal", "charred_chest_bal", "HangingJute_bal", "StatueOdin_bal", "StatueRaven_bal", "StatueThor_bal", "StatueFace_bal", "StatueEagle_bal", "StatueWolf_bal", "wood_shelf_wall_bal", "dvergr_bed_bal", "dvergr_chair_bal", "dvergr_chest_bal", "dvergr_shelf_bal", "dvergr_cabinet_high_bal", "dvergr_shelf_high_bal", "dvergr_shelf_wall_bal", "dvergr_shelf_wall_small_bal", "dvergr_cabinet_bal", "dvergr_cabinet_small_bal", "dvergr_cabinet_small_wall_bal", "dvergr_cabinet_small_drawer_bal", "dvergr_cabinet_wall_bal", "blackmarble_sarcophagus_bal", "piece_brazier_green_bal", "piece_brazierceiling_blue_bal", "piece_brazierceiling_green_bal", "dvergr_stool_bal", "dvergr_table_bal", "piece_chest_private_bal", "bed_noble_bal", "black_carpet_end_bal", "black_carpet_mid_bal", "bone_pile_bal", "core_wood_bed_bal", "rostrum_itemstand_bal", "piece_lantern_ceiling_bal", "ground_spike_trap_bal", "piece_banner_black1_bal", "piece_banner_black2_bal", "piece_banner_black3_bal", "piece_banner_black4_bal", "piece_banner12_bal", "piece_banner13_bal", "piece_banner_metal1_bal", "piece_banner_metal1_long_bal", "piece_banner_metal2_bal", "piece_banner_metal2_long_bal", "piece_banner_metal3_bal", "piece_banner_metal3_long_bal", "piece_banner_metal4_bal", "piece_banner_metal4_long_bal", "piece_bed03_bal", "piece_chicken_nest_bal", "piece_candlechandelier_bal", "piece_chest_bronze_bal", "piece_chest_jewelbox_bal", "piece_chest_stone_bal", "piece_clamChest_bal", "piece_clamChestSmall_bal", "piece_crystal_walltorch_bal", "piece_crystalchandelier_bal", "gabro_fireplace_bal", "piece_curtain_big_bal", "BustStand_bal", "herb_ladder_bal", "piece_brazierstone_bal", "WeaponDecor01_bal", "flowergirland4m_bal", "clutter_clothset1_bal", "clutter_clothset2_bal", "hildir_table_bal", "piece_table_drakkar_bal", "tabelcloth1_bal", "wagon_static_bal", "elegant_carpet_bal", "torn_carpet_bal", "corewood_stool_bal", "piece_table_round_small_bal", "piece_ashwood_echandelier_bal", "piece_darkwood_bench_bal", "piece_elegant_bench2_bal", "piece_emberwood_stool_bal", "piece_emberwoodchair_bal", "piece_sofa_bal", "piece_sofa_reverse_bal", "piece_table_round_noble_bal", "runefire_bal", "piece_bannerLong_bal", "rug_vigvisir_bal", "linen_carpet_bal", "side_wall_decor_bal", "StatueWood_bal", "corewood_crate_bal", "rug_neck_bal", "rug_fox_bal", "rug_habrok_bal", "rug_fenring_bal", "rug_troll_bal", "ladder_wood_2m_bal", "ladder_wood_4m_bal", "hook_itemstand_bal", "piece_braziercolumn_bal", "piece_curtain_side_bal", "stone_wolf_head_floor_bal", "stone_wolf_head_wall_bal", "blackmarble_runestone1_bal", "piece_deco_planter1x1_bal", "HangingMedalions_bal", "piece_cartographytable_small_bal", "piece_mosscrown_bal", "clutter_ropepile_bal" }; } public class DatabaseAddMethods { public void AddItems(List<GameObject> items) { foreach (GameObject item in items) { AddItem(item); } } public void AddRecipes(List<Recipe> recipes) { foreach (Recipe recipe in recipes) { AddRecipe(recipe); } } public void AddStatuseffects(List<StatusEffect> 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<ItemDrop>(); if ((Object)(object)component != (Object)null) { if ((Object)(object)ObjectDB.instance.GetItemPrefab(((Object)newPrefab).name) == (Object)null) { ObjectDB.instance.m_items.Add(newPrefab); Dictionary<int, GameObject> dictionary = (Dictionary<int, GameObject>)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<GameObject> allPrefabs; private string projectName = "[BalrondBiomes]"; public void setInstance(List<GameObject> gameObjects) { allPrefabs = gameObjects; } public void ReplaceOnObject(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return; } SpawnArea component = gameObject.GetComponent<SpawnArea>(); if ((Object)(object)component != (Object)null) { EffectList spawnEffects = component.m_spawnEffects; if (spawnEffects != null) { findEffectsAndChange(spawnEffects.m_effectPrefabs); } } Destructible component2 = gameObject.GetComponent<Destructible>(); 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<Projectile>(); 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<Pickable>(); if ((Object)(object)component != (Object)null) { fixPlant(component); } Destructible component2 = gameObject.GetComponent<Destructible>(); if ((Object)(object)component2 != (Object)null) { fixPDestructable(component2); } MineRock5 component3 = gameObject.GetComponent<MineRock5>(); if ((Object)(object)component3 != (Object)null) { fixMineRock5(component3); } MineRock component4 = gameObject.GetComponent<MineRock>(); 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<Humanoid>(); 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<FootStep>(); if (!((Object)(object)component2 != (Object)null)) { return; } List<StepEffect> effects = component2.m_effects; foreach (StepEffect item in effects) { GameObject[] effectPrefabs = item.m_effectPrefabs; List<GameObject> list = new List<GameObject>(); 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<ItemDrop>(); 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<Piece>(); if ((Object)(object)component != (Object)null) { EffectList placeEffect = component.m_placeEffect; if (placeEffect != null) { findEffectsAndChange(placeEffect.m_effectPrefabs); } } WearNTear component2 = gameObject.GetComponent<WearNTear>(); 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<GameObject> buildPrefabs = new List<GameObject>(); public List<GameObject> plantPrefabs = new List<GameObject>(); public List<GameObject> itemPrefabs = new List<GameObject>(); public List<GameObject> monsterPrefabs = new List<GameObject>(); public List<GameObject> vegetationPrefabs = new List<GameObject>(); public List<GameObject> clutterPrefabs = new List<GameObject>(); public List<GameObject> locationPrefabs = new List<GameObject>(); public List<GameObject> roomPrefabs = new List<GameObject>(); public List<GameObject> vfxPrefabs = new List<GameObject>(); public FxReplacment fxReplacment = null; public List<Recipe> recipes = new List<Recipe>(); public List<StatusEffect> statusEffects = new List<StatusEffect>(); public StatusEffect newBarleyStatus = null; public ShaderReplacment shaderReplacment = new ShaderReplacment(); public Sprite newLogo = null; public void loadAssets() { assetBundle = GetAssetBundleFromResources("furniturereborn_bal"); string basePath = "Assets/Custom/BalrondFurniture/"; loadPieces(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); addBalrondShelfToggle(zNetScene); addBalrondPlanter(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<ItemDrop>().m_itemData.m_shared.m_buildPieces; string[] array2 = array; foreach (string name in array2) { addBuildpiecesToOtherHammer(name, buildPieces, zNetScene); } List<GameObject> 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<ItemDrop>().m_itemData.m_shared.m_buildPieces = pieceTable; } } public void setupRavenGuide(GameObject gameObject, List<GameObject> 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<GuidePoint>(); 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<GuidePoint>().m_ravenPrefab = val; } } public void setupBuildPiecesListDB() { GameObject val = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "Hammer"); List<GameObject> pieces = val.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces.m_pieces; foreach (GameObject buildPrefab in buildPrefabs) { AddToBuildList(buildPrefab, pieces); } } private void AddToBuildList(GameObject prefab, List<GameObject> 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<ItemDrop>().m_itemData.m_shared.m_buildPieces; List<GameObject> pieces = buildPieces.m_pieces; foreach (GameObject plantPrefab in plantPrefabs) { pieces.Add(plantPrefab); } } public void FixAllFx(FxReplacment fxReplacment) { this.fxReplacment = fxReplacment; fixBuildPiecesFX(); fixVegetationFX(); fixItemFX(); fixMonsterFX(); fixOtherFX(); } private void loadStatusFromPotion() { string[] source = new string[0]; foreach (GameObject itemPrefab in itemPrefabs) { if (source.Contains(((Object)itemPrefab).name)) { ItemDrop component = itemPrefab.GetComponent<ItemDrop>(); 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 void fixVegetationFX() { foreach (GameObject vegetationPrefab in vegetationPrefabs) { fxReplacment.ReplaceOnVegetation(vegetationPrefab); } } private void fixBuildPiecesFX() { foreach (GameObject buildPrefab in buildPrefabs) { fxReplacment.ReplaceFxOnPiece(buildPrefab); } } private void fixItemFX() { foreach (GameObject itemPrefab in itemPrefabs) { fxReplacment.ReplaceOnItem(itemPrefab); } } private void fixMonsterFX() { foreach (GameObject monsterPrefab in monsterPrefabs) { fxReplacment.ReplaceOnMonster(monsterPrefab); } } private void fixOtherFX() { foreach (GameObject vfxPrefab in vfxPrefabs) { fxReplacment.ReplaceOnObject(vfxPrefab); } } 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<GameObject>(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<GameObject>(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 loadItems(string basePath) { string text = basePath + "Items/"; string[] array = new string[0]; string[] array2 = array; foreach (string text2 in array2) { GameObject val = assetBundle.LoadAsset<GameObject>(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<GameObject>(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[0]; string[] array2 = array; foreach (string text2 in array2) { GameObject val = assetBundle.LoadAsset<GameObject>(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); } } 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 static void addBalrondPlanter(ZNetScene zNetScene) { string[] array = new string[1] { "piece_deco_planter1x1_bal" }; string[] array2 = array; foreach (string planterName in array2) { GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == planterName); BalrondPlanter balrondPlanter = val.GetComponent<BalrondPlanter>(); if ((Object)(object)balrondPlanter == (Object)null) { balrondPlanter = val.AddComponent<BalrondPlanter>(); } balrondPlanter.m_toggle = ((Component)val.transform.Find("flowers")).gameObject; } } public static void addBalrondShelfToggle(ZNetScene zNetScene) { string[] array = new string[3] { "dvergr_shelf_wall_bal", "dvergr_shelf_high_bal", "dvergr_shelf_bal" }; string[] array2 = array; foreach (string shelfName in array2) { GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == shelfName); if ((Object)(object)val != (Object)null) { Container component = val.GetComponent<Container>(); BalrondToggle balrondToggle = val.GetComponent<BalrondToggle>(); if ((Object)(object)balrondToggle == (Object)null) { balrondToggle = val.AddComponent<BalrondToggle>(); } balrondToggle.m_toggle = ((Component)val.transform.Find("toggle")).gameObject; if ((Object)(object)component != (Object)null) { balrondToggle.m_openEffects = component.m_openEffects; balrondToggle.m_closeEffects = component.m_closeEffects; Object.DestroyImmediate((Object)(object)component); } } } } } public class ShaderReplacment { public static List<GameObject> prefabsToReplaceShader = new List<GameObject>(); public static List<Material> materialsInPrefabs = new List<Material>(); 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<Shader> shaders = new List<Shader>(); private static readonly HashSet<Shader> CachedShaders = new HashSet<Shader>(); public static bool debug = true; public static Shader findShader(string name) { Shader[] array = Resources.FindObjectsOfTypeAll<Shader>(); 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<Shader> 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<Renderer>(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>(); AssetBundle[] array2 = array; foreach (AssetBundle val in array2) { IEnumerable<Shader> enumerable3; try { IEnumerable<Shader> enumerable2; if (!val.isStreamedSceneAssetBundle || !Object.op_Implicit((Object)(object)val)) { IEnumerable<Shader> enumerable = val.LoadAllAssets<Shader>(); enumerable2 = enumerable; } else { enumerable2 = from shader in ((IEnumerable<string>)val.GetAllAssetNames()).Select((Func<string, Shader>)val.LoadAsset<Shader>) 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<GameObject> pieces = new List<GameObject>(); public static void setupTables(List<GameObject> list) { pieces = list; prepareTables(); } private static CraftingStation FindStation(List<GameObject> 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<CraftingStation>(); } 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, "BalrondFurnitureReborn-translation/"); defaultPath = text; } public void createDefaultPath() { string configPath = Paths.ConfigPath; string text = Path.Combine(configPath, "BalrondFurnitureReborn-translation/"); if (!Directory.Exists(text)) { CreateFolder(text); } else { Debug.Log((object)("BalrondFurnitureReborn: Folder already exists: " + text)); } defaultPath = text; } private string[] jsonFilePath(string folderName, string extension) { string configPath = Paths.ConfigPath; string text = Path.Combine(configPath, "BalrondFurnitureReborn-translation/"); if (!Directory.Exists(text)) { CreateFolder(text); } else { Debug.Log((object)("BalrondFurnitureReborn: Folder already exists: " + text)); } string[] files = Directory.GetFiles(text, extension); Debug.Log((object)("BalrondFurnitureReborn:" + folderName + " Json Files Found: " + files.Length)); return files; } private static void CreateFolder(string path) { try { Directory.CreateDirectory(path); Debug.Log((object)"BalrondFurnitureReborn: Folder created successfully."); } catch (Exception ex) { Debug.Log((object)("BalrondFurnitureReborn: 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<string, string> dictionary = new Dictionary<string, string>(); foreach (string key in jsonData.Keys) { dictionary[key] = jsonData[key].ToString(); } if (dictionary != null) { BalrondTranslator.translations.Add(fileNameWithoutExtension, dictionary); Debug.Log((object)("BalrondFurnitureReborn: Json Files Language: " + fileNameWithoutExtension)); num++; } else { Debug.LogError((object)("BalrondFurnitureReborn: Loading FAILED file: " + text)); } } Debug.Log((object)("BalrondFurnitureReborn: Translation JsonFiles Loaded: " + num)); } } [BepInPlugin("balrond.astafaraios.BalrondFurnitureReborn", "BalrondFurnitureReborn", "1.2.0")] public class Launch : BaseUnityPlugin { [HarmonyPatch(typeof(FejdStartup), "SetupGui")] private class FejdStartup_SetupGUI { private static void Postfix() { string selectedLanguage = Localization.instance.GetSelectedLanguage(); Dictionary<string, string> translations = GetTranslations(selectedLanguage); AddTranslations(translations); } } [HarmonyPriority(800)] [HarmonyPatch(typeof(Localization), "SetupLanguage")] private class Translation_SetupLanguage { private static void Prefix(Localization __instance, string language) { Dictionary<string, string> translations = GetTranslations(language); AddTranslations(translations, __instance); } } [HarmonyPriority(800)] [HarmonyPatch(typeof(Localization), "LoadCSV")] private class Translation_LoadCSV { private static void Prefix(Localization __instance, string language) { Dictionary<string, string> translations = GetTranslations(language); AddTranslations(translations, __instance); } } [HarmonyPatch(typeof(AudioMan), "Awake")] private static class AudioMan_Awake_Patch { private static void Postfix(AudioMan __instance) { List<List<GameObject>> list = new List<List<GameObject>> { modResourceLoader.itemPrefabs, modResourceLoader.buildPrefabs, modResourceLoader.monsterPrefabs, modResourceLoader.vfxPrefabs, modResourceLoader.vegetationPrefabs }; foreach (List<GameObject> item in list) { foreach (GameObject item2 in item) { AudioSource[] componentsInChildren = item2.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val in componentsInChildren) { val.outputAudioMixerGroup = __instance.m_masterMixer.outputAudioMixerGroup; } } } } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] public static class Object_CopyOtherDB_Path { public static void Postfix() { if (IsObjectDBValid()) { modResourceLoader.setupBuildPiecesListDB(); StatusEffect val = ObjectDB.instance.m_StatusEffects.Find((StatusEffect x) => ((Object)x).name == "Spirit"); databaseAddMethods.AddItems(modResourceLoader.itemPrefabs); databaseAddMethods.AddStatuseffects(modResourceLoader.statusEffects); databaseAddMethods.AddRecipes(modResourceLoader.recipes); } } } [HarmonyPatch(typeof(ObjectDB), "Awake")] public static class ObjectDB_Awake_Path { public static void Postfix() { if (IsObjectDBValid()) { modResourceLoader.setupBuildPiecesListDB(); databaseAddMethods.AddItems(modResourceLoader.itemPrefabs); databaseAddMethods.AddStatuseffects(modResourceLoader.statusEffects); databaseAddMethods.AddRecipes(modResourceLoader.recipes); ObjectDB.instance.m_recipes.Sort(SortByScore); } } private static int SortByScore(Recipe p1, Recipe p2) { if ((Object)(object)p1.m_item == (Object)null) { return 0; } if ((Object)(object)p2.m_item == (Object)null) { return 1; } return ((Object)p1.m_item).name.CompareTo(((Object)p2.m_item).name); } } [HarmonyPatch(typeof(ZNetScene), "Awake")] public static class ZNetScene_Awake_Path { public static bool hasSpawned; public static void Prefix(ZNetScene __instance) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null) { Debug.LogWarning((object)(projectName + ": No ZnetScene found")); return; } fxReplacment.setInstance(__instance.m_prefabs); modResourceLoader.FixAllFx(fxReplacment); modResourceLoader.AddPrefabsToZnetScene(__instance); if (!Launch.hasSpawned) { pieceTargeting.changePieceTargeting(__instance.m_prefabs); buildPieceBuilder.SetupBuildPieces(__instance.m_prefabs); if (!new ZNet().IsDedicated()) { ShaderReplacment.runMaterialFix(); hasSpawned = true; } } } } private readonly Harmony harmony = new Harmony("balrond.astafaraios.BalrondFurnitureReborn"); public const string PluginGUID = "balrond.astafaraios.BalrondFurnitureReborn"; public const string PluginName = "BalrondFurnitureReborn"; public const string PluginVersion = "1.2.0"; public static ModResourceLoader modResourceLoader = new ModResourceLoader(); public static FxReplacment fxReplacment = new FxReplacment(); public static DatabaseAddMethods databaseAddMethods = new DatabaseAddMethods(); public static BuildPieceTargeting pieceTargeting = new BuildPieceTargeting(); public static BuildPieceBuilder buildPieceBuilder = new BuildPieceBuilder(); public static GameObject gui; public static GameObject gui2; public static string projectName = "BalrondFurnitureReborn"; public static GameObject RootObject; public static GameObject PrefabContainer; public static bool hasSpawned = false; public static JsonLoader jsonLoader = new JsonLoader(); private void Awake() { jsonLoader.loadJson(); modResourceLoader.loadAssets(); harmony.PatchAll(); } private void OnDestroy() { harmony.UnpatchSelf(); } private static 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 static Dictionary<string, string> GetTranslations(string language) { Dictionary<string, string> result = BalrondTranslator.getLanguage("English"); if (!string.Equals(language, "English", StringComparison.OrdinalIgnoreCase)) { Dictionary<string, string> language2 = BalrondTranslator.getLanguage(language); if (language2 != null) { result = language2; } else { Debug.Log((object)("BalrondFurnitureReborn: Did not find translation file for '" + language + "', loading English")); } } return result; } private static void AddTranslations(Dictionary<string, string> translations, Localization localizationInstance = null) { if (translations == null) { Debug.LogWarning((object)"BalrondFurnitureReborn: No translation file found!"); return; } if (localizationInstance != null) { foreach (KeyValuePair<string, string> translation in translations) { localizationInstance.AddWord(translation.Key, translation.Value); } return; } foreach (KeyValuePair<string, string> translation2 in translations) { Localization.instance.AddWord(translation2.Key, translation2.Value); } } } public class BuildPieceBuilder { private List<GameObject> list; private string[] piecesNames = BuildPieceList.buildPieces; public void SetupBuildPieces(List<GameObject> 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_2799: Unknown result type (might be due to invalid IL or missing references) //IL_1dff: Unknown result type (might be due to invalid IL or missing references) //IL_1549: Unknown result type (might be due to invalid IL or missing references) //IL_15df: Unknown result type (might be due to invalid IL or missing references) //IL_3483: Unknown result type (might be due to invalid IL or missing references) //IL_2c6d: Unknown result type (might be due to invalid IL or missing references) //IL_3398: Unknown result type (might be due to invalid IL or missing references) //IL_24f8: Unknown result type (might be due to invalid IL or missing references) //IL_25c2: Unknown result type (might be due to invalid IL or missing references) //IL_22fa: Unknown result type (might be due to invalid IL or missing references) //IL_3c1c: Unknown result type (might be due to invalid IL or missing references) //IL_3a56: Unknown result type (might be due to invalid IL or missing references) //IL_1cc9: Unknown result type (might be due to invalid IL or missing references) //IL_391e: Unknown result type (might be due to invalid IL or missing references) //IL_3281: Unknown result type (might be due to invalid IL or missing references) //IL_2e66: Unknown result type (might be due to invalid IL or missing references) //IL_1b9a: Unknown result type (might be due to invalid IL or missing references) //IL_18d9: Unknown result type (might be due to invalid IL or missing references) //IL_2f38: Unknown result type (might be due to invalid IL or missing references) //IL_1997: Unknown result type (might be due to invalid IL or missing references) //IL_16c5: Unknown result type (might be due to invalid IL or missing references) //IL_14c6: Unknown result type (might be due to invalid IL or missing references) //IL_1ad2: Unknown result type (might be due to invalid IL or missing references) //IL_1e76: Unknown result type (might be due to invalid IL or missing references) //IL_21fa: Unknown result type (might be due to invalid IL or missing references) //IL_2185: Unknown result type (might be due to invalid IL or missing references) //IL_1c04: Unknown result type (might be due to invalid IL or missing references) //IL_39ba: Unknown result type (might be due to invalid IL or missing references) //IL_1648: Unknown result type (might be due to invalid IL or missing references) //IL_24a3: Unknown result type (might be due to invalid IL or missing references) //IL_1fc4: Unknown result type (might be due to invalid IL or missing references) //IL_39fc: Unknown result type (might be due to invalid IL or missing references) //IL_3216: Unknown result type (might be due to invalid IL or missing references) //IL_3b2f: Unknown result type (might be due to invalid IL or missing references) //IL_395f: Unknown result type (might be due to invalid IL or missing references) //IL_1507: Unknown result type (might be due to invalid IL or missing references) //IL_1a7d: Unknown result type (might be due to invalid IL or missing references) //IL_307b: Unknown result type (might be due to invalid IL or missing references) //IL_1807: Unknown result type (might be due to invalid IL or missing references) //IL_293e: Unknown result type (might be due to invalid IL or missing references) //IL_2122: Unknown result type (might be due to invalid IL or missing references) //IL_224f: Unknown result type (might be due to invalid IL or missing references) //IL_2dfd: Unknown result type (might be due to invalid IL or missing references) //IL_26e2: Unknown result type (might be due to invalid IL or missing references) //IL_2026: Unknown result type (might be due to invalid IL or missing references) //IL_146e: Unknown result type (might be due to invalid IL or missing references) //IL_159e: Unknown result type (might be due to invalid IL or missing references) //IL_274b: Unknown result type (might be due to invalid IL or missing references) //IL_304d: Unknown result type (might be due to invalid IL or missing references) //IL_1748: Unknown result type (might be due to invalid IL or missing references) //IL_1870: Unknown result type (might be due to invalid IL or missing references) //IL_2d2b: Unknown result type (might be due to invalid IL or missing references) //IL_2a10: Unknown result type (might be due to invalid IL or missing references) //IL_1707: Unknown result type (might be due to invalid IL or missing references) //IL_2d94: Unknown result type (might be due to invalid IL or missing references) //IL_3342: Unknown result type (might be due to invalid IL or missing references) //IL_3b71: Unknown result type (might be due to invalid IL or missing references) //IL_268d: Unknown result type (might be due to invalid IL or missing references) //IL_1942: Unknown result type (might be due to invalid IL or missing references) //IL_37d9: Unknown result type (might be due to invalid IL or missing references) //IL_3835: Unknown result type (might be due to invalid IL or missing references) //IL_1f4c: Unknown result type (might be due to invalid IL or missing references) //IL_25b6: Unknown result type (might be due to invalid IL or missing references) //IL_3118: Unknown result type (might be due to invalid IL or missing references) //IL_234f: Unknown result type (might be due to invalid IL or missing references) //IL_398d: Unknown result type (might be due to invalid IL or missing references) //IL_3a29: Unknown result type (might be due to invalid IL or missing references) //IL_2b9b: Unknown result type (might be due to invalid IL or missing references) //IL_29a7: Unknown result type (might be due to invalid IL or missing references) //IL_1d8a: Unknown result type (might be due to invalid IL or missing references) //IL_28d5: Unknown result type (might be due to invalid IL or missing references) //IL_1b13: Unknown result type (might be due to invalid IL or missing references) //IL_254d: Unknown result type (might be due to invalid IL or missing references) //IL_2fa1: Unknown result type (might be due to invalid IL or missing references) //IL_1d1e: Unknown result type (might be due to invalid IL or missing references) //IL_2cd6: Unknown result type (might be due to invalid IL or missing references) //IL_1c45: Unknown result type (might be due to invalid IL or missing references) //IL_20ae: Unknown result type (might be due to invalid IL or missing references) //IL_244e: Unknown result type (might be due to invalid IL or missing references) //IL_23a4: Unknown result type (might be due to invalid IL or missing references) //IL_20e8: Unknown result type (might be due to invalid IL or missing references) //IL_300c: Unknown result type (might be due to invalid IL or missing references) //IL_28bc: Unknown result type (might be due to invalid IL or missing references) //IL_1a14: Unknown result type (might be due to invalid IL or missing references) //IL_2b32: Unknown result type (might be due to invalid IL or missing references) //IL_34b0: Unknown result type (might be due to invalid IL or missing references) //IL_23f9: Unknown result type (might be due to invalid IL or missing references) //IL_32ec: Unknown result type (might be due to invalid IL or missing references) //IL_2ecf: Unknown result type (might be due to invalid IL or missing references) //IL_318d: Unknown result type (might be due to invalid IL or missing references) //IL_3883: Unknown result type (might be due to invalid IL or missing references) //IL_3505: Unknown result type (might be due to invalid IL or missing references) //IL_3a98: 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_285b: Unknown result type (might be due to invalid IL or missing references) //IL_2074: Unknown result type (might be due to invalid IL or missing references) //IL_38d1: Unknown result type (might be due to invalid IL or missing references) //IL_1ed7: Unknown result type (might be due to invalid IL or missing references) //IL_27e6: Unknown result type (might be due to invalid IL or missing references) //IL_178a: Unknown result type (might be due to invalid IL or missing references) //IL_3b02: Unknown result type (might be due to invalid IL or missing references) //IL_22a5: Unknown result type (might be due to invalid IL or missing references) //IL_33ed: Unknown result type (might be due to invalid IL or missing references) //IL_2c04: Unknown result type (might be due to invalid IL or missing references) //IL_2ac9: Unknown result type (might be due to invalid IL or missing references) //IL_3456: Unknown result type (might be due to invalid IL or missing references) //IL_1c87: Unknown result type (might be due to invalid IL or missing references) //IL_3c82: Unknown result type (might be due to invalid IL or missing references) Piece component = gameObject.gameObject.GetComponent<Piece>(); SetStation(component, TableMapper.workbench); component.m_resources = (Requirement[])(object)new Requirement[0]; switch (((Object)gameObject).name) { case "piece_table_drakkar_bal": SetStation(component, TableMapper.blackforge); component.m_category = (PieceCategory)4; AddResources(component, "YggdrasilWood", 20); AddResources(component, "CeramicPlate", 20); AddResources(component, "BronzeNails", 100); break; case "piece_clamChestSmall_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_category = (PieceCategory)4; AddResources(component, "BoneFragments", 5); AddResources(component, "AmberPearl", 1); break; case "piece_clamChest_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_category = (PieceCategory)4; AddResources(component, "BoneFragments", 10); AddResources(component, "SeaPearl_bal", 1); break; case "piece_lantern_ceiling_bal": SetStation(component, TableMapper.blackforge); component.m_category = (PieceCategory)4; AddResources(component, "BrassChain_bal", 1); AddResources(component, "Lantern", 1); AddResources(component, "Copper", 1); break; case "tabelcloth1_bal": SetStation(component, TableMapper.workbench); component.m_category = (PieceCategory)4; AddResources(component, "JuteThread_bal", 1); AddResources(component, "StrawThread_bal", 2); break; case "clutter_clothset1_bal": case "clutter_clothset2_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_category = (PieceCategory)4; AddResources(component, "Wood", 2); AddResources(component, "StrawThread_bal", 4); AddResources(component, "JuteBlue", 1); AddResources(component, "JuteRed", 1); break; case "flowergirland4m_bal": SetStation(component, TableMapper.workbench); component.m_category = (PieceCategory)4; AddResources(component, "Wood", 1); AddResources(component, "BasicSeed_bal", 1); AddResources(component, "Dandelion", 1); break; case "WeaponDecor01_bal": SetStation(component, TableMapper.forge); AddResources(component, "Iron", 2); AddResources(component, "Stone", 4); component.m_category = (PieceCategory)4; break; case "wagon_static_bal": SetStation(component, TableMapper.forge); AddResources(component, "Iron", 3); AddResources(component, "FineWood", 15); component.m_category = (PieceCategory)0; break; case "hildir_table_bal": SetStation(component, TableMapper.forge); AddResources(component, "Iron", 1); AddResources(component, "FineWood", 8); component.m_category = (PieceCategory)4; break; case "piece_chest_bronze_bal": SetStation(component, TableMapper.forge); AddResources(component, "Bronze", 2); AddResources(component, "FineWood", 10); component.m_category = (PieceCategory)4; break; case "gabro_fireplace_bal": SetStation(component, TableMapper.stoneCutter); setFireplaceFuelItem(component, "Wood"); AddResources(component, "Wood", 5); AddResources(component, "FineWood", 4); AddResources(component, "Gabro_bal", 4); AddResources(component, "Stone", 2); component.m_category = (PieceCategory)4; break; case "piece_brazier_green_bal": SetStation(component, TableMapper.forge); setFireplaceFuelItem(component, "Guck"); AddResources(component, "Bronze", 5); AddResources(component, "Guck", 3); AddResources(component, "WolfClaw", 3); component.m_category = (PieceCategory)4; break; case "piece_brazierceiling_blue_bal": SetStation(component, TableMapper.forge); setFireplaceFuelItem(component, "GreydwarfEye"); AddResources(component, "Bronze", 3); AddResources(component, "GreydwarfEye", 5); AddResources(component, "BrassChain_bal", 1); component.m_category = (PieceCategory)4; break; case "piece_brazierceiling_green_bal": SetStation(component, TableMapper.forge); setFireplaceFuelItem(component, "Guck"); AddResources(component, "Bronze", 3); AddResources(component, "Guck", 3); AddResources(component, "BrassChain_bal", 1); component.m_category = (PieceCategory)4; break; case "BustStand_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "RoundLog", 2); AddResources(component, "CarvedWood_bal", 2); AddResources(component, "FineWood", 2); component.m_category = (PieceCategory)4; break; case "piece_brazierstone_bal": SetStation(component, TableMapper.forge); setFireplaceFuelItem(component, "Coal"); AddResources(component, "RoundLog", 2); AddResources(component, "Coal", 2); AddResources(component, "Iron", 3); AddResources(component, "Stone", 4); component.m_category = (PieceCategory)4; break; case "herb_ladder_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "RoundLog", 2); AddResources(component, "Straw_bal", 2, "Wood", 1); AddResources(component, "Dandelion", 2); AddResources(component, "FreshSeaweed", 2); component.m_category = (PieceCategory)4; break; case "clutter_bookset1_bal": case "clutter_bookset2_bal": case "clutter_bookset3_bal": SetStation(component, TableMapper.artisian); AddResources(component, "StrawThread_bal", 1); AddResources(component, "LeatherScraps", 1); AddResources(component, "Coal", 1); component.m_category = (PieceCategory)0; break; case "clutter_deskknife_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Flint", 1); AddResources(component, "FineWood", 1); component.m_category = (PieceCategory)0; break; case "itemstand26_inner_bal": case "itemstand26_outer_bal": case "itemstand45_inner_bal": case "itemstand45_outer_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "CarvedWood_bal", 2); AddResources(component, "WoodNails_bal", 2); break; case "clutter_bottleset_bal": case "clutter_cupset_bal": case "clutter_cupset2_bal": case "clutter_tableset_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "ClayBrick_bal", 1, "Wood", 2); AddResources(component, "FineWood", 1); component.m_category = (PieceCategory)0; break; case "piece_braziercolumn_bal": setFireplaceFuelItem(component, "Coal"); SetStation(component, TableMapper.stoneCutter); AddResources(component, "Stone", 12); AddResources(component, "Coal", 2); AddResources(component, "Iron", 1); component.m_category = (PieceCategory)0; break; case "Hearth_1x3_bal": setFireplaceFuelItem(component, "Wood"); SetStation(component, TableMapper.stoneCutter); AddResources(component, "Stone", 6); component.m_category = (PieceCategory)0; break; case "Hearth_2x3_bal": setFireplaceFuelItem(component, "Wood"); SetStation(component, TableMapper.stoneCutter); AddResources(component, "Stone", 12); component.m_category = (PieceCategory)0; break; case "Hearth_2x2_bal": setFireplaceFuelItem(component, "Wood"); SetStation(component, TableMapper.stoneCutter); AddResources(component, "Stone", 9); component.m_category = (PieceCategory)0; break; case "rostrum_itemstand_bal": SetStation(component, TableMapper.stoneCutter); AddResources(component, "Stone", 5); AddResources(component, "CarvedWood_bal", 3); AddResources(component, "Resin", 2); component.m_category = (PieceCategory)4; break; case "charred_chest_bal": SetStation(component, TableMapper.magetable); AddResources(component, "CharredBone", 50); AddResources(component, "FlametalNew", 30); AddResources(component, "MorgenHeart", 2); AddResources(component, "Blackwood", 30); component.m_category = (PieceCategory)4; break; case "HangingMedalions_bal": SetStation(component, TableMapper.forge); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "JuteRed", 1); AddResources(component, "FineWood", 2); AddResources(component, "GreydwarfEye", 2); AddResources(component, "IronNails", 2); component.m_category = (PieceCategory)0; break; case "piece_ashwood_echandelier_bal": SetStation(component, TableMapper.blackforge); setFireplaceFuelItem(component, "Resin"); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Flametal", 4); AddResources(component, "Blackwood", 10); AddResources(component, "Resin", 20); component.m_category = (PieceCategory)4; break; case "HangingJute_bal": SetStation(component, TableMapper.forge); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "JuteThread_bal", 1, "JuteRed", 1); AddResources(component, "Bloodbag", 1); AddResources(component, "IronNails", 1); component.m_category = (PieceCategory)0; break; case "piece_deco_planter1x1_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "CarvedWood_bal", 1); AddResources(component, "Stone", 1); AddResources(component, "WoodBucketWater_bal", 1, "Wood", 2); AddResources(component, "EnrichedSoil_bal", 2); component.m_category = (PieceCategory)0; break; case "blackmarble_sarcophagus_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 25); AddResources(component, "BoneFragments", 25); AddResources(component, "GreydwarfEye", 10); AddResources(component, "DvergrKeyFragment", 1); component.m_category = (PieceCategory)4; break; case "StatueOdin_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 15); AddResources(component, "Stone", 5); AddResources(component, "Opal_bal", 1, "Ruby", 1); component.m_category = (PieceCategory)0; break; case "StatueFace_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 10); AddResources(component, "Sapphire_bal", 1, "Ruby", 1); component.m_category = (PieceCategory)0; break; case "StatueEagle_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 20); component.m_category = (PieceCategory)0; break; case "StatueRaven_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 20); component.m_category = (PieceCategory)0; break; case "StatueWolf_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Stone", 50); component.m_category = (PieceCategory)0; break; case "StatueThor_bal": SetStation(component, TableMapper.stoneCutter); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BlackMarble", 25); AddResources(component, "Stone", 10); AddResources(component, "Sapphire_bal", 2, "Ruby", 2); component.m_category = (PieceCategory)0; break; case "dvergr_bed_bal": SetStation(component, TableMapper.forge); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Wood", 2); AddResources(component, "ScaleHide", 2); AddResources(component, "YggdrasilWood", 2); AddResources(component, "Copper", 2); component.m_category = (PieceCategory)4; break; case "dvergr_chair_bal": SetStation(component, TableMapper.forge); AddResources(component, "LeatherScraps", 2); AddResources(component, "YggdrasilWood", 2); AddResources(component, "Copper", 2); component.m_category = (PieceCategory)4; break; case "dvergr_chest_bal": SetStation(component, TableMapper.forge); AddResources(component, "BronzeNails", 12); AddResources(component, "YggdrasilWood", 5); AddResources(component, "Copper", 5); component.m_category = (PieceCategory)4; break; case "dvergr_shelf_bal": SetStation(component, TableMapper.forge); AddResources(component, "Wood", 2); AddResources(component, "YggdrasilWood", 1); AddResources(component, "Copper", 1); component.m_category = (PieceCategory)4; break; case "wood_shelf_wall_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "CarvedWood_bal", 2); AddResources(component, "FineWood", 1); AddResources(component, "WoodNails_bal", 2, "Wood", 1); component.m_category = (PieceCategory)4; break; case "dvergr_shelf_high_bal": SetStation(component, TableMapper.forge); AddResources(component, "Wood", 3); AddResources(component, "YggdrasilWood", 2); AddResources(component, "Copper", 1); component.m_category = (PieceCategory)4; break; case "dvergr_shelf_wall_bal": SetStation(component, TableMapper.forge); AddResources(component, "Wood", 2); AddResources(component, "YggdrasilWood", 1); AddResources(component, "Copper", 1); component.m_category = (PieceCategory)4; break; case "dvergr_shelf_wall_small_bal": SetStation(component, TableMapper.forge); AddResources(component, "Wood", 1); AddResources(component, "YggdrasilWood", 1); AddResources(component, "Copper", 1); component.m_category = (PieceCategory)4; break; case "dvergr_cabinet_small_wall_bal": case "dvergr_cabinet_small_drawer_bal": case "dvergr_cabinet_small_bal": SetStation(component, TableMapper.forge); AddResources(component, "Wood", 2); AddResources(component, "YggdrasilWood", 2); AddResources(component, "Copper", 2); component.m_category = (PieceCategory)4; break; case "dvergr_cabinet_high_bal": case "dvergr_cabinet_bal": case "dvergr_cabinet_wall_bal": SetStation(component, TableMapper.forge); AddResources(component, "Wood", 4); AddResources(component, "YggdrasilWood", 3); AddResources(component, "Copper", 3); component.m_category = (PieceCategory)4; break; case "dvergr_stool_bal": SetStation(component, TableMapper.forge); AddResources(component, "Wood", 2); AddResources(component, "YggdrasilWood", 2); AddResources(component, "Copper", 2); component.m_category = (PieceCategory)4; break; case "dvergr_table_bal": SetStation(component, TableMapper.forge); AddResources(component, "IronNails", 8); AddResources(component, "Wood", 2); AddResources(component, "YggdrasilWood", 2); AddResources(component, "Copper", 2); component.m_category = (PieceCategory)4; break; case "piece_chest_private_bal": component.m_category = (PieceCategory)4; SetStation(component, TableMapper.magetable); AddResources(component, "BronzeNails", 40); AddResources(component, "YggdrasilWood", 25); AddResources(component, "DvergrKeyFragment", 1); AddResources(component, "Sap", 10); break; case "bed_noble_bal": SetStation(component, TableMapper.forge); AddResources(component, "FlametalNew", 2); AddResources(component, "Blackwood", 15); AddResources(component, "JuteRed", 4); AddResources(component, "LinenThread", 10); component.m_category = (PieceCategory)4; break; case "black_carpet_end_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "AskHide", 1); AddResources(component, "LinenThread", 2); AddResources(component, "Coal", 2); component.m_category = (PieceCategory)4; break; case "black_carpet_mid_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "AskHide", 2); AddResources(component, "LinenThread", 8); AddResources(component, "Coal", 4); AddResources(component, "JuteRed", 1); component.m_category = (PieceCategory)4; break; case "bone_pile_bal": SetStation(component, TableMapper.workbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "BoneFragments", 20); AddResources(component, "TrophySkeleton", 5); component.m_category = (PieceCategory)0; break; case "piece_mosscrown_bal": SetStation(component, TableMapper.workbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Moss_bal", 5); AddResources(component, "Wood", 3); component.m_category = (PieceCategory)4; break; case "core_wood_bed_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "TrollHide", 2); AddResources(component, "Straw_bal", 3, "Dandelion", 2); AddResources(component, "RoundLog", 5); AddResources(component, "Wood", 3); component.m_category = (PieceCategory)4; break; case "ground_spike_trap_bal": SetStation(component, TableMapper.workbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Root", 2); AddResources(component, "Straw_bal", 2, "Wood", 1); AddResources(component, "BoneFragments", 5); component.m_category = (PieceCategory)0; break; case "piece_banner10_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_category = (PieceCategory)4; AddResources(component, "FineWood", 2); AddResources(component, "DyeKit_bal", 1, "Cloudberry", 2); AddResources(component, "LeatherScraps", 3); AddResources(component, "StrawThread_bal", 3, "Wood", 2); break; case "piece_banner11_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_category = (PieceCategory)4; AddResources(component, "FineWood", 2); AddResources(component, "DyeKit_bal", 1, "Blueberries", 3); AddResources(component, "LeatherScraps", 3); AddResources(component, "StrawThread_bal", 3, "Wood", 2); break; case "piece_banner12_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_category = (PieceCategory)4; AddResources(component, "FineWood", 2); AddResources(component, "DyeKit_bal", 1, "Bloodbag", 1); AddResources(component, "JuteRed", 1); AddResources(component, "StrawThread_bal", 3, "Wood", 2); break; case "piece_banner13_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_category = (PieceCategory)4; AddResources(component, "Blackwood", 1); AddResources(component, "DyeKit_bal", 1, "Bloodbag", 1); AddResources(component, "JuteRed", 1); AddResources(component, "StrawThread_bal", 3, "Wood", 2); break; case "piece_banner_metal1_bal": SetStation(component, TableMapper.forge); AddResources(component, "Iron", 1); AddResources(component, "LinenThread", 1); AddResources(component, "DyeKit_bal", 1, "Cloudberry", 2); AddResources(component, "Coal", 2); component.m_category = (PieceCategory)4; break; case "piece_banner_metal1_long_bal": SetStation(component, TableMapper.forge); AddResources(component, "Iron", 1); AddResources(component, "LinenThread", 2); AddResources(component, "DyeKit_bal", 2, "Cloudberry", 4); AddResources(component, "Coal", 2); component.m_category = (PieceCategory)4; break; case "piece_banner_metal2_bal": SetStation(component, TableMapper.forge); AddResources(component, "Iron", 1); AddResources(component, "LinenThread", 1); AddResources(component, "DyeKit_bal", 1, "Raspberry", 2); AddResources(component, "Coal", 2); component.m_category = (PieceCategory)4; break; case "piece_banner_metal2_long_bal": SetStation(component, TableMapper.forge); AddResources(component, "Iron", 1); AddResources(component, "LinenThread", 2); AddResources(component, "DyeKit_bal", 2, "Raspberry", 4); AddResources(component, "Coal", 2); component.m_category = (PieceCategory)4; break; case "piece_banner_metal4_bal": SetStation(component, TableMapper.forge); AddResources(component, "Iron", 1); AddResources(component, "LinenThread", 1); AddResources(component, "DyeKit_bal", 1, "Blueberries", 2); AddResources(component, "Coal", 2); component.m_category = (PieceCategory)4; break; case "piece_banner_metal4_long_bal": SetStation(component, TableMapper.forge); AddResources(component, "Iron", 1); AddResources(component, "LinenThread", 2); AddResources(component, "DyeKit_bal", 2, "Blueberries", 4); AddResources(component, "Coal", 2); component.m_category = (PieceCategory)4; break; case "piece_darkwood_bench_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "ElderBark", 5); AddResources(component, "IronNails", 4); AddResources(component, "FineWood", 3); component.m_category = (PieceCategory)4; break; case "piece_banner_metal3_bal": SetStation(component, TableMapper.forge); AddResources(component, "Iron", 1); AddResources(component, "LinenThread", 1); AddResources(component, "DyeKit_bal", 1, "Guck", 2); AddResources(component, "Coal", 2); component.m_category = (PieceCategory)4; break; case "piece_banner_metal3_long_bal": SetStation(component, TableMapper.forge); AddResources(component, "Iron", 1); AddResources(component, "LinenThread", 2); AddResources(component, "DyeKit_bal", 2, "Guck", 4); AddResources(component, "Coal", 2); component.m_category = (PieceCategory)4; break; case "piece_banner_black1_bal": SetStation(component, TableMapper.forge); AddResources(component, "HardWood_bal", 1, "FineWood", 2); AddResources(component, "LeatherScraps", 4); AddResources(component, "DyeKit_bal", 2, "Blueberries", 3); AddResources(component, "Coal", 2); component.m_category = (PieceCategory)4; break; case "piece_banner_black2_bal": SetStation(component, TableMapper.forge); AddResources(component, "HardWood_bal", 1, "FineWood", 2); AddResources(component, "LeatherScraps", 4); AddResources(component, "DyeKit_bal", 2, "Resin", 3); AddResources(component, "Coal", 2); component.m_category = (PieceCategory)4; break; case "piece_banner_black3_bal": SetStation(component, TableMapper.forge); AddResources(component, "HardWood_bal", 1, "FineWood", 2); AddResources(component, "LeatherScraps", 4); AddResources(component, "DyeKit_bal", 2, "Guck", 1); AddResources(component, "Coal", 2); component.m_category = (PieceCategory)4; break; case "piece_banner_black4_bal": SetStation(component, TableMapper.forge); AddResources(component, "HardWood_bal", 1, "FineWood", 2); AddResources(component, "LeatherScraps", 4); AddResources(component, "DyeKit_bal", 2, "Bloodbag", 1); AddResources(component, "Coal", 2); component.m_category = (PieceCategory)4; break; case "piece_bed03_bal": SetStation(component, TableMapper.workbench); AddResources(component, "JuteRed", 2); AddResources(component, "JuteBlue", 4); AddResources(component, "Coal", 10); AddResources(component, "YggdrasilWood", 20); component.m_category = (PieceCategory)4; break; case "piece_chicken_nest_bal": SetStation(component, TableMapper.workbench); AddResources(component, "Straw_bal", 5); AddResources(component, "Wood", 1); component.m_category = (PieceCategory)4; break; case "clutter_ropepile_bal": SetStation(component, TableMapper.workbench); AddResources(component, "StrawThread_bal", 10); component.m_category = (PieceCategory)0; break; case "piece_candlechandelier_bal": SetStation(component, TableMapper.forge); setFireplaceFuelItem(component, "Honey"); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Honey", 4); AddResources(component, "Resin", 8); AddResources(component, "Chain", 1); AddResources(component, "Iron", 4); AddResources(component, "BronzeNails", 8); component.m_category = (PieceCategory)4; break; case "piece_crystal_walltorch_bal": SetStation(component, TableMapper.forge); setFireplaceFuelItem(component, "Crystal"); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Crystal", 2); AddResources(component, "Iron", 3); AddResources(component, "BronzeNails", 4); component.m_category = (PieceCategory)4; break; case "piece_crystalchandelier_bal": SetStation(component, TableMapper.forge); setFireplaceFuelItem(component, "Crystal"); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Crystal", 5); AddResources(component, "Iron", 6); AddResources(component, "Chain", 1); AddResources(component, "BronzeNails", 8); component.m_category = (PieceCategory)4; break; case "piece_chest_jewelbox_bal": SetStation(component, TableMapper.forge); AddResources(component, "BronzeNails", 20); AddResources(component, "FineWood", 10); AddResources(component, "HardAntler", 1); AddResources(component, "TrollHide", 2); component.m_category = (PieceCategory)4; break; case "piece_chest_stone_bal": SetStation(component, TableMapper.stoneCutter); AddResources(component, "Stone", 30); AddResources(component, "Flint", 10); AddResources(component, "SharpeningStone", 4); AddResources(component, "IronScrap", 8); component.m_category = (PieceCategory)4; break; case "blackmarble_runestone1_bal": SetStation(component, TableMapper.stoneCutter); AddResources(component, "BlackMarble", 9); AddResources(component, "Flint", 3); AddResources(component, "GreydwarfEye", 3); component.m_category = (PieceCategory)0; break; case "stone_wolf_head_floor_bal": case "stone_wolf_head_wall_bal": SetStation(component, TableMapper.stoneCutter); AddResources(component, "Stone", 9); AddResources(component, "Flint", 3); AddResources(component, "WolfFang", 3); component.m_category = (PieceCategory)4; break; case "piece_curtain_big_bal": SetStation(component, TableMapper.forge); AddResources(component, "FlametalNew", 4); AddResources(component, "JuteRed", 4); AddResources(component, "IronNails", 8); component.m_category = (PieceCategory)4; break; case "piece_cartographytable_small_bal": SetStation(component, TableMapper.forge); AddResources(component, "Finewood", 6); AddResources(component, "Iron", 2); AddResources(component, "LeatherScraps", 4); AddResources(component, "DyeKit_bal", 2); component.m_category = (PieceCategory)0; break; case "corewood_stool_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "RoundLog", 2); component.m_category = (PieceCategory)4; break; case "piece_table_round_small_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "RoundLog", 4); component.m_category = (PieceCategory)4; break; case "piece_curtain_side_bal": SetStation(component, TableMapper.forge); AddResources(component, "Silver", 1); AddResources(component, "JuteThread_bal", 4, "JuteBlue", 2); AddResources(component, "IronNails", 4); component.m_category = (PieceCategory)4; break; case "piece_elegant_bench_bal": SetStation(component, TableMapper.forge); AddResources(component, "FlametalNew", 3); AddResources(component, "Blackwood", 15); AddResources(component, "JuteRed", 2); AddResources(component, "IronNails", 8); break; case "piece_elegant_bench2_bal": SetStation(component, TableMapper.forge); AddResources(component, "FlametalNew", 4); AddResources(component, "Blackwood", 20); AddResources(component, "JuteRed", 2); AddResources(component, "IronNails", 8); break; case "piece_emberwood_stool_bal": SetStation(component, TableMapper.forge); AddResources(component, "FlametalNew", 1); AddResources(component, "Blackwood", 10); AddResources(component, "JuteRed", 1); AddResources(component, "IronNails", 4); break; case "piece_emberwoodchair_bal": SetStation(component, TableMapper.forge); AddResources(component, "FlametalNew", 4); AddResources(component, "Blackwood", 15); AddResources(component, "JuteRed", 2); AddResources(component, "IronNails", 20); break; case "piece_sofa_reverse_bal": case "piece_sofa_bal": SetStation(component, TableMapper.forge); AddResources(component, "JuteRed", 4); AddResources(component, "JuteBlue", 1); AddResources(component, "HardWood_bal", 5, "FineWood", 9); AddResources(component, "IronNails", 20); break; case "piece_table_round_noble_bal": SetStation(component, TableMapper.forge); AddResources(component, "FlametalNew", 4); AddResources(component, "Blackwood", 20); AddResources(component, "JuteRed", 3); AddResources(component, "IronNails", 8); break; case "runefire_bal": setFireplaceFuelItem(component, "Ectoplasm"); SetStation(component, TableMapper.stoneCutter); AddResources(component, "HardWood_bal", 10, "FineWood", 14); AddResources(component, "Thunderstone", 2); AddResources(component, "Ectoplasm", 5, "Guck"); AddResources(component, "Flint", 10); component.m_category = (PieceCategory)0; break; case "piece_bannerLong_bal": AddResources(component, "DyeKit_bal", 3, "Coal", 6); AddResources(component, "FineWood", 3); AddResources(component, "LinenThread", 8); AddResources(component, "LeatherScraps", 6); component.m_category = (PieceCategory)4; break; case "corewood_crate_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "RoundLog", 6); AddResources(component, "BronzeNails", 16); component.m_category = (PieceCategory)4; break; case "hardwood_crate_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "HardWood_bal", 6, "FineWood", 9); AddResources(component, "IronNails", 8); component.m_category = (PieceCategory)4; break; case "hook_itemstand_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "Chain", 1); AddResources(component, "Iron", 2); component.m_category = (PieceCategory)4; break; case "rug_habrok_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "HabrokHide_bal", 3); AddResources(component, "StrawThread_bal", 2, "Wood", 1); component.m_category = (PieceCategory)4; break; case "rug_neck_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "NeckSkin_bal", 2, "LeatherScraps", 10); component.m_category = (PieceCategory)4; break; case "side_wall_decor_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "FineWood", 2); component.m_category = (PieceCategory)2; break; case "StatueWood_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "RoundLog", 10); AddResources(component, "Ruby", 1); component.m_category = (PieceCategory)0; break; case "ladder_wood_2m_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 5); component.m_category = (PieceCategory)0; break; case "ladder_wood_4m_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Wood", 4); component.m_category = (PieceCategory)0; break; case "linen_carpet_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Bloodbag", 2); AddResources(component, "LinenThread", 10); component.m_category = (PieceCategory)4; break; case "torn_carpet_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Bloodbag", 3); AddResources(component, "LinenThread", 9); AddResources(component, "JuteRed", 3); AddResources(component, "Coal", 3); component.m_category = (PieceCategory)4; break; case "rug_troll_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "TrollHide", 5); component.m_category = (PieceCategory)4; break; case "rug_fox_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "FoxFur_bal", 2, "LeatherScraps", 30); AddResources(component, "StrawThread_bal", 2, "Wood", 2); component.m_category = (PieceCategory)4; break; case "rug_fenring_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "WolfHairBundle", 3); AddResources(component, "WolfPelt", 1); AddResources(component, "StrawThread_bal", 2, "Wood", 1); component.m_category = (PieceCategory)4; break; case "elegant_carpet_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Coal", 6); AddResources(component, "JuteRed", 5); AddResources(component, "LinenThread", 12); component.m_category = (PieceCategory)4; break; case "rug_vigvisir_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "Coal", 4); AddResources(component, "JuteRed", 4); AddResources(component, "StrawThread_bal", 8, "Wood", 3); AddResources(component, "Bloodbag", 1); component.m_category = (PieceCategory)4; break; } } private void setFireplaceFuelItem(Piece piece, string name, int startFuel = -1, int maxFuel = -1, float secPerFuel = -1f) { Fireplace component = ((Component)piece).GetComponent<Fireplace>(); component.m_fuelItem = FindItem(list, name).GetComponent<ItemDrop>(); 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); } 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<Requirement> list = new List<Requirement>(); 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_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown Requirement val = new Requirement(); val.m_recover = true; GameObject val2 = FindItem(list, name); if ((Object)(object)val2 != (Object)null) { ItemDrop component = val2.GetComponent<ItemDrop>(); val.m_amount = amount; val.m_amountPerLevel = 0; val.m_resItem = component; } else { val2 = FindItem(list, altItem); ItemDrop component2 = val2.GetComponent<ItemDrop>(); 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<GameObject> 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<GameObject> list, string