A2: Player figure and animation

The islander is built in headless Blender (tools/models/figure.py,
`make figure`, `make art`) as twelve rigid parts with their origins at
their joints: an oilskin coat, a sou'wester, sea boots, a bedding roll
and the canvas wing-sail. Debian's Blender can't write glTF, so the
figure is jointed rather than skinned.

FigureRig hangs the parts on pivots, paints them from Palette with the
coat in the player's own oilskin, and plays FigurePoses' hand-written
key poses through one AnimationTree: idle, walk and run by speed,
crouch and creep, air, skydive, glide, swim and aboard; long, short and
carried holds; reload and use layers; fire, boathook swing, keg throw
and building as one-shots; and a flinch when health drops. The chest
takes a third of the pitch and the held item all of it.

Figures animate from replicated state only: positions, look, health,
the held item and the FLAG_ bits (reloading and using now reach
mirrored players), with actions from FX. Every boathook swing is now a
sim "swing" event, sent as a SHOT with no item, so misses are seen and
heard; the new FX kind PLACE shows pieces placed. Protocol version 4.

Tests: test_figure_rig (15), plus swing and PLACE cases in test_harvest
and test_net_fx. make check passes (604 tests); make client-check
passes. Captures: figure_states, figure_actions, figure_close
(make figure-captures), client_glide and client_landed.

Closes #42

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 17:35:53 -05:00
co-authored by Claude Opus 5.5
parent da0c65f3ce
commit 07738330b5
66 changed files with 6230 additions and 88 deletions
+30 -3
View File
@@ -54,7 +54,7 @@ func test_a_hit_yields_the_props_material_and_damages_it() -> void:
assert_eq(player.materials[Materials.DRIFTWOOD], Tuning.HARVEST_PER_HIT)
assert_eq(player.materials[Materials.STONE], 0)
assert_eq(sim.props.health[0], 200 - Tuning.HARVEST_DAMAGE)
assert_eq(sim.events[0]["material"], Materials.DRIFTWOOD)
assert_eq(_harvest(sim)["material"], Materials.DRIFTWOOD)
func test_each_prop_kind_gives_its_own_material() -> void:
@@ -93,7 +93,7 @@ func test_looking_away_misses() -> void:
for _i: int in 1:
sim.submit_command(1, PlayerCommand.from_input(sim.tick, Vector2.ZERO, PI, 0.0, PlayerCommand.BUTTON_FIRE))
sim.step()
hits += sim.events.size()
hits += sim.events.filter(func(event: Dictionary) -> bool: return event["type"] != "swing").size()
assert_eq(hits, 0)
@@ -120,7 +120,7 @@ func test_carry_cap_stops_gains_but_not_damage() -> void:
player.materials[Materials.STONE] = Tuning.MATERIAL_CAP - 5
_swing_for(sim, 1)
assert_eq(player.materials[Materials.STONE], Tuning.MATERIAL_CAP)
assert_eq(sim.events[0]["amount"], 5, "the event reports what was actually gained")
assert_eq(_harvest(sim)["amount"], 5, "the event reports what was actually gained")
_swing_for(sim, Harvest.swing_interval_ticks())
assert_eq(player.materials[Materials.STONE], Tuning.MATERIAL_CAP, "never over the cap")
assert_eq(sim.props.health[0], 400 - Tuning.HARVEST_DAMAGE * 2, "capped players still damage props")
@@ -199,3 +199,30 @@ func test_harvesting_on_a_real_island_is_deterministic() -> void:
assert_eq(gained, Tuning.HARVEST_PER_HIT * 2, "two swings at a real pine")
hashes.append(sim.state_hash())
assert_eq(hashes[0], hashes[1])
## This tick's harvest event; every swing also makes a "swing" event before it.
func _harvest(sim: Simulation) -> Dictionary:
for event: Dictionary in sim.events:
if event["type"] == "harvest":
return event
return {}
func test_every_swing_reports_itself_hit_or_miss() -> void:
var sim: Simulation = Simulation.new(5, SimGround.flat(0.0))
var player: SimEntity = sim.entities.find(sim.add_player())
player.drop_state = Drop.NONE
player.on_ground = true
player.position = Vector3(10.0, 0.0, 10.0)
player.pitch = PlayerCommand.PITCH_MAX / 2
var events: Array[Dictionary] = []
Harvest.swing(player, sim.ground, sim.props, events, sim.structures)
assert_eq(events.size(), 1, "a miss: %s" % [events])
assert_eq(events[0]["type"], "swing")
assert_eq(events[0]["player"], player.id)
var direction: Vector3 = events[0]["direction"]
assert_true(direction.y > 0.5, "along the look")
Harvest.swing(player, sim.ground, sim.props, events, sim.structures)
assert_eq(events.size(), 1, "not again until the boathook is ready")