2024-03-14 04:17:00 +00:00
|
|
|
extends Node
|
|
|
|
class_name LevelPlaylist
|
|
|
|
|
|
|
|
|
|
|
|
## The [GolfLevel]s that should be sequentially loaded on the [LevelManager].
|
|
|
|
@export var levels: Array[PackedScene] = []
|
|
|
|
|
|
|
|
|
2024-03-16 04:25:23 +00:00
|
|
|
## Emitted when the playlist has advanced to a new level, but before it is returned by [method advanced].
|
|
|
|
signal advanced(level: PackedScene)
|
|
|
|
|
|
|
|
|
2024-03-14 04:17:00 +00:00
|
|
|
## The index of the current level in [field levels].
|
|
|
|
var idx: int = -1
|
|
|
|
|
|
|
|
|
|
|
|
## Advances to the next level in the playlist and returns it as a [PackedScene].
|
|
|
|
##
|
|
|
|
## Returns null when the playlist is complete.
|
|
|
|
func advance() -> PackedScene:
|
|
|
|
idx += 1
|
|
|
|
if idx >= len(levels):
|
|
|
|
return null
|
2024-03-16 04:25:23 +00:00
|
|
|
var level = levels[idx]
|
|
|
|
advanced.emit(level)
|
|
|
|
return level
|