Subsystems
Unreal's subsystems are singleton-like UObjects whose lifetime is managed automatically by the Engine. They come handy to act as managers or central pieces of logic, specially for local (non-networked) features. Subsystems are easy to access from the context they are associated with, from any actor or object. For example, to get the Unit Subsystem (which is a World Subsystem) we can just:
const auto UnitSubsystem = GetWorld()->GetSubsystem<URTSUnitSubsystem>();
Current subsystems reference:
1. Building subsystem
Manages central logic for buildings, most notably, it holds an octree wthat stores all building positions and extents, very useful to make spatial queries (for collision or enemy detection for example). It has utility functions to query the octree, and to draw building-related debug visualisation.
2. Experience subsystem
Handles all the logic to grant experience (and splash/area of effect experience) for units.
3. Fog of War subsystem
The fog of war subsystem handles the data setup and input for the GPU calculated fog of war, and sets up the post process material. This should not be confused with the CPU-calculated fog of war (see URTSFogOfWarProcessor), which is calculated completely independently for entity vision and logic. This GPU-based fog of war is mostly for the visuals of the fog and done through post-processing. The fog of war texture is calculated in a Niagara emitter as a compute-shader.
4. Ragdoll subsystem
Currently an optional/experimental and WIP feature, which might never be used/completed. It handles ragdoll logic, mostly to set a limit on ragdolls (we don't want to have too many at the same time), and handle the transition between entity and ragdoll proxy actor.
5. Unit subsystem
Last but not least, the most complex susbsytem is the unit subsystem. It performs a series of central actions related to units such as:
- Instantiate and update unit octree.
- Instantiate and update entity handle (battalion) octree.
- Feeds positions of selected units to Niagara to render selection decal indicators.
- Ticks turbosequence manager for animations
- Creates the boids when units are registered and links both.
- Utility functions to get units in radius
- Functions to render unit/boid-related debug visualisation.
It handles the unit octree (for spatial queries, same as the building susbsystem), the entity handle octree (for battalion detection),