A9: In-game HUD, with a FEED message for the kill feed and who stands
The HUD (src/client/hud) is drawn in the paper-and-ink motifs of the style
guide:
- top centre: the tide post, the most prominent thing on screen. It is a
notched post with the sea filled in, the next level's rust notch and the
player's own height. Beside it are the phase, the time to the rise, both
levels and how far the player stands above or below the next line;
- top right: how many are standing, and the kill feed in words;
- bottom left: health and armour, each with a number, a word, quarter notches
and its own hatching. Low health adds LOW;
- bottom centre: the boathook and five slots, with names on two lines, rounds
and reserve or counts, and tier pips;
- bottom right: materials, and the build line ("NOT ENOUGH" when short).
Snapshots only carry nearby players, so the server now sends FEED (NetFeed,
reliable) when anyone is placed and at each phase change. It carries who is
standing, the match size and the newest 16 entries with names. Bots get crew
names (CrewNames). HudState works out what to show from the client, or from a
server's match for captures and tests, so the drawing never reaches into
either.
The project now stretches canvas items from a 1280x720 base, so the HUD scales
to any screen. make hud-captures renders it at 1280x720 and 3840x2160. The
parser fuzzer covers FEED.
Closes #49
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://test/capture/client_scene.gd" id="1"]
|
||||
|
||||
[node name="CaptureClient" type="Node3D"]
|
||||
script = ExtResource("1")
|
||||
stage = "hud"
|
||||
@@ -0,0 +1,7 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://test/capture/client_scene.gd" id="1"]
|
||||
|
||||
[node name="CaptureClient" type="Node3D"]
|
||||
script = ExtResource("1")
|
||||
stage = "hud_build"
|
||||
@@ -9,6 +9,10 @@
|
||||
## ground inside, below the sea, stays dry on the client too (issue N11). build and
|
||||
## build_refused: once landed, the client goes into build mode for a driftwood wall,
|
||||
## with plenty of materials or none, so the ghost shows in its allowed or refused tint.
|
||||
## hud and hud_build (issue A9): once landed, the server hands the player a carbine, a
|
||||
## fowling piece and bandages, wounds them a little and takes three bots out in
|
||||
## different ways, so every part of the HUD has something to show; hud_build then goes
|
||||
## into build mode. Every stage draws the HUD as the client's HudState has it.
|
||||
extends Node3D
|
||||
|
||||
const DT: float = 1.0 / Tuning.TICK_RATE_HZ
|
||||
@@ -64,7 +68,7 @@ func _ready() -> void:
|
||||
reached = me.drop_state == Drop.ABOARD and _session.game.prediction.next_tick > 3 * Tuning.TICK_RATE_HZ
|
||||
"glide":
|
||||
reached = me.drop_state == Drop.GLIDING
|
||||
"landed", "basin", "build", "build_refused":
|
||||
"landed", "basin", "build", "build_refused", "hud", "hud_build":
|
||||
reached = me.drop_state == Drop.NONE
|
||||
if reached and since < 0:
|
||||
since = 0
|
||||
@@ -84,6 +88,14 @@ func _ready() -> void:
|
||||
basin_text = _build_mode(stage == "build")
|
||||
if basin_text.is_empty():
|
||||
return
|
||||
elif stage.begins_with("hud"):
|
||||
basin_text = _stage_hud()
|
||||
if basin_text.is_empty():
|
||||
return
|
||||
if stage == "hud_build" and _build_mode(true).is_empty():
|
||||
return
|
||||
_session.hud.fade_feed = false
|
||||
_session.hud.show_state(_session.hud_state())
|
||||
_session.view.settle()
|
||||
var others: int = 0
|
||||
var camera: Camera3D = _session.view.camera
|
||||
@@ -95,6 +107,9 @@ func _ready() -> void:
|
||||
if to.length() < 150.0 and to.normalized().dot(-camera.basis.z) > 0.8:
|
||||
others += 1
|
||||
var flow: Match = _loop.match_flow
|
||||
if stage.begins_with("hud"):
|
||||
_caption("HUD · %s · seed %d · %s%s" % [stage.to_upper(), match_seed, flow.phase_name(), basin_text], Vector2(18.0, 132.0), 15)
|
||||
return
|
||||
_caption("NETWORK CLIENT · %s · %s · seed %d\njoined %s over UDP as \"%s\" · %d players drawn, %d others ahead of the camera\nsimulation tick %d on the server, %d predicted here · %d snapshots, %d world messages, %d corrections" % [
|
||||
stage.to_upper(), flow.phase_name(), match_seed, HOST, _net.name_of(_session.link.handle),
|
||||
_session.view.entities.figure_count(), others, _loop.sim.tick, _session.game.prediction.next_tick,
|
||||
@@ -102,6 +117,53 @@ func _ready() -> void:
|
||||
] + basin_text)
|
||||
|
||||
|
||||
## Gives the player things to carry and a wound, takes three bots out (one by the
|
||||
## player's carbine, one drowned, one to the tide), and plays on a second so the client
|
||||
## hears of it. Returns a caption line, or "" after reporting an error.
|
||||
func _stage_hud() -> String:
|
||||
var flow: Match = _loop.match_flow
|
||||
var sim: Simulation = _loop.sim
|
||||
var mine: SimEntity = sim.entities.find(int(flow.entity_of.get(_session.link.handle, 0)))
|
||||
if mine == null or mine.eliminated:
|
||||
push_error("client capture: the player isn't in the match for the HUD")
|
||||
return ""
|
||||
Inventory.give(mine, ItemCatalog.code_of("dock_carbine"), 1, -1, 2)
|
||||
Inventory.give(mine, ItemCatalog.code_of("fowling_piece"), 1, -1, 0)
|
||||
Inventory.give(mine, ItemCatalog.code_of("sailcloth_bandage"), 3)
|
||||
Inventory.give(mine, ItemCatalog.code_of("cartridges"), 45)
|
||||
Inventory.select(mine, 1)
|
||||
mine.materials = PackedInt32Array([140, 60, 12])
|
||||
mine.health = 64
|
||||
mine.armor = 35
|
||||
var causes: Array[int] = [SimEntity.CAUSE_WEAPON, SimEntity.CAUSE_DROWN, SimEntity.CAUSE_TIDE]
|
||||
var taken: int = 0
|
||||
for bot: int in flow.bot_handles.keys():
|
||||
var player: SimEntity = sim.entities.find(int(flow.entity_of.get(bot, 0)))
|
||||
if player == null or player.eliminated:
|
||||
continue
|
||||
player.health = 0
|
||||
player.last_cause = causes[taken]
|
||||
player.last_attacker = mine.id if causes[taken] == SimEntity.CAUSE_WEAPON else 0
|
||||
taken += 1
|
||||
for _round: int in 3:
|
||||
_game.poll()
|
||||
_loop.run_tick()
|
||||
_game.after_tick()
|
||||
_session.pump(DT)
|
||||
if taken == causes.size():
|
||||
break
|
||||
for _round: int in Tuning.TICK_RATE_HZ:
|
||||
_game.poll()
|
||||
_loop.run_tick()
|
||||
_game.after_tick()
|
||||
_session.pump(DT)
|
||||
var hud: HudState = _session.hud_state()
|
||||
if hud.feed.size() < 3 or not hud.playing or hud.tide.is_empty():
|
||||
push_error("client capture: the HUD has %d feed lines, playing %s, tide %s" % [hud.feed.size(), hud.playing, hud.tide])
|
||||
return ""
|
||||
return " · %d of %d standing, %d feed lines" % [hud.standing, hud.total, hud.feed.size()]
|
||||
|
||||
|
||||
## Stops the autoplay where the player stands and goes into build mode for a driftwood
|
||||
## wall, after the server has given the player plenty of materials or taken them all.
|
||||
## Returns a caption line, or "" after reporting an error.
|
||||
@@ -229,16 +291,16 @@ func _exit_tree() -> void:
|
||||
_net.close()
|
||||
|
||||
|
||||
func _caption(text: String) -> void:
|
||||
func _caption(text: String, at: Vector2 = Vector2(18.0, 14.0), font_size: int = 20) -> void:
|
||||
var settings: LabelSettings = LabelSettings.new()
|
||||
settings.font_size = 20
|
||||
settings.font_size = font_size
|
||||
settings.font_color = Color(0.96, 0.94, 0.88)
|
||||
settings.outline_size = 6
|
||||
settings.outline_color = Color(0.08, 0.09, 0.1)
|
||||
var label: Label = Label.new()
|
||||
label.label_settings = settings
|
||||
label.text = text
|
||||
label.position = Vector2(18.0, 14.0)
|
||||
label.position = at
|
||||
var layer: CanvasLayer = CanvasLayer.new()
|
||||
layer.add_child(label)
|
||||
add_child(layer)
|
||||
|
||||
Reference in New Issue
Block a user