Class ItemSpawner

java.lang.Object
com.csse3200.game.entities.spawner.ItemSpawner

public class ItemSpawner extends Object
Spawns items in the game area based on a provided configuration. The configuration maps item types to their spawn locations and quantities. Each item type should have a corresponding creation method in the WeaponsFactory or other relevant factory.
  • Constructor Details

    • ItemSpawner

      public ItemSpawner(GameArea gameArea)
  • Method Details

    • spawnItems

      public void spawnItems(Map<String,List<ItemSpawner.ItemSpawnInfo>> config)
      Spawns items in the game area based on the provided information. Each item type is created using the appropriate factory method.
      Parameters:
      config - A map where keys are item types and values are lists of ItemSpawnInfo objects
    • makeItem

      protected Entity makeItem(String type)
      Creates a new world-pickable item entity from the given type string. If the type matches a Weapons enum constant, a corresponding weapon pickup entity is created via WorldPickUpFactory.
      Parameters:
      type - which is the type of item to be created
      Returns:
      A new Entity representing the item, or null if the type does not match any known item.