private PickupTier PickupIndexToPickupTier(PickupIndex pickupIndex)
        {
            var isEquipment = PickupCatalog.GetPickupDef(pickupIndex).equipmentIndex == EquipmentIndex.None ? false : true;

            if (!isEquipment)
            {
                var tier = ItemCatalog.GetItemDef((PickupCatalog.GetPickupDef(pickupIndex).itemIndex)).tier;
                switch (tier)
                {
                case ItemTier.Tier1:
                    return(PickupTier.Tier1);

                case ItemTier.Tier2:
                    return(PickupTier.Tier2);

                case ItemTier.Tier3:
                    return(PickupTier.Tier3);

                case ItemTier.Boss:
                    return(PickupTier.Boss);

                case ItemTier.Lunar:
                    return(PickupTier.Lunar);

                default:
                    return(PickupTier.None);
                }
            }
            else
            {
                var isLunar = EquipmentCatalog.GetEquipmentDef((PickupCatalog.GetPickupDef(pickupIndex).equipmentIndex)).isLunar;
                if (isLunar)
                {
                    return(PickupTier.LunarEquipment);
                }
                else
                {
                    //if (EquipmentCatalog.GetEquipmentDef((PickupCatalog.GetPickupDef(pickupIndex).equipmentIndex)).isBoss)
                    //    Debug.LogWarning("WAS A BOSS EQUIP!!? " + PickupCatalog.GetPickupDef(pickupIndex).nameToken);
                    return(PickupTier.Equipment);
                }
            }
        }
Beispiel #2
0
 private static void InitItemList()
 {
     _itemsByRarity = new List <ItemIndex>();
     foreach (ItemIndex itemIndex in ItemCatalog.allItems)
     {
         var itemDef = ItemCatalog.GetItemDef(itemIndex);
         if (itemDef.tier == ItemTier.NoTier)
         {
             continue;
         }
         _itemsByRarity.Add(itemIndex);
     }
     _itemsByRarity.Sort((a, b) =>
     {
         var definitionA = ItemCatalog.GetItemDef(a);
         var definitionB = ItemCatalog.GetItemDef(b);
         return(definitionA.tier.CompareTo(definitionB.tier));
     });
 }
Beispiel #3
0
        public static List <ItemIndex> GetDefaultDropList(ItemTier itemTier)
        {
            var list = new List <ItemIndex>();

            for (var itemIndex = ItemIndex.Syringe; itemIndex < ItemIndex.Count; itemIndex++)
            {
                if (!Run.instance.availableItems.HasItem(itemIndex))
                {
                    continue;
                }

                if (ItemCatalog.GetItemDef(itemIndex).tier == itemTier)
                {
                    list.Add(itemIndex);
                }
            }

            return(list);
        }
        private void GenericPickupController_OnTriggerStay(On.RoR2.GenericPickupController.orig_OnTriggerStay orig, GenericPickupController self, Collider other)
        {
            if (!ArtifactEnabled)
            {
                orig(self, other);
                return;
            }

            if (NetworkServer.active && self.waitStartTime.timeSince >= self.waitDuration && !self.consumed)
            {
                CharacterBody component = other.GetComponent <CharacterBody>();
                if (component)
                {
                    PickupDef pickupDef = PickupCatalog.GetPickupDef(self.pickupIndex);
                    ItemIndex itemIndex = (pickupDef != null) ? pickupDef.itemIndex : ItemIndex.None;
                    if (itemIndex != ItemIndex.None && ItemCatalog.GetItemDef(itemIndex).tier == ItemTier.Lunar && component.isPlayerControlled)
                    {
                        return;
                    }
                    EquipmentIndex equipmentIndex = (pickupDef != null) ? pickupDef.equipmentIndex : EquipmentIndex.None;
                    if (equipmentIndex != EquipmentIndex.None)
                    {
                        if (EquipmentCatalog.GetEquipmentDef(equipmentIndex).isLunar)
                        {
                            return;
                        }
                        if (component.inventory && component.inventory.currentEquipmentIndex != EquipmentIndex.None)
                        {
                            return;
                        }
                    }
                    if (pickupDef != null && pickupDef.coinValue != 0U && component.isPlayerControlled)
                    {
                        return;
                    }
                    if (GenericPickupController.BodyHasPickupPermission(component))
                    {
                        self.AttemptGrant(component);
                    }
                }
            }
        }
Beispiel #5
0
        private ItemIndex GetRandomItemIndex(ItemIndex itemIndex)
        {
            ItemDef definition = ItemCatalog.GetItemDef(itemIndex);

            List <ItemIndex> list = new List <ItemIndex>();

            switch (definition.tier)
            {
            case ItemTier.Tier1:
                list = ItemCatalog.tier1ItemList;
                break;

            case ItemTier.Tier2:
                list = ItemCatalog.tier2ItemList;
                break;

            case ItemTier.Tier3:
                list = ItemCatalog.tier3ItemList;
                break;

            case ItemTier.Lunar:
                list = ItemCatalog.lunarItemList;
                break;

            case ItemTier.Boss:
                list = ItemCatalog.allItems.ToList().FindAll(
                    iIndex => ItemCatalog.GetItemDef(iIndex).tier.Equals(ItemTier.Boss)
                    );
                break;
            }

            list = list.FindAll(
                iIndex => PreventPickupConfigEntries.ContainsKey(iIndex) && !PreventPickupConfigEntries[iIndex].Value
                );

            if (list.Count() == 0)
            {
                list.Add(ItemIndex.ScrapWhite);
            }

            return(list[new Random().Next(list.Count)]);
        }
        // Token: 0x0600220F RID: 8719 RVA: 0x000A1038 File Offset: 0x0009F238
        public void SetItemIndex(ItemIndex newItemIndex, int newItemCount)
        {
            if (this.itemIndex == newItemIndex && this.itemCount == newItemCount)
            {
                return;
            }
            this.itemIndex = newItemIndex;
            this.itemCount = newItemCount;
            string  titleToken = "";
            string  bodyToken  = "";
            Color   color      = Color.white;
            Color   bodyColor  = new Color(0.6f, 0.6f, 0.6f, 1f);
            ItemDef itemDef    = ItemCatalog.GetItemDef(this.itemIndex);

            if (itemDef != null)
            {
                this.image.texture = Resources.Load <Texture>(itemDef.pickupIconPath);
                if (this.itemCount > 1)
                {
                    this.stackText.enabled = true;
                    this.stackText.text    = string.Format("x{0}", this.itemCount);
                }
                else
                {
                    this.stackText.enabled = false;
                }
                titleToken = itemDef.nameToken;
                bodyToken  = itemDef.pickupToken;
                color      = ColorCatalog.GetColor(itemDef.darkColorIndex);
            }
            if (this.glowImage)
            {
                this.glowImage.color = new Color(color.r, color.g, color.b, 0.75f);
            }
            if (this.tooltipProvider)
            {
                this.tooltipProvider.titleToken = titleToken;
                this.tooltipProvider.bodyToken  = bodyToken;
                this.tooltipProvider.titleColor = color;
                this.tooltipProvider.bodyColor  = bodyColor;
            }
        }
        private void RandomRemoveItemOne()
        {
            List <ItemIndex> list = new List <ItemIndex>();

            for (int i = 0; i < itemStacks.Length; i++)
            {
                int num = itemStacks[i];
                if (num > 0)
                {
                    list.Add((ItemIndex)i);
                }
            }
            ItemIndex itemIndex = (list.Count == 0) ? ItemIndex.None : list[GetRandom(0, list.Count)];

            characterMaster.inventory.RemoveItem(itemIndex, 1);
            ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex);

            Chat.AddMessage("Remove One Item:" + Language.GetString(itemDef.nameToken));
            itemStacks[(int)itemIndex] -= 1;
        }
        public void OnPointerClick(PointerEventData eventData)
        {
            // TODO(kookehs): Add multiplayer support.
            if (!NetworkServer.active || Inventory == null)
            {
                return;
            }

            CharacterBody characterBody = Inventory.GetComponent <CharacterMaster>().GetBody();
            Notification  notification  = characterBody.gameObject.AddComponent <Notification>();

            notification.transform.SetParent(characterBody.transform);
            notification.SetPosition(new Vector3((float)(Screen.width * 0.8), (float)(Screen.height * 0.25), 0));
            Transform transform = characterBody.transform;

            if (EquipmentIndex != EquipmentIndex.None)
            {
                EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(EquipmentIndex);
                notification.SetIcon(Resources.Load <Texture>(equipmentDef.pickupIconPath));
                notification.GetTitle       = () => "Equipment dropped";
                notification.GetDescription = () => $"{Language.GetString(equipmentDef.nameToken)}";
                Inventory.SetEquipmentIndex(EquipmentIndex.None);
                PickupDropletController.CreatePickupDroplet(new PickupIndex(EquipmentIndex), transform.position, Vector3.up * 20f + transform.forward * 10f);
                Destroy(this);
                return;
            }

            ItemDef itemDef = ItemCatalog.GetItemDef(ItemIndex);

            notification.SetIcon(Resources.Load <Texture>(itemDef.pickupIconPath));
            notification.GetTitle       = () => "Item dropped";
            notification.GetDescription = () => $"{Language.GetString(itemDef.nameToken)}";
            Inventory.RemoveItem(ItemIndex, 1);
            PickupDropletController.CreatePickupDroplet(new PickupIndex(ItemIndex), transform.position, Vector3.up * 20f + transform.forward * 10f);
            int[] itemStacks = (int[])typeof(Inventory).GetField("itemStacks", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(Inventory);

            if (itemStacks[(int)ItemIndex] <= 0)
            {
                Destroy(this);
            }
        }
        public void OnPointerClick(PointerEventData eventData)
        {
            if (!NetworkServer.active || Inventory == null || IsMaster)
            {
                return;
            }

            if (ItemDropped)
            {
                return;
            }

            ItemDropped = true;
            CharacterBody characterBody = Inventory.GetComponent <CharacterMaster>().GetBody();

            Api.Notification notification = characterBody.gameObject.AddComponent <Api.Notification>();;
            notification.transform.SetParent(characterBody.transform);
            notification.SetPosition(new Vector3((float)(Screen.width * 0.8), (float)(Screen.height * 0.25), 0));
            Transform transform = characterBody.transform;

            if (EquipmentIndex != EquipmentIndex.None)
            {
                EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(EquipmentIndex);
                notification.SetIcon(Resources.Load <Texture>(equipmentDef.pickupIconPath));
                notification.GetTitle       = () => "Equipment dropped";
                notification.GetDescription = () => $"{Language.GetString(equipmentDef.nameToken)}";
                Inventory.SetEquipmentIndex(EquipmentIndex.None);
                PickupDropletController.CreatePickupDroplet(new PickupIndex(EquipmentIndex), transform.position, Vector3.up * 20f + transform.forward * 10f);
                Destroy(this);
                return;
            }

            ItemDef itemDef = ItemCatalog.GetItemDef(ItemIndex);

            notification.SetIcon(Resources.Load <Texture>(itemDef.pickupIconPath));
            notification.GetTitle       = () => "Item dropped";
            notification.GetDescription = () => $"{Language.GetString(itemDef.nameToken)}";
            Inventory.RemoveItem(ItemIndex, 1);
            PickupDropletController.CreatePickupDroplet(new PickupIndex(ItemIndex), transform.position, Vector3.up * 20f + transform.forward * 10f);
            Destroy(this);
        }
Beispiel #10
0
        public static List <PickupIndex> GetDefaultLunarDropList()
        {
            var list = new List <PickupIndex>();

            for (var equipmentIndex = EquipmentIndex.CommandMissile;
                 equipmentIndex < EquipmentIndex.Count;
                 equipmentIndex++)
            {
                if (!Run.instance.availableEquipment.HasEquipment(equipmentIndex))
                {
                    continue;
                }

                var equipmentDef = EquipmentCatalog.GetEquipmentDef(equipmentIndex);
                if (equipmentDef.canDrop && equipmentDef.isLunar)
                {
                    list.Add(PickupCatalog.FindPickupIndex(equipmentIndex));
                }
            }

            for (var itemIndex = ItemIndex.Syringe;
                 itemIndex < ItemIndex.Count;
                 itemIndex++)
            {
                if (!Run.instance.availableItems.HasItem(itemIndex))
                {
                    continue;
                }

                if (ItemCatalog.GetItemDef(itemIndex).tier == ItemTier.Lunar)
                {
                    list.Add(PickupCatalog.FindPickupIndex(itemIndex));
                }
            }

            list.AddRange(AdditionalTierItems[ItemTier.Lunar].Select(x => PickupCatalog.FindPickupIndex(x)));
            list.AddRange(AdditionalEquipment
                          .Where(x => EquipmentCatalog.GetEquipmentDef(x).isLunar)
                          .Select(x => PickupCatalog.FindPickupIndex(x)));
            return(list);
        }
Beispiel #11
0
        void SpawnItem(Int32 id)
        {
            int width = 170;

            if (_CharacterCollected)
            {
                ItemScrollPos = GUILayout.BeginScrollView(ItemScrollPos);


                for (int i = (int)ItemIndex.Syringe; i < (int)ItemIndex.Count; i++)
                {
                    GUILayout.BeginHorizontal("box");
                    var def = ItemCatalog.GetItemDef((ItemIndex)i);
                    if (GUILayout.Button(Language.GetString(def.nameToken), BtnStyle, GUILayout.Width(width), GUILayout.ExpandHeight(true)))
                    {
                        GUILayout.Space(10);
                        var localUser = LocalUserManager.GetFirstLocalUser();
                        if (localUser.cachedMasterController && localUser.cachedMasterController.master)
                        {
                            var body = localUser.cachedMasterController.master.GetBody();
                            PickupDropletController.CreatePickupDroplet(new PickupIndex((ItemIndex)i), body.transform.position + (Vector3.up * 1.5f), Vector3.up * 20f + body.transform.forward * 2f);
                        }
                    }
                    if (GUILayout.Button("x10", BtnStyle, GUILayout.Width(width), GUILayout.ExpandHeight(true)))
                    {
                        for (int counter = 0; counter <= 9; counter++)
                        {
                            var localUser = LocalUserManager.GetFirstLocalUser();
                            if (localUser.cachedMasterController && localUser.cachedMasterController.master)
                            {
                                var body = localUser.cachedMasterController.master.GetBody();
                                PickupDropletController.CreatePickupDroplet(new PickupIndex((ItemIndex)i), body.transform.position + (Vector3.up * 1.5f), Vector3.up * 20f + body.transform.forward * 2f);
                            }
                        }
                    }
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndScrollView();
            GUI.DragWindow();
        }
Beispiel #12
0
        public static bool IsValidItemPickup(PickupIndex pickup)
        {
            var pickupdef = PickupCatalog.GetPickupDef(pickup);

            if (pickupdef.itemIndex != ItemIndex.None)
            {
                var itemdef = ItemCatalog.GetItemDef(pickupdef.itemIndex);
                switch (itemdef.tier)
                {
                case ItemTier.Tier1:
                    return(ShareSuite.WhiteItemsShared.Value);

                case ItemTier.Tier2:
                    return(ShareSuite.GreenItemsShared.Value);

                case ItemTier.Tier3:
                    return(ShareSuite.RedItemsShared.Value);

                case ItemTier.Lunar:
                    return(ShareSuite.LunarItemsShared.Value);

                case ItemTier.Boss:
                    return(ShareSuite.BossItemsShared.Value);

                case ItemTier.NoTier:
                    break;

                default:
                    return(false);
                }
            }

            if (pickupdef.equipmentIndex != EquipmentIndex.None)
            {
                // var equipdef = EquipmentCatalog.GetEquipmentDef(pickupdef.equipmentIndex);
                // Optional further checks ...
                return(false);
            }

            return(false);
        }
Beispiel #13
0
        public static ShopViewModel GetShopViewModel(NetworkInstanceId clientId)
        {
            var player          = PlayerCharacterMasterController.instances.First(x => x.master.netId == clientId);
            var allItems        = AugmentResolver.AllAvailableAugments;
            var activeForPlayer = AugmentResolver.GetActiveAugmentsForPlayer(clientId);
            var viewModels      = new List <ShopItemViewModel>();

            foreach (var item in allItems)
            {
                if (!activeForPlayer.Augments.TryGetValue(item.Key,
                                                          out var existingAugments))
                {
                    existingAugments = new ConcurrentDictionary <AugmentId, AugmentBase>();
                }

                var itemCount = player.master.inventory.GetItemCount(item.Key);
                var itemTier  = ItemCatalog.GetItemDef(item.Key).tier;
                var itemCost  = ConfigResolver.ItemCount(itemTier);

                var pointsToSpend = itemCount / (itemCost * (existingAugments.Count + 1));

                var augmentViewModels = new List <AugmentViewModel>();
                foreach (var augment in item.Value)
                {
                    var active      = existingAugments.ContainsKey(augment.Key);
                    var level       = augment.Value.GetLevel(clientId);
                    var purchasable = pointsToSpend > 0 && level < augment.Value.MaxLevel;
                    var viewModel   = new AugmentViewModel(augment.Value,
                                                           active,
                                                           purchasable,
                                                           level);
                    augmentViewModels.Add(viewModel);
                }

                viewModels.Add(new ShopItemViewModel(item.Key,
                                                     augmentViewModels,
                                                     pointsToSpend));
            }

            return(new ShopViewModel(viewModels));
        }
Beispiel #14
0
        //Gets players current items to make sure they can drop item from inventory if enabled
        public static List <ItemIndex> CurrentInventory()
        {
            var currentInventory = new List <ItemIndex>();

            string[] unreleasedItems = { "Count", "None" };

            foreach (ItemIndex itemIndex in ItemCatalog.allItems)
            {
                ItemDef itemDef            = ItemCatalog.GetItemDef(itemIndex);
                bool    unreleasednullItem = unreleasedItems.Any(itemDef.name.Contains);
                if (!unreleasednullItem)
                {
                    int itemCount = UmbraMenu.LocalPlayerInv.GetItemCount(itemIndex);
                    if (itemCount > 0)                   // If item is in inventory
                    {
                        currentInventory.Add(itemIndex); // add to list
                    }
                }
            }
            return(currentInventory);
        }
            //-------------------------
            //-------------------------


            static public bool ListContainsValidItems(List <ItemTag> forbiddenTags, List <PickupIndex> givenList)
            {
                foreach (PickupIndex pickupIndex in givenList)
                {
                    bool    validItem = true;
                    ItemDef itemDef   = ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(pickupIndex).itemIndex);
                    foreach (ItemTag itemTag in forbiddenTags)
                    {
                        if (itemDef.ContainsTag(itemTag))
                        {
                            validItem = false;
                            break;
                        }
                    }
                    if (validItem)
                    {
                        return(true);
                    }
                }
                return(false);
            }
Beispiel #16
0
        private static bool ValidDropRequest(ItemIndex index, bool scrap)
        {
            if (index == ItemIndex.None)
            {
                return(false);
            }

            if (index == ArtifactKeyIndex && scrap)
            {
                return(false);
            }

            ItemDef itemDef = ItemCatalog.GetItemDef(index);

            if (itemDef.tier == ItemTier.NoTier)
            {
                return(false);
            }

            if (!ZetArtifactsPlugin.DropifactLunar.Value && itemDef.tier == ItemTier.Lunar)
            {
                return(false);
            }
            if (!ZetArtifactsPlugin.DropifactVoid.Value && IsVoidTier(itemDef.tier))
            {
                return(false);
            }
            if (!ZetArtifactsPlugin.DropifactUnique.Value && itemDef.ContainsTag(ItemTag.WorldUnique))
            {
                return(false);
            }

            if (scrap)
            {
                return(IsScrapable(itemDef.tier));
            }

            return(true);
        }
Beispiel #17
0
        private void GiveRandomRed(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self) //ripped from harbcrate, i did credit though.
        {
            orig(self);
            var amount = GetCount(self);

            if (amount > 1)
            {
                self.inventory.RemoveItem(catalogIndex);
                PickupIndex loot = Run.instance.treasureRng.NextElementUniform(Run.instance.availableTier3DropList);
                if (self.isPlayerControlled)
                {
                    PickupDropletController.CreatePickupDroplet(loot, self.corePosition, Vector3.up * 5);
                }
                else
                {
                    PickupDef def = PickupCatalog.GetPickupDef(loot);
                    self.inventory.GiveItem(def.itemIndex);
                    var lootCount = self.inventory.GetItemCount(def.itemIndex);
                    Chat.AddPickupMessage(self, def.nameToken, ColorCatalog.GetColor(ItemCatalog.GetItemDef(def.itemIndex).colorIndex), (uint)lootCount);
                }
            }
        }
Beispiel #18
0
        internal static void Init()
        {
            On.RoR2.Inventory.GiveItem += (orig, self, index, count) =>
            {
                // Assuming this isn't another printer or special case item...
                if (index != Assets.PocketPrinterItemIndex)
                {
                    // Get item tier and check if it's allowed
                    ItemTier tier    = ItemCatalog.GetItemDef(index).tier;
                    bool     success = true;
                    if (!PocketPrinter.AllowCopyBossItems.Value && tier == ItemTier.Boss)
                    {
                        success = false;
                    }
                    if (!PocketPrinter.AllowCopyLunarItems.Value && tier == ItemTier.Lunar)
                    {
                        success = false;
                    }
                    if (!PocketPrinter.AllowCopyRedItems.Value && tier == ItemTier.Tier3)
                    {
                        success = false;
                    }

                    if (success)
                    {
                        // Get how many printers we already have
                        int printerCount = self.GetItemCount(Assets.PocketPrinterItemIndex);
                        if (printerCount > 0)
                        {
                            // Remove all printers and increase count
                            count += printerCount;
                            self.RemoveItem(Assets.PocketPrinterItemIndex, printerCount);
                        }
                    }
                }
                // Call base function
                orig(self, index, count);
            };
        }
Beispiel #19
0
        private static ItemIndex SelectItemFromTier(List <ItemIndex> itemIndexs, ItemTier itemTier)
        {
            List <ItemIndex> tieredItems = new List <ItemIndex>();
            var itemIndex = ItemIndex.None;

            foreach (var item in itemIndexs)
            {
                var itemDef = ItemCatalog.GetItemDef(item);
                if (itemDef.tier == itemTier)
                {
                    tieredItems.Add(item);
                }
            }
            if (tieredItems.Count > 0)
            {
                Xoroshiro128Plus rng = new Xoroshiro128Plus(Run.instance.treasureRng.nextUlong);

                itemIndex = rng.NextElementUniform(tieredItems);
            }


            return(itemIndex);
        }
Beispiel #20
0
        private void RoR2Application_Update(On.RoR2.RoR2Application.orig_Update orig, RoR2Application self)
        {
            var codename = ItemCatalog.GetItemDef(ItemIndex.Bear)?.nameToken;

            if (codename != null)
            {
                var name = Language.GetString(codename);
                if (name != codename)
                {
                    if (SurvivorCatalog.allSurvivorDefs != null)
                    {
                        if (SurvivorCatalog.allSurvivorDefs.Count() != 0)
                        {
                            var tmp = new Dictionary <string, bool>();
                            configitem("!Item!", "examplecharacter_example", tmp);
                            var survivors = SurvivorCatalog.allSurvivorDefs;
                            for (ItemIndex i = 0; i < ItemIndex.Count; i++)
                            {
                                var item = ItemCatalog.GetItemDef(i);
                                if (item.hidden == false)
                                {
                                    var itemdic = new Dictionary <string, bool>();
                                    dropping.Add(i, itemdic);
                                    var itemname = Language.GetString(item.nameToken);
                                    configitem(itemname, "ALL", itemdic);
                                    foreach (var survivor in survivors)
                                    {
                                        configitem(itemname, survivor.descriptionToken, itemdic);
                                    }
                                }
                            }
                            On.RoR2.RoR2Application.Update -= RoR2Application_Update;
                        }
                    }
                }
            }
        }
Beispiel #21
0
 private static void PageBuilderOnAddSimplePickup(On.RoR2.UI.LogBook.PageBuilder.orig_AddSimplePickup orig, PageBuilder self, PickupIndex pickupIndex)
 {
     if (IsCustomItemOrEquipment(pickupIndex))
     {
         ItemIndex      itemIndex      = pickupIndex.itemIndex;
         EquipmentIndex equipmentIndex = pickupIndex.equipmentIndex;
         string         token          = null;
         if (itemIndex != ItemIndex.None)
         {
             ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex);
             self.AddDescriptionPanel(Language.GetString(itemDef.descriptionToken));
             token = itemDef.loreToken;
             //ulong statValueULong = get from custom file;
             //ulong statValueULong2 = get from custom file;
             string stringFormatted  = Language.GetStringFormatted("GENERIC_PREFIX_FOUND", "Unknown"); // param arg being the value from custom file
             string stringFormatted2 = Language.GetStringFormatted("ITEM_PREFIX_STACKCOUNT", "Unknown");
             self.AddSimpleTextPanel(stringFormatted, stringFormatted2);
         }
         else if (equipmentIndex != EquipmentIndex.None)
         {
             EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(equipmentIndex);
             self.AddDescriptionPanel(Language.GetString(equipmentDef.descriptionToken));
             token = equipmentDef.loreToken;
             // this.statSheet.GetStatDisplayValue(PerEquipmentStatDef.totalTimeHeld.FindStatDef(equipmentIndex)) get from custom file instead
             // this.statSheet.GetStatDisplayValue(PerEquipmentStatDef.totalTimesFired.FindStatDef(equipmentIndex))
             string stringFormatted3 = Language.GetStringFormatted("EQUIPMENT_PREFIX_TOTALTIMEHELD", "Unknown");
             string stringFormatted4 = Language.GetStringFormatted("EQUIPMENT_PREFIX_USECOUNT", "Unknown");
             self.AddSimpleTextPanel(stringFormatted3, stringFormatted4);
         }
         // ReSharper disable once AssignNullToNotNullAttribute
         self.AddNotesPanel(Language.IsTokenInvalid(token) ? Language.GetString("EARLY_ACCESS_LORE") : Language.GetString(token));
     }
     else
     {
         orig(self, pickupIndex);
     }
 }
        private void BuildNotification(PickupIndex pickupIndex, RoR2.UI.PingIndicator pingIndicator)
        {
            LocalUser localUser = LocalUserManager.GetFirstLocalUser();

            if (localUser.currentNetworkUser.userName ==
                Util.GetBestMasterName(pingIndicator.pingOwner.GetComponent <CharacterMaster>()))
            {
                if (localUser.userProfile.HasDiscoveredPickup(pickupIndex))
                {
                    PickupDef pickup = PickupCatalog.GetPickupDef(pickupIndex);

                    ItemDef      item     = ItemCatalog.GetItemDef(pickup.itemIndex);
                    EquipmentDef equip    = EquipmentCatalog.GetEquipmentDef(pickup.equipmentIndex);
                    ArtifactDef  artifact = ArtifactCatalog.GetArtifactDef(pickup.artifactIndex);

                    GenericNotification notification = Object
                                                       .Instantiate(Resources.Load <GameObject>("Prefabs/NotificationPanel2"))
                                                       .GetComponent <GenericNotification>();

                    if (item != null)
                    {
                        notification.SetItem(item);
                    }
                    else if (equip != null)
                    {
                        notification.SetEquipment(equip);
                    }
                    else if (artifact != null)
                    {
                        notification.SetArtifact(artifact);
                    }

                    notification.transform.SetParent(RoR2Application.instance.mainCanvas.transform, false);
                    notification.transform.position = new Vector3(notification.transform.position.x + 2, 95, 0);
                }
            }
        }
Beispiel #23
0
        public static List <PickupIndex> GetDefaultLunarDropList()
        {
            var list = new List <PickupIndex>();

            for (var equipmentIndex = EquipmentIndex.CommandMissile;
                 equipmentIndex < EquipmentIndex.Count;
                 equipmentIndex++)
            {
                if (!Run.instance.availableEquipment.HasEquipment(equipmentIndex))
                {
                    continue;
                }

                var equipmentDef = EquipmentCatalog.GetEquipmentDef(equipmentIndex);
                if (equipmentDef.canDrop && equipmentDef.isLunar)
                {
                    list.Add(new PickupIndex(equipmentIndex));
                }
            }

            for (var itemIndex = ItemIndex.Syringe;
                 itemIndex < ItemIndex.Count;
                 itemIndex++)
            {
                if (!Run.instance.availableItems.HasItem(itemIndex))
                {
                    continue;
                }

                if (ItemCatalog.GetItemDef(itemIndex).tier == ItemTier.Lunar)
                {
                    list.Add(new PickupIndex(itemIndex));
                }
            }

            return(list);
        }
Beispiel #24
0
        private ItemIndex GetScrapItemIndex(ItemIndex itemIndex)
        {
            ItemDef definition = ItemCatalog.GetItemDef(itemIndex);

            switch (definition.tier)
            {
            case ItemTier.Tier1:
                return(ItemIndex.ScrapWhite);

            case ItemTier.Tier2:
                return(ItemIndex.ScrapGreen);

            case ItemTier.Tier3:
                return(ItemIndex.ScrapRed);

            case ItemTier.Lunar:
                return(ItemIndex.ScrapGreen);

            case ItemTier.Boss:
                return(ItemIndex.ScrapYellow);
            }

            return(ItemIndex.ScrapWhite);
        }
Beispiel #25
0
        // Disable field making for totalCollected and highestCollected for custom items
        private static void PerItemStatDefOnRegisterStatDefs(On.RoR2.Stats.PerItemStatDef.orig_RegisterStatDefs orig)
        {
            var instancesList = typeof(PerItemStatDef).GetFieldValue <List <PerItemStatDef> >("instancesList");

            foreach (PerItemStatDef perItemStatDef in instancesList)
            {
                var prefix       = perItemStatDef.GetFieldValue <string>("prefix");
                var recordType   = perItemStatDef.GetFieldValue <StatRecordType>("recordType");
                var dataType     = perItemStatDef.GetFieldValue <StatDataType>("dataType");
                var keyToStatDef = ItemCatalog.GetPerItemBuffer <StatDef>();
                perItemStatDef.SetFieldValue("keyToStatDef", keyToStatDef);

                foreach (ItemIndex itemIndex in ItemCatalog.allItems)
                {
                    if ((int)itemIndex >= OriginalItemCount)
                    {
                        continue;
                    }
                    ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex);
                    StatDef statDef = StatDef.Register(prefix + "." + itemDef.name, recordType, dataType, 0.0);
                    keyToStatDef[(int)itemIndex] = statDef;
                }
            }
        }
Beispiel #26
0
        // Token: 0x06002C78 RID: 11384 RVA: 0x000BBA48 File Offset: 0x000B9C48
        private void GrantPickupServer(PickupIndex pickupIndex, int countToGrant)
        {
            PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);

            if (pickupDef == null)
            {
                return;
            }
            ItemIndex itemIndex = pickupDef.itemIndex;

            if (ItemCatalog.GetItemDef(itemIndex) == null)
            {
                return;
            }
            base.characterBody.inventory.GiveItem(itemIndex, countToGrant);
            Chat.SendBroadcastChat(new Chat.PlayerPickupChatMessage
            {
                subjectAsCharacterBody = base.characterBody,
                baseToken      = "MONSTER_PICKUP",
                pickupToken    = pickupDef.nameToken,
                pickupColor    = pickupDef.baseColor,
                pickupQuantity = (uint)this.itemsToGrant
            });
        }
Beispiel #27
0
        private string constructItemsLostString(List <ItemCount> difference)
        {
            string result = "<color=#8296ae>You gave up ";

            for (int i = 0; i < difference.Count; i++)
            {
                ItemCount   diffItem    = difference[i];
                PickupIndex pickupIndex = new PickupIndex(diffItem.itemIndex);
                string      itemName    = Language.GetString(ItemCatalog.GetItemDef(diffItem.itemIndex).nameToken);
                string      hexColor    = "#" + ColorUtility.ToHtmlStringRGB(pickupIndex.GetPickupColor());

                result += "x" + diffItem.count + " " + "<color=" + hexColor + ">" + itemName + "</color>";
                if (i + 1 < difference.Count)
                {
                    result += ", ";
                }
                else
                {
                    result += "</color>";
                }
            }

            return(result);
        }
Beispiel #28
0
        public int AdjustItemCount(ItemIndex itemIndex)
        {
            switch (ItemCatalog.GetItemDef(itemIndex).tier)
            {
            case ItemTier.Tier1:
                return(multCommon);

            case ItemTier.Tier2:
                return(multUncommon);

            case ItemTier.Tier3:
                return(multLegendary);

            case ItemTier.Lunar:
                return(multLunar);

            case ItemTier.Boss:
                return(multBoss);

            case ItemTier.NoTier:
                break;
            }
            return(1);
        }
Beispiel #29
0
        private float GetChance(ItemIndex itemIndex)
        {
            ItemDef definition = ItemCatalog.GetItemDef(itemIndex);

            switch (definition.tier)
            {
            case ItemTier.Tier1:
                return(WhiteRandomItemChance.Value);

            case ItemTier.Tier2:
                return(GreenRandomItemChance.Value);

            case ItemTier.Tier3:
                return(RedRandomItemChance.Value);

            case ItemTier.Lunar:
                return(LunarRandomItemChance.Value);

            case ItemTier.Boss:
                return(BossRandomItemChance.Value);
            }

            return(0f);
        }
        public void CalculateInvalidInteractables(DropList dropList)
        {
            TiersPresent.Clear();
            foreach (DropType dropType in System.Enum.GetValues(typeof(DropType)))
            {
                TiersPresent.Add(dropType, false);
            }

            SubsetTiersPresent.Clear();
            foreach (var subsetChest in _subsetChests)
            {
                SubsetTiersPresent.Add(subsetChest, new Dictionary <DropType, bool>());
                foreach (DropType dropType in System.Enum.GetValues(typeof(DropType)))
                {
                    SubsetTiersPresent[subsetChest].Add(dropType, false);
                }
            }

            if (DropList.IsValidList(dropList.AvailableTier1DropList))
            {
                foreach (var pickupIndex in dropList.AvailableTier1DropList)
                {
                    var pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
                    if (pickupDef != null)
                    {
                        TiersPresent[DropType.tier1] = true;
                        break;
                    }
                }
            }

            if (DropList.IsValidList(dropList.AvailableTier2DropList))
            {
                foreach (var pickupIndex in dropList.AvailableTier2DropList)
                {
                    var pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
                    if (pickupDef != null)
                    {
                        TiersPresent[DropType.tier2] = true;
                        break;
                    }
                }
            }

            if (DropList.IsValidList(dropList.AvailableTier3DropList))
            {
                foreach (var pickupIndex in dropList.AvailableTier3DropList)
                {
                    var pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
                    if (pickupDef != null)
                    {
                        TiersPresent[DropType.tier3] = true;
                        break;
                    }
                }
            }

            foreach (var pickupIndex in dropList.AvailableSpecialItems)
            {
                var pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
                if (pickupDef != null)
                {
                    if (pickupDef.itemIndex != ItemIndex.None &&
                        Catalog.Pearls.Contains(pickupDef.itemIndex))
                    {
                        TiersPresent[DropType.pearl] = true;
                        break;
                    }
                }
            }

            if (DropList.IsValidList(dropList.AvailableBossDropList))
            {
                foreach (var pickupIndex in dropList.AvailableBossDropList)
                {
                    var pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
                    if (pickupDef != null)
                    {
                        TiersPresent[DropType.boss] = true;
                        break;
                    }
                }
            }

            if (DropList.IsValidList(dropList.AvailableLunarDropList))
            {
                foreach (var pickupIndex in dropList.AvailableLunarDropList)
                {
                    var pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
                    if (pickupDef != null)
                    {
                        TiersPresent[DropType.lunar] = true;
                        break;
                    }
                }
            }

            var everyItem = new List <PickupIndex>();

            AddItemsToList(everyItem, dropList.AvailableTier1DropList);
            AddItemsToList(everyItem, dropList.AvailableTier2DropList);
            AddItemsToList(everyItem, dropList.AvailableTier3DropList);
            foreach (var pickupIndex in everyItem)
            {
                var pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
                if (pickupDef != null)
                {
                    var itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex);
                    if (itemDef != null)
                    {
                        foreach (var itemTag in itemDef.tags)
                        {
                            var interactableName = "";
                            if (itemTag == ItemTag.Damage)
                            {
                                TiersPresent[DropType.damage] = true;
                                interactableName = "CategoryChestDamage";
                            }
                            else if (itemTag == ItemTag.Healing)
                            {
                                TiersPresent[DropType.healing] = true;
                                interactableName = "CategoryChestHealing";
                            }
                            else if (itemTag == ItemTag.Utility)
                            {
                                TiersPresent[DropType.utility] = true;
                                interactableName = "CategoryChestUtility";
                            }
                            if (_subsetChests.Contains(interactableName))
                            {
                                if (dropList.AvailableTier1DropList.Contains(pickupIndex))
                                {
                                    SubsetTiersPresent[interactableName][DropType.tier1] = true;
                                }
                                if (dropList.AvailableTier2DropList.Contains(pickupIndex))
                                {
                                    SubsetTiersPresent[interactableName][DropType.tier2] = true;
                                }
                                if (dropList.AvailableTier3DropList.Contains(pickupIndex))
                                {
                                    SubsetTiersPresent[interactableName][DropType.tier3] = true;
                                }
                            }
                        }
                    }
                }
            }
            List <List <PickupIndex> > allDropLists = new List <List <PickupIndex> >()
            {
                dropList.AvailableTier1DropList,
                dropList.AvailableTier2DropList,
                dropList.AvailableTier3DropList,
                dropList.AvailableBossDropList,
                dropList.AvailableLunarDropList,
                dropList.AvailableSpecialItems,
                dropList.AvailableEquipmentDropList,
                dropList.AvailableNormalEquipmentDropList,
                dropList.AvailableLunarEquipmentDropList,
                dropList.AvailableSpecialEquipment,
            };

            foreach (List <PickupIndex> availableDropList in allDropLists)
            {
                foreach (PickupIndex pickupIndex in availableDropList)
                {
                    PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
                    if (pickupDef != null)
                    {
                        ItemIndex itemIndex = pickupDef.itemIndex;
                        if (itemIndex != ItemIndex.None)
                        {
                            if (!ItemCatalog.GetItemDef(itemIndex).ContainsTag(ItemTag.Scrap))
                            {
                                ItemTier itemTier = ItemCatalog.GetItemDef(itemIndex).tier;
                                if (itemTier == ItemTier.Tier1)
                                {
                                    TiersPresent[DropType.tier1Tier] = true;
                                }
                                else if (itemTier == ItemTier.Tier2)
                                {
                                    TiersPresent[DropType.tier2Tier] = true;
                                }
                                else if (itemTier == ItemTier.Tier3)
                                {
                                    TiersPresent[DropType.tier3Tier] = true;
                                }
                                else if (itemTier == ItemTier.Boss)
                                {
                                    TiersPresent[DropType.bossTier] = true;
                                }
                                else if (itemTier == ItemTier.Lunar)
                                {
                                    TiersPresent[DropType.lunarTier] = true;
                                }
                            }
                        }
                        EquipmentIndex equipmentIndex = pickupDef.equipmentIndex;
                        if (equipmentIndex != EquipmentIndex.None)
                        {
                            TiersPresent[DropType.equipmentTier] = true;
                        }
                    }
                }
            }

            if (DropList.IsValidList(dropList.AvailableNormalEquipmentDropList))
            {
                TiersPresent[DropType.equipment] = true;
            }
            if (DropList.IsValidList(dropList.AvailableLunarEquipmentDropList))
            {
                TiersPresent[DropType.lunar] = true;
            }
            var interactableTypeKeys = InteractablesTiers.Keys.ToList();

            foreach (var interactableType in interactableTypeKeys)
            {
                var interactableTypeTierKeys = InteractablesTiers[interactableType].Keys.ToList();
                foreach (var tier in interactableTypeTierKeys)
                {
                    InteractablesTiers[interactableType][tier] = false;
                }
            }
            foreach (var tier in TiersPresent.Keys)
            {
                if (TiersPresent[tier])
                {
                    foreach (var interactableType in interactableTypeKeys)
                    {
                        if (InteractablesTiers[interactableType].ContainsKey(tier))
                        {
                            InteractablesTiers[interactableType][tier] = true;
                        }
                    }
                }
            }
            var scrapTierKeys = InteractablesTiers["Scrapper"].Keys.ToList();

            foreach (DropType tier in scrapTierKeys)
            {
                if (InteractablesTiers["Scrapper"][tier])
                {
                    if (Catalog.ScrapItems.ContainsKey(TierConversion[tier]))
                    {
                        if (!dropList.AvailableSpecialItems.Contains(PickupCatalog.FindPickupIndex(Catalog.ScrapItems[TierConversion[tier]])))
                        {
                            InteractablesTiers["Scrapper"][tier] = false;
                        }
                    }
                }
            }

            InvalidInteractables.Clear();
            foreach (var interactableType in InteractablesTiers.Keys)
            {
                var interactableValid = false;
                var allTrue           = true;
                foreach (var tier in InteractablesTiers[interactableType].Keys)
                {
                    if (InteractablesTiers[interactableType][tier])
                    {
                        interactableValid = true;
                    }
                    else
                    {
                        allTrue = false;
                    }
                }
                if (!interactableValid || AllTiersMustBePresent.Contains(interactableType) && !allTrue)
                {
                    InvalidInteractables.Add(interactableType);
                }
            }
        }