using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; 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("AichoPieces")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("AichoPieces")] [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: AssemblyVersion("1.0.0.0")] namespace AichoPieces; internal class BuildPieceList { public static string[] buildPieces = new string[70] { "clutter_potionSet_aicho", "clutter_alcoholbottleSet_aicho", "clutter_shipmodel_aicho", "clutter_potion1_aicho", "clutter_potion2_aicho", "clutter_potion3_aicho", "clutter_potion4_aicho", "clutter_alcoholbottle1_aicho", "clutter_alcoholbottle2_aicho", "clutter_alcoholbottle3_aicho", "clutter_alcoholbottle5_aicho", "wallscroll_aicho", "StatueDeath_aicho", "gateway_black_aicho", "gateway_white_aicho", "stone_floor4m_aicho", "stone_wall4m_aicho", "clutter_winebottle_aicho", "clutter_alcoholbox_aicho", "clutter_candles1_aicho", "clutter_candles2_aicho", "StatueEagle_aicho", "StatueWolf_aicho", "clutter_bottleset_bal", "clutter_cupset_bal", "clutter_tableset_bal", "spiderWeb4_aicho", "spiderWeb5_aicho", "spiderWeb6_aicho", "piece_candlechandelier1_aicho", "piece_candlechandelier2_aicho", "cabinet_aicho", "cabinet2_aicho", "clutter_bookset1_bal", "clutter_bookset2_bal", "clutter_bookset3_bal", "cage_1_aicho", "cage_2_aicho", "clutter_scroll1_aicho", "clutter_scroll2_aicho", "clutter_scroll3_aicho", "Coffin1_aicho", "Coffin2_aicho", "Painting1_aicho", "Painting2_aicho", "Painting3_aicho", "Painting4_aicho", "pirate_barrels_aicho", "pirateTable_aicho", "scarecrow_aicho", "skeleton_puppet1_aicho", "skeleton_puppet2_aicho", "skeleton_puppet3_aicho", "StatueAngel_aicho", "StatueGriffin_aicho", "StatueFace_aicho", "StatueHand_aicho", "StatueOdin2_aicho", "StatueThor_aicho", "StatueThor2_aicho", "stone_arche_big_aicho", "stone_arche_cricle_aicho", "supply_shelf_aicho", "target_dummy_aicho", "target_dummy1_aicho", "target_practice_2_aicho", "tomb1_aicho", "tomb2_aicho", "tomb3_aicho", "tomb4_aicho" }; } public class DatabaseAddMethods { public void AddItems(List items) { foreach (GameObject item in items) { AddItem(item); } } public void AddRecipes(List recipes) { foreach (Recipe recipe in recipes) { AddRecipe(recipe); } } public void AddStatuseffects(List statusEffects) { foreach (StatusEffect statusEffect in statusEffects) { AddStatus(statusEffect); } } private bool IsObjectDBValid() { return (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0 && ObjectDB.instance.m_recipes.Count != 0 && (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null; } private void AddStatus(StatusEffect status) { if (!IsObjectDBValid()) { return; } if ((Object)(object)status != (Object)null) { if ((Object)(object)ObjectDB.instance.GetStatusEffect(status.m_nameHash) == (Object)null) { ObjectDB.instance.m_StatusEffects.Add(status); } else { Debug.Log((object)(Launch.projectName + ": " + ((Object)status).name + " - Status already in the game")); } } else { Debug.LogError((object)(Launch.projectName + ": " + ((Object)status).name + " - Status not found")); } } private void AddRecipe(Recipe recipe) { if (!IsObjectDBValid()) { return; } if ((Object)(object)recipe != (Object)null) { if ((Object)(object)ObjectDB.instance.m_recipes.Find((Recipe x) => ((Object)x).name == ((Object)recipe).name) == (Object)null) { if ((Object)(object)recipe.m_item != (Object)null) { ObjectDB.instance.m_recipes.Add(recipe); } } else { Debug.Log((object)(Launch.projectName + ": " + ((Object)recipe).name + " - Recipe with this name already in the Game")); } } else { Debug.LogError((object)(Launch.projectName + ": " + ((Object)recipe).name + " - Recipe not found")); } } private void AddItem(GameObject newPrefab) { if (!IsObjectDBValid()) { return; } ItemDrop component = newPrefab.GetComponent(); if ((Object)(object)component != (Object)null) { if ((Object)(object)ObjectDB.instance.GetItemPrefab(((Object)newPrefab).name) == (Object)null) { ObjectDB.instance.m_items.Add(newPrefab); Dictionary dictionary = (Dictionary)typeof(ObjectDB).GetField("m_itemByHash", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ObjectDB.instance); dictionary[((Object)newPrefab).name.GetHashCode()] = newPrefab; } else { Debug.LogWarning((object)(Launch.projectName + ": " + ((Object)newPrefab).name + " - ItemDrop already exist")); } } else { Debug.LogError((object)(Launch.projectName + ": " + ((Object)newPrefab).name + " - ItemDrop not found on prefab")); } } } public class FxReplacment { private List allPrefabs; private string projectName = "[BalrondBiomes]"; public void setInstance(List gameObjects) { allPrefabs = gameObjects; } public void ReplaceOnObject(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return; } SpawnArea component = gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { EffectList spawnEffects = component.m_spawnEffects; if (spawnEffects != null) { findEffectsAndChange(spawnEffects.m_effectPrefabs); } } Destructible component2 = gameObject.GetComponent(); if ((Object)(object)component2 != (Object)null) { EffectList hitEffect = component2.m_hitEffect; if (hitEffect != null) { findEffectsAndChange(hitEffect.m_effectPrefabs); } EffectList destroyedEffect = component2.m_destroyedEffect; if (destroyedEffect != null) { findEffectsAndChange(destroyedEffect.m_effectPrefabs); } } Projectile component3 = gameObject.GetComponent(); if ((Object)(object)component3 != (Object)null) { EffectList hitEffects = component3.m_hitEffects; if (hitEffects != null) { findEffectsAndChange(hitEffects.m_effectPrefabs); } EffectList hitWaterEffects = component3.m_hitWaterEffects; if (hitWaterEffects != null) { findEffectsAndChange(hitWaterEffects.m_effectPrefabs); } EffectList spawnOnHitEffects = component3.m_spawnOnHitEffects; if (spawnOnHitEffects != null) { findEffectsAndChange(spawnOnHitEffects.m_effectPrefabs); } } } public void ReplaceOnVegetation(GameObject gameObject) { Pickable component = gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { fixPlant(component); } Destructible component2 = gameObject.GetComponent(); if ((Object)(object)component2 != (Object)null) { fixPDestructable(component2); } MineRock5 component3 = gameObject.GetComponent(); if ((Object)(object)component3 != (Object)null) { fixMineRock5(component3); } MineRock component4 = gameObject.GetComponent(); if ((Object)(object)component4 != (Object)null) { fixMineRock(component4); } } private void fixPlant(Pickable pickable) { EffectList pickEffector = pickable.m_pickEffector; if (pickEffector != null) { findEffectsAndChange(pickEffector.m_effectPrefabs); } } private void fixPDestructable(Destructible minerock5) { EffectList hitEffect = minerock5.m_hitEffect; if (hitEffect != null) { findEffectsAndChange(hitEffect.m_effectPrefabs); } EffectList destroyedEffect = minerock5.m_destroyedEffect; if (destroyedEffect != null) { findEffectsAndChange(destroyedEffect.m_effectPrefabs); } } private void fixMineRock5(MineRock5 minerock5) { EffectList hitEffect = minerock5.m_hitEffect; if (hitEffect != null) { findEffectsAndChange(hitEffect.m_effectPrefabs); } EffectList destroyedEffect = minerock5.m_destroyedEffect; if (destroyedEffect != null) { findEffectsAndChange(destroyedEffect.m_effectPrefabs); } } private void fixMineRock(MineRock minerock5) { EffectList hitEffect = minerock5.m_hitEffect; if (hitEffect != null) { findEffectsAndChange(hitEffect.m_effectPrefabs); } EffectList destroyedEffect = minerock5.m_destroyedEffect; if (destroyedEffect != null) { findEffectsAndChange(destroyedEffect.m_effectPrefabs); } } public void ReplaceOnMonster(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { Debug.LogWarning((object)(projectName + ":: GameObject not found")); return; } Humanoid component = gameObject.GetComponent(); if ((Object)(object)component == (Object)null) { Debug.LogWarning((object)(projectName + ":: GameObject not found")); return; } EffectList dropEffects = component.m_dropEffects; if (dropEffects != null) { findEffectsAndChange(dropEffects.m_effectPrefabs); } EffectList backstabHitEffects = ((Character)component).m_backstabHitEffects; if (backstabHitEffects != null) { findEffectsAndChange(backstabHitEffects.m_effectPrefabs); } EffectList consumeItemEffects = component.m_consumeItemEffects; if (consumeItemEffects != null) { findEffectsAndChange(consumeItemEffects.m_effectPrefabs); } EffectList critHitEffects = ((Character)component).m_critHitEffects; if (critHitEffects != null) { findEffectsAndChange(critHitEffects.m_effectPrefabs); } EffectList deathEffects = ((Character)component).m_deathEffects; if (deathEffects != null) { findEffectsAndChange(deathEffects.m_effectPrefabs); } EffectList hitEffects = ((Character)component).m_hitEffects; if (hitEffects != null) { findEffectsAndChange(hitEffects.m_effectPrefabs); } EffectList jumpEffects = ((Character)component).m_jumpEffects; if (jumpEffects != null) { findEffectsAndChange(jumpEffects.m_effectPrefabs); } EffectList perfectBlockEffect = component.m_perfectBlockEffect; if (perfectBlockEffect != null) { findEffectsAndChange(perfectBlockEffect.m_effectPrefabs); } EffectList pickupEffects = component.m_pickupEffects; if (pickupEffects != null) { findEffectsAndChange(pickupEffects.m_effectPrefabs); } EffectList slideEffects = ((Character)component).m_slideEffects; if (slideEffects != null) { findEffectsAndChange(slideEffects.m_effectPrefabs); } EffectList tarEffects = ((Character)component).m_tarEffects; if (tarEffects != null) { findEffectsAndChange(tarEffects.m_effectPrefabs); } EffectList waterEffects = ((Character)component).m_waterEffects; if (waterEffects != null) { findEffectsAndChange(waterEffects.m_effectPrefabs); } FootStep component2 = gameObject.GetComponent(); if (!((Object)(object)component2 != (Object)null)) { return; } List effects = component2.m_effects; foreach (StepEffect item in effects) { GameObject[] effectPrefabs = item.m_effectPrefabs; List list = new List(); list.AddRange(effectPrefabs); for (int i = 0; i < list.Count; i++) { if ((Object)(object)list[i] != (Object)null) { string name = ((Object)list[i]).name; GameObject val = allPrefabs.Find((GameObject x) => ((Object)x).name == name); if (!((Object)(object)val == (Object)null)) { list[i] = val; } } } } } public void ReplaceOnItem(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return; } ItemDrop component = gameObject.GetComponent(); if (!((Object)(object)component == (Object)null)) { EffectList hitEffect = component.m_itemData.m_shared.m_hitEffect; if (hitEffect != null) { findEffectsAndChange(hitEffect.m_effectPrefabs); } EffectList hitTerrainEffect = component.m_itemData.m_shared.m_hitTerrainEffect; if (hitTerrainEffect != null) { findEffectsAndChange(hitTerrainEffect.m_effectPrefabs); } EffectList holdStartEffect = component.m_itemData.m_shared.m_holdStartEffect; if (holdStartEffect != null) { findEffectsAndChange(holdStartEffect.m_effectPrefabs); } EffectList trailStartEffect = component.m_itemData.m_shared.m_trailStartEffect; if (trailStartEffect != null) { findEffectsAndChange(trailStartEffect.m_effectPrefabs); } EffectList blockEffect = component.m_itemData.m_shared.m_blockEffect; if (blockEffect != null) { findEffectsAndChange(blockEffect.m_effectPrefabs); } } } public void ReplaceFxOnPiece(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return; } Piece component = gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { EffectList placeEffect = component.m_placeEffect; if (placeEffect != null) { findEffectsAndChange(placeEffect.m_effectPrefabs); } } WearNTear component2 = gameObject.GetComponent(); if ((Object)(object)component2 != (Object)null) { EffectList hitEffect = component2.m_hitEffect; if (hitEffect != null) { findEffectsAndChange(hitEffect.m_effectPrefabs); } } } private void findEffectsAndChange(EffectData[] effects) { if (effects == null || effects.Length == 0) { return; } foreach (EffectData val in effects) { if ((Object)(object)val.m_prefab != (Object)null) { string name = ((Object)val.m_prefab).name; GameObject val2 = allPrefabs.Find((GameObject x) => ((Object)x).name == name); if (!((Object)(object)val2 == (Object)null)) { val.m_prefab = val2; } } } } } public class ModResourceLoader { public AssetBundle assetBundle; public List buildPrefabs = new List(); public List plantPrefabs = new List(); public List itemPrefabs = new List(); public List monsterPrefabs = new List(); public List vegetationPrefabs = new List(); public List clutterPrefabs = new List(); public List locationPrefabs = new List(); public List roomPrefabs = new List(); public List vfxPrefabs = new List(); public FxReplacment fxReplacment = null; public List recipes = new List(); public List statusEffects = new List(); public StatusEffect newBarleyStatus = null; public ShaderReplacment shaderReplacment = new ShaderReplacment(); public Sprite newLogo = null; public void loadAssets() { assetBundle = GetAssetBundleFromResources("aichopieces"); string basePath = "Assets/Custom/Comission/AichoPieces/"; loadPieces(basePath); loadPlants(basePath); loadItems(basePath); loadVegetation(basePath); loadOther(basePath); } public void AddPrefabsToZnetScene(ZNetScene zNetScene) { zNetScene.m_prefabs.AddRange(vegetationPrefabs); foreach (GameObject gm in itemPrefabs) { GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)gm).name); if ((Object)(object)val == (Object)null) { zNetScene.m_prefabs.Add(gm); } else { Debug.LogWarning((object)("Object exists: " + ((Object)gm).name)); } } foreach (GameObject gm2 in buildPrefabs) { GameObject val2 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)gm2).name); if ((Object)(object)val2 == (Object)null) { zNetScene.m_prefabs.Add(gm2); } else { Debug.LogWarning((object)("Object exists: " + ((Object)gm2).name)); } } foreach (GameObject gm3 in vfxPrefabs) { GameObject val3 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)gm3).name); if ((Object)(object)val3 == (Object)null) { zNetScene.m_prefabs.Add(gm3); } else { Debug.LogWarning((object)("Object exists: " + ((Object)gm3).name)); } } zNetScene.m_prefabs.RemoveAll((GameObject x) => (Object)(object)x == (Object)null); addPlantstoCultivator(zNetScene); setupBuildPiecesList(zNetScene); } private void setupBuildPiecesList(ZNetScene zNetScene) { string[] array = new string[4] { "Hammer", "HammerIron", "HammerDverger", "HammerBlackmetal" }; GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Hammer"); PieceTable buildPieces = val.GetComponent().m_itemData.m_shared.m_buildPieces; string[] array2 = array; foreach (string name in array2) { addBuildpiecesToOtherHammer(name, buildPieces, zNetScene); } string[] source = new string[39] { "scarecrow_aicho", "clutter_bottleset_bal", "clutter_cupset_bal", "clutter_tableset_bal", "cabinet_aicho", "cabinet2_aicho", "clutter_bookset1_bal", "clutter_bookset2_bal", "clutter_bookset3_bal", "clutter_scroll1_aicho", "clutter_scroll2_aicho", "clutter_scroll3_aicho", "Painting1_aicho", "Painting2_aicho", "Painting3_aicho", "Painting4_aicho", "pirate_barrels_aicho", "pirateTable_aicho", "piece_candlechandelier1_aicho", "piece_candlechandelier2_aicho", "clutter_winebottle_aicho", "clutter_potion1_aicho", "clutter_potion2_aicho", "clutter_potion3_aicho", "clutter_potion4_aicho", "clutter_alcoholbottle1_aicho", "clutter_alcoholbottle2_aicho", "clutter_alcoholbottle3_aicho", "clutter_alcoholbottle4_aicho", "clutter_alcoholbottle5_aicho", "supply_shelf_aicho", "StatueFace_aicho", "clutter_shipmodel_aicho", "stone_floor4m_aicho", "stone_wall4m_aicho", "clutter_potionSet_aicho", "clutter_alcoholbottleSet_aicho", "StatueOdin2_aicho", "StatueWolf_aicho" }; List pieces = buildPieces.m_pieces; foreach (GameObject buildPrefab in buildPrefabs) { if (source.Contains(((Object)buildPrefab).name)) { setupRavenGuide(buildPrefab, zNetScene.m_prefabs); AddToBuildList(buildPrefab, pieces); } } } private void addBuildpiecesToOtherHammer(string name, PieceTable pieceTable, ZNetScene zNetScene) { GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == name); if (!((Object)(object)val == (Object)null)) { val.GetComponent().m_itemData.m_shared.m_buildPieces = pieceTable; } } public void setupRavenGuide(GameObject gameObject, List gameObjects) { GameObject val = null; Transform val2 = gameObject.transform.Find("GuidePoint"); if ((Object)(object)val2 == (Object)null) { return; } GameObject val3 = gameObjects.Find((GameObject x) => ((Object)x).name == "piece_workbench"); if ((Object)(object)val3 != (Object)null) { GameObject gameObject2 = ((Component)val3.transform.Find("GuidePoint")).gameObject; if ((Object)(object)gameObject2 != (Object)null) { GuidePoint component = gameObject2.GetComponent(); if ((Object)(object)component != (Object)null) { val = component.m_ravenPrefab; } } } if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)"Ravens not found"); } else { ((Component)val2).GetComponent().m_ravenPrefab = val; } } public void setupBuildPiecesListDB() { GameObject val = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "Hammer"); List pieces = val.GetComponent().m_itemData.m_shared.m_buildPieces.m_pieces; foreach (GameObject buildPrefab in buildPrefabs) { AddToBuildList(buildPrefab, pieces); } } private void AddToBuildList(GameObject prefab, List buildPieces) { if ((Object)(object)buildPieces.Find((GameObject x) => ((Object)x).name == ((Object)prefab).name) == (Object)null) { buildPieces.Add(prefab); } } private void addPlantstoCultivator(ZNetScene zNetScene) { GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Cultivator"); PieceTable buildPieces = val.GetComponent().m_itemData.m_shared.m_buildPieces; List pieces = buildPieces.m_pieces; foreach (GameObject plantPrefab in plantPrefabs) { pieces.Add(plantPrefab); } } 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(); 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[2] { "Swamp_Sapling_aicho", "Willow_Sapling_aicho" }; string[] array2 = array; foreach (string text2 in array2) { GameObject val = assetBundle.LoadAsset(text + text2 + ".prefab"); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("Could not find plant with name: " + text2)); continue; } ShaderReplacment.Replace(val); plantPrefabs.Add(val); } } private void loadPieces(string basePath) { string text = basePath + "Pieces/"; string[] buildPieces = BuildPieceList.buildPieces; string[] array = buildPieces; foreach (string text2 in array) { GameObject val = assetBundle.LoadAsset(text + text2 + ".prefab"); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("Could not find piece with name: " + text2)); continue; } ShaderReplacment.Replace(val); buildPrefabs.Add(val); } } private void loadItems(string basePath) { string text = basePath + "Items/"; string[] array = new string[3] { "HammerMolten", "SwampSeed_aicho", "WillowSeed_aicho" }; string[] array2 = array; foreach (string text2 in array2) { GameObject val = assetBundle.LoadAsset(text + text2 + ".prefab"); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("Could not find item with name: " + text2)); continue; } ShaderReplacment.Replace(val); itemPrefabs.Add(val); } } private void loadVegetation(string basePath) { string text = basePath + "Vegetation/"; string[] array = new string[4] { "SwampTree_aicho", "Willow_aicho", "WetTree_Stub_aicho", "Willow_Stub_aicho" }; string[] array2 = array; foreach (string text2 in array2) { GameObject val = assetBundle.LoadAsset(text + text2 + ".prefab"); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("Could not find vegegation with name: " + text2)); continue; } ShaderReplacment.Replace(val); vegetationPrefabs.Add(val); } } private void loadOther(string basePath) { string text = basePath + "Other/"; string[] array = new string[4] { "moltenHammerList", "Wet_log_aicho", "Wet_log_half_aicho", "Willow_log_aicho" }; string[] array2 = array; foreach (string text2 in array2) { GameObject val = assetBundle.LoadAsset(text + text2 + ".prefab"); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("Could not find object with name: " + text2)); continue; } ShaderReplacment.Replace(val); vfxPrefabs.Add(val); } } public void setIronHook(ZNetScene zNetScene) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "piece_cookingstation_iron"); GameObject val2 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "piece_cookingstation"); ItemConversion val3 = new ItemConversion(); val3.m_from = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "BearMeat").GetComponent(); val3.m_to = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "BearMeatCooked").GetComponent(); val3.m_cookTime = 40f; ItemConversion val4 = new ItemConversion(); val4.m_from = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Potato").GetComponent(); val4.m_to = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "PotatoFried").GetComponent(); val4.m_cookTime = 30f; if ((Object)(object)val != (Object)null) { CookingStation component = val.GetComponent(); component.m_conversion.Add(val4); component.m_conversion.Add(val3); } if ((Object)(object)val2 != (Object)null) { CookingStation component2 = val2.GetComponent(); component2.m_conversion.Add(val4); component2.m_conversion.Add(val3); } } public void setupPickableDrops(ZNetScene zNetScene) { GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Pickable_MeadowsMeatPile01"); GameObject val2 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Pickable_MeadowsMeatPile02"); Pickable component = val.GetComponent(); Pickable component2 = val2.GetComponent(); GameObject item = getItem(zNetScene, "RawMeat"); if ((Object)(object)item != (Object)null) { component.m_itemPrefab = item; component2.m_itemPrefab = item; } createExtraDrops(component, zNetScene); createExtraDrops(component2, zNetScene); } private void createExtraDrops(Pickable pickable, ZNetScene zNetScene) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) List list = new List(); string name = ((Object)((Component)pickable).gameObject).name; string text = name; if (!(text == "Pickable_MeadowsMeatPile01")) { if (text == "Pickable_MeadowsMeatPile02") { list.Add(createDrop(zNetScene, "RawMeat", 1, 1, 0.4f)); list.Add(createDrop(zNetScene, "Coins", 5, 15, 0.2f)); list.Add(createDrop(zNetScene, "BoneFragments", 1, 3, 0.2f)); list.Add(createDrop(zNetScene, "NeckTail", 1, 2, 0.3f)); } } else { list.Add(createDrop(zNetScene, "RawMeat", 1, 1, 0.4f)); list.Add(createDrop(zNetScene, "DeerMeat", 1, 1, 0.2f)); list.Add(createDrop(zNetScene, "NeckTail", 1, 2, 0.3f)); list.Add(createDrop(zNetScene, "Honey", 1, 2, 0.1f)); } pickable.m_extraDrops.m_drops = list; } private DropData createDrop(ZNetScene zNetScene, string name, int min, int max, float chance) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) DropData result = default(DropData); result.m_stackMin = min; result.m_stackMax = max; result.m_weight = chance; result.m_item = getItem(zNetScene, name); return result; } private GameObject getItem(ZNetScene zNetScene, string name) { return zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == name); } } public class ShaderReplacment { public static List prefabsToReplaceShader = new List(); public static List materialsInPrefabs = new List(); public string[] shaderlist = new string[49] { "Custom/AlphaParticle", "Custom/Blob", "Custom/Bonemass", "Custom/Clouds", "Custom/Creature", "Custom/Decal", "Custom/Distortion", "Custom/Flow", "Custom/FlowOpaque", "Custom/Grass", "Custom/GuiScroll", "Custom/Heightmap", "Custom/icon", "Custom/InteriorSide", "Custom/LitGui", "Custom/LitParticles", "Custom/mapshader", "Custom/ParticleDecal", "Custom/Piece", "Custom/Player", "Custom/Rug", "Custom/ShadowBlob", "Custom/SkyboxProcedural", "Custom/SkyObject", "Custom/StaticRock", "Custom/Tar", "Custom/Trilinearmap", "Custom/UI/BGBlur", "Custom/Vegetation", "Custom/Water", "Custom/WaterBottom", "Custom/WaterMask", "Custom/Yggdrasil", "Custom/Yggdrasil/root", "Hidden/BlitCopyHDRTonemap", "Hidden/Dof/DepthOfFieldHdr", "Hidden/Dof/DX11Dof", "Hidden/Internal-Loading", "Hidden/Internal-UIRDefaultWorld", "Hidden/SimpleClear", "Hidden/SunShaftsComposite", "Lux Lit Particles/ Bumped", "Lux Lit Particles/ Tess Bumped", "Particles/Standard Surface2", "Particles/Standard Unlit2", "Standard TwoSided", "ToonDeferredShading2017", "Unlit/DepthWrite", "Unlit/Lighting" }; public static List shaders = new List(); private static readonly HashSet CachedShaders = new HashSet(); public static bool debug = true; public static Shader findShader(string name) { Shader[] array = Resources.FindObjectsOfTypeAll(); if (array.Length == 0) { Debug.LogWarning((object)"SHADER LIST IS EMPTY!"); return null; } if (debug) { } return shaders.Find((Shader x) => ((Object)x).name == name); } public static Shader GetShaderByName(string name) { return shaders.Find((Shader x) => ((Object)x).name == name.Trim()); } public static void debugShaderList(List shadersRes) { foreach (Shader shadersRe in shadersRes) { Debug.LogWarning((object)("SHADER NAME IS: " + ((Object)shadersRe).name)); } debug = false; } public static void Replace(GameObject gameObject) { prefabsToReplaceShader.Add(gameObject); GetMaterialsInPrefab(gameObject); } public static void GetMaterialsInPrefab(GameObject gameObject) { Renderer[] componentsInChildren = gameObject.GetComponentsInChildren(true); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { Material[] sharedMaterials = val.sharedMaterials; if (sharedMaterials == null || sharedMaterials.Length == 0) { continue; } Material[] array2 = sharedMaterials; foreach (Material val2 in array2) { if ((Object)(object)val2 != (Object)null) { materialsInPrefabs.Add(val2); } } } } public static void getMeShaders() { AssetBundle[] array = Resources.FindObjectsOfTypeAll(); AssetBundle[] array2 = array; foreach (AssetBundle val in array2) { IEnumerable enumerable3; try { IEnumerable enumerable2; if (!val.isStreamedSceneAssetBundle || !Object.op_Implicit((Object)(object)val)) { IEnumerable enumerable = val.LoadAllAssets(); enumerable2 = enumerable; } else { enumerable2 = from shader in ((IEnumerable)val.GetAllAssetNames()).Select((Func)val.LoadAsset) where (Object)(object)shader != (Object)null select shader; } enumerable3 = enumerable2; } catch (Exception) { continue; } if (enumerable3 == null) { continue; } foreach (Shader item in enumerable3) { CachedShaders.Add(item); } } } public static void runMaterialFix() { getMeShaders(); shaders.AddRange(CachedShaders); foreach (Material materialsInPrefab in materialsInPrefabs) { Shader shader = materialsInPrefab.shader; if (!((Object)(object)shader == (Object)null)) { string name = ((Object)shader).name; if (!(name == "Standard") && name.Contains("Balrond")) { setProperValue(materialsInPrefab, name); } } } } private static void setProperValue(Material material, string shaderName) { string name = shaderName.Replace("Balrond", "Custom"); name = checkNaming(name); Shader shaderByName = GetShaderByName(name); if ((Object)(object)shaderByName == (Object)null) { Debug.LogWarning((object)("Shader not found " + name)); } else { material.shader = shaderByName; } } private static string checkNaming(string name) { string result = name; if (name.Contains("Bumped")) { result = name.Replace("Custom", "Lux Lit Particles"); } if (name.Contains("Tess Bumped")) { result = name.Replace("Custom", "Lux Lit Particles"); } if (name.Contains("Standard Surface")) { result = name.Replace("Custom", "Particles"); result = result.Replace("Standard Surface2", "Standard Surface"); } if (name.Contains("Standard Unlit")) { result = name.Replace("Custom", "Particles"); result = result.Replace("Standard Unlit", "Standard Unlit2"); result = result.Replace("Standard Unlit22", "Standard Unlit2"); } return result; } } [BepInPlugin("balrond.astafaraios.AichoPieces", "AichoPieces", "1.0.3")] 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; } } [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(true); foreach (AudioSource val in componentsInChildren) { val.outputAudioMixerGroup = __instance.m_masterMixer.outputAudioMixerGroup; } } foreach (GameObject buildPrefab in modResourceLoader.buildPrefabs) { AudioSource[] componentsInChildren2 = buildPrefab.GetComponentsInChildren(true); foreach (AudioSource val2 in componentsInChildren2) { val2.outputAudioMixerGroup = __instance.m_masterMixer.outputAudioMixerGroup; } } foreach (GameObject monsterPrefab in modResourceLoader.monsterPrefabs) { AudioSource[] componentsInChildren3 = monsterPrefab.GetComponentsInChildren(true); foreach (AudioSource val3 in componentsInChildren3) { val3.outputAudioMixerGroup = __instance.m_masterMixer.outputAudioMixerGroup; } } foreach (GameObject vfxPrefab in modResourceLoader.vfxPrefabs) { AudioSource[] componentsInChildren4 = vfxPrefab.GetComponentsInChildren(true); foreach (AudioSource val4 in componentsInChildren4) { val4.outputAudioMixerGroup = __instance.m_masterMixer.outputAudioMixerGroup; } } foreach (GameObject vegetationPrefab in modResourceLoader.vegetationPrefabs) { AudioSource[] componentsInChildren5 = vegetationPrefab.GetComponentsInChildren(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()) { 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()) { 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.AichoPieces"); public const string PluginGUID = "balrond.astafaraios.AichoPieces"; public const string PluginName = "AichoPieces"; public const string PluginVersion = "1.0.3"; 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 = "AichoPieces"; public static GameObject RootObject; public static GameObject PrefabContainer; public static bool hasSpawned = false; private void Awake() { createPrefabContainer(); modResourceLoader.loadAssets(); harmony.PatchAll(); } private string buildUpgradeString(List list) { string text = "vegetation_reset "; text += buildStringFromList(list); return text + " start"; } private string buildStringFromList(List 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(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()); } public static GameObject fixMaterials(GameObject clone, GameObject source) { MeshRenderer[] componentsInChildren = source.GetComponentsInChildren(); foreach (MeshRenderer val in componentsInChildren) { MeshRenderer[] componentsInChildren2 = clone.GetComponentsInChildren(); 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(); ((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(); if ((Object)(object)component != (Object)null) { RandomSpawn val3 = val.AddComponent(); 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[] 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 list; private string[] piecesNames = BuildPieceList.buildPieces; private CraftingStation workbench; private CraftingStation tannery; private CraftingStation runeForge; private CraftingStation alchemyLab; private CraftingStation grill; private CraftingStation fletcher; private CraftingStation blackforge; private CraftingStation forge; private CraftingStation cauldron; private CraftingStation stonecutter; public void SetupBuildPieces(List list) { 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 setupSaplings() { GameObject val = list.Find((GameObject x) => ((Object)x).name == "Swamp_Sapling_aicho"); GameObject val2 = list.Find((GameObject x) => ((Object)x).name == "Willow_Sapling_aicho"); if ((Object)(object)val != (Object)null) { Piece component = val.GetComponent(); ((Behaviour)component).enabled = true; SetStation(component, null); AddResources(component, "SwampSeed_aicho", 1); } if ((Object)(object)val2 != (Object)null) { Piece component2 = val2.GetComponent(); ((Behaviour)component2).enabled = true; SetStation(component2, null); AddResources(component2, "WillowSeed_aicho", 1); } } private void EditBuildPiece(GameObject gameObject) { //IL_1216: Unknown result type (might be due to invalid IL or missing references) //IL_15df: Unknown result type (might be due to invalid IL or missing references) //IL_15b1: Unknown result type (might be due to invalid IL or missing references) //IL_1399: Unknown result type (might be due to invalid IL or missing references) //IL_0ca1: Unknown result type (might be due to invalid IL or missing references) //IL_1564: Unknown result type (might be due to invalid IL or missing references) //IL_0e7c: Unknown result type (might be due to invalid IL or missing references) //IL_1471: Unknown result type (might be due to invalid IL or missing references) //IL_10bd: Unknown result type (might be due to invalid IL or missing references) //IL_0f7b: Unknown result type (might be due to invalid IL or missing references) //IL_12f7: Unknown result type (might be due to invalid IL or missing references) //IL_0dbc: Unknown result type (might be due to invalid IL or missing references) //IL_0f2b: Unknown result type (might be due to invalid IL or missing references) //IL_112d: Unknown result type (might be due to invalid IL or missing references) //IL_13e9: Unknown result type (might be due to invalid IL or missing references) //IL_14e1: Unknown result type (might be due to invalid IL or missing references) //IL_143c: Unknown result type (might be due to invalid IL or missing references) //IL_0d5a: Unknown result type (might be due to invalid IL or missing references) //IL_0fcb: Unknown result type (might be due to invalid IL or missing references) //IL_101b: Unknown result type (might be due to invalid IL or missing references) //IL_1513: Unknown result type (might be due to invalid IL or missing references) //IL_106b: Unknown result type (might be due to invalid IL or missing references) //IL_0ecc: Unknown result type (might be due to invalid IL or missing references) //IL_1367: Unknown result type (might be due to invalid IL or missing references) //IL_12a6: Unknown result type (might be due to invalid IL or missing references) //IL_0e1d: Unknown result type (might be due to invalid IL or missing references) //IL_1265: Unknown result type (might be due to invalid IL or missing references) //IL_11a2: Unknown result type (might be due to invalid IL or missing references) Piece component = gameObject.gameObject.GetComponent(); SetStation(component, workbench); switch (((Object)gameObject).name) { case "Swamp_Sapling_aicho": case "Willow_Sapling_aicho": case "scarecrow_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "LeatherScraps", 20); AddResources(component, "Wood", 5); AddResources(component, "Coal", 15); component.m_category = (PieceCategory)0; break; case "clutter_bottleset_bal": case "clutter_cupset_bal": case "clutter_tableset_bal": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "Tin", 5); AddResources(component, "FineWood", 2); AddResources(component, "RoundLog", 4); AddResources(component, "Wood", 8); break; case "cabinet_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "BronzeNails", 15); AddResources(component, "Wood", 10); AddResources(component, "FineWood", 10); AddResources(component, "Resin", 20); component.m_category = (PieceCategory)4; break; case "cabinet2_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "BronzeNails", 30); AddResources(component, "Wood", 10); AddResources(component, "FineWood", 20); AddResources(component, "Resin", 40); component.m_category = (PieceCategory)4; break; case "clutter_bookset1_bal": case "clutter_bookset2_bal": case "clutter_bookset3_bal": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "LeatherScraps", 15); AddResources(component, "FineWood", 10); AddResources(component, "Resin", 5); AddResources(component, "DeerHide", 30); component.m_category = (PieceCategory)4; break; case "clutter_scroll1_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "BronzeNails", 6); AddResources(component, "Coal", 10); AddResources(component, "FineWood", 5); AddResources(component, "DeerHide", 3); component.m_category = (PieceCategory)4; break; case "clutter_scroll2_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "Coal", 10); AddResources(component, "FineWood", 5); AddResources(component, "DeerHide", 3); component.m_category = (PieceCategory)4; break; case "clutter_scroll3_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "BronzeNails", 6); AddResources(component, "Coal", 10); AddResources(component, "FineWood", 5); AddResources(component, "DeerHide", 3); component.m_category = (PieceCategory)4; break; case "Painting1_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "Blackwood", 5); AddResources(component, "Coal", 10); AddResources(component, "DeerHide", 5); component.m_category = (PieceCategory)4; break; case "Painting2_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "RoundLog", 5); AddResources(component, "Coal", 10); AddResources(component, "DeerHide", 5); component.m_category = (PieceCategory)4; break; case "Painting3_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "Wood", 5); AddResources(component, "Coal", 10); AddResources(component, "DeerHide", 5); component.m_category = (PieceCategory)4; break; case "Painting4_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "FineWood", 5); AddResources(component, "Coal", 10); AddResources(component, "DeerHide", 5); component.m_category = (PieceCategory)4; break; case "pirate_barrels_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "Iron", 10); AddResources(component, "Resin", 20); AddResources(component, "RoundLog", 60); component.m_category = (PieceCategory)4; break; case "pirateTable_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "BronzeNails", 10); AddResources(component, "Crystal", 3); AddResources(component, "Wood", 20); AddResources(component, "RoundLog", 5); AddResources(component, "Coal", 10); component.m_category = (PieceCategory)4; break; case "piece_candlechandelier1_aicho": ((Behaviour)component).enabled = true; setFireplaceFuelItem(component); SetStation(component, workbench); AddResources(component, "Iron", 10); AddResources(component, "Chain", 1); AddResources(component, "Resin", 12); AddResources(component, "IronNails", 30); component.m_category = (PieceCategory)4; break; case "piece_candlechandelier2_aicho": ((Behaviour)component).enabled = true; setFireplaceFuelItem(component); SetStation(component, workbench); AddResources(component, "Bronze", 15); AddResources(component, "Chain", 5); AddResources(component, "Resin", 8); AddResources(component, "BronzeNails", 30); component.m_category = (PieceCategory)4; break; case "wallscroll_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "Wood", 1); AddResources(component, "Coal", 1); AddResources(component, "Raspberry", 1); component.m_category = (PieceCategory)4; break; case "clutter_winebottle_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "Crystal", 10); AddResources(component, "Wood", 5); component.m_category = (PieceCategory)4; break; case "clutter_alcoholbox_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "Crystal", 20); AddResources(component, "Resin", 40); AddResources(component, "Wood", 1); component.m_category = (PieceCategory)4; break; case "supply_shelf_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "Wood", 10); AddResources(component, "IronNails", 15); AddResources(component, "Bronze", 1); AddResources(component, "Coal", 10); AddResources(component, "Feathers", 2); component.m_category = (PieceCategory)4; break; case "stone_floor4m_aicho": case "stone_wall4m_aicho": ((Behaviour)component).enabled = true; SetStation(component, stonecutter); AddResources(component, "Stone", 12); component.m_category = (PieceCategory)3; break; case "StatueFace_aicho": ((Behaviour)component).enabled = true; SetStation(component, stonecutter); AddResources(component, "Stone", 50); AddResources(component, "Ruby", 1); AddResources(component, "FreezeGland", 2); component.m_category = (PieceCategory)4; break; case "StatueOdin2_aicho": ((Behaviour)component).enabled = true; SetStation(component, stonecutter); AddResources(component, "Stone", 250); AddResources(component, "Ruby", 1); AddResources(component, "FreezeGland", 2); component.m_category = (PieceCategory)4; break; case "StatueWolf_aicho": ((Behaviour)component).enabled = true; SetStation(component, stonecutter); AddResources(component, "Stone", 500); component.m_category = (PieceCategory)4; break; case "clutter_shipmodel_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "Wood", 40); AddResources(component, "LinenThread", 30); AddResources(component, "IronNails", 20); AddResources(component, "BoneFragments", 4); AddResources(component, "Iron", 2); component.m_category = (PieceCategory)4; break; case "stone_arche_cricle_aicho": ((Behaviour)component).enabled = true; SetStation(component, stonecutter); AddResources(component, "Stone", 20); component.m_category = (PieceCategory)4; break; case "clutter_potionSet_aicho": case "clutter_alcoholbottleSet_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "Crystal", 20); AddResources(component, "Resin", 40); AddResources(component, "Wood", 2); component.m_category = (PieceCategory)4; break; case "clutter_potion1_aicho": case "clutter_potion2_aicho": case "clutter_potion3_aicho": case "clutter_potion4_aicho": case "clutter_alcoholbottle1_aicho": case "clutter_alcoholbottle2_aicho": case "clutter_alcoholbottle3_aicho": case "clutter_alcoholbottle4_aicho": case "clutter_alcoholbottle5_aicho": ((Behaviour)component).enabled = true; SetStation(component, workbench); AddResources(component, "Crystal", 5); AddResources(component, "Resin", 10); AddResources(component, "Wood", 1); component.m_category = (PieceCategory)4; break; case "StatueDeath_aicho": case "gateway_black_aicho": case "gateway_white_aicho": case "clutter_candles1_aicho": case "clutter_candles2_aicho": case "spiderWeb1_aicho": case "spiderWeb2_aicho": case "spiderWeb3_aicho": case "spiderWeb4_aicho": case "spiderWeb5_aicho": case "spiderWeb6_aicho": case "archgate_pass_aicho": case "cage_1_aicho": case "cage_2_aicho": case "Coffin1_aicho": case "Coffin2_aicho": case "skeleton_puppet1_aicho": case "skeleton_puppet2_aicho": case "skeleton_puppet3_aicho": case "StatueAngel_aicho": case "StatueGriffin_aicho": case "StatueHand_aicho": case "StatueThor_aicho": case "StatueThor2_aicho": case "StatueEagle_aicho": case "stone_arche_big_aicho": case "stone_pillar6m1_aicho": case "stone_pillar6m2_aicho": case "stone_pillar6m3_aicho": case "stone_pillar6m4_aicho": case "target_dummy_aicho": case "target_dummy1_aicho": case "target_practice_2_aicho": case "tomb1_aicho": case "tomb2_aicho": case "tomb3_aicho": case "tomb4_aicho": ((Behaviour)component).enabled = false; SetStation(component, workbench); AddResources(component, "Coal", 1); component.m_category = (PieceCategory)0; break; } } private void setFireplaceFuelItem(Piece piece, string name = "Wood", int startFuel = -1, int maxFuel = -1, float secPerFuel = -1f) { Fireplace component = ((Component)piece).GetComponent(); component.m_fuelItem = FindItem(list, name).GetComponent(); component.m_startFuel = ((startFuel != -1) ? ((float)startFuel) : component.m_startFuel); component.m_maxFuel = ((maxFuel != -1) ? ((float)maxFuel) : component.m_maxFuel); component.m_secPerFuel = ((secPerFuel != -1f) ? secPerFuel : component.m_secPerFuel); } 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 list = new List(); 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 list = new List(); list.AddRange(piece.m_resources); Requirement val = new Requirement(); val.m_resItem = FindItem(this.list, itemName).GetComponent(); val.m_amount = amount; val.m_amountPerLevel = amountPerLevel; list.Add(val); piece.m_resources = list.ToArray(); } private GameObject FindItem(List list, string name, bool isStation = false) { GameObject val = list.Find((GameObject x) => ((Object)x).name == name); if ((Object)(object)val != (Object)null) { return val; } if ((Object)(object)val == (Object)null && isStation) { return null; } Debug.LogWarning((object)(Launch.projectName + ": Item Not Found - " + name + ", Replaced With Wood")); return list.Find((GameObject x) => ((Object)x).name == "Wood"); } private CraftingStation FindStation(List list, string name) { GameObject val = FindItem(list, name, isStation: true); if ((Object)(object)val != (Object)null) { return val.GetComponent(); } return null; } private void setupTables(List list) { workbench = FindStation(list, "piece_workbench"); if ((Object)(object)workbench == (Object)null) { Debug.LogWarning((object)"Did not foundpiece_workbench"); } tannery = FindStation(list, "piece_tannery"); if ((Object)(object)tannery == (Object)null) { tannery = workbench; } blackforge = FindStation(list, "blackforge"); if ((Object)(object)blackforge == (Object)null) { Debug.LogWarning((object)"Did not foundblackforge"); } forge = FindStation(list, "forge"); if ((Object)(object)forge == (Object)null) { Debug.LogWarning((object)"Did not foundforge"); } cauldron = FindStation(list, "piece_cauldron"); if ((Object)(object)cauldron == (Object)null) { Debug.LogWarning((object)"Did not foundpiece_cauldron"); } runeForge = FindStation(list, "piece_runeforge"); if ((Object)(object)runeForge == (Object)null) { runeForge = forge; } alchemyLab = FindStation(list, "piece_alchemylab"); if ((Object)(object)alchemyLab == (Object)null) { alchemyLab = cauldron; } grill = FindStation(list, "piece_grill"); if ((Object)(object)grill == (Object)null) { grill = cauldron; } fletcher = FindStation(list, "piece_fletcher"); if ((Object)(object)fletcher == (Object)null) { fletcher = workbench; } stonecutter = FindStation(list, "piece_stonecutter"); if ((Object)(object)stonecutter == (Object)null) { Debug.LogWarning((object)"Did not foundpiece_stonecutter"); stonecutter = workbench; } } } public class BuildPieceTargeting { private static string[] names = new string[0]; public void changePieceTargeting(List gameObjects) { List list = gameObjects.FindAll((GameObject x) => (Object)(object)x.GetComponent() != (Object)null); foreach (GameObject item in list) { Piece component = item.GetComponent(); 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() != (Object)null) { return true; } if ((Object)(object)gameObject.GetComponent() != (Object)null) { return true; } if ((Object)(object)gameObject.GetComponent() != (Object)null) { return true; } if ((Object)(object)gameObject.GetComponent() != (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(); 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() != (Object)null) { itemDrop = prefab.GetComponent(); } else { Debug.LogWarning((object)("DVERGER FURNITURE: NO ITEM DROP FOUND on prefab name: " + ((Object)prefab).name)); } } public Requirement getPieceConfig() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_003e: Expected O, but got Unknown Requirement val = new Requirement { m_resItem = itemDrop, m_amount = amount, m_amountPerLevel = amountPerLevel, m_recover = recovery }; Requirement result = val; pieceConfig = val; return result; } }