begin work on room state machine
This commit is contained in:
parent
d49752c98a
commit
d23a7c4c36
2 changed files with 49 additions and 0 deletions
48
scenes/room/room_state.gd
Normal file
48
scenes/room/room_state.gd
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
class_name RoomState extends State
|
||||
|
||||
|
||||
const STARTING = "Starting"
|
||||
const PLAYING = "Playing"
|
||||
const EXITING = "Exiting"
|
||||
|
||||
var room: Room
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
await owner.ready
|
||||
room = owner as Room
|
||||
assert(room != null, "The RoomState state type must be used only in the room scene. It needs the owner's parent to be a Room node.")
|
||||
|
||||
|
||||
func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _exit() -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _handle_input(_event: InputEvent) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _state_update(_delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _state_physics_update(_delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func match_state(exclude: Array[StringName] = []) -> StringName:
|
||||
|
||||
return ""
|
||||
|
||||
|
||||
func watch_state(exclude: Array[StringName] = [], data: Dictionary[StringName, Variant] = {}) -> bool:
|
||||
var next_state: StringName = match_state(exclude)
|
||||
if next_state != "":
|
||||
finished.emit(next_state, data)
|
||||
return true
|
||||
|
||||
return false
|
||||
1
scenes/room/room_state.gd.uid
Normal file
1
scenes/room/room_state.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://hjm43hb4os07
|
||||
Loading…
Add table
Reference in a new issue