Implement prototype: venue-driven simulation core, scenarios, tests, and playable entrance scene
CI / headless-tests (push) Canceled after 49s

- Godot 4.3 project scaffold with first-person guard, procedural world,
  interaction HUD, access inspection, radio forms, debug overlay, shift review
- Simulation core: ShiftCoordinator, VenueScenario, EventScheduler, NPCController/FSM,
  AccessVerifier, EscalationManager, RadioSystem, IncidentRecorder,
  ReputationEvaluator, CrowdSystem, EventBus
- Three authored scenarios (Hollywood Blvd building, The Joke Shop, TV studio)
- Custom headless test runner (25 tests) replacing editor-dependent GUT,
  plus GitHub Actions CI
- Documentation workflow live: README, PLAN (tech stack), TODO/DONE, MEMORY
This commit is contained in:
zwitschi committed 2026-10-31 11:37:54 +01:00
1 parent e23f284ad4
commit 439e0a4281
45 files changed
+4368 -7

No files matched your search

+118
View File
@@ -0,0 +1,118 @@
class_name NpcAvatar
extends CharacterBody3D
## Visual + navigation wrapper around a logic NPCController (ADR-0001).
## Gives the controller a body, color-coded by archetype, and simple movement.
const NPCController := preload("res://src/core/npc_controller.gd")
const Rules := preload("res://src/core/rules.gd")
var npc: NPCController = null
var spawn_position: Vector3 = Vector3.ZERO
var target_position: Vector3 = Vector3.ZERO
var awaiting_interaction := false
var arrived := false
const TYPE_COLORS := {
Rules.NpcType.TOURIST: Color(0.90, 0.75, 0.55),
Rules.NpcType.PERFORMER: Color(0.80, 0.55, 0.90),
Rules.NpcType.INFLUENCER: Color(0.95, 0.55, 0.55),
Rules.NpcType.CONFUSED_VISITOR: Color(0.95, 0.85, 0.50),
Rules.NpcType.INTOXICATED: Color(0.60, 0.75, 0.50),
Rules.NpcType.TRESPASSER: Color(0.55, 0.55, 0.75),
Rules.NpcType.VIOLENT_THREAT: Color(0.85, 0.25, 0.25),
Rules.NpcType.MENTAL_CRISIS: Color(0.85, 0.65, 0.45),
Rules.NpcType.AUTHORIZED_STAFF: Color(0.45, 0.70, 0.90),
Rules.NpcType.AUTHORIZED_GUEST: Color(0.60, 0.85, 0.65),
Rules.NpcType.DELIVERY: Color(0.80, 0.70, 0.40),
Rules.NpcType.RESPONDER: Color(0.25, 0.30, 0.85),
}
func _init() -> void:
npc = NPCController.new()
func get_npc_controller() -> NPCController:
return npc
func setup(profile: NpcProfile, intent: String, seed_value: int, p_spawn: Vector3, p_target: Vector3) -> void:
npc.setup("npc_%d" % seed_value, profile, intent, seed_value)
spawn_position = p_spawn
target_position = p_target
position = p_spawn
npc.fsm.state_changed.connect(_on_state_changed)
_build_body(profile.npc_type)
# Normalize intent targets: approach the entrance, stop near the door.
var collider := CollisionShape3D.new()
var shape := CapsuleShape3D.new()
shape.radius = 0.35
shape.height = 1.6
collider.shape = shape
collider.position = Vector3(0, 0.8, 0)
add_child(collider)
func _build_body(npc_type: int) -> void:
var body := MeshInstance3D.new()
var capsule := CapsuleMesh.new()
capsule.radius = 0.35
capsule.height = 1.6
body.mesh = capsule
var mat := StandardMaterial3D.new()
mat.albedo_color = TYPE_COLORS.get(npc_type, Color(0.7, 0.7, 0.7))
body.material_override = mat
add_child(body)
var id_tag := MeshInstance3D.new()
var sphere := SphereMesh.new()
sphere.radius = 0.12
sphere.height = 0.24
var tag_mat := StandardMaterial3D.new()
tag_mat.albedo_color = Color(1, 1, 1)
id_tag.mesh = sphere
id_tag.material_override = tag_mat
id_tag.position = Vector3(0, 1.05, 0)
id_tag.scale = Vector3(1, 0.4, 1)
add_child(id_tag)
func _physics_process(delta: float) -> void:
if npc == null or npc.fsm == null:
return
_advance_fsm()
_move_toward_target(delta)
func _advance_fsm() -> void:
if npc.leave_requested:
var away := global_position + (global_position - spawn_position).normalized() * 40.0
away.y = 0.5
target_position = away
return
if arrived and not awaiting_interaction:
awaiting_interaction = true
func _move_toward_target(delta: float) -> void:
var to_target := target_position - global_position
to_target.y = 0.0
var dist := to_target.length()
if dist < 0.7:
_arrive()
return
var dir := to_target.normalized()
velocity.x = dir.x * 1.3
velocity.z = dir.z * 1.3
velocity.y -= 9.8 * delta
look_at(global_position + Vector3(dir.x, 0, dir.z), Vector3.UP)
move_and_slide()
func _arrive() -> void:
arrived = true
velocity = Vector3.ZERO
if npc.intent == "enter" or npc.intent == "trespass" or npc.intent == "deliver" or npc.intent == "arrive":
target_position = Vector3(0, 0.5, 1.2)
if (global_position - Vector3(0, 0.5, 1.2)).length() < 0.8:
awaiting_interaction = true
func _on_state_changed(_node: Object, _from: String, to_state: String) -> void:
match to_state:
"LEAVING":
npc.leave_requested = true
"THREATENING", "FORCING_ENTRY":
# Advance toward the door posture; keep it simple for the prototype.
pass