Entity Spawner - UQcsse3200/2024-studio-1 GitHub Wiki
The EntitySpawner
class is responsible for generating and placing animals and items throughout the map in the game. It manages the logic for determining where (and soon when) to spawn these entities through the index generated by the seed provided to it.
- random number generator: in charges of randomizing a number based on the given for randomizing uses in the class
- gameArea: the current gameArea (or the current room)
- npcFactory: the NPCFactory in charge of creating the animals
- animals: a List<List> contains the sequence of animals for each index
- items: a List<List> contains the sequence of items for each index
- setGameArea(): set the current game area, usually called when a room is created
- addAnimalGroups(): add a List of animals to the
animals
List<List>, serves to add custom animals sequence to the List - addItemGroups(): similar to addAnimalGroup() but for
items
. - spawnAnimalGroup(): spawns the group of animals based on the given index in
animals
- spawnItemGroup(): similar to spawnAnimalGroup() but for
items
##Usage Firstly set the game area for the spawner
After that, we should add some components to the animals
and items
through their helper functions
Finally, call spawnAnimalGroup() and spawnItemGroup() (please note that in this picture indexes are set to 0 but they are intended to be set to animal_index
and item_index
)