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 MoonforgedBannerCollection v1.0.2
MoonforgedBannerCollection.dll
Decompiled a week agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.0.0.0")] namespace Moonforged.BannerCollection; public class BannerClothController : MonoBehaviour { private const float UpdateInterval = 0.25f; private readonly List<Component> clothComponents = new List<Component>(); private readonly List<Component> globalWindComponents = new List<Component>(); private readonly Dictionary<Component, float> originalWindMultipliers = new Dictionary<Component, float>(); private static Type clothType; private static Type coverType; private static Type globalWindType; private static PropertyInfo externalAccelerationProperty; private static PropertyInfo randomAccelerationProperty; private static MethodInfo isUnderRoofMethod; private static MethodInfo updateWindMethod; private static FieldInfo windMultiplierField; private float updateTimer; private bool roofStateInitialized; private bool wasUnderRoof; private void Awake() { CacheReflection(); FindClothComponents(); FindGlobalWindComponents(); UpdateRoofState(); } private void OnEnable() { updateTimer = 0f; roofStateInitialized = false; } private void OnDisable() { RestoreOriginalWind(); } private void OnDestroy() { RestoreOriginalWind(); } private void Update() { updateTimer -= Time.deltaTime; if (!(updateTimer > 0f)) { updateTimer = 0.25f; UpdateRoofState(); } } private static void CacheReflection() { if (clothType == null) { clothType = Type.GetType("UnityEngine.Cloth, UnityEngine.ClothModule"); if (clothType != null) { externalAccelerationProperty = clothType.GetProperty("externalAcceleration"); randomAccelerationProperty = clothType.GetProperty("randomAcceleration"); } } if (coverType == null) { coverType = Type.GetType("Cover, assembly_utils") ?? Type.GetType("Cover, assembly_valheim"); if (coverType != null) { isUnderRoofMethod = coverType.GetMethod("IsUnderRoof", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(Vector3) }, null); } } if (globalWindType == null) { globalWindType = Type.GetType("GlobalWind, assembly_valheim"); if (globalWindType != null) { windMultiplierField = globalWindType.GetField("m_multiplier", BindingFlags.Instance | BindingFlags.Public); updateWindMethod = globalWindType.GetMethod("UpdateWind", BindingFlags.Instance | BindingFlags.NonPublic); } } } private void FindClothComponents() { clothComponents.Clear(); if (clothType == null) { return; } Component[] componentsInChildren = ((Component)this).GetComponentsInChildren(clothType, true); Component[] array = componentsInChildren; foreach (Component val in array) { if ((Object)(object)val != (Object)null) { clothComponents.Add(val); } } } private void FindGlobalWindComponents() { globalWindComponents.Clear(); originalWindMultipliers.Clear(); if (globalWindType == null) { return; } Component[] componentsInChildren = ((Component)this).GetComponentsInChildren(globalWindType, true); Component[] array = componentsInChildren; foreach (Component val in array) { if (!((Object)(object)val == (Object)null)) { globalWindComponents.Add(val); if (windMultiplierField != null && windMultiplierField.GetValue(val) is float value) { originalWindMultipliers[val] = value; } } } } private void UpdateRoofState() { if (clothComponents.Count == 0) { FindClothComponents(); if (clothComponents.Count == 0) { return; } } if (globalWindComponents.Count == 0) { FindGlobalWindComponents(); } bool flag = IsBannerUnderRoof(); if (!roofStateInitialized || flag != wasUnderRoof) { roofStateInitialized = true; wasUnderRoof = flag; if (flag) { StopWindUnderRoof(); } else { RestoreOriginalWind(); } } if (flag) { ZeroClothWind(); } } private bool IsBannerUnderRoof() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0089: Unknown result type (might be due to invalid IL or missing references) if (isUnderRoofMethod == null) { return false; } bool flag = default(bool); foreach (Component clothComponent in clothComponents) { if ((Object)(object)clothComponent == (Object)null) { continue; } Vector3 val = clothComponent.transform.position; Renderer component = clothComponent.GetComponent<Renderer>(); if ((Object)(object)component != (Object)null) { Bounds bounds = component.bounds; val = ((Bounds)(ref bounds)).center; } try { object obj = isUnderRoofMethod.Invoke(null, new object[1] { val }); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } if (((uint)num & (flag ? 1u : 0u)) != 0) { return true; } } catch { return false; } } return false; } private void StopWindUnderRoof() { foreach (Component globalWindComponent in globalWindComponents) { if (!((Object)(object)globalWindComponent == (Object)null) && !(windMultiplierField == null)) { windMultiplierField.SetValue(globalWindComponent, 0f); updateWindMethod?.Invoke(globalWindComponent, null); } } ZeroClothWind(); } private void ZeroClothWind() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) foreach (Component clothComponent in clothComponents) { if (!((Object)(object)clothComponent == (Object)null)) { externalAccelerationProperty?.SetValue(clothComponent, Vector3.zero, null); randomAccelerationProperty?.SetValue(clothComponent, Vector3.zero, null); } } } private void RestoreOriginalWind() { foreach (Component globalWindComponent in globalWindComponents) { if (!((Object)(object)globalWindComponent == (Object)null) && !(windMultiplierField == null) && originalWindMultipliers.TryGetValue(globalWindComponent, out var value)) { windMultiplierField.SetValue(globalWindComponent, value); updateWindMethod?.Invoke(globalWindComponent, null); } } } } public static class BannerConfigManager { public static void Init(string modName, ConfigFile config) { } public static ConfigEntry<T> AddEntry<T>(ConfigFile cfg, string section, string key, T defaultValue, string description) { return cfg.Bind<T>(section, key, defaultValue, description); } } public class BannerIndoorClothStopper : MonoBehaviour { private const float RoofCheckInterval = 0.25f; private readonly List<Behaviour> clothComponents = new List<Behaviour>(); private readonly List<bool> originalEnabledStates = new List<bool>(); private static Type clothType; private static MethodInfo isUnderRoofMethod; private float roofCheckTimer; private bool roofStateInitialized; private bool wasUnderRoof; private void Awake() { CacheReflection(); CacheClothComponents(); } private void OnEnable() { roofCheckTimer = 0f; roofStateInitialized = false; } private void OnDisable() { RestoreOriginalClothState(); } private void OnDestroy() { RestoreOriginalClothState(); } private void Update() { roofCheckTimer -= Time.deltaTime; if (roofCheckTimer > 0f) { return; } roofCheckTimer = 0.25f; if (clothComponents.Count == 0) { CacheClothComponents(); if (clothComponents.Count == 0) { return; } } bool flag = IsUnderRoof(); if (!roofStateInitialized || flag != wasUnderRoof) { roofStateInitialized = true; wasUnderRoof = flag; SetClothSimulation(flag); } } private static void CacheReflection() { if (clothType == null) { clothType = FindRuntimeType("UnityEngine.Cloth"); } if (isUnderRoofMethod == null) { Type type = FindRuntimeType("Cover"); if (type != null) { isUnderRoofMethod = type.GetMethod("IsUnderRoof", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(Vector3) }, null); } } } private static Type FindRuntimeType(string fullName) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = assembly.GetType(fullName, throwOnError: false); if (type != null) { return type; } } return null; } private void CacheClothComponents() { clothComponents.Clear(); originalEnabledStates.Clear(); if (clothType == null) { CacheReflection(); } if (clothType == null) { return; } Component[] componentsInChildren = ((Component)this).GetComponentsInChildren(clothType, true); Component[] array = componentsInChildren; foreach (Component val in array) { Behaviour val2 = (Behaviour)(object)((val is Behaviour) ? val : null); if (val2 != null) { clothComponents.Add(val2); originalEnabledStates.Add(val2.enabled); } } } private bool IsUnderRoof() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) if (isUnderRoofMethod == null) { CacheReflection(); if (isUnderRoofMethod == null) { return false; } } bool flag = default(bool); foreach (Behaviour clothComponent in clothComponents) { if ((Object)(object)clothComponent == (Object)null) { continue; } Vector3 val = ((Component)clothComponent).transform.position; Renderer component = ((Component)clothComponent).GetComponent<Renderer>(); if ((Object)(object)component != (Object)null) { Bounds bounds = component.bounds; val = ((Bounds)(ref bounds)).center; } try { object obj = isUnderRoofMethod.Invoke(null, new object[1] { val }); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } if (((uint)num & (flag ? 1u : 0u)) != 0) { return true; } } catch { return false; } } return false; } private void SetClothSimulation(bool underRoof) { for (int i = 0; i < clothComponents.Count; i++) { Behaviour val = clothComponents[i]; if (!((Object)(object)val == (Object)null) && i < originalEnabledStates.Count) { bool flag = originalEnabledStates[i]; val.enabled = !underRoof && flag; } } } private void RestoreOriginalClothState() { for (int i = 0; i < clothComponents.Count && i < originalEnabledStates.Count; i++) { Behaviour val = clothComponents[i]; if ((Object)(object)val != (Object)null) { val.enabled = originalEnabledStates[i]; } } } } public class BannerRegistration { public string PrefabName; public string DisplayName; public RequirementConfig[] Requirements; public string Description; public string Category; public int Comfort; public BannerRegistration(string prefab, string display, RequirementConfig[] reqs, string desc, string cat, int comfort = 0) { PrefabName = prefab; DisplayName = display; Requirements = reqs; Description = desc; Category = cat; Comfort = comfort; } } public static class BannerRegistrar { private static bool wasAlreadyRegistered = false; private static ConfigEntry<string> BannerCategoryConfig; public static readonly List<BannerRegistration> AllRegistrations = new List<BannerRegistration> { new BannerRegistration("M_Eikthyr_Banner", "Moonforged Eikthyr Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Wood", 10, 0, true), new RequirementConfig("Raspberry", 4, 0, true), new RequirementConfig("LeatherScraps", 5, 0, true) }, "", "banner"), new BannerRegistration("M_TheElder_Banner", "Moonforged Elder Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("RoundLog", 5, 0, true), new RequirementConfig("Blueberries", 4, 0, true), new RequirementConfig("TrollHide", 5, 0, true) }, "", "banner"), new BannerRegistration("M_Bonemass_Banner", "Moonforged Bonemass Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("ElderBark", 10, 0, true), new RequirementConfig("Guck", 4, 0, true), new RequirementConfig("DeerHide", 5, 0, true) }, "", "banner"), new BannerRegistration("M_Moder_Banner", "Moonforged Moder Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("FineWood", 10, 0, true), new RequirementConfig("FreezeGland", 4, 0, true), new RequirementConfig("WolfPelt", 5, 0, true) }, "", "banner"), new BannerRegistration("M_Yagluth_Banner", "Moonforged Yagluth Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("FineWood", 10, 0, true), new RequirementConfig("Cloudberry", 4, 0, true), new RequirementConfig("LoxPelt", 5, 0, true) }, "", "banner"), new BannerRegistration("M_TheQueen_Banner", "Moonforged Queen Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("YggdrasilWood", 5, 0, true), new RequirementConfig("MushroomMagecap", 4, 0, true), new RequirementConfig("ScaleHide", 5, 0, true) }, "", "banner"), new BannerRegistration("M_Fader_Banner", "Moonforged Fader Banner", (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("Blackwood", 10, 0, true), new RequirementConfig("CharredBone", 4, 0, true), new RequirementConfig("Fiddleheadfern", 5, 0, true), new RequirementConfig("AskHide", 5, 0, true) }, "", "banner"), new BannerRegistration("M_KallFimbulbringer_Banner", "Moonforged Kall Fimbulbringer Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Frostwood", 10, 0, true), new RequirementConfig("Ice", 10, 0, true), new RequirementConfig("MooseHide", 5, 0, true) }, "", "banner"), new BannerRegistration("M_Haldor_Banner", "Moonforged Haldor Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Wood", 4, 0, true), new RequirementConfig("Raspberry", 4, 0, true), new RequirementConfig("DeerHide", 4, 0, true) }, "", "banner"), new BannerRegistration("M_Hildir_Banner", "Moonforged Hildir Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("FineWood", 4, 0, true), new RequirementConfig("Cloudberry", 4, 0, true), new RequirementConfig("LoxPelt", 4, 0, true) }, "", "banner"), new BannerRegistration("M_BogWitch_Banner", "Moonforged Bog Witch Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("ElderBark", 4, 0, true), new RequirementConfig("MushroomYellow", 4, 0, true), new RequirementConfig("TrophyDraugr", 4, 0, true) }, "", "banner"), new BannerRegistration("M_Brennan_Banner", "Moonforged Brenna Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("RoundLog", 4, 0, true), new RequirementConfig("TrophySkeleton", 4, 0, true), new RequirementConfig("TrollHide", 4, 0, true) }, "", "banner"), new BannerRegistration("M_Geirrhafa_Banner", "Moonforged Geirrhafa Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("FineWood", 4, 0, true), new RequirementConfig("WolfFang", 4, 0, true), new RequirementConfig("TrophyHatchling", 2, 0, true) }, "", "banner"), new BannerRegistration("M_ZilThungr_Banner", "Moonforged Zil & Thungr Banner", (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("FineWood", 4, 0, true), new RequirementConfig("TrophyGoblin", 1, 0, true), new RequirementConfig("TrophyGoblinBrute", 1, 0, true), new RequirementConfig("LoxPelt", 5, 0, true) }, "", "banner"), new BannerRegistration("M_Meadows", "Moonforged Meadows Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Wood", 10, 0, true), new RequirementConfig("Raspberry", 4, 0, true), new RequirementConfig("LeatherScraps", 5, 0, true) }, "", "banner"), new BannerRegistration("M_BlackForest", "Moonforged Black Forest Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("RoundLog", 5, 0, true), new RequirementConfig("Blueberries", 4, 0, true), new RequirementConfig("TrollHide", 5, 0, true) }, "", "banner"), new BannerRegistration("M_Swamp", "Moonforged Swamp Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("ElderBark", 10, 0, true), new RequirementConfig("Guck", 4, 0, true), new RequirementConfig("DeerHide", 5, 0, true) }, "", "banner"), new BannerRegistration("M_Mountains", "Moonforged Mountains Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("FineWood", 10, 0, true), new RequirementConfig("FreezeGland", 4, 0, true), new RequirementConfig("WolfPelt", 5, 0, true) }, "", "banner"), new BannerRegistration("M_Plains", "Moonforged Plains Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("FineWood", 10, 0, true), new RequirementConfig("Cloudberry", 4, 0, true), new RequirementConfig("LoxPelt", 5, 0, true) }, "", "banner"), new BannerRegistration("M_Mistlands", "Moonforged Mistlands Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("YggdrasilWood", 5, 0, true), new RequirementConfig("MushroomMagecap", 4, 0, true), new RequirementConfig("ScaleHide", 5, 0, true) }, "", "banner"), new BannerRegistration("M_Ashlands", "Moonforged Ashlands Banner", (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("Blackwood", 10, 0, true), new RequirementConfig("CharredBone", 4, 0, true), new RequirementConfig("Fiddleheadfern", 5, 0, true), new RequirementConfig("AskHide", 5, 0, true) }, "", "banner"), new BannerRegistration("M_DeepNorth", "Moonforged Deepnorth Banner", (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Frostwood", 10, 0, true), new RequirementConfig("Ice", 10, 0, true), new RequirementConfig("MooseHide", 5, 0, true) }, "", "banner") }; public static void InitConfig(ConfigFile cfg) { BannerCategoryConfig = BannerConfigManager.AddEntry(cfg, "Categories", "BannerCategory", "Moonforged Banner Collection", "Hammer category name for all Moonforged banners."); } private static string CategoryToTab(string category) { string text = category.ToLower(); if (1 == 0) { } string result = ((!(text == "banner")) ? category : ((BannerCategoryConfig != null) ? BannerCategoryConfig.Value : "Moonforged Banner Collection")); if (1 == 0) { } return result; } public static void RegisterAllBanners(AssetBundle bundle) { if (wasAlreadyRegistered) { return; } foreach (BannerRegistration allRegistration in AllRegistrations) { RegisterBanner(bundle, allRegistration); } wasAlreadyRegistered = true; } private static void RegisterBanner(AssetBundle bundle, BannerRegistration reg) { //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Expected O, but got Unknown //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Expected O, but got Unknown if ((Object)(object)bundle == (Object)null) { return; } GameObject val = bundle.LoadAsset<GameObject>(reg.PrefabName); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("[Moonforged Banner Collection] Missing prefab in AssetBundle: " + reg.PrefabName)); return; } ((Object)val).name = reg.PrefabName; ZNetView val2 = val.GetComponent<ZNetView>() ?? val.AddComponent<ZNetView>(); val2.m_persistent = true; val2.m_syncInitialScale = true; if (!Object.op_Implicit((Object)(object)val.GetComponent<ZSyncTransform>())) { val.AddComponent<ZSyncTransform>(); } if (!Object.op_Implicit((Object)(object)val.GetComponent<BannerIndoorClothStopper>())) { val.AddComponent<BannerIndoorClothStopper>(); } Piece val3 = val.GetComponent<Piece>() ?? val.AddComponent<Piece>(); val3.m_name = reg.DisplayName; val3.m_description = reg.Description; val3.m_groundOnly = false; ZNetScene instance = ZNetScene.instance; GameObject val4 = ((instance != null) ? instance.GetPrefab("vfx_Place_wood") : null); ZNetScene instance2 = ZNetScene.instance; GameObject val5 = ((instance2 != null) ? instance2.GetPrefab("sfx_build_hammer_wood") : null); ZNetScene instance3 = ZNetScene.instance; GameObject val6 = ((instance3 != null) ? instance3.GetPrefab("vfx_destroyed") : null); ZNetScene instance4 = ZNetScene.instance; GameObject val7 = ((instance4 != null) ? instance4.GetPrefab("sfx_wood_break") : null); EffectList val8 = new EffectList(); List<EffectData> list = new List<EffectData>(); if ((Object)(object)val4 != (Object)null) { list.Add(new EffectData { m_prefab = val4 }); } if ((Object)(object)val5 != (Object)null) { list.Add(new EffectData { m_prefab = val5 }); } val8.m_effectPrefabs = list.ToArray(); val3.m_placeEffect = val8; WearNTear val9 = val.GetComponent<WearNTear>() ?? val.AddComponent<WearNTear>(); val9.m_health = 1000f; val9.m_noRoofWear = true; EffectList val10 = new EffectList(); List<EffectData> list2 = new List<EffectData>(); if ((Object)(object)val6 != (Object)null) { list2.Add(new EffectData { m_prefab = val6 }); } if ((Object)(object)val7 != (Object)null) { list2.Add(new EffectData { m_prefab = val7 }); } val10.m_effectPrefabs = list2.ToArray(); val9.m_destroyedEffect = val10; if (reg.Comfort > 0) { val3.m_comfort = reg.Comfort; } Sprite val11 = bundle.LoadAsset<Sprite>(reg.PrefabName); if ((Object)(object)val11 != (Object)null) { val3.m_icon = val11; } string craftingStation = (reg.Requirements.Any((RequirementConfig r) => r.Item.ToLower() == "iron") ? "forge" : "piece_workbench"); PieceConfig val12 = new PieceConfig { PieceTable = PieceTables.Hammer, Category = CategoryToTab(reg.Category), CraftingStation = craftingStation, Requirements = reg.Requirements }; PieceManager.Instance.AddPiece(new CustomPiece(val, true, val12)); } } [BepInPlugin("Moonforged.BannerCollection", "Moonforged Banner Collection", "1.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class MoonforgedBannerCollection : BaseUnityPlugin { public const string PluginGUID = "Moonforged.BannerCollection"; public const string PluginName = "Moonforged Banner Collection"; public const string PluginVersion = "1.0.2"; private const string BundleResourcePath = "Moonforged.BannerCollection.mb_windows"; private AssetBundle bannersBundle; private void Awake() { BannerConfigManager.Init("Moonforged.BannerCollection", ((BaseUnityPlugin)this).Config); bannersBundle = EmbeddedAssetBundleLoader.LoadBundle("Moonforged.BannerCollection.mb_windows"); if ((Object)(object)bannersBundle == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load embedded AssetBundle: Moonforged.BannerCollection.mb_windows"); return; } BannerRegistrar.InitConfig(((BaseUnityPlugin)this).Config); PrefabManager.OnPrefabsRegistered += OnPrefabsRegistered; } private void OnDestroy() { PrefabManager.OnPrefabsRegistered -= OnPrefabsRegistered; } private void OnPrefabsRegistered() { ((MonoBehaviour)this).StartCoroutine(DelayedRegister(bannersBundle)); } private IEnumerator DelayedRegister(AssetBundle bundle) { while ((Object)(object)ZNetScene.instance == (Object)null) { yield return null; } BannerRegistrar.RegisterAllBanners(bundle); } } public static class EmbeddedAssetBundleLoader { public static AssetBundle LoadBundle(string resourcePath) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); using Stream stream = executingAssembly.GetManifestResourceStream(resourcePath); if (stream == null) { Debug.LogError((object)("AssetBundle resource not found: " + resourcePath)); return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return AssetBundle.LoadFromMemory(memoryStream.ToArray()); } }