Game.GarbageProducerSystem
Assembly: Assembly-CSharp
Namespace: Game.Serialization
Type: class
Base: GameSystemBase, IPostDeserialize
Summary:
GarbageProducerSystem is a small runtime/system class used during deserialization to migrate legacy garbage producer state for older saved games. When deserializing from versions older than Version.garbageProducerFlags it scans entities with a GarbageProducer component, inspects their IconElement buffer for the garbage notification prefab, and sets the GarbagePilingUpWarning flag on the GarbageProducer component where appropriate. The system also contains compiler helper wiring (query assignment and type-handle assignment) used by the game's ECS/Jobs integration.
Fields
-
private EntityQuery m_Query
Used to store an EntityQuery instance. In this compiled form it appears declared but is not referenced by the visible code; it may be reserved for other compiler-generated logic or future queries. -
private TypeHandle __TypeHandle
A compiler-generated struct instance (see inner TypeHandle type). The TypeHandle is responsible for assigning ECS type handles via its __AssignHandles method when the system is created for the compiler/runtime. -
private EntityQuery __query_31347557_0
An EntityQuery built in __AssignQueries. It is used to obtain the GarbageParameterData singleton (which contains the m_GarbageNotificationPrefab reference) required by the migration performed in PostDeserialize.
Properties
- This type does not declare any public properties.
Constructors
public GarbageProducerSystem()
Default constructor. Marked with [Preserve] to avoid stripping by the Unity linkers. No custom runtime initialization is performed here; the system sets up its queries and type handles in OnCreateForCompiler.
Methods
-
protected override void OnUpdate()
The runtime update method is empty in this compiled code — the system performs no per-frame work. -
public void PostDeserialize(Context context)
This is the key method for this system. It is invoked after deserialization and performs a migration when the deserialized context.version is older than Version.garbageProducerFlags. Behavior: - Early exit if context.version >= Version.garbageProducerFlags (no migration needed).
- Builds an entity query for entities with the GarbageProducer component.
- Reads the GarbageParameterData singleton (via __query_31347557_0) to obtain the garbage notification prefab (m_GarbageNotificationPrefab).
- Iterates all GarbageProducer entities (converted to a NativeArray
with Allocator.TempJob). - For each entity, if it has an IconElement DynamicBuffer, iterates the buffer; for any IconElement whose m_Icon prefab reference matches the garbage notification prefab, the system sets the GarbagePilingUpWarning flag on that entity's GarbageProducer component (if not already set) and writes the component back to the EntityManager.
- Disposes the temporary NativeArray.
-
Notes: uses base.EntityManager.TryGetBuffer / TryGetComponent / TryGetComponent
to safely query buffers and components. The method is migration-only and only touches entities when the condition on versions is met. -
private void __AssignQueries(ref SystemState state)
Compiler-generated helper that constructs an EntityQuery for GarbageParameterData (including EntityQueryOptions.IncludeSystems) and stores it in __query_31347557_0. Uses an EntityQueryBuilder with Allocator.Temp and disposes/cleans up builder resources. -
protected override void OnCreateForCompiler()
Called when the system is created by the compiler/runtime. It calls base.OnCreateForCompiler(), then calls __AssignQueries and the TypeHandle's __AssignHandles to initialize query and type-handle state required for runtime operation. -
private struct TypeHandle
(inner type) public void __AssignHandles(ref SystemState state)
Compiler-generated stub to assign type handles. In this decompiled form the method is empty but is a placeholder expected by the system creation flow.
Usage Example
// Illustrative example: trigger the migration logic after loading an old save.
// The real game serialization pipeline calls PostDeserialize automatically.
// This example shows how you might invoke it manually in a test environment.
var world = ...; // obtain the World / Game world that owns systems
var system = world.GetExistingSystemManaged<Game.Serialization.GarbageProducerSystem>();
if (system != null)
{
// Construct a Context with a version older than Version.garbageProducerFlags
var ctx = new Context { version = Version.SomeOlderVersion };
system.PostDeserialize(ctx); // runs the migration that sets GarbagePilingUpWarning flags
}
Note: Context and Version are game-specific types. In normal operation the game's deserialization pipeline will call PostDeserialize — manual invocation is only needed for tests or tooling.