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.SpawnMode
Constructor 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 theEntitySpawner
class.EntitySpawner(java.util.List<Spawnpoint> spawnpoints, int amount, IEntitySpawner.SpawnMode spawnMode)
Method Summary
Modifier and Type Method Description protected java.util.List<Spawnpoint>
getCustomSpawnpoints()
int
getSpawnAmount()
Gets the amount of Entities that are spawned in each wave.int
getSpawnDelay()
Gets the delay between spawning individual Entities of one wave.int
getSpawnInterval()
Gets the interval between spawn waves.IEntitySpawner.SpawnMode
getSpawnMode()
Gets the spawn mode for an EntitySpawner.java.util.List<Spawnpoint>
getSpawnPoints()
Gets the list of SpawnPoints that a EntitySpawner uses.void
setSpawnAmount(int amount)
Sets the amount of Entities that spawn in each wave.void
setSpawnDelay(int delay)
Gets the delay in milliseconds between spawning individual Entities of one wave.void
setSpawnInterval(int interval)
Sets the interval in milliseconds between each spawn wave.void
setSpawnMode(IEntitySpawner.SpawnMode mode)
Sets the spawn mode.protected boolean
shouldSpawn()
protected void
spawnNewEntities()
Spawn new entities, depending on theSpawnMode
, spawnAmount, spawnDelay, and spawnInterval of anEntitySpawner
.void
update()
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 theEntitySpawner
class.- 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:IEntitySpawner
Gets the amount of Entities that are spawned in each wave.- Specified by:
getSpawnAmount
in interfaceIEntitySpawner<T extends IEntity>
- Returns:
- the spawn amount
getSpawnInterval
public int getSpawnInterval()Description copied from interface:IEntitySpawner
Gets the interval between spawn waves.- Specified by:
getSpawnInterval
in interfaceIEntitySpawner<T extends IEntity>
- Returns:
- the spawn interval
getSpawnDelay
public int getSpawnDelay()Description copied from interface:IEntitySpawner
Gets the delay between spawning individual Entities of one wave.- Specified by:
getSpawnDelay
in interfaceIEntitySpawner<T extends IEntity>
- Returns:
- the spawn delay
getSpawnMode
Description copied from interface:IEntitySpawner
Gets the spawn mode for an EntitySpawner.- Specified by:
getSpawnMode
in interfaceIEntitySpawner<T extends IEntity>
- Returns:
- the spawn mode
- See Also:
IEntitySpawner.SpawnMode
getSpawnPoints
Description copied from interface:IEntitySpawner
Gets the list of SpawnPoints that a EntitySpawner uses.- Specified by:
getSpawnPoints
in interfaceIEntitySpawner<T extends IEntity>
- Returns:
- the spawn points
setSpawnAmount
public void setSpawnAmount(int amount)Description copied from interface:IEntitySpawner
Sets the amount of Entities that spawn in each wave.- Specified by:
setSpawnAmount
in interfaceIEntitySpawner<T extends IEntity>
- Parameters:
amount
- the new amount
setSpawnInterval
public void setSpawnInterval(int interval)Description copied from interface:IEntitySpawner
Sets the interval in milliseconds between each spawn wave.- Specified by:
setSpawnInterval
in interfaceIEntitySpawner<T extends IEntity>
- Parameters:
interval
- the new interval
setSpawnDelay
public void setSpawnDelay(int delay)Description copied from interface:IEntitySpawner
Gets the delay in milliseconds between spawning individual Entities of one wave.- Specified by:
setSpawnDelay
in interfaceIEntitySpawner<T extends IEntity>
- Parameters:
delay
- the new spawn delay
setSpawnMode
Description copied from interface:IEntitySpawner
Sets the spawn mode.- Specified by:
setSpawnMode
in interfaceIEntitySpawner<T extends IEntity>
- Parameters:
mode
- the new spawn mode- See Also:
IEntitySpawner.SpawnMode
update
public void update()Description copied from interface:IUpdateable
This 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:
update
in 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