Decompiled source of balrond furniture reborn v1.0.6
plugins/BalrondFurnitureReborn.dll
Decompiled 3 weeks 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 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[67] { "clutter_bookset1_bal", "clutter_bookset2_bal", "clutter_bookset3_bal", "clutter_bottleset_bal", "clutter_cupset_bal", "clutter_tableset_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", "dvergr_bed_bal", "dvergr_chair_bal", "dvergr_chest_bal", "dvergr_shelf_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", "ground_spike_trap_bal", "piece_banner_black1_bal", "piece_banner_black2_bal", "piece_banner_black3_bal", "piece_banner_black4_bal", "piece_bed03_bal", "piece_candlechandelier_bal", "piece_chest_jewelbox_bal", "piece_chest_stone_bal", "piece_crystal_walltorch_bal", "piece_crystalchandelier_bal", "piece_curtain_big_bal", "BustStand_bal", "herb_ladder_bal", "piece_brazierstone_bal", "piece_elegant_bench2_bal", "piece_emberwood_stool_bal", "piece_emberwoodchair_bal", "piece_sofa_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_bear_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" }; } 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); } 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); } } public void setIronHook(ZNetScene zNetScene) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "piece_cookingstation_iron"); GameObject val2 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "piece_cookingstation"); ItemConversion val3 = new ItemConversion(); val3.m_from = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "BearMeat").GetComponent<ItemDrop>(); val3.m_to = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "BearMeatCooked").GetComponent<ItemDrop>(); val3.m_cookTime = 40f; ItemConversion val4 = new ItemConversion(); val4.m_from = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Potato").GetComponent<ItemDrop>(); val4.m_to = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "PotatoFried").GetComponent<ItemDrop>(); val4.m_cookTime = 30f; if ((Object)(object)val != (Object)null) { CookingStation component = val.GetComponent<CookingStation>(); component.m_conversion.Add(val4); component.m_conversion.Add(val3); } if ((Object)(object)val2 != (Object)null) { CookingStation component2 = val2.GetComponent<CookingStation>(); component2.m_conversion.Add(val4); component2.m_conversion.Add(val3); } } public void setupPickableDrops(ZNetScene zNetScene) { GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Pickable_MeadowsMeatPile01"); GameObject val2 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Pickable_MeadowsMeatPile02"); Pickable component = val.GetComponent<Pickable>(); Pickable component2 = val2.GetComponent<Pickable>(); GameObject item = getItem(zNetScene, "RawMeat"); if ((Object)(object)item != (Object)null) { component.m_itemPrefab = item; component2.m_itemPrefab = item; } createExtraDrops(component, zNetScene); createExtraDrops(component2, zNetScene); } private void createExtraDrops(Pickable pickable, ZNetScene zNetScene) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) List<DropData> list = new List<DropData>(); string name = ((Object)((Component)pickable).gameObject).name; string text = name; if (!(text == "Pickable_MeadowsMeatPile01")) { if (text == "Pickable_MeadowsMeatPile02") { list.Add(createDrop(zNetScene, "RawMeat", 1, 1, 0.4f)); list.Add(createDrop(zNetScene, "Coins", 5, 15, 0.2f)); list.Add(createDrop(zNetScene, "BoneFragments", 1, 3, 0.2f)); list.Add(createDrop(zNetScene, "NeckTail", 1, 2, 0.3f)); } } else { list.Add(createDrop(zNetScene, "RawMeat", 1, 1, 0.4f)); list.Add(createDrop(zNetScene, "DeerMeat", 1, 1, 0.2f)); list.Add(createDrop(zNetScene, "NeckTail", 1, 2, 0.3f)); list.Add(createDrop(zNetScene, "Honey", 1, 2, 0.1f)); } pickable.m_extraDrops.m_drops = list; } private DropData createDrop(ZNetScene zNetScene, string name, int min, int max, float chance) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) DropData result = default(DropData); result.m_stackMin = min; result.m_stackMax = max; result.m_weight = chance; result.m_item = getItem(zNetScene, name); return result; } private GameObject getItem(ZNetScene zNetScene, string name) { return zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == name); } } public 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) { 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)); return null; } private static void prepareTables() { cauldron = FindStation(pieces, "piece_cauldron"); workbench = FindStation(pieces, "piece_workbench"); heavyWorkbench = FindStation(pieces, "piece_heavy_workbench_bal"); forge = FindStation(pieces, "forge"); ironworks = FindStation(pieces, "piece_metalworks_bal"); blackforge = FindStation(pieces, "blackforge"); stoneCutter = FindStation(pieces, "piece_stonecutter"); artisian = FindStation(pieces, "piece_artisanstation"); runeforge = FindStation(pieces, "piece_runeforge_bal"); magetable = FindStation(pieces, "piece_magetable"); fletcher = FindStation(pieces, "piece_fletcher_bal"); } } 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.0.6")] public class Launch : BaseUnityPlugin { [HarmonyPatch(typeof(Player), "UseStamina")] private class Player_UseStamina { private static bool Prefix() { if (Player.m_debugMode && ((Terminal)Console.instance).IsCheatsEnabled()) { return false; } return true; } } [HarmonyPriority(800)] [HarmonyPatch(typeof(Localization), "SetupLanguage")] private class Translation_SetupLanguage { private static void Prefix(Localization __instance, string language) { Dictionary<string, string> dictionary = BalrondTranslator.getLanguage("English"); if ("English" != language) { Dictionary<string, string> language2 = BalrondTranslator.getLanguage(language); if (language2 != null) { dictionary = language2; } else { Debug.Log((object)"BalrondFurnitureReborn: Did not find translation file loading English"); } } if (dictionary != null) { foreach (KeyValuePair<string, string> item in dictionary) { __instance.AddWord(item.Key, item.Value); } return; } Debug.LogWarning((object)"BalrondFurnitureReborn: No translation file found!"); } } [HarmonyPriority(800)] [HarmonyPatch(typeof(Localization), "LoadCSV")] private class Translation_LoadCSV { private static void Prefix(Localization __instance, string language) { Dictionary<string, string> dictionary = BalrondTranslator.getLanguage("English"); if ("English" != language) { Dictionary<string, string> language2 = BalrondTranslator.getLanguage(language); if (language2 != null) { dictionary = language2; } else { Debug.Log((object)"BalrondFurnitureReborn: Did not find translation file loading English"); } } if (dictionary != null) { foreach (KeyValuePair<string, string> item in dictionary) { __instance.AddWord(item.Key, item.Value); } return; } Debug.LogWarning((object)"BalrondFurnitureReborn: No translation file found!"); } } [HarmonyPatch(typeof(FejdStartup), "SetupGui")] private class FejdStartup_SetupGUI { private static void Postfix() { string selectedLanguage = Localization.instance.GetSelectedLanguage(); Dictionary<string, string> dictionary = BalrondTranslator.getLanguage("English"); if ("English" != selectedLanguage) { Dictionary<string, string> language = BalrondTranslator.getLanguage(selectedLanguage); if (language != null) { dictionary = language; } else { Debug.Log((object)"BalrondFurnitureReborn: Did not find translation file loading English"); } } if (dictionary != null) { foreach (KeyValuePair<string, string> item in dictionary) { Localization.instance.AddWord(item.Key, item.Value); } return; } Debug.LogWarning((object)"BalrondFurnitureReborn: No translation file found!"); } } [HarmonyPatch(typeof(AudioMan), "Awake")] private static class AudioMan_Awake_Patch { private static void Postfix(AudioMan __instance) { foreach (GameObject itemPrefab in modResourceLoader.itemPrefabs) { AudioSource[] componentsInChildren = itemPrefab.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val in componentsInChildren) { val.outputAudioMixerGroup = __instance.m_masterMixer.outputAudioMixerGroup; } } foreach (GameObject buildPrefab in modResourceLoader.buildPrefabs) { AudioSource[] componentsInChildren2 = buildPrefab.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val2 in componentsInChildren2) { val2.outputAudioMixerGroup = __instance.m_masterMixer.outputAudioMixerGroup; } } foreach (GameObject monsterPrefab in modResourceLoader.monsterPrefabs) { AudioSource[] componentsInChildren3 = monsterPrefab.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val3 in componentsInChildren3) { val3.outputAudioMixerGroup = __instance.m_masterMixer.outputAudioMixerGroup; } } foreach (GameObject vfxPrefab in modResourceLoader.vfxPrefabs) { AudioSource[] componentsInChildren4 = vfxPrefab.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val4 in componentsInChildren4) { val4.outputAudioMixerGroup = __instance.m_masterMixer.outputAudioMixerGroup; } } foreach (GameObject vegetationPrefab in modResourceLoader.vegetationPrefabs) { AudioSource[] componentsInChildren5 = vegetationPrefab.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val5 in componentsInChildren5) { val5.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.0.6"; 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(); createPrefabContainer(); modResourceLoader.loadAssets(); harmony.PatchAll(); } private string buildUpgradeString(List<GameObject> list) { string text = "vegetation_reset "; text += buildStringFromList(list); return text + " start"; } private string buildStringFromList(List<GameObject> list) { string text = ""; foreach (GameObject item in list) { text = text + ((Object)item).name + ","; } text.Remove(text.Length - 1); return text; } public void createPrefabContainer() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown RootObject = new GameObject("_ValheimReforgedRoot"); Object.DontDestroyOnLoad((Object)(object)RootObject); PrefabContainer = new GameObject("Prefabs"); PrefabContainer.transform.parent = RootObject.transform; PrefabContainer.SetActive(false); } public static GameObject cloneMe(GameObject source, string name) { GameObject val = Object.Instantiate<GameObject>(source, PrefabContainer.transform); ((Object)val).name = name; fixMaterials(val, source); val.SetActive(true); return val; } public static void addConsumeFood(MonsterAI monsterAI, ZNetScene __instance, string name) { monsterAI.m_consumeItems.Add(__instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "BugMeat").GetComponent<ItemDrop>()); } public static GameObject fixMaterials(GameObject clone, GameObject source) { MeshRenderer[] componentsInChildren = source.GetComponentsInChildren<MeshRenderer>(); foreach (MeshRenderer val in componentsInChildren) { MeshRenderer[] componentsInChildren2 = clone.GetComponentsInChildren<MeshRenderer>(); foreach (MeshRenderer val2 in componentsInChildren2) { if (((Object)val).name == ((Object)val2).name) { ((Renderer)val2).materials = ((Renderer)val).sharedMaterials; ((Renderer)val2).sharedMaterials = ((Renderer)val).sharedMaterials; break; } } } return clone; } 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; } public static void setPlayerResistance(GameObject player) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) Humanoid component = player.GetComponent<Humanoid>(); ((Character)component).m_damageModifiers.m_spirit = (DamageModifier)0; } private static string editZnetName(string name) { name = name.Replace("(Clone)", ""); int num = name.IndexOf("("); if (num >= 0) { name = name.Substring(0, num); } return name.Trim(); } public static GameObject cloneZnet(ZNetView znet) { GameObject val = ZNetScene.instance.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)znet).name); if ((Object)(object)val != (Object)null) { Transform parent = val.transform.parent; GameObject val2 = val; val = cloneMe(val, ((Object)val2).name); val.transform.parent = parent; val2.transform.parent = null; RandomSpawn component = val2.GetComponent<RandomSpawn>(); if ((Object)(object)component != (Object)null) { RandomSpawn val3 = val.AddComponent<RandomSpawn>(); val3.m_chanceToSpawn = component.m_chanceToSpawn; if ((Object)(object)component.m_OffObject != (Object)null) { string name = ((Object)component.m_OffObject).name; Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(); Transform[] array = componentsInChildren; foreach (Transform val4 in array) { if (((Object)val4).name == name) { val3.m_OffObject = ((Component)val4).gameObject; break; } } } } return val; } return null; } } 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_1c98: Unknown result type (might be due to invalid IL or missing references) //IL_19e0: Unknown result type (might be due to invalid IL or missing references) //IL_1a28: Unknown result type (might be due to invalid IL or missing references) //IL_1585: Unknown result type (might be due to invalid IL or missing references) //IL_1af2: Unknown result type (might be due to invalid IL or missing references) //IL_16b7: Unknown result type (might be due to invalid IL or missing references) //IL_14b1: Unknown result type (might be due to invalid IL or missing references) //IL_1420: Unknown result type (might be due to invalid IL or missing references) //IL_1b29: Unknown result type (might be due to invalid IL or missing references) //IL_111c: Unknown result type (might be due to invalid IL or missing references) //IL_0c33: Unknown result type (might be due to invalid IL or missing references) //IL_0ee4: Unknown result type (might be due to invalid IL or missing references) //IL_1b79: Unknown result type (might be due to invalid IL or missing references) //IL_13b2: Unknown result type (might be due to invalid IL or missing references) //IL_1bb1: Unknown result type (might be due to invalid IL or missing references) //IL_1c61: Unknown result type (might be due to invalid IL or missing references) //IL_15eb: Unknown result type (might be due to invalid IL or missing references) //IL_1a6c: Unknown result type (might be due to invalid IL or missing references) //IL_1c39: Unknown result type (might be due to invalid IL or missing references) //IL_1cde: Unknown result type (might be due to invalid IL or missing references) //IL_1049: Unknown result type (might be due to invalid IL or missing references) //IL_0e18: Unknown result type (might be due to invalid IL or missing references) //IL_0e6b: Unknown result type (might be due to invalid IL or missing references) //IL_12bb: Unknown result type (might be due to invalid IL or missing references) //IL_0c6a: Unknown result type (might be due to invalid IL or missing references) //IL_1d30: Unknown result type (might be due to invalid IL or missing references) //IL_12ff: Unknown result type (might be due to invalid IL or missing references) //IL_1220: Unknown result type (might be due to invalid IL or missing references) //IL_117d: Unknown result type (might be due to invalid IL or missing references) //IL_10d6: Unknown result type (might be due to invalid IL or missing references) //IL_1c01: Unknown result type (might be due to invalid IL or missing references) //IL_0d7b: Unknown result type (might be due to invalid IL or missing references) //IL_1b51: Unknown result type (might be due to invalid IL or missing references) //IL_1bd9: Unknown result type (might be due to invalid IL or missing references) //IL_0dd3: Unknown result type (might be due to invalid IL or missing references) //IL_13cb: Unknown result type (might be due to invalid IL or missing references) //IL_0b3e: Unknown result type (might be due to invalid IL or missing references) //IL_0d01: Unknown result type (might be due to invalid IL or missing references) //IL_1003: Unknown result type (might be due to invalid IL or missing references) //IL_0fa2: Unknown result type (might be due to invalid IL or missing references) //IL_0f19: Unknown result type (might be due to invalid IL or missing references) //IL_0ba7: Unknown result type (might be due to invalid IL or missing references) //IL_1660: Unknown result type (might be due to invalid IL or missing references) //IL_0bfc: Unknown result type (might be due to invalid IL or missing references) //IL_179a: Unknown result type (might be due to invalid IL or missing references) //IL_1360: Unknown result type (might be due to invalid IL or missing references) //IL_0eaf: Unknown result type (might be due to invalid IL or missing references) //IL_1aaf: Unknown result type (might be due to invalid IL or missing references) //IL_1266: Unknown result type (might be due to invalid IL or missing references) //IL_1090: Unknown result type (might be due to invalid IL or missing references) //IL_1754: Unknown result type (might be due to invalid IL or missing references) //IL_0d3e: Unknown result type (might be due to invalid IL or missing references) //IL_1171: Unknown result type (might be due to invalid IL or missing references) //IL_0cc5: Unknown result type (might be due to invalid IL or missing references) //IL_170e: Unknown result type (might be due to invalid IL or missing references) //IL_0f4e: Unknown result type (might be due to invalid IL or missing references) Piece component = gameObject.gameObject.GetComponent<Piece>(); SetStation(component, TableMapper.workbench); switch (((Object)gameObject).name) { case "BustStand_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "RoundLog", 2); AddResources(component, "Wood", 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", 2); 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, "FineWood", 1); AddResources(component, "Coal", 1); component.m_category = (PieceCategory)0; break; case "clutter_bottleset_bal": case "clutter_cupset_bal": case "clutter_tableset_bal": SetStation(component, TableMapper.artisian); AddResources(component, "ClayBrick_bal", 1); 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 "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 "HangingJute_bal": component.m_resources = (Requirement[])(object)new Requirement[0]; AddResources(component, "JuteThread_bal", 1); AddResources(component, "Bloodbag", 1); AddResources(component, "IronNails", 1); component.m_category = (PieceCategory)0; 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); 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); 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); 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", 2); AddResources(component, "Copper", 2); 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 "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); 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); AddResources(component, "BoneFragments", 5); component.m_category = (PieceCategory)0; break; case "piece_banner10_bal": case "piece_banner11_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_category = (PieceCategory)4; AddResources(component, "FineWood", 2); AddResources(component, "DyeKit_bal", 1); AddResources(component, "LeatherScraps", 3); AddResources(component, "StrawThread_bal", 3); break; case "piece_banner12_bal": SetStation(component, TableMapper.heavyWorkbench); component.m_category = (PieceCategory)4; AddResources(component, "FineWood", 2); AddResources(component, "DyeKit_bal", 1); AddResources(component, "JuteRed", 1); AddResources(component, "StrawThread_bal", 3); break; case "piece_banner_black1_bal": case "piece_banner_black2_bal": case "piece_banner_black3_bal": case "piece_banner_black4_bal": SetStation(component, TableMapper.forge); AddResources(component, "HardWood_bal", 1); AddResources(component, "LeatherScraps", 4); AddResources(component, "DyeKit_bal", 2); 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); 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 "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_curtain_side_bal": SetStation(component, TableMapper.forge); AddResources(component, "Silver", 1); AddResources(component, "JuteThread_bal", 4); 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_bal": SetStation(component, TableMapper.forge); AddResources(component, "JuteRed", 4); AddResources(component, "JuteBlue", 1); AddResources(component, "HardWood_bal", 5); 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, "SpiritShard_bal"); SetStation(component, TableMapper.stoneCutter); AddResources(component, "HardWood_bal", 10); AddResources(component, "Thunderstone", 2); AddResources(component, "SpiritShard_bal", 5); AddResources(component, "Flint", 10); component.m_category = (PieceCategory)0; break; case "piece_bannerLong_bal": AddResources(component, "DyeKit_bal", 3); 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); 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_bear_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "BearFur_bal", 3); AddResources(component, "StrawThread_bal", 2); component.m_category = (PieceCategory)4; break; case "rug_neck_bal": SetStation(component, TableMapper.heavyWorkbench); AddResources(component, "NeckSkin_bal", 2); 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 "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); AddResources(component, "StrawThread_bal", 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); 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); 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 EditResource(Piece piece, string itemName, int amount, bool remove = false) { if (remove) { List<Requirement> list = new List<Requirement>(); Requirement[] resources = piece.m_resources; foreach (Requirement val in resources) { if (((Object)((Component)val.m_resItem).gameObject).name != itemName) { list.Add(val); } } piece.m_resources = list.ToArray(); return; } Requirement[] resources2 = piece.m_resources; foreach (Requirement val2 in resources2) { if (((Object)((Component)val2.m_resItem).gameObject).name == itemName) { val2.m_amount = amount; } } } private void AddResources(Piece piece, string itemName, int amount, int amountPerLevel = 0) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown List<Requirement> list = new List<Requirement>(); list.AddRange(piece.m_resources); Requirement val = new Requirement(); val.m_resItem = FindItem(this.list, itemName).GetComponent<ItemDrop>(); val.m_amount = amount; val.m_amountPerLevel = amountPerLevel; list.Add(val); piece.m_resources = list.ToArray(); } 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 name) { GameObject val = FindItem(list, name, isStation: true); if ((Object)(object)val != (Object)null) { return val.GetComponent<CraftingStation>(); } return null; } } public class BuildPieceTargeting { private static string[] names = new string[0]; public void changePieceTargeting(List<GameObject> gameObjects) { List<GameObject> list = gameObjects.FindAll((GameObject x) => (Object)(object)x.GetComponent<WearNTear>() != (Object)null); foreach (GameObject item in list) { Piece component = item.GetComponent<Piece>(); if ((Object)(object)component != (Object)null && names.Contains(((Object)item).name)) { ((StaticTarget)component).m_primaryTarget = true; } if ((Object)(object)component != (Object)null && shouldBePrimaryTarget(item)) { ((StaticTarget)component).m_primaryTarget = true; } setResistances(item); } } private bool shouldBePrimaryTarget(GameObject gameObject) { if ((Object)(object)gameObject.GetComponent<Door>() != (Object)null) { return true; } if ((Object)(object)gameObject.GetComponent<CraftingStation>() != (Object)null) { return true; } if ((Object)(object)gameObject.GetComponent<StationExtension>() != (Object)null) { return true; } if ((Object)(object)gameObject.GetComponent<Container>() != (Object)null) { return false; } return false; } private void setResistances(GameObject gameObject) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) WearNTear component = gameObject.GetComponent<WearNTear>(); if ((Object)(object)component != (Object)null) { component.m_damages.m_chop = setChopDamageResistance(component); component.m_damages.m_pickaxe = setPickaxeDamageResistance(component); component.m_damages.m_fire = setFireDamageResistance(component); } } private DamageModifier setChopDamageResistance(WearNTear wearNTear) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected I4, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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) MaterialType materialType = wearNTear.m_materialType; MaterialType val = materialType; return (DamageModifier)((int)val switch { 0 => 6, 3 => 2, 2 => 5, 1 => 1, _ => 0, }); } private DamageModifier setPickaxeDamageResistance(WearNTear wearNTear) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected I4, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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) MaterialType materialType = wearNTear.m_materialType; MaterialType val = materialType; return (DamageModifier)((int)val switch { 0 => 0, 3 => 1, 2 => 2, 1 => 6, _ => 0, }); } private DamageModifier setFireDamageResistance(WearNTear wearNTear) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected I4, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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) MaterialType materialType = wearNTear.m_materialType; MaterialType val = materialType; return (DamageModifier)((int)val switch { 0 => 6, 3 => 2, 2 => 0, 1 => 5, _ => 0, }); } } public class Resource { public int amount = 1; public int amountPerLevel = 0; public bool recovery = true; public ItemDrop itemDrop; public Requirement pieceConfig; public string item = "Wood"; public Resource() { } public Resource(string item, int amount, int amountPerLevel = 0, bool recovery = true) { this.item = item; this.amount = amount; this.amountPerLevel = amountPerLevel; this.recovery = recovery; } public void setItemDrop(GameObject prefab) { if ((Object)(object)prefab.GetComponent<ItemDrop>() != (Object)null) { itemDrop = prefab.GetComponent<ItemDrop>(); } else { Debug.LogWarning((object)("DVERGER FURNITURE: NO ITEM DROP FOUND on prefab name: " + ((Object)prefab).name)); } } public Requirement getPieceConfig() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_003e: Expected O, but got Unknown Requirement val = new Requirement { m_resItem = itemDrop, m_amount = amount, m_amountPerLevel = amountPerLevel, m_recover = recovery }; Requirement result = val; pieceConfig = val; return result; } } } namespace LitJson2 { internal enum JsonType { None, Object, Array, String, Int, Long, Double, Boolean } internal interface IJsonWrapper : IList, IOrderedDictionary, IDictionary, ICollection, IEnumerable { bool IsArray { get; } bool IsBoolean { get; } bool IsDouble { get; } bool IsInt { get; } bool IsLong { get; } bool IsObject { get; } bool IsString { get; } bool GetBoolean(); double GetDouble(); int GetInt(); JsonType GetJsonType(); long GetLong(); string GetString(); void SetBoolean(bool val); void SetDouble(double val); void SetInt(int val); void SetJsonType(JsonType type); void SetLong(long val); void SetString(string val); string ToJson(); void ToJson(JsonWriter writer); } internal class JsonData : IJsonWrapper, IList, IOrderedDictionary, IDictionary, ICollection, IEnumerable, IEquatable<JsonData> { private IList<JsonData> inst_array; private bool inst_boolean; private double inst_double; private int inst_int; private long inst_long; private IDictionary<string, JsonData> inst_object; private string inst_string; private string json; private JsonType type; private IList<KeyValuePair<string, JsonData>> object_list; public int Count => EnsureCollection().Count; public bool IsArray => type == JsonType.Array; public bool IsBoolean => type == JsonType.Boolean; public bool IsDouble => type == JsonType.Double; public bool IsInt => type == JsonType.Int; public bool IsLong => type == JsonType.Long; public bool IsObject => type == JsonType.Object; public bool IsString => type == JsonType.String; public ICollection<string> Keys { get { EnsureDictionary(); return inst_object.Keys; } } int ICollection.Count => Count; bool ICollection.IsSynchronized => EnsureCollection().IsSynchronized; object ICollection.SyncRoot => EnsureCollection().SyncRoot; bool IDictionary.IsFixedSize => EnsureDictionary().IsFixedSize; bool IDictionary.IsReadOnly => EnsureDictionary().IsReadOnly; ICollection IDictionary.Keys { get { EnsureDictionary(); IList<string> list = new List<string>(); foreach (KeyValuePair<string, JsonData> item in object_list) { list.Add(item.Key); } return (ICollection)list; } } ICollection IDictionary.Values { get { EnsureDictionary(); IList<JsonData> list = new List<JsonData>(); foreach (KeyValuePair<string, JsonData> item in object_list) { list.Add(item.Value); } return (ICollection)list; } } bool IJsonWrapper.IsArray => IsArray; bool IJsonWrapper.IsBoolean => IsBoolean; bool IJsonWrapper.IsDouble => IsDouble; bool IJsonWrapper.IsInt => IsInt; bool IJsonWrapper.IsLong => IsLong; bool IJsonWrapper.IsObject => IsObject; bool IJsonWrapper.IsString => IsString; bool IList.IsFixedSize => EnsureList().IsFixedSize; bool IList.IsReadOnly => EnsureList().IsReadOnly; object IDictionary.this[object key] { get { return EnsureDictionary()[key]; } set { if (!(key is string)) { throw new ArgumentException("The key has to be a string"); } JsonData value2 = ToJsonData(value); this[(string)key] = value2; } } object IOrderedDictionary.this[int idx] { get { EnsureDictionary(); return object_list[idx].Value; } set { EnsureDictionary(); JsonData value2 = ToJsonData(value); KeyValuePair<string, JsonData> keyValuePair = object_list[idx]; inst_object[keyValuePair.Key] = value2; KeyValuePair<string, JsonData> value3 = new KeyValuePair<string, JsonData>(keyValuePair.Key, value2); object_list[idx] = value3; } } object IList.this[int index] { get { return EnsureList()[index]; } set { EnsureList(); JsonData value2 = ToJsonData(value); this[index] = value2; } } public JsonData this[string prop_name] { get { EnsureDictionary(); return inst_object[prop_name]; } set { EnsureDictionary(); KeyValuePair<string, JsonData> keyValuePair = new KeyValuePair<string, JsonData>(prop_name, value); if (inst_object.ContainsKey(prop_name)) { for (int i = 0; i < object_list.Count; i++) { if (object_list[i].Key == prop_name) { object_list[i] = keyValuePair; break; } } } else { object_list.Add(keyValuePair); } inst_object[prop_name] = value; json = null; } } public JsonData this[int index] { get { EnsureCollection(); if (type == JsonType.Array) { return inst_array[index]; } return object_list[index].Value; } set { EnsureCollection(); if (type == JsonType.Array) { inst_array[index] = value; } else { KeyValuePair<string, JsonData> keyValuePair = object_list[index]; KeyValuePair<string, JsonData> value2 = new KeyValuePair<string, JsonData>(keyValuePair.Key, value); object_list[index] = value2; inst_object[keyValuePair.Key] = value; } json = null; } } public JsonData() { } public JsonData(bool boolean) { type = JsonType.Boolean; inst_boolean = boolean; } public JsonData(double number) { type = JsonType.Double; inst_double = number; } public JsonData(int number) { type = JsonType.Int; inst_int = number; } public JsonData(long number) { type = JsonType.Long; inst_long = number; } public JsonData(object obj) { if (obj is bool) { type = JsonType.Boolean; inst_boolean = (bool)obj; return; } if (obj is double) { type = JsonType.Double; inst_double = (double)obj; return; } if (obj is int) { type = JsonType.Int; inst_int = (int)obj; return; } if (obj is long) { type = JsonType.Long; inst_long = (long)obj; return; } if (obj is string) { type = JsonType.String; inst_string = (string)obj; return; } throw new ArgumentException("Unable to wrap the given object with JsonData"); } public JsonData(string str) { type = JsonType.String; inst_string = str; } public static implicit operator JsonData(bool data) { return new JsonData(data); } public static implicit operator JsonData(double data) { return new JsonData(data); } public static implicit operator JsonData(int data) { return new JsonData(data); } public static implicit operator JsonData(long data) { return new JsonData(data); } public static implicit operator JsonData(string data) { return new JsonData(data); } public static explicit operator bool(JsonData data) { if (data.type != JsonType.Boolean) { throw new InvalidCastException("Instance of JsonData doesn't hold a double"); } return data.inst_boolean; } public static explicit operator double(JsonData data) { if (data.type != JsonType.Double) { throw new InvalidCastException("Instance of JsonData doesn't hold a double"); } return data.inst_double; } public static explicit operator int(JsonData data) { if (data.type != JsonType.Int) { throw new InvalidCastException("Instance of JsonData doesn't hold an int"); } return data.inst_int; } public static explicit operator long(JsonData data) { if (data.type != JsonType.Long) { throw new InvalidCastException("Instance of JsonData doesn't hold an int"); } return data.inst_long; } public static explicit operator string(JsonData data) { if (data.type != JsonType.String) { throw new InvalidCastException("Instance of JsonData doesn't hold a string"); } return data.inst_string; } void ICollection.CopyTo(Array array, int index) { EnsureCollection().CopyTo(array, index); } void IDictionary.Add(object key, object value) { JsonData value2 = ToJsonData(value); EnsureDictionary().Add(key, value2); KeyValuePair<string, JsonData> item = new KeyValuePair<string, JsonData>((string)key, value2); object_list.Add(item); json = null; } void IDictionary.Clear() { EnsureDictionary().Clear(); object_list.Clear(); json = null; } bool IDictionary.Contains(object key) { return EnsureDictionary().Contains(key); } IDictionaryEnumerator IDictionary.GetEnumerator() { return ((IOrderedDictionary)this).GetEnumerator(); } void IDictionary.Remove(object key) { EnsureDictionary().Remove(key); for (int i = 0; i < object_list.Count; i++) { if (object_list[i].Key == (string)key) { object_list.RemoveAt(i); break; } } json = null; } IEnumerator IEnumerable.GetEnumerator() { return EnsureCollection().GetEnumerator(); } bool IJsonWrapper.GetBoolean() { if (type != JsonType.Boolean) { throw new InvalidOperationException("JsonData instance doesn't hold a boolean"); } return inst_boolean; } double IJsonWrapper.GetDouble() { if (type != JsonType.Double) { throw new InvalidOperationException("JsonData instance doesn't hold a double"); } return inst_double; } int IJsonWrapper.GetInt() { if (type != JsonType.Int) { throw new InvalidOperationException("JsonData instance doesn't hold an int"); } return inst_int; } long IJsonWrapper.GetLong() { if (type != JsonType.Long) { throw new InvalidOperationException("JsonData instance doesn't hold a long"); } return inst_long; } string IJsonWrapper.GetString() { if (type != JsonType.String) { throw new InvalidOperationException("JsonData instance doesn't hold a string"); } return inst_string; } void IJsonWrapper.SetBoolean(bool val) { type = JsonType.Boolean; inst_boolean = val; json = null; } void IJsonWrapper.SetDouble(double val) { type = JsonType.Double; inst_double = val; json = null; } void IJsonWrapper.SetInt(int val) { type = JsonType.Int; inst_int = val; json = null; } void IJsonWrapper.SetLong(long val) { type = JsonType.Long; inst_long = val; json = null; } void IJsonWrapper.SetString(string val) { type = JsonType.String; inst_string = val; json = null; } string IJsonWrapper.ToJson() { return ToJson(); } void IJsonWrapper.ToJson(JsonWriter writer) { ToJson(writer); } int IList.Add(object value) { return Add(value); } void IList.Clear() { EnsureList().Clear(); json = null; } bool IList.Contains(object value) { return EnsureList().Contains(value); } int IList.IndexOf(object value) { return EnsureList().IndexOf(value); } void IList.Insert(int index, object value) { EnsureList().Insert(index, value); json = null; } void IList.Remove(object value) { EnsureList().Remove(value); json = null; } void IList.RemoveAt(int index) { EnsureList().RemoveAt(index); json = null; } IDictionaryEnumerator IOrderedDictionary.GetEnumerator() { EnsureDictionary(); return new OrderedDictionaryEnumerator(object_list.GetEnumerator()); } void IOrderedDictionary.Insert(int idx, object key, object value) { string text = (string)key; JsonData value2 = (this[text] = ToJsonData(value)); KeyValuePair<string, JsonData> item = new KeyValuePair<string, JsonData>(text, value2); object_list.Insert(idx, item); } void IOrderedDictionary.RemoveAt(int idx) { EnsureDictionary(); inst_object.Remove(object_list[idx].Key); object_list.RemoveAt(idx); } private ICollection EnsureCollection() { if (type == JsonType.Array) { return (ICollection)inst_array; } if (type == JsonType.Object) { return (ICollection)inst_object; } throw new InvalidOperationException("The JsonData instance has to be initialized first"); } private IDictionary EnsureDictionary() { if (type == JsonType.Object) { return (IDictionary)inst_object; } if (type != 0) { throw new InvalidOperationException("Instance of JsonData is not a dictionary"); } type = JsonType.Object; inst_object = new Dictionary<string, JsonData>(); object_list = new List<KeyValuePair<string, JsonData>>(); return (IDictionary)inst_object; } private IList EnsureList() { if (type == JsonType.Array) { return (IList)inst_array; } if (type != 0) { throw new InvalidOperationException("Instance of JsonData is not a list"); } type = JsonType.Array; inst_array = new List<JsonData>(); return (IList)inst_array; } private JsonData ToJsonData(object obj) { if (obj == null) { return null; } if (obj is JsonData) { return (JsonData)obj; } return new JsonData(obj); } private static void WriteJson(IJsonWrapper obj, JsonWriter writer) { if (obj == null) { writer.Write(null); } else if (obj.IsString) { writer.Write(obj.GetString()); } else if (obj.IsBoolean) { writer.Write(obj.GetBoolean()); } else if (obj.IsDouble) { writer.Write(obj.GetDouble()); } else if (obj.IsInt) { writer.Write(obj.GetInt()); } else if (obj.IsLong) { writer.Write(obj.GetLong()); } else if (obj.IsArray) { writer.WriteArrayStart(); foreach (object item in (IEnumerable)obj) { WriteJson((JsonData)item, writer); } writer.WriteArrayEnd(); } else { if (!obj.IsObject) { return; } writer.WriteObjectStart(); foreach (DictionaryEntry item2 in (IDictionary)obj) { writer.WritePropertyName((string)item2.Key); WriteJson((JsonData)item2.Value, writer); } writer.WriteObjectEnd(); } } public int Add(object value) { JsonData value2 = ToJsonData(value); json = null; return EnsureList().Add(value2); } public void Clear() { if (IsObject) { ((IDictionary)this).Clear(); } else if (IsArray) { ((IList)this).Clear(); } } public bool Equals(JsonData x) { if (x == null) { return false; } if (x.type != type) { return false; } return type switch { JsonType.None => true, JsonType.Object => inst_object.Equals(x.inst_object), JsonType.Array => inst_array.Equals(x.inst_array), JsonType.String => inst_string.Equals(x.inst_string), JsonType.Int => inst_int.Equals(x.inst_int), JsonType.Long => inst_long.Equals(x.inst_long), JsonType.Double => inst_double.Equals(x.inst_double), JsonType.Boolean => inst_boolean.Equals(x.inst_boolean), _ => false, }; } public JsonType GetJsonType() { return type; } public void SetJsonType(JsonType type) { if (this.type != type) { switch (type) { case JsonType.Object: inst_object = new Dictionary<string, JsonData>(); object_list = new List<KeyValuePair<string, JsonData>>(); break; case JsonType.Array: inst_array = new List<JsonData>(); break; case JsonType.String: inst_string = null; break; case JsonType.Int: inst_int = 0; break; case JsonType.Long: inst_long = 0L; break; case JsonType.Double: inst_double = 0.0; break; case JsonType.Boolean: inst_boolean = false; break; } this.type = type; } } public string ToJson() { if (json != null) { return json; } StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.Validate = false; WriteJson(this, jsonWriter); json = stringWriter.ToString(); return json; } public void ToJson(JsonWriter writer) { bool validate = writer.Validate; writer.Validate = false; WriteJson(this, writer); writer.Validate = validate; } public override string ToString() { return type switch { JsonType.Array => "JsonData array", JsonType.Boolean => inst_boolean.ToString(), JsonType.Double => inst_double.ToString(), JsonType.Int => inst_int.ToString(