コード例 #1
0
        public override void update(float elapsed)
        {
            if (
                entity_.info.state != ObjectState.OK ||
                input_ == null || input_.entity_.info.state == ObjectState.DAMAGED ||
                output_ == null || output_.entity_.info.state == ObjectState.DAMAGED
                )
            {
                return;
            }

            int        itemIndex = input_.getFirstItem();
            GameEntity item      = input_.getItem(itemIndex);

            if (item == null)
            {
                currentTime_ = 0;
                return;
            }

            if (!output_.canPlaceItem(item) || output_.getNumItem(item.item) >= output_.numberPerSlot_)
            {
                currentTime_ = 0;
                return;
            }

            currentTime_ += elapsed;

            if (currentTime_ >= processTime_)
            {
                currentTime_ = 0;
                output_.offerItem(Locator.getObjectFactory().createItem(item.item, 1));
                if (item.item.number_ > 1)
                {
                    item.item.number_--;
                    input_.onUpdate();
                }
                else
                {
                    input_.takeItem(itemIndex);
                }
            }
            if (notify_ != null)
            {
                notify_();
            }
        }
コード例 #2
0
        private void checkStatus()
        {
            InventoryComponent ic = entity_.inventory;

            for (int index = 0; index < ic.capacity; ++index)
            {
                GameEntity item = ic.getItem(index);
                if (item == null)
                {
                    continue;
                }
                if (item.item.ID_ == Locator.getObjectFactory().orbItem.ID_)
                {
                    entity_.info.state = ObjectState.OK;
                    return;
                }
            }
            entity_.info.state = ObjectState.DISABLED;
        }