Fix all tables consumed the same customer.

This commit is contained in:
JonShard
2026-08-06 18:49:57 +02:00
parent 1cf3afd440
commit d5c162a51a
12 changed files with 73 additions and 39 deletions
+1
View File
@@ -44,6 +44,7 @@ func finish_current_day() -> void:
func _process(delta: float) -> void:
if GameManager.game_state != GameManager.GameState.RUNNING:
return
day_time_remaining -= delta
var customers_at_this_time = GameManager.customers_per_day * get_day_progression()
#print("DayController: customers_at_this_time: ", customers_at_this_time)
+24 -10
View File
@@ -1,3 +1,4 @@
class_name QueueController
extends Node3D
@export var queue_patience: float = 120
@@ -7,26 +8,42 @@ extends Node3D
var _customers: Array[float] = [] # Temp. Array of their patience
var _tables: Array[Node3D] = []
func _ready() -> void:
progress_bar_3d.override_fill_color(Color.YELLOW)
progress_bar_3d.exponential = true
Signals.request_customer_spawn.connect(_on_request_customer_spawn)
Signals.consumed_customer.connect(on_consumed_customer)
Signals.game_state_changed.connect(_on_game_state_changed)
func _on_game_state_changed(new_state: GameManager.GameState) -> void:
if new_state == GameManager.GameState.RUNNING:
_rebuild_table_list()
func _on_request_customer_spawn() -> void:
spawn_customer()
func on_consumed_customer() -> void:
_customers.pop_front()
func spawn_customer() -> void:
_customers.append(queue_patience)
func _rebuild_table_list() -> void:
_tables.clear()
_tables.append_array(get_tree().get_nodes_in_group("table"))
print("QueueController _rebuild_table_list complete: ", _tables)
func _try_to_assign_customers() -> void:
for customer in _customers:
for table: Table in _tables:
var result: bool = table.try_consume_customer()
if result == true:
_customers.pop_front()
break
func _process(delta: float) -> void:
# Process customers patience
for i in range(0, _customers.size()):
@@ -34,10 +51,7 @@ func _process(delta: float) -> void:
if _customers[i] <= 0:
GameManager.game_over()
# Try to assign customers to tables
for customer in _customers:
get_tree().call_group("table", "try_consume_customer")
_try_to_assign_customers()
# Update visuals
if not _customers.is_empty():
+6
View File
@@ -104,6 +104,12 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.6, 0, 0)
[node name="Table" parent="." unique_id=1863572470 instance=ExtResource("11_gaw43")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.8, 0, 1.8)
[node name="Table2" parent="." unique_id=987495548 instance=ExtResource("11_gaw43")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.8, 0, 2.4)
[node name="Table3" parent="." unique_id=113648557 instance=ExtResource("11_gaw43")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.8, 0, 3)
[node name="GameOverPanel" parent="." unique_id=522901881 instance=ExtResource("12_n58f2")]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 2.7718225, 2.8122003, 1.8000003)
scene = ExtResource("13_hooyg")