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 LogbookMarkRead v1.0.0
plugins/LogbookMarkRead.dll
Decompiled 13 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using EntityStates; using HarmonyLib; using Microsoft.CodeAnalysis; using RoR2; using RoR2.UI; using RoR2.UI.LogBook; using TMPro; using UnityEngine; using UnityEngine.Events; 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("crygup")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Adds a button to the logbook to mark an entire section as read.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+b777ca2b76964cd6b18fe897b52a89d565d49e0f")] [assembly: AssemblyProduct("LogbookMarkRead")] [assembly: AssemblyTitle("LogbookMarkRead")] [assembly: AssemblyVersion("1.0.0.0")] [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; } } } namespace LogbookMarkRead { [BepInPlugin("local.liz.logbookmarkread", "Logbook Mark Read", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { public const string Id = "local.liz.logbookmarkread"; internal static ManualLogSource Log; private Harmony harmony; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; harmony = new Harmony("local.liz.logbookmarkread"); harmony.Patch((MethodBase)AccessTools.Method(typeof(LogBookController), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "AddButton", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void AddButton(LogBookController __instance) { if (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<PageButton>())) { ((Component)__instance).gameObject.AddComponent<PageButton>(); } } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } } public sealed class PageButton : MonoBehaviour { private static readonly FieldInfo CurrentPage = AccessTools.Field(typeof(LogBookController), "currentEntriesPageObject"); private static readonly FieldInfo CurrentCategory = AccessTools.Field(typeof(LogBookController), "currentCategoryIndex"); private LogBookController controller; private EntityStateMachine stateMachine; private MPButton button; private RectTransform rect; private RectTransform previous; private void Start() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Expected O, but got Unknown //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) try { controller = ((Component)this).GetComponent<LogBookController>(); stateMachine = ((Component)this).GetComponent<EntityStateMachine>(); previous = (RectTransform)((Component)controller.previousPageButton).transform; GameObject val = Object.Instantiate<GameObject>(controller.categoryButtonPrefab, ((Transform)previous).parent, false); ((Object)val).name = "MarkAllAsRead"; button = val.GetComponent<MPButton>(); ((Button)button).onClick = new ButtonClickedEvent(); button.onSelect = new UnityEvent(); button.onDeselect = new UnityEvent(); button.onDebugSelect = new UnityEvent(); button.onFindSelectableLeft = new UnityEvent(); button.onFindSelectableRight = new UnityEvent(); button.defaultFallbackButton = false; button.requiredTopLayer = ((Component)controller).GetComponent<UILayerKey>(); button.disableGamepadClick = false; button.disablePointerClick = false; ((UnityEvent)((Button)button).onClick).AddListener(new UnityAction(MarkCurrentCategory)); MPButton obj = button; Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)3; ((Selectable)obj).navigation = navigation; MPButton obj2 = button; HGButton val2 = (HGButton)(object)((obj2 is HGButton) ? obj2 : null); if (val2 != null) { val2.updateTextOnHover = false; } LanguageTextMeshController[] componentsInChildren = val.GetComponentsInChildren<LanguageTextMeshController>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].token = "Mark all as read"; } TMP_Text componentInChildren = val.GetComponentInChildren<TMP_Text>(true); componentInChildren.text = "Mark all as read"; componentInChildren.alignment = (TextAlignmentOptions)514; componentInChildren.enableAutoSizing = true; componentInChildren.fontSizeMin = 12f; componentInChildren.fontSizeMax = 24f; componentInChildren.enableWordWrapping = false; (val.GetComponent<LayoutElement>() ?? val.AddComponent<LayoutElement>()).ignoreLayout = true; rect = (RectTransform)val.transform; RectTransform obj3 = rect; Vector2 anchorMin = (rect.anchorMax = previous.anchorMin); obj3.anchorMin = anchorMin; rect.pivot = new Vector2(1f, 0.5f); val.SetActive(true); } catch (Exception ex) { Plugin.Log.LogError((object)("Could not add the logbook button: " + ex)); if (Object.op_Implicit((Object)(object)button)) { Object.Destroy((Object)(object)((Component)button).gameObject); } ((Behaviour)this).enabled = false; } } private bool CanMark() { if (Object.op_Implicit((Object)(object)controller) && ((Behaviour)controller).isActiveAndEnabled && controller.navigationPanel.activeInHierarchy && Object.op_Implicit((Object)(object)stateMachine) && stateMachine.state is Idle) { object? value = CurrentPage.GetValue(controller); GameObject val = (GameObject)((value is GameObject) ? value : null); if (val != null) { return val.activeInHierarchy; } } return false; } private void LateUpdate() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)button) && Object.op_Implicit((Object)(object)previous)) { ((Component)button).gameObject.SetActive(controller.navigationPanel.activeInHierarchy); ((Selectable)button).interactable = CanMark(); RectTransform obj = rect; Rect val = previous.rect; obj.SetSizeWithCurrentAnchors((Axis)0, ((Rect)(ref val)).height * 3.65f); RectTransform obj2 = rect; val = previous.rect; obj2.SetSizeWithCurrentAnchors((Axis)1, ((Rect)(ref val)).height); RectTransform obj3 = rect; RectTransform obj4 = previous; val = previous.rect; float num = ((Rect)(ref val)).xMin - 6f; val = previous.rect; ((Transform)obj3).position = ((Transform)obj4).TransformPoint(new Vector3(num, ((Rect)(ref val)).center.y)); } } private void MarkCurrentCategory() { if (!CanMark()) { return; } try { int num = (int)CurrentCategory.GetValue(controller); if (num >= 0 && num < LogBookController.categories.Length) { LocalUser? obj = ((IEnumerable<LocalUser>)LocalUserManager.readOnlyLocalUsersList).FirstOrDefault((Func<LocalUser, bool>)((LocalUser v) => v != null)); UserProfile val = ((obj != null) ? obj.userProfile : null); int num2 = PageRead.MarkCategory(LogBookController.categories[num].viewableNode, val); if (num2 > 0) { val.SaveIfNecessary(); } Plugin.Log.LogInfo((object)$"Marked {num2} logbook entries as read in the selected category."); } } catch (Exception ex) { Plugin.Log.LogError((object)("Could not mark the logbook category as read: " + ex)); } } private void OnDestroy() { if (Object.op_Implicit((Object)(object)button)) { Object.Destroy((Object)(object)((Component)button).gameObject); } } } internal static class PageRead { internal static int MarkCategory(Node category, UserProfile profile) { return Mark(((category != null) ? (from node in category.Descendants() select node.fullName) : null) ?? Enumerable.Empty<string>(), profile); } internal static int Mark(IEnumerable<string> names, UserProfile profile) { if (profile == null) { return 0; } int num = 0; foreach (string name in names) { if (!string.IsNullOrEmpty(name) && !profile.HasViewedViewable(name)) { Node val = ViewablesCatalog.FindNode(name); if (val != null && !val.isFolder && val.shouldShowUnviewed(profile)) { profile.MarkViewableAsViewed(name); num++; } } } return num; } } }