using System; using System.Collections.Generic; using System.Diagnostics; 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 BepInEx; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Extensions; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("VentureValheim.PiecesRoughStone")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("VentureValheim.PiecesRoughStone")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("640FA3FD-69DD-4F28-8C2F-1D91C78B3A7B")] [assembly: AssemblyFileVersion("0.2.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.2.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace VentureValheim { public class PieceMaker { public struct PieceMakerConfiguration { public string PrefabPrefix; public string NamePrefix; public List Pieces; public string PrefabReference; public string PieceTableCategory; public Material ReplacementMaterial; public Material ReplacementMaterialWorn; public Material ReplacementMaterialDestruction; public Material ReplacementMaterialSecondary; } public struct PieceConfiguration { public string Prefab; public int ResourceAmount; public Sprite Icon; } internal ManualLogSource PieceMakerLogger; public static string[] RoughStonePieces = new string[3] { "stone_pillar", "stone_arch", "stone_wall_4x2" }; public static string[] GraustenPieces = new string[19] { "Piece_grausten_stone_ladder", "Piece_grausten_floor_1x1", "Piece_grausten_floor_2x2", "Piece_grausten_floor_4x4", "Piece_grausten_pillarbase_small", "Piece_grausten_pillarbase_medium", "Piece_grausten_pillarbase_tapered", "Piece_grausten_pillarbase_tapered_inverted", "Piece_grausten_pillarbeam_small", "Piece_grausten_pillarbeam_medium", "Piece_grausten_pillar_arch_small", "Piece_grausten_pillar_arch", "Piece_grausten_wall_arch", "Piece_grausten_wall_arch_inverted", "Piece_grausten_wall_1x2", "Piece_grausten_wall_2x2", "Piece_grausten_wall_4x2", "Piece_grausten_window_2x2", "Piece_grausten_window_4x2" }; public static string[] GraustenRoofPieces = new string[6] { "piece_grausten_roof_45", "piece_grausten_roof_45_corner", "piece_grausten_roof_45_corner2", "piece_grausten_roof_45_arch", "piece_grausten_roof_45_arch_corner", "piece_grausten_roof_45_arch_corner2" }; public static string[] BlackMarblePieces = new string[14] { "blackmarble_1x1", "blackmarble_2x1x1", "blackmarble_2x2x2", "blackmarble_floor", "blackmarble_floor_triangle", "blackmarble_stair", "blackmarble_tip", "blackmarble_base_1", "blackmarble_basecorner", "blackmarble_out_1", "blackmarble_outcorner", "blackmarble_arch", "blackmarble_column_1", "blackmarble_column_2" }; public PieceMaker(ManualLogSource logger) { PieceMakerLogger = logger; } public static PieceTable GetPieceTable(GameObject item) { if ((Object)(object)item == (Object)null) { return null; } ItemDrop component = item.GetComponent(); if ((Object)(object)component == (Object)null) { return null; } return component.m_itemData?.m_shared.m_buildPieces; } public static List FindVanillaPieces(PieceTable pieceTable, string resource, PieceCategory category) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Piece val = default(Piece); foreach (GameObject piece in pieceTable.m_pieces) { if (piece.TryGetComponent(ref val) && (int)category != 100 && val.m_category == category && val.m_resources.Length == 1 && ((Object)val.m_resources[0].m_resItem).name == resource) { list.Add(Utils.GetPrefabName(((Object)piece).name)); } } return list; } public List FindVanillaPieces(string[] prefabs, AssetBundle bundle, string iconPrefx) { List list = new List(); Piece val = default(Piece); foreach (string text in prefabs) { GameObject prefab = ZNetScene.instance.GetPrefab(text); if ((Object)(object)prefab != (Object)null && prefab.TryGetComponent(ref val)) { string text2 = iconPrefx + text; Sprite val2 = bundle.LoadAsset(text2); if ((Object)(object)val2 == (Object)null) { PieceMakerLogger.LogDebug((object)("Asset buundle did not contain icon: " + text2)); } list.Add(new PieceConfiguration { Prefab = Utils.GetPrefabName(((Object)prefab).name), ResourceAmount = ((val.m_resources.Length != 0) ? val.m_resources[0].m_amount : 0), Icon = val2 }); } } return list; } public void AddCopies(PieceMakerConfiguration config, GameObject root) { //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Expected O, but got Unknown //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Expected O, but got Unknown //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Expected O, but got Unknown //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) if (config.Pieces == null || config.Pieces.Count == 0) { PieceMakerLogger.LogError((object)"No pieces found! Can not add new options."); return; } GameObject prefab = ZNetScene.instance.GetPrefab(config.PrefabReference); Piece val = null; WearNTear val2 = null; if ((Object)(object)prefab == (Object)null) { PieceMakerLogger.LogWarning((object)"Could not find stone piece to copy effects. Using defaults."); } else { val = prefab.GetComponent(); val2 = prefab.GetComponent(); } if ((Object)(object)config.ReplacementMaterial == (Object)null) { MeshRenderer componentInChildren = prefab.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { config.ReplacementMaterial = ((Renderer)componentInChildren).material; } if ((Object)(object)config.ReplacementMaterial == (Object)null) { PieceMakerLogger.LogError((object)("Could not find material to copy from prefab " + config.PrefabReference + "!")); } PieceMakerLogger.LogDebug((object)$"Secondary material null: {(Object)(object)config.ReplacementMaterialSecondary == (Object)null}!"); } int num = 0; foreach (PieceConfiguration piece2 in config.Pieces) { GameObject prefab2 = ZNetScene.instance.GetPrefab(piece2.Prefab); GameObject piece = Object.Instantiate(prefab2, root.transform, false); ((Object)piece).name = config.PrefabPrefix + Utils.GetPrefabName(piece); Piece component = piece.GetComponent(); if ((Object)(object)component != (Object)null) { Piece component2 = prefab2.GetComponent(); component.m_name = config.NamePrefix + component2.m_name; component.m_icon = (Sprite)(((Object)(object)piece2.Icon == (Object)null) ? ((object)component2.m_icon) : ((object)piece2.Icon)); component.m_placeEffect = val.m_placeEffect; WearNTear component3 = piece.GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.m_health = val2.m_health; component3.m_destroyedEffect = val2.m_destroyedEffect; component3.m_hitEffect = val2.m_hitEffect; component3.m_materialType = val2.m_materialType; component3.m_damages = val2.m_damages; component3.m_ashDamageImmune = val2.m_ashDamageImmune; component3.m_ashDamageResist = val2.m_ashDamageResist; component3.m_burnable = val2.m_burnable; } ReplaceMaterials(ref piece, new string[2] { "new", "New" }, config.ReplacementMaterial, config.ReplacementMaterialSecondary); ReplaceMaterials(ref piece, new string[2] { "worn", "Worn" }, config.ReplacementMaterialWorn, config.ReplacementMaterialSecondary); ReplaceMaterials(ref piece, new string[2] { "broken", "Broken" }, config.ReplacementMaterialWorn, config.ReplacementMaterialSecondary); ReplaceMaterials(ref piece, new string[2] { "destruction", "Destruction" }, config.ReplacementMaterialDestruction, config.ReplacementMaterialSecondary); PieceConfig val3 = new PieceConfig(); val3.Name = component.m_name; val3.Description = component.m_description; val3.PieceTable = PieceTables.Hammer; val3.Category = config.PieceTableCategory; val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig { Item = "Stone", Amount = piece2.ResourceAmount, Recover = true } }; PieceConfig val4 = val3; PieceManager.Instance.AddPiece(new CustomPiece(piece, true, val4)); num++; continue; } PieceMakerLogger.LogDebug((object)(((Object)piece).name + " is not a piece, skipping.")); break; } PieceMakerLogger.LogInfo((object)$"Done adding {num} additional pieces."); } internal void ReplaceMaterials(ref GameObject piece, string[] hierarchyNames, Material material, Material secondaryMaterial) { bool flag = false; foreach (string text in hierarchyNames) { Transform val = TransformExtensions.FindDeepChild(piece.transform, text, (IterativeSearchType)1); if ((Object)(object)val == (Object)null) { continue; } MeshRenderer[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); if (componentsInChildren == null) { continue; } flag = true; MeshRenderer[] array = componentsInChildren; foreach (MeshRenderer val2 in array) { if ((Object)(object)secondaryMaterial != (Object)null && ((Renderer)val2).materials.Length > 1) { Material[] source = (Material[])(object)new Material[2] { material, secondaryMaterial }; ((Renderer)val2).SetMaterials(source.ToList()); } else { ((Renderer)val2).material = material; } } } if (!flag) { PieceMakerLogger.LogDebug((object)("Could not replace materials for " + ((Object)piece).name + ": " + hierarchyNames[0])); } } } } namespace VentureValheim.PiecesRoughStone { [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.orianaventure.mod.VenturePiecesRoughStone", "VenturePiecesRoughStone", "0.2.0")] public class PiecesRoughStonePlugin : BaseUnityPlugin { private const string ModName = "VenturePiecesRoughStone"; private const string ModVersion = "0.2.0"; private const string Author = "com.orianaventure.mod"; private const string ModGUID = "com.orianaventure.mod.VenturePiecesRoughStone"; private readonly Harmony HarmonyInstance = new Harmony("com.orianaventure.mod.VenturePiecesRoughStone"); public static readonly ManualLogSource PiecesRoughStoneLogger = Logger.CreateLogSource("VenturePiecesRoughStone"); public static GameObject Root; internal static AssetBundle StoneBundle; internal static Material StoneTexture; internal static Material StoneTextureWorn; internal static Material StoneTextureDestruction; internal static Material StoneTextureSecondary; internal static Material StoneTextureNoNoise; public void Awake() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown PiecesRoughStoneLogger.LogInfo((object)"My girlfriend turned into the moon."); Root = new GameObject("RoughStoneRoot"); Root.SetActive(false); Object.DontDestroyOnLoad((Object)(object)Root); Assembly executingAssembly = Assembly.GetExecutingAssembly(); HarmonyInstance.PatchAll(executingAssembly); StoneBundle = AssetUtils.LoadAssetBundleFromResources("vv_roughstone", Assembly.GetExecutingAssembly()); StoneTexture = StoneBundle.LoadAsset("vv_rough_stone"); StoneTextureWorn = StoneBundle.LoadAsset("vv_rough_stone_worn"); StoneTextureDestruction = StoneBundle.LoadAsset("vv_rough_stone_destruction"); StoneTextureSecondary = StoneBundle.LoadAsset("vv_roof_blue"); StoneTextureNoNoise = StoneBundle.LoadAsset("vv_rough_stone_nonoise"); PrefabManager.OnPrefabsRegistered += PiecesRoughStone.Initialize; } } public class PiecesRoughStone { private const string CATEGORY = "Venture Stone"; private const string PREFAB_PREFIX = "VV_RS_"; private const string NAME_PREFIX = "VRS "; private const string ICON_PREFIX = "VV_RSicon_"; public static void Initialize() { PieceMaker pieceMaker = new PieceMaker(PiecesRoughStonePlugin.PiecesRoughStoneLogger); string prefabReference = "stone_wall_4x2"; List pieces = pieceMaker.FindVanillaPieces(PieceMaker.BlackMarblePieces, PiecesRoughStonePlugin.StoneBundle, "VV_RSicon_"); PieceMaker.PieceMakerConfiguration config = new PieceMaker.PieceMakerConfiguration { Pieces = pieces, PieceTableCategory = "Venture Stone", PrefabPrefix = "VV_RS_", NamePrefix = "VRS ", PrefabReference = prefabReference, ReplacementMaterial = PiecesRoughStonePlugin.StoneTexture, ReplacementMaterialWorn = PiecesRoughStonePlugin.StoneTextureWorn, ReplacementMaterialDestruction = PiecesRoughStonePlugin.StoneTextureDestruction, ReplacementMaterialSecondary = null }; List pieces2 = pieceMaker.FindVanillaPieces(PieceMaker.GraustenPieces, PiecesRoughStonePlugin.StoneBundle, "VV_RSicon_"); PieceMaker.PieceMakerConfiguration config2 = new PieceMaker.PieceMakerConfiguration { Pieces = pieces2, PieceTableCategory = "Venture Stone", PrefabPrefix = "VV_RS_", NamePrefix = "VRS ", PrefabReference = prefabReference, ReplacementMaterial = PiecesRoughStonePlugin.StoneTextureNoNoise, ReplacementMaterialWorn = PiecesRoughStonePlugin.StoneTextureNoNoise, ReplacementMaterialDestruction = PiecesRoughStonePlugin.StoneTextureDestruction, ReplacementMaterialSecondary = null }; List pieces3 = pieceMaker.FindVanillaPieces(PieceMaker.GraustenRoofPieces, PiecesRoughStonePlugin.StoneBundle, "VV_RSicon_"); PieceMaker.PieceMakerConfiguration config3 = new PieceMaker.PieceMakerConfiguration { Pieces = pieces3, PieceTableCategory = "Venture Stone", PrefabPrefix = "VV_RS_", NamePrefix = "VRS ", PrefabReference = prefabReference, ReplacementMaterial = PiecesRoughStonePlugin.StoneTextureNoNoise, ReplacementMaterialWorn = PiecesRoughStonePlugin.StoneTextureNoNoise, ReplacementMaterialDestruction = PiecesRoughStonePlugin.StoneTextureSecondary, ReplacementMaterialSecondary = PiecesRoughStonePlugin.StoneTextureSecondary }; pieceMaker.AddCopies(config, PiecesRoughStonePlugin.Root); pieceMaker.AddCopies(config2, PiecesRoughStonePlugin.Root); pieceMaker.AddCopies(config3, PiecesRoughStonePlugin.Root); PrefabManager.OnPrefabsRegistered -= Initialize; } } }