Files
EscapistsReintroduced/docs/architecture.md
T

32 lines
4.6 KiB
Markdown

# Architecture
## Dependencies
`core -> ArmaReforger`; `ai -> core`; `intel -> core`; `map -> core`; `chat -> core, ai, intel, map`. Every project declares the vanilla dependency explicitly. Addon GUIDs are listed in `addons.json`; metadata supplies new resource GUIDs. `tools/check.py` rejects external addon dependencies, duplicate resource identities, unresolved resources and legacy Escapists symbols.
Core owns `ERR_GameMode`, mission rules, native spawn lifecycle integration, settings, the location registry, the vanilla faction catalog and authored scenario construction. `ERR_Phase` transitions are checked centrally. `ERR_LocationComponent` registers stable location IDs and replicates discovery. Mission phase, discovery and persistent settings mutations are server-owned.
The mode exposes `OnPhaseChanged`, `OnGroup`, `OnTick` and `OnStop` events. `ERR_CommandService` is the response-coordinator interface. AI supplies its implementation through `CreateCommandService`. Intel subscribes to group and mission ticks; Map observes replicated discovery and supplies its own field-map item through the scenario resource hook. Chat sends authenticated owner RPCs to mutate validated settings or read HQ status. Scenario placement and mission transitions are separate classes, but richer lifecycle and objective service interfaces remain migration work.
## HQ information flow
Physical group members observe through vanilla AI perception. `ERR_HQObservation` requires fresh visual observations; `ERR_HQReport` snapshots the available information. The radio graph uses living, correctly affiliated actors actually carrying radios. Reports traverse bounded physical routes, with delay and inventory/affiliation checks at each hop. The delivered contact registry expires stale reports. Orders return through the radio graph before an existing eligible group receives a native search waypoint.
The coordinator is the sole source of strategic response orders. Individual units retain vanilla tactical combat. It does not spawn reinforcements when alerted. Initial physical forces are authored by the scenario. No distant-unit virtual simulation is implemented.
The current coordinator is a reduced implementation. Full contact scheduling, supporting aircraft, mortar firing and physical logistics are not operational yet. The migrated availability/prediction/salvo helpers must not be mistaken for those controllers.
## Bounded work and ownership
HQ bounds group/contact registries and staggers report checks; routes have hop limits and timeouts. Intel has a bounded insertion queue and remembers physical folders already consumed, so handing a folder to another player cannot rediscover a location. The journal buffers and rotates output. Spawn retries are bounded and server-authored tickets constrain spawn resources and positions.
Stop events cancel service timers, remove HQ waypoints and despawn owned AI groups through the native group lifecycle. Composition walls have explicit hierarchy ownership. Two scripted round completions across restart are recorded, but full entity-count and memory soak tests are still required. The engine destroys the world during a scenario restart; merely clearing an owner array is not evidence of complete entity cleanup.
## Round player lifecycle
`ERR_PlayerRoster` owns life records by backend identity; transient connection IDs are only lookup keys. Spawn, disconnect and rebind publish `OnChanged`. The native reconnect component retains the same physical character for voluntary as well as involuntary departures during its configured reservation interval. Reservation expiry does not restore a spent life. The defeat check includes reserved living characters. A server with no connected players pauses defeat and clears the radio defence timer.
First-time arrivals may spawn during prison, search or defence. Late spawn positions are checked beside conscious, on-foot survivors, with the authored prison as fallback. New arrivals during extraction observe until the next round. Dead players cannot request another life. Unconscious characters remain survivors and retain their own camera; they do not hold the radio objective.
The server selects a living friendly survivor for each spectator and replicates only its replication ID and fallback position. A local camera follows that survivor; owner RPCs allow `/esc spectate next` and `/esc spectate previous`. Only the selected survivor and occupied vehicle are pinned for streaming to that spectator. Loss, target changes and mission stop release pins. Reconnect, remote streaming and multi-client camera behavior still require multiplayer tests.