implement delivery ready indicator logic + off-color detection

This commit is contained in:
god
2026-07-06 02:41:37 +08:00
parent 717e8cedae
commit a7a4ca68aa
4 changed files with 99 additions and 14 deletions
+32 -9
View File
@@ -52,6 +52,7 @@ var hud_rush_bar: ProgressBar
var hud_rush_label: Label
var hud_stack_badge: Label
var hud_points_label: Label
var hud_delivery_indicator: Label
var _candy_survival_hud_scene: PackedScene = preload("res://scenes/candy_survival_hud.tscn")
func _ready():
@@ -70,6 +71,7 @@ func _setup_hud() -> void:
hud_ghost_label = bot_box.get_node_or_null("SabotagePanel/GhostChargesLabel")
hud_stack_badge = bot_box.get_node_or_null("ScorePanel/CandyStackBadge")
hud_points_label = bot_box.get_node_or_null("ScorePanel/PointsLabel")
hud_delivery_indicator = bot_box.get_node_or_null("ScorePanel/DeliveryIndicator")
var top_box = hud_layer.get_node_or_null("TopContainer")
if top_box:
@@ -175,6 +177,10 @@ func _process(delta: float) -> void:
# Sync color to the Mekton NPC
if mekton_node and mekton_node.has_method("set_face_color_rpc"):
mekton_node.rpc("set_face_color_rpc", current_face)
# Update delivery indicators for all players based on new face
for pid in player_candies:
_update_candy_badge(pid)
# Sugar Rush timers
@@ -222,24 +228,30 @@ func _process(delta: float) -> void:
# ── Blueprint ──
func on_blueprint_completed(pid: int, primary_color: int, off_color: bool) -> void:
func on_blueprint_completed(pid: int, primary_tile_id: int, off_color: bool) -> void:
var base_points = 1000
var points = base_points if not off_color else int(base_points * OFF_COLOR_PENALTY)
_add_score(pid, points)
player_blueprints[pid] = player_blueprints.get(pid, 0) + 1
_give_candy(pid, primary_color)
var candy_color = CandyColor.HEART
for key in TILE_IDS:
if TILE_IDS[key] == primary_tile_id:
candy_color = key
break
_give_candy(pid, candy_color)
func can_finish_with_off_color(pid: int, primary_color: int) -> bool:
return not _grid_has_color_tiles(primary_color)
func can_finish_with_off_color(pid: int, primary_tile_id: int) -> bool:
return not _grid_has_color_tiles(primary_tile_id)
func _grid_has_color_tiles(color: int) -> bool:
func _grid_has_color_tiles(target_tile_id: int) -> bool:
if not gridmap:
return true
var target = TILE_IDS.get(color, 7)
for x in range(1, ARENA_COLS - 1):
for y in range(1, ARENA_ROWS - 1):
var v = Vector3i(x, 1, y)
if gridmap.get_cell_item(v) == target:
if gridmap.get_cell_item(v) == target_tile_id:
return true
return false
@@ -254,7 +266,8 @@ func _update_candy_badge(pid: int) -> void:
var count = player_candies.get(pid, 0)
var mult = 1.0 + count * MULTI_STEP
var color = player_candy_color.get(pid, -1)
rpc("sync_candy_badge", pid, count, mult)
var face_match = (color != -1 and color == current_face)
rpc("sync_candy_badge", pid, count, mult, face_match)
# Update the 3D meshes on the player's head across all clients
var all_players = get_tree().get_nodes_in_group("Players")
@@ -476,10 +489,20 @@ func get_score(pid: int) -> int:
# ── RPCs (stubs — HUD client handles visuals) ──
@rpc("authority", "call_remote", "unreliable")
func sync_candy_badge(pid: int, count: int, mult: float) -> void:
func sync_candy_badge(pid: int, count: int, mult: float, face_match: bool) -> void:
if pid == multiplayer.get_unique_id():
if hud_stack_badge:
hud_stack_badge.text = "Stack: %d (x%.1f)" % [count, mult]
if hud_delivery_indicator:
if count > 0:
if face_match:
hud_delivery_indicator.text = "READY TO DELIVER!"
hud_delivery_indicator.add_theme_color_override("font_color", Color(0.4, 1.0, 0.4))
else:
hud_delivery_indicator.text = "Waiting for match..."
hud_delivery_indicator.add_theme_color_override("font_color", Color(1.0, 0.4, 0.4))
else:
hud_delivery_indicator.text = ""
@rpc("authority", "call_remote", "unreliable")
func sync_knock_result(attacker: int, target: int, candies: int) -> void: