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 No Glow Expanded v1.1.1
plugins/NoGlowExpanded.dll
Decompiled a day agousing System; 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 System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; [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("NoGlowExpanded")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.1.0")] [assembly: AssemblyInformationalVersion("1.1.1+6c4239ba82069ae72729030d7ed73adc9f6e3ec0")] [assembly: AssemblyProduct("NoGlowExpanded")] [assembly: AssemblyTitle("NoGlowExpanded")] [assembly: AssemblyVersion("1.1.1.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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; } } [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; } } } internal static class PluginInfo { public const string PluginGUID = "NoGlowExpanded"; public const string PluginName = "No Glow Expanded"; public const string VanillaGearGUID = "NoGlowExpanded.VanillaGear"; public const string PluginSemanticVersion = "1.1.1"; } namespace Pechyvo.NoGlowExpanded { [BepInPlugin("NoGlowExpanded", "No Glow Expanded - Global Settings", "1.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { private static readonly Harmony _harmony = new Harmony("NoGlowExpanded"); private static bool _isInitialized = false; public void Awake() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)SystemInfo.graphicsDeviceType != 4 && !_isInitialized) { _isInitialized = true; _harmony.PatchAll(); NoGlowExpanded.Bind(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger); PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailable; } } public void OnDestroy() { if (_isInitialized) { _isInitialized = false; PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailable; NoGlowExpanded.Shutdown(); _harmony.UnpatchSelf(); } } private void Update() { if (NoGlowExpanded.VerboseLoggingEnabled) { EffectAudit.Tick(); } } private static void OnVanillaPrefabsAvailable() { NoGlowExpanded.Apply(); } } internal static class NoGlowExpanded { private enum DiagnosticLevel { Off, Basic, Verbose } [Flags] private enum EffectChoice { UseDefaults = 0, SuppressLight = 1, SuppressParticles = 2, SuppressBoth = 3, SuppressMaterialGlow = 4, SuppressLightAndGlow = 5, SuppressParticlesAndGlow = 6, SuppressAll = 7, KeepOriginalEffects = 8, MuteIdleSound = 0x10 } internal sealed class ConfigurationManagerAttributes { public bool? IsAdvanced; public string? DispName; public string? Category; public int? Order; public Action<ConfigEntryBase>? CustomDrawer; } private enum EffectOrder { RefinementGlow = 1, IdleSound, MaterialGlow, Particles, WorldLight } internal enum ArmoryRegistration { Added, AlreadyRegistered, NoSupportedEffects } [HarmonyPatch(typeof(ZNetView), "Awake")] private static class ApplyVisualsToSpawnedWorldObject { private static bool Prepare() { return AccessTools.Method(typeof(ZNetView), "Awake", (Type[])null, (Type[])null) != null; } private static void Postfix(ZNetView __instance) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!_prefabsReady) { return; } Scene scene = ((Component)__instance).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { ApplyWorldEffects(((Component)__instance).gameObject); ConfigEntry<bool>? hideForgeGlow = _hideForgeGlow; if ((hideForgeGlow != null && hideForgeGlow.Value) || ForgeGlowPrefabHashes.Count > 0) { ApplyDroppedForgeGlow(((Component)__instance).gameObject); } } } } [HarmonyPatch(typeof(VisEquipment), "AttachItem")] private static class HideHeldForgeGlow { private static void Postfix(int itemHash, GameObject __result) { ApplyEquippedForgeGlow(itemHash, __result); } } [HarmonyPatch(typeof(VisEquipment), "AttachArmor")] private static class HideWornForgeGlow { private static void Postfix(int itemHash, List<GameObject> __result) { if (__result == null) { return; } foreach (GameObject item in __result) { ApplyEquippedForgeGlow(itemHash, item); } } } private static ConfigEntry<string> _lights = null; private static ConfigEntry<string> _particles = null; private static ConfigEntry<string> _emission = null; private static ConfigEntry<bool> _defaultLights = null; private static ConfigEntry<bool> _defaultParticles = null; private static ConfigEntry<bool> _defaultEmission = null; private static ConfigEntry<DiagnosticLevel>? _loggingLevel; private static readonly Dictionary<Renderer, Material[]> OriginalMaterials = new Dictionary<Renderer, Material[]>(); private static readonly Dictionary<Material, Material> MutedMaterials = new Dictionary<Material, Material>(); private static bool _prefabsReady; private static bool _vanillaGearBound; private static readonly Dictionary<string, ConfigEntry<EffectChoice>> GearChoices = new Dictionary<string, ConfigEntry<EffectChoice>>(); private static readonly Dictionary<string, (bool Light, bool Particles, bool IdleSound)> ArmoryEffects = new Dictionary<string, (bool, bool, bool)>(StringComparer.Ordinal); private static readonly HashSet<string> DiscoveredArmoryGear = new HashSet<string>(StringComparer.Ordinal); private const string DualDyrnwynPrefab = "VADual_SwordDyrnwyn"; private const string DyrnwynBladeMaterial = "Dyrnwyn_mat"; private static ManualLogSource _logger = null; private static readonly HashSet<Light> DisabledLights = new HashSet<Light>(); private static readonly HashSet<Behaviour> DisabledLightControllers = new HashSet<Behaviour>(); private static readonly HashSet<ParticleSystem> DisabledParticleLights = new HashSet<ParticleSystem>(); private static readonly HashSet<ParticleSystemRenderer> DisabledParticles = new HashSet<ParticleSystemRenderer>(); private const string DyrnwynPrefab = "SwordDyrnwyn"; private const string LegacyDyrnwynPrefab = "SwordIronFire"; private static readonly Dictionary<string, string> EmissionRenderers = new Dictionary<string, string>(StringComparer.Ordinal) { ["SwordDyrnwyn"] = "default", ["StaffFireball"] = "default (1)", ["StaffIceShards"] = "default (1)", ["StaffShield"] = "default", ["StaffSkeleton"] = "fi_vil_combs_props_bone_skull", ["BattleaxeCrystal"] = "default", ["MeadFrostResist"] = "default", ["MeadEitrMinor"] = "potion", ["MeadStaminaLingering"] = "potion", ["AncientSeed"] = "model", ["DragonEgg"] = "model", ["BattleaxeSkullSplittur"] = "battleaxe" }; private const string GaldrTable = "piece_magetable"; private const string JotunPuffs = "Pickable_Mushroom_JotunPuffs"; private const string Magecap = "Pickable_Mushroom_Magecap"; private const string Thistle = "Pickable_Thistle"; private const string YellowMushroom = "Pickable_Mushroom_yellow"; private const string ArtisanTable = "piece_artisanstation"; private static readonly Dictionary<string, string> WorldEmissionRenderers = new Dictionary<string, string>(StringComparer.Ordinal) { ["Pickable_Mushroom_yellow"] = "visual" }; private static readonly HashSet<string> LightlessGear = new HashSet<string>(StringComparer.Ordinal) { "StaffShield", "BombBile", "BombLava", "BombDynamite", "BombBlob_Frost", "MaceSilver", "CapeFeather", "BloodGoldKey" }; private static readonly (string Prefab, string Key, string Token, string Name, string Category)[] VanillaGear = new(string, string, string, string, string)[66] { ("MeadStaminaMinor", "MeadStaminaMinor", "$item_mead_stamina_minor", "Minor Stamina Mead", "Meadows - Consumables"), ("Pickable_Mushroom_yellow", "Pickable_Mushroom_yellow", "$item_mushroomyellow", "Yellow Mushroom", "Black Forest - Consumables"), ("MeadPoisonResist", "MeadPoisonResist", "$item_mead_poisonres", "Poison Resistance Mead", "Black Forest - Consumables"), ("Pickable_Thistle", "Pickable_Thistle", "$item_thistle", "Thistle", "Black Forest - Ingredients"), ("AncientSeed", "AncientSeed", "$item_ancientseed", "Ancient Seed", "Black Forest - Items"), ("SurtlingCore", "SurtlingCore", "$item_surtlingcore", "Surtling Core", "Black Forest - Items"), ("CryptKey", "CryptKey", "$item_cryptkey", "Swamp Key", "Swamp - Items"), ("MeadFrostResist", "MeadFrostResist", "$item_mead_frostres", "Frost Resistance Mead", "Swamp - Consumables"), ("DragonEgg", "DragonEgg", "$item_dragonegg", "Dragon Egg", "Mountains - Items"), ("DragonTear", "DragonTear", "$item_dragontear", "Dragon Tear", "Mountains - Items"), ("BattleaxeCrystal", "BattleaxeCrystal", "$item_battleaxe_crystal", "Crystal Battleaxe", "Mountains - Weapons"), ("BowDraugrFang", "BowDraugrFang", "$item_bow_draugrfang", "Draugr Fang", "Mountains - Weapons"), ("MaceSilver", "MaceSilver", "$item_mace_silver", "Frostner", "Mountains - Weapons"), ("BombBlob_Frost", "BombBlob_Frost", "$item_bombblob_frost", "Blob Bomb: Frost", "Mountains - Weapons"), ("piece_artisanstation", "piece_artisanstation", "$piece_artisanstation", "Artisan Table", "Plains - Structures"), ("MeadStaminaMedium", "MeadStaminaMedium", "$item_mead_stamina_medium", "Medium Stamina Mead", "Plains - Consumables"), ("MaceNeedle", "MaceNeedle", "$item_mace_needle", "Porcupine", "Plains - Weapons"), ("piece_magetable", "piece_magetable", "$piece_magetable", "Galdr Table", "Mistlands - Structures"), ("Pickable_Mushroom_JotunPuffs", "Pickable_Mushroom_JotunPuffs", "$item_mushroom_jotunpuffs", "Jotun Puffs", "Mistlands - Consumables"), ("Pickable_Mushroom_Magecap", "Pickable_Mushroom_Magecap", "$item_mushroom_magecap", "Magecap", "Mistlands - Consumables"), ("AtgeirHimminAfl", "AtgeirHimminAfl", "$item_atgeir_himminafl", "Himminafl", "Mistlands - Weapons"), ("BattleaxeSkullSplittur", "BattleaxeSkullSplittur", "$item_battleaxe_skullsplittur", "Skull Splittur", "Mistlands - Weapons"), ("AxeJotunBane", "AxeJotunBane", "$item_axe_jotunbane", "Jotun Bane", "Mistlands - Weapons"), ("BowSpineSnap", "BowSpineSnap", "$item_bow_snipesnap", "Spinesnap", "Mistlands - Weapons"), ("SwordMistwalker", "SwordMistwalker", "$item_sword_mistwalker", "Mistwalker", "Mistlands - Weapons"), ("BombBile", "BombBile", "$item_bilebomb", "Bile Bomb", "Mistlands - Weapons"), ("StaffSkeleton", "StaffSkeleton", "$item_staffskeleton", "Dead Raiser", "Mistlands - Staves"), ("StaffFireball", "StaffFireball", "$item_stafffireball", "Staff of Embers", "Mistlands - Staves"), ("StaffIceShards", "StaffIceShards", "$item_stafficeshards", "Staff of Frost", "Mistlands - Staves"), ("StaffShield", "StaffShield", "$item_staffshield", "Staff of Protection", "Mistlands - Staves"), ("CapeFeather", "CapeFeather", "$item_cape_feather", "Feather Cape", "Mistlands - Armor"), ("MeadEitrMinor", "MeadEitrMinor", "$item_mead_eitr_minor", "Minor Eitr Mead", "Mistlands - Consumables"), ("MeadStaminaLingering", "MeadStaminaLingering", "$item_mead_stamina_lingering", "Lingering Stamina Mead", "Mistlands - Consumables"), ("MeadEitrLingering", "MeadEitrLingering", "$item_mead_eitr_lingering", "Lingering Eitr Mead", "Ashlands - Consumables"), ("SwordDyrnwyn", "SwordDyrnwyn", "$item_sword_dyrnwyn", "Dyrnwyn", "Ashlands - Weapons"), ("BombDynamite", "BombDynamite", "$item_bomb_dynamite", "Ember Charge", "Ashlands - Weapons"), ("BombLava", "BombLava", "$item_lavabomb", "Basalt Bomb", "Ashlands - Weapons"), ("StaffLightning", "StaffLightning", "$item_staff_lightning", "Dundr", "Ashlands - Staves"), ("StaffRedTroll", "StaffRedTroll", "$item_staffredtroll", "Trollstav", "Ashlands - Staves"), ("StaffGreenRoots", "StaffGreenRoots", "$item_staffgreenroots", "Staff of the Wild", "Ashlands - Staves"), ("AxeBerzerkrBlood", "AxeBerzerkrBlood", "$item_axe_berzerkr_blood", "Bleeding Berserkir Axes", "Ashlands - Blood"), ("AxeBerzerkrLightning", "AxeBerzerkrLightning", "$item_axe_berzerkr_lightning", "Thundering Berserkir Axes", "Ashlands - Lightning"), ("AxeBerzerkrNature", "AxeBerzerkrNature", "$item_axe_berzerkr_nature", "Primal Berserkir Axes", "Ashlands - Nature"), ("BowAshlandsBlood", "BowAshlandsBlood", "$item_bow_ashlandsblood", "Blood Fang", "Ashlands - Blood"), ("BowAshlandsStorm", "BowAshlandsStorm", "$item_bow_ashlandsstorm", "Storm Fang", "Ashlands - Lightning"), ("BowAshlandsRoot", "BowAshlandsRoot", "$item_bow_ashlandsroot", "Root Fang", "Ashlands - Nature"), ("CrossbowRipperBlood", "CrossbowRipperBlood", "$item_crossbow_ripper_blood", "Wound Ripper", "Ashlands - Blood"), ("CrossbowRipperLightning", "CrossbowRipperLightning", "$item_crossbow_ripper_lightning", "Storm Ripper", "Ashlands - Lightning"), ("CrossbowRipperNature", "CrossbowRipperNature", "$item_crossbow_ripper_nature", "Root Ripper", "Ashlands - Nature"), ("MaceEldnerBlood", "MaceEldnerBlood", "$item_mace_eldner_blood", "Bloodgeon", "Ashlands - Blood"), ("MaceEldnerLightning", "MaceEldnerLightning", "$item_mace_eldner_lightning", "Storm Star", "Ashlands - Lightning"), ("MaceEldnerNature", "MaceEldnerNature", "$item_mace_eldner_nature", "Klossen", "Ashlands - Nature"), ("SpearSplitner_Blood", "SpearSplitner_Blood", "$item_spear_splitner_blood", "Splitnir the Bleeding", "Ashlands - Blood"), ("SpearSplitner_Lightning", "SpearSplitner_Lightning", "$item_spear_splitner_lightning", "Splitnir the Storming", "Ashlands - Lightning"), ("SpearSplitner_Nature", "SpearSplitner_Nature", "$item_spear_splitner_nature", "Splitnir the Primal", "Ashlands - Nature"), ("SwordNiedhoggBlood", "SwordNiedhoggBlood", "$item_sword_niedhogg_blood", "Nidhögg the Bleeding", "Ashlands - Blood"), ("SwordNiedhoggLightning", "SwordNiedhoggLightning", "$item_sword_niedhogg_lightning", "Nidhögg the Thundering", "Ashlands - Lightning"), ("SwordNiedhoggNature", "SwordNiedhoggNature", "$item_sword_niedhogg_nature", "Nidhögg the Primal", "Ashlands - Nature"), ("THSwordSlayerBlood", "THSwordSlayerBlood", "$item_sword_slayer_blood", "Brutal Slayer", "Ashlands - Blood"), ("THSwordSlayerLightning", "THSwordSlayerLightning", "$item_sword_slayer_lightning", "Scourging Slayer", "Ashlands - Lightning"), ("THSwordSlayerNature", "THSwordSlayerNature", "$item_sword_slayer_nature", "Primal Slayer", "Ashlands - Nature"), ("BloodGoldKey", "BloodGoldKey", "$item_bloodgoldkey", "Intricate Key", "Deep North - Items"), ("StaffFrostOrbs", "Frost Orbs Staff", "$item_staff_frostorbs", "Northern Vengeance", "Deep North - Staves"), ("StaffSpiritCaller", "Spirit Caller", "$item_staff_spiritcaller", "Spirit Caller", "Deep North - Staves"), ("SwordGold_BloodLightning", "BloodLightning Sword", "$item_sword_gold_bloodlightning", "Thunderblood Sword", "Deep North - Thunderblood"), ("SwordGold_FrostFire", "FrostFire Sword", "$item_sword_gold_frostfire", "Frostfire Sword", "Deep North - Frostfire") }; private static readonly (string Family, string Name, string Token, bool FrostfireGoldSuffix, bool ThunderbloodGoldSuffix)[] DeepNorthVariants = new(string, string, string, bool, bool)[11] { ("Atgeir", "Atgeir", "atgeir", false, false), ("Axe", "Axe", "axe", false, false), ("Battleaxe", "Greataxe", "axe2h", false, false), ("Bow", "Bow", "bow", false, false), ("Crossbow", "Crossbow", "crossbow", true, true), ("Fist", "Knucklechains", "fistweapon", true, false), ("Knife", "Dagger", "knife", false, false), ("Mace", "Mace", "mace", false, false), ("Sledge", "Sledge", "mace2h", false, false), ("Spear", "Spear", "spear", false, false), ("THSword", "Greatsword", "sword2h", false, false) }; private const string MuteIdleSoundLabel = "Mute idle sound"; private static ConfigEntry<bool> _defaultMuteIdleSound = null; private static ConfigEntry<string> _idleSoundPrefabs = null; private static readonly HashSet<AudioSource> MutedIdleAudio = new HashSet<AudioSource>(); private static ConfigEntry<bool>? _hideForgeGlow; private static ConfigEntry<string> _forgeGlowPrefabs = null; private const string ForgeGlowName = "UpgraderGlow"; private const string ForgeGlowKey = "Hide Forge of Potential glow"; private static readonly HashSet<GameObject> HiddenForgeGlows = new HashSet<GameObject>(); private static readonly Dictionary<GameObject, int> SelectedForgeGear = new Dictionary<GameObject, int>(); private static readonly HashSet<int> ForgeGlowPrefabHashes = new HashSet<int>(); internal static bool BasicLoggingEnabled { get { DiagnosticLevel? diagnosticLevel = _loggingLevel?.Value; if (diagnosticLevel.HasValue) { DiagnosticLevel valueOrDefault = diagnosticLevel.GetValueOrDefault(); if ((uint)(valueOrDefault - 1) <= 1u) { return true; } } return false; } } internal static bool VerboseLoggingEnabled { get { ConfigEntry<DiagnosticLevel>? loggingLevel = _loggingLevel; if (loggingLevel == null) { return false; } return loggingLevel.Value == DiagnosticLevel.Verbose; } } private static bool HasParticleControl(string prefab) { if (ArmoryEffects.TryGetValue(prefab, out (bool, bool, bool) value)) { return value.Item2; } bool flag = prefab != "MaceNeedle" && prefab != "Pickable_Mushroom_JotunPuffs"; if (flag) { bool flag2; switch (prefab) { case "AncientSeed": case "DragonEgg": case "SurtlingCore": case "BattleaxeSkullSplittur": flag2 = true; break; default: flag2 = false; break; } flag = !flag2; } return flag && !WorldEmissionRenderers.ContainsKey(prefab) && !prefab.StartsWith("Mead", StringComparison.Ordinal); } private static bool HasLightControl(string prefab) { if (!ArmoryEffects.TryGetValue(prefab, out (bool, bool, bool) value)) { return !LightlessGear.Contains(prefab); } return value.Item1; } private static ConfigEntry<T> BindEffectSetting<T>(ConfigFile config, string section, string key, T defaultValue, string description, EffectOrder order, string? displayName = null) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = (int)order, DispName = displayName } })); } internal static void Bind(ConfigFile config, ManualLogSource logger) { //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Expected O, but got Unknown _logger = logger; ConfigMigration.MigrateGlobalSettings(config, logger); _defaultLights = BindEffectSetting(config, "Defaults", "Suppress world light", defaultValue: true, "Turn off light cast onto nearby surfaces for gear set to Use defaults.", EffectOrder.WorldLight); _defaultParticles = BindEffectSetting(config, "Defaults", "Hide particles", defaultValue: true, "Hide attached particle visuals for gear set to Use defaults.", EffectOrder.Particles); _defaultEmission = BindEffectSetting(config, "Defaults", "Suppress material glow", defaultValue: true, "Suppress verified emissive materials for gear set to Use defaults.", EffectOrder.MaterialGlow); _hideForgeGlow = BindEffectSetting(config, "Defaults", "Hide Forge of Potential glow", defaultValue: false, "Hide the glow added by Forge of Potential refinement. This setting applies independently of each item's effect settings.", EffectOrder.RefinementGlow, "Hide refinement glow"); _hideForgeGlow.SettingChanged += delegate { RefreshForgeGlow(); }; _lights = BindEffectSetting(config, "Custom Prefabs", "Suppress world light", "", "Comma-separated prefab IDs. Turns off light cast onto nearby surfaces. Dedicated settings take precedence. Re-equip to apply.", EffectOrder.WorldLight); _particles = BindEffectSetting(config, "Custom Prefabs", "Hide particles", "", "Comma-separated prefab IDs. Hides attached sparks, smoke, and similar particles. Dedicated settings take precedence. Re-equip to apply.", EffectOrder.Particles); _emission = BindEffectSetting(config, "Custom Prefabs", "Suppress material glow", "", "Comma-separated prefab IDs. Dims supported glowing surfaces, such as runes or blades. Dedicated settings take precedence. Re-equip to apply.", EffectOrder.MaterialGlow); _defaultLights.SettingChanged += OnSettingChanged; _defaultParticles.SettingChanged += OnSettingChanged; _defaultEmission.SettingChanged += OnSettingChanged; _lights.SettingChanged += OnSettingChanged; _particles.SettingChanged += OnSettingChanged; _emission.SettingChanged += OnSettingChanged; _forgeGlowPrefabs = BindEffectSetting(config, "Custom Prefabs", "Hide Forge of Potential glow", "", "Comma-separated prefab IDs. Hide Forge of Potential refinement glow even when the global toggle is off. Re-equip to apply to held gear.", EffectOrder.RefinementGlow, "Hide refinement glow"); BindAudioSettings(config); ReadForgeGlowPrefabs(); _forgeGlowPrefabs.SettingChanged += delegate { ReadForgeGlowPrefabs(); RefreshForgeGlow(); }; _loggingLevel = config.Bind<DiagnosticLevel>("Debug", "Logging level", DiagnosticLevel.Off, new ConfigDescription("Off hides diagnostics. Basic shows registration totals. Verbose adds per-item effect counts and skip reasons. Warnings and errors are always logged.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { IsAdvanced = true, Order = 100 } })); EffectAudit.Bind(config, logger); } internal static ArmoryRegistration RegisterArmoryGear(ConfigFile config, string prefab, GameObject root, string token, string fallbackName, string category, string weaponType) { if (GearChoices.ContainsKey(prefab)) { return ArmoryRegistration.AlreadyRegistered; } bool flag = Array.Exists(root.GetComponentsInChildren<Light>(true), (Light component) => IsAttachedGearEffect((Component)(object)component, root)) || Array.Exists(root.GetComponentsInChildren<ParticleSystem>(true), delegate(ParticleSystem component) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) LightsModule lights = component.lights; return ((LightsModule)(ref lights)).enabled && IsAttachedGearEffect((Component)(object)component, root); }); bool flag2 = Array.Exists(root.GetComponentsInChildren<ParticleSystemRenderer>(true), (ParticleSystemRenderer component) => IsAttachedGearEffect((Component)(object)component, root)); bool flag3 = Array.Exists(root.GetComponentsInChildren<AudioSource>(true), (AudioSource source) => IsIdleAudio(source, root)); if (!flag && !flag2 && !flag3) { return ArmoryRegistration.NoSupportedEffects; } ArmoryEffects.Add(prefab, (flag, flag2, flag3)); if (category == "Uncategorized") { DiscoveredArmoryGear.Add(prefab); } BindGear(config, prefab, prefab, token, fallbackName, category, weaponType); return ArmoryRegistration.Added; } internal static void RefreshRegisteredGear() { if (_prefabsReady) { Apply(armoryRefresh: true); } } private static void BindGear(ConfigFile config, string prefab, string key, string token, string fallbackName, string category, string? sortFamily = null) { //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown bool open = false; object obj; if (token.Length != 0) { Localization instance = Localization.instance; obj = ((instance != null) ? instance.Localize(token) : null); } else { obj = null; } string text = (string)obj; string dispName = ((string.IsNullOrWhiteSpace(text) || text == token || text.StartsWith("[", StringComparison.Ordinal)) ? fallbackName : text); string text2 = GearSorting.ConfigSection(category); string text3 = (IsWorldObject(prefab) ? "Changes apply to supported loaded world objects immediately." : ("Visual effects for " + prefab + ". Re-equip after changing. Suppress options override Defaults.")); if (DiscoveredArmoryGear.Contains(prefab)) { text3 += " Use defaults respects any matching Custom Prefabs lists first."; } ConfigEntry<EffectChoice> val = config.Bind<EffectChoice>(text2, key, EffectChoice.UseDefaults, new ConfigDescription(text3, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { DispName = dispName, Category = category, Order = GearSorting.WeaponOrder(sortFamily ?? prefab), CustomDrawer = delegate(ConfigEntryBase setting) { DrawGearChoice((ConfigEntry<EffectChoice>)(object)setting, ref open, EmissionRenderers.ContainsKey(prefab) || WorldEmissionRenderers.ContainsKey(prefab) || prefab == "VADual_SwordDyrnwyn", HasLightControl(prefab), HasParticleControl(prefab), HasIdleSoundControl(prefab)); } } })); GearChoices.Add(prefab, val); val.SettingChanged += OnSettingChanged; } private static void DrawGearChoice(ConfigEntry<EffectChoice> entry, ref bool open, bool supportsEmission, bool supportsLight, bool supportsParticles, bool supportsIdleSound) { GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); string text = entry.Value switch { EffectChoice.UseDefaults => "Use defaults", EffectChoice.KeepOriginalEffects => "Keep original effects", _ => "Custom", }; if (GUILayout.Button((open ? "▼ " : "▶ ") + text, Array.Empty<GUILayoutOption>())) { open = !open; } if (open) { if (GUILayout.Button("Use defaults", Array.Empty<GUILayoutOption>())) { entry.Value = EffectChoice.UseDefaults; } if (GUILayout.Button("Keep original effects", Array.Empty<GUILayoutOption>())) { entry.Value = EffectChoice.KeepOriginalEffects; } if ((entry.Value == EffectChoice.UseDefaults || entry.Value == EffectChoice.KeepOriginalEffects) && GUILayout.Button("Customize effects", Array.Empty<GUILayoutOption>())) { EffectChoice effectChoice = (EffectChoice)((supportsEmission ? 4 : 0) | (supportsLight ? 1 : 0) | (supportsParticles ? 2 : 0)); entry.Value = ((effectChoice == EffectChoice.UseDefaults && supportsIdleSound) ? EffectChoice.MuteIdleSound : effectChoice); } if (entry.Value != EffectChoice.UseDefaults && entry.Value != EffectChoice.KeepOriginalEffects) { bool num = supportsLight && GUILayout.Toggle(HasEffect(entry.Value, EffectChoice.SuppressLight), "Suppress world light", Array.Empty<GUILayoutOption>()); bool flag = supportsParticles && GUILayout.Toggle(HasEffect(entry.Value, EffectChoice.SuppressParticles), "Hide particles", Array.Empty<GUILayoutOption>()); bool flag2 = supportsEmission && GUILayout.Toggle(HasEffect(entry.Value, EffectChoice.SuppressMaterialGlow), "Suppress material glow", Array.Empty<GUILayoutOption>()); bool flag3 = supportsIdleSound && GUILayout.Toggle(HasEffect(entry.Value, EffectChoice.MuteIdleSound), "Mute idle sound", Array.Empty<GUILayoutOption>()); EffectChoice effectChoice2 = (EffectChoice)((num ? 1 : 0) | (flag ? 2 : 0) | (flag2 ? 4 : 0) | (flag3 ? 16 : 0)); entry.Value = ((effectChoice2 == EffectChoice.UseDefaults) ? EffectChoice.KeepOriginalEffects : effectChoice2); } } GUILayout.EndVertical(); } private static bool HasEffect(EffectChoice choice, EffectChoice effect) { return (choice & effect) != 0; } private static void OnSettingChanged(object sender, EventArgs args) { if (_prefabsReady) { Apply(); } } internal static void Apply(bool armoryRefresh = false) { //IL_0538: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Unknown result type (might be due to invalid IL or missing references) _prefabsReady = true; if (!_vanillaGearBound) { return; } Restore(); Dictionary<string, GameObject?> resolvedGear = new Dictionary<string, GameObject>(StringComparer.Ordinal); HashSet<string> hashSet = ReadNames(_lights.Value); HashSet<string> hashSet2 = ReadNames(_particles.Value); HashSet<string> hashSet3 = ReadNames(_emission.Value); HashSet<string> hashSet4 = ReadNames(_idleSoundPrefabs.Value); hashSet3.Remove("SwordIronFire"); hashSet.Remove("StaffThunderBlood"); hashSet.Remove("StaffOrbofAhri"); hashSet.Remove("SwordIronFire"); hashSet2.Remove("StaffThunderBlood"); hashSet2.Remove("StaffOrbofAhri"); hashSet2.Remove("SwordIronFire"); foreach (KeyValuePair<string, ConfigEntry<EffectChoice>> gearChoice in GearChoices) { EffectChoice value = gearChoice.Value.Value; if (value == EffectChoice.UseDefaults) { if (_defaultMuteIdleSound.Value && HasIdleSoundControl(gearChoice.Key)) { hashSet4.Add(gearChoice.Key); } } else { hashSet4.Remove(gearChoice.Key); if (HasEffect(value, EffectChoice.MuteIdleSound) && HasIdleSoundControl(gearChoice.Key)) { hashSet4.Add(gearChoice.Key); } } if (value == EffectChoice.UseDefaults && DiscoveredArmoryGear.Contains(gearChoice.Key) && (hashSet.Contains(gearChoice.Key) || hashSet2.Contains(gearChoice.Key) || hashSet3.Contains(gearChoice.Key))) { continue; } hashSet.Remove(gearChoice.Key); hashSet2.Remove(gearChoice.Key); hashSet3.Remove(gearChoice.Key); if (!IsWorldObject(gearChoice.Key)) { if (HasLightControl(gearChoice.Key) && (HasEffect(value, EffectChoice.SuppressLight) || (value == EffectChoice.UseDefaults && _defaultLights.Value))) { hashSet.Add(gearChoice.Key); } if (HasParticleControl(gearChoice.Key) && (HasEffect(value, EffectChoice.SuppressParticles) || (value == EffectChoice.UseDefaults && _defaultParticles.Value))) { hashSet2.Add(gearChoice.Key); } } } if (hashSet.Contains("SwordDyrnwyn")) { hashSet.Add("SwordIronFire"); } if (hashSet2.Contains("SwordDyrnwyn")) { hashSet2.Add("SwordIronFire"); } foreach (string item in hashSet3) { GameObject val = ResolveGear(item); if ((Object)(object)val != (Object)null) { SuppressEmission(val, item, null); } } foreach (KeyValuePair<string, string> emissionRenderer in EmissionRenderers) { EffectChoice value2 = GearChoices[emissionRenderer.Key].Value; if (HasEffect(value2, EffectChoice.SuppressMaterialGlow) || (value2 == EffectChoice.UseDefaults && _defaultEmission.Value)) { SuppressEmission(emissionRenderer.Key, emissionRenderer.Value); if (emissionRenderer.Key == "SwordDyrnwyn") { SuppressEmission("SwordIronFire", "Viking_Sword (1)"); } } } if (GearChoices.TryGetValue("VADual_SwordDyrnwyn", out ConfigEntry<EffectChoice> value3) && (HasEffect(value3.Value, EffectChoice.SuppressMaterialGlow) || (value3.Value == EffectChoice.UseDefaults && _defaultEmission.Value))) { GameObject val2 = ResolveGear("VADual_SwordDyrnwyn"); if ((Object)(object)val2 != (Object)null) { int count = OriginalMaterials.Count; SuppressEmission(val2, "VADual_SwordDyrnwyn", null, "Dyrnwyn_mat"); if (VerboseLoggingEnabled) { _logger.LogInfo((object)$"Dual Dyrnwyn: suppressed material glow on {OriginalMaterials.Count - count} renderer(s)."); } } } foreach (string item2 in hashSet) { GameObject val3 = ResolveGear(item2); if ((Object)(object)val3 == (Object)null) { continue; } int num = 0; LightLod[] componentsInChildren = val3.GetComponentsInChildren<LightLod>(true); foreach (LightLod val4 in componentsInChildren) { if (IsGearEffect(item2, (Component)(object)val4, val3) && DisableLightController((Behaviour)(object)val4)) { num++; } } LightFlicker[] componentsInChildren2 = val3.GetComponentsInChildren<LightFlicker>(true); foreach (LightFlicker val5 in componentsInChildren2) { if (IsGearEffect(item2, (Component)(object)val5, val3) && DisableLightController((Behaviour)(object)val5)) { num++; } } int num2 = 0; Light[] componentsInChildren3 = val3.GetComponentsInChildren<Light>(true); foreach (Light val6 in componentsInChildren3) { if (IsGearEffect(item2, (Component)(object)val6, val3) && ((Behaviour)val6).enabled && DisabledLights.Add(val6)) { ((Behaviour)val6).enabled = false; num2++; } } int num3 = 0; ParticleSystem[] componentsInChildren4 = val3.GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val7 in componentsInChildren4) { if (IsGearEffect(item2, (Component)(object)val7, val3)) { LightsModule lights = val7.lights; if (((LightsModule)(ref lights)).enabled && DisabledParticleLights.Add(val7)) { ((LightsModule)(ref lights)).enabled = false; num3++; } } } if (VerboseLoggingEnabled && (!armoryRefresh || ArmoryEffects.ContainsKey(item2))) { _logger.LogInfo((object)$"'{item2}': disabled {num2} light(s), {num} light controller(s), and {num3} particle light module(s)."); } } foreach (string item3 in hashSet2) { GameObject val8 = ResolveGear(item3); if ((Object)(object)val8 == (Object)null) { continue; } int num4 = 0; ParticleSystemRenderer[] componentsInChildren5 = val8.GetComponentsInChildren<ParticleSystemRenderer>(true); foreach (ParticleSystemRenderer val9 in componentsInChildren5) { if (!IsGearEffect(item3, (Component)(object)val9, val8)) { continue; } bool flag = item3 == "DragonTear"; if (flag) { bool flag2; switch (((Object)val9).name) { case "flare": case "smoke_expl": case "pixel flakes": flag2 = true; break; default: flag2 = false; break; } flag = !flag2; } if (!flag) { flag = ((item3 == "CryptKey" || item3 == "BloodGoldKey") ? true : false); if ((!flag || !((Object)(object)((Component)val9).gameObject == (Object)(object)val8)) && ((Renderer)val9).enabled && DisabledParticles.Add(val9)) { ((Renderer)val9).enabled = false; num4++; } } } if (VerboseLoggingEnabled && (!armoryRefresh || ArmoryEffects.ContainsKey(item3))) { _logger.LogInfo((object)$"'{item3}': hid {num4} particle renderer(s)."); } } foreach (string item4 in hashSet4) { GameObject val10 = ResolveGear(item4); if ((Object)(object)val10 != (Object)null) { MuteIdleAudio(item4, val10, VerboseLoggingEnabled && (!armoryRefresh || ArmoryEffects.ContainsKey(item4))); } } HiddenForgeGlows.RemoveWhere((GameObject glow) => (Object)(object)glow == (Object)null); Transform[] array = Object.FindObjectsByType<Transform>((FindObjectsInactive)1, (FindObjectsSortMode)0); foreach (Transform obj in array) { ApplyWorldEffects(((Component)obj).gameObject); ApplyWorldForgeGlow(obj); } GameObject? ResolveGear(string name) { if (!resolvedGear.TryGetValue(name, out GameObject value4)) { value4 = GetGear(name); resolvedGear.Add(name, value4); } return value4; } } private static string PrefabName(string name) { if (!name.EndsWith("(Clone)", StringComparison.Ordinal)) { return name; } return name.Substring(0, name.Length - 7); } private static void ApplyWorldEffects(GameObject root) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) string text = PrefabName(((Object)root).name); if (text == "MushroomYellow") { text = "Pickable_Mushroom_yellow"; } if (!IsWorldObject(text)) { return; } Scene scene = root.scene; if (!((Scene)(ref scene)).IsValid() || !GearChoices.TryGetValue(text, out ConfigEntry<EffectChoice> value)) { return; } EffectChoice value2 = value.Value; bool flag = HasEffect(value2, EffectChoice.SuppressLight) || (value2 == EffectChoice.UseDefaults && _defaultLights.Value); bool flag2 = HasParticleControl(text) && (HasEffect(value2, EffectChoice.SuppressParticles) || (value2 == EffectChoice.UseDefaults && _defaultParticles.Value)); if (WorldEmissionRenderers.TryGetValue(text, out string value3) && (HasEffect(value2, EffectChoice.SuppressMaterialGlow) || (value2 == EffectChoice.UseDefaults && _defaultEmission.Value))) { SuppressEmission(root, text, value3); } if (!flag && !flag2) { return; } DisabledLights.RemoveWhere((Light light) => (Object)(object)light == (Object)null); DisabledLightControllers.RemoveWhere((Behaviour controller) => (Object)(object)controller == (Object)null); DisabledParticles.RemoveWhere((ParticleSystemRenderer renderer) => (Object)(object)renderer == (Object)null); if (flag) { Light[] componentsInChildren = root.GetComponentsInChildren<Light>(true); foreach (Light val in componentsInChildren) { if (IsWorldEffect((Component)(object)val, root, text, "Point Light")) { LightLod component = ((Component)val).GetComponent<LightLod>(); if ((Object)(object)component != (Object)null) { DisableLightController((Behaviour)(object)component); } LightFlicker component2 = ((Component)val).GetComponent<LightFlicker>(); if ((Object)(object)component2 != (Object)null) { DisableLightController((Behaviour)(object)component2); } if (((Behaviour)val).enabled && DisabledLights.Add(val)) { ((Behaviour)val).enabled = false; } } } } if (!flag2) { return; } ParticleSystemRenderer[] componentsInChildren2 = root.GetComponentsInChildren<ParticleSystemRenderer>(true); foreach (ParticleSystemRenderer val2 in componentsInChildren2) { bool num2; if (!(text == "Pickable_Thistle")) { num2 = IsWorldEffect((Component)(object)val2, root, text, "Particle System"); } else { if (((Object)val2).name.Equals("flare", StringComparison.OrdinalIgnoreCase)) { goto IL_023e; } num2 = ((Object)val2).name.Equals("bees", StringComparison.OrdinalIgnoreCase); } if (!num2) { continue; } goto IL_023e; IL_023e: if (((Renderer)val2).enabled && DisabledParticles.Add(val2)) { ((Renderer)val2).enabled = false; } } } private static bool IsWorldEffect(Component effect, GameObject root, string prefab, string plantTarget) { if (prefab == "piece_artisanstation") { if (!((Object)effect).name.Equals("Point Light", StringComparison.OrdinalIgnoreCase) && !((Object)effect).name.Equals("flare", StringComparison.OrdinalIgnoreCase) && !((Object)effect).name.Equals("smoke_expl", StringComparison.OrdinalIgnoreCase) && !((Object)effect).name.Equals("pixel flakes", StringComparison.OrdinalIgnoreCase)) { return false; } } else if (prefab != "piece_magetable") { return ((Object)effect).name.Equals(plantTarget, StringComparison.OrdinalIgnoreCase); } string value = ((prefab == "piece_artisanstation") ? "Tear" : "Effects"); Transform val = effect.transform; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root.transform) { if (((Object)val).name.Equals(value, StringComparison.OrdinalIgnoreCase)) { return true; } val = val.parent; } return false; } private static void SuppressEmission(string prefabName, string rendererName) { GameObject prefab = PrefabManager.Instance.GetPrefab(prefabName); if ((Object)(object)prefab != (Object)null) { SuppressEmission(prefab, prefabName, rendererName); } } private static void SuppressEmission(GameObject prefab, string prefabName, string? rendererName, string? materialName = null) { //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if ((rendererName != null && !((Object)val).name.Equals(rendererName, StringComparison.OrdinalIgnoreCase)) || (rendererName == null && (val is ParticleSystemRenderer || IsPickupOrUpgradeEffect((Component)(object)val, prefab))) || (materialName != null && !IsAttachedGearEffect((Component)(object)val, prefab)) || OriginalMaterials.ContainsKey(val)) { continue; } Material[] sharedMaterials = val.sharedMaterials; Material[] array = null; for (int j = 0; j < sharedMaterials.Length; j++) { Material val2 = sharedMaterials[j]; if ((Object)(object)val2 == (Object)null || (materialName != null && !((Object)val2).name.Equals(materialName, StringComparison.OrdinalIgnoreCase) && !((Object)val2).name.Equals(materialName + " (Instance)", StringComparison.OrdinalIgnoreCase))) { continue; } bool num = val2.IsKeywordEnabled("_EMISSION"); bool flag = prefabName == "StaffSkeleton" && ((Object)val2).name.StartsWith("SkeletonItem_mat", StringComparison.Ordinal) && val2.HasProperty("_EmissionColor"); bool flag2 = prefabName == "BattleaxeSkullSplittur" && ((Object)val2).name.StartsWith("battleaxe_mistlands_mat", StringComparison.Ordinal) && val2.HasProperty("_EmissionColor"); int num2; if (rendererName == null && (Object)(object)val2.shader != (Object)null && ((Object)val2.shader).name == "Custom/Creature" && val2.HasProperty("_EmissionColor")) { Color color = val2.GetColor("_EmissionColor"); num2 = ((((Color)(ref color)).maxColorComponent > 0f) ? 1 : 0); } else { num2 = 0; } bool flag3 = (byte)num2 != 0; if (!num && !flag && !flag2 && !flag3 && (materialName == null || !val2.HasProperty("_EmissionColor"))) { continue; } if (!MutedMaterials.TryGetValue(val2, out Material value)) { value = new Material(val2); value.DisableKeyword("_EMISSION"); if (value.HasProperty("_EmissionColor")) { value.SetColor("_EmissionColor", Color.black); } MutedMaterials.Add(val2, value); } (array ?? (array = (Material[])sharedMaterials.Clone()))[j] = value; } if (array != null) { OriginalMaterials.Add(val, sharedMaterials); val.sharedMaterials = array; } } } private static bool IsPickupOrUpgradeEffect(Component component, GameObject prefab) { Transform val = component.transform; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)prefab.transform) { if (IsPickupOrUpgradeNode(val)) { return true; } val = val.parent; } return false; } private static bool IsPickupOrUpgradeNode(Transform node) { if (!((Object)node).name.Equals("fx_ItemSparkles", StringComparison.OrdinalIgnoreCase)) { return IsForgeGlow(node); } return true; } private static bool IsGearEffect(string name, Component effect, GameObject root) { if (!ArmoryEffects.ContainsKey(name)) { return !IsPickupOrUpgradeEffect(effect, root); } return IsAttachedGearEffect(effect, root); } private static bool IsAttachedGearEffect(Component effect, GameObject root) { Transform val = effect.transform; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root.transform) { if (IsPickupOrUpgradeNode(val)) { return false; } if ((Object)(object)val.parent == (Object)(object)root.transform) { switch (((Object)val).name) { case "attach": case "attach_back": case "attach_skin": return true; default: return false; } } val = val.parent; } return false; } private static void Restore() { //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) RestoreIdleAudio(); foreach (KeyValuePair<Renderer, Material[]> originalMaterial in OriginalMaterials) { if ((Object)(object)originalMaterial.Key != (Object)null) { originalMaterial.Key.sharedMaterials = originalMaterial.Value; } } OriginalMaterials.Clear(); foreach (Light disabledLight in DisabledLights) { if ((Object)(object)disabledLight != (Object)null) { ((Behaviour)disabledLight).enabled = true; } } foreach (ParticleSystemRenderer disabledParticle in DisabledParticles) { if ((Object)(object)disabledParticle != (Object)null) { ((Renderer)disabledParticle).enabled = true; } } foreach (ParticleSystem disabledParticleLight in DisabledParticleLights) { if (!((Object)(object)disabledParticleLight == (Object)null)) { LightsModule lights = disabledParticleLight.lights; ((LightsModule)(ref lights)).enabled = true; } } foreach (Behaviour disabledLightController in DisabledLightControllers) { if ((Object)(object)disabledLightController != (Object)null) { disabledLightController.enabled = true; } } DisabledLights.Clear(); DisabledLightControllers.Clear(); DisabledParticleLights.Clear(); DisabledParticles.Clear(); } internal static void Shutdown() { _prefabsReady = false; RestoreForgeGlow(); SelectedForgeGear.Clear(); Restore(); foreach (Material value in MutedMaterials.Values) { Object.Destroy((Object)(object)value); } MutedMaterials.Clear(); } private static bool DisableLightController(Behaviour controller) { if (!controller.enabled || !DisabledLightControllers.Add(controller)) { return false; } controller.enabled = false; return true; } private static HashSet<string> ReadNames(string value) { HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal); string[] array = value.Split(','); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length > 0) { hashSet.Add(text); } } return hashSet; } private static GameObject? GetGear(string name) { bool flag = ArmoryEffects.ContainsKey(name); if (flag) { ObjectDB instance = ObjectDB.instance; GameObject val = ((instance != null) ? instance.GetItemPrefab(name) : null); if ((Object)(object)val != (Object)null && (Object)(object)val.GetComponent<ItemDrop>() != (Object)null) { return val; } } GameObject prefab = PrefabManager.Instance.GetPrefab(name); if ((Object)(object)prefab != (Object)null && (Object)(object)prefab.GetComponent<ItemDrop>() != (Object)null) { return prefab; } if (!flag) { ObjectDB instance2 = ObjectDB.instance; prefab = ((instance2 != null) ? instance2.GetItemPrefab(name) : null); if ((Object)(object)prefab != (Object)null && (Object)(object)prefab.GetComponent<ItemDrop>() != (Object)null) { return prefab; } } _logger.LogWarning((object)("'" + name + "' did not resolve to an item prefab.")); return null; } private static bool IsWorldObject(string prefab) { switch (prefab) { case "piece_magetable": case "Pickable_Mushroom_JotunPuffs": case "Pickable_Mushroom_Magecap": case "Pickable_Thistle": case "Pickable_Mushroom_yellow": case "piece_artisanstation": return true; default: return false; } } internal static void BindVanillaGear(ConfigFile config, ConfigFile oldConfig, ManualLogSource logger) { (string, string, string, string, string)[] array = (from entry in GetVanillaGear() orderby GearSorting.BiomeOrder(entry.Category) select entry).ToArray(); IEnumerable<ConfigDefinition> definitions = ((IEnumerable<(string, string, string, string, string)>)array).Select((Func<(string, string, string, string, string), ConfigDefinition>)(((string Prefab, string Key, string Token, string Name, string Category) item) => new ConfigDefinition(GearSorting.ConfigSection(item.Category), item.Key))); ConfigMigration.MoveGearSettings(oldConfig, config, definitions, logger); ConfigMigration.RemoveCheatSword(config); (string, string, string, string, string)[] array2 = array; for (int num = 0; num < array2.Length; num++) { (string, string, string, string, string) tuple = array2[num]; BindGear(config, tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4, tuple.Item5); } _vanillaGearBound = true; if (_prefabsReady) { Apply(); } } private static IEnumerable<(string Prefab, string Key, string Token, string Name, string Category)> GetVanillaGear() { (string Prefab, string Key, string Token, string Name, string Category)[] vanillaGear = VanillaGear; for (int i = 0; i < vanillaGear.Length; i++) { yield return vanillaGear[i]; } (string Family, string Name, string Token, bool FrostfireGoldSuffix, bool ThunderbloodGoldSuffix)[] deepNorthVariants = DeepNorthVariants; for (int i = 0; i < deepNorthVariants.Length; i++) { (string Family, string Name, string Token, bool FrostfireGoldSuffix, bool ThunderbloodGoldSuffix) variant = deepNorthVariants[i]; string text = variant.Family + "Gold_BloodLightning"; string frostfire = variant.Family + "Gold_FrostFire"; string text2 = (variant.ThunderbloodGoldSuffix ? "bloodlightning_gold" : "gold_bloodlightning"); string frostfireToken = (variant.FrostfireGoldSuffix ? "frostfire_gold" : "gold_frostfire"); yield return (Prefab: text, Key: text, Token: "$item_" + variant.Token + "_" + text2, Name: "Thunderblood " + variant.Name, Category: "Deep North - Thunderblood"); yield return (Prefab: frostfire, Key: frostfire, Token: "$item_" + variant.Token + "_" + frostfireToken, Name: "Frostfire " + variant.Name, Category: "Deep North - Frostfire"); } } private static void BindAudioSettings(ConfigFile config) { _defaultMuteIdleSound = BindEffectSetting(config, "Defaults", "Mute idle sound", defaultValue: true, "Mute detected looping equipment sounds on gear set to Use defaults. Re-equip to apply.", EffectOrder.IdleSound); _idleSoundPrefabs = BindEffectSetting(config, "Custom Prefabs", "Mute idle sound", "", "Comma-separated prefab IDs. Mutes attached looping audio. Explicit item overrides take precedence. Re-equip to apply.", EffectOrder.IdleSound); _defaultMuteIdleSound.SettingChanged += OnSettingChanged; _idleSoundPrefabs.SettingChanged += OnSettingChanged; } private static bool IsIdleAudio(AudioSource source, GameObject prefab) { if (source.loop) { return IsAttachedGearEffect((Component)(object)source, prefab); } return false; } private static bool HasIdleSoundControl(string prefab) { if (ArmoryEffects.TryGetValue(prefab, out (bool, bool, bool) value)) { return value.Item3; } return false; } private static void MuteIdleAudio(string name, GameObject prefab, bool log) { int num = 0; AudioSource[] componentsInChildren = prefab.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val in componentsInChildren) { if (!val.mute && IsIdleAudio(val, prefab) && MutedIdleAudio.Add(val)) { val.mute = true; num++; } } if (log) { _logger.LogInfo((object)$"'{name}': muted {num} looping audio source(s)."); } } private static void RestoreIdleAudio() { foreach (AudioSource item in MutedIdleAudio) { if ((Object)(object)item != (Object)null) { item.mute = false; } } MutedIdleAudio.Clear(); } private static void RefreshForgeGlow() { RestoreForgeGlow(); foreach (KeyValuePair<GameObject, int> item in SelectedForgeGear) { if ((Object)(object)item.Key != (Object)null) { HideAttachedForgeGlow(item.Key, item.Value); } } ConfigEntry<bool>? hideForgeGlow = _hideForgeGlow; if ((hideForgeGlow != null && hideForgeGlow.Value) || ForgeGlowPrefabHashes.Count != 0) { Transform[] array = Object.FindObjectsByType<Transform>((FindObjectsInactive)1, (FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { ApplyWorldForgeGlow(array[i]); } } } private static void ReadForgeGlowPrefabs() { ForgeGlowPrefabHashes.Clear(); foreach (string item in ReadNames(_forgeGlowPrefabs.Value)) { ForgeGlowPrefabHashes.Add(StringExtensionMethods.GetStableHashCode(item)); } PruneSelectedForgeGear(); } private static void PruneSelectedForgeGear() { List<GameObject> list = null; foreach (KeyValuePair<GameObject, int> item in SelectedForgeGear) { if ((Object)(object)item.Key == (Object)null || !ForgeGlowPrefabHashes.Contains(item.Value)) { (list ?? (list = new List<GameObject>())).Add(item.Key); } } if (list == null) { return; } foreach (GameObject item2 in list) { SelectedForgeGear.Remove(item2); } } private static void ApplyWorldForgeGlow(Transform node) { ConfigEntry<bool>? hideForgeGlow = _hideForgeGlow; if (hideForgeGlow != null && hideForgeGlow.Value) { HideForgeGlow(node); } else if (ForgeGlowPrefabHashes.Count > 0) { ApplyDroppedForgeGlow(((Component)node).gameObject); } } private static void ApplyDroppedForgeGlow(GameObject root) { ItemDrop val = default(ItemDrop); if (root.TryGetComponent<ItemDrop>(ref val)) { HideAttachedForgeGlow(root, StringExtensionMethods.GetStableHashCode(PrefabName(((Object)root).name))); } } private static void HideForgeGlow(Transform node) { if (IsForgeGlow(node) && ((Component)node).gameObject.activeSelf) { HiddenForgeGlows.Add(((Component)node).gameObject); ((Component)node).gameObject.SetActive(false); } } private static bool IsForgeGlow(Transform node) { if (!((Object)node).name.Equals("UpgraderGlow", StringComparison.OrdinalIgnoreCase)) { return ((Object)node).name.Equals("UpgraderGlow(Clone)", StringComparison.OrdinalIgnoreCase); } return true; } private static void RestoreForgeGlow() { foreach (GameObject hiddenForgeGlow in HiddenForgeGlows) { if ((Object)(object)hiddenForgeGlow != (Object)null) { hiddenForgeGlow.SetActive(true); } } HiddenForgeGlows.Clear(); } private static void HideAttachedForgeGlow(GameObject root, int itemHash) { ConfigEntry<bool>? hideForgeGlow = _hideForgeGlow; if ((hideForgeGlow != null && hideForgeGlow.Value) || ForgeGlowPrefabHashes.Contains(itemHash)) { HiddenForgeGlows.RemoveWhere((GameObject glow) => (Object)(object)glow == (Object)null); Transform[] componentsInChildren = root.GetComponentsInChildren<Transform>(true); for (int num = 0; num < componentsInChildren.Length; num++) { HideForgeGlow(componentsInChildren[num]); } } } private static void ApplyEquippedForgeGlow(int itemHash, GameObject root) { if (!((Object)(object)root == (Object)null)) { if (ForgeGlowPrefabHashes.Contains(itemHash)) { PruneSelectedForgeGear(); SelectedForgeGear[root] = itemHash; } HideAttachedForgeGlow(root, itemHash); } } } [BepInPlugin("NoGlowExpanded.ValheimArmory", "No Glow Expanded - Valheim Armory", "1.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal sealed class ValheimArmoryIntegration : BaseUnityPlugin { private const string ArmoryGuid = "MidnightsFX.ValheimArmory"; internal const string Uncategorized = "Uncategorized"; private (int Eligible, int Total, int UncategorizedEligible, int UncategorizedTotal)? _lastLogged; private static readonly (string Prefab, string Name, string Category, string WeaponType)[] Catalog = new(string, string, string, string)[166] { ("VAatgeir_antler", "Antler Atgeir", "Meadows - Weapons", "Atgeir"), ("VAAtgeir_Flint", "Flint Atgeir", "Meadows - Weapons", "Atgeir"), ("VAFlint_Axe", "Flint Axe", "Meadows - Weapons", "Axe"), ("VAFlint_dualaxes", "Flint Dualaxes", "Meadows - Weapons", "Axe"), ("VAAntler_Bow", "Antler Bow", "Meadows - Weapons", "Bow"), ("VACrossbowWood", "Wood Crossbow", "Meadows - Weapons", "Crossbow"), ("VAAntler_dagger", "Antler Dagger", "Meadows - Weapons", "Knife"), ("VADagger_Flint_2h", "Flint Knives", "Meadows - Weapons", "Knife"), ("VAAntler_greataxe", "Antler Greataxe", "Meadows - Weapons", "Battleaxe"), ("VAFlint_greataxe", "Flint Greataxe", "Meadows - Weapons", "Battleaxe"), ("VAFlint_Greatsword", "Flint Greatsword", "Meadows - Weapons", "THSword"), ("VAFist_Flint", "Flint Knuckles", "Meadows - Weapons", "Fist"), ("VAFlintMace", "Flint Mace", "Meadows - Weapons", "Mace"), ("VADual_Club", "Dual Club", "Meadows - Weapons", "Mace"), ("VADual_VAFlintMace", "Dual Flint Mace", "Meadows - Weapons", "Mace"), ("VASpearFlint", "Flint Spear", "Meadows - Weapons", "Spear"), ("VAAntler_Sword", "Antler Sword", "Meadows - Weapons", "Sword"), ("VADual_VAAntler_Sword", "Dual Antler Sword", "Meadows - Weapons", "Sword"), ("VAFlint_Sword", "Flint Sword", "Meadows - Weapons", "Sword"), ("VADual_SwordWood", "Dual Wooden Sword", "Meadows - Weapons", "Sword"), ("VADual_VAFlint_Sword", "Dual Flint Sword", "Meadows - Weapons", "Sword"), ("VABronze_dualaxes", "Bronze Dualaxes", "Black Forest - Weapons", "Axe"), ("VACrossbowElder", "Vine Crossbow", "Black Forest - Weapons", "Crossbow"), ("VACrossbowBronze", "Bronze Crossbow", "Black Forest - Weapons", "Crossbow"), ("VAdagger_copper_2h", "Copper Knives", "Black Forest - Weapons", "Knife"), ("VAbronze_battleaxe", "Bronze Lumber Axe", "Black Forest - Weapons", "Battleaxe"), ("VAbronze_greatsword", "Bronze Greatsword", "Black Forest - Weapons", "THSword"), ("VAFist_Bronze", "Bronze Knuckles", "Black Forest - Weapons", "Fist"), ("VAElder_mace", "Vine Mace", "Black Forest - Weapons", "Mace"), ("VADual_VAElder_mace", "Dual Vine Mace", "Black Forest - Weapons", "Mace"), ("VADual_MaceBronze", "Dual Bronze Mace", "Black Forest - Weapons", "Mace"), ("VAElderHammer", "Vine Hammer", "Black Forest - Weapons", "Sledge"), ("VABronzeSledge", "Bronze Sledge", "Black Forest - Weapons", "Sledge"), ("VAVine_Sword", "Vine Sword", "Black Forest - Weapons", "Sword"), ("VADual_VAVine_Sword", "Dual Vine Sword", "Black Forest - Weapons", "Sword"), ("VASwordChitin", "Chitin Sword", "Black Forest - Weapons", "Sword"), ("VADual_SwordBronze", "Dual Bronze Sword", "Black Forest - Weapons", "Sword"), ("VADual_VASwordChitin", "Dual Abyssal Sword", "Black Forest - Weapons", "Sword"), ("VAElderRoundShield", "Vine Shield", "Black Forest - Weapons", "Shield"), ("VABlood_Bones_pickaxe", "Blood Bone Battlepick", "Black Forest - Weapons", "Pickaxe"), ("VABone_axe", "Bonerot Axe", "Swamp - Weapons", "Axe"), ("VABone_dualaxes", "Bonerot Dualaxes", "Swamp - Weapons", "Axe"), ("VAIron_dualaxes", "Iron Dualaxes", "Swamp - Weapons", "Axe"), ("VACrossbowIron", "Iron Crossbow", "Swamp - Weapons", "Crossbow"), ("VABonemassDagger", "Bonerot Knife", "Swamp - Weapons", "Knife"), ("VAdagger_iron", "Iron Knife", "Swamp - Weapons", "Knife"), ("VAdagger_iron_2h", "Iron Knives", "Swamp - Weapons", "Knife"), ("VAdagger_chitin_2h", "Chitin Knives", "Swamp - Weapons", "Knife"), ("VABonemassGreatsword", "Bonerot Greatsword", "Swamp - Weapons", "THSword"), ("VAiron_greatsword", "Iron Greatsword", "Swamp - Weapons", "THSword"), ("VAFist_Iron", "Iron Knuckles", "Swamp - Weapons", "Fist"), ("VADual_MaceIron", "Dual Iron Mace", "Swamp - Weapons", "Mace"), ("VABonemassWarhammer", "Bonerot Sledge", "Swamp - Weapons", "Sledge"), ("VABonemassSword", "Bonerot Sword", "Swamp - Weapons", "Sword"), ("VADual_VABonemassSword", "Dual Bonerot Sword", "Swamp - Weapons", "Sword"), ("VADual_SwordIron", "Dual Iron Sword", "Swamp - Weapons", "Sword"), ("VAserpent_buckler", "Serpent Scale Buckler", "Swamp - Weapons", "Shield"), ("VAStaff_Druid_Fire", "Druidic Staff of Fire", "Swamp - Staves", "Staff"), ("VAStaff_Druid_Poison", "Druidic Staff of Poison", "Swamp - Staves", "Staff"), ("VAStaff_Druid_Spirit", "Druidic Staff of Spirit", "Swamp - Staves", "Staff"), ("VAAtgeirChitin", "Royal Abyssal Atgeir", "Mountains - Weapons", "Atgeir"), ("VASilverAtgeir", "Silver Atgeir", "Mountains - Weapons", "Atgeir"), ("VAModer_Axe", "Dragonfrost Axe", "Mountains - Weapons", "Axe"), ("VAModer_dualaxes", "Dragonfrost Dual Axes", "Mountains - Weapons", "Axe"), ("VAcrystal_axe", "Silver Axe", "Mountains - Weapons", "Axe"), ("VACrystal_dualaxes", "Crystal Dualaxes", "Mountains - Weapons", "Axe"), ("VABlood_bone_bow", "Blood Bone Bow", "Mountains - Weapons", "Bow"), ("VACrossbowModerNew", "Dragonfrost Crossbow", "Mountains - Weapons", "Crossbow"), ("VACrossbowModer", "Dragonfrost Crossbow (Legacy)", "Mountains - Weapons", "Crossbow"), ("VACrossbowSilver", "Draugr Claw", "Mountains - Weapons", "Crossbow"), ("VAdagger_moder", "Dragonfrost Knife", "Mountains - Weapons", "Knife"), ("VAdagger_moder_2h", "Dragonfrost Dual Knives", "Mountains - Weapons", "Knife"), ("VAdagger_silver_2h", "Silver Knives", "Mountains - Weapons", "Knife"), ("VAModer_greatsword", "Dragonfrost Greatsword", "Mountains - Weapons", "THSword"), ("VAsilver_greatsword", "Silver Greatsword", "Mountains - Weapons", "THSword"), ("VADual_MaceSilver", "Dual Frostner", "Mountains - Weapons", "Mace"), ("VASilverSledge", "Silver Sledge", "Mountains - Weapons", "Sledge"), ("VASpearModer", "Dragonfrost Spear", "Mountains - Weapons", "Spear"), ("VASwordModer", "Dragonfrost Sword", "Mountains - Weapons", "Sword"), ("VADual_VASwordModer", "Dual Dragonfrost Sword", "Mountains - Weapons", "Sword"), ("VADual_SwordSilver", "Dual Silver Sword", "Mountains - Weapons", "Sword"), ("VAModer_shield", "Dragonfrost Shield", "Mountains - Weapons", "Shield"), ("VAModer_RoundShield", "Dragonfrost Buckler", "Mountains - Weapons", "Shield"), ("VAsilver_tower", "Silver Tower Shield", "Mountains - Weapons", "Shield"), ("VAStaff_Druid_Ice", "Druidic Staff of Ice", "Mountains - Staves", "Staff"), ("VAYagluthAtgeir", "Goblin King Atgeir", "Plains - Weapons", "Atgeir"), ("VABlackmetal_dualaxes", "Blackmetal Dualaxes", "Plains - Weapons", "Axe"), ("VABlackmetal_bow", "Blackmetal Bow", "Plains - Weapons", "Bow"), ("VACrossbowBlackmetal", "Blackmetal Crossbow", "Plains - Weapons", "Crossbow"), ("VAArbalistBronze", "Bronze Arbalist", "Plains - Weapons", "Crossbow"), ("VAknife_blackmetal", "Blackmetal Knives", "Plains - Weapons", "Knife"), ("VAblackmetal_2h_axe", "Blackmetal Greataxe", "Plains - Weapons", "Battleaxe"), ("VAblackmetal_battleaxe", "Herkirs Wrath", "Plains - Weapons", "Battleaxe"), ("VAYagluth_greatsword", "Goblin King Greatsword", "Plains - Weapons", "THSword"), ("VABlackmetal_greatsword", "Blackmetal Greatsword", "Plains - Weapons", "THSword"), ("VAFist_Yagluth", "Goblin King Knuckles", "Plains - Weapons", "Fist"), ("VADual_MaceNeedle", "Dual Porcupine", "Plains - Weapons", "Mace"), ("VAblackmetal_sledge", "Skyshatter", "Plains - Weapons", "Sledge"), ("VASpearBlackmetal", "Blackmetal Spear", "Plains - Weapons", "Spear"), ("VADual_SwordBlackmetal", "Dual Black Metal Sword", "Plains - Weapons", "Sword"), ("VAJotunn_single_axe", "Jotuns Bane (Half)", "Mistlands - Weapons", "Axe"), ("VAJotunn_dualaxes", "Jotun Dualaxes", "Mistlands - Weapons", "Axe"), ("VAHeavy_Blood_Bone_Bow", "Carapace Blood Bow", "Mistlands - Weapons", "Bow"), ("VAQueen_bow", "Pincer Greatbow", "Mistlands - Weapons", "Bow"), ("VAdagger_queen", "Carapace Dagger", "Mistlands - Weapons", "Knife"), ("VAdagger_blackmetal_mistlands", "Hati Knife", "Mistlands - Weapons", "Knife"), ("VAJotunn_2h_axe", "Jotuns Greataxe", "Mistlands - Weapons", "Battleaxe"), ("VAQueen_greatsword", "Pincer Greatsword", "Mistlands - Weapons", "THSword"), ("VAmistland_mace", "Blackmarble Mace", "Mistlands - Weapons", "Mace"), ("VADual_VAmistland_mace", "Dual Blackmarble Mace", "Mistlands - Weapons", "Mace"), ("VADual_SwordMistwalker", "Dual Mistwalker", "Mistlands - Weapons", "Sword"), ("VADual_VASwordQueen", "Dual Carapace Sword", "Mistlands - Weapons", "Sword"), ("VASwordQueen", "Carapace Sword", "Mistlands - Weapons", "Sword"), ("VAdverger_tower", "Dverger Towershield", "Mistlands - Weapons", "Shield"), ("VAStaff_Poison", "Staff of Poison", "Mistlands - Staves", "Staff"), ("VAStaff_Spirit", "Staff of Spirit", "Mistlands - Staves", "Staff"), ("VAMeteorAtgeir", "Flametal Atgeir", "Ashlands - Weapons", "Atgeir"), ("VAFlametal_Axe", "Flametal Axe", "Ashlands - Weapons", "Axe"), ("VASoulStealer", "Soulstealer", "Ashlands - Weapons", "Knife"), ("VAdagger_meteor_2h", "Assassin's Knives", "Ashlands - Weapons", "Knife"), ("VAdagger_meteor", "Flametal Knife", "Ashlands - Weapons", "Knife"), ("VAFlametalAxe_2h", "Flametal Battleaxe", "Ashlands - Weapons", "Battleaxe"), ("VAGreatswordFader", "Dreadfire Greatsword", "Ashlands - Weapons", "THSword"), ("VADual_MaceEldner", "Dual Flametal Mace", "Ashlands - Weapons", "Mace"), ("VAflametal_sledge", "Flametal Sledge", "Ashlands - Weapons", "Sledge"), ("VASpearFader", "Dreadfire Spear", "Ashlands - Weapons", "Spear"), ("VASwordFader", "Dreadfire Sword", "Ashlands - Weapons", "Sword"), ("VADual_VASwordFader", "Dual Dreadfire Sword", "Ashlands - Weapons", "Sword"), ("VADual_SwordDyrnwyn", "Dual Dyrnwyn", "Ashlands - Weapons", "Sword"), ("VADual_SwordNiedhogg", "Dual NidhöGg", "Ashlands - Weapons", "Sword"), ("VAMeteorAtgeir_blood", "Flametal Blood Atgeir", "Ashlands - Blood", "Atgeir"), ("VAFlametal_Axe_Blood", "Flametal Blood Axe", "Ashlands - Blood", "Axe"), ("VAdagger_meteor_2h_blood", "Assassin's Blood Knives", "Ashlands - Blood", "Knife"), ("VAdagger_meteor_blood", "Flametal Blood Knife", "Ashlands - Blood", "Knife"), ("VAFlametalAxe_blood_2h", "Flametal Blood Battleaxe", "Ashlands - Blood", "Battleaxe"), ("VADual_MaceEldnerBlood", "Dual Bloodgeon", "Ashlands - Blood", "Mace"), ("VAflametal_sledge_blood", "Deathblow", "Ashlands - Blood", "Sledge"), ("VADual_SwordNiedhoggBlood", "Dual Nidhögg the Bleeding", "Ashlands - Blood", "Sword"), ("VAMeteorAtgeir_lightning", "Flametal Lightning Atgeir", "Ashlands - Lightning", "Atgeir"), ("VAFlametal_Axe_Lightning", "Flametal Lightning Axe", "Ashlands - Lightning", "Axe"), ("VAdagger_meteor_2h_lightning", "Assassin's Lightning Knives", "Ashlands - Lightning", "Knife"), ("VAdagger_meteor_lightning", "Flametal Lightning Knife", "Ashlands - Lightning", "Knife"), ("VAFlametalAxe_lightning_2h", "Flametal Lightning Battleaxe", "Ashlands - Lightning", "Battleaxe"), ("VADual_MaceEldnerLightning", "Dual Storm Star", "Ashlands - Lightning", "Mace"), ("VAflametal_sledge_lightning", "Thundermaker", "Ashlands - Lightning", "Sledge"), ("VADual_SwordNiedhoggLightning", "Dual Nidhögg the Thundering", "Ashlands - Lightning", "Sword"), ("VAMeteorAtgeir_nature", "Flametal Primal Atgeir", "Ashlands - Nature", "Atgeir"), ("VAFlametal_Axe_Primal", "Flametal Primal Axe", "Ashlands - Nature", "Axe"), ("VAdagger_meteor_2h_nature", "Assassin's Primal Knives", "Ashlands - Nature", "Knife"), ("VAdagger_meteor_nature", "Flametal Primal Knife", "Ashlands - Nature", "Knife"), ("VAFlametalAxe_primal_2h", "Flametal Primal Battleaxe", "Ashlands - Nature", "Battleaxe"), ("VADual_MaceEldnerNature", "Dual Klossen", "Ashlands - Nature", "Mace"), ("VAflametal_sledge_nature", "Earthshaker", "Ashlands - Nature", "Sledge"), ("VADual_SwordNiedhoggNature", "Dual Nidhögg the Primal", "Ashlands - Nature", "Sword"), ("VAGold_dualaxes", "Nord Dualaxes", "Deep North - Weapons", "Axe"), ("VAknife_gold", "Nord Daggers", "Deep North - Weapons", "Knife"), ("VADual_MaceGold", "Dual Nord Mace", "Deep North - Weapons", "Mace"), ("VADual_SwordGold", "Dual Nord Sword", "Deep North - Weapons", "Sword"), ("VAGold_dualaxes_thunderblood", "Thunderblood Dualaxes", "Deep North - Thunderblood", "Axe"), ("VAknife_gold_thunderblood", "Thunderblood Daggers", "Deep North - Thunderblood", "Knife"), ("VADual_MaceGold_BloodLightning", "Dual Thunderblood Mace", "Deep North - Thunderblood", "Mace"), ("VADual_SwordGold_BloodLightning", "Dual Thunderblood Sword", "Deep North - Thunderblood", "Sword"), ("VAGold_dualaxes_frostfire", "Frostfire Dualaxes", "Deep North - Frostfire", "Axe"), ("VAknife_gold_frostfire", "Frostfire Daggers", "Deep North - Frostfire", "Knife"), ("VADual_MaceGold_FrostFire", "Dual Frostfire Mace", "Deep North - Frostfire", "Mace"), ("VADual_SwordGold_FrostFire", "Dual Frostfire Sword", "Deep North - Frostfire", "Sword") }; private void Awake() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)SystemInfo.graphicsDeviceType != 4 && Chainloader.PluginInfos.TryGetValue("MidnightsFX.ValheimArmory", out var value) && !((Object)(object)value.Instance == (Object)null)) { ItemManager.OnItemsRegistered += RegisterGear; } } private void OnDestroy() { ItemManager.OnItemsRegistered -= RegisterGear; } private void RegisterGear() { int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; ObjectDB instance = ObjectDB.instance; ItemDrop val2 = default(ItemDrop); foreach (var item in from entry in GetCandidates() orderby GearSorting.BiomeOrder(entry.Category) select entry) { bool flag = item.Item3 == "Uncategorized"; GameObject val = ((instance != null) ? instance.GetItemPrefab(item.Item1) : null); if (flag) { if ((Object)(object)val == (Object)null) { continue; } num4++; } num3++; if ((Object)(object)val == (Object)null) { val = PrefabManager.Instance.GetPrefab(item.Item1); } if ((Object)(object)val == (Object)null) { LogSkipped(item.Item1, "prefab was not registered"); continue; } if (!val.TryGetComponent<ItemDrop>(ref val2)) { LogSkipped(item.Item1, "prefab has no ItemDrop component"); continue; } NoGlowExpanded.ArmoryRegistration armoryRegistration = NoGlowExpanded.RegisterArmoryGear(((BaseUnityPlugin)this).Config, item.Item1, val, val2.m_itemData.m_shared.m_name, item.Item2, item.Item3, item.Item4); if (armoryRegistration == NoGlowExpanded.ArmoryRegistration.NoSupportedEffects) { LogSkipped(item.Item1, "no supported lights, particles, or looping audio on the attached model"); continue; } num2++; if (flag) { num5++; } if (armoryRegistration == NoGlowExpanded.ArmoryRegistration.Added) { num++; } } (int, int, int, int) tuple = (num2, num3, num5, num4); if (NoGlowExpanded.BasicLoggingEnabled) { if (num <= 0) { (int, int, int, int) tuple2 = tuple; (int, int, int, int)? lastLogged = _lastLogged; if (lastLogged.HasValue) { (int, int, int, int) valueOrDefault = lastLogged.GetValueOrDefault(); if (tuple2.Item1 == valueOrDefault.Item1 && tuple2.Item2 == valueOrDefault.Item2 && tuple2.Item3 == valueOrDefault.Item3 && tuple2.Item4 == valueOrDefault.Item4) { goto IL_024a; } } } ((BaseUnityPlugin)this).Logger.LogInfo((object)($"ValheimArmory: {num2}/{num3} candidates have effect settings; {num3 - num2} skipped. " + $"Uncategorized: {num5}/{num4} candidates have settings.")); _lastLogged = tuple; } goto IL_024a; IL_024a: if (num2 > 0) { NoGlowExpanded.RefreshRegisteredGear(); } } private static IEnumerable<(string Prefab, string Name, string Category, string WeaponType)> GetCandidates() { HashSet<string> seen = new HashSet<string>(StringComparer.Ordinal); (string Prefab, string Name, string Category, string WeaponType)[] catalog = Catalog; for (int i = 0; i < catalog.Length; i++) { (string, string, string, string) tuple = catalog[i]; seen.Add(tuple.Item1); yield return tuple; } if ((Object)(object)ObjectDB.instance == (Object)null) { yield break; } IOrderedEnumerable<string> orderedEnumerable = (from item in ModRegistry.GetItems("MidnightsFX.ValheimArmory") where (Object)(object)item.ItemPrefab != (Object)null select ((Object)item.ItemPrefab).name).OrderBy<string, string>((string name) => name, StringComparer.Ordinal); foreach (string item in orderedEnumerable) { if (seen.Add(item)) { yield return (Prefab: item, Name: item, Category: "Uncategorized", WeaponType: ""); } } } private void LogSkipped(string prefab, string reason) { if (NoGlowExpanded.VerboseLoggingEnabled) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Skipped '" + prefab + "': " + reason + ".")); } } } [BepInPlugin("NoGlowExpanded.VanillaGear", "No Glow Expanded - Vanilla Gear", "1.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal sealed class VanillaGearPlugin : BaseUnityPlugin { private void Awake() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)SystemInfo.graphicsDeviceType != 4) { ConfigFile config = Chainloader.PluginInfos["NoGlowExpanded"].Instance.Config; NoGlowExpanded.BindVanillaGear(((BaseUnityPlugin)this).Config, config, ((BaseUnityPlugin)this).Logger); } } } internal static class GearSorting { internal static string ConfigSection(string category) { int num = category.IndexOf(" - ", StringComparison.Ordinal); if (num >= 0) { return category.Substring(0, num); } return category; } internal static int BiomeOrder(string category) { return ConfigSection(category) switch { "Meadows" => 0, "Black Forest" => 1, "Swamp" => 2, "Mountains" => 3, "Plains" => 4, "Mistlands" => 5, "Ashlands" => 6, "Deep North" => 7, _ => 8, }; } internal static int WeaponOrder(string family) { if (family.StartsWith("Pickable_Mushroom_", StringComparison.Ordinal)) { return 150; } if (family.StartsWith("Mead", StringComparison.Ordinal) || family == "CryptKey") { return 140; } if (family.StartsWith("Staff", StringComparison.Ordinal)) { return 130; } if (family.StartsWith("Atgeir", StringComparison.Ordinal)) { return 120; } if (family.StartsWith("Axe", StringComparison.Ordinal)) { return 110; } if (family.StartsWith("Bow", StringComparison.Ordinal)) { return 100; } if (family.StartsWith("Crossbow", StringComparison.Ordinal)) { return 90; } if (family.StartsWith("Knife", StringComparison.Ordinal)) { return 80; } if (family.StartsWith("Battleaxe", StringComparison.Ordinal)) { return 70; } if (family.StartsWith("THSword", StringComparison.Ordinal)) { return 60; } if (family.StartsWith("Fist", StringComparison.Ordinal)) { return 50; } if (family.StartsWith("Mace", StringComparison.Ordinal)) { return 40; } if (family.StartsWith("Sledge", StringComparison.Ordinal)) { return 30; } if (family.StartsWith("Spear", StringComparison.Ordinal)) { return 20; } if (family.StartsWith("Shield", StringComparison.Ordinal)) { return 5; } return 10; } } internal static class ConfigMigration { internal const string CustomPrefabs = "Custom Prefabs"; internal const string WorldLight = "Suppress world light"; internal const string Particles = "Hide particles"; internal const string MaterialGlow = "Suppress material glow"; internal const string DebugSection = "Debug"; internal static void MigrateGlobalSettings(ConfigFile config, ManualLogSource logger) { Dictionary<ConfigDefinition, string> saved = GetUnboundValues(config); if (saved == null) { logger.LogWarning((object)"Could not migrate the old global settings."); return; } Move("Extra gear effects", "DisableLights", "Custom Prefabs", "Suppress world light"); Move("Extra gear effects", "HideParticles", "Custom Prefabs", "Hide particles"); Move("Extra gear effects", "SuppressMaterialGlow", "Custom Prefabs", "Suppress material glow"); string[] array = new string[3] { "Logging level", "Write effect audit", "Effect audit scope" }; foreach (string text in array) { Move("Debug and Tests", text, "Debug", text); } RemoveCheatSword(config); void Move(string oldSection, string oldKey, string newSection, string newKey) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown if (saved.Remove(new ConfigDefinition(oldSection, oldKey), out string value)) { saved.TryAdd(new ConfigDefinition(newSection, newKey), value); } } } internal static void RemoveCheatSword(ConfigFile config) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown Dictionary<ConfigDefinition, string>? unboundValues = GetUnboundValues(config); if (unboundValues != null && unboundValues.Remove(new ConfigDefinition("Debug and Tests", "SwordCheat"))) { config.Save(); } } internal static void MoveGearSettings(ConfigFile source, ConfigFile destination, IEnumerable<ConfigDefinition> definitions, ManualLogSource logger) { Dictionary<ConfigDefinition, string> unboundValues = GetUnboundValues(source); if (unboundValues != null) { Dictionary<ConfigDefinition, string> unboundValues2 = GetUnboundValues(destination); if (unboundValues2 != null) { List<ConfigDefinition> list = new List<ConfigDefinition>(); foreach (ConfigDefinition definition in definitions) { if (unboundValues.TryGetValue(definition, out var value)) { if (!destination.ContainsKey(definition)) { unboundValues2.TryAdd(definition, value); } list.Add(definition); } } if (list.Count == 0) { return; } destination.Save(); foreach (ConfigDefinition item in list) { unboundValues.Remove(item); } source.Save(); return; } } logger.LogWarning((object)"Could not migrate the existing gear settings."); } private static Dictionary<ConfigDefinition, string>? GetUnboundValues(ConfigFile config) { return typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(config) as Dictionary<ConfigDefinition, string>; } } internal static class EffectAudit { private enum AuditScope { HeldGear, FullCatalog } private static ConfigEntry<KeyboardShortcut>? _shortcut; private static ConfigEntry<AuditScope>? _scope; private static ManualLogSource _logger; internal static void Bind(ConfigFile config, ManualLogSource logger) { //IL_001b: 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_004a: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown _logger = logger; _shortcut = config.Bind<KeyboardShortcut>("Debug", "Write effect audit", new KeyboardShortcut((KeyCode)291, Array.Empty<KeyCode>()), new ConfigDescription("Write a read-only item effect report while in a world with Verbose logging enabled.", (AcceptableValueBase)null, new object[1] { new NoGlowExpanded.ConfigurationManagerAttributes { IsAdvanced = true } })); _scope = config.Bind<AuditScope>("Debug", "Effect audit scope", AuditScope.HeldGear, new ConfigDescription("Inspect the live items in your hands, or include every registered item prefab.", (AcceptableValueBase)null, new object[1] { new NoGlowExpanded.ConfigurationManagerAttributes { IsAdvanced = true } })); } internal static void Tick() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) ConfigEntry<KeyboardShortcut>? shortcut = _shortcut; if (shortcut == null) { return; } KeyboardShortcut value = shortcut.Value; if (((KeyboardShortcut)(ref value)).IsDown() && (Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)ObjectDB.instance != (Object)null) { try { WriteReport(); } catch (Exception ex) { _logger.LogError((object)ex); } } } private static void WriteReport() { StringBuilder stringBuilder = new StringBuilder(); VisEquipment componentInChildren = ((Component)Player.m_localPlayer).GetComponentInChildren<VisEquipment>(true); stringBuilder.AppendLine("[Live held items]"); if ((Object)(object)componentInChildren != (Object)null) { DescribeHand(componentInChildren, "m_leftItemInstance", "Left hand", stringBuilder); DescribeHand(componentInChildren, "m_rightItemInstance", "Right hand", stringBuilder); } else { stringBuilder.AppendLine("Player equipment is unavailable."); } ConfigEntry<AuditScope>? scope = _scope; if (scope != null && scope.Value == AuditScope.FullCatalog) { DescribeCatalog(stringBuilder); } string path = $"NoGlowEffectAudit-{DateTime.Now:yyyyMMdd-HHmmss-fff}.txt"; string text = Path.Combine(Paths.BepInExRootPath, path); File.WriteAllText(text, stringBuilder.ToString(), Encoding.UTF8); _logger.LogInfo((object)("Effect audit written to " + text)); } private static void DescribeHand(VisEquipment equipment, string fieldName, string label, StringBuilder report) { FieldInfo fieldInfo = AccessTools.Field(typeof(VisEquipment), fieldName); if (fieldInfo == null) { report.AppendLine(label + ": equipment field unavailable."); return; } object? value = fieldInfo.GetValue(equipment); GameObject val = (GameObject)((value is GameObject) ? value : null); if ((Object)(object)val == (Object)null) { report.AppendLine(label + ": empty."); return; } report.AppendLine(label + ": " + ((Object)val).name); Describe(val, report); } private static void DescribeCatalog(StringBuilder report) { StringBuilder stringBuilder = new StringBuilder(); report.AppendLine("\n[Registered item prefabs] Component presence does not prove passive visibility."); ItemDrop val = default(ItemDrop); foreach (GameObject item in ObjectDB.instance.m_items) { if (!((Object)(object)item == (Object)null) && item.TryGetComponent<ItemDrop>(ref val)) { stringBuilder.Clear(); Describe(item, stringBuilder); if (stringBuilder.Length != 0) { string name = val.m_itemData.m_shared.m_name; Localization instance = Localization.instance; string text = ((instance != null) ? instance.Localize(name) : null) ?? name; report.AppendLine("\n[" + ((Object)item).name + "] " + text + " (" + name + ")"); report.Append(stringBuilder); } } } } private static void Describe(GameObject root, StringBuilder report) { //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) Light[] componentsInChildren = root.GetComponentsInChildren<Light>(true); foreach (Light val in componentsInChildren) { Line(root, (Component)(object)val, report, $"Light enabled={((Behaviour)val).enabled} intensity={val.intensity} range={val.range}"); } LightLod[] componentsInChildren2 = root.GetComponentsInChildren<LightLod>(true); foreach (LightLod val2 in componentsInChildren2) { Line(root, (Component)(object)val2, report, $"LightLod enabled={((Behaviour)val2).enabled}"); } LightFlicker[] componentsInChildren3 = root.GetComponentsInChildren<LightFlicker>(true); foreach (LightFlicker val3 in componentsInChildren3) { Line(root, (Component)(object)val3, report, $"LightFlicker enabled={((Behaviour)val3).enabled}"); } ParticleSystem[] componentsInChildren4 = root.GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val4 in componentsInChildren4) { ParticleSystemRenderer component = ((Component)val4).GetComponent<ParticleSystemRenderer>(); string text = $"Particles rendererEnabled={(Object)(object)component != (Object)null && ((Renderer)component).enabled} "; MainModule main = val4.main; object arg = ((MainModule)(ref main)).playOnAwake; main = val4.main; string text2 = $"playOnAwake={arg} looping={((MainModule)(ref main)).loop} "; object arg2 = val4.isPlaying; object arg3 = val4.particleCount; LightsModule lights = val4.lights; Line(root, (Component)(object)val4, report, text + text2 + $"playing={arg2} count={arg3} particleLights={((LightsModule)(ref lights)).enabled}"); } Renderer[] componentsInChildren5 = root.GetComponentsInChildren<Renderer>(true); foreach (Renderer val5 in componentsInChildren5) { Material[] sharedMaterials = val5.sharedMaterials; foreach (Material val6 in sharedMaterials) { if (!((Object)(object)val6 == (Object)null) && val6.HasProperty("_EmissionColor")) { Color color = val6.GetColor("_EmissionColor"); bool flag = val6.IsKeywordEnabled("_EMISSION"); if (flag || !(((Color)(ref color)).maxColorComponent <= 0f)) { Line(root, (Component)(object)val5, report, "Emission candidate material=" + ((Object)val6).name + " shader=" + ((Object)val6.shader).name + " " + $"keyword={flag} color={color}"); } } } } AudioSource[] componentsInChildren6 = root.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val7 in componentsInChildren6) { AudioClip clip = val7.clip; Line(root, (Component)(object)val7, report, "Audio clip=" + (((clip != null) ? ((Object)clip).name : null) ?? "(none assigned)") + " " + $"enabled={((Behaviour)val7).enabled} muted={val7.mute} loop={val7.loop} playOnAwake={val7.playOnAwake} playing={val7.isPlaying}"); } } private static void Line(GameObject root, Component component, StringBuilder report, string detail) { Transform val = component.transform; string text = ((Object)val).name; while ((Object)(object)val != (Object)(object)root.transform && (Object)(object)val.parent != (Object)null) { val = val.parent; text = ((Object)val).name + "/" + text; } report.AppendLine($" {text} [activeSelf={component.gameObject.activeSelf}, activeInHierarchy={component.gameObject.activeInHierarchy}] {detail}"); } } }