Class SpawnTask
java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.components.tasks.SpawnTask
- All Implemented Interfaces:
PriorityTask
,Task
A task that spawns an entity at a specified position after a certain duration.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.csse3200.game.ai.tasks.Task
Task.Status
-
Field Summary
Fields inherited from class com.csse3200.game.ai.tasks.DefaultTask
owner, status
-
Constructor Summary
ConstructorsConstructorDescriptionSpawnTask
(com.badlogic.gdx.math.Vector2 spawnPosition, float spawnDuration) Constructs a new SpawnTask with the specified spawn position and duration. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Completes the spawn task, stopping it and cleaning up if necessary.float
Returns the elapsed time since the spawn task started.int
Returns the priority of this task.float
Returns the duration of the spawn task.com.badlogic.gdx.math.Vector2
Returns the position where the entity will be spawned.void
start()
Starts the spawn task, positioning the entity at the spawn location.Methods inherited from class com.csse3200.game.ai.tasks.DefaultTask
create, getStatus, setOwner, stop, update
-
Constructor Details
-
SpawnTask
public SpawnTask(com.badlogic.gdx.math.Vector2 spawnPosition, float spawnDuration) Constructs a new SpawnTask with the specified spawn position and duration.- Parameters:
spawnPosition
- the position where the entity will be spawnedspawnDuration
- the duration of the spawn task
-
-
Method Details
-
getSpawnPosition
public com.badlogic.gdx.math.Vector2 getSpawnPosition()Returns the position where the entity will be spawned.- Returns:
- the spawn position
-
getSpawnDuration
public float getSpawnDuration()Returns the duration of the spawn task.- Returns:
- the spawn duration
-
getElapsedTime
public float getElapsedTime()Returns the elapsed time since the spawn task started.- Returns:
- the elapsed time
-
getPriority
public int getPriority()Returns the priority of this task. Higher values indicate higher priority.- Specified by:
getPriority
in interfacePriorityTask
- Returns:
- the priority of this task
-
start
public void start()Starts the spawn task, positioning the entity at the spawn location.- Specified by:
start
in interfaceTask
- Overrides:
start
in classDefaultTask
-
completeTask
public void completeTask()Completes the spawn task, stopping it and cleaning up if necessary.
-