28 lines
754 B
GDScript
28 lines
754 B
GDScript
extends RoomState
|
|
|
|
|
|
func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void:
|
|
print("entering room")
|
|
room.player = _instantiate_player()
|
|
assert(room.player != null, "player is null")
|
|
room.camera.global_position = room.config.camera_position
|
|
|
|
finished.emit(PLAYING)
|
|
return
|
|
|
|
|
|
func _instantiate_player() -> Player:
|
|
var p: Player = room.player_scene.instantiate()
|
|
room.add_child(p)
|
|
if room.initial_spawn != Vector2i.ZERO:
|
|
p.global_position = room.initial_spawn
|
|
else:
|
|
assert(
|
|
room.config.initial_spawn != Vector2i.ZERO,
|
|
"invalid player initial spawn provided"
|
|
)
|
|
p.global_position = room.config.initial_spawn
|
|
if room.config.enable_point_light:
|
|
p.enable_point_light(true, room.config.point_light_energy)
|
|
|
|
return p
|