Class GreedyEntity

    • Field Detail

      • inventoryOperationLock

        protected final Object inventoryOperationLock
        A lock to synchronize all operations involving the entities inventory.
    • Constructor Detail

      • GreedyEntity

        public GreedyEntity()
    • Method Detail

      • getInventory

        public Inventory getInventory()
        Returns:
        the inventory of this greedy entity
      • canCarry

        public boolean canCarry​(Class<? extends CollectableEntity> type)
        Description copied from interface: EntityCollector
        Check if this can collect and drop the given collectable entity type.
        Specified by:
        canCarry in interface EntityCollector
        Parameters:
        type - The type to check; must not be null
        Returns:
        true if this entity collector can collect or drop the given entity type
      • getCurrentlyCollectableEntities

        public <T extends CollectableEntityList<T> getCurrentlyCollectableEntities​(Class<T> type,
                                                                                     boolean includeSubclasses)
        Get all the currently collectable entities of the given type
        Type Parameters:
        T - The generic type to return the entities as
        Parameters:
        type - The type of entity to get; must not be null
        includeSubclasses - Whether to include the subclasses of the given type
        Returns:
        A list of currently collectable entities matching the type
      • collect

        public void collect​(CollectableEntity entity)
        Description copied from interface: EntityCollector
        Collect the given entity.
        Specified by:
        collect in interface EntityCollector
        Parameters:
        entity - The entity to collect; must not be null; must be collectable by this
      • getCurrentlyDroppableEntities

        public <T extends CollectableEntityList<T> getCurrentlyDroppableEntities​(Class<T> type,
                                                                                   boolean includeSubclasses)
        Get all the currently droppable entities of the given type
        Type Parameters:
        T - The generic type to return the entities as
        Parameters:
        type - The type of entity to get; must not be null
        includeSubclasses - Whether to include the subclasses of the given type
        Returns:
        A list of currently collectable entities matching the type
      • drop

        public void drop​(CollectableEntity entity,
                         Position pos)
        Description copied from interface: EntityCollector
        Drop the given entity.
        Specified by:
        drop in interface EntityCollector
        Parameters:
        entity - The entity to drop;must not be null; must be droppable by this
        pos - The position to drop the entity at; must not be null
      • drop

        public void drop​(CollectableEntity entity)
        Drop the given entity at the current position.
        Parameters:
        entity - The entity to drop;must not be null; must be droppable by this *
        Throws:
        CannotDropEntityException - if the given entity cannot be dropped right now for any reason
        IllegalArgumentException - if an argument is null