Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of EmeraudeBoisResine v1.1.0
plugins/EmeraudeBoisResine.dll
Decompiled 17 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("EmeraudeBoisResine")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0")] [assembly: AssemblyProduct("EmeraudeBoisResine")] [assembly: AssemblyTitle("EmeraudeBoisResine")] [assembly: AssemblyVersion("1.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace EmeraudeBoisResine { [BepInPlugin("emeraude.boisresine", "Emeraude Bois Resine", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "emeraude.boisresine"; public const string Name = "Emeraude Bois Resine"; public const string Version = "1.1.0"; private const string Suffix = "_resine"; private const string Category = "Resined wood"; private const int WoodFactor = 2; private static readonly Color Amber = new Color(0.9f, 0.68f, 0.42f); private void Awake() { AddTranslations(); PrefabManager.OnVanillaPrefabsAvailable += AddResinedPieces; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Emeraude Bois Resine 1.1.0 loaded"); } private void AddTranslations() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "English"; localization.AddTranslation(ref text, new Dictionary<string, string> { ["emeraude_resine"] = "resined", ["emeraude_resine_desc"] = "Doesn't wear out in the rain or in water." }); text = "French"; localization.AddTranslation(ref text, new Dictionary<string, string> { ["emeraude_resine"] = "résiné", ["emeraude_resine_desc"] = "Ne s'abîme pas sous la pluie ni dans l'eau.", ["jotunn_cat_resined_wood"] = "Bois résiné" }); } private void AddResinedPieces() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown PrefabManager.OnVanillaPrefabsAvailable -= AddResinedPieces; ItemDrop component = PrefabManager.Instance.GetPrefab("Hammer").GetComponent<ItemDrop>(); Dictionary<Material, Material> tinted = new Dictionary<Material, Material>(); List<string> list = new List<string>(); foreach (GameObject item in component.m_itemData.m_shared.m_buildPieces.m_pieces.ToList()) { if (IsPlainWood(item)) { CustomPiece val = new CustomPiece(((Object)item).name + "_resine", ((Object)item).name, ConfigFrom(item.GetComponent<Piece>())); val.PiecePrefab.GetComponent<WearNTear>().m_noRoofWear = false; Tint(val.PiecePrefab, tinted); PieceManager.Instance.AddPiece(val); list.Add(((Object)item).name); } } ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} pièces résinées : {1}", list.Count, string.Join(", ", list))); } private static bool IsPlainWood(GameObject prefab) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Invalid comparison between Unknown and I4 Piece val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<Piece>() : null); WearNTear val2 = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<WearNTear>() : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2) && val.m_enabled && (int)val.m_category == 2 && val.m_resources.Length != 0 && val.m_resources.All((Requirement requirement) => Object.op_Implicit((Object)(object)requirement.m_resItem) && ((Object)requirement.m_resItem).name == "Wood") && val2.m_noRoofWear) { return (int)val2.m_materialType == 0; } return false; } private static PieceConfig ConfigFrom(Piece original) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown PieceConfig val = new PieceConfig { Name = original.m_name + " ($emeraude_resine)", Description = "$emeraude_resine_desc", PieceTable = PieceTables.Hammer, Category = "Resined wood", CraftingStation = (Object.op_Implicit((Object)(object)original.m_craftingStation) ? ((Object)original.m_craftingStation).name : "") }; Requirement[] resources = original.m_resources; foreach (Requirement val2 in resources) { val.AddRequirement(new RequirementConfig(((Object)val2.m_resItem).name, val2.m_amount * 2, 0, val2.m_recover)); } return val; } private static void Tint(GameObject prefab, Dictionary<Material, Material> tinted) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { Material[] sharedMaterials = val.sharedMaterials; for (int j = 0; j < sharedMaterials.Length; j++) { if (Object.op_Implicit((Object)(object)sharedMaterials[j]) && sharedMaterials[j].HasProperty("_Color")) { if (!tinted.TryGetValue(sharedMaterials[j], out var value)) { value = new Material(sharedMaterials[j]) { color = sharedMaterials[j].color * Amber }; tinted[sharedMaterials[j]] = value; } sharedMaterials[j] = value; } } val.sharedMaterials = sharedMaterials; } } } }