FResidentSystem
FResidentSystem — the brain of every Resident, stepped at a fixed 10 Hz so the same session and the same stimuli land on the same bits at any frame rate (the Attention meter's rule).
- Module
- AINavigation
- Header
#include "AINavigation/ResidentSystem.h"- Namespace
Mowo
Perception is stimulus-driven and needs no line of sight. A sound, a voice or a scan pulse on the bus is heard when it lies within its reach after the room graph has taken its share (FSoundPropagation, or whatever SetPropagation installs); how well it was heard sets how far the Resident's alertness rises and how exact the position it believes is. The belief — the last place the crew was sensed — loses confidence with a half-life and is given up below the profile's floor.
Stage is the alertness stage, lifted to the floor the Attention meter's stage allows. A Dormant Resident stands; the others walk the NavAgent to the belief and, Searching or Hunting, visit points sampled around it that sound could still reach from the belief.
Only the authority (the host, or an offline game) simulates. It replicates each Resident's stage and belief to the clients at 4 Hz; a client only shows what it was sent.
Type aliases
| Alias | Description |
|---|---|
using FPropagationFn = std::function<float(const Vec3& from, const Vec3& to)> |
Properties
| Type | Name | Description |
|---|---|---|
static constexpr uint16_t | kNetEventId | Default 0xFE50. |
static constexpr float | kStepSeconds | Default 0.1f. |
static constexpr float | kSendSeconds | Default 0.25f. |
static constexpr float | kScanHitRadius | Default 0.9f. |
static constexpr float | kScanHitHeight | Default 0.9f. |
Constructors
| Signature | Name | Description |
|---|---|---|
FResidentSystem() | FResidentSystem | |
~FResidentSystem() override | ~FResidentSystem | |
FResidentSystem(const FResidentSystem&) = delete | FResidentSystem |
Public functions
| Returns | Name | Description |
|---|---|---|
FResidentSystem& | operator= | |
SystemPhase | GetPhase | |
bool | DeclaresComponentAccess | |
ComponentMask | GetReadMask | |
ComponentMask | GetWriteMask | |
void | Update | |
void | SetStimulusBus | The bus Residents hear from; unset, the world's AIPerceptionSystem bus. |
void | SetPropagation | Gain (0..1) a sound keeps travelling between two points; unset, the world's room and portal graph. |
void | SetDefaultProfile | |
void | SetSessionSeed | The session seed every Resident's stream derives from; unset, the process seed (--seed=N pins it). |
uint32_t | GetSessionSeed | |
float | Hear | Hears one stimulus as resident would from where it stands. |
FScanResponse | ReactToScan | A scan pulse struck the Resident (the S3 reaction table row): alarms it toward scannerPosition and returns the response the scan should apply to the points the Resident returns. |
uint32_t | ReactToScanHits | The scan service's hook: every Resident standing where a shot's rays landed reacts once. |
void | InstallScanResponse | Files the Resident's response as an instance rule, so the scan service resolves it with every other rule. |
void | RaiseAlertness | Lifts alertness directly — a designer's or a script's push. |
bool | IsAuthority | |
int32_t | GetStage | |
const std::vector<Vec3>* | GetSearchPoints | |
TMulticastDelegate<EntityID, int32_t, int32_t>& | OnStageChanged | Fired on the authority as it happens, on a client as replicated state arrives. |
TMulticastDelegate<EntityID, int32_t, Vec3, float>& | OnStimulusHeard | |
TMulticastDelegate<EntityID>& | OnTargetLost | |
uint32_t | GetEventSerial | Monotone counters and the last event's kind for Visual Scripting, which polls rather than binds: 1 stage, 2 heard, 3 lost. |
int32_t | GetLastEventKind | |
EntityID | GetLastEventResident | |
void | DebugDrawResidents |
Function details
FResidentSystem
FResidentSystem()~FResidentSystem
~FResidentSystem() overrideFResidentSystem
FResidentSystem(const FResidentSystem&) = deleteoperator=
FResidentSystem& operator=(const FResidentSystem&) = deleteGetPhase
SystemPhase GetPhase() const overrideDeclaresComponentAccess
bool DeclaresComponentAccess() const overrideGetReadMask
ComponentMask GetReadMask() const overrideGetWriteMask
ComponentMask GetWriteMask() const overrideUpdate
void Update(float deltaTime) overrideSetStimulusBus
void SetStimulusBus(const FAIStimulusBus* bus)The bus Residents hear from; unset, the world's AIPerceptionSystem bus.
SetPropagation
void SetPropagation(FPropagationFn propagation)Gain (0..1) a sound keeps travelling between two points; unset, the world's room and portal graph.
SetDefaultProfile
void SetDefaultProfile(const FResidentProfile& profile)SetSessionSeed
void SetSessionSeed(uint32_t seed)The session seed every Resident's stream derives from; unset, the process seed (--seed=N pins it).
GetSessionSeed
uint32_t GetSessionSeed() constHear
float Hear(EntityID resident, const FAIStimulus& stimulus)Hears one stimulus as resident would from where it stands. Returns how well it was heard, 0..1, 0 when it was out of reach.
ReactToScan
FScanResponse ReactToScan(EntityID resident, const Vec3& scannerPosition, float shotRange = 0.0f)A scan pulse struck the Resident (the S3 reaction table row): alarms it toward scannerPosition and returns the response the scan should apply to the points the Resident returns. shotRange (the scanner's range, 0 = unknown) scales the alarm by how near the Resident stood: a hit at the edge of the beam is a faint ping, one at the scanner's feet is a scream.
ReactToScanHits
uint32_t ReactToScanHits(const Vec3& scannerPosition, float shotRange, const Vec3* hitPositions, uint32_t hitCount)The scan service's hook: every Resident standing where a shot's rays landed reacts once. Returns how many did. Authority only.
InstallScanResponse
void InstallScanResponse(FScanResponseTable& table, EntityID resident)Files the Resident's response as an instance rule, so the scan service resolves it with every other rule.
RaiseAlertness
void RaiseAlertness(EntityID resident, float amount)Lifts alertness directly — a designer's or a script's push.
IsAuthority
bool IsAuthority() constGetStage
int32_t GetStage(EntityID resident) constGetSearchPoints
const std::vector<Vec3>* GetSearchPoints(EntityID resident) constOnStageChanged
TMulticastDelegate<EntityID, int32_t, int32_t>& OnStageChanged()Fired on the authority as it happens, on a client as replicated state arrives. Stage: resident, old, new. Heard: resident, stimulus type, position, how well. Lost: resident.
OnStimulusHeard
TMulticastDelegate<EntityID, int32_t, Vec3, float>& OnStimulusHeard()OnTargetLost
TMulticastDelegate<EntityID>& OnTargetLost()GetEventSerial
uint32_t GetEventSerial() constMonotone counters and the last event's kind for Visual Scripting, which polls rather than binds: 1 stage, 2 heard, 3 lost.
GetLastEventKind
int32_t GetLastEventKind() constGetLastEventResident
EntityID GetLastEventResident() constDebugDrawResidents
static void DebugDrawResidents(World* world)