Class ItemSpawner
java.lang.Object
com.csse3200.game.entities.spawner.ItemSpawner
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
It holds the information needed to spawn an item -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Entity
Creates a new world-pickable item entity from the given type string.void
spawnItems
(Map<String, List<ItemSpawner.ItemSpawnInfo>> config) Spawns items in the game area based on the provided information.
-
Constructor Details
-
ItemSpawner
-
-
Method Details
-
spawnItems
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
Creates a new world-pickable item entity from the given type string. If the type matches aWeapons
enum constant, a corresponding weapon pickup entity is created viaWorldPickUpFactory
.- Parameters:
type
- which is the type of item to be created- Returns:
- A new
Entity
representing the item, ornull
if the type does not match any known item.
-