Beispiel #1
0
        private static bool PrevPagePatch(ItemSpawnerV2 __instance)
        {
            ItemSpawnerData data = __instance.GetComponent <ItemSpawnerData>();

            if (data.SavedPagePositions[__instance.PMode][data.CurrentDepth] > 0)
            {
                data.SavedPagePositions[__instance.PMode][data.CurrentDepth] -= 1;
                __instance.RedrawSimpleCanvas();
            }

            return(false);
        }
Beispiel #2
0
        private static bool NextPagePatch(ItemSpawnerV2 __instance)
        {
            ItemSpawnerData data = __instance.GetComponent <ItemSpawnerData>();

            if (OtherLoader.SpawnerEntriesByPath[data.CurrentPath].childNodes.Count / __instance.IMG_SimpleTiles.Count > data.SavedPagePositions[__instance.PMode][data.CurrentDepth])
            {
                data.SavedPagePositions[__instance.PMode][data.CurrentDepth] += 1;
                __instance.RedrawSimpleCanvas();
            }

            return(false);
        }
Beispiel #3
0
        private static bool PageModePatch(ItemSpawnerV2 __instance, int i)
        {
            ItemSpawnerData data = __instance.GetComponent <ItemSpawnerData>();

            data.CurrentPath  = ((ItemSpawnerV2.PageMode)i).ToString();
            data.CurrentDepth = 0;
            data.SavedPagePositions[(ItemSpawnerV2.PageMode)i] = new Dictionary <int, int>();

            data.SavedPagePositions[(ItemSpawnerV2.PageMode)i][data.CurrentDepth] = 0;

            return(true);
        }
Beispiel #4
0
        private static bool GoBackPatch(ItemSpawnerV2 __instance)
        {
            ItemSpawnerData data = __instance.GetComponent <ItemSpawnerData>();

            if (!data.CurrentPath.Contains("/"))
            {
                return(false);
            }

            data.CurrentPath = data.CurrentPath.Substring(0, data.CurrentPath.LastIndexOf("/"));
            data.SavedPagePositions[__instance.PMode][data.CurrentDepth] = 0;
            data.CurrentDepth -= 1;

            OtherLogger.Log("Going back to path: " + data.CurrentPath, OtherLogger.LogType.General);
            __instance.RedrawSimpleCanvas();

            return(false);
        }
Beispiel #5
0
        private static bool SimpleButtonPatch(ItemSpawnerV2 __instance, int i)
        {
            ItemSpawnerData data = __instance.GetComponent <ItemSpawnerData>();

            //If the entry that was selected has child entries, we should display the child entries
            if (OtherLoader.SpawnerEntriesByPath[data.VisibleEntries[i].EntryPath].childNodes.Count > 0)
            {
                data.CurrentPath   = data.VisibleEntries[i].EntryPath;
                data.CurrentDepth += 1;
                data.SavedPagePositions[__instance.PMode][data.CurrentDepth] = 0;

                __instance.RedrawSimpleCanvas();
            }

            else
            {
                OtherLogger.Log("Setting selected id to: " + data.VisibleEntries[i].MainObjectID, OtherLogger.LogType.General);

                __instance.SetSelectedID(data.VisibleEntries[i].MainObjectID);
                __instance.RedrawDetailsCanvas();
            }

            return(false);
        }
Beispiel #6
0
        private static bool SpawnItemRelated(ItemSpawnerV2 __instance, int i)
        {
            //If the selected item has a spawner entry, use that
            if (OtherLoader.SpawnerEntriesByID.ContainsKey(__instance.m_selectedID))
            {
                __instance.Boop(1);

                ItemSpawnerData data = __instance.GetComponent <ItemSpawnerData>();
                AnvilManager.Run(SpawnItems(__instance, data.VisibleSecondaryEntries[i]));
            }

            //Otherwise try to use legacy spawner ID
            else if (IM.HasSpawnedID(__instance.m_selectedID))
            {
                return(true);
            }

            else
            {
                __instance.Boop(2);
            }

            return(false);
        }
Beispiel #7
0
        private static bool RedrawSimplePatch(ItemSpawnerV2 __instance)
        {
            if (__instance.PMode == ItemSpawnerV2.PageMode.MainMenu)
            {
                return(false);
            }

            ItemSpawnerData data = __instance.GetComponent <ItemSpawnerData>();

            data.VisibleEntries.Clear();

            List <EntryNode> entries = OtherLoader.SpawnerEntriesByPath[data.CurrentPath].childNodes.Where(o => o.entry.IsDisplayedInMainEntry).ToList();

            OtherLogger.Log($"Got {entries.Count} entries for path: {data.CurrentPath}", OtherLogger.LogType.General);

            entries = entries.OrderBy(o => o.entry.DisplayName).OrderBy(o => o.entry.IsModded?1:0).OrderBy(o => o.childNodes.Count > 0?0:1).ToList();

            int currPage   = data.SavedPagePositions[__instance.PMode][data.CurrentDepth];
            int startIndex = currPage * __instance.IMG_SimpleTiles.Count;

            for (int i = 0; i < __instance.IMG_SimpleTiles.Count; i++)
            {
                if (startIndex + i < entries.Count)
                {
                    ItemSpawnerEntry entry = entries[startIndex + i].entry;
                    data.VisibleEntries.Add(entry);

                    __instance.IMG_SimpleTiles[i].gameObject.SetActive(true);
                    __instance.TXT_SimpleTiles[i].gameObject.SetActive(true);
                    __instance.IMG_SimpleTiles[i].sprite = entry.EntryIcon;
                    __instance.TXT_SimpleTiles[i].text   = entry.DisplayName;
                }
                else
                {
                    __instance.IMG_SimpleTiles[i].gameObject.SetActive(false);
                    __instance.TXT_SimpleTiles[i].gameObject.SetActive(false);
                }
            }

            int numPages = (int)Math.Ceiling((double)entries.Count / __instance.IMG_SimpleTiles.Count);

            OtherLogger.Log($"There are {numPages} pages for this entry", OtherLogger.LogType.General);

            __instance.TXT_SimpleTiles_PageNumber.text = (currPage + 1) + " / " + (numPages);
            __instance.TXT_SimpleTiles_Showing.text    =
                "Showing " +
                (currPage * __instance.IMG_SimpleTiles.Count) +
                " - " +
                (currPage * __instance.IMG_SimpleTiles.Count + data.VisibleEntries.Count) +
                " Of " +
                entries.Count;


            if (currPage > 0)
            {
                __instance.GO_SimpleTiles_PrevPage.SetActive(true);
            }
            else
            {
                __instance.GO_SimpleTiles_PrevPage.SetActive(false);
            }

            if (currPage < numPages - 1)
            {
                __instance.GO_SimpleTiles_NextPage.SetActive(true);
            }
            else
            {
                __instance.GO_SimpleTiles_NextPage.SetActive(false);
            }

            return(false);
        }
Beispiel #8
0
        private static bool RedrawDetailsCanvasPatch(ItemSpawnerV2 __instance)
        {
            OtherLogger.Log("Selected ID: " + __instance.m_selectedID, OtherLogger.LogType.General);

            //If there is no spawner entry for the selected ID, set everything to blank
            if (!OtherLoader.SpawnerEntriesByID.ContainsKey(__instance.m_selectedID))
            {
                return(true);
            }


            else
            {
                ItemSpawnerEntry entry = OtherLoader.SpawnerEntriesByID[__instance.m_selectedID];
                ItemSpawnerData  data  = __instance.GetComponent <ItemSpawnerData>();

                OtherLogger.Log("We found an entry for it!", OtherLogger.LogType.General);

                //First, fill activate some of the detail and populate it with info
                for (int l = 0; l < __instance.IM_FavButtons.Count; l++)
                {
                    __instance.IM_FavButtons[l].gameObject.SetActive(true);
                }

                __instance.IM_Detail.gameObject.SetActive(true);
                __instance.IM_Detail.sprite = entry.EntryIcon;
                __instance.TXT_Title.text   = entry.DisplayName;
                __instance.BTN_SpawnSelectedObject.SetActive(true);
                __instance.TXT_Detail.text = __instance.GetDetailText(__instance.m_selectedID);



                //Now get all the secondary entries
                List <ItemSpawnerEntry> secondaryEntries = new List <ItemSpawnerEntry>();
                for (int m = 0; m < entry.SecondaryObjectIDs.Count; m++)
                {
                    if (!OtherLoader.SpawnerEntriesByID.ContainsKey(entry.SecondaryObjectIDs[m]))
                    {
                        OtherLogger.LogWarning($"Secondary ID for ({entry.MainObjectID}) was not in entry dictionary! It will not appear! Secondary ID ({entry.SecondaryObjectIDs[m]})");
                        continue;
                    }

                    ItemSpawnerEntry secondary = OtherLoader.SpawnerEntriesByID[entry.SecondaryObjectIDs[m]];
                    if (!secondary.IsReward || GM.Rewards.RewardUnlocks.Rewards.Contains(secondary.MainObjectID))
                    {
                        secondaryEntries.Add(secondary);
                    }
                }


                //Now we create the secondaries page
                //Start by drawing the tiles
                data.VisibleSecondaryEntries.Clear();
                int startIndex = __instance.m_selectedIDRelatedPage * __instance.IM_DetailRelated.Count;
                for (int i = 0; i < __instance.IM_DetailRelated.Count; i++)
                {
                    if (startIndex + i < secondaryEntries.Count)
                    {
                        ItemSpawnerEntry secondaryEntry = secondaryEntries[startIndex + i];
                        data.VisibleSecondaryEntries.Add(secondaryEntry);

                        __instance.IM_DetailRelated[i].gameObject.SetActive(true);
                        __instance.IM_DetailRelated[i].sprite = secondaryEntry.EntryIcon;
                    }
                    else
                    {
                        __instance.IM_DetailRelated[i].gameObject.SetActive(false);
                    }
                }

                //Now handle the page selectors
                int numPages = (int)Math.Ceiling((double)secondaryEntries.Count / __instance.IM_DetailRelated.Count);
                __instance.TXT_DetailsRelatedPageNum.gameObject.SetActive(true);
                __instance.TXT_DetailsRelatedPageNum.text = (__instance.m_selectedIDRelatedPage + 1).ToString() + " / " + numPages.ToString();

                if (__instance.m_selectedIDRelatedPage > 0)
                {
                    __instance.BTN_DetailsRelatedPrevPage.SetActive(true);
                }
                else
                {
                    __instance.BTN_DetailsRelatedPrevPage.SetActive(false);
                }

                if (__instance.m_selectedIDRelatedPage < numPages - 1)
                {
                    __instance.BTN_DetailsRelatedNextPage.SetActive(true);
                }
                else
                {
                    __instance.BTN_DetailsRelatedNextPage.SetActive(false);
                }



                //Setup the tutorials panel
                for (int i = 0; i < __instance.BTNS_DetailTutorial.Count; i++)
                {
                    if (i < entry.TutorialBlockIDs.Count)
                    {
                        if (IM.TutorialBlockDic.ContainsKey(entry.TutorialBlockIDs[i]))
                        {
                            __instance.BTNS_DetailTutorial[i].gameObject.SetActive(true);
                            __instance.BTNS_DetailTutorial[i].text = IM.TutorialBlockDic[entry.TutorialBlockIDs[i]].Title;
                        }
                        else
                        {
                            __instance.BTNS_DetailTutorial[i].gameObject.SetActive(false);
                        }
                    }
                    else
                    {
                        __instance.BTNS_DetailTutorial[i].gameObject.SetActive(false);
                    }
                }



                //Setup the favorites icons
                for (int i = 0; i < __instance.IM_FavButtons.Count; i++)
                {
                    if (ManagerSingleton <IM> .Instance.ItemMetaDic.ContainsKey(__instance.m_selectedID) && ManagerSingleton <IM> .Instance.ItemMetaDic[__instance.m_selectedID].ContainsKey(TagType.Favorites) && ManagerSingleton <IM> .Instance.ItemMetaDic[__instance.m_selectedID][TagType.Favorites].Contains(__instance.FaveTags[i]))
                    {
                        __instance.IM_FavButtons[i].sprite = __instance.IM_FavButton_Faved[i];
                    }
                    else
                    {
                        __instance.IM_FavButtons[i].sprite = __instance.IM_FavButton_UnFaved[i];
                    }
                }
            }


            return(false);
        }