Struct GhostDistancePartitioningSystem
Automatically adds the GhostDistancePartitionShared shared component to each ghost instance on the server (a structural change), and then updates said component - for each ghost instance - if its Unity.Transforms.LocalTransform.Position changes to a new tile (which is also a structural change, as it needs to update a shared component value). It does this every tick.
Implements
Inherited Members
Namespace: Unity.NetCode
Assembly: Unity.NetCode.dll
Syntax
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation, WorldSystemFilterFlags.Default)]
[UpdateInGroup(typeof(GhostSimulationSystemGroup), OrderFirst = true)]
[BurstCompile]
public struct GhostDistancePartitioningSystem : ISystem, ISystemStartStop, ISystemCompilerGenerated
Remarks
This system only operates if it detects the existence of the GhostDistanceData configuration singleton component within a ServerWorld.
Note that adding the GhostDistancePartitionShared shared component to each ghost instance will almost certainly exacerbate Unity.Entities.ArchetypeChunk entity fragmentation, as we're using the Unity.Entities.ArchetypeChunk system to spatially partition ghost instances. I.e. If there are (for example) just two ghosts of the same archetype within a specific tile, the maximum utilization of their chunk will by 2.
Note that, due to; a) the number of changed positions this system needs to check; b) the frequency of structural changes created by this system; and c) the fragmentation caused by the shared component itself, the impact of enabling importance scaling should be measured, and benchmarked against other possible solutions.
Methods
OnCreate(ref SystemState)
Declaration
[BurstCompile]
public void OnCreate(ref SystemState state)
Parameters
Type | Name | Description |
---|---|---|
SystemState | state |
OnCreateForCompiler(ref SystemState)
Declaration
public void OnCreateForCompiler(ref SystemState state)
Parameters
Type | Name | Description |
---|---|---|
SystemState | state |
OnStartRunning(ref SystemState)
Declaration
[BurstCompile]
public void OnStartRunning(ref SystemState state)
Parameters
Type | Name | Description |
---|---|---|
SystemState | state |
OnStopRunning(ref SystemState)
Clean up any/all GhostDistancePartitionShared components that we've added. Note: This will not de-frag fragmented chunks automatically.
Declaration
[BurstCompile]
public void OnStopRunning(ref SystemState state)
Parameters
Type | Name | Description |
---|---|---|
SystemState | state |
OnUpdate(ref SystemState)
Declaration
[BurstCompile]
public void OnUpdate(ref SystemState state)
Parameters
Type | Name | Description |
---|---|---|
SystemState | state |