Change way of gettng Managers to use class name

This commit is contained in:
JonShard
2026-08-01 21:46:52 +02:00
parent ee169a62b6
commit 247a7e316d
4 changed files with 12 additions and 19 deletions
+1 -3
View File
@@ -1,8 +1,6 @@
class_name CombinableItem
extends Node
const RECIPE_MANAGER = preload("res://RecipeManager.gd")
@onready var combine_area_3d: Area3D = $Area3d
@onready var _pickable: XRToolsPickable = get_parent() as XRToolsPickable
@@ -62,7 +60,7 @@ func _on_body_entered(body: Node3D) -> void:
print("CombinableItem _on_body_entered: other is not a foodItem")
return
var result: PackedScene = RECIPE_MANAGER.get_combination_result(_food_item.id, other.id)
var result: PackedScene = RecipeManager.get_combination_result(_food_item.id, other.id)
if not result:
print("CombinableItem _on_body_entered: There is no recipe for %s + %s" % [_food_item.id, other.id])
return
+3 -4
View File
@@ -1,6 +1,5 @@
extends StaticBody3D
const RECIPE_MANAGER = preload("res://RecipeManager.gd")
@export var cook_speed = 1
@onready var snap_zone: XRToolsSnapZone = $XRToolsSnapZone
@@ -75,13 +74,13 @@ func _on_object_picked_up(_item) -> void:
if not _food_item:
print("Hob: held object is not a FoodItem")
return
var result = RECIPE_MANAGER.get_cooking_result(_food_item.id)
var result = RecipeManager.get_cooking_result(_food_item.id)
if not result:
print("Hob: held a FoodItem that is not cookable, id: %s result: %s" % [_food_item.id, result])
return
cooking_result = result
cooking_result_time = RECIPE_MANAGER.get_cooking_time(_food_item.id)
cooking_result_time = RecipeManager.get_cooking_time(_food_item.id)
print("Hob: set cooking_result ", cooking_result)
# The setters above already refresh the display and start the flames.
@@ -106,7 +105,7 @@ func convert_held_to_item(_item: String) -> void:
# Spawn the new item through the server so it replicates to every peer
# (including late joiners), in the old item's position.
var original_transform = old_pickable.global_transform
var new_scene_instance = NetworkManager.spawn_item(RECIPE_MANAGER.get_item_scene(_item).resource_path, original_transform)
var new_scene_instance = NetworkManager.spawn_item(RecipeManager.get_item_scene(_item).resource_path, original_transform)
# Drop and free the old item and pick up the new one
print("Hob freeing old_pickable ", old_pickable)
+7 -9
View File
@@ -1,8 +1,6 @@
class_name Table
extends StaticBody3D
const GAME_MANAGER = preload("res://GameManager.gd")
@export var thinking_duration: float = 3.0
@export var ordering_duration: float = 50.0
@export var primary_duration: float = 70.0
@@ -52,9 +50,9 @@ func place_order() -> void:
print("Table place_order()")
var new_orders: Array[String] = _unsatisfied_orders.duplicate()
for _i in range(0, randi_range(1, 2)):
new_orders.append(GAME_MANAGER.get_random_meal())
new_orders.append(GameManager.get_random_meal())
for _i in range(0, randi_range(0, 1)):
new_orders.append(GAME_MANAGER.get_random_side())
new_orders.append(GameManager.get_random_side())
_unsatisfied_orders = new_orders
_original_orders = _unsatisfied_orders.duplicate()
@@ -243,11 +241,11 @@ func _collect_money_from_food():
var food_item: FoodItem = Helper.find_food_item(held_object)
if plate:
for fi: FoodItem in plate.get_food_items():
GAME_MANAGER.money += fi.sell_value
GameManager.money += fi.sell_value
elif food_item:
GAME_MANAGER.money += food_item.sell_value
GameManager.money += food_item.sell_value
print("Table _collect_money_from_food(), money: ", GAME_MANAGER.money)
print("Table _collect_money_from_food(), money: ", GameManager.money)
func _set_snap_zones_enabled(value: bool) -> void:
@@ -313,7 +311,7 @@ func _state_end(oldState: TableState):
TableState.ORDERING, TableState.WAITING_PRIMARY, TableState.WAITING_FRIEND:
label_3d.text = lbl_gameover
GAME_MANAGER.game_over()
GameManager.game_over()
## Pure presentation, driven off the current (locally authoritative or
@@ -362,7 +360,7 @@ func _process(delta: float) -> void:
if _state_time > 0.0:
_state_time = max(0.0, _state_time - delta)
return
if GAME_MANAGER.game_state == GAME_MANAGER.GameState.GAME_OVER:
if GameManager.game_state == GameManager.GameState.GAME_OVER:
return
_state_end(_state)
+1 -3
View File
@@ -1,13 +1,11 @@
extends Control
@onready var _Restart_btn: Button = %Restart
const GAME_MANAGER = preload("res://GameManager.gd")
func _ready() -> void:
_Restart_btn.pressed.connect(_restart)
func _restart():
GAME_MANAGER._restart()
GameManager._restart()
get_tree().reload_current_scene()