Cleanup logs, make prints more uniform.

This commit is contained in:
JonShard
2026-08-14 10:02:26 +02:00
parent 9e0c3ed174
commit f28c987a3a
26 changed files with 184 additions and 184 deletions
+9 -9
View File
@@ -19,9 +19,9 @@ var contained_items: Array[FoodItem] # Expose nice list of others to read
func _ready() -> void:
area_3d.body_entered.connect(_on_body_entered)
if not area_3d:
push_error("Area3D node not found in container.gd")
SweetLogger.warning("{0} missing area_3d reference", [name])
if not xr_pickable:
push_error("XRPickable node not found in container.gd")
SweetLogger.warning("{0} missing xr_pickable reference", [name])
# Absorbing items is a server decision (the container's holder is server-
@@ -29,13 +29,13 @@ func _ready() -> void:
func _on_body_entered(body: Node3D) -> void:
if not NetworkManager.owns_world():
return
SweetLogger.debug("enabled: {0}", [enabled])
SweetLogger.debug("Enabled: {0}", [enabled])
if not enabled:
SweetLogger.debug("disabled in _on_body_entered body")
SweetLogger.debug("Disabled in _on_body_entered body")
return
if not body.is_in_group(target_group):
return
SweetLogger.debug("body: {0}", [body])
SweetLogger.debug("Body: {0}", [body])
# If one of us is in a station
@@ -46,14 +46,14 @@ func _on_body_entered(body: Node3D) -> void:
# If enough space, add item
var food_item = body.get_node("FoodItem")
SweetLogger.debug("in station found {0} of type {1}: {2}", [target_group, FoodItem.Type.keys()[food_item.type], body.name], "container.gd", "_on_body_entered")
SweetLogger.debug("In station found {0} of type {1}: {2}", [target_group, FoodItem.Type.keys()[food_item.type], body.name], "container.gd", "_on_body_entered")
var meal_count := contained_items.filter(func(f): return f.type == FoodItem.Type.MEAL).size()
var side_count := contained_items.filter(func(f): return f.type == FoodItem.Type.SIDE).size()
if food_item.type == FoodItem.Type.MEAL and meal_count < meal_positions.size():
SweetLogger.debug("adding meal")
SweetLogger.debug("Adding meal")
_add_item(body)
if food_item.type == FoodItem.Type.SIDE and side_count < side_positions.size():
SweetLogger.debug("adding side")
SweetLogger.debug("Adding side")
_add_item(body)
@@ -93,7 +93,7 @@ func _add_item(item: Node3D) -> void:
NetworkManager.despawn_item(item)
# In case the container is on a table that needs to register this addition,
# ask all table in scene to absorb any new items.
SweetLogger.debug("group call absorb_items()")
SweetLogger.debug("Group call absorb_items()")
get_tree().call_group("table", "absorb_items")
+1 -1
View File
@@ -18,7 +18,7 @@ func get_food_items() -> Array[FoodItem]:
func _ready() -> void:
if not dirty_node:
push_error("Plate is missing its dirty_node")
SweetLogger.warning("{0} missing dirty_node reference", [name])
dirty_node.visible = is_dirty
+1 -1
View File
@@ -33,7 +33,7 @@ var _grab_race_logged := false
func _ready() -> void:
_pickable = get_parent() as XRToolsPickable
if not _pickable:
push_error("NetPickable must be a child of an XRToolsPickable")
SweetLogger.error("{0} must be a child of an XRToolsPickable", [name])
return
_original_freeze_mode = _pickable.freeze_mode
_original_enabled = _pickable.enabled
+2 -2
View File
@@ -154,7 +154,7 @@ func _despawn_static_item(path: NodePath) -> void:
func _spawn_item_from_data(data: Variant) -> Node:
var scene: PackedScene = load(data["scene"])
if not scene:
push_error("spawn_item: could not load scene %s" % str(data.get("scene")))
SweetLogger.error("Could not load scene {0}", [str(data.get("scene"))])
return null
var inst := scene.instantiate()
if inst is Node3D:
@@ -474,7 +474,7 @@ func _on_player_absent(peer_id: int) -> void:
# --- Command-line driven test bootstrap -----------------------------------
func _handle_cmdline() -> void:
SweetLogger.info("Networkmanager _handle_cmdline()")
SweetLogger.debug("->[]")
var args := OS.get_cmdline_args()
if args.has("--server"):
log_line("cmdline: --server")
+2 -2
View File
@@ -7,7 +7,7 @@ func _ready() -> void:
func _on_game_state_changed(new_state: GameManager.GameState) -> void:
SweetLogger.info("game_state_changed to {0}", [GameManager.GameState.keys()[new_state]], "build_mode_controller.gd", "_on_game_state_changed")
SweetLogger.info("Game state changed to {0}", [GameManager.GameState.keys()[new_state]], "build_mode_controller.gd", "_on_game_state_changed")
if new_state == GameManager.GameState.BUILDING:
despawn_unheld_pickables()
@@ -25,7 +25,7 @@ func despawn_unheld_pickables():
NetworkManager.despawn_item(pickable)
continue
if not held_by.is_in_group("persistent_inventory"):
SweetLogger.debug("despawn_unheld_pickables held_by: {0}, pickable: {1}", [held_by, pickable])
SweetLogger.debug("Despawn unheld pickable held_by: {0}, pickable: {1}", [held_by, pickable])
NetworkManager.despawn_item(pickable)
+7 -7
View File
@@ -10,16 +10,16 @@ var _food_item: FoodItem
func _ready() -> void:
SweetLogger.debug("_ready(): {0}", [_pickable.name])
SweetLogger.debug("{0} ready", [_pickable.name])
_food_item = get_parent().get_node_or_null("FoodItem") as FoodItem
if not _food_item:
push_error("CombinableItem is missing FoodItem reference. must be a sibling of a FoodItem on ", get_parent().name, ".")
SweetLogger.warning("{0} missing FoodItem reference, must be a sibling of a FoodItem", [get_parent().name])
if not _pickable:
push_error("CombineZone must be a grand child of an XRToolsPickable.")
SweetLogger.error("{0} must be a grandchild of an XRToolsPickable", [get_parent().name])
return
if not _food_item:
push_error("CombineZone requires a FoodItem sibling on ", _pickable.name, ".")
SweetLogger.warning("{0} requires a FoodItem sibling", [_pickable.name])
return
# Detect items whether held (layer 17 "Held Objects") or loose
@@ -52,12 +52,12 @@ func _on_body_entered(body: Node3D) -> void:
if not NetworkManager.owns_world():
return
if _combining or body == _pickable:
SweetLogger.debug("other is our own pickable")
SweetLogger.debug("Other is our own pickable")
return
var other := Helper.find_food_item(body)
if not other:
SweetLogger.debug("other is not a foodItem")
SweetLogger.debug("Other is not a FoodItem")
return
var result: PackedScene = RecipeManager.get_combination_result(_food_item.id, other.id)
@@ -69,7 +69,7 @@ func _on_body_entered(body: Node3D) -> void:
# Instantiate the result of combination and free the two ingredient items
func _combine(other_body: Node3D, result: PackedScene) -> void:
SweetLogger.debug("combining {0} + {1} into {2}", [_food_item.id, Helper.find_food_item(other_body).id, result.resource_path])
SweetLogger.debug("Combining {0} + {1} into {2}", [_food_item.id, Helper.find_food_item(other_body).id, result.resource_path])
# Get Snapzone
var snap_zone := _pickable.get_picked_up_by()
+1 -1
View File
@@ -6,4 +6,4 @@ extends Node
func _ready() -> void:
if not turns_into:
push_error("Cooking Error: 'turns_into' PackedScene is missing on ", name, ". Please assign a scene in the Inspector.")
SweetLogger.warning("{0} missing turns_into reference", [name])
+3 -3
View File
@@ -15,10 +15,10 @@ var _time_left: float = time_to_despawn
func _ready() -> void:
if not _pickable:
push_error("DespawningItem must be a grand child of an XRToolsPickable.")
SweetLogger.error("{0} must be a grandchild of an XRToolsPickable", [name])
return
if not _rigid:
push_error("DespawningItem must be a grand child of an RigidBody3D.")
SweetLogger.error("{0} must be a grandchild of a RigidBody3D", [name])
return
@@ -41,7 +41,7 @@ func _process(delta: float) -> void:
# Count down to zero and despawn
_time_left -= delta
if _time_left <= 0:
SweetLogger.debug("despawning {0}", [get_parent()])
SweetLogger.debug("Despawning {0}", [get_parent()])
NetworkManager.despawn_item(get_parent())
# Stop counting: despawn_item() only queues the free, so without this we
# keep re-reporting the same item every frame until it actually goes.
+3 -3
View File
@@ -7,12 +7,12 @@ extends Node3D
func _ready() -> void:
if not kitchen_scene:
push_error("StationSpawner missing kitchen_scene")
SweetLogger.warning("{0} missing kitchen_scene reference", [name])
SweetLogger.debug("initializing")
SweetLogger.debug("->[]")
if NetworkManager.owns_world():
SweetLogger.debug("initializing on server")
SweetLogger.debug("Initializing on server")
# Later we will do procedural generation here.
# For now we just load a scene.
NetworkManager.call_deferred("spawn_item", kitchen_scene.resource_path, transform)
+4 -4
View File
@@ -30,14 +30,14 @@ func _reset_values() -> void:
func start_next_day() -> void:
SweetLogger.info("starting next day")
SweetLogger.info("Starting next day")
_reset_values()
GameManager.set_customers_per_day(GameManager.customers_per_day + GameManager.customers_count_increase_per_day)
GameManager.set_day_number(GameManager.day_number + 1)
func finish_current_day() -> void:
SweetLogger.info("finishing current day")
SweetLogger.info("Finishing current day")
_reset_values()
@@ -50,9 +50,9 @@ func _process(delta: float) -> void:
#print("DayController: customers_at_this_time: ", customers_at_this_time)
if customers_spawned < customers_at_this_time:
customers_spawned += 1
SweetLogger.debug("spawning customer")
SweetLogger.debug("Spawning customer")
Signals.request_customer_spawn.emit()
# If day complete
if GameManager.customers_per_day == customers_served and customers_spawned == GameManager.customers_per_day:
SweetLogger.info("day complete")
SweetLogger.info("Day complete")
finish_current_day()
+1 -1
View File
@@ -32,7 +32,7 @@ func spawn_customer() -> void:
func _rebuild_table_list() -> void:
_tables.clear()
_tables.append_array(get_tree().get_nodes_in_group("table"))
SweetLogger.debug("_rebuild_table_list complete: {0}", [_tables])
SweetLogger.debug("Rebuild table list complete: {0}", [_tables])
func _try_to_assign_customers() -> void:
+10 -10
View File
@@ -114,14 +114,14 @@ func get_next(size, walls):
var offset = [-1,-1]
walls.shuffle()
SweetLogger.debug("get_next size: {0}", [size])
SweetLogger.debug("Size: {0}", [size])
for wall in walls:
SweetLogger.debug("get_next wall: {0}", [wall])
SweetLogger.debug("Wall: {0}", [wall])
if wall["der"][1] == 0:
SweetLogger.debug("get_next horizontal wall")
SweetLogger.debug("Horizontal wall")
if size[0]<wall["len"]-6:
SweetLogger.debug("TileMapLayer get_next length 6 less can go anywhere")
SweetLogger.debug("Length 6 less can go anywhere")
if wall["der"][0] == 1:offset[1] = wall["pos"][1]
else: offset[1] = wall["pos"][1]-size[1]
@@ -130,16 +130,16 @@ func get_next(size, walls):
if size[0]+offset[0]>wall["pos"][0]+wall["len"]-3:offset[0] = wall["len"]-(3+size[0])
elif size[0]<=wall["len"]-3:
SweetLogger.debug("TileMapLayer get_next 3 less needs to be on a corner")
SweetLogger.debug("3 less needs to be on a corner")
if wall["der"][0] == 1:offset[1] = wall["pos"][1]
else: offset[1] = wall["pos"][1]-size[1]
if randi_range(0, 1):offset[0]=wall["pos"][0]+wall["len"]-size[0]
else:offset[0] = wall["pos"][0]
else:
SweetLogger.debug("get_next vertical wall")
SweetLogger.debug("Vertical wall")
if size[1]<wall["len"]-6:
SweetLogger.debug("TileMapLayer get_next length 6 less can go anywhere")
SweetLogger.debug("Length 6 less can go anywhere")
if wall["der"][1] == 1:offset[0] = wall["pos"][0]
else: offset[0] = wall["pos"][0]-size[0]
@@ -148,10 +148,10 @@ func get_next(size, walls):
if size[1]+offset[1]>wall["len"]-3:offset[1] = wall["len"]-(3+size[1])
elif size[1]<=wall["len"]-3:
SweetLogger.debug("TileMapLayer get_next 3 less needs to be on a corner")
SweetLogger.debug("3 less needs to be on a corner")
if wall["der"][1] == 1:offset[0] = wall["pos"][0]
else: offset[0] = wall["pos"][0]-size[0]
SweetLogger.debug("get_next offset: {0}", [offset])
SweetLogger.debug("Offset: {0}", [offset])
if randi() % 2:offset[1]=wall["pos"][1]+wall["len"]-size[1]
else:offset[1] = wall["pos"][1]
@@ -165,7 +165,7 @@ func get_next(size, walls):
func draw_room(Size, offset=Vector2i(0, 0)):
var walls = []
offset = Vector2i(offset[0], offset[1])
SweetLogger.debug("draw_room size: {0} offset: {1}", [Size, offset])
SweetLogger.debug("Size: {0} offset: {1}", [Size, offset])
for i in range(Size[0]):
tile_map.set_cell(Vector2i(i+offset[0],offset[1]), 0, Vector2i(1,1))
+19 -19
View File
@@ -18,15 +18,15 @@ extends StaticBody3D
func _ready() -> void:
if not audio:
push_error("Counter is missing reference to AudioStreamPlayer3D")
SweetLogger.warning("{0} missing audio reference", [name])
if not chop_audio:
push_error("Counter is missing reference to chop_audio AudioStream")
SweetLogger.warning("{0} missing chop_audio reference", [name])
if not progress_bar or progress_bar is not ProgressBar3D:
push_error("Counter missing reference to progressbar, or wrong type:", progress_bar)
SweetLogger.warning("{0} missing progress_bar reference", [name])
if not knife or knife is not XRToolsPickable:
push_error("Counter missing reference to knife, or wrong type:", knife)
SweetLogger.warning("{0} missing knife reference", [name])
if not snap_zone or snap_zone is not XRToolsSnapZone:
push_error("Counter missing reference to snap_zone, or wrong type:", snap_zone)
SweetLogger.warning("{0} missing snap_zone reference", [name])
snap_zone.has_picked_up.connect(_on_object_picked_up)
snap_zone.has_dropped.connect(_on_object_dropped)
@@ -47,7 +47,7 @@ func _set_result(value: String) -> void:
if not process_result.is_empty():
knife.visible = true
knife.enabled = true
SweetLogger.debug("chopping recipe set: {0}", [process_result])
SweetLogger.debug("Chopping recipe set: {0}", [process_result])
else:
_hide_all_tools()
@@ -71,7 +71,7 @@ func _refresh_progress_bar() -> void:
# Add work from gesture area (knife hits). This increments the chopping progress.
func add_work(work: float) -> void:
SweetLogger.debug("add_work: {0}", [work])
SweetLogger.debug("Add work: {0}", [work])
# Only the world owner should drive the authoritative state. Guarding is
# handled by higher-level NetworkManager logic elsewhere, mirror hob's
# convert_held_to_item which checks ownership before spawning.
@@ -82,16 +82,16 @@ func add_work(work: float) -> void:
audio.play()
# If we've reached the required time, convert the held item
if process_result != "" and process_result_work > 0 and work_progress >= process_result_work:
SweetLogger.debug("chopping complete, converting item to: {0}", [process_result])
SweetLogger.debug("Chopping complete, converting item to: {0}", [process_result])
work_progress = 0
convert_held_to_item(process_result)
func _on_gesture_area_body_entered(body: Node3D) -> void:
SweetLogger.debug("gesture area entered: {0}", [body])
SweetLogger.debug("Gesture area entered: {0}", [body])
if body.is_in_group("chopping_tool"):
if process_result == "":
SweetLogger.debug("knife entered but nothing to chop")
SweetLogger.debug("Knife entered but nothing to chop")
return
var speed := 0.0
@@ -101,31 +101,31 @@ func _on_gesture_area_body_entered(body: Node3D) -> void:
speed = body.velocity.length()
if speed < chop_min_speed:
SweetLogger.debug("knife too slow for chopping: {0}", [speed])
SweetLogger.debug("Knife too slow for chopping: {0}", [speed])
return
add_work(chop_work_steps)
func _on_object_picked_up(_item: Variant) -> void:
SweetLogger.debug("object picked up: {0}", [_item])
SweetLogger.debug("Object picked up: {0}", [_item])
var food_item = Helper.find_food_item(_item)
if not food_item:
SweetLogger.debug("held object is not a FoodItem")
SweetLogger.debug("Held object is not a FoodItem")
return
var result = RecipeManager.get_chopping_result(food_item.id)
if not result:
SweetLogger.debug("held a FoodItem that is not choppable, id: {0} process_result: {1}", [food_item.id, result])
SweetLogger.debug("Held a FoodItem that is not choppable, id: {0} process_result: {1}", [food_item.id, result])
return
process_result = result
process_result_work = RecipeManager.get_chopping_work(food_item.id)
SweetLogger.debug("set process_result {0} work: {1}", [process_result, process_result_work])
SweetLogger.debug("Set process_result {0} work: {1}", [process_result, process_result_work])
func _on_object_dropped(_item: Variant) -> void:
SweetLogger.debug("object drop")
SweetLogger.debug("Object drop")
work_progress = 0
process_result = ""
process_result_work = 0
@@ -135,17 +135,17 @@ func _on_object_dropped(_item: Variant) -> void:
func convert_held_to_item(_item: String) -> void:
if not NetworkManager.owns_world():
return
SweetLogger.debug("converting {0}", [_item])
SweetLogger.debug("Converting {0}", [_item])
var old_pickable = snap_zone.picked_up_object
if not old_pickable:
push_warning("Counter finished processing _item, but snap zone is missing its reference")
SweetLogger.warning("{0} finished processing item, but snap_zone is missing its reference", [name])
return
var original_transform = old_pickable.global_transform
var new_scene_instance = NetworkManager.spawn_item(RecipeManager.get_item_scene(_item).resource_path, original_transform)
SweetLogger.debug("freeing old_pickable {0}", [old_pickable])
SweetLogger.debug("Freeing old_pickable {0}", [old_pickable])
snap_zone.drop_object()
NetworkManager.despawn_item(old_pickable)
snap_zone.pick_up_object(new_scene_instance)
+1 -1
View File
@@ -11,7 +11,7 @@ func _makeDirty(item) -> void:
return
var plate: PlateController = item.get_node_or_null("PlateController") as PlateController
if not plate:
SweetLogger.debug("held object is not a Plate")
SweetLogger.debug("Held object is not a Plate")
return
if not plate.is_dirty:
plate.is_dirty = true
+3 -3
View File
@@ -5,9 +5,9 @@ extends StaticBody3D
func _ready() -> void:
if not item_scene:
push_error("Item dispenser is missing a reference to it's item to dispense")
SweetLogger.warning("{0} missing item_scene reference", [name])
if not snap_zone:
push_error("Item dispenser is missing a reference to its snap zone child")
SweetLogger.warning("{0} missing snap_zone reference", [name])
func _process(_delta: float) -> void:
@@ -21,6 +21,6 @@ func _process(_delta: float) -> void:
#return
#
if not snap_zone.picked_up_object:
SweetLogger.debug("missing item, spawning new item")
SweetLogger.debug("Missing item, spawning new item")
var new_item = NetworkManager.spawn_item(item_scene.resource_path, snap_zone.global_transform)
snap_zone.pick_up_object(new_item)
+5 -5
View File
@@ -43,7 +43,7 @@ func _set_effects_playing(playing: bool) -> void:
func _ready() -> void:
if not progress_bar or progress_bar is not ProgressBar3D:
push_error("Sink missing reference to progressbar, or wrong type:", progress_bar)
SweetLogger.warning("{0} missing progress_bar reference", [name])
snap_zone.has_picked_up.connect(_on_object_picked_up)
snap_zone.has_dropped.connect(_on_object_dropped)
@@ -59,7 +59,7 @@ func _refresh_progress_bar() -> void:
func _on_object_picked_up(_item) -> void:
SweetLogger.debug("object picked up: {0}", [_item])
SweetLogger.debug("Object picked up: {0}", [_item])
plate = _item.get_node_or_null("PlateController") as PlateController
if plate:
# The setter starts the effects and shows the bar, here and on clients.
@@ -67,7 +67,7 @@ func _on_object_picked_up(_item) -> void:
func _on_object_dropped(_item) -> void:
SweetLogger.debug("object drop")
SweetLogger.debug("Object drop")
_reset_sink()
@@ -81,14 +81,14 @@ func complete_washing():
return
plate.is_dirty = false
_reset_sink()
SweetLogger.debug("washing complete!")
SweetLogger.debug("Washing complete")
func _process(delta: float) -> void:
if is_washing:
time_washed += wash_speed * delta
_refresh_progress_bar()
SweetLogger.debug("washing plate: {0}", [time_washed])
SweetLogger.debug("Washing plate: {0}", [time_washed])
if time_washed >= plate_wash_time:
complete_washing()
+11 -11
View File
@@ -21,7 +21,7 @@ const GHOST_COLOR_INVALID: Color = Color(1, 0, 0, 0.35)
func set_move_handle_enabled(enabled: bool) -> void:
SweetLogger.debug("set_move_handle_enabled: {0}", [enabled])
SweetLogger.debug("Set move handle enabled: {0}", [enabled])
move_handle.visible = enabled
move_handle.enabled = enabled
if enabled:
@@ -32,18 +32,18 @@ func _on_game_state_changed(new_state: GameManager.GameState) -> void:
set_move_handle_enabled(new_state == GameManager.GameState.BUILDING)
func _on_station_bought(_instance: Node3D):
SweetLogger.info("_on_station_bought")
SweetLogger.debug("->[]")
if GameManager.game_state == GameManager.GameState.BUILDING:
set_move_handle_enabled(true)
func _ready() -> void:
SweetLogger.debug("->[]")
if not station:
push_error("StationMovement is missing referece to station")
SweetLogger.warning("{0} missing station reference", [name])
if not move_handle:
push_error("StationMovement is missing reference to move_handle")
SweetLogger.warning("{0} missing move_handle reference", [name])
if not move_ghost:
push_error("StationMovement is missing reference to move_ghost")
SweetLogger.warning("{0} missing move_ghost reference", [name])
move_handle_rigid = move_handle as RigidBody3D
original_collision_layer = station.collision_layer
@@ -107,7 +107,7 @@ func _apply_visibility_state(ghost_visible: bool, station_visible: bool) -> void
func _handle_pickup(_by: Node) -> void:
SweetLogger.debug("->[]")
if move_handle.get_picked_up_by() and move_handle.get_picked_up_by() is XRToolsSnapZone:
SweetLogger.info("handle pickup by snap zone, dropping and resetting position")
SweetLogger.info("Handle pickup by snap zone, dropping and resetting position")
move_handle.drop()
move_handle.global_position = station.global_position + Vector3(0, original_handle_y_pos, 0)
move_handle.rotation = station.rotation
@@ -121,7 +121,7 @@ func _handle_pickup(_by: Node) -> void:
func _handle_drop(_by: Node) -> void:
SweetLogger.info("handle drop")
SweetLogger.info("Handle drop")
is_moving = false
_apply_visibility_state(false, true)
station.collision_layer = original_collision_layer
@@ -134,11 +134,11 @@ func _handle_drop(_by: Node) -> void:
if is_valid:
station.global_transform = move_ghost.global_transform
move_handle.global_transform = move_ghost.global_transform.translated(Vector3(0, original_handle_y_pos, 0))
SweetLogger.debug("handle drop (local apply), station authority: {0} move_handle authority: {1}", [station.get_multiplayer_authority(), move_handle.get_multiplayer_authority()])
SweetLogger.debug("Handle drop (local apply), station authority: {0} move_handle authority: {1}", [station.get_multiplayer_authority(), move_handle.get_multiplayer_authority()])
else:
station.global_transform = original_station_transform
move_handle.global_transform = original_station_transform.translated(Vector3(0, original_handle_y_pos, 0))
SweetLogger.debug("handle drop (local reject), restoring original position", [])
SweetLogger.debug("Handle drop (local reject), restoring original position")
func _process(_delta: float) -> void:
@@ -198,7 +198,7 @@ func server_handle_drop(new_transform: Transform3D, client_thinks_valid: bool):
if not _was_last_pos_valid: # Edge case
server_update_visibility.rpc(false, true)
SweetLogger.warning("Can not not reset visibility to normal when the last pos was invalid")
SweetLogger.debug("transform rejected (invalid)")
SweetLogger.debug("Transform rejected (invalid)")
_was_last_pos_valid = false
return
@@ -208,7 +208,7 @@ func server_handle_drop(new_transform: Transform3D, client_thinks_valid: bool):
server_update_visibility.rpc(false, true)
_was_last_pos_valid = true
SweetLogger.debug("transform applied")
SweetLogger.debug("Transform applied")
@rpc("any_peer", "call_local", "reliable") # Server updates clients
+26 -26
View File
@@ -47,7 +47,7 @@ var _players_count: int = 0
func place_order() -> void:
SweetLogger.debug("place_order()")
SweetLogger.debug("->[]")
var new_orders: Array[String] = _unsatisfied_orders.duplicate()
# for _i in range(0, randi_range(1, 2)):
# new_orders.append(GameManager.get_random_meal())
@@ -64,7 +64,7 @@ func server_place_order() -> void:
func absorb_items():
SweetLogger.debug("absorb_items()")
SweetLogger.debug("->[]")
for snap_zone_node in snap_zones:
var held_object = snap_zone_node.picked_up_object
if not held_object:
@@ -74,7 +74,7 @@ func absorb_items():
func satisfyAllOrders() -> void:
SweetLogger.debug("satisfyAllOrders()")
SweetLogger.debug("->[]")
_unsatisfied_orders.clear()
_original_orders.clear()
clearAllFood()
@@ -82,7 +82,7 @@ func satisfyAllOrders() -> void:
func clearAllFood() -> void:
SweetLogger.debug("clearAllFood()")
SweetLogger.debug("->[]")
for zone in snap_zones:
var held_object = zone.picked_up_object
if not held_object:
@@ -103,7 +103,7 @@ func clearAllFood() -> void:
# Group called from Queue when trying to assign customers to tables
func try_consume_customer() -> bool:
if _state == TableState.EMPTY:
SweetLogger.debug("try_consume_customer, consumed a customer")
SweetLogger.debug("Try consume customer, consumed a customer")
_state_end(TableState.EMPTY)
return true
return false
@@ -111,18 +111,18 @@ func try_consume_customer() -> bool:
func _ready() -> void:
if not label_3d:
push_error("Table is missing reference to Label3D")
SweetLogger.warning("{0} missing label_3d reference", [name])
if not label_3d_time:
push_error("Table is missing reference to Label3DTime")
SweetLogger.warning("{0} missing label_3d_time reference", [name])
if not progress_bar or progress_bar is not ProgressBar3D:
push_error("Table missing reference to progressbar, or wrong type:", progress_bar)
SweetLogger.warning("{0} missing progress_bar reference", [name])
progress_bar.y_billboard = true
progress_bar.exponential = true
# Render whatever state already arrived from the server before we were in
# the tree (see the guard in _refresh_display).
_refresh_display.call_deferred()
if not audio_player:
push_error("Table is missing reference to AudioStreamPlayer3D")
SweetLogger.warning("{0} missing audio_player reference", [name])
# Get snap_zones for plates, store in array snap_zones
for child in get_children():
@@ -131,7 +131,7 @@ func _ready() -> void:
snap_zones.append(snap_zone_node)
if snap_zones.is_empty():
push_error("Table is missing XRToolsSnapZone children")
SweetLogger.warning("{0} missing XRToolsSnapZone children", [name])
return
for snap_zone_node in snap_zones:
@@ -148,14 +148,14 @@ func _ready() -> void:
func _on_object_picked_up(_item) -> void:
SweetLogger.debug("object picked up: {0}", [_item])
SweetLogger.debug("Object picked up: {0}", [_item])
if _state == TableState.EATING:
return
_absorb_item_if_correct(_item)
func _on_object_dropped(_item) -> void:
SweetLogger.debug("object dropped, item: {0}", [_item])
SweetLogger.debug("Object dropped, item: {0}", [_item])
# If then player picks up a food_item (side) the table has already registerd, unregister
var food_item: FoodItem = Helper.find_food_item(_item)
if food_item and food_item.type == FoodItem.Type.SIDE:
@@ -172,12 +172,12 @@ func _on_object_dropped(_item) -> void:
# There is no on_stay signal, we have to track player with bool
func _on_player_enter(_body):
_players_count += 1
SweetLogger.debug("_on_player_enter() players_count: {0}", [_players_count])
SweetLogger.debug("Player enter, players_count: {0}", [_players_count])
func _on_player_exit(_body):
_players_count -= 1
SweetLogger.debug("_on_player_exit() players_count: {0}", [_players_count])
SweetLogger.debug("Player exit, players_count: {0}", [_players_count])
func _place_order_if_player():
@@ -194,20 +194,20 @@ func _place_order_if_player():
func _get_plate_controller_from_item(_item: Node) -> PlateController:
if not _item:
SweetLogger.debug("_item is null")
SweetLogger.debug("Item is null")
return null
for child in _item.get_children():
if child is PlateController:
SweetLogger.debug("found child")
SweetLogger.debug("Found child")
return child
SweetLogger.debug("no match")
SweetLogger.debug("No match")
return null
func _absorb_item_if_correct(_item: Node) -> void:
SweetLogger.debug("_absorb_item_if_correct, item: {0}", [_item])
SweetLogger.debug("Absorb item if correct, item: {0}", [_item])
if not _item:
return
if not (_state == TableState.WAITING_PRIMARY or _state == TableState.WAITING_FRIEND):
@@ -215,14 +215,14 @@ func _absorb_item_if_correct(_item: Node) -> void:
# Plate: Get plate controller in child of _item (hopefully a plate XRpickable)
var plate_controller = _get_plate_controller_from_item(_item)
SweetLogger.debug("_absorb_item_if_correct plate_controller ref: {0}", [plate_controller])
SweetLogger.debug("Plate_controller ref: {0}", [plate_controller])
_item.print_tree_pretty()
if plate_controller:
# Absorm items from the plate we want
for food_item: FoodItem in plate_controller.container.contained_items: # TOOD: handle registering the meal again when a side is added to the plate
if food_item.id in _unsatisfied_orders and not food_item.is_absorbed:
SweetLogger.debug("_absorb_item_if_correct held a plate with FoodItem that is in unsatisfied orders, removing it")
SweetLogger.debug("Held a plate with FoodItem that is in unsatisfied orders, removing it")
(plate_controller.get_parent() as XRToolsPickable).get_picked_up_by().enabled = false # Lock meal that is deliverd
_unsatisfied_orders.erase(food_item.id)
food_item.is_absorbed = true
@@ -232,17 +232,17 @@ func _absorb_item_if_correct(_item: Node) -> void:
# Side pickable item, no container
var food_item: FoodItem = Helper.find_food_item(_item)
if food_item and food_item.type == FoodItem.Type.SIDE:
SweetLogger.debug("_absorb_item_if_correct held a side that is in unsatisfied orders, removing it")
SweetLogger.debug("Held a side that is in unsatisfied orders, removing it")
# Do not lock snap zone here. Problem if table want many meals, but to many sides have filled up slots, so can't place plates.
_unsatisfied_orders.erase(food_item.id)
_update_state_from_orders()
return
SweetLogger.debug("absorb_item_if_correct() held object is not a Plate or Side")
SweetLogger.debug("Held object is not a Plate or Side")
func _update_state_from_orders():
SweetLogger.debug("_update_state_from_orders: unsatisfied_orders: {0}", [_unsatisfied_orders])
SweetLogger.debug("Unsatisfied_orders: {0}", [_unsatisfied_orders])
if _unsatisfied_orders.size() > 0 and _state != TableState.EATING:
_set_state(TableState.WAITING_FRIEND)
@@ -265,7 +265,7 @@ func _collect_money_from_food():
elif food_item:
GameManager.set_money(GameManager.money + food_item.sell_value)
SweetLogger.debug("_collect_money_from_food(), money: {0}", [GameManager.money])
SweetLogger.debug("Money: {0}", [GameManager.money])
func _set_snap_zones_enabled(value: bool) -> void:
@@ -349,7 +349,7 @@ func _refresh_display() -> void:
# null. Bail out until _ready() has resolved them; _ready() calls back in
# once it has, so nothing that arrived early is lost.
if not progress_bar or not label_3d or not label_3d_time:
push_error("Table missing progress bar or label")
SweetLogger.warning("{0} missing progress_bar or label reference", [name])
return
match _state:
TableState.IDLE:
@@ -388,7 +388,7 @@ func _process(delta: float) -> void:
#SweetLogger.error("State {0} time: {1} duration: {2}", [TableState.keys()[_state], _state_time, _state_duration])
if not NetworkManager.owns_world():
SweetLogger.error("Is not server, return")
SweetLogger.debug("Not server, skipping state update")
return
if GameManager.game_state == GameManager.GameState.GAME_OVER:
+1 -1
View File
@@ -10,7 +10,7 @@ class_name ProgressBar3D
func _ready() -> void:
if not progress_bar:
push_error("Progressbar3D missing reference to ProgressBar")
SweetLogger.warning("{0} missing progress_bar reference", [name])
if y_billboard:
$Sprite3D.billboard = BaseMaterial3D.BillboardMode.BILLBOARD_FIXED_Y
+2 -2
View File
@@ -21,12 +21,12 @@ func _process(_delta: float) -> void:
func _on_button_pressed() -> void:
SweetLogger.debug("buy {0}", [station_name])
SweetLogger.debug("Buy {0}", [station_name])
_buy_station()
func _buy_station() -> void:
SweetLogger.debug("cost={0} current money={1}", [cost, GameManager.money])
SweetLogger.debug("Cost={0} current money={1}", [cost, GameManager.money])
GameManager.set_money(GameManager.money - cost)
var transform = Helper.get_snapped_transform(XRHelpers.get_xr_origin(self).get_node_or_null("PlayerBody"))
var forward: Vector3 = -transform.basis.z.normalized()
+8 -8
View File
@@ -22,7 +22,7 @@ func _ready() -> void:
Signals.station_bought.connect(_on_station_bought)
viewport = get_parent().get_parent() as XRToolsViewport2DIn3D
if not viewport:
push_error("Shop UI could not find XRToolsViewport2DIn3D grand parent")
SweetLogger.error("{0} could not find XRToolsViewport2DIn3D grandparent", [name])
enabled = false
@@ -32,9 +32,9 @@ func _process(_delta: float) -> void:
func toggle_shop():
if GameManager.game_state == GameManager.GameState.BUILDING:
SweetLogger.debug("toggle shop")
SweetLogger.debug("Toggle shop")
enabled = !enabled
SweetLogger.debug("_process: money={0} label text={1}", [GameManager.money, money_label.text])
SweetLogger.debug("Money={0} label text={1}", [GameManager.money, money_label.text])
@@ -54,11 +54,11 @@ func _set_poke_enabled_for_controller(controller_node: XRController3D, value: bo
var poke_node = Helper.find_first_child_of_type(controller_node, XRToolsPoke)
if poke_node:
SweetLogger.debug("_set_poke_enabled_for_controller: {0} poke enabled: {1}", [poke_node.name, value])
SweetLogger.debug("Poke enabled: {0} on {1}", [value, poke_node.name])
poke_node.enabled = value
poke_node.visible = value
else:
SweetLogger.debug("_set_poke_enabled_for_controller: {0} poke not found", [controller_node.name])
SweetLogger.debug("Poke not found on {0}", [controller_node.name])
# For some reason, this is called every frame the button is down. So we need our own timer.
func _on_controller_button_pressed(button_name: String) -> void:
@@ -80,13 +80,13 @@ func _on_other_controller_button_pressed(button_name: String) -> void:
func _on_station_bought(_instance) -> void:
enabled = false
money_label.text = str(GameManager.money) + "$"
SweetLogger.debug("_on_station_bought: new money: {0}", [GameManager.money])
SweetLogger.debug("New money: {0}", [GameManager.money])
func detect_hand_from_xr_ancestor() -> void:
controller = XRHelpers.get_xr_controller(self)
if not controller:
push_error("Shop UI could not find XRController3D ancestor")
SweetLogger.error("{0} could not find XRController3D ancestor", [name])
return
var left_controller := XRHelpers.get_left_controller(self)
@@ -96,4 +96,4 @@ func detect_hand_from_xr_ancestor() -> void:
other_controller = right_controller
elif controller == right_controller:
other_controller = left_controller
SweetLogger.debug("detected hand: {0}", [controller.get_tracker_hand()])
SweetLogger.debug("Detected hand: {0}", [controller.get_tracker_hand()])
+27 -27
View File
@@ -9,9 +9,9 @@ func set_money(value):
if multiplayer.is_server():
money = max(0,value)
client_sync_money.rpc(money)
SweetLogger.info("set_money money set to {0}", [money])
SweetLogger.info("Set to {0}", [money])
else:
SweetLogger.info("set_money client/(peer_id={0}) attempted to set money directly, sending request to server", [multiplayer.get_unique_id()])
SweetLogger.info("Client (peer {0}) attempted direct set, forwarding to server", [multiplayer.get_unique_id()])
server_set_money.rpc_id(1, value)
@rpc("any_peer", "call_remote", "reliable") # CLIENT -> SERVER: Request a change
@@ -29,9 +29,9 @@ func set_day_number(value: int) -> void:
if multiplayer.is_server():
day_number = value
client_sync_day_number.rpc(day_number)
SweetLogger.info("set_day_number day_number set to {0}", [day_number])
SweetLogger.info("Set to {0}", [day_number])
else:
SweetLogger.info("set_day_number client/(peer_id={0}) attempted to set day_number directly, sending request to server", [multiplayer.get_unique_id()])
SweetLogger.info("Client (peer {0}) attempted direct set, forwarding to server", [multiplayer.get_unique_id()])
server_set_day_number.rpc_id(1, value)
@rpc("any_peer", "call_remote", "reliable")
@@ -51,9 +51,9 @@ func set_meals_in_play(value: Array[String]) -> void:
if multiplayer.is_server():
meals_in_play = value
client_sync_meals_in_play.rpc(meals_in_play)
SweetLogger.info("set_meals_in_play meals_in_play set to {0}", [meals_in_play])
SweetLogger.info("Set to {0}", [meals_in_play])
else:
SweetLogger.info("set_meals_in_play client/(peer_id={0}) attempted to set meals_in_play directly, sending request to server", [multiplayer.get_unique_id()])
SweetLogger.info("Client (peer {0}) attempted direct set, forwarding to server", [multiplayer.get_unique_id()])
server_set_meals_in_play.rpc_id(1, value)
@rpc("any_peer", "call_remote", "reliable")
@@ -73,9 +73,9 @@ func set_sides_in_play(value: Array[String]) -> void:
if multiplayer.is_server():
sides_in_play = value
client_sync_sides_in_play.rpc(sides_in_play)
SweetLogger.info("set_sides_in_play sides_in_play set to {0}", [sides_in_play])
SweetLogger.info("Set to {0}", [sides_in_play])
else:
SweetLogger.info("set_sides_in_play client/(peer_id={0}) attempted to set sides_in_play directly, sending request to server", [multiplayer.get_unique_id()])
SweetLogger.info("Client (peer {0}) attempted direct set, forwarding to server", [multiplayer.get_unique_id()])
server_set_sides_in_play.rpc_id(1, value)
@rpc("any_peer", "call_remote", "reliable")
@@ -96,9 +96,9 @@ func set_day_length_seconds(value: float) -> void:
if multiplayer.is_server():
day_length_seconds = value
client_sync_day_length_seconds.rpc(day_length_seconds)
SweetLogger.info("set_day_length_seconds day_length_seconds set to {0}", [day_length_seconds])
SweetLogger.info("Set to {0}", [day_length_seconds])
else:
SweetLogger.info("set_day_length_seconds client/(peer_id={0}) attempted to set day_length_seconds directly, sending request to server", [multiplayer.get_unique_id()])
SweetLogger.info("Client (peer {0}) attempted direct set, forwarding to server", [multiplayer.get_unique_id()])
server_set_day_length_seconds.rpc_id(1, value)
@rpc("any_peer", "call_remote", "reliable")
@@ -118,9 +118,9 @@ func set_customers_per_day(value: float) -> void:
if multiplayer.is_server():
customers_per_day = value
client_sync_customers_per_day.rpc(customers_per_day)
SweetLogger.info("set_customers_per_day customers_per_day set to {0}", [customers_per_day])
SweetLogger.info("Set to {0}", [customers_per_day])
else:
SweetLogger.info("set_customers_per_day client/(peer_id={0}) attempted to set customers_per_day directly, sending request to server", [multiplayer.get_unique_id()])
SweetLogger.info("Client (peer {0}) attempted direct set, forwarding to server", [multiplayer.get_unique_id()])
server_set_customers_per_day.rpc_id(1, value)
@rpc("any_peer", "call_remote", "reliable")
@@ -140,9 +140,9 @@ func set_customers_count_increase_per_day(value: float) -> void:
if multiplayer.is_server():
customers_count_increase_per_day = value
client_sync_customers_count_increase_per_day.rpc(customers_count_increase_per_day)
SweetLogger.info("set_customers_count_increase_per_day customers_count_increase_per_day set to {0}", [customers_count_increase_per_day])
SweetLogger.info("Set to {0}", [customers_count_increase_per_day])
else:
SweetLogger.info("set_customers_count_increase_per_day client/(peer_id={0}) attempted to set customers_count_increase_per_day directly, sending request to server", [multiplayer.get_unique_id()])
SweetLogger.info("Client (peer {0}) attempted direct set, forwarding to server", [multiplayer.get_unique_id()])
server_set_customers_count_increase_per_day.rpc_id(1, value)
@rpc("any_peer", "call_remote", "reliable")
@@ -162,9 +162,9 @@ func set_group_min_size(value: int) -> void:
if multiplayer.is_server():
group_min_size = value
client_sync_group_min_size.rpc(group_min_size)
SweetLogger.info("set_group_min_size group_min_size set to {0}", [group_min_size])
SweetLogger.info("Set to {0}", [group_min_size])
else:
SweetLogger.info("set_group_min_size client/(peer_id={0}) attempted to set group_min_size directly, sending request to server", [multiplayer.get_unique_id()])
SweetLogger.info("Client (peer {0}) attempted direct set, forwarding to server", [multiplayer.get_unique_id()])
server_set_group_min_size.rpc_id(1, value)
@rpc("any_peer", "call_remote", "reliable")
@@ -184,9 +184,9 @@ func set_group_max_size(value: int) -> void:
if multiplayer.is_server():
group_max_size = value
client_sync_group_max_size.rpc(group_max_size)
SweetLogger.info("set_group_max_size group_max_size set to {0}", [group_max_size])
SweetLogger.info("Set to {0}", [group_max_size])
else:
SweetLogger.info("set_group_max_size client/(peer_id={0}) attempted to set group_max_size directly, sending request to server", [multiplayer.get_unique_id()])
SweetLogger.info("Client (peer {0}) attempted direct set, forwarding to server", [multiplayer.get_unique_id()])
server_set_group_max_size.rpc_id(1, value)
@rpc("any_peer", "call_remote", "reliable")
@@ -213,9 +213,9 @@ func set_game_state(value: GameState) -> void:
game_state = value
client_sync_game_state.rpc(game_state)
Signals.game_state_changed.emit(game_state)
SweetLogger.info("set_game_state game_state set to {0}", [game_state])
SweetLogger.info("Set to {0}", [game_state])
else:
SweetLogger.info("set_game_state client/(peer_id={0}) attempted to set game_state directly, sending request to server", [multiplayer.get_unique_id()])
SweetLogger.info("Client (peer {0}) attempted direct set, forwarding to server", [multiplayer.get_unique_id()])
server_set_game_state.rpc_id(1, value)
@rpc("any_peer", "call_remote", "reliable")
@@ -230,29 +230,29 @@ func client_sync_game_state(value: GameState) -> void:
func get_random_meal() -> String:
if meals_in_play.size() == 0:
push_error("GameManager: get_random_meal() called but meals_in_play is empty")
SweetLogger.error("Get_random_meal() called but meals_in_play is empty")
return ""
var rand_index = randi() % meals_in_play.size()
SweetLogger.debug("get_random_meal() returning {0}", [meals_in_play[rand_index]])
SweetLogger.debug("Get_random_meal() returning {0}", [meals_in_play[rand_index]])
return meals_in_play[rand_index]
func get_random_side() -> String:
SweetLogger.debug("get_random_side()")
SweetLogger.debug("->[]")
if sides_in_play.size() == 0:
push_error("GameManager: get_random_side() called but sides_in_play is empty")
SweetLogger.error("Get_random_side() called but sides_in_play is empty")
return ""
var rand_index = randi() % sides_in_play.size()
SweetLogger.debug("get_random_side() list={0} returning {1}", [sides_in_play, sides_in_play[rand_index]], "GameManager.gd", "get_random_side")
SweetLogger.debug("List={0} returning {1}", [sides_in_play, sides_in_play[rand_index]], "GameManager.gd", "get_random_side")
return sides_in_play[rand_index]
func _restart():
SweetLogger.info("restart Game")
SweetLogger.info("Restart game")
game_state = GameState.RUNNING
func game_over():
SweetLogger.info("Game Over")
SweetLogger.info("Game over")
game_state = GameState.GAME_OVER
Signals.game_over.emit()
+21 -21
View File
@@ -16,7 +16,7 @@ static func load_recipes() -> void:
var recipe_path := "res://recipes.yaml"
if not FileAccess.file_exists(recipe_path):
push_error("RecipeManager: recipes.yaml was not found at %s" % recipe_path)
SweetLogger.error("Recipes.yaml was not found at {0}", [recipe_path])
return
var yaml_available := ClassDB.class_exists("YAML")
@@ -25,7 +25,7 @@ static func load_recipes() -> void:
if result != null and not result.has_error():
var data = result.get_data()
if typeof(data) != TYPE_DICTIONARY:
push_warning("RecipeManager: YAML addon parsed recipes.yaml but returned an unsupported structure")
SweetLogger.warning("YAML addon parsed recipes.yaml but returned an unsupported structure")
_recipes = data
_build_scene_paths()
@@ -98,12 +98,12 @@ static func get_item_scene(item_id: StringName) -> PackedScene:
load_recipes()
var scene_path = _scene_paths.get(str(item_id), "")
if typeof(scene_path) != TYPE_STRING or scene_path.is_empty():
push_error("RecipeManager: no scene mapping found for item id '%s'" % item_id)
SweetLogger.error("No scene mapping found for item id '{0}'", [item_id])
return null
var scene = ResourceLoader.load(scene_path)
if not scene:
push_error("RecipeManager: failed to load scene '%s' for item '%s'" % [scene_path, item_id])
SweetLogger.error("Failed to load scene '{0}' for item '{1}'", [scene_path, item_id])
return null
return scene as PackedScene
@@ -111,14 +111,14 @@ static func get_item_scene(item_id: StringName) -> PackedScene:
static func print_all_recipes() -> void:
load_recipes()
if not _loaded:
SweetLogger.warning("could not load recipes.yaml; no recipes printed.")
SweetLogger.warning("Could not load recipes.yaml; no recipes printed")
return
if _combining_map.is_empty():
SweetLogger.warning("no combining recipes found")
SweetLogger.warning("No combining recipes found")
return
SweetLogger.info("#### RecipeManager: Loaded recipes ####")
SweetLogger.info("#### Loaded recipes ####")
_print_combining_recipes()
SweetLogger.info("")
_print_cooking_recipes()
@@ -135,7 +135,7 @@ static func _print_combining_recipes() -> void:
var key_str = str(pair_key)
var separator_index = key_str.find("|")
if separator_index == -1:
SweetLogger.warning("invalid combining map key '{0}'", [key_str])
SweetLogger.warning("Invalid combining map key '{0}'", [key_str])
continue
var first = key_str.substr(0, separator_index)
@@ -198,7 +198,7 @@ static func _build_combining_map() -> void:
for result_id in combining.keys():
var recipe_entries = _get_recipe_entries(combining[result_id])
if recipe_entries.is_empty():
push_error("RecipeManager: combining recipe '%s' must contain at least one valid recipe" % result_id)
SweetLogger.error("Combining recipe '{0}' must contain at least one valid recipe", [result_id])
continue
for recipe in recipe_entries:
var first = StringName(recipe[0])
@@ -251,24 +251,24 @@ static func _build_cooking_map() -> void:
if typeof(cook_val) == TYPE_ARRAY:
for entry in cook_val:
if typeof(entry) != TYPE_DICTIONARY:
push_error("RecipeManager: cooking recipe for '%s' contains a non-dictionary entry" % cooked_id)
SweetLogger.error("Cooking recipe for '{0}' contains a non-dictionary entry", [cooked_id])
continue
entries.append(entry)
elif typeof(cook_val) == TYPE_DICTIONARY:
entries.append(cook_val)
else:
push_error("RecipeManager: cooking recipe for '%s' must be a dictionary or array of dictionaries" % cooked_id)
SweetLogger.error("Cooking recipe for '{0}' must be a dictionary or array of dictionaries", [cooked_id])
continue
var parsed_entries: Array = []
for cook_def in entries:
var ingredient = cook_def.get("ingredient", "")
if typeof(ingredient) != TYPE_STRING or str(ingredient).is_empty():
push_error("RecipeManager: cooking recipe '%s' missing a valid 'ingredient' field" % cooked_id)
SweetLogger.error("Cooking recipe '{0}' missing a valid 'ingredient' field", [cooked_id])
continue
var time_val = cook_def.get("time", null)
if typeof(time_val) != TYPE_INT and typeof(time_val) != TYPE_FLOAT:
push_error("RecipeManager: cooking recipe '%s' missing a valid 'time' field" % cooked_id)
SweetLogger.error("Cooking recipe '{0}' missing a valid 'time' field", [cooked_id])
continue
parsed_entries.append({"ingredient": StringName(str(ingredient)), "time": float(time_val)})
@@ -289,15 +289,15 @@ static func _build_chopping_map() -> void:
for chopped_id in chopping.keys():
var chop_def = chopping[chopped_id]
if typeof(chop_def) != TYPE_DICTIONARY:
push_error("RecipeManager: chopping recipe for '%s' must be a dictionary" % chopped_id)
SweetLogger.error("Chopping recipe for '{0}' must be a dictionary", [chopped_id])
continue
var ingredient = chop_def.get("ingredient", "")
if typeof(ingredient) != TYPE_STRING or str(ingredient).is_empty():
push_error("RecipeManager: chopping recipe '%s' missing a valid 'ingredient' field" % chopped_id)
SweetLogger.error("Chopping recipe '{0}' missing a valid 'ingredient' field", [chopped_id])
continue
var work_val = chop_def.get("work", null)
if typeof(work_val) != TYPE_INT and typeof(work_val) != TYPE_FLOAT:
push_error("RecipeManager: chopping recipe '%s' missing a valid 'work' field" % chopped_id)
SweetLogger.error("Chopping recipe '{0}' missing a valid 'work' field", [chopped_id])
continue
# store chopped item -> { ingredient: StringName, work: float }
_chopping_map[StringName(chopped_id)] = {"ingredient": StringName(str(ingredient)), "work": float(work_val)}
@@ -316,15 +316,15 @@ static func _build_rolling_map() -> void:
for rolled_id in rolling.keys():
var roll_def = rolling[rolled_id]
if typeof(roll_def) != TYPE_DICTIONARY:
push_error("RecipeManager: rolling recipe for '%s' must be a dictionary" % rolled_id)
SweetLogger.error("Rolling recipe for '{0}' must be a dictionary", [rolled_id])
continue
var ingredient = roll_def.get("ingredient", "")
if typeof(ingredient) != TYPE_STRING or str(ingredient).is_empty():
push_error("RecipeManager: rolling recipe '%s' missing a valid 'ingredient' field" % rolled_id)
SweetLogger.error("Rolling recipe '{0}' missing a valid 'ingredient' field", [rolled_id])
continue
var work_val = roll_def.get("work", null)
if typeof(work_val) != TYPE_INT and typeof(work_val) != TYPE_FLOAT:
push_error("RecipeManager: rolling recipe '%s' missing a valid 'work' field" % rolled_id)
SweetLogger.error("Rolling recipe '{0}' missing a valid 'work' field", [rolled_id])
continue
# store rolled item -> { ingredient: StringName, work: float }
_rolling_map[StringName(rolled_id)] = {"ingredient": StringName(str(ingredient)), "work": float(work_val)}
@@ -343,13 +343,13 @@ static func _build_augmenting_map() -> void:
for target_id in augmenting.keys():
var augment_def = augmenting[target_id]
if typeof(augment_def) != TYPE_DICTIONARY:
push_error("RecipeManager: augmenting recipe for '%s' must be a dictionary" % target_id)
SweetLogger.error("Augmenting recipe for '{0}' must be a dictionary", [target_id])
continue
var map: Dictionary = {}
for attr_key in augment_def.keys():
var ingredient = augment_def[attr_key]
if typeof(ingredient) != TYPE_STRING or str(ingredient).is_empty():
push_error("RecipeManager: augmenting recipe '%s' has invalid ingredient for '%s'" % [target_id, attr_key])
SweetLogger.error("Augmenting recipe '{0}' has invalid ingredient for '{1}'", [target_id, attr_key])
continue
# store ingredient -> attribute_key (e.g. sliced_tomato -> has_tomato)
map[StringName(str(ingredient))] = StringName(str(attr_key))
+3 -3
View File
@@ -25,15 +25,15 @@ static func find_first_child_of_type(node: Node, type: Variant) -> Node:
# Returns true if decendant is a decendant node of root, false otherwise. Returns false if either node is null.
static func is_node_decendant_of(decendant: Node, root: Node) -> bool:
if not decendant or not root:
SweetLogger.debug("is_node_decendant_of: decendant or root is null")
SweetLogger.debug("Decendant or root is null")
return false
var current: Node = decendant
while current:
if current == root:
SweetLogger.debug("is_node_decendant_of: decendant {0} is a descendant of root {1}", [decendant.name, root.name])
SweetLogger.debug("Decendant {0} is a descendant of root {1}", [decendant.name, root.name])
return true
current = current.get_parent()
SweetLogger.debug("is_node_decendant_of: decendant {0} is NOT a descendant of root {1}", [decendant.name, root.name])
SweetLogger.debug("Decendant {0} is NOT a descendant of root {1}", [decendant.name, root.name])
return false
+8 -8
View File
@@ -42,17 +42,17 @@ func _run() -> void:
_clear_previous_results(logs_dir)
print_rich("[b]Running the multiplayer test suite...[/b]")
SweetLogger.info("the editor will be unresponsive until it finishes (~2 minutes)")
SweetLogger.info("The editor will be unresponsive until it finishes (~2 minutes)")
var server_pid := _launch(exe, project_dir, ["--server"], SERVER_SCENE)
if server_pid <= 0:
push_error("Could not start the server instance")
SweetLogger.error("Could not start the server instance")
return
# Give the host time to come up and open its port before the client dials in.
OS.delay_msec(5000)
var client_pid := _launch(exe, project_dir, ["--join", "127.0.0.1"], CLIENT_SCENE)
if client_pid <= 0:
push_error("Could not start the client instance")
SweetLogger.error("Could not start the client instance")
OS.kill(server_pid)
return
@@ -61,7 +61,7 @@ func _run() -> void:
OS.delay_msec(500)
waited += 0.5
if OS.is_process_running(server_pid):
SweetLogger.warning("timed out after {0}s, stopping the instances", [TIMEOUT_SEC])
SweetLogger.warning("Timed out after {0}s, stopping the instances", [TIMEOUT_SEC])
OS.kill(server_pid)
if OS.is_process_running(client_pid):
OS.kill(client_pid)
@@ -105,7 +105,7 @@ func _clear_previous_results(logs_dir: String) -> void:
func _print_report(logs_dir: String) -> void:
var path := logs_dir.path_join("mptest_report.txt")
if not FileAccess.file_exists(path):
push_error("No report at %s the run did not finish. Check logs/mptest_server.log" % path)
SweetLogger.error("No report at {0}, the run did not finish, check logs/mptest_server.log", [path])
return
var text := FileAccess.get_file_as_string(path)
SweetLogger.info("")
@@ -119,7 +119,7 @@ func _print_report(logs_dir: String) -> void:
print_rich("[color=gray]%s[/color]" % line)
else:
SweetLogger.info("{0}", [line])
SweetLogger.info("report: {0}", [path])
SweetLogger.info("Report: {0}", [path])
func _build_gif(project_dir: String, logs_dir: String) -> void:
@@ -129,9 +129,9 @@ func _build_gif(project_dir: String, logs_dir: String) -> void:
"-ExecutionPolicy", "Bypass", "-File", script,
], out, true)
for line in out:
print(line)
SweetLogger.debug("{0}", [line])
var gif := logs_dir.path_join("mptest_run.gif")
if code == 0 and FileAccess.file_exists(gif):
print_rich("[b]gif:[/b] %s" % gif)
else:
push_warning("GIF was not produced (is ffmpeg on PATH?). See the output above.")
SweetLogger.warning("GIF was not produced (is ffmpeg on PATH?), see the output above")
+2 -2
View File
@@ -3,8 +3,8 @@ extends Node
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
SweetLogger.debug("stations: {0}", [get_stations()])
SweetLogger.debug("items: {0}", [get_items()])
SweetLogger.debug("Stations: {0}", [get_stations()])
SweetLogger.debug("Items: {0}", [get_items()])