Class EntitySpawner<T extends IEntity>
java.lang.Object
de.gurkenlabs.litiengine.environment.EntitySpawner<T>
- All Implemented Interfaces:
IEntitySpawner<T>,IUpdateable
public abstract class EntitySpawner<T extends IEntity>
extends java.lang.Object
implements IEntitySpawner<T>TODO: Implement spawn event/listener
TODO: Implement additional constructors to enhance the API
Nested Class Summary
Nested classes/interfaces inherited from interface de.gurkenlabs.litiengine.environment.IEntitySpawner
IEntitySpawner.SpawnModeConstructor Summary
Constructors Constructor Description EntitySpawner(int interval, int amount)EntitySpawner(int interval, int amount, java.util.function.Function<IEntitySpawner<T>,java.util.List<Spawnpoint>> spawnpointCallback)EntitySpawner(int amount, java.util.function.Function<IEntitySpawner<T>,java.util.List<Spawnpoint>> spawnpointCallback)EntitySpawner(java.util.List<Spawnpoint> spawnpoints, int interval, int amount)EntitySpawner(java.util.List<Spawnpoint> spawnpoints, int interval, int amount, IEntitySpawner.SpawnMode spawnMode)Initializes a new instance of theEntitySpawnerclass.EntitySpawner(java.util.List<Spawnpoint> spawnpoints, int amount, IEntitySpawner.SpawnMode spawnMode)Method Summary
Modifier and Type Method Description protected java.util.List<Spawnpoint>getCustomSpawnpoints()intgetSpawnAmount()Gets the amount of Entities that are spawned in each wave.intgetSpawnDelay()Gets the delay between spawning individual Entities of one wave.intgetSpawnInterval()Gets the interval between spawn waves.IEntitySpawner.SpawnModegetSpawnMode()Gets the spawn mode for an EntitySpawner.java.util.List<Spawnpoint>getSpawnPoints()Gets the list of SpawnPoints that a EntitySpawner uses.voidsetSpawnAmount(int amount)Sets the amount of Entities that spawn in each wave.voidsetSpawnDelay(int delay)Gets the delay in milliseconds between spawning individual Entities of one wave.voidsetSpawnInterval(int interval)Sets the interval in milliseconds between each spawn wave.voidsetSpawnMode(IEntitySpawner.SpawnMode mode)Sets the spawn mode.protected booleanshouldSpawn()protected voidspawnNewEntities()Spawn new entities, depending on theSpawnMode, spawnAmount, spawnDelay, and spawnInterval of anEntitySpawner.voidupdate()This method is called by the game loop on all objects that are attached to the loop.
Constructor Details
EntitySpawner
public EntitySpawner(int interval, int amount)EntitySpawner
EntitySpawner
public EntitySpawner(java.util.List<Spawnpoint> spawnpoints, int amount, IEntitySpawner.SpawnMode spawnMode)EntitySpawner
public EntitySpawner(java.util.List<Spawnpoint> spawnpoints, int interval, int amount, IEntitySpawner.SpawnMode spawnMode)Initializes a new instance of theEntitySpawnerclass.- Parameters:
spawnpoints- The spawnpoints from which this instance will choose from when spawning entities.interval- The interval in which entities will be spawned.amount- The amount of entities to spawn on every spawn event.spawnMode- the spawning behaviour
EntitySpawner
public EntitySpawner(int amount, java.util.function.Function<IEntitySpawner<T>,java.util.List<Spawnpoint>> spawnpointCallback)EntitySpawner
public EntitySpawner(int interval, int amount, java.util.function.Function<IEntitySpawner<T>,java.util.List<Spawnpoint>> spawnpointCallback)
Method Details
getSpawnAmount
public int getSpawnAmount()Description copied from interface:IEntitySpawnerGets the amount of Entities that are spawned in each wave.- Specified by:
getSpawnAmountin interfaceIEntitySpawner<T extends IEntity>- Returns:
- the spawn amount
getSpawnInterval
public int getSpawnInterval()Description copied from interface:IEntitySpawnerGets the interval between spawn waves.- Specified by:
getSpawnIntervalin interfaceIEntitySpawner<T extends IEntity>- Returns:
- the spawn interval
getSpawnDelay
public int getSpawnDelay()Description copied from interface:IEntitySpawnerGets the delay between spawning individual Entities of one wave.- Specified by:
getSpawnDelayin interfaceIEntitySpawner<T extends IEntity>- Returns:
- the spawn delay
getSpawnMode
Description copied from interface:IEntitySpawnerGets the spawn mode for an EntitySpawner.- Specified by:
getSpawnModein interfaceIEntitySpawner<T extends IEntity>- Returns:
- the spawn mode
- See Also:
IEntitySpawner.SpawnMode
getSpawnPoints
Description copied from interface:IEntitySpawnerGets the list of SpawnPoints that a EntitySpawner uses.- Specified by:
getSpawnPointsin interfaceIEntitySpawner<T extends IEntity>- Returns:
- the spawn points
setSpawnAmount
public void setSpawnAmount(int amount)Description copied from interface:IEntitySpawnerSets the amount of Entities that spawn in each wave.- Specified by:
setSpawnAmountin interfaceIEntitySpawner<T extends IEntity>- Parameters:
amount- the new amount
setSpawnInterval
public void setSpawnInterval(int interval)Description copied from interface:IEntitySpawnerSets the interval in milliseconds between each spawn wave.- Specified by:
setSpawnIntervalin interfaceIEntitySpawner<T extends IEntity>- Parameters:
interval- the new interval
setSpawnDelay
public void setSpawnDelay(int delay)Description copied from interface:IEntitySpawnerGets the delay in milliseconds between spawning individual Entities of one wave.- Specified by:
setSpawnDelayin interfaceIEntitySpawner<T extends IEntity>- Parameters:
delay- the new spawn delay
setSpawnMode
Description copied from interface:IEntitySpawnerSets the spawn mode.- Specified by:
setSpawnModein interfaceIEntitySpawner<T extends IEntity>- Parameters:
mode- the new spawn mode- See Also:
IEntitySpawner.SpawnMode
update
public void update()Description copied from interface:IUpdateableThis method is called by the game loop on all objects that are attached to the loop. It's called on every tick of the loop and the frequency can be configured using theClientConfiguration.- Specified by:
updatein interfaceIUpdateable- See Also:
ClientConfiguration.setMaxFps(int)
shouldSpawn
protected boolean shouldSpawn()getCustomSpawnpoints
spawnNewEntities
protected void spawnNewEntities()Spawn new entities, depending on theSpawnMode, spawnAmount, spawnDelay, and spawnInterval of anEntitySpawner.- See Also:
IEntitySpawner.SpawnMode
