示例#1
0
        public IEnumerator RegisterAssetLoadLate(string bundlePath, string bundleName, LoadOrderType loadOrder)
        {
            //In order to get this bundle to load later, we want to replace the file path for the already loaded FVRObject
            string bundleID = bundlePath.Replace(bundleName, "") + " : " + bundleName.Replace("late_", "");

            OtherLoader.ManagedBundles[bundleID] = bundlePath;
            LoaderStatus.TrackLoader(bundleID, loadOrder);

            AnvilCallbackBase anvilCallbackBase;

            if (AnvilManager.m_bundles.TryGetValue(bundleID, out anvilCallbackBase))
            {
                AnvilManager.m_bundles.m_lookup.Remove(bundleID);
                AnvilManager.m_bundles.m_loading.Remove(anvilCallbackBase);

                if (OtherLoader.LogLoading.Value)
                {
                    OtherLogger.Log("Registered asset bundle to load later (" + bundlePath + ")", OtherLogger.LogType.General);
                    OtherLogger.Log("This bundle will replace the data bundle (" + bundleID + ")", OtherLogger.LogType.Loading);
                }
                else
                {
                    OtherLogger.Log("Registered asset bundle to load later (" + bundleName + ")", OtherLogger.LogType.General);
                    OtherLogger.Log("This bundle will replace the data bundle (" + LoaderUtils.GetBundleNameFromUniqueID(bundleID) + ")", OtherLogger.LogType.Loading);
                }
            }
            else
            {
                OtherLogger.LogError("Tried to register bundle to load later, but pre-bundle had not yet been loaded! (" + bundleID + ")");
            }

            yield return(null);
        }
示例#2
0
        private static bool SpawnItemDetails(ItemSpawnerV2 __instance)
        {
            OtherLogger.Log("Trying to spawn: " + __instance.m_selectedID, OtherLogger.LogType.General);

            //If the selected item has a spawner entry, use that
            if (OtherLoader.SpawnerEntriesByID.ContainsKey(__instance.m_selectedID))
            {
                OtherLogger.Log("Using normal spawn", OtherLogger.LogType.General);

                __instance.Boop(1);
                AnvilManager.Run(SpawnItems(__instance, OtherLoader.SpawnerEntriesByID[__instance.m_selectedID]));
            }

            //Otherwise try to use legacy spawner ID
            else if (IM.HasSpawnedID(__instance.m_selectedID))
            {
                OtherLogger.Log("Using legacy spawn", OtherLogger.LogType.General);

                return(true);
            }

            else
            {
                __instance.Boop(2);
            }

            return(false);
        }
示例#3
0
 private void LoadHandlingReleaseSetEntries(UnityEngine.Object[] allAssets)
 {
     foreach (HandlingReleaseSet releaseSet in allAssets)
     {
         OtherLogger.Log("Loading new handling release set entry: " + releaseSet.name, OtherLogger.LogType.Loading);
         ManagerSingleton <SM> .Instance.m_handlingReleaseDic.Add(releaseSet.Type, releaseSet);
     }
 }
示例#4
0
 private void LoadHandlingGrabSetEntries(UnityEngine.Object[] allAssets)
 {
     foreach (HandlingGrabSet grabSet in allAssets)
     {
         OtherLogger.Log("Loading new handling grab set entry: " + grabSet.name, OtherLogger.LogType.Loading);
         ManagerSingleton <SM> .Instance.m_handlingGrabDic.Add(grabSet.Type, grabSet);
     }
 }
示例#5
0
 private void LoadHandlingSlotSetEntries(UnityEngine.Object[] allAssets)
 {
     foreach (HandlingReleaseIntoSlotSet slotSet in allAssets)
     {
         OtherLogger.Log("Loading new handling QB slot set entry: " + slotSet.name, OtherLogger.LogType.Loading);
         ManagerSingleton <SM> .Instance.m_handlingReleaseIntoSlotDic.Add(slotSet.Type, slotSet);
     }
 }
        public static bool Patch_AddScreens(OptionsScreen_Quickbelt __instance)
        {
            //make the page handler; this handles changing pages
            var pageHandler = __instance.gameObject.AddComponent <QBslotPageHandler>();

            pageHandler.QBslotButtonSet = __instance.OBS_SlotStyle;

            GameObject template = __instance.OBS_Handedness.ButtonsInSet[0].gameObject;          //get and save a template- we'll use this to make the other buttons

            foreach (FVRPointableButton qb in __instance.OBS_SlotStyle.ButtonsInSet)             //delete all the currently existing buttons
            {
                Object.Destroy(qb.gameObject);
            }

            //remake the ButtonsInSet array that holds all the QB buttons
            __instance.OBS_SlotStyle.ButtonsInSet = new FVRPointableButton[GM.Instance.QuickbeltConfigurations.Length];
            for (var i = 0; i < __instance.OBS_SlotStyle.ButtonsInSet.Length; i++)
            {
                int pagePos = i % QBS_PER_PAGE;                 //14 QBs per page + 2 for page nav (qbs_per_page is default 14)
                int column  = pagePos % 4;                      // 4 QBs per column
                var row     = (int)Mathf.Floor((pagePos / 4f)); //4QBs per row

                //set fistvr button location / references
                //spawn off template; set proper parent
                OtherLogger.Log("Adding QB " + GM.Instance.QuickbeltConfigurations[i].name, OtherLogger.LogType.Loading);
                GameObject         newButton        = Object.Instantiate(template, __instance.OBS_SlotStyle.transform, true);
                FVRPointableButton newButtonsButton = newButton.GetComponent <FVRPointableButton>(); //get pointablebutton
                __instance.OBS_SlotStyle.ButtonsInSet[i] = newButtonsButton;                         //add the pointable button to the list
                string QBname   = GM.Instance.QuickbeltConfigurations[i].name.Split('_').Last();     //get name based off prefab name
                Button uiButton = SetQBSlotOptionsPanelButton(newButton, row, column, QBname);

                //Before you ask, "__instance.SetSlotStyle(i)" will not work
                //what it calls moves with i, and i can't get it to stay. neither will
                //some hack that makes a new int on the fly based off i.

                //set the QB style
                uiButton.onClick.AddListener(() => { __instance.SetSlotStyle(uiButton.transform.GetSiblingIndex()); });
                //tell the button group handler the button's been pressed
                uiButton.onClick.AddListener(() => { __instance.OBS_SlotStyle.SetSelectedButton(uiButton.transform.GetSiblingIndex()); });
            }

            //make last page button. see the forloop for comments, it's basically the same
            GameObject pageButton         = Object.Instantiate(template, __instance.OBS_SlotStyle.transform, true);
            Button     pageButtonUIButton = SetQBSlotOptionsPanelButton(pageButton, 3, 2, "Previous Page");

            pageButtonUIButton.onClick.AddListener(() => { pageHandler.GotoPreviousPage(); });
            pageHandler.ButtonPreviousPage = pageButtonUIButton.gameObject;             //set pageHandler's prev page button

            //make next page button.
            pageButton         = Object.Instantiate(template, __instance.OBS_SlotStyle.transform, true);
            pageButtonUIButton = SetQBSlotOptionsPanelButton(pageButton, 3, 3, "Next Page");
            pageButtonUIButton.onClick.AddListener(() => { pageHandler.GotoNextPage(); });
            pageHandler.ButtonNextPage = pageButtonUIButton.gameObject;             //set pageHandler's next page button
            return(true);
        }
示例#7
0
        private void LoadImpactSetEntries(UnityEngine.Object[] allAssets)
        {
            foreach (AudioBulletImpactSet impactSet in allAssets)
            {
                OtherLogger.Log("Loading new bullet impact set entry: " + impactSet.name, OtherLogger.LogType.Loading);
                //this is probably the stupidest workaround, but it works and it's short. it just adds impactset to the impact sets
                ManagerSingleton <SM> .Instance.AudioBulletImpactSets.Concat(new AudioBulletImpactSet[] { impactSet });

                ManagerSingleton <SM> .Instance.m_bulletHitDic.Add(impactSet.Type, impactSet);
            }
        }
示例#8
0
        private void LoadSpawnerEntries(UnityEngine.Object[] allAssets)
        {
            foreach (ItemSpawnerEntry entry in allAssets)
            {
                OtherLogger.Log("Loading new item spawner entry: " + entry.EntryPath, OtherLogger.LogType.Loading);
                entry.IsModded = true;
                PopulateEntryPaths(entry);
                OtherLoader.SpawnerEntriesByID[entry.MainObjectID] = entry;

                RegisterItemIntoMetaTagSystem(entry);
            }
        }
示例#9
0
        private void LoadFVRObjects(string bundleID, UnityEngine.Object[] allAssets)
        {
            foreach (FVRObject item in allAssets)
            {
                if (item == null)
                {
                    continue;
                }

                OtherLogger.Log("Loading FVRObject: " + item.ItemID, OtherLogger.LogType.Loading);

                if (IM.OD.ContainsKey(item.ItemID))
                {
                    OtherLogger.LogError("The ItemID of FVRObject is already used! Item will not be loaded! ItemID: " + item.ItemID);
                    continue;
                }
                item.m_anvilPrefab.Bundle = bundleID;

                if (item.CreditCost == 0)
                {
                    item.CalcCreditCost();                      //calculate credit cost if not set
                }
                IM.OD.Add(item.ItemID, item);
                ManagerSingleton <IM> .Instance.odicTagCategory.AddOrCreate(item.Category).Add(item);

                ManagerSingleton <IM> .Instance.odicTagFirearmEra.AddOrCreate(item.TagEra).Add(item);

                ManagerSingleton <IM> .Instance.odicTagFirearmSize.AddOrCreate(item.TagFirearmSize).Add(item);

                ManagerSingleton <IM> .Instance.odicTagFirearmAction.AddOrCreate(item.TagFirearmAction).Add(item);

                ManagerSingleton <IM> .Instance.odicTagAttachmentMount.AddOrCreate(item.TagAttachmentMount).Add(item);

                ManagerSingleton <IM> .Instance.odicTagAttachmentFeature.AddOrCreate(item.TagAttachmentFeature).Add(item);

                item.IsModContent = true;

                foreach (FVRObject.OTagFirearmFiringMode mode in item.TagFirearmFiringModes)
                {
                    ManagerSingleton <IM> .Instance.odicTagFirearmFiringMode.AddOrCreate(mode).Add(item);
                }
                foreach (FVRObject.OTagFirearmFeedOption feed in item.TagFirearmFeedOption)
                {
                    ManagerSingleton <IM> .Instance.odicTagFirearmFeedOption.AddOrCreate(feed).Add(item);
                }
                foreach (FVRObject.OTagFirearmMount mount in item.TagFirearmMounts)
                {
                    ManagerSingleton <IM> .Instance.odicTagFirearmMount.AddOrCreate(mount).Add(item);
                }
            }
        }
示例#10
0
        private static void MetaTagPatch(ItemSpawnerID ID)
        {
            //If this IDs items didn't get added, add it to the firearm page
            if (IM.Instance.PageItemLists.ContainsKey(ItemSpawnerV2.PageMode.Firearms))
            {
                if (!IM.Instance.PageItemLists.Any(o => o.Value.Contains(ID.ItemID)) && IM.OD.ContainsKey(ID.MainObject.ItemID) && IM.OD[ID.MainObject.ItemID].IsModContent)
                {
                    OtherLogger.Log("Adding misc mod item to meta tag system: " + ID.ItemID, OtherLogger.LogType.Loading);

                    IM.AddMetaTag(ID.Category.ToString(), TagType.Category, ID.ItemID, ItemSpawnerV2.PageMode.Firearms);
                    IM.AddMetaTag(ID.SubCategory.ToString(), TagType.SubCategory, ID.ItemID, ItemSpawnerV2.PageMode.Firearms);
                }
            }
        }
示例#11
0
        private static bool LoadModdedBundlesPatch(string bundle, ref AnvilCallback <AssetBundle> __result)
        {
            if (ManagedBundles.ContainsKey(bundle))
            {
                //If this is a modded bundle, we should first check if the bundle is already loaded
                AnvilCallbackBase anvilCallbackBase;
                if (AnvilManager.m_bundles.TryGetValue(bundle, out anvilCallbackBase))
                {
                    OtherLogger.Log("Tried to load modded asset bundle, and it's already loaded : " + bundle, OtherLogger.LogType.Loading);
                    __result = anvilCallbackBase as AnvilCallback <AssetBundle>;
                    return(false);
                }

                //If the bundle is not already loaded, then load it
                else
                {
                    OtherLogger.Log("Tried to load modded asset bundle, and it's not yet loaded : " + bundle, OtherLogger.LogType.Loading);

                    AnvilCallback <AssetBundle> mainCallback = LoaderUtils.LoadAssetBundle(ManagedBundles[bundle]);
                    List <BundleInfo>           dependencies = LoaderStatus.GetBundleDependencies(bundle);

                    if (dependencies.Count > 0)
                    {
                        OtherLogger.Log("Dependencies:", OtherLogger.LogType.Loading);
                        dependencies.ForEach(o => OtherLogger.Log(ManagedBundles[o.BundleID], OtherLogger.LogType.Loading));

                        //Start with the last dependency, and loop through from second to last dep up to the first dep
                        //The first dep in the list is the dependency for all other dependencies, so it is the deepest
                        AnvilCallback <AssetBundle> dependency = LoaderUtils.LoadAssetBundle(ManagedBundles[dependencies.Last().BundleID]);
                        mainCallback.m_dependancy = dependency;
                        AnvilManager.m_bundles.Add(dependencies.Last().BundleID, dependency);

                        for (int i = dependencies.Count - 2; i >= 0; i--)
                        {
                            dependency.m_dependancy = LoaderUtils.LoadAssetBundle(ManagedBundles[dependencies[i].BundleID]);
                            dependency = dependency.m_dependancy;
                            AnvilManager.m_bundles.Add(dependencies[i].BundleID, dependency);
                        }
                    }

                    __result = mainCallback;
                    AnvilManager.m_bundles.Add(bundle, __result);
                    return(false);
                }
            }

            return(true);
        }
示例#12
0
 private void LoadQuickbeltEntries(UnityEngine.Object[] allAssets)
 {
     foreach (GameObject quickbelt in allAssets)
     {
         string[] QBnameSplit = quickbelt.name.Split('_');
         if (QBnameSplit.Length > 1)
         {
             if (QBnameSplit[QBnameSplit.Length - 2] == "QuickBelt")
             {
                 OtherLogger.Log("Adding QuickBelt " + quickbelt.name, OtherLogger.LogType.Loading);
                 Array.Resize(ref GM.Instance.QuickbeltConfigurations, GM.Instance.QuickbeltConfigurations.Length + 1);
                 GM.Instance.QuickbeltConfigurations[GM.Instance.QuickbeltConfigurations.Length - 1] = quickbelt;
             }
         }
     }
 }
示例#13
0
        private void LoadAudioImpactSetEntries(UnityEngine.Object[] allAssets)
        {
            foreach (AudioImpactSet AIS in allAssets)
            {
                //resize SM's AIS list to its length + 1, insert AIS into list
                OtherLogger.Log("Loading new Audio Impact Set: " + AIS.name, OtherLogger.LogType.Loading);
                Array.Resize(ref ManagerSingleton <SM> .Instance.AudioImpactSets, ManagerSingleton <SM> .Instance.AudioImpactSets.Length + 1);
                ManagerSingleton <SM> .Instance.AudioImpactSets[ManagerSingleton <SM> .Instance.AudioImpactSets.Length - 1] = AIS;
                //clears impactdic
                ManagerSingleton <SM> .Instance.m_impactDic = new Dictionary <ImpactType, Dictionary <MatSoundType, Dictionary <AudioImpactIntensity, AudioEvent> > >();
                //remakes impactdic
                ManagerSingleton <SM> .Instance.generateImpactDictionary(); //TODO: this is an inefficient method. pls dont remake

                //the dictionary every time a new one is added! oh well. it works
            }
        }
示例#14
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);
        }
示例#15
0
        private void LoadMechanicalAccuracyEntries(UnityEngine.Object[] allAssets)
        {
            foreach (FVRFireArmMechanicalAccuracyChart chart in allAssets)
            {
                foreach (FVRFireArmMechanicalAccuracyChart.MechanicalAccuracyEntry entry in chart.Entries)
                {
                    OtherLogger.Log("Loading new mechanical accuracy entry: " + entry.Class, OtherLogger.LogType.Loading);

                    if (!AM.SMechanicalAccuracyDic.ContainsKey(entry.Class))
                    {
                        AM.SMechanicalAccuracyDic.Add(entry.Class, entry);
                    }
                    else
                    {
                        OtherLogger.LogError("Duplicate mechanical accuracy class found, will not use one of them! Make sure you're using unique mechanical accuracy classes!");
                    }
                }
            }
        }
示例#16
0
        public void LoadLegacyAssets(CoroutineStarter starter)
        {
            if (!Directory.Exists(OtherLoader.MainLegacyDirectory))
            {
                Directory.CreateDirectory(OtherLoader.MainLegacyDirectory);
            }

            OtherLogger.Log("Plugins folder found (" + Paths.PluginPath + ")", OtherLogger.LogType.General);

            List <string> legacyPaths = Directory.GetDirectories(Paths.PluginPath, "LegacyVirtualObjects", SearchOption.AllDirectories).ToList();

            legacyPaths.Add(OtherLoader.MainLegacyDirectory);

            foreach (string legacyPath in legacyPaths)
            {
                OtherLogger.Log("Legacy folder found (" + legacyPath + ")", OtherLogger.LogType.General);

                foreach (string bundlePath in Directory.GetFiles(legacyPath, "*", SearchOption.AllDirectories))
                {
                    //Only allow files without file extensions to be loaded (assumed to be an asset bundle)
                    if (Path.GetFileName(bundlePath) != Path.GetFileNameWithoutExtension(bundlePath))
                    {
                        continue;
                    }

                    string bundleID = bundlePath.Replace(Path.GetFileName(bundlePath), "") + " : " + Path.GetFileName(bundlePath);

                    IEnumerator routine = LoadAssetsFromPathAsync(bundlePath, bundleID, "", new string[] { }, LoadOrderType.LoadUnordered, true).TryCatch <Exception>(e =>
                    {
                        OtherLogger.LogError("Failed to load mod (" + bundleID + ")");
                        OtherLogger.LogError(e.ToString());
                        LoaderStatus.UpdateProgress(bundleID, 1);
                        LoaderStatus.RemoveActiveLoader(bundleID, true);
                    });

                    starter(routine);
                }
            }
        }
示例#17
0
        private void UnloadAllModdedBundles()
        {
            foreach (string bundleID in ManagedBundles.Keys)
            {
                if (!AnvilManager.m_bundles.m_lookup.ContainsKey(bundleID))
                {
                    continue;
                }

                OtherLogger.Log("Unloading bundle: " + bundleID, OtherLogger.LogType.General);

                //Get the bundle container
                AnvilCallback <AssetBundle> bundleCallback = (AnvilCallback <AssetBundle>)AnvilManager.m_bundles.m_lookup[bundleID];

                //Remove Instances of this bundle from the anvil manager
                AnvilManager.m_bundles.m_loading.Remove(AnvilManager.m_bundles.m_lookup[bundleID]);
                AnvilManager.m_bundles.m_lookup.Remove(bundleID);

                //Unload the bundle
                bundleCallback.Result.Unload(false);
            }
        }
示例#18
0
        public IEnumerator StartAssetLoadDirect(string folderPath, string bundleName, string guid, string[] dependancies, LoadOrderType loadOrder, bool allowUnload)
        {
            OtherLogger.Log("Direct Loading Bundle (" + bundleName + ")", OtherLogger.LogType.General);

            string      bundlePath = Path.Combine(folderPath, bundleName);
            string      lateName   = "late_" + bundleName;
            string      latePath   = Path.Combine(folderPath, lateName);
            string      bundleID   = bundlePath.Replace(bundleName, "") + " : " + bundleName;
            IEnumerator afterLoad  = null;

            if (File.Exists(latePath))
            {
                afterLoad = RegisterAssetLoadLate(latePath, lateName, loadOrder);
            }

            return(LoadAssetsFromPathAsync(bundlePath, bundleID, guid, dependancies, loadOrder, allowUnload, afterLoad).TryCatch(e =>
            {
                OtherLogger.LogError("Failed to load mod (" + bundleID + ")");
                OtherLogger.LogError(e.ToString());
                LoaderStatus.UpdateProgress(bundleID, 1);
                LoaderStatus.RemoveActiveLoader(bundleID, true);
            }));
        }
        private static bool StartPatch(ItemSpawnerUI __instance)
        {
            //Make sure previous data objects on this spawner are destroyed
            ItemSpawnerDataObject dupObject = __instance.gameObject.GetComponent <ItemSpawnerDataObject>();

            if (dupObject != null)
            {
                OtherLogger.Log("Destroying duplicated ItemSpawnerDataObject", OtherLogger.LogType.General);
                UnityEngine.Object.Destroy(dupObject);
            }

            //Somehow, an extra canvas is created when loaded by Atlas, so we must clear all previous canvases as well
            Transform dupCanvas = __instance.transform.Find("LoadingTextCanvas");

            if (dupCanvas != null)
            {
                OtherLogger.Log("Destroying duplicated progress canvas", OtherLogger.LogType.General);
                UnityEngine.Object.Destroy(dupCanvas.gameObject);
            }

            __instance.gameObject.AddComponent <ItemSpawnerDataObject>();

            return(true);
        }
示例#20
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);
        }
示例#21
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);
        }
示例#22
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);
        }
示例#23
0
        private static bool DetailTextPatch(ItemSpawnerV2 __instance, string id, ref string __result)
        {
            FVRObject fvrObj;
            string    spawnerCat;
            string    spawnerSubcat;

            if (IM.Instance.SpawnerIDDic.ContainsKey(id))
            {
                OtherLogger.Log("Getting ID from spawnerID", OtherLogger.LogType.General);

                ItemSpawnerID spawnerID = IM.Instance.SpawnerIDDic[id];
                fvrObj = IM.OD[spawnerID.MainObject.ItemID];

                spawnerCat = spawnerID.Category.ToString();
                if (!Enum.IsDefined(typeof(ItemSpawnerID.EItemCategory), spawnerID.Category) && IM.CDefInfo.ContainsKey(spawnerID.Category))
                {
                    spawnerCat = IM.CDefInfo[spawnerID.Category].DisplayName;
                }

                spawnerSubcat = spawnerID.SubCategory.ToString();
                if (!Enum.IsDefined(typeof(ItemSpawnerID.ESubCategory), spawnerID.SubCategory) && IM.CDefSubInfo.ContainsKey(spawnerID.SubCategory))
                {
                    spawnerSubcat = IM.CDefSubInfo[spawnerID.SubCategory].DisplayName;
                }
            }

            else if (OtherLoader.SpawnerEntriesByID.ContainsKey(id))
            {
                OtherLogger.Log("Getting ID from otherloader", OtherLogger.LogType.General);

                spawnerCat    = "None";
                spawnerSubcat = "None";

                fvrObj = IM.OD[id];
            }

            else
            {
                OtherLogger.LogError($"The ItemID was not found to have spawner entry! ItemID: {id}");
                __result = "";
                return(false);
            }


            string text =
                "Spawner Category: " + spawnerCat + "\n" +
                "Spawner Subcategory: " + spawnerSubcat + "\n" +
                "Object Category: " + fvrObj.Category.ToString() + "\n" +
                "Set: " + fvrObj.TagSet.ToString() + "\n" +
                "Size: " + fvrObj.TagFirearmSize.ToString() + "\n" +
                "Era: " + fvrObj.TagEra.ToString() + "\n" +
                "Action: " + fvrObj.TagFirearmAction.ToString() + "\n" +
                "Round Power: " + fvrObj.TagFirearmRoundPower.ToString() + "\n" +
                "Country: " + fvrObj.TagFirearmCountryOfOrigin.ToString() + "\n" +
                "Introduction Year: " + fvrObj.TagFirearmFirstYear.ToString() + "\n" +
                "Magazine Type: " + fvrObj.MagazineType.ToString() + "\n" +
                "Round Type: " + fvrObj.RoundType.ToString() + "\n" +
                "Firing Modes: " + string.Join(",", fvrObj.TagFirearmFiringModes.Select(o => o.ToString()).ToArray()) + "\n" +
                "Feed Options: " + string.Join(",", fvrObj.TagFirearmFeedOption.Select(o => o.ToString()).ToArray()) + "\n" +
                "Mounts: " + string.Join(",", fvrObj.TagFirearmMounts.Select(o => o.ToString()).ToArray()) + "\n" +
                "Attachment Mount: " + fvrObj.TagAttachmentMount.ToString() + "\n" +
                "Attachment Feature: " + fvrObj.TagAttachmentFeature.ToString();

            __result = text;

            return(false);
        }
示例#24
0
        private void LoadBulletData(UnityEngine.Object[] allAssets)
        {
            foreach (FVRFireArmRoundDisplayData data in allAssets)
            {
                if (data == null)
                {
                    continue;
                }

                OtherLogger.Log("Loading ammo type: " + data.Type, OtherLogger.LogType.Loading);

                if (!AM.STypeDic.ContainsKey(data.Type))
                {
                    OtherLogger.Log("This is a new ammo type! Adding it to dictionary", OtherLogger.LogType.Loading);
                    AM.STypeDic.Add(data.Type, new Dictionary <FireArmRoundClass, FVRFireArmRoundDisplayData.DisplayDataClass>());
                }
                else
                {
                    OtherLogger.Log("This is an existing ammo type, will add subclasses to this type", OtherLogger.LogType.Loading);
                }

                if (!AM.STypeList.Contains(data.Type))
                {
                    AM.STypeList.Add(data.Type);
                }

                if (!AM.SRoundDisplayDataDic.ContainsKey(data.Type))
                {
                    AM.SRoundDisplayDataDic.Add(data.Type, data);
                }

                //If this Display Data already exists, then we should add our classes to the existing display data class list
                else
                {
                    List <FVRFireArmRoundDisplayData.DisplayDataClass> classes = new List <FVRFireArmRoundDisplayData.DisplayDataClass>(AM.SRoundDisplayDataDic[data.Type].Classes);
                    classes.AddRange(data.Classes);
                    AM.SRoundDisplayDataDic[data.Type].Classes = classes.ToArray();
                }

                if (!AM.STypeClassLists.ContainsKey(data.Type))
                {
                    AM.STypeClassLists.Add(data.Type, new List <FireArmRoundClass>());
                }

                foreach (FVRFireArmRoundDisplayData.DisplayDataClass roundClass in data.Classes)
                {
                    OtherLogger.Log("Loading ammo class: " + roundClass.Class, OtherLogger.LogType.Loading);
                    if (!AM.STypeDic[data.Type].ContainsKey(roundClass.Class))
                    {
                        OtherLogger.Log("This is a new ammo class! Adding it to dictionary", OtherLogger.LogType.Loading);
                        AM.STypeDic[data.Type].Add(roundClass.Class, roundClass);
                    }
                    else
                    {
                        OtherLogger.LogError("Ammo class already exists for bullet type! Bullet will not be loaded! Type: " + data.Type + ", Class: " + roundClass.Class);
                        return;
                    }

                    if (!AM.STypeClassLists[data.Type].Contains(roundClass.Class))
                    {
                        AM.STypeClassLists[data.Type].Add(roundClass.Class);
                    }
                }
            }
        }
示例#25
0
        private IEnumerator LoadAssetsFromPathAsync(string path, string bundleID, string guid, string[] dependancies, LoadOrderType loadOrder, bool allowUnload, IEnumerator afterLoad = null)
        {
            //Start tracking this bundle and then wait a frame for everything else to be tracked
            LoaderStatus.TrackLoader(bundleID, loadOrder);
            yield return(null);

            //If there are many active loaders at once, we should wait our turn
            bool overTime = false;

            while (!LoaderStatus.CanOrderedModLoad(bundleID))
            {
                if (!overTime && Time.time - LoaderStatus.LastLoadEventTime > 30)
                {
                    OtherLogger.Log("Bundle has been waiting a long time to load! (" + bundleID + ")", OtherLogger.LogType.General);
                    LoaderStatus.PrintWaitingBundles(bundleID);
                    overTime = true;
                }

                yield return(null);
            }

            //Begin the loading process
            LoaderStatus.AddActiveLoader(bundleID);

            if (OtherLoader.LogLoading.Value)
            {
                OtherLogger.Log("Beginning async loading of asset bundle (" + bundleID + ")", OtherLogger.LogType.General);
            }


            //Load the bundle and apply it's contents
            float time = Time.time;

            LoaderStatus.UpdateProgress(bundleID, UnityEngine.Random.Range(.1f, .3f));

            AnvilCallback <AssetBundle> bundle = LoaderUtils.LoadAssetBundle(path);

            yield return(bundle);

            LoaderStatus.UpdateProgress(bundleID, 0.9f);

            yield return(ApplyLoadedAssetBundleAsync(bundle, bundleID).TryCatch(e =>
            {
                OtherLogger.LogError("Failed to load mod (" + bundleID + ")");
                OtherLogger.LogError(e.ToString());
                LoaderStatus.UpdateProgress(bundleID, 1);
                LoaderStatus.RemoveActiveLoader(bundleID, true);
            }));


            //Log that the bundle is loaded
            if (OtherLoader.LogLoading.Value)
            {
                OtherLogger.Log($"[{(Time.time - time).ToString("0.000")} s] Completed loading bundle ({bundleID})", OtherLogger.LogType.General);
            }
            else
            {
                OtherLogger.Log($"[{(Time.time - time).ToString("0.000")} s] Completed loading bundle ({LoaderUtils.GetBundleNameFromUniqueID(bundleID)})", OtherLogger.LogType.General);
            }



            if (allowUnload && OtherLoader.OptimizeMemory.Value)
            {
                OtherLogger.Log("Unloading asset bundle (Optimize Memory is true)", OtherLogger.LogType.Loading);
                bundle.Result.Unload(false);
            }
            else
            {
                AnvilManager.m_bundles.Add(bundleID, bundle);
            }

            OtherLoader.ManagedBundles.Add(bundleID, path);
            LoaderStatus.UpdateProgress(bundleID, 1);
            LoaderStatus.RemoveActiveLoader(bundleID, !(OtherLoader.OptimizeMemory.Value && allowUnload));

            if (afterLoad != null)
            {
                yield return(afterLoad);
            }
        }
示例#26
0
        private void LoadSpawnerIDs(UnityEngine.Object[] allAssets)
        {
            foreach (ItemSpawnerID id in allAssets)
            {
                OtherLogger.Log("Adding Itemspawner ID! Category: " + id.Category + ", SubCategory: " + id.SubCategory, OtherLogger.LogType.Loading);

                //Try to set the main object of this ID as a secondary if the main is null (so that it gets tagged properly)
                if (id.MainObject == null && id.Secondaries.Length > 0)
                {
                    id.MainObject = id.Secondaries.Select(o => o.MainObject).FirstOrDefault(o => o != null);
                    if (id.MainObject == null)
                    {
                        OtherLogger.Log("Could not select a secondary object for ItemSpawnerID, it will not appear in spawner: Display Name: " + id.DisplayName, OtherLogger.LogType.Loading);
                    }
                    else
                    {
                        id.ItemID = id.MainObject.ItemID;
                    }
                }


                if (id.MainObject != null)
                {
                    if (id.UnlockCost == 0)
                    {
                        id.UnlockCost = id.MainObject.CreditCost;
                    }

                    IM.RegisterItemIntoMetaTagSystem(id);
                    if (!id.IsDisplayedInMainEntry)
                    {
                        HideItemFromCategories(id);
                    }
                }


                if (IM.CD.ContainsKey(id.Category) && IM.SCD.ContainsKey(id.SubCategory))
                {
                    IM.CD[id.Category].Add(id);
                    IM.SCD[id.SubCategory].Add(id);

                    if (!ManagerSingleton <IM> .Instance.SpawnerIDDic.ContainsKey(id.ItemID))
                    {
                        ManagerSingleton <IM> .Instance.SpawnerIDDic[id.ItemID] = id;

                        //Now we will try to convert this SpawnerID into a spawner entry
                        ItemSpawnerEntry SpawnerEntry = ScriptableObject.CreateInstance <ItemSpawnerEntry>();

                        //If the category is defined, we can try to add it based on what page it was given
                        if (Enum.IsDefined(typeof(ItemSpawnerID.EItemCategory), id.Category))
                        {
                            //TODO this should be done without having to loop through potentially all spawner entries, I bet this could become expensive
                            bool added = false;
                            foreach (KeyValuePair <ItemSpawnerV2.PageMode, List <string> > pageItems in IM.Instance.PageItemLists)
                            {
                                if (pageItems.Value.Contains(id.ItemID))
                                {
                                    OtherLogger.Log("Adding SpawnerID to spawner entry tree", OtherLogger.LogType.Loading);
                                    SpawnerEntry.LegacyPopulateFromID(pageItems.Key, id, true);
                                    PopulateEntryPaths(SpawnerEntry, id);
                                    added = true;

                                    break;
                                }
                            }

                            if (added)
                            {
                                continue;
                            }

                            //If we make it to this point, we failed to add the entry to the tree structure, but should still populate the entries data
                            OtherLogger.Log("ItemSpawnerID could not be converted for new spawner because of metadata issues! ItemID: " + id.ItemID, OtherLogger.LogType.Loading);
                            SpawnerEntry.LegacyPopulateFromID(ItemSpawnerV2.PageMode.Firearms, id, true);
                        }

                        //Otherwise, all custom category items go under the firearms page
                        else
                        {
                            OtherLogger.Log("Adding SpawnerID to spawner entry tree under custom category", OtherLogger.LogType.Loading);
                            SpawnerEntry.LegacyPopulateFromID(ItemSpawnerV2.PageMode.Firearms, id, true);
                            PopulateEntryPaths(SpawnerEntry, id);
                        }
                    }
                }

                else
                {
                    OtherLogger.LogError("ItemSpawnerID could not be added, because either the main category or subcategory were not loaded! Item will not appear in the itemspawner! Item Display Name: " + id.DisplayName);
                }
            }
        }
示例#27
0
        private void LoadSpawnerCategories(UnityEngine.Object[] allAssets)
        {
            foreach (ItemSpawnerCategoryDefinitions newLoadedCats in allAssets)
            {
                foreach (ItemSpawnerCategoryDefinitions.Category newCategory in newLoadedCats.Categories)
                {
                    OtherLogger.Log("Loading New ItemSpawner Category! Name (" + newCategory.DisplayName + "), Value (" + newCategory.Cat + ")", OtherLogger.LogType.Loading);


                    //If the loaded categories already contains this new category, we want to add subcategories
                    if (IM.CDefs.Categories.Any(o => o.Cat == newCategory.Cat))
                    {
                        OtherLogger.Log("Category already exists! Adding subcategories", OtherLogger.LogType.Loading);

                        foreach (ItemSpawnerCategoryDefinitions.Category currentCat in IM.CDefs.Categories)
                        {
                            if (currentCat.Cat == newCategory.Cat)
                            {
                                foreach (ItemSpawnerCategoryDefinitions.SubCategory newSubCat in newCategory.Subcats)
                                {
                                    //Only add this new subcategory if it is unique
                                    if (!IM.CDefSubInfo.ContainsKey(newSubCat.Subcat))
                                    {
                                        OtherLogger.Log("Adding subcategory: " + newSubCat.DisplayName, OtherLogger.LogType.Loading);

                                        List <ItemSpawnerCategoryDefinitions.SubCategory> currSubCatList = currentCat.Subcats.ToList();
                                        currSubCatList.Add(newSubCat);
                                        currentCat.Subcats = currSubCatList.ToArray();

                                        IM.CDefSubs[currentCat.Cat].Add(newSubCat);

                                        if (!IM.CDefSubInfo.ContainsKey(newSubCat.Subcat))
                                        {
                                            IM.CDefSubInfo.Add(newSubCat.Subcat, newSubCat);
                                        }
                                        if (!IM.SCD.ContainsKey(newSubCat.Subcat))
                                        {
                                            IM.SCD.Add(newSubCat.Subcat, new List <ItemSpawnerID>());
                                        }
                                    }

                                    else
                                    {
                                        OtherLogger.LogWarning("SubCategory type is already being used, and SubCategory will not be added! Make sure your subcategory is using a unique type! SubCategory Type: " + newSubCat.Subcat);
                                    }
                                }
                            }
                        }
                    }

                    //If new category, we can just add the whole thing
                    else
                    {
                        OtherLogger.Log("This is a new primary category", OtherLogger.LogType.Loading);

                        List <ItemSpawnerCategoryDefinitions.Category> currentCatsList = IM.CDefs.Categories.ToList();
                        currentCatsList.Add(newCategory);
                        IM.CDefs.Categories = currentCatsList.ToArray();

                        OtherLogger.Log("Num CDefs: " + IM.CDefs.Categories.Length, OtherLogger.LogType.Loading);

                        if (!IM.CDefSubs.ContainsKey(newCategory.Cat))
                        {
                            IM.CDefSubs.Add(newCategory.Cat, new List <ItemSpawnerCategoryDefinitions.SubCategory>());
                        }
                        if (!IM.CDefInfo.ContainsKey(newCategory.Cat))
                        {
                            IM.CDefInfo.Add(newCategory.Cat, newCategory);
                        }
                        if (!IM.CD.ContainsKey(newCategory.Cat))
                        {
                            IM.CD.Add(newCategory.Cat, new List <ItemSpawnerID>());
                        }

                        foreach (ItemSpawnerCategoryDefinitions.SubCategory newSubCat in newCategory.Subcats)
                        {
                            IM.CDefSubs[newCategory.Cat].Add(newSubCat);

                            if (!IM.CDefSubInfo.ContainsKey(newSubCat.Subcat))
                            {
                                IM.CDefSubInfo.Add(newSubCat.Subcat, newSubCat);
                            }
                            if (!IM.SCD.ContainsKey(newSubCat.Subcat))
                            {
                                IM.SCD.Add(newSubCat.Subcat, new List <ItemSpawnerID>());
                            }
                        }
                    }
                }
            }
        }
示例#28
0
        //Anatomy of a BundleID
        // [Mod Path] : [Bundle Name]
        // Combining these two gives you the path to the asset bundle


        public Empty LoadAssembly(FileSystemInfo handle)
        {
            OtherLogger.Log("Loading Assembly: " + handle.FullName, OtherLogger.LogType.Loading);
            Assembly.LoadFile(handle.FullName);
            return(new Empty());
        }