Package com.csse3200.game.entities
Class EntitySpawn
java.lang.Object
com.csse3200.game.entities.EntitySpawn
Computes how many enemies to spawn in the current wave and selects a type per spawn request.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance with a default per-enemy weight cost.EntitySpawn
(int robotWeight) Creates a new instance with a specified per-enemy weight cost.EntitySpawn
(WaveConfigProvider waveConfigProvider, int robotWeight) Test-only constructor allowing injection of a prebuilt WaveConfigProvider to avoid LibGDX file IO in unit tests. -
Method Summary
Modifier and TypeMethodDescriptionint
void
setWaveConfigProvider
(WaveConfigProvider waveConfigProvider) Sets the WaveConfigProvider instance for this EntitySpawn.void
Computes spawn count from the current wave's weight budget and minimum requirement configured in JSON.void
Builds a spawn queue for the current wave using the new system: - Each wave has a budget (waveWeight).
-
Constructor Details
-
EntitySpawn
public EntitySpawn()Creates a new instance with a default per-enemy weight cost. -
EntitySpawn
public EntitySpawn(int robotWeight) Creates a new instance with a specified per-enemy weight cost. Note: WaveManager must be set separately using setWaveManager().- Parameters:
robotWeight
- weight cost of a single enemy used to derive spawn counts
-
EntitySpawn
Test-only constructor allowing injection of a prebuilt WaveConfigProvider to avoid LibGDX file IO in unit tests.- Parameters:
waveConfigProvider
- provider of wave configurationrobotWeight
- weight cost per enemy
-
-
Method Details
-
setWaveConfigProvider
Sets the WaveConfigProvider instance for this EntitySpawn.- Parameters:
waveConfigProvider
- the WaveConfigProvider instance to use
-
getSpawnCount
public int getSpawnCount()- Returns:
- computed spawn count for this wave.
-
spawnEnemies
public void spawnEnemies()Computes spawn count from the current wave's weight budget and minimum requirement configured in JSON. -
getNextRobotType
- Returns:
- next enemy type from the spawn queue, or "standard" if empty.
-
spawnEnemiesFromConfig
public void spawnEnemiesFromConfig()Builds a spawn queue for the current wave using the new system: - Each wave has a budget (waveWeight). - Each enemy type consumes budget (cost). - Enemies are picked randomly, weighted by 'chance'. - Loop continues until budget runs out.
-