public virtual void OnEnter(Item item)
 {
     if (item != null && !item.Deleted)
     {
         Items.AddOrReplace(item);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Adds the item to the player's list of items if it is: 1) new; 2) better than the current item of that type; or 3) stackable.
        /// Adds the value of the item that was not kept to <see cref="JunkValue"/>.
        /// Invokes the <see cref="ItemGained"/> event.
        /// </summary>
        /// <param name="newItem">The item to give the player</param>
        /// <param name="compareFunc">The function for comparing the new item to the existing one</param>
        /// <param name="firstItem">Whether this is the first item in a group that the player is receiving</param>
        private void AddOrReplaceItem(Item newItem, bool firstItem = true)
        {
            Item junkedItem = Items.AddOrReplace(newItem);

            if (junkedItem != null)
            {
                JunkValue += junkedItem.Value;
            }

            ItemGainedEventArgs eventArgs = new ItemGainedEventArgs()
            {
                Item      = newItem,
                ItemKept  = junkedItem != newItem,
                FirstItem = firstItem
            };

            UpdateStats();

            ItemGained?.Invoke(this, eventArgs);
        }
Esempio n. 3
0
        public override void OnEnter(Item item)
        {
            base.OnEnter(item);

            if (item == null || item.Deleted)
            {
                return;
            }

            if (Items != null)
            {
                Items.AddOrReplace(item);
            }

            var reg = item.GetRegion <InstanceRegion>();

            if (reg != null)
            {
                reg.OnEnter(item);
            }
        }