Station Move handles disabled when not in build mode
This commit is contained in:
@@ -16,9 +16,3 @@ func _ready() -> void:
|
|||||||
# Later we will do procedural generation here.
|
# Later we will do procedural generation here.
|
||||||
# For now we just load a scene.
|
# For now we just load a scene.
|
||||||
NetworkManager.call_deferred("spawn_item", kitchen_scene.resource_path, transform)
|
NetworkManager.call_deferred("spawn_item", kitchen_scene.resource_path, transform)
|
||||||
|
|
||||||
func _unhandled_input(event: InputEvent) -> void:
|
|
||||||
if event.is_action_pressed("satisfy_table_orders"):
|
|
||||||
var trans: Transform3D = transform
|
|
||||||
trans.origin += Vector3(-1.2, 0, 0)
|
|
||||||
NetworkManager.call_deferred("spawn_item", hob_scene.resource_path, trans)
|
|
||||||
|
|||||||
@@ -16,8 +16,16 @@ var ghost_materials: Array[StandardMaterial3D] = []
|
|||||||
const GHOST_COLOR_VALID: Color = Color(0, 1, 0, 0.35)
|
const GHOST_COLOR_VALID: Color = Color(0, 1, 0, 0.35)
|
||||||
const GHOST_COLOR_INVALID: Color = Color(1, 0, 0, 0.35)
|
const GHOST_COLOR_INVALID: Color = Color(1, 0, 0, 0.35)
|
||||||
|
|
||||||
# TODO: public toggle to disable handle in build mode.
|
|
||||||
# TODO: If game exits build mode, drop the handle before disabling it.
|
func set_move_handle_enabled(enabled: bool) -> void:
|
||||||
|
move_handle.visible = enabled
|
||||||
|
move_handle.enabled = enabled
|
||||||
|
if enabled:
|
||||||
|
move_handle.drop()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_game_state_changed(new_state: GameManager.GameState) -> void:
|
||||||
|
set_move_handle_enabled(new_state == GameManager.GameState.BUILDING)
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
@@ -39,6 +47,8 @@ func _ready() -> void:
|
|||||||
move_ghost.visible = false
|
move_ghost.visible = false
|
||||||
_cache_ghost_materials()
|
_cache_ghost_materials()
|
||||||
_set_ghost_color(GHOST_COLOR_VALID)
|
_set_ghost_color(GHOST_COLOR_VALID)
|
||||||
|
set_move_handle_enabled(false)
|
||||||
|
Signals.game_state_changed.connect(_on_game_state_changed)
|
||||||
|
|
||||||
|
|
||||||
func _cache_ghost_materials() -> void:
|
func _cache_ghost_materials() -> void:
|
||||||
|
|||||||
@@ -7,11 +7,16 @@ static var sides_in_play: Array[String]
|
|||||||
|
|
||||||
enum GameState {
|
enum GameState {
|
||||||
RUNNING,
|
RUNNING,
|
||||||
GAME_OVER
|
GAME_OVER,
|
||||||
|
BUILDING
|
||||||
}
|
}
|
||||||
static var game_state: GameState = GameState.RUNNING
|
static var game_state: GameState = GameState.RUNNING: set = _set_game_state
|
||||||
|
|
||||||
|
|
||||||
|
static func _set_game_state(value: GameState):
|
||||||
|
game_state = value
|
||||||
|
Signals.game_state_changed.emit(value)
|
||||||
|
|
||||||
static func _restart():
|
static func _restart():
|
||||||
print("restart Game")
|
print("restart Game")
|
||||||
game_state = GameState.RUNNING
|
game_state = GameState.RUNNING
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ extends Node
|
|||||||
|
|
||||||
signal game_over
|
signal game_over
|
||||||
signal restart_game
|
signal restart_game
|
||||||
|
signal game_state_changed(new_state: GameManager.GameState)
|
||||||
@@ -5,6 +5,10 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
if event.is_action_pressed("satisfy_table_orders"):
|
if event.is_action_pressed("satisfy_table_orders"):
|
||||||
satisfy_table_orders()
|
satisfy_table_orders()
|
||||||
|
if event.is_action_pressed("set_building_mode"):
|
||||||
|
set_buidling_mode()
|
||||||
|
if event.is_action_pressed("set_running_mode"):
|
||||||
|
set_running_mode()
|
||||||
|
|
||||||
|
|
||||||
# Finds any node of class/type Table and calls satisfyAllOrders()
|
# Finds any node of class/type Table and calls satisfyAllOrders()
|
||||||
@@ -17,4 +21,11 @@ func satisfy_table_orders() -> void:
|
|||||||
node.satisfyAllOrders()
|
node.satisfyAllOrders()
|
||||||
|
|
||||||
|
|
||||||
|
func set_buidling_mode():
|
||||||
|
print("Global key event: Setting building mode")
|
||||||
|
GameManager.game_state = GameManager.GameState.BUILDING
|
||||||
|
|
||||||
|
|
||||||
|
func set_running_mode():
|
||||||
|
print("Global key event: Setting running mode")
|
||||||
|
GameManager.game_state = GameManager.GameState.RUNNING
|
||||||
|
|||||||
@@ -61,6 +61,16 @@ satisfy_table_orders={
|
|||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
set_building_mode={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":46,"key_label":0,"unicode":46,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
set_running_mode={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":44,"key_label":0,"unicode":44,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[layer_names]
|
[layer_names]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user