using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using CustomBossBars.Helpers; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.AddressableAssets.ResourceLocators; using UnityEngine.ResourceManagement.ResourceLocations; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class ExtensionMarkerAttribute : Attribute { public ExtensionMarkerAttribute(string name) { } } } namespace CustomBossBars { [BepInPlugin("duviz.CustomBossbars", "CustomBossbars", "0.1.0")] public class Plugin : BaseUnityPlugin { public static Plugin instance; public static ConfigFile config; public static List<(ConfigEntry, ConfigEntry)> bossbars = new List<(ConfigEntry, ConfigEntry)>(); public static List<(ConfigEntry, ConfigEntry)> namesOverrides = new List<(ConfigEntry, ConfigEntry)>(); public static ConfigEntry secondaryBossbarColor; public static ConfigEntry idolBossbarColor; public void Awake() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) instance = this; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; config = ((BaseUnityPlugin)this).Config; new Harmony("duviz.CustomBossbars").PatchAll(); secondaryBossbarColor = config.Bind("Colors", "Stamina bar color", Color.red, (ConfigDescription)null); idolBossbarColor = config.Bind("Colors", "Idol protected color", new Color(0.25f, 0.75f, 1f), (ConfigDescription)null); for (int i = 0; i < 16; i++) { bossbars.Add((config.Bind("Colors", $"Bossbar color n{i + 1}", Color.red, (ConfigDescription)null), config.Bind("Colors", $"Bossbar damage color n{i + 1}", Color.white, (ConfigDescription)null))); } for (int j = 0; j < 32; j++) { namesOverrides.Add((config.Bind("Names", $"Boss original name n{j + 1}", "", (ConfigDescription)null), config.Bind("Names", $"Boss replacement name n{j + 1}", "", (ConfigDescription)null))); } } public void Start() { SceneManager.sceneLoaded += delegate { config.Reload(); }; } public static T Ass(string path) { return AssHelper.Ass(path); } public static void LogInfo(object msg) { ((BaseUnityPlugin)instance).Logger.LogInfo(msg); } public static void LogWarning(object msg) { ((BaseUnityPlugin)instance).Logger.LogWarning(msg); } public static void LogError(object msg) { ((BaseUnityPlugin)instance).Logger.LogError(msg); } } public class PluginInfo { public const string GUID = "Duviz.CustomBossBars"; public const string Name = "CustomBossBars"; public const string Version = "0.1.2"; } [HarmonyPatch] public class Patch { [HarmonyPatch(typeof(BossHealthBarTemplate), "Initialize")] [HarmonyPrefix] public static void Initialize(BossHealthBarTemplate __instance, BossHealthBar bossBar, ref SliderLayer[] colorLayers) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown Plugin.config.Reload(); Plugin.LogInfo(colorLayers.Length); for (int i = 0; i < colorLayers.Length; i++) { colorLayers[i] = new SliderLayer { color = Plugin.bossbars[i].Item1.Value, afterImageColor = Plugin.bossbars[i].Item2.Value }; } string bossName = bossBar.bossName; foreach (var (val, val2) in Plugin.namesOverrides) { if (val.Value.ToLower() == bossName.ToLower()) { bossBar.bossName = val2.Value; } } } [HarmonyPatch(typeof(BossHealthBarTemplate), "GetHPColor")] [HarmonyPrefix] public static bool GetHPColor(BossHealthBarTemplate __instance, int index, ref Color __result) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (__instance.source != null && __instance.source.Blessed) { __result = Plugin.idolBossbarColor.Value; return false; } __result = __instance.hpColors[index]; return false; } [HarmonyPatch(typeof(BossHealthBar), "SetSecondaryBarColor")] [HarmonyPrefix] public static bool SetSecondaryBarColor(BossHealthBar __instance) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) Plugin.config.Reload(); __instance.secondaryBarColor = Plugin.secondaryBossbarColor.Value; return false; } [HarmonyPatch(typeof(BossHealthBar), "Awake")] [HarmonyPrefix] public static void Awake(BossHealthBar __instance) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) Plugin.config.Reload(); __instance.secondaryBarColor = Plugin.secondaryBossbarColor.Value; } } } namespace CustomBossBars.Helpers { public static class AssHelper { [SpecialName] public sealed class $34505F560D9EACF86A87F3ED1F85E448 { [SpecialName] public static class $69FE22D2D9367C6033D7C9FA04F1ABE9 { } [ExtensionMarker("$69FE22D2D9367C6033D7C9FA04F1ABE9")] public int Occurrences(char lookUp) { throw null; } [ExtensionMarker("$69FE22D2D9367C6033D7C9FA04F1ABE9")] public IEnumerable Occurences(char lookUp) { throw null; } } private static List cache_PrefabKeys = null; public static Dictionary CachedAddressableAssets = new Dictionary(); public static IResourceLocator MainAddressablesLocator => Addressables.ResourceLocators.FirstOrDefault((Func)((IResourceLocator loc) => loc.LocatorId == "AddressablesMainContentCatalog")); public static IEnumerable GetAddressableKeys() { IResourceLocator mainAddressablesLocator = MainAddressablesLocator; return ((mainAddressablesLocator != null) ? mainAddressablesLocator.Keys : null) ?? Array.Empty(); } public static List GetPrefabAddressableKeys(Func Search = null) { if (cache_PrefabKeys != null) { return cache_PrefabKeys.Where(Search).ToList(); } List list = new List(); IList list2 = default(IList); foreach (object addressableKey in GetAddressableKeys()) { if (MainAddressablesLocator.Locate(addressableKey, typeof(GameObject), ref list2) && !list.Contains(list2[0].PrimaryKey)) { list.Add(list2[0].PrimaryKey); } } list.Sort(); cache_PrefabKeys = list; return list.Where(Search).ToList(); } public static T Ass(string key) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (CachedAddressableAssets.TryGetValue(key + typeof(T).Name, out var value)) { return (T)value; } T val = Addressables.LoadAssetAsync((object)key).WaitForCompletion(); if (val != null) { CachedAddressableAssets.Add(key + typeof(T).Name, val); } else { Plugin.LogError("Failed to load asset: " + key); } return val; } public static int Occurrences(this string str, char lookUp) { int num = 0; foreach (char c in str) { if (c == lookUp) { num++; } } return num; } public static IEnumerable Occurences(this string str, char lookUp) { for (int i = 0; i < str.Length; i++) { if (str[i] == lookUp) { yield return i; } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }