Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of MeditateReminder v1.0.0
MeditateReminder.dll
Decompiled 3 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using On.RoR2; using On.RoR2.UI; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.UI; [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("MeditateReminder")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MeditateReminder")] [assembly: AssemblyTitle("MeditateReminder")] [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 MeditateReminder { internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Birbski.MeditateReminder", "MeditateReminder", "1.0.0")] public class MeditateReminder : BaseUnityPlugin { [CompilerGenerated] private sealed class <<SendMessage>g__ShowMessage|44_0>d : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public MeditateReminder <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <<SendMessage>g__ShowMessage|44_0>d(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown int num = <>1__state; MeditateReminder meditateReminder = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; meditateReminder.goReminder.SetActive(true); <>2__current = (object)new WaitForSeconds(revealTime.Value); <>1__state = 1; return true; case 1: <>1__state = -1; meditateReminder.goReminder.SetActive(false); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const string PluginGUID = "Birbski.MeditateReminder"; public const string PluginAuthor = "Birbski"; public const string PluginName = "MeditateReminder"; public const string PluginVersion = "1.0.0"; private const float placementMin = 0.01f; private const float placementMax = 1f; private const int fontSizeMin = 8; private const int fontSizeMax = 96; private const float timerMin = 1f; private const float timerMax = 5f; private TextMeshProUGUI reminderText; private GameObject goReminder; private BodyIndex seekerBodyIndex; private float prevCd; public static ConfigEntry<bool> useChat { get; set; } public static ConfigEntry<float> xPlacement { get; set; } public static ConfigEntry<float> yPlacement { get; set; } public static ConfigEntry<int> fontSize { get; set; } public static ConfigEntry<Color> fontColor { get; set; } public static ConfigEntry<float> revealTime { get; set; } public void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown //IL_0168: Expected O, but got Unknown //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown //IL_01ba: Expected O, but got Unknown //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Expected O, but got Unknown //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: 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) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Expected O, but got Unknown //IL_01ef: Expected O, but got Unknown //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Expected O, but got Unknown //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Expected O, but got Unknown //IL_0215: Expected O, but got Unknown //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Expected O, but got Unknown //IL_021f: 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) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0245: 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) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Expected O, but got Unknown //IL_0267: Expected O, but got Unknown //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Expected O, but got Unknown //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Expected O, but got Unknown //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Expected O, but got Unknown //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Expected O, but got Unknown Log.Init(((BaseUnityPlugin)this).Logger); seekerBodyIndex = BodyCatalog.FindBodyIndex("SeekerBody"); useChat = ((BaseUnityPlugin)this).Config.Bind<bool>("-", "SendInChat", false, "Show reminder in chat rather than on screen"); xPlacement = ((BaseUnityPlugin)this).Config.Bind<float>("-", "XPlacement", 0.4f, "Placement of reminder text on X Axis (0 - 1.0)"); yPlacement = ((BaseUnityPlugin)this).Config.Bind<float>("-", "YPlacement", 0.4f, "Placement of reminder text on Y Axis (0 - 1.0)"); fontSize = ((BaseUnityPlugin)this).Config.Bind<int>("-", "FontSize", 28, "Size of reminder text"); fontColor = ((BaseUnityPlugin)this).Config.Bind<Color>("-", "FontColor", Color.cyan, "Color of reminder text"); revealTime = ((BaseUnityPlugin)this).Config.Bind<float>("-", "RevealTime", 3f, "How many seconds the reminder text is on screen"); Sprite val = LoadSprite(); if ((Object)(object)val != (Object)null) { ModSettingsManager.SetModIcon(val); } ModSettingsManager.SetModDescription("A reminder for those of us who can't be bothered to look and see if Meditate is off of cooldown or not"); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(useChat)); ModSettingsManager.AddOption((BaseOption)new SliderOption(xPlacement, (SliderConfig)new StepSliderConfig { min = 0.01f, max = 1f, increment = 0.01f, FormatString = "{0:0.0}", checkIfDisabled = new IsDisabledDelegate(CheckToEnableOptions) })); ModSettingsManager.AddOption((BaseOption)new SliderOption(yPlacement, (SliderConfig)new StepSliderConfig { min = 0.01f, max = 1f, increment = 0.01f, FormatString = "{0:0.0}", checkIfDisabled = new IsDisabledDelegate(CheckToEnableOptions) })); ModSettingsManager.AddOption((BaseOption)new IntSliderOption(fontSize, new IntSliderConfig { min = 8, max = 96, checkIfDisabled = new IsDisabledDelegate(CheckToEnableOptions) })); ModSettingsManager.AddOption((BaseOption)new ColorOption(fontColor, new ColorOptionConfig { checkIfDisabled = new IsDisabledDelegate(CheckToEnableOptions) })); ModSettingsManager.AddOption((BaseOption)new SliderOption(revealTime, (SliderConfig)new StepSliderConfig { min = 1f, max = 5f, increment = 1f, FormatString = "{0:0}", checkIfDisabled = new IsDisabledDelegate(CheckToEnableOptions) })); CharacterBody.FixedUpdate += new hook_FixedUpdate(CharacterBody_FixedUpdate); CharacterBody.OnDestroy += new hook_OnDestroy(CharacterBody_OnDestroy); HUD.Awake += new hook_Awake(HUD_Awake); } private void OnDestroy() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown CharacterBody.FixedUpdate -= new hook_FixedUpdate(CharacterBody_FixedUpdate); CharacterBody.OnDestroy -= new hook_OnDestroy(CharacterBody_OnDestroy); HUD.Awake -= new hook_Awake(HUD_Awake); } private void CharacterBody_OnDestroy(orig_OnDestroy orig, CharacterBody self) { prevCd = 0f; orig.Invoke(self); } private bool CheckToEnableOptions() { return useChat.Value; } private void CharacterBody_FixedUpdate(orig_FixedUpdate orig, CharacterBody self) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0021: 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) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); if ((int)seekerBodyIndex == -1) { seekerBodyIndex = BodyCatalog.FindBodyIndex("SeekerBody"); } if (self.bodyIndex != seekerBodyIndex || (Object)(object)self.master == (Object)null || !self.master.hasEffectiveAuthority) { return; } SkillLocator skillLocator = self.skillLocator; if ((Object)(object)skillLocator == (Object)null) { return; } GenericSkill special = skillLocator.special; if (!((Object)(object)special == (Object)null)) { ((Object)((Component)self).gameObject).GetInstanceID(); float cooldownRemaining = special.cooldownRemaining; if (prevCd > 0f && cooldownRemaining <= 0f && self.GetBuffCount(Buffs.ChakraBuff) < 7) { SendMessage(); } prevCd = cooldownRemaining; } } private void HUD_Awake(orig_Awake orig, HUD self) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); goReminder = new GameObject("MeditateReminderText"); goReminder.transform.SetParent(self.mainUIPanel.transform); reminderText = goReminder.AddComponent<TextMeshProUGUI>(); ((TMP_Text)reminderText).fontSize = fontSize.Value; ((Graphic)reminderText).color = fontColor.Value; ((TMP_Text)reminderText).text = "Refresh meditate!"; RectTransform rectTransform = ((TMP_Text)reminderText).rectTransform; rectTransform.anchorMin = new Vector2(xPlacement.Value, yPlacement.Value); rectTransform.anchorMax = new Vector2(xPlacement.Value, yPlacement.Value); rectTransform.anchoredPosition = Vector2.zero; goReminder.SetActive(false); } private void SendMessage() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if (useChat.Value) { Chat.AddMessage("<color=yellow>Refresh meditate!</color>"); } else if (Object.op_Implicit((Object)(object)goReminder)) { CheckLimits(); ((TMP_Text)reminderText).fontSize = fontSize.Value; ((Graphic)reminderText).color = fontColor.Value; RectTransform rectTransform = ((TMP_Text)reminderText).rectTransform; rectTransform.anchorMin = new Vector2(xPlacement.Value, yPlacement.Value); rectTransform.anchorMax = new Vector2(xPlacement.Value, yPlacement.Value); rectTransform.anchoredPosition = Vector2.zero; ((MonoBehaviour)this).StartCoroutine(ShowMessage()); } [IteratorStateMachine(typeof(<<SendMessage>g__ShowMessage|44_0>d))] IEnumerator ShowMessage() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <<SendMessage>g__ShowMessage|44_0>d(0) { <>4__this = this }; } } private void CheckLimits() { if (xPlacement.Value < 0.01f) { xPlacement.Value = 0.01f; } if (xPlacement.Value > 1f) { xPlacement.Value = 1f; } if (yPlacement.Value < 0.01f) { yPlacement.Value = 0.01f; } if (yPlacement.Value > 1f) { yPlacement.Value = 1f; } if (((TMP_Text)reminderText).fontSize < 8f) { ((TMP_Text)reminderText).fontSize = 8f; } if (((TMP_Text)reminderText).fontSize > 96f) { ((TMP_Text)reminderText).fontSize = 96f; } if (revealTime.Value < 1f) { revealTime.Value = 1f; } if (revealTime.Value > 5f) { revealTime.Value = 5f; } } private Sprite LoadSprite() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) string path = Paths.PluginPath + "\\Birbski-MeditateReminder\\icon.png"; if (!File.Exists(path)) { Log.Error("Logo File does not exist"); return null; } byte[] array = File.ReadAllBytes(path); Texture2D val = new Texture2D(256, 256, (TextureFormat)5, false); if (!ImageConversion.LoadImage(val, array)) { Log.Error("Texture load error"); return null; } ((Texture)val).filterMode = (FilterMode)1; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); } } }