Example #1
0
        /// <summary>
        /// Drops item by item ID from player's inventory
        /// </summary>
        /// <param name="session"></param>
        /// <param name="itemId"></param>
        public void DropItem(PlayerSession session, int itemId)
        {
#if ITEMV2
            EntityReferenceCache entityReferenceCache = GameManagerUtilities.PlayerRefCache();
#else
            Vector3 position = session.WorldPlayerEntity.transform.position;
#endif
            PlayerInventory inventory = Inventory(session);
            for (int slot = 0; slot < inventory.Capacity; slot++)
            {
#if ITEMV2
                ItemObject item = inventory.GetSlot(slot);
                if (item.ItemId == itemId)
                {
                    inventory.DropSlot(slot, entityReferenceCache.PlayerCamera.SimData.FireDirectionWorldSpace);
                }
#else
                ItemInstance item = inventory.GetSlot(slot);
                if (item.Item.ItemId == itemId)
                {
                    inventory.DropSlot(slot, position + new Vector3(0f, 1f, 0f) + position / 2f, (position + new Vector3(0f, 0.2f, 0f)) * 8f);
                }
#endif
            }
        }
Example #2
0
        /// <summary>
        /// Drops item by item ID from player's inventory
        /// </summary>
        /// <param name="session"></param>
        /// <param name="itemId"></param>
        public void DropItem(PlayerSession session, int itemId)
        {
            EntityReferenceCache entityReferenceCache = GameManagerUtilities.PlayerRefCache();
            PlayerInventory      inventory            = Inventory(session);

            for (int slot = 0; slot < inventory.Capacity; slot++)
            {
                ItemObject item = inventory.GetSlot(slot);
                if (item.ItemId == itemId)
                {
                    inventory.DropSlot(slot, entityReferenceCache.PlayerCamera.SimData.FireDirectionWorldSpace);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Drops item by item ID from player's inventory
        /// </summary>
        /// <param name="session"></param>
        /// <param name="itemId"></param>
        public void DropItem(PlayerSession session, int itemId)
        {
#if ITEMV2
            var entityReferenceCache = GameManagerUtilities.PlayerRefCache();
#else
            var position = session.WorldPlayerEntity.transform.position;
#endif
            var inventory = Inventory(session);
            for (var slot = 0; slot < inventory.Capacity; slot++)
            {
                var item = inventory.GetSlot(slot);
#if ITEMV2
                if (item.ItemId == itemId)
                {
                    inventory.DropSlot(slot, entityReferenceCache.PlayerCamera.SimData.FireDirectionWorldSpace);
                }
#else
                if (item.Item.ItemId == itemId)
                {
                    inventory.DropSlot(slot, (position + new Vector3(0f, 1f, 0f)) + (position / 2f), (position + new Vector3(0f, 0.2f, 0f)) * 8f);
                }
#endif
            }
        }