Game.Prefabs.IndustrialProcessData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct IndustrialProcessData
Base: System.ValueType, implements IComponentData, IQueryTypeParameter, ISerializable
Summary:
IndustrialProcessData is an ECS component struct used to describe an industrial production process for a prefab in Cities: Skylines 2. It stores up to two input resource stacks, one output resource stack, the amount of work required per production unit, the maximum number of workers per cell (float), and a byte flag indicating import behavior. The struct implements ISerializable for game save/load (or prefab serialization) and IComponentData so it can be attached to entities in the Unity DOTS/ECS world. Keep field ordering stable to preserve save compatibility.
Fields
-
public ResourceStack m_Input1
Represents the primary input resource and its amount consumed per production unit. Typically a ResourceStack contains an identifier/type and a quantity. This field is serialized first; do not change ordering without handling save/data compatibility. -
public ResourceStack m_Input2
Represents an optional secondary input resource consumed per production unit. Can be a default/empty ResourceStack if not used. -
public ResourceStack m_Output
Represents the output resource produced per production unit. Holds the resource type and produced quantity. -
public int m_WorkPerUnit
Integer amount of "work" required to produce one unit of output. Determines production speed relative to worker/workforce input or production systems. -
public float m_MaxWorkersPerCell
Maximum number of workers assigned per cell/tile for this production process. A floating-point value allows fractional scaling when distributed across workforce systems. -
public byte m_IsImport
Byte flag indicating import behavior; typically 0 = not import, 1 = import-only (interpretation depends on game code). Stored as byte for compact serialization and potential extension.
Properties
- (none)
This struct does not expose any C# properties — only public fields. Use the fields directly or wrap them in helper methods elsewhere if needed.
Constructors
- (implicit default)
No explicit constructors are defined. The struct uses the implicit parameterless constructor. Initialize fields directly when creating an instance.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the struct's fields to the provided writer in the following order: m_Input1, m_Input2, m_Output, m_WorkPerUnit, m_MaxWorkersPerCell, m_IsImport. The generic writer must implement IWriter. Maintain this exact order to ensure serialization compatibility with Deserialize. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the struct's fields from the provided reader in the same order used by Serialize. The method uses out/ref semantics to populate the fields. The generic reader must implement IReader. Ensure readers/writers are paired and version-compatible when loading saved data.
Usage Example
// Example: creating an IndustrialProcessData and adding it to an entity (ECS)
var process = new Game.Prefabs.IndustrialProcessData
{
m_Input1 = new ResourceStack(resourceId: 1, amount: 5), // example constructor
m_Input2 = new ResourceStack(resourceId: 0, amount: 0), // unused
m_Output = new ResourceStack(resourceId: 10, amount: 1),
m_WorkPerUnit = 100,
m_MaxWorkersPerCell = 2.5f,
m_IsImport = 0
};
// Add to an entity (using EntityManager in DOTS)
entityManager.AddComponentData(myEntity, process);
// Example: serializing to a writer (hypothetical IWriter instance)
process.Serialize(myWriter);
// Example: deserializing
var loaded = new Game.Prefabs.IndustrialProcessData();
loaded.Deserialize(myReader);
Notes and tips: - ResourceStack is referenced but defined elsewhere; ensure you know its fields and serialization behavior. - Keep serialization field order stable between versions to avoid save-game compatibility issues. - Use AddComponentData or SetComponentData to apply this struct to entities in the game's ECS systems.