Skip to content

Game.Serialization.DataMigration.ShortLaneRemoveSystem

Assembly:
{{ Unknown — not specified in the source file. Likely part of the game's main assembly (Game) or a serialization/data-migration assembly. }}

Namespace: Game.Serialization.DataMigration

Type: class

Base: Game.Common.GameSystemBase

Summary:
This system runs during game load/data migration and adapts old save data that predates the "ShortLaneOptimization" format tag. It finds entities that represent SubLanes (with either Edge or Node components present) and, when the loaded save does not have the ShortLaneOptimization format tag, marks those entities with the Updated component so they can be processed/removed by subsequent migration logic. The [Preserve] attributes prevent stripping by build tools.


Fields

  • private LoadGameSystem m_LoadGameSystem
    Reference to the LoadGameSystem in the same World. Used to inspect the current load context (format tags, etc.) to decide whether migration behavior should run.

  • private EntityQuery m_Query
    An EntityQuery configured in OnCreate to select entities that have a SubLane component and either an Edge or Node component. Used by OnUpdate to target entities that require being marked Updated.

Properties

  • None

Constructors

  • public ShortLaneRemoveSystem()
    Default constructor. Marked with [Preserve] in the source to avoid being stripped; no custom initialization beyond what OnCreate performs.

Methods

  • protected override void OnCreate() : System.Void
    Initializes the system:
  • Acquires a reference to the LoadGameSystem via World.GetOrCreateSystemManaged().
  • Builds an EntityQuery that matches entities with SubLane (All) and at least one of Edge or Node (Any). This query is cached in m_Query for use in OnUpdate.

  • protected override void OnUpdate() : System.Void
    Per-frame/update logic executed while loading:

  • Checks the load context format flags via m_LoadGameSystem.context.format.Has(FormatTags.ShortLaneOptimization).
  • If the ShortLaneOptimization tag is NOT present and the query has matching entities (m_Query.IsEmptyIgnoreFilter is false), it adds the Updated component to all entities matched by m_Query through EntityManager.AddComponent(m_Query).
  • Adding Updated typically signals other systems or migration steps to handle removal or conversion of these SubLane entities.

Notes: - The system uses IsEmptyIgnoreFilter to ensure the check ignores filters and inspects the underlying query result. - The behavior is conditional on the save's format flags; when the ShortLaneOptimization flag is present, no action is taken.

Usage Example

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    m_LoadGameSystem = base.World.GetOrCreateSystemManaged<LoadGameSystem>();
    m_Query = GetEntityQuery(new EntityQueryDesc
    {
        All = new ComponentType[1] { ComponentType.ReadOnly<SubLane>() },
        Any = new ComponentType[2]
        {
            ComponentType.ReadOnly<Edge>(),
            ComponentType.ReadOnly<Node>()
        }
    });
}

{{ Additional notes for modders: - Purpose: This system is specifically for migration of legacy save data. If you are adding or changing lane/sub-lane representations in your mod, be aware of this migration path so old saves remain consistent. - To prevent this system from modifying entities for a custom load path, ensure the LoadGameSystem.context.format includes the FormatTags.ShortLaneOptimization flag when appropriate. - The Updated component is used as a signal — inspect systems that respond to Updated to understand the full removal/conversion pipeline for SubLane entities. - The [Preserve] attribute is applied to methods and the constructor to avoid stripping; when creating similar systems, add [Preserve] if they must be available at runtime despite code stripping. }}