Add crowd presentation, fix NPC navigation, refresh screenshots
NPC navigation (previously dead in the live game) - Only assign NavigationAgent3D.target_position when it changes: re-assigning every frame invalidated the path, so get_next_path_position() kept returning the current point and avatars never moved. - Follow the first path point that is closer to the destination than the avatars are. Nav points sit on the navmesh plane (y=0) while bodies stand at y~0.5, so the old 3D distance test always looked "already there"; path[0] is also the old start point, so a naive "far enough away" pick steered backwards and oscillated. - Fix fsm.state -> fsm.current_state in the idle-lifetime check. Crowd presentation - Aggressive behavior, visible weapons, and responder arrivals make idle bystanders stop and face the incident for 12 s; someone waiting at the entrance keeps focus. - Panic (mood >= 0.75) walks people away from the door at 2.4 m/s, then they despawn. - Wire reactions to EventBus.crowd_changed: CrowdSystem.apply_event() emits on the bus, not on its own `changed` signal (the first wiring received nothing). - Measured a 16-NPC entrance at ~1.2 ms/frame (824 fps, vsync off), so no LOD/culling. World and HUD - Skyline is now a ring of four alpha-scissored planes at 200 m instead of a single plane; PlaneMesh defaults to horizontal, which is why the backdrop rendered as a band overhead. Larger ground plane, mipmapped texture, scissor threshold 0.5 (0.3 left mip dashes in the sky), lifted albedo so the city is not pure black. - Flashlight aims straight ahead and lights the person/door instead of the ground. - Shorter HUD controls line so it stops overlapping itself. Tests, tooling, docs - Headless suite 98 -> 105 (new test_crowd_presentation.gd, 7 tests). - New smoke_crowd.gd: rubbernecking, panic, and flee-target sanity. - capture_screenshots.gd starts a shift from the venue menu and stages the night set properly; all six README screenshots regenerated. - README, TODO/DONE (crowd section moved), MEMORY updated. Version 0.2.4.
This commit is contained in:
1 parent
f5ad1642b5
commit
71b0b53705
21 files changed
+512
-60
No files matched your search
@@ -9,6 +9,7 @@ const AccessArtifact := preload("res://src/core/access_artifact.gd")
|
||||
const AccessLoadout := preload("res://src/core/access_loadout.gd")
|
||||
const AccessVerifier := preload("res://src/core/access_verifier.gd")
|
||||
const DoorState := preload("res://src/core/door_state.gd")
|
||||
const CrowdSystem := preload("res://src/core/crowd_system.gd")
|
||||
const WandScreener := preload("res://src/core/wand_screener.gd")
|
||||
const RadioSystem := preload("res://src/core/radio_system.gd")
|
||||
const ScenarioFactory := preload("res://src/content/scenario_factory.gd")
|
||||
@@ -134,6 +135,7 @@ func _ready() -> void:
|
||||
coordinator.npc_spawn_requested.connect(_spawn_npc)
|
||||
coordinator.shift_ended.connect(_on_shift_ended)
|
||||
coordinator.radio.responder_arrived.connect(_on_responder_arrived)
|
||||
_connect_crowd()
|
||||
|
||||
_build_ui()
|
||||
_last_phase = -1
|
||||
@@ -160,10 +162,13 @@ func _build_guard() -> GuardController:
|
||||
flashlight.name = "Flashlight"
|
||||
flashlight.visible = false
|
||||
flashlight.position = Vector3(0, -0.15, -0.4)
|
||||
flashlight.rotation_degrees = Vector3(-10, 0, 0)
|
||||
flashlight.spot_range = 18.0
|
||||
flashlight.spot_angle = 28.0
|
||||
flashlight.light_energy = 2.5
|
||||
# Aim straight ahead: tilting it down made the cone hit the ground right in
|
||||
# front of the guard instead of the person or door being checked.
|
||||
flashlight.rotation_degrees = Vector3.ZERO
|
||||
flashlight.spot_range = 22.0
|
||||
flashlight.spot_angle = 30.0
|
||||
flashlight.light_energy = 4.0
|
||||
flashlight.spot_attenuation = 0.6
|
||||
head.add_child(flashlight)
|
||||
var collider := CollisionShape3D.new()
|
||||
var shape := CapsuleShape3D.new()
|
||||
@@ -217,6 +222,7 @@ func _reset_shift_state() -> void:
|
||||
hud.set_body_camera(false)
|
||||
scenario_duration_s = selected_scenario.shift_duration_s
|
||||
coordinator.setup(selected_scenario, scenario_duration_s, 4242)
|
||||
_connect_crowd()
|
||||
_last_phase = -1
|
||||
_apply_phase_lighting()
|
||||
|
||||
@@ -481,6 +487,51 @@ func _on_responder_arrived(call: Dictionary) -> void:
|
||||
})
|
||||
coordinator.crowd.apply_event("emergency_responder" if call.get("type", "") == "emergency" else "calm_professionalism")
|
||||
|
||||
## Crowd presentation (PLAN: Public Crowd Reaction). The crowd system is a
|
||||
## mood/attention float; this turns its events into avatar behavior.
|
||||
func _connect_crowd() -> void:
|
||||
# CrowdSystem routes its updates through the EventBus (`event_bus.crowd_changed`);
|
||||
# its own `changed` signal is not emitted by apply_event().
|
||||
if coordinator == null or coordinator.event_bus == null:
|
||||
return
|
||||
if not coordinator.event_bus.crowd_changed.is_connected(_on_crowd_changed):
|
||||
coordinator.event_bus.crowd_changed.connect(_on_crowd_changed)
|
||||
|
||||
func _on_crowd_changed(payload: Dictionary) -> void:
|
||||
var event_type := str(payload.get("event", ""))
|
||||
var panic := bool(payload.get("panic", false))
|
||||
# Panic wins: people clear away from the entrance.
|
||||
if panic or event_type == "crowd_panic":
|
||||
_flee_crowd()
|
||||
return
|
||||
if CrowdSystem.reaction_for_event(event_type) == "watch":
|
||||
_rubberneck_crowd()
|
||||
|
||||
func _incident_point() -> Vector3:
|
||||
if targeted_npc is Node3D and is_instance_valid(targeted_npc):
|
||||
return (targeted_npc as Node3D).global_position
|
||||
if guard:
|
||||
return guard.global_position
|
||||
return Vector3(0, 0, 1.2)
|
||||
|
||||
## Idle bystanders stop and face the incident instead of walking on.
|
||||
func _rubberneck_crowd() -> void:
|
||||
var point := _incident_point()
|
||||
for npc in npcs:
|
||||
if not is_instance_valid(npc) or not npc.has_method("start_rubberneck"):
|
||||
continue
|
||||
if npc == targeted_npc:
|
||||
continue
|
||||
npc.start_rubberneck(point)
|
||||
|
||||
## Panic: everyone nearby moves away from the door.
|
||||
func _flee_crowd() -> void:
|
||||
var door_pos: Vector3 = selected_scenario._location_or_default("entrance", Vector3(0, 0.5, 1.2))
|
||||
for npc in npcs:
|
||||
if not is_instance_valid(npc) or not npc.has_method("start_flee"):
|
||||
continue
|
||||
npc.start_flee(door_pos)
|
||||
|
||||
func _responder_profile() -> NpcProfile:
|
||||
var p := NpcProfile.new()
|
||||
p.id = "responder"
|
||||
|
||||
Reference in new issue
Block a user