diff --git a/ItemChecklist.cs b/ItemChecklist.cs index 85f2445..cf06278 100644 --- a/ItemChecklist.cs +++ b/ItemChecklist.cs @@ -21,12 +21,14 @@ public class ItemChecklist : Mod internal static UserInterface ItemChecklistInterface; internal ItemChecklistUI ItemChecklistUI; internal event Action OnNewItem; + internal List UnfindableItems; public override void Load() { // Latest uses ItemID.Sets.IsAMaterial, added 0.10.1.5 instance = this; ToggleChecklistHotKey = KeybindLoader.RegisterKeybind(this, "Toggle Item Checklist", "I"); + UnfindableItems = new List(); MagicStorageIntegration.Load(); if (!Main.dedServ) @@ -44,6 +46,7 @@ public override void Unload() instance = null; ToggleChecklistHotKey = null; ItemChecklistInterface = null; + UnfindableItems = null; MagicStorageIntegration.Unload(); UIElements.UICheckbox.checkboxTexture = null; @@ -85,6 +88,42 @@ public override object Call(params object[] args) OnNewItem += callback; return "RegisterSuccess"; } + else if (message == "RegisterUnfindableItems") + { + int[] unfindableItems = args[1] as int[]; + for (var i = 0; i < unfindableItems; i++) + { + if (unfindableItems[i] < 0 || unfindableItems[i] > ItemLoader.ItemCount) + { + throw new IndexOutOfRangeException("Attempted to register item type out of range"); + } + if (!UnfindableItems.Contains(unfindableItems[i]) + { + UnfindableItems.Add(unfindableItems[i]); + } + } + return "RegisterSuccess"; + } + else if (message == "ModifyFindableFlag") + { + if (Main.gameMenu) + { + return "NotInGame"; + } + int type = args[1] as int; + bool findable = args[2] as bool; + Main.LocalPlayer.GetModPlayer().findableItems[type] = findable; + return "ModifySuccess"; + } + else if (message == "IsFindable") + { + if (Main.gameMenu) + { + return null; + } + int type = args[1] as int; + return Main.LocalPlayer.GetModPlayer().findableItems[type]; + } else { Logger.Error("ItemChecklist Call Error: Unknown Message: " + message); diff --git a/ItemChecklistPlayer.cs b/ItemChecklistPlayer.cs index 9835804..0657e99 100644 --- a/ItemChecklistPlayer.cs +++ b/ItemChecklistPlayer.cs @@ -74,7 +74,7 @@ public override void Initialize() findableItems = new bool[ItemLoader.ItemCount]; for (int i = 0; i < ItemLoader.ItemCount; i++) { - if (i > 0 && !ItemID.Sets.Deprecated[i] && ItemLoader.GetItem(i) is not Terraria.ModLoader.Default.UnloadedItem && ItemChecklistUI.vanillaIDsInSortOrder != null && ItemChecklistUI.vanillaIDsInSortOrder[i] != -1) // TODO, is this guaranteed? + if (i > 0 && !ItemID.Sets.Deprecated[i] && ItemLoader.GetItem(i) is not Terraria.ModLoader.Default.UnloadedItem && ItemChecklistUI.vanillaIDsInSortOrder != null && ItemChecklistUI.vanillaIDsInSortOrder[i] != -1 && !ItemChecklist.instance.UnfindableItems.Contains(i)) // TODO, is this guaranteed? { totalItemsToFind++; findableItems[i] = true;