private string CreatePath(ItemSpawnerV2.PageMode Page, ItemSpawnerID ID)
        {
            string path = Page.ToString();

            //If the category is meatfortress, include it
            if (ID.Category == ItemSpawnerID.EItemCategory.MeatFortress)
            {
                path += "/" + ID.Category.ToString();
            }

            //If the category is modded, include it
            else if (!Enum.IsDefined(typeof(ItemSpawnerID.EItemCategory), ID.Category) && IM.CDefInfo.ContainsKey(ID.Category))
            {
                path += "/" + IM.CDefInfo[ID.Category].DisplayName;
            }

            //Include all subcategories that aren't none
            if (ID.SubCategory != ItemSpawnerID.ESubCategory.None)
            {
                if (Enum.IsDefined(typeof(ItemSpawnerID.ESubCategory), ID.SubCategory))
                {
                    path += "/" + ID.SubCategory.ToString();
                }

                else if (IM.CDefSubInfo.ContainsKey(ID.SubCategory))
                {
                    path += "/" + IM.CDefSubInfo[ID.SubCategory].DisplayName;
                }
            }

            path += "/" + MainObjectID;

            return(path);
        }
Exemplo n.º 2
0
 private void HideItemFromCategories(ItemSpawnerID ID)
 {
     foreach (List <string> pageItems in IM.Instance.PageItemLists.Values)
     {
         pageItems.Remove(ID.MainObject.ItemID);
     }
 }
Exemplo n.º 3
0
        private GameObject UpdateCurrentGameObj(GameObject obj)
        {
            if (obj != null)
            {
                m_currentGameObj       = obj;
                m_currentFVRObj        = null;
                m_currentFVRPhysObj    = null;
                m_currentItemSpawnerID = null;

                if (m_currentGameObj.GetComponentInChildren <FVRPhysicalObject>() != null)
                {
                    m_currentFVRPhysObj    = m_currentGameObj.GetComponentInChildren <FVRPhysicalObject>();
                    m_currentFVRObj        = m_currentFVRPhysObj.ObjectWrapper;
                    m_currentItemSpawnerID = m_currentFVRPhysObj.IDSpawnedFrom;

#if !UNITY_EDITOR && !UNITY_STANDALONE
                    if (m_currentFVRObj != null && IM.HasSpawnedID(m_currentFVRObj.SpawnedFromId))
                    {
                        m_currentItemSpawnerID = IM.GetSpawnerID(m_currentFVRObj.SpawnedFromId);
                    }
#endif
                }
                SpawnerRefreshElements();
            }

            return(m_currentGameObj);
        }
Exemplo n.º 4
0
 private void AddFTWMagToItemSpawnerPage(ItemSpawnerID item)
 {
     IM.SCD.TryGetValue(ItemSpawnerID.ESubCategory.PDW, out var pdwSubCatIDs);
     foreach (var id in pdwSubCatIDs)
     {
         if (id.ItemID == "FTW.mag.MP7.20")
         {
             Array.Resize(ref item.Secondaries, 3);
             item.Secondaries[2] = id;
             break;
         }
     }
 }
Exemplo n.º 5
0
        public void CopyFromItemSpawner()
        {
#if !UNITY_EDITOR && !UNITY_STANDALONE
            foreach (ItemSpawnerUI spawner in FindObjectsOfType <ItemSpawnerUI>())
            {
                ItemSpawnerID id = (ItemSpawnerID)AccessTools.Field(typeof(ItemSpawnerUI), "m_curID").GetValue(spawner);
                if (id != null && id.MainObject != null)
                {
                    UpdateCurrentGameObj(id.MainObject);
                }
            }
#endif
        }
Exemplo n.º 6
0
        private static void PopulateSpawnerEntries()
        {
            foreach (KeyValuePair <ItemSpawnerV2.PageMode, List <string> > PageLists in IM.Instance.PageItemLists)
            {
                foreach (string ItemID in PageLists.Value)
                {
                    ItemSpawnerID SpawnerID = IM.Instance.SpawnerIDDic[ItemID];

                    ItemSpawnerEntry SpawnerEntry = ScriptableObject.CreateInstance <ItemSpawnerEntry>();
                    SpawnerEntry.LegacyPopulateFromID(PageLists.Key, SpawnerID, false);
                    ItemLoader.PopulateEntryPaths(SpawnerEntry, SpawnerID);
                }
            }
        }
Exemplo n.º 7
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);
                }
            }
        }
Exemplo n.º 8
0
        private void ReplaceItemSpawnerIcon(ItemSpawnerID itemSpawnerId, string path)
        {
            if (!itemSpawnerId.Sprite)
            {
                return;
            }
            Sideloader.LogDebug(
                $"ItemSpawnerID Icon: {string.Join(":", new[] {path, itemSpawnerId.Sprite.name, itemSpawnerId.Sprite.texture.name})}");
            var mod = AssetTree.Find(path, itemSpawnerId.Sprite.name, itemSpawnerId.Sprite.texture.name)
                      .FirstOrDefault();

            if (mod == null)
            {
                return;
            }
            var tex    = mod.Mod.LoadTexture(mod.FullPath);
            var sprite = Sprite.Create(tex, itemSpawnerId.Sprite.rect, itemSpawnerId.Sprite.pivot,
                                       itemSpawnerId.Sprite.pixelsPerUnit, 0, SpriteMeshType.Tight, itemSpawnerId.Sprite.border);

            itemSpawnerId.Sprite = sprite;
        }
Exemplo n.º 9
0
        public void Update()
        {
            if (Helpers.BepInExGetKeyDown(_shortcutPrintLayerAndTagsInfo.Value))
            {
                string LayerNames = "Layers:";
                for (int i = 0; i < 32; i++)
                {
                    LayerNames += $"\n{i} - {LayerMask.LayerToName(i)}";
                }
                Debug.Log(LayerNames);

                string LayerCollisions = "Layer Collisions: (+ for ignoring)\n";
                LayerCollisions += "   |  0|  1|  2|  3|  4|  5|  6|  7|  8|  9| 10| 11| 12| 13| 14| 15| 16| 17| 18| 19| 20| 21| 22| 23| 24| 25| 26| 27| 28| 29| 30| 31|";
                for (int i = 0; i < 32; i++)
                {
                    LayerCollisions += $"\n{i,3}|";
                    for (int j = 0; j < 32; j++)
                    {
                        LayerCollisions += !Physics.GetIgnoreLayerCollision(2 ^ i, 2 ^ j) ? " + |" : "   |";
                    }
                }
                Debug.Log(LayerCollisions);
            }
            else if (Helpers.BepInExGetKeyDown(_shortcutPrintAllStreamingAssetsBundles.Value))
            {
                string ootpoot = "";

                foreach (string assBundle in System.IO.Directory.GetFiles(Application.streamingAssetsPath))
                {
                    if (!assBundle.Contains("."))
                    {
                        AssetBundle asset = AnvilManager.GetBundleAsync(System.IO.Path.GetFileName(assBundle)).Result;
                        if (asset != null)
                        {
                            string[] names = System.IO.Path.GetFileName(assBundle).Split(new[] { "_" }, StringSplitOptions.None);
                            string   name  = names[names.Length - 1];
                            ootpoot += $"{name}: {string.Join($"\n{name}: ", asset.GetAllAssetNames())}\n\n\n";
                        }
                    }
                }

                foreach (System.Collections.Generic.KeyValuePair <string, ItemSpawnerID> kvp in (System.Collections.Generic.Dictionary <string, ItemSpawnerID>)AccessTools.Field(typeof(IM), "SpawnerIDDic").GetValue(ManagerSingleton <IM> .Instance))
                {
                    ootpoot += $"{kvp.Key} - {kvp.Value}\n";
                }

                Debug.Log(ootpoot);
            }

            else if (Helpers.BepInExGetKeyDown(_shortcutTelePlayerToReset.Value))
            {
                GM.CurrentMovementManager.TeleportToPoint(GM.CurrentSceneSettings.DeathResetPoint.position, true);
            }
            else if (Helpers.BepInExGetKeyDown(_shortcutTelePlayer2mForward.Value))
            {
                GM.CurrentMovementManager.TeleportToPoint(GM.CurrentPlayerRoot.position + (GM.CurrentPlayerBody.Head.forward * 2.0f), true);
            }
            else if (Helpers.BepInExGetKeyDown(_shortcutTelePlayerToOrigin.Value))
            {
                GM.CurrentMovementManager.TeleportToPoint(Vector3.zero, true);
            }

            else if (Helpers.BepInExGetKeyDown(_shortcutSpawnModPanelV2.Value))
            {
                ItemSpawnerID id = IM.GetSpawnerID("MiscUtModPanelV2");
                if (id != null)
                {
                    GameObject panel = Instantiate(id.MainObject.GetGameObject(), new Vector3(0f, .25f, 0f) + GM.CurrentPlayerRoot.position, Quaternion.identity);
                    if (GM.CurrentPlayerBody.QuickbeltSlots.Count > 0)
                    {
                        foreach (FVRQuickBeltSlot qbSlot in GM.CurrentPlayerBody.QuickbeltSlots)
                        {
                            if (qbSlot.HeldObject == null && qbSlot.CurObject == null)
                            {
                                panel.GetComponent <FVRPhysicalObject>().SetQuickBeltSlot(qbSlot);
                                break;
                            }
                        }
                    }
                }
                else
                {
                    Logger.LogError("ModPanelV2 was null?");
                }
            }
            else if (Helpers.BepInExGetKeyDown(_shortcutScrambleMaterials.Value))
            {
                foreach (Renderer mr in UnityEngine.Object.FindObjectsOfType(typeof(UnityEngine.Renderer)))
                {
                    mr.material = (Resources.FindObjectsOfTypeAll(typeof(Material))[UnityEngine.Random.Range(0, Resources.FindObjectsOfTypeAll(typeof(Material)).Length)] as Material);
                }
            }
            else if (Helpers.BepInExGetKeyDown(_shortcutScrambleMeshes.Value))
            {
                foreach (MeshFilter mf in UnityEngine.Object.FindObjectsOfType(typeof(UnityEngine.MeshFilter)))
                {
                    mf.mesh = (Resources.FindObjectsOfTypeAll(typeof(Mesh))[UnityEngine.Random.Range(0, Resources.FindObjectsOfTypeAll(typeof(Mesh)).Length)] as Mesh);
                }
            }
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Pop
        /// </summary>
        /// <param name="Page"></param>
        /// <param name="ID"></param>
        public static void PopulateEntryPaths(ItemSpawnerEntry entry, ItemSpawnerID spawnerID = null)
        {
            string[] pathSegments = entry.EntryPath.Split('/');
            string   currentPath  = "";

            for (int i = 0; i < pathSegments.Length; i++)
            {
                //If we are at the full path length for this entry, we can just assign the entry
                if (i == pathSegments.Length - 1)
                {
                    EntryNode previousNode = OtherLoader.SpawnerEntriesByPath[currentPath];
                    currentPath += (i == 0 ? "" : "/") + pathSegments[i];

                    //If there is already an node at this path, we should just update it. Otherwise, add it as a new node
                    EntryNode node;
                    if (OtherLoader.SpawnerEntriesByPath.ContainsKey(currentPath))
                    {
                        node       = OtherLoader.SpawnerEntriesByPath[currentPath];
                        node.entry = entry;
                    }
                    else
                    {
                        node = new EntryNode(entry);
                        OtherLoader.SpawnerEntriesByPath[currentPath] = node;
                        previousNode.childNodes.Add(node);
                    }
                }


                //If we are at the page level, just check to see if we need to add a page node
                else if (i == 0)
                {
                    currentPath += (i == 0 ? "" : "/") + pathSegments[i];

                    if (!OtherLoader.SpawnerEntriesByPath.ContainsKey(currentPath))
                    {
                        EntryNode pageNode = new EntryNode();
                        pageNode.entry.EntryPath = currentPath;
                        OtherLoader.SpawnerEntriesByPath[currentPath] = pageNode;
                    }
                }

                //If these are just custom categories of any depth, just add the ones that aren't already loaded
                else
                {
                    EntryNode previousNode = OtherLoader.SpawnerEntriesByPath[currentPath];
                    currentPath += (i == 0 ? "" : "/") + pathSegments[i];

                    if (!OtherLoader.SpawnerEntriesByPath.ContainsKey(currentPath))
                    {
                        EntryNode node = new EntryNode();
                        node.entry.EntryPath = currentPath;
                        node.entry.IsDisplayedInMainEntry = true;

                        //Now this section below is for legacy support
                        if (spawnerID != null)
                        {
                            //If this is meatfortress category, do that
                            if (i == 1 && spawnerID.Category == ItemSpawnerID.EItemCategory.MeatFortress)
                            {
                                node.entry.EntryIcon   = IM.CDefInfo[ItemSpawnerID.EItemCategory.MeatFortress].Sprite;
                                node.entry.DisplayName = IM.CDefInfo[ItemSpawnerID.EItemCategory.MeatFortress].DisplayName;
                            }

                            //If this is a modded main category, do that
                            else if (i == 1 && !Enum.IsDefined(typeof(ItemSpawnerID.EItemCategory), spawnerID.Category))
                            {
                                if (IM.CDefInfo.ContainsKey(spawnerID.Category))
                                {
                                    node.entry.EntryIcon   = IM.CDefInfo[spawnerID.Category].Sprite;
                                    node.entry.DisplayName = IM.CDefInfo[spawnerID.Category].DisplayName;
                                }
                            }

                            //If this is a subcategory (modded or not), do that
                            else if (IM.CDefSubInfo.ContainsKey(spawnerID.SubCategory))
                            {
                                node.entry.EntryIcon   = IM.CDefSubInfo[spawnerID.SubCategory].Sprite;
                                node.entry.DisplayName = IM.CDefSubInfo[spawnerID.SubCategory].DisplayName;
                            }

                            node.entry.IsModded = IM.OD[spawnerID.MainObject.ItemID].IsModContent;
                        }

                        previousNode.childNodes.Add(node);
                        OtherLoader.SpawnerEntriesByPath[currentPath] = node;
                    }
                }
            }
        }
Exemplo n.º 12
0
        // Add 20rnd mag to mp7 page
        private void ItemSpawnerUI_Draw_Tiles_Detail(On.FistVR.ItemSpawnerUI.orig_Draw_Tiles_Detail orig, ItemSpawnerUI self, ItemSpawnerID item)
        {
            if (item.ItemID == "PDW" + MP7_ID && item.Secondaries.Length <= 2)
            {
                AddFTWMagToItemSpawnerPage(item);
            }

            orig(self, item);
        }
Exemplo n.º 13
0
        public void LegacyPopulateFromID(ItemSpawnerV2.PageMode Page, ItemSpawnerID ID, bool IsModded)
        {
            if (ID.MainObject != null)
            {
                MainObjectID = ID.MainObject.ItemID;
            }
            else
            {
                OtherLogger.LogWarning("ItemSpawnerID has a null MainObject! ItemID: " + ID.ItemID);
                MainObjectID = ID.ItemID;
            }

            if (IM.OD.ContainsKey(MainObjectID))
            {
                OtherLoader.SpawnerEntriesByID[MainObjectID] = this;
            }

            SpawnWithIDs = new List <string>();
            if (ID.SecondObject != null)
            {
                SpawnWithIDs.Add(ID.SecondObject.ItemID);
            }


            //Add secondary items to entry, being careful of null values!
            SecondaryObjectIDs = new List <string>();
            foreach (ItemSpawnerID secondary in ID.Secondaries)
            {
                if (secondary != null && secondary.MainObject != null)
                {
                    SecondaryObjectIDs.Add(secondary.MainObject.ItemID);
                }
                else if (secondary == null)
                {
                    OtherLogger.LogWarning("Failed to add secondary to item (" + MainObjectID + ") due to secondary item being null!");
                }
                else
                {
                    OtherLogger.LogWarning("Failed to add secondary to item (" + MainObjectID + ") due to null MainObject!, Secondary display name: " + secondary.DisplayName);
                }
            }

            if (ID.Secondaries_ByStringID != null)
            {
                SecondaryObjectIDs.AddRange(ID.Secondaries_ByStringID);
            }


            EntryPath   = CreatePath(Page, ID);
            EntryIcon   = ID.Sprite;
            DisplayName = ID.DisplayName;

            IsDisplayedInMainEntry = ID.IsDisplayedInMainEntry;
            UsesLargeSpawnPad      = ID.UsesLargeSpawnPad;
            this.IsModded          = IsModded;

            TutorialBlockIDs = new List <string>();
            TutorialBlockIDs.AddRange(ID.TutorialBlocks);

            ModTags = new List <string>();
            ModTags.AddRange(ID.ModTags);
        }
 public static bool IsRewardUnlockedPrefix(RewardUnlocks __instance, ref bool __result, ItemSpawnerID ID)
 {
     __result = __instance.IsRewardUnlocked(ID.ItemID);
     return(false);
 }