public sealed class PerceptionSystemWorks out what every listener can notice, as cheaply as the three bounds allow.
As a system
- Phase
- Update
- Writes
- AiPerception
- Runs before
- AiSystem
Remarks
The order of the tests is the design, and doc 37 § D15 makes all three mandatory rather than tuning: a StimuliGrid instead of a scan, a per-listener update rate with a random deviation, and distance-based rate reduction. Within a pass the cheapest test comes first — the filter, then the radius, then the cone, then the trace — because the last one is a raycast and everything above it exists to stop it happening.
Runs in Update and before AiSystem, so a behaviour tree steps on this frame's perception rather than last frame's. That matters more than it sounds: the two systems are the abort loop — a sense writes a key, the key has observers, and an observer interrupts a branch — and running them the other way round puts a frame of lag inside it.
⚠ A listener is not required to be an AiAgent. The blackboard binding is the only part that needs one, and it is skipped when Agents is unset or the entity has no agent — so a camera, a trap or a trigger can perceive without deciding.
Fields and properties (11)
public PerceptionLibrary ConfigsWhat its listeners sense with, by index.
public IPerceptionGovernor GovernorHow often each listener senses. Replaceable, because what an agent is worth is a game's decision.
public IOcclusionTester OcclusionWhat stops sight. OpenSightlines until a game hands it a physics world.
public Vector3? FocusWhere the agents that matter are — usually the player.
public AiSystem? AgentsWhere the blackboards are, for Binding.
public bool BroadPhaseWhether to use the StimuliGrid.
public float EventMemoryHow long an event stays available for a listener that has not sensed yet, in seconds.
public PerceptionStats LastStatsWhat the last frame cost.
public int PopulationHow many listeners have joined.
public float ClockThe clock the stamps and ages are against, in seconds since the system started.
public SystemAccess AccessWhat this system reads and writes.
Methods (8)
public PerceptionSystem(PerceptionLibrary? configs = null)Creates the system.
public override JobHandle Update(in SystemContext context, JobHandle dependency)Runs the system.
public void Step(World world, GameTime time)Runs one frame against a world.
public PerceivedTargets? PerceivedBy(in AiPerception listener)What a listener knows, or null if it has not joined.
public PerceivedTargets? PerceivedBy(World world, Entity listener)What a listener knows, by entity.
public static Vector3 PositionOf(World world, Entity entity)Where an entity is, as this system reads it.
public void ReportNoise(Entity source, Vector3 at, float loudness = 1)Makes a noise anything in range can hear.
public void ReportDamage(Entity source, Entity victim, Vector3 at, float amount = 1)Tells one listener it was hurt.
Used by (26)
- AiGameplayDebuggerVixen.Ai.Diagnostics
- BindingTestsVixen.Ai.Perception.Tests
- EventSenseTestsVixen.Ai.Perception.Tests
- FilterTestsVixen.Ai.Perception.Tests
- FleetVixen.Ai.Perception.Tests
- MakeNoiseTaskVixen.Ai.Perception
- NearestPerceivedInputVixen.Ai.Perception
- NearestPerceivedSensorVixen.Ai.Perception
- NearestPerceivedServiceVixen.Ai.Perception
- OverlayFixtureVixen.Ai.Diagnostics.Tests
- PatrolChaseGiveUpTestsVixen.Ai.Nodes.Tests
- PerceivedCountInputVixen.Ai.Perception
- PerceivedCountSensorVixen.Ai.Perception
- PerceivedTargetDecoratorVixen.Ai.Perception
- PerceptionCostTestsVixen.Ai.Perception.Tests
- PerceptionInputsVixen.Ai.Perception
- PerceptionLayeringTestsVixen.Ai.Perception.Tests
- PerceptionNodeTestsVixen.Ai.Perception.Tests
- PerceptionNodesVixen.Ai.Perception
- PerceptionSnapshotsVixen.Ai.Perception
- ScheduleTestsVixen.Ai.Perception.Tests
- SeamTestsVixen.Ai.Nodes.Tests
- SightOcclusionTestsVixen.Ai.Perception.Tests
- SightTestsVixen.Ai.Perception.Tests
- VillageVixen.Ai.Nodes.Tests
- VillageSampleTestsVixen.Ai.Nodes.Tests