Example #1
0
 public void AddItem(ItemIndex itemIndex, uint amount)
 {
     for (int i = 0; i < amount; i++)
     {
         itemIndices.Add(itemIndex);
     }
 }
        private void Run_Update(On.RoR2.Run.orig_Update orig, Run self)
        {
            if (Input.GetKeyDown(KeyCode.F5))
            {
                Debug.Log("Spawn DIO");
                LocalUser localUser = LocalUserManager.GetFirstLocalUser();
                Transform transform = localUser.cachedBodyObject.transform;

                PickupIndex dio = new PickupIndex(ItemIndex.ExtraLife);
                PickupDropletController.CreatePickupDroplet(dio, transform.position, Vector3.up * 5f);
            }

            if (Input.GetKeyDown(KeyCode.F6))
            {
                Debug.Log("Spawn Random");
                LocalUser localUser = LocalUserManager.GetFirstLocalUser();
                Transform transform = localUser.cachedBodyObject.transform;

                List <PickupIndex> tier3Items = Run.instance.availableTier3DropList;
                int rng = random.Next(0, tier3Items.Count);

                ItemIndex rngItem = tier3Items[rng].itemIndex;

                PickupIndex dio = new PickupIndex(rngItem);
                PickupDropletController.CreatePickupDroplet(dio, transform.position, Vector3.up * 5f);
            }
        }
Example #3
0
        private static void TargetCheckItems(ConCommandArgs args)
        {
            var localMaster = PlayerCharacterMasterController.instances[0].master;
            var component   = HasComponent(localMaster);

            if (component && component.HasBody())
            {
                var inventory = component.targetedBody.inventory;
                if (inventory)
                { //https://stackoverflow.com/questions/23563960/how-to-get-enum-value-by-string-or-int
                    var       ChatQueue        = component.targetedBody.GetDisplayName() + "'s inventory:\n";
                    ItemIndex itemIndexIterate = ItemIndex.Syringe;
                    ItemIndex itemCountIterate = (ItemIndex)ItemCatalog.itemCount;
                    while (itemIndexIterate < itemCountIterate)
                    {
                        var itemCount = inventory.GetItemCount(itemIndexIterate);
                        if (itemCount > 0)
                        {
                            ChatQueue += itemIndexIterate + " x" + itemCount + "\n";
                        }
                        itemIndexIterate++;
                    }

                    Debug.Log(ChatQueue);
                }
            }
        }
 void DropItemIndex(Vector3 position, ItemIndex itemIndex, int count)
 {
     for (uint i = 0; i < count; i++)
     {
         PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(itemIndex), position, Vector3.up * 5f);
     }
 }
 public static void customItemCap(CharacterMaster cm)
 {
     // Custom item caps
     string[] customItemCaps = DII.CustomItemCapsAll.Value.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
     foreach (string item in customItemCaps)
     {
         string[] temp = item.Split(new[] { '-' });
         if (temp.Length == 2)
         {
             if (Int32.TryParse(temp[0], out int itemId) && Int32.TryParse(temp[1], out int cap))
             {
                 if (cm.inventory.GetItemCount((ItemIndex)itemId) > cap)
                 {
                     cm.inventory.ResetItem((ItemIndex)itemId);
                     cm.inventory.GiveItem((ItemIndex)itemId, cap);
                 }
             }
             else if (Int32.TryParse(temp[1], out cap))
             {
                 ItemIndex index = ItemCatalog.FindItemIndex(temp[0]);
                 if (index != ItemIndex.None)
                 {
                     if (cm.inventory.GetItemCount(index) > cap)
                     {
                         cm.inventory.ResetItem(index);
                         cm.inventory.GiveItem(index, cap);
                     }
                 }
             }
         }
     }
 }
Example #6
0
        public override void SetupAttributes()
        {
            if (ItemBodyModelPrefab == null)
            {
                ItemBodyModelPrefab = Resources.Load <GameObject>(modelResourcePath);
                displayRules        = GenerateItemDisplayRules();
            }

            base.SetupAttributes();
            var shellStackMax = new R2API.CustomBuff(
                new BuffDef
            {
                canStack = false,
                isDebuff = false,
                name     = "ShellStackMax",
                iconPath = "@SupplyDrop:Assets/Main/Textures/Icons/ShellBuffIcon.png"
            });

            ShellStackMax = R2API.BuffAPI.Add(shellStackMax);

            var shellStackDef = new CustomItem(new ItemDef
            {
                hidden    = true,
                name      = "INTERNALShell",
                tier      = ItemTier.NoTier,
                canRemove = false
            }, new ItemDisplayRuleDict(null));

            shellStack = ItemAPI.Add(shellStackDef);
        }
Example #7
0
            private static void VialAsItem()
            {
                LanguageAPI.Add("VIAL_NAME_TOKEN", "Mysterious Vial");
                LanguageAPI.Add("VIAL_PICKUP_TOKEN", "Increased health regeneration.");
                LanguageAPI.Add("VIAL_DESCRIPTION_TOKEN", "Gain <style=cIsHealing>1.2</style> <style=cStack>(+1.2 per stack)</style>HP regen/s.");
                LanguageAPI.Add("VIAL_LORE_TOKEN", "Apply to skin for a rapidly acting gel that contains both antiseptics and an agent to encourage protein synthesis!");
                LanguageAPI.Add("VIAL_NAME_TOKEN", "神秘药剂", "zh-CN");
                LanguageAPI.Add("VIAL_PICKUP_TOKEN", "增加生命值再生速度", "zh-CN");
                LanguageAPI.Add("VIAL_DESCRIPTION_TOKEN", "使<style=cIsHealing>基础生命值再生速度</style>提高<style=cIsHealing>1.2hp/s</style><style=cStack>(每层增加1.2hp/s)</style>。", "zh-CN");
                LanguageAPI.Add("VIAL_LORE_TOKEN", "涂在皮肤上,可快速作用,同时含有防腐剂和促进蛋白质合成的物质!", "zh-CN");

                ItemDef VialDef = new ItemDef
                {
                    name             = "VIAL_NAME_TOKEN",
                    pickupIconPath   = IconPath,
                    pickupModelPath  = PrefabPath,
                    nameToken        = "VIAL_NAME_TOKEN",
                    pickupToken      = "VIAL_PICKUP_TOKEN",
                    descriptionToken = "VIAL_DESCRIPTION_TOKEN",
                    loreToken        = "VIAL_LORE_TOKEN",
                    tier             = ItemTier.Tier1,
                    tags             = new ItemTag[]
                    {
                        ItemTag.Healing
                    }
                };

                ItemDisplayRule[] DisplayRules = null;
                CustomItem        VialItem     = new CustomItem(VialDef, DisplayRules);

                VialItemIndex = ItemAPI.Add(VialItem);
            }
Example #8
0
 // Token: 0x06001787 RID: 6023 RVA: 0x0006F864 File Offset: 0x0006DA64
 public override void OverrideRuleChoices(RuleChoiceMask mustInclude, RuleChoiceMask mustExclude)
 {
     base.OverrideRuleChoices(mustInclude, mustExclude);
     base.ForceChoice(mustInclude, mustExclude, "Difficulty.Normal");
     base.ForceChoice(mustInclude, mustExclude, "Misc.StartingMoney.50");
     base.ForceChoice(mustInclude, mustExclude, "Misc.StageOrder.Random");
     base.ForceChoice(mustInclude, mustExclude, "Misc.KeepMoneyBetweenStages.Off");
     for (ArtifactIndex artifactIndex = ArtifactIndex.Command; artifactIndex < ArtifactIndex.Count; artifactIndex++)
     {
         RuleDef       ruleDef       = RuleCatalog.FindRuleDef(artifactIndex.ToString());
         RuleChoiceDef ruleChoiceDef = (ruleDef != null) ? ruleDef.FindChoice("Off") : null;
         if (ruleChoiceDef != null)
         {
             base.ForceChoice(mustInclude, mustExclude, ruleChoiceDef);
         }
     }
     for (ItemIndex itemIndex = ItemIndex.Syringe; itemIndex < ItemIndex.Count; itemIndex++)
     {
         RuleDef       ruleDef2       = RuleCatalog.FindRuleDef("Items." + itemIndex.ToString());
         RuleChoiceDef ruleChoiceDef2 = (ruleDef2 != null) ? ruleDef2.FindChoice("On") : null;
         if (ruleChoiceDef2 != null)
         {
             base.ForceChoice(mustInclude, mustExclude, ruleChoiceDef2);
         }
     }
     for (EquipmentIndex equipmentIndex = EquipmentIndex.CommandMissile; equipmentIndex < EquipmentIndex.Count; equipmentIndex++)
     {
         RuleDef       ruleDef3       = RuleCatalog.FindRuleDef("Equipment." + equipmentIndex.ToString());
         RuleChoiceDef ruleChoiceDef3 = (ruleDef3 != null) ? ruleDef3.FindChoice("On") : null;
         if (ruleChoiceDef3 != null)
         {
             base.ForceChoice(mustInclude, mustExclude, ruleChoiceDef3);
         }
     }
 }
Example #9
0
            private static void ThalliumAsItem()
            {
                LanguageAPI.Add("THALLIUM_NAME_TOKEN", "Thallium");
                LanguageAPI.Add("THALLIUM_PICKUP_TOKEN", "Chance to slow and damage enemies over time.");
                LanguageAPI.Add("THALLIUM_DESCRIPTION_TOKEN", "<style=cIsDamage>10%</style> chance on hit to slow an enemy with a <style=cIsDamage>metal poisoning</style>, <style=cIsUtility>slowing</style> them by <style=cIsUtility>100%</style> and dealing <style=cIsDamage>600%</style> <style=cStack>(+600% per stack)</style> TOTAL damage.");
                LanguageAPI.Add("THALLIUM_LORE_TOKEN", "Shipping Method: High Priority / Fragile\r\nOrder Details: She shouldn't notice.");
                LanguageAPI.Add("THALLIUM_NAME_TOKEN", "铊", "zh-CN");
                LanguageAPI.Add("THALLIUM_PICKUP_TOKEN", "几率减速敌人,并且使敌人中毒。", "zh-CN");
                LanguageAPI.Add("THALLIUM_DESCRIPTION_TOKEN", "有<style=cIsDamage>10%</style> 几率使得敌人<style=cIsDamage>金属中毒</style>,并<style=cIsUtility>减速</style>其<style=cIsUtility>100%</style>,造成<style=cIsDamage>600%</style> <style=cStack>(每层增加600%)</style> 总伤害。", "zh-CN");
                LanguageAPI.Add("THALLIUM_LORE_TOKEN", "运输方式:高优先级 / 脆弱\r\n商品细节:她不会注意到的。", "zh-CN");

                ItemDef ThalliumDef = new ItemDef
                {
                    name             = "THALLIUM_NAME_TOKEN",
                    pickupIconPath   = IconPath,
                    pickupModelPath  = PrefabPath,
                    nameToken        = "THALLIUM_NAME_TOKEN",
                    pickupToken      = "THALLIUM_PICKUP_TOKEN",
                    descriptionToken = "THALLIUM_DESCRIPTION_TOKEN",
                    loreToken        = "THALLIUM_LORE_TOKEN",
                    tier             = ItemTier.Tier3,
                    tags             = new ItemTag[]
                    {
                        ItemTag.Damage
                    }
                };

                ItemDisplayRule[] DisplayRules = null;
                CustomItem        ThalliumItem = new CustomItem(ThalliumDef, DisplayRules);

                ThalliumItemIndex = ItemAPI.Add(ThalliumItem);
            }
            // Token: 0x060019D1 RID: 6609 RVA: 0x0007B5B0 File Offset: 0x000797B0
            public static RunReport.PlayerInfo Generate(PlayerCharacterMasterController playerCharacterMasterController)
            {
                CharacterMaster      characterMaster = playerCharacterMasterController.master;
                Inventory            inventory       = characterMaster.inventory;
                PlayerStatsComponent component       = playerCharacterMasterController.GetComponent <PlayerStatsComponent>();

                RunReport.PlayerInfo playerInfo = new RunReport.PlayerInfo();
                playerInfo.networkUser     = playerCharacterMasterController.networkUser;
                playerInfo.master          = characterMaster;
                playerInfo.bodyIndex       = BodyCatalog.FindBodyIndex(characterMaster.bodyPrefab);
                playerInfo.killerBodyIndex = characterMaster.GetKillerBodyIndex();
                StatSheet.Copy(component.currentStats, playerInfo.statSheet);
                playerInfo.itemAcquisitionOrder = inventory.itemAcquisitionOrder.ToArray();
                for (ItemIndex itemIndex = ItemIndex.Syringe; itemIndex < ItemIndex.Count; itemIndex++)
                {
                    playerInfo.itemStacks[(int)itemIndex] = inventory.GetItemCount(itemIndex);
                }
                playerInfo.equipment = new EquipmentIndex[inventory.GetEquipmentSlotCount()];
                uint num = 0u;

                while ((ulong)num < (ulong)((long)playerInfo.equipment.Length))
                {
                    playerInfo.equipment[(int)num] = inventory.GetEquipment(num).equipmentIndex;
                    num += 1u;
                }
                return(playerInfo);
            }
Example #11
0
        public void GiveItem(ItemIndex itemIndex, int count = 1)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.Inventory::GiveItem(RoR2.ItemIndex,System.Int32)' called on client");
                return;
            }
            if (count <= 0)
            {
                if (count < 0)
                {
                    this.RemoveItem(itemIndex, -count);
                }
                return;
            }
            base.SetDirtyBit(1u);
            if ((this.itemStacks[(int)itemIndex] += count) == count)
            {
                this.itemAcquisitionOrder.Add(itemIndex);
                base.SetDirtyBit(8u);
            }
            Action action = this.onInventoryChanged;

            if (action != null)
            {
                action();
            }
            Action <Inventory, ItemIndex, int> action2 = Inventory.onServerItemGiven;

            if (action2 != null)
            {
                action2(this, itemIndex, count);
            }
            this.CallRpcItemAdded(itemIndex);
        }
            // Token: 0x060019CF RID: 6607 RVA: 0x0007B424 File Offset: 0x00079624
            public void Read(NetworkReader reader)
            {
                this.bodyIndex       = reader.ReadBodyIndex();
                this.killerBodyIndex = reader.ReadBodyIndex();
                GameObject gameObject = reader.ReadGameObject();

                this.master = (gameObject ? gameObject.GetComponent <CharacterMaster>() : null);
                this.statSheet.Read(reader);
                int newSize = (int)reader.ReadPackedUInt32();

                Array.Resize <ItemIndex>(ref this.itemAcquisitionOrder, newSize);
                for (int i = 0; i < this.itemAcquisitionOrder.Length; i++)
                {
                    ItemIndex itemIndex = reader.ReadItemIndex();
                    this.itemAcquisitionOrder[i] = itemIndex;
                }
                reader.ReadItemStacks(this.itemStacks);
                int newSize2 = (int)reader.ReadPackedUInt32();

                Array.Resize <EquipmentIndex>(ref this.equipment, newSize2);
                for (int j = 0; j < this.equipment.Length; j++)
                {
                    EquipmentIndex equipmentIndex = reader.ReadEquipmentIndex();
                    this.equipment[j] = equipmentIndex;
                }
                this.ResolveLocalInformation();
            }
Example #13
0
        public static int GiveItemIfLess(CharacterMaster characterMaster, ItemIndex itemIndex, bool showInChat = true, CharacterBody characterBody = null, int amount = 1, int max = 1)
        {
            var self           = characterMaster.inventory;
            var InventoryCount = self.GetItemCount(itemIndex);

            //var pickupindex = PickupCatalog.FindPickupIndex(itemIndex);
            //var pickupDef = PickupCatalog.GetPickupDef(pickupindex);
            if (InventoryCount < max)
            {
                if (InventoryCount + amount > max)
                {
                    amount = max - InventoryCount;
                }

                if (!showInChat)
                {
                    _logger.LogDebug("HelperUtil: GiveItemIfLess: ShowInChat was false, so we gave the item.");
                    self.GiveItem(itemIndex, amount);
                }
                else
                {
                    _logger.LogDebug("HelperUtil: GiveItemIfLess: ShowInChat was true, so we called SimulatePickup()");
                    SimulatePickup(characterMaster, itemIndex, amount);
                }
            }
            return(amount);
        }
Example #14
0
        public static void GiveItemToPlayers(ItemIndex itemIndex, bool showInChat = true, int amount = 1)
        {
            var instances = PlayerCharacterMasterController.instances;

            foreach (PlayerCharacterMasterController playerCharacterMaster in instances)
            {
                var master = playerCharacterMaster.master;
                if (master)
                {
                    var body = playerCharacterMaster.body;
                    if (body)
                    {
                        var inventory = master.inventory;

                        if (inventory)
                        {
                            if (showInChat)
                            {
                                SimulatePickup(master, itemIndex, amount);
                            }
                            else
                            {
                                inventory.GiveItem(itemIndex, amount);
                            }
                        }
                    }
                }
            }
        }
Example #15
0
        public ItemList() : base(itemsList)
        {
            if (UmbraMenu.characterCollected)
            {
                int           buttonPlacement = 1;
                List <Button> buttons         = new List <Button>();
                for (int i = 0; i < UmbraMenu.items.Count; i++)
                {
                    ItemIndex itemIndex = UmbraMenu.items[i];
                    void ButtonAction() => GiveItem(itemIndex);

                    Color32 itemColor = ColorCatalog.GetColor(ItemCatalog.GetItemDef(itemIndex).colorIndex);
                    if (itemColor.r <= 105 && itemColor.g <= 105 && itemColor.b <= 105)
                    {
                        string itemName = Util.GenerateColoredString(Language.GetString(ItemCatalog.GetItemDef(itemIndex).nameToken), new Color32(255, 255, 255, 255));
                        Button button   = new Button(new NormalButton(this, buttonPlacement, itemName, ButtonAction));
                        buttons.Add(button);
                        buttonPlacement++;
                    }
                    else
                    {
                        string itemName = Util.GenerateColoredString(Language.GetString(ItemCatalog.GetItemDef(itemIndex).nameToken), itemColor);
                        Button button   = new Button(new NormalButton(this, buttonPlacement, itemName, ButtonAction));
                        buttons.Add(button);
                        buttonPlacement++;
                    }
                }
                AddButtons(buttons);
                SetActivatingButton(Utility.FindButtonById(3, 3));
                SetPrevMenuId(3);
            }
        }
Example #16
0
        private static void BiscoLeashAsRedTierItem()
        {
            var biscoLeashItemDef = new ItemDef
            {
                name             = "BiscosLeash", // its the internal name, no spaces, apostrophes and stuff like that
                tier             = ItemTier.Tier3,
                pickupModelPath  = PrefabPath,
                pickupIconPath   = IconPath,
                nameToken        = "BISCOLEASH_NAME", // stylised name
                pickupToken      = "BISCOLEASH_PICKUP",
                descriptionToken = "BISCOLEASH_DESC",
                loreToken        = "BISCOLEASH_LORE",
                tags             = new[]
                {
                    ItemTag.Utility,
                    ItemTag.Damage
                }
            };

            var itemDisplayRules = new ItemDisplayRule[1];                         // keep this null if you don't want the item to show up on the survivor 3d model. You can also have multiple rules !

            itemDisplayRules[0].followerPrefab = BiscoLeashPrefab;                 // the prefab that will show up on the survivor
            itemDisplayRules[0].childName      = "Chest";                          // this will define the starting point for the position of the 3d model, you can see what are the differents name available in the prefab model of the survivors
            itemDisplayRules[0].localScale     = new Vector3(0.15f, 0.15f, 0.15f); // scale the model
            itemDisplayRules[0].localAngles    = new Vector3(0f, 180f, 0f);        // rotate the model
            itemDisplayRules[0].localPos       = new Vector3(-0.35f, -0.1f, 0f);   // position offset relative to the childName, here the survivor Chest

            var biscoLeash = new R2API.CustomItem(biscoLeashItemDef, itemDisplayRules);

            BiscoLeashItemIndex = ItemAPI.Add(biscoLeash); // ItemAPI sends back the ItemIndex of your item
        }
Example #17
0
        public static void GiveItem(ItemIndex itemIndex)
        {
            var localUser = LocalUserManager.GetFirstLocalUser();

            if (localUser.cachedMasterController && localUser.cachedMasterController.master)
            {
                if (Items.isDropItemForAll)
                {
                    Items.DropItemMethod(itemIndex);
                }
                else if (Items.isDropItemFromInventory)
                {
                    if (Items.CurrentInventory().Contains(itemIndex))
                    {
                        UmbraMenu.LocalPlayerInv.RemoveItem(itemIndex, 1);
                        Items.DropItemMethod(itemIndex);
                    }
                    else
                    {
                        Chat.AddMessage($"<color=yellow> You do not have that item and therefore cannot drop it from your inventory.</color>");
                        Chat.AddMessage($" ");
                    }
                }
                else
                {
                    UmbraMenu.LocalPlayerInv.GiveItem(itemIndex, 1);
                }
            }
        }
        // Token: 0x06002362 RID: 9058 RVA: 0x0009AB3C File Offset: 0x00098D3C
        public void UpdateDisplay()
        {
            this.updateRequestPending = false;
            if (!this || !base.isActiveAndEnabled)
            {
                return;
            }
            ItemIndex[] array = ItemCatalog.RequestItemOrderBuffer();
            int         num   = 0;

            for (int i = 0; i < this.itemOrderCount; i++)
            {
                if (ItemInventoryDisplay.ItemIsVisible(this.itemOrder[i]))
                {
                    array[num++] = this.itemOrder[i];
                }
            }
            this.AllocateIcons(num);
            for (int j = 0; j < num; j++)
            {
                ItemIndex itemIndex = array[j];
                this.itemIcons[j].SetItemIndex(itemIndex, this.itemStacks[(int)itemIndex]);
            }
            ItemCatalog.ReturnItemOrderBuffer(array);
        }
Example #19
0
 public override void RegisterHooks(ItemIndex itemIndex)
 {
     On.RoR2.HealthComponent.TakeDamage += (orig, self, damageInfo) =>
     {
         if ((self.body.isElite || self.body.isBoss) && damageInfo.attacker)
         {
             var attackerBody = damageInfo.attacker.GetComponent <CharacterBody>();
             if (attackerBody != null && attackerBody && attackerBody.master && attackerBody.master.inventory)
             {
                 int itemCount = attackerBody.master.inventory.GetItemCount(itemIndex);
                 if (itemCount > 0)
                 {
                     if (self.body.isElite)
                     {
                         damageInfo.damage *= 1 + StackUtils.LinearStack(itemCount, ELITE_DMG_BASE, ELITE_DMG_STACK);
                     }
                     else if (self.body.isBoss)
                     {
                         damageInfo.damage *= StackUtils.ExponentialStack(itemCount, BOSS_DMG_BASE, BOSS_DMG_STACK);
                     }
                 }
             }
         }
         orig(self, damageInfo);
     };
 }
Example #20
0
        private void CreateItemIndex()
        {
            _data = new ItemIndex
            {
                ItemCategories = new Dictionary <string, List <ItemInfo> >()
            };

            // Create categories
            foreach (string category in Enum.GetNames(typeof(ItemCategory)))
            {
                _data.ItemCategories.Add(category, new List <ItemInfo>());
            }

            // Iterate and categorize items
            foreach (ItemDefinition itemDefinition in ItemManager.GetItemDefinitions())
            {
                _data.ItemCategories[itemDefinition.category.ToString()].Add(
                    new ItemInfo
                {
                    ItemId           = itemDefinition.itemid,
                    Shortname        = itemDefinition.shortname,
                    HasDurability    = itemDefinition.condition.enabled,
                    VanillaStackSize = GetVanillaStackSize(itemDefinition),
                    CustomStackSize  = 0
                });
            }

            _data.VersionNumber = Version;

            SaveData();
        }
Example #21
0
 public static bool IsBossItem(ItemIndex index)
 {
     return(index == ItemIndex.Knurl ||
            index == ItemIndex.SprintWisp ||
            index == ItemIndex.TitanGoldDuringTP ||
            index == ItemIndex.BeetleGland);
 }
        public static string ProvideStatsForItem(ItemIndex itemIndex, int itemCount)
        {
            var itemStatList = testDefs.ContainsKey(itemIndex) ? testDefs[itemIndex] : null;

            if (itemStatList == null)
            {
                return("NOT IMPL");
            }

            var fullStatText = string.Empty;

            foreach (Test subItemStat in itemStatList)
            {
                float statValue = subItemStat.CalculateStat(itemCount);

                var statValueStr = subItemStat.Formatter.Format(statValue);

                if (itemStatList.IndexOf(subItemStat) == itemStatList.Count - 1)
                {
                    // this is the last line
                    // TextMeshPro richtext modifier that allows me to align the stack counter on the right
                    // also TODO: implement WrapIn string extension
                    fullStatText += $"<align=left>{subItemStat.StatText}: {statValueStr}<line-height=0>";
                }
                else
                {
                    fullStatText += $"{subItemStat.StatText}: {statValueStr}\n";
                }
            }

            return($"{fullStatText}\n<align=right>({itemCount} stacks)<line-height=1em>");
        }
        // Token: 0x06000D6F RID: 3439 RVA: 0x0003C4CB File Offset: 0x0003A6CB
        private IEnumerator HighlightNewItem(ItemIndex itemIndex)
        {
            yield return(new WaitForSeconds(0.05f));

            CharacterMaster component = base.GetComponent <CharacterMaster>();

            if (component)
            {
                GameObject bodyObject = component.GetBodyObject();
                if (bodyObject)
                {
                    ModelLocator component2 = bodyObject.GetComponent <ModelLocator>();
                    if (component2)
                    {
                        Transform modelTransform = component2.modelTransform;
                        if (modelTransform)
                        {
                            CharacterModel component3 = modelTransform.GetComponent <CharacterModel>();
                            if (component3)
                            {
                                component3.HighlightItemDisplay(itemIndex);
                            }
                        }
                    }
                }
            }
            yield break;
        }
Example #24
0
        public void ServerRemoveItem(ItemIndex ind)
        {
            if (!NetworkServer.active)
            {
                return;
            }
            if (!itemcounts.ContainsKey(ind))
            {
                return;
            }
            else
            {
                itemcounts[ind]--;
            }
            if (itemcounts[ind] == 0)
            {
                itemcounts.Remove(ind);
            }

            new MsgDeltaDisplay(GetComponent <NetworkIdentity>().netId, ind, false).Send(R2API.Networking.NetworkDestination.Clients);

            trackedInventories.RemoveAll(x => !x || !x.gameObject);
            foreach (var inv in trackedInventories)
            {
                var fakeInv = inv.gameObject.GetComponent <FakeInventory>();
                fakeInv.RemoveItem(ind);
            }
        }
        private GameObject PickupIndex_GetPickupDisplayPrefab(On.RoR2.PickupIndex.orig_GetPickupDisplayPrefab orig, ref PickupIndex self)
        {
            PickupIndex dio = new PickupIndex(ItemIndex.ExtraLife);

            if (self != dio)
            {
                return(orig.Invoke(ref self));
            }
            else
            {
                List <PickupIndex> tier3Items = Run.instance.availableTier3DropList;
                if (!tier3Items.Contains(self))
                {
                    return(orig.Invoke(ref self));
                }


                int rng = random.Next(0, tier3Items.Count);
                if (tier3Items[rng] == dio)
                {
                    rng++;
                }

                ItemIndex rngItem = tier3Items[rng].itemIndex;

                GameObject gameObject = Resources.Load <GameObject>(ItemCatalog.GetItemDef(rngItem).pickupModelPath);
                return(gameObject);
            }
        }
Example #26
0
 // Token: 0x06000B4B RID: 2891 RVA: 0x00031D04 File Offset: 0x0002FF04
 private void OnTriggerStay(Collider other)
 {
     if (NetworkServer.active && this.waitStartTime.timeSince >= this.waitDuration && !this.consumed)
     {
         CharacterBody component = other.GetComponent <CharacterBody>();
         if (component)
         {
             ItemIndex itemIndex = this.pickupIndex.itemIndex;
             if (itemIndex != ItemIndex.None && ItemCatalog.GetItemDef(itemIndex).tier == ItemTier.Lunar)
             {
                 return;
             }
             EquipmentIndex equipmentIndex = this.pickupIndex.equipmentIndex;
             if (equipmentIndex != EquipmentIndex.None)
             {
                 if (EquipmentCatalog.GetEquipmentDef(equipmentIndex).isLunar)
                 {
                     return;
                 }
                 if (component.inventory && component.inventory.currentEquipmentIndex != EquipmentIndex.None)
                 {
                     return;
                 }
             }
             if (this.pickupIndex.coinValue != 0U)
             {
                 return;
             }
             if (GenericPickupController.BodyHasPickupPermission(component))
             {
                 this.AttemptGrant(component);
             }
         }
     }
 }
Example #27
0
        private static void TargetRemoveItem(ConCommandArgs args)
        {
            var localMaster = PlayerCharacterMasterController.instances[0].master;
            var component   = HasComponent(localMaster);

            if (component && component.HasBody())
            {
                var inventory = component.targetedBody.inventory;
                if (inventory)
                { //https://stackoverflow.com/questions/23563960/how-to-get-enum-value-by-string-or-int
                    ItemIndex itemIndex       = (ItemIndex)args.GetArgInt(0);
                    var       targetItemCount = inventory.GetItemCount(itemIndex);

                    int itemCount = args.GetArgInt(1);
                    if (itemCount < 0)
                    {
                        inventory.RemoveItem(itemIndex, targetItemCount);
                        Chat.AddMessage("Removed " + itemIndex + " x" + itemCount + " from " + component.targetedBody.GetDisplayName());
                    }
                    else
                    {
                        var amountToRemove = Mathf.Max(itemCount, targetItemCount);
                        inventory.RemoveItem(itemIndex, amountToRemove);
                        Chat.AddMessage("Removed " + itemIndex + " x" + amountToRemove + " from " + component.targetedBody.GetDisplayName());
                    }
                }
            }
        }
Example #28
0
        private static void SendPickupMessage(CharacterMaster master, PickupIndex pickupIndex)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.GenericPickupController::SendPickupMessage(RoR2.CharacterMaster,RoR2.PickupIndex)' called on client");
                return;
            }
            uint pickupQuantity = 1U;

            if (master.inventory)
            {
                ItemIndex itemIndex = pickupIndex.itemIndex;
                if (itemIndex != ItemIndex.None)
                {
                    pickupQuantity = (uint)master.inventory.GetItemCount(itemIndex);
                }
            }
            GenericPickupController.PickupMessage msg = new GenericPickupController.PickupMessage
            {
                masterGameObject = master.gameObject,
                pickupIndex      = pickupIndex,
                pickupQuantity   = pickupQuantity
            };
            NetworkServer.SendByChannelToAll(57, msg, QosChannelIndex.chat.intVal);
        }
Example #29
0
        private static void HandleAspectDisplay(CharacterModel model, EquipmentDef display, EquipmentDef target, ItemDef item)
        {
            ItemMask  list  = model.enabledItemDisplays;
            ItemIndex index = item.itemIndex;

            if (!target)
            {
                return;
            }

            if (display == target)
            {
                if (!list.Contains(index))
                {
                    list.Add(index);
                    DisplayRuleGroup drg = model.itemDisplayRuleSet.GetEquipmentDisplayRuleGroup(target.equipmentIndex);
                    model.InstantiateDisplayRuleGroup(drg, index, EquipmentIndex.None);
                }
            }
            else
            {
                if (list.Contains(index))
                {
                    list.Remove(index);
                    RemoveAspectDisplay(model, index);
                }
            }
        }
Example #30
0
        /*public void shift_up() {
         *  vertical_tile_offset++;
         *  Debug.Log(vertical_tile_offset);
         * }
         * public void shift_down() {
         *  vertical_tile_offset--;
         *  Debug.Log(vertical_tile_offset);
         * }
         * public void shift_left() {
         *  tile_size -= 0.5f;
         *  Debug.Log(tile_size);
         * }
         * public void shift_right() {
         *  tile_size += 0.5f;
         *  Debug.Log(tile_size);
         * }*/

        public void RegisterOffer(int ItemListLocation, CharacterBody CB)
        {
            // LocalUser User = LocalUserManager.GetFirstLocalUser();

            // Chat.AddMessage($"Item Loc: {ItemListLocation}, Item List: {InvData.Count}, {InvData[ItemListLocation].item_index}");

            ItemIndex item = InvData[ItemListLocation].item_index;

            Transform UserTransform = CB.transform;

            // Debug.Log(firstLocalUser.userProfile.name);
            CB.inventory.RemoveItem(item, 1);
            float player_rot = 0;

            Vector3 mod_rot = new Vector3((float)(Math.Cos(player_rot)) * 10, 20, (float)(Math.Sin(player_rot)) * 10);

            PickupDropletController.CreatePickupDroplet(
                new PickupIndex(item), UserTransform.position, mod_rot);

            string color_tag = "#" + ColorCatalog.GetColorHexString(ItemCatalog.GetItemDef(item).colorIndex);

            // Chat.AddMessage($"{CB.name} has dropped <color={color_tag}> {Language.GetString(ItemCatalog.GetItemDef(item).nameToken)} </color>");
            sendChatMessage($"{CB.GetUserName()} has dropped <color={color_tag}> {Language.GetString(ItemCatalog.GetItemDef(item).nameToken)} </color>");


            InvData[ItemListLocation].count -= 1;
            if (InvData[ItemListLocation].count <= 0)
            {
                InvData.RemoveAt(ItemListLocation);
                Destroy(TileList[TileList.Count - 1]);
                TileList.RemoveAt(TileList.Count - 1);
            }
        }