Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of GrowthNectarDisplay v1.0.0
plugins/GrowthNectarDisplay/GrowthNectarDisplay.dll
Decompiled a year agousing System; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GrowthNectarDisplay.BuffIconIndicator; using GrowthNectarDisplay.ModCompatibility; using GrowthNectarDisplay.Utilities.Extensions; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Collections.Generic; using MonoMod.Cil; using MonoMod.Utils; using On.RoR2.UI; using R2API.Utils; using RiskOfOptions; using RiskOfOptions.Options; using RoR2; using RoR2.UI; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: NetworkCompatibility(/*Could not decode attribute arguments.*/)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("GrowthNectarDisplay")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+74d29c1e47922b6a508b86995ce2393031f860ec")] [assembly: AssemblyProduct("GrowthNectarDisplay")] [assembly: AssemblyTitle("GrowthNectarDisplay")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace GrowthNectarDisplay { internal static class Assets { public static Sprite GrowthNectarBuffIndicatorSprite { get; private set; } public static void Load() { GrowthNectarBuffIndicatorSprite = loadSprite(Path.Combine(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)GrowthNectarDisplayPlugin.Instance).Info.Location), "assets"), "Indicator.png"), "GrowthNectarBuffIndicator"); } private static Sprite loadSprite(string filePath, string name) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Texture2D val = loadTexture(filePath, name); if (!Object.op_Implicit((Object)(object)val)) { return null; } Sprite obj = Sprite.Create(val, new Rect(Vector2.zero, new Vector2((float)((Texture)val).width, (float)((Texture)val).height)), new Vector2(0.5f, 0.5f)); ((Object)obj).name = name; return obj; } private static Texture2D loadTexture(string filePath, string name) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown if (!File.Exists(filePath)) { Log.Error("Failed to load texture '" + name + "': File " + filePath + " does not exist", "X:\\Git\\RoR2\\GrowthNectarDisplay\\GrowthNectarDisplay\\Assets.cs", "loadTexture", 33); return null; } byte[] array = File.ReadAllBytes(filePath); Texture2D val = new Texture2D(1, 1); if (!ImageConversion.LoadImage(val, array)) { return null; } ((Object)val).name = name; return val; } } [BepInPlugin("Gorakh.GrowthNectarDisplay", "GrowthNectarDisplay", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class GrowthNectarDisplayPlugin : BaseUnityPlugin { public const string PluginGUID = "Gorakh.GrowthNectarDisplay"; public const string PluginAuthor = "Gorakh"; public const string PluginName = "GrowthNectarDisplay"; public const string PluginVersion = "1.0.0"; private static GrowthNectarDisplayPlugin _instance; internal static GrowthNectarDisplayPlugin Instance => _instance; private void Awake() { Stopwatch stopwatch = Stopwatch.StartNew(); SingletonHelper.Assign<GrowthNectarDisplayPlugin>(ref _instance, this); Log.Init(((BaseUnityPlugin)this).Logger); Assets.Load(); GrowthNectarBuffIndicatorController.StaticInit(((BaseUnityPlugin)this).Config); if (RiskOfOptionsCompat.Enabled) { RiskOfOptionsCompat.AddOptions(); } stopwatch.Stop(); Log.Message_NoCallerPrefix($"Initialized in {stopwatch.Elapsed.TotalMilliseconds:F0}ms"); } private void OnDestroy() { SingletonHelper.Unassign<GrowthNectarDisplayPlugin>(ref _instance, this); } } internal static class Log { private static readonly StringBuilder _sharedStringBuilder; private static readonly int _cachedCallerPathPrefixLength; private static ManualLogSource _logSource; static Log() { _sharedStringBuilder = new StringBuilder(256); _cachedCallerPathPrefixLength = getCallerPathPrefixLength("X:\\Git\\RoR2\\GrowthNectarDisplay\\GrowthNectarDisplay\\Log.cs"); static int getCallerPathPrefixLength([CallerFilePath] string callerPath = null) { int num = callerPath.LastIndexOf("GrowthNectarDisplay\\"); if (num >= 0) { return num + "GrowthNectarDisplay\\".Length; } Debug.LogError((object)"[GrowthNectarDisplay] Logger failed to determine caller path prefix length"); return 0; } } internal static void Init(ManualLogSource logSource) { _logSource = logSource; } private static StringBuilder AppendCallerPrefix(this StringBuilder stringBuilder, string callerPath, string callerMemberName, int callerLineNumber) { return stringBuilder.Append(callerPath, _cachedCallerPathPrefixLength, callerPath.Length - _cachedCallerPathPrefixLength).Append(':').Append(callerLineNumber) .Append(" (") .Append(callerMemberName) .Append("):"); } private static StringBuilder buildCallerLogString(string callerPath, string callerMemberName, int callerLineNumber, object data) { return _sharedStringBuilder.Clear().AppendCallerPrefix(callerPath, callerMemberName, callerLineNumber).Append(' ') .Append(data); } [Conditional("DEBUG")] internal static void Debug(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogDebug((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [Conditional("DEBUG")] internal static void Debug_NoCallerPrefix(object data) { _logSource.LogDebug(data); } internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogError((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Error_NoCallerPrefix(object data) { _logSource.LogError(data); } internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogFatal((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Fatal_NoCallerPrefix(object data) { _logSource.LogFatal(data); } internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogInfo((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Info_NoCallerPrefix(object data) { _logSource.LogInfo(data); } internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogMessage((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Message_NoCallerPrefix(object data) { _logSource.LogMessage(data); } internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogWarning((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Warning_NoCallerPrefix(object data) { _logSource.LogWarning(data); } internal static void LogType(LogLevel level, object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) if ((level & 0x20) == 0) { _logSource.Log(level, (object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void LogType_NoCallerPrefix(LogLevel level, object data) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) if ((level & 0x20) == 0) { _logSource.Log(level, data); } } } } namespace GrowthNectarDisplay.Utilities.Extensions { public static class AssetLoadExtensions { public static void CallOnSuccess<T>(this AsyncOperationHandle<T> handle, Action<T> onSuccess) { handle.Completed += delegate(AsyncOperationHandle<T> handle) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)handle.Status == 2) { Log.Error("Failed to load asset '" + handle.LocationName + "'", "X:\\Git\\RoR2\\GrowthNectarDisplay\\GrowthNectarDisplay\\Utilities\\Extensions\\AssetLoadExtensions.cs", "CallOnSuccess", 19); } else { onSuccess(handle.Result); } }; } } public static class PatchExtensions { public static void EmitSkipMethodCall(this ILCursor c, MethodDefinition method = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) c.EmitSkipMethodCall(OpCodes.Br, method); } public static void EmitSkipMethodCall(this ILCursor c, OpCode branchOpCode, MethodDefinition method = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) c.EmitSkipMethodCall(branchOpCode, null, method); } public static void EmitSkipMethodCall(this ILCursor c, OpCode branchOpCode, Action<ILCursor> emitSkippedReturnValue, MethodDefinition method = null) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) if (c == null) { throw new ArgumentNullException("c"); } if ((int)((OpCode)(ref branchOpCode)).FlowControl != 0 && (int)((OpCode)(ref branchOpCode)).FlowControl != 3) { throw new ArgumentException($"Invalid branch OpCode: {branchOpCode}"); } if (method == null) { MethodReference val = default(MethodReference); if (!ILPatternMatchingExt.MatchCallOrCallvirt(c.Next, ref val)) { Log.Error($"Failed to find method call to skip: {((MemberReference)c.Context.Method).FullName} at instruction {c.Next} ({c.Index})", "X:\\Git\\RoR2\\GrowthNectarDisplay\\GrowthNectarDisplay\\Utilities\\Extensions\\PatchExtensions.cs", "EmitSkipMethodCall", 33); return; } method = Extensions.SafeResolve(val); if (method == null) { Log.Error($"Failed to resolve method '{((MemberReference)val).FullName}': {((MemberReference)c.Context.Method).FullName} at instruction {c.Next} ({c.Index})", "X:\\Git\\RoR2\\GrowthNectarDisplay\\GrowthNectarDisplay\\Utilities\\Extensions\\PatchExtensions.cs", "EmitSkipMethodCall", 41); return; } } int num = ((MethodReference)method).Parameters.Count + ((!method.IsStatic) ? 1 : 0); bool flag = Extensions.Is((MemberReference)(object)((MethodReference)method).ReturnType, (MemberInfo)typeof(void)); ILLabel val2 = c.DefineLabel(); c.Emit(branchOpCode, (object)val2); int index = c.Index; c.Index = index + 1; if (num > 0 || !flag) { ILLabel val3 = c.DefineLabel(); c.Emit(OpCodes.Br, (object)val3); c.MarkLabel(val2); for (int i = 0; i < num; i++) { c.Emit(OpCodes.Pop); } if (emitSkippedReturnValue != null) { emitSkippedReturnValue(c); } else if (!flag) { Log.Warning($"Skipped method ({((MemberReference)method).FullName}) is not void, emitting default value: {((MemberReference)c.Context.Method).FullName} at instruction {c.Next} ({c.Index})", "X:\\Git\\RoR2\\GrowthNectarDisplay\\GrowthNectarDisplay\\Utilities\\Extensions\\PatchExtensions.cs", "EmitSkipMethodCall", 73); if (((MethodReference)method).ReturnType.IsValueType) { VariableDefinition val4 = c.Context.AddVariable(((MethodReference)method).ReturnType); c.Emit(OpCodes.Ldloca, val4); c.Emit(OpCodes.Initobj, ((MethodReference)method).ReturnType); c.Emit(OpCodes.Ldloc, val4); } else { c.Emit(OpCodes.Ldnull); } } c.MarkLabel(val3); } else { c.MarkLabel(val2); } } public static bool TryFindParameter(this MethodReference method, Type type, string name, out ParameterDefinition parameter) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) Enumerator<ParameterDefinition> enumerator = method.Parameters.GetEnumerator(); try { while (enumerator.MoveNext()) { ParameterDefinition current = enumerator.Current; if ((string.IsNullOrEmpty(name) || ((ParameterReference)current).Name == name) && (type == null || Extensions.Is((MemberReference)(object)((ParameterReference)current).ParameterType, (MemberInfo)type))) { parameter = current; return true; } } } finally { ((IDisposable)enumerator).Dispose(); } parameter = null; return false; } public static bool TryFindParameter(this MethodReference method, string name, out ParameterDefinition parameter) { return method.TryFindParameter(null, name, out parameter); } public static bool TryFindParameter(this MethodReference method, Type type, out ParameterDefinition parameter) { return method.TryFindParameter(type, null, out parameter); } public static bool TryFindParameter<T>(this MethodReference method, string name, out ParameterDefinition parameter) { return method.TryFindParameter(typeof(T), name, out parameter); } public static bool TryFindParameter<T>(this MethodReference method, out ParameterDefinition parameter) { return method.TryFindParameter(typeof(T), null, out parameter); } public static VariableDefinition AddVariable(this ILContext context, TypeReference variableType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown VariableDefinition val = new VariableDefinition(variableType); context.Method.Body.Variables.Add(val); return val; } public static VariableDefinition AddVariable(this ILContext context, Type variableType) { return context.AddVariable(context.Import(variableType)); } public static VariableDefinition AddVariable<T>(this ILContext context) { return context.AddVariable(context.Import(typeof(T))); } public static void EmitStoreStack(this ILCursor cursor, params VariableDefinition[] variables) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (cursor == null) { throw new ArgumentNullException("cursor"); } if (variables == null) { throw new ArgumentNullException("variables"); } if (variables.Length != 0) { for (int num = variables.Length - 1; num >= 1; num--) { cursor.Emit(OpCodes.Stloc, variables[num]); } cursor.Emit(OpCodes.Dup); cursor.Emit(OpCodes.Stloc, variables[0]); for (int i = 1; i < variables.Length; i++) { cursor.Emit(OpCodes.Ldloc, variables[i]); } } } } } namespace GrowthNectarDisplay.ModCompatibility { internal static class RiskOfOptionsCompat { private static Sprite _iconSprite; private const string MOD_GUID = "Gorakh.GrowthNectarDisplay"; private const string MOD_NAME = "GrowthNectarDisplay"; public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddOptions() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown ModSettingsManager.SetModDescription("Options for GrowthNectarDisplay", "Gorakh.GrowthNectarDisplay", "GrowthNectarDisplay"); Sprite val = tryGetIcon(); if (Object.op_Implicit((Object)(object)val)) { ModSettingsManager.SetModIcon(val, "Gorakh.GrowthNectarDisplay", "GrowthNectarDisplay"); } ModSettingsManager.AddOption((BaseOption)new ColorOption(GrowthNectarBuffIndicatorController.IndicatorColorConfig), "Gorakh.GrowthNectarDisplay", "GrowthNectarDisplay"); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(GrowthNectarBuffIndicatorController.RequireItemInInventoryConfig), "Gorakh.GrowthNectarDisplay", "GrowthNectarDisplay"); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(GrowthNectarBuffIndicatorController.AlwaysShowOnScoreboardOpenConfig), "Gorakh.GrowthNectarDisplay", "GrowthNectarDisplay"); } private static Sprite tryGetIcon() { if (!Object.op_Implicit((Object)(object)_iconSprite)) { _iconSprite = tryGenerateIcon(); if (!Object.op_Implicit((Object)(object)_iconSprite)) { Log.Warning("Failed to get config icon", "X:\\Git\\RoR2\\GrowthNectarDisplay\\GrowthNectarDisplay\\ModCompatibility\\RiskOfOptionsCompat.cs", "tryGetIcon", 46); } } return _iconSprite; } private static Sprite tryGenerateIcon() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) FileInfo fileInfo = findIconFileRecursive(new DirectoryInfo(Path.GetDirectoryName(((BaseUnityPlugin)GrowthNectarDisplayPlugin.Instance).Info.Location))); if (fileInfo == null) { return null; } byte[] array; try { array = File.ReadAllBytes(fileInfo.FullName); } catch (Exception arg) { Log.Error_NoCallerPrefix($"Failed to read icon file '{fileInfo.FullName}': {arg}"); return null; } Texture2D val = new Texture2D(256, 256); ((Object)val).name = "texGrowthNectarDisplayIcon"; if (!ImageConversion.LoadImage(val, array)) { Log.Error("Failed to load icon into texture", "X:\\Git\\RoR2\\GrowthNectarDisplay\\GrowthNectarDisplay\\ModCompatibility\\RiskOfOptionsCompat.cs", "tryGenerateIcon", 75); return null; } Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); ((Object)obj).name = "GrowthNectarDisplayIcon"; return obj; } private static FileInfo findIconFileRecursive(DirectoryInfo dir) { if (dir == null) { return null; } if (string.Equals(dir.FullName, Paths.PluginPath, StringComparison.OrdinalIgnoreCase)) { return null; } FileInfo fileInfo = dir.EnumerateFiles("icon.png", SearchOption.TopDirectoryOnly).FirstOrDefault(); if (fileInfo != null) { return fileInfo; } return findIconFileRecursive(dir.Parent); } } } namespace GrowthNectarDisplay.BuffIconIndicator { public class GrowthNectarBuffIndicatorController : MonoBehaviour { [CompilerGenerated] private static class <>O { public static hook_GetNewBuffIcon <0>__BuffDisplay_GetNewBuffIcon; } [NonSerialized] public BuffDisplay OwnerBuffDisplay; private GameObject _indicatorRoot; private Image _indicatorImage; private BuffIcon _buffIcon; private CharacterBody _buffSource; public static ConfigEntry<Color> IndicatorColorConfig { get; private set; } public static ConfigEntry<bool> RequireItemInInventoryConfig { get; private set; } public static ConfigEntry<bool> AlwaysShowOnScoreboardOpenConfig { get; private set; } public static void StaticInit(ConfigFile config) { //IL_0005: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_0087: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00b2: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00dd: Expected O, but got Unknown //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_0049: Expected O, but got Unknown Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/UI/BuffIcon.prefab").CallOnSuccess(delegate(GameObject buffIcon) { buffIcon.AddComponent<GrowthNectarBuffIndicatorController>(); }); object obj = <>O.<0>__BuffDisplay_GetNewBuffIcon; if (obj == null) { hook_GetNewBuffIcon val = BuffDisplay_GetNewBuffIcon; <>O.<0>__BuffDisplay_GetNewBuffIcon = val; obj = (object)val; } BuffDisplay.GetNewBuffIcon += (hook_GetNewBuffIcon)obj; IndicatorColorConfig = config.Bind<Color>(new ConfigDefinition("Indicator", "Indicator Color"), new Color(0.9692f, 0.7857f, 0.0969f), new ConfigDescription("The color of the indicator", (AcceptableValueBase)null, Array.Empty<object>())); RequireItemInInventoryConfig = config.Bind<bool>(new ConfigDefinition("Indicator", "Require Item"), true, new ConfigDescription("If enabled, the Growth Nectar buff indicator will not show unless you have the Growth Nectar item", (AcceptableValueBase)null, Array.Empty<object>())); AlwaysShowOnScoreboardOpenConfig = config.Bind<bool>(new ConfigDefinition("Indicator", "Always Visible in Scoreboard"), false, new ConfigDescription("If enabled, the Growth Nectar buff indicator will always be visible when opening the scoreboard (TAB)", (AcceptableValueBase)null, Array.Empty<object>())); } private static BuffIcon BuffDisplay_GetNewBuffIcon(orig_GetNewBuffIcon orig, BuffDisplay self) { BuffIcon obj = orig.Invoke(self); GrowthNectarBuffIndicatorController growthNectarBuffIndicatorController = default(GrowthNectarBuffIndicatorController); if (((Component)obj).TryGetComponent<GrowthNectarBuffIndicatorController>(ref growthNectarBuffIndicatorController)) { growthNectarBuffIndicatorController.OwnerBuffDisplay = self; } return obj; } private void Awake() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) _buffIcon = ((Component)this).GetComponent<BuffIcon>(); _indicatorRoot = new GameObject("GrowthNectarIndicator"); RectTransform obj = _indicatorRoot.AddComponent<RectTransform>(); ((Transform)obj).SetParent(((Component)this).transform); obj.anchorMin = new Vector2(0f, 0f); obj.anchorMax = new Vector2(0f, 0f); obj.sizeDelta = new Vector2(12f, 12f); obj.anchoredPosition = new Vector2(6f, 6f); _indicatorImage = _indicatorRoot.AddComponent<Image>(); ((Graphic)_indicatorImage).raycastTarget = false; } private void OnEnable() { _buffSource = null; refreshIndicator(); } private void FixedUpdate() { refreshIndicator(); } private void refreshIndicator() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) CharacterBody buffSource = null; if (Object.op_Implicit((Object)(object)OwnerBuffDisplay)) { buffSource = OwnerBuffDisplay.source; } _buffSource = buffSource; bool flag = shouldShowIndicator(); if (Object.op_Implicit((Object)(object)_indicatorRoot)) { _indicatorRoot.SetActive(flag); } if (flag && Object.op_Implicit((Object)(object)_indicatorImage)) { Sprite growthNectarBuffIndicatorSprite = Assets.GrowthNectarBuffIndicatorSprite; Color value = IndicatorColorConfig.Value; _indicatorImage.sprite = growthNectarBuffIndicatorSprite; ((Graphic)_indicatorImage).color = value; } } private bool shouldShowIndicator() { BuffDef val = (Object.op_Implicit((Object)(object)_buffIcon) ? _buffIcon.buffDef : null); if (!Object.op_Implicit((Object)(object)val) || val.isHidden || val.ignoreGrowthNectar) { return false; } if (!Object.op_Implicit((Object)(object)_buffSource) || !_buffSource.isPlayerControlled) { return false; } bool flag = false; if (AlwaysShowOnScoreboardOpenConfig.Value) { foreach (HUD readOnlyInstance in HUD.readOnlyInstanceList) { if (Object.op_Implicit((Object)(object)readOnlyInstance.scoreboardPanel) && readOnlyInstance.scoreboardPanel.activeSelf) { flag = true; break; } } } if (!flag && RequireItemInInventoryConfig.Value) { Inventory inventory = _buffSource.inventory; if (!Object.op_Implicit((Object)(object)inventory) || inventory.GetItemCount(Items.BoostAllStats) <= 0) { return false; } } return true; } } }