Implement prototype: venue-driven simulation core, scenarios, tests, and playable entrance scene
CI / headless-tests (push) Canceled after 49s
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:
1 parent
e23f284ad4
commit
439e0a4281
45 files changed
+4368
-7
No files matched your search
@@ -0,0 +1,85 @@
|
||||
class_name IncidentRecorder
|
||||
extends RefCounted
|
||||
|
||||
const EventBus := preload("res://src/core/event_bus.gd")
|
||||
|
||||
var event_bus: EventBus = null
|
||||
|
||||
func set_event_bus(bus: EventBus) -> void:
|
||||
event_bus = bus
|
||||
## Structured incident history (ADR-0005). Records observations, player actions,
|
||||
## access evidence, escalation levels, responses, and outcomes for evidence,
|
||||
## reputation, crowd reactions, and shift review.
|
||||
|
||||
var incidents: Array[Dictionary] = []
|
||||
var _open_incidents: Dictionary = {} # npc_id -> incident dict
|
||||
|
||||
## Begin an incident for an NPC. Returns incident_id.
|
||||
func start_incident(npc_id: String, trigger: String) -> String:
|
||||
var incident := {
|
||||
"id": "inc_%s_%d" % [npc_id, Time.get_ticks_usec()],
|
||||
"npc_id": npc_id,
|
||||
"trigger": trigger,
|
||||
"opened_at_ms": Time.get_ticks_msec(),
|
||||
"events": [],
|
||||
"access_evidence": [],
|
||||
"escalation_history": [],
|
||||
"outcome": null,
|
||||
}
|
||||
_open_incidents[npc_id] = incident
|
||||
return incident["id"]
|
||||
|
||||
func add_event(npc_id: String, event: Dictionary) -> void:
|
||||
if not _open_incidents.has(npc_id):
|
||||
return
|
||||
var incident: Dictionary = _open_incidents[npc_id]
|
||||
event["at_ms"] = Time.get_ticks_msec()
|
||||
incident["events"].append(event)
|
||||
if event_bus:
|
||||
event_bus.incident_recorded.emit(incident.duplicate(true))
|
||||
|
||||
func add_access_evidence(npc_id: String, evidence: Dictionary) -> void:
|
||||
if not _open_incidents.has(npc_id):
|
||||
return
|
||||
var incident: Dictionary = _open_incidents[npc_id]
|
||||
incident["access_evidence"].append(evidence)
|
||||
if event_bus:
|
||||
event_bus.access_decided.emit(evidence.duplicate(true))
|
||||
incident["events"].append({
|
||||
"type": "access_check",
|
||||
"at_ms": Time.get_ticks_msec(),
|
||||
"evidence": evidence,
|
||||
})
|
||||
|
||||
func add_escalation(npc_id: String, level: int, reason: String) -> void:
|
||||
if not _open_incidents.has(npc_id):
|
||||
return
|
||||
var incident: Dictionary = _open_incidents[npc_id]
|
||||
incident["escalation_history"].append({
|
||||
"level": level,
|
||||
"reason": reason,
|
||||
"at_ms": Time.get_ticks_msec(),
|
||||
})
|
||||
|
||||
## Close an incident. outcome: e.g. "peaceful", "escort_off_property",
|
||||
## "assisted", "responded", "custody". Returns the closed incident.
|
||||
func close_incident(npc_id: String, outcome: String) -> Dictionary:
|
||||
if not _open_incidents.has(npc_id):
|
||||
return {}
|
||||
var incident: Dictionary = _open_incidents[npc_id]
|
||||
incident["outcome"] = outcome
|
||||
incident["closed_at_ms"] = Time.get_ticks_msec()
|
||||
incidents.append(incident)
|
||||
_open_incidents.erase(npc_id)
|
||||
if event_bus:
|
||||
event_bus.incident_recorded.emit(incident.duplicate(true))
|
||||
return incident
|
||||
|
||||
func open_incidents_count() -> int:
|
||||
return _open_incidents.size()
|
||||
|
||||
func to_dict() -> Dictionary:
|
||||
return {
|
||||
"incidents": incidents.duplicate(true),
|
||||
"open_count": _open_incidents.size(),
|
||||
}
|
||||
Reference in new issue
Block a user