Add Sweetlogger
This commit is contained in:
+21
-21
@@ -47,7 +47,7 @@ var _players_count: int = 0
|
||||
|
||||
|
||||
func place_order() -> void:
|
||||
print("Table place_order()")
|
||||
SweetLogger.debug("place_order()", [], "table.gd", "place_order")
|
||||
var new_orders: Array[String] = _unsatisfied_orders.duplicate()
|
||||
# for _i in range(0, randi_range(1, 2)):
|
||||
# new_orders.append(GameManager.get_random_meal())
|
||||
@@ -59,7 +59,7 @@ func place_order() -> void:
|
||||
|
||||
|
||||
func absorb_items():
|
||||
print("Table: absorb_items()")
|
||||
SweetLogger.debug("absorb_items()", [], "table.gd", "absorb_items")
|
||||
for snap_zone_node in snap_zones:
|
||||
var held_object = snap_zone_node.picked_up_object
|
||||
if not held_object:
|
||||
@@ -69,7 +69,7 @@ func absorb_items():
|
||||
|
||||
|
||||
func satisfyAllOrders() -> void:
|
||||
print("Table: satisfyAllOrders()")
|
||||
SweetLogger.debug("satisfyAllOrders()", [], "table.gd", "satisfyAllOrders")
|
||||
_unsatisfied_orders.clear()
|
||||
_original_orders.clear()
|
||||
clearAllFood()
|
||||
@@ -77,7 +77,7 @@ func satisfyAllOrders() -> void:
|
||||
|
||||
|
||||
func clearAllFood() -> void:
|
||||
print("Table: clearAllFood()")
|
||||
SweetLogger.debug("clearAllFood()", [], "table.gd", "clearAllFood")
|
||||
for zone in snap_zones:
|
||||
var held_object = zone.picked_up_object
|
||||
if not held_object:
|
||||
@@ -98,7 +98,7 @@ func clearAllFood() -> void:
|
||||
# Group called from Queue when trying to assign customers to tables
|
||||
func try_consume_customer() -> bool:
|
||||
if _state == TableState.EMPTY:
|
||||
print("Table try_consume_customer, consumed a customer")
|
||||
SweetLogger.debug("try_consume_customer, consumed a customer", [], "table.gd", "try_consume_customer")
|
||||
_state_end(TableState.EMPTY)
|
||||
return true
|
||||
return false
|
||||
@@ -137,14 +137,14 @@ func _ready() -> void:
|
||||
|
||||
|
||||
func _on_object_picked_up(_item) -> void:
|
||||
print("Table: object picked up: ", _item)
|
||||
SweetLogger.debug("object picked up: {0}", [_item], "table.gd", "_on_object_picked_up")
|
||||
if _state == TableState.EATING:
|
||||
return
|
||||
_absorb_item_if_correct(_item)
|
||||
|
||||
|
||||
func _on_object_dropped(_item) -> void:
|
||||
print("Table: object dropped, item: ", _item)
|
||||
SweetLogger.debug("object dropped, item: {0}", [_item], "table.gd", "_on_object_dropped")
|
||||
# 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:
|
||||
@@ -161,12 +161,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
|
||||
print("Table _on_player_enter() pleryers_count: ", _players_count)
|
||||
SweetLogger.debug("_on_player_enter() players_count: {0}", [_players_count], "table.gd", "_on_player_enter")
|
||||
|
||||
|
||||
func _on_player_exit(_body):
|
||||
_players_count -= 1
|
||||
print("Table _on_player_exit() pleryers_count: ", _players_count)
|
||||
SweetLogger.debug("_on_player_exit() players_count: {0}", [_players_count], "table.gd", "_on_player_exit")
|
||||
|
||||
|
||||
func _place_order_if_player():
|
||||
@@ -183,20 +183,20 @@ func _place_order_if_player():
|
||||
|
||||
func _get_plate_controller_from_item(_item: Node) -> PlateController:
|
||||
if not _item:
|
||||
print("_item is null")
|
||||
SweetLogger.debug("_item is null", [], "table.gd", "_get_plate_controller_from_item")
|
||||
return null
|
||||
|
||||
for child in _item.get_children():
|
||||
if child is PlateController:
|
||||
print("found child")
|
||||
SweetLogger.debug("found child", [], "table.gd", "_get_plate_controller_from_item")
|
||||
return child
|
||||
|
||||
print("no match")
|
||||
SweetLogger.debug("no match", [], "table.gd", "_get_plate_controller_from_item")
|
||||
return null
|
||||
|
||||
|
||||
func _absorb_item_if_correct(_item: Node) -> void:
|
||||
print("Table _absorb_item_if_correct, item: ", _item)
|
||||
SweetLogger.debug("_absorb_item_if_correct, item: {0}", [_item], "table.gd", "_absorb_item_if_correct")
|
||||
if not _item:
|
||||
return
|
||||
if not (_state == TableState.WAITING_PRIMARY or _state == TableState.WAITING_FRIEND):
|
||||
@@ -204,14 +204,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)
|
||||
print("Table _absorb_item_if_correct plate_controller ref: ", plate_controller)
|
||||
SweetLogger.debug("_absorb_item_if_correct plate_controller ref: {0}", [plate_controller], "table.gd", "_absorb_item_if_correct")
|
||||
_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:
|
||||
print("Table: _absorb_item_if_correct held a plate with FoodItem that is in unsatisfied orders, removing it")
|
||||
SweetLogger.debug("_absorb_item_if_correct held a plate with FoodItem that is in unsatisfied orders, removing it", [], "table.gd", "_absorb_item_if_correct")
|
||||
(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
|
||||
@@ -221,17 +221,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:
|
||||
print("Table: _absorb_item_if_correct held a side that is in unsatisfied orders, removing it")
|
||||
SweetLogger.debug("_absorb_item_if_correct held a side that is in unsatisfied orders, removing it", [], "table.gd", "_absorb_item_if_correct")
|
||||
# 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
|
||||
|
||||
print("Table: absorb_item_if_correct() held object is not a Plate or Side")
|
||||
SweetLogger.debug("absorb_item_if_correct() held object is not a Plate or Side", [], "table.gd", "_absorb_item_if_correct")
|
||||
|
||||
|
||||
func _update_state_from_orders():
|
||||
print("Table _update_state_from_orders: unsatisfied_orders: ", _unsatisfied_orders)
|
||||
SweetLogger.debug("_update_state_from_orders: unsatisfied_orders: {0}", [_unsatisfied_orders], "table.gd", "_update_state_from_orders")
|
||||
if _unsatisfied_orders.size() > 0 and _state != TableState.EATING:
|
||||
_set_state(TableState.WAITING_FRIEND)
|
||||
|
||||
@@ -254,7 +254,7 @@ func _collect_money_from_food():
|
||||
elif food_item:
|
||||
GameManager.set_money(GameManager.money + food_item.sell_value)
|
||||
|
||||
print("Table _collect_money_from_food(), money: ", GameManager.money)
|
||||
SweetLogger.debug("_collect_money_from_food(), money: {0}", [GameManager.money], "table.gd", "_collect_money_from_food")
|
||||
|
||||
|
||||
func _set_snap_zones_enabled(value: bool) -> void:
|
||||
@@ -265,7 +265,7 @@ func _set_snap_zones_enabled(value: bool) -> void:
|
||||
## Server-only state transition: sets the new state's timer and assigns
|
||||
## _state (whose setter refreshes the display on every peer).
|
||||
func _set_state(newState: TableState) -> void:
|
||||
print("Table State START: ", TableState.keys()[newState])
|
||||
SweetLogger.debug("State START: {0}", [TableState.keys()[newState]], "table.gd", "_set_state")
|
||||
|
||||
match newState:
|
||||
TableState.IDLE:
|
||||
@@ -307,7 +307,7 @@ func _set_state(newState: TableState) -> void:
|
||||
|
||||
# When state timer is finished, do this stuff before moving to next state
|
||||
func _state_end(oldState: TableState):
|
||||
print("Table State END : ", TableState.keys()[oldState])
|
||||
SweetLogger.debug("State END: {0}", [TableState.keys()[oldState]], "table.gd", "_state_end")
|
||||
match oldState:
|
||||
TableState.EMPTY:
|
||||
customers.visible = true
|
||||
|
||||
Reference in New Issue
Block a user