Game.Notifications.MarkerCreateSystem
Assembly: Assembly-CSharp
Namespace: Game.Notifications
Type: class
Base: GameSystemBase, IPostDeserialize
Summary:
MarkerCreateSystem is an ECS system responsible for creating and removing "marker" icons (notification icons) for game entities such as transport stops, buildings, vehicles and other marker-capable objects. It collects infomode filters and active tool requirements, builds bitmasks for which marker/icon types should be active, and schedules a parallel JobChunk (MarkerCreateJob) that inspects archetype chunks and issues icon add/remove commands through IconCommandSystem. The system supports prefabs for different transport/vehicle/building/marker types, honors infomode priorities, handles standalone stops and outside connections, and avoids clustering when necessary (e.g. for vehicles). It also implements IPostDeserialize to initialize internal masks after loading.
Fields
-
private ToolSystem m_ToolSystem
{{ m_ToolSystem is a reference to the ToolSystem used to read active tool state (e.g. editor/selection tool and its stop/icon requirements). }} -
private IconCommandSystem m_IconCommandSystem
{{ Used to create an IconCommandBuffer to queue icon add/remove commands produced by the job. }} -
private EntityQuery m_EntityQuery
{{ Query used to find the relevant entities when processing normally (or after load). Matches transport stops, buildings or vehicles (and markers) excluding deleted/owned/trailers/upgraded service buildings as configured. }} -
private EntityQuery m_UpdatedQuery
{{ Smaller query used to run updates on changed/created/deleted entities when the system is already loaded (optimized incremental update). }} -
private EntityQuery m_InfomodeQuery
{{ Query for active infomode prefabs (Infoview* components) used to compute active infomode masks and priorities. }} -
private EntityQuery m_IconQuery
{{ Query that gathers icon prefabs (TransportStopMarkerData, BuildingMarkerData, VehicleMarkerData, MarkerMarkerData, PrefabData) used to find marker prefabs. }} -
private uint m_TransportTypeMask
{{ Bitmask of which TransportType markers are currently requested (from infomodes and tools). }} -
private uint m_BuildingTypeMask
{{ Bitmask of which BuildingType markers are currently requested. }} -
private uint m_BuildingStatusTypeMask
{{ Bitmask of requested BuildingStatus / Signature building marker types. }} -
private uint m_VehicleTypeMask
{{ Bitmask of requested VehicleType markers. }} -
private uint m_MarkerTypeMask
{{ Bitmask of requested MarkerType markers. }} -
private bool m_Loaded
{{ Flag set by PostDeserialize to indicate the system was just loaded; used to choose the initial entity query. }} -
private TypeHandle __TypeHandle
{{ Internal structure holding ComponentTypeHandle/BufferTypeHandle/ComponentLookup instances used to create job type handles and lookups. }} -
private struct MarkerCreateJob
(nested)
{{ A Burst-compiled IJobChunk that performs the heavy work: for each chunk it determines applicable marker prefab(s) based on component composition, infomode/tool requirements and prefab icon definitions, then issues add/remove icon commands via IconCommandBuffer. Contains a number of helper functions (GetTransportStopType, IsTransportStopType, FindMarkerPrefab, GetBuildingType, IsBuildingType, GetVehicleType, IsVehicleType, GetMarkerType, IsMarkerType) used to decide which marker to spawn. }} -
private struct TypeHandle
(nested)
{{ Holds pre-assigned ComponentTypeHandle/BufferTypeHandle/ComponentLookup fields and an __AssignHandles method to initialize them from a SystemState. Used to avoid repeated GetComponentTypeHandle/GetComponentLookup calls each frame. }}
Properties
- None (no public properties exposed)
{{ All state is private; the system is driven by queries, PostDeserialize and internal job scheduling. }}
Constructors
public MarkerCreateSystem()
{{ Default constructor. The real initialization is done in OnCreate; constructor preserved for runtime and compiler. }}
Methods
-
protected override void OnCreate()
{{ Initializes references to ToolSystem and IconCommandSystem and constructs the EntityQuery instances (m_EntityQuery, m_UpdatedQuery, m_InfomodeQuery, m_IconQuery). This sets up which entities and icon prefabs the system will operate on. The method is marked [Preserve] in the source. }} -
public void PostDeserialize(Context context)
{{ Implementation of IPostDeserialize. Resets the various type masks to uint.MaxValue and sets m_Loaded = true so the next update treats the world as freshly loaded and uses the full-matching entity query for initial icon population. }} -
private bool GetLoaded()
{{ Helper that returns true once if m_Loaded is true, and sets m_Loaded to false. Used in OnUpdate to switch between initial full update vs incremental updated query. }} -
protected override void OnUpdate()
{{ Core update method. Collects current tool/informode requirements and builds bitmasks for requested marker types. If nothing changed (masks and query emptiness), it early-outs. Otherwise it constructs NativeArrays/NativeLists for infomode chunks and icon prefab chunks, creates a MarkerCreateJob, fills it with the appropriate type handles, lookups and flags, schedules it (parallel) over the relevant entity query, and wires up the IconCommandSystem command buffer dependencies. Also disposes temporary chunk arrays/lists with job dependencies. }} -
private void __AssignQueries(ref SystemState state)
{{ Internal helper used by compiler-generated paths to ensure queries are assigned; in this class it doesn't build custom queries (it creates them in OnCreate), but the method exists for compatibility with codegen. }} -
protected override void OnCreateForCompiler()
{{ Compiler/runtime helper that calls __AssignQueries and __TypeHandle.__AssignHandles to set up handles for the code-generated variant of the system. }} -
(Nested/MarkerCreateJob)
public void Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
{{ The job's Execute implementation. For each chunk, determines which marker prefab(s) to use based on chunk components and infomode/tool state, then:- Adds icon commands for owners/entities (using IconCommandBuffer.Add) with flags (priority, cluster layer, uniqueness, hidden, disallow cluster) as appropriate.
- Removes icon commands for icon buffer entries whose prefab does not match the marker prefabs currently chosen. The job contains many helper functions for resolving types and finding marker prefabs by iterating icon prefab chunks. The job is [BurstCompile] and uses many readonly ComponentTypeHandles and ComponentLookups passed in at schedule time. }}
-
(Nested/TypeHandle)
public void __AssignHandles(ref SystemState state)
{{ Assigns all ComponentTypeHandle, BufferTypeHandle and ComponentLookup fields from the provided SystemState. Called from OnCreateForCompiler to prepare handles used when scheduling the job. }}
Usage Example
[Preserve]
protected override void OnCreate()
{
base.OnCreate();
// Typical initialization performed by the system:
m_ToolSystem = base.World.GetOrCreateSystemManaged<ToolSystem>();
m_IconCommandSystem = base.World.GetOrCreateSystemManaged<IconCommandSystem>();
// The system builds EntityQuery instances in its OnCreate to select transport stops,
// buildings, vehicles and marker-prefab archetypes. No further setup is required here.
}
{{ NOTES: - MarkerCreateSystem is heavily data-driven and relies on prefab marker definitions (TransportStopMarkerData, BuildingMarkerData, VehicleMarkerData, MarkerMarkerData) being present in the world so it can resolve which prefab entity to use as the visual icon. - The system uses IconCommandSystem.CreateCommandBuffer to produce commands from the job; this avoids touching managed state inside the job and batches changes back to the IconCommandSystem. - Infomode chunks and active tool settings influence which icons are shown — the system computes bitmasks and infomode priorities to decide preferred marker types. - The nested MarkerCreateJob is Burst-compiled and parallel-scheduled for performance; when creating custom systems or debugging, ensure you respect safety rules for ComponentLookups and Native container usage. }}