Class SingleDropHandler

java.lang.Object
com.csse3200.game.components.npc.SingleDropHandler

public class SingleDropHandler extends Object
Handles the dropping one item for one entity on a specified trigger and at a specified rate.
  • Constructor Details

    • SingleDropHandler

      public SingleDropHandler(Supplier<Entity> createItem, int triggersToNextDrop, BiConsumer<String,EventListener0> listener, String trigger, boolean requiresTamed)
      Constructor for SingleDropHandler
      Parameters:
      createItem - Method that creates item to be dropped
      triggersToNextDrop - Number of triggers until item is dropped
      listener - Method to add new listener
      trigger - Trigger that will prompt item drop
  • Method Details

    • setEntity

      public void setEntity(Entity entity)
      Set the entity that is dropping the item. This method has to be separate from the constructor as the entity may not be instantiated before this class is instantiated.
      Parameters:
      entity - The entity that is dropping the item
    • dropItem

      public void dropItem()
      Drops item at entity's location. Checks tamed status (if necessary) and maintains drop rate.
    • getListener

      public BiConsumer<String,EventListener0> getListener()
      Getter for listener
      Returns:
      listener for the trigger
    • getTrigger

      public String getTrigger()
      Getter for trigger
      Returns:
      trigger that prompts item drop
    • dispose

      public void dispose()