Game.Prefabs.WorkStopData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary:
WorkStopData is a small ECS component used by the game's prefab/system to mark whether a work stop (prefab entity) has an associated work location. It is a value type (struct) that implements the game's serialization interface so its single boolean value is persisted/loaded by Colossal's serialization system. Typical usage is attaching this component to entities via the Unity.Entities EntityManager or querying it in systems that process work stops.
Fields
public bool m_WorkLocation
Indicates whether the work stop has a work location (true) or not (false). This field is the single data member of the struct and is what gets serialized/deserialized.
Properties
- This type exposes no public properties.
Constructors
public WorkStopData()
(implicit default struct constructor)
Because this is a plain struct, it has an implicit default constructor that initializes m_WorkLocation to false. You can initialize an instance using an object initializer:
var data = new WorkStopData { m_WorkLocation = true };
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the m_WorkLocation boolean to the provided writer. This method is called by the Colossal serialization pipeline to persist the component state. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads a boolean from the provided reader and assigns it to m_WorkLocation. This is used when loading saved data (or when reconstructing entities from serialized data).
Usage Example
// Adding the component to an entity and setting the flag
var workStop = new WorkStopData { m_WorkLocation = true };
entityManager.AddComponentData(entity, workStop);
// Reading the component in a system
var current = entityManager.GetComponentData<WorkStopData>(entity);
if (current.m_WorkLocation)
{
// handle work-location-specific logic
}
// Serialization is handled by the game's serialization system via the implemented methods.
// Example showing manual construction for testing serialization:
var writer = /* obtain an IWriter from serialization context */;
workStop.Serialize(writer);
var reader = /* obtain an IReader from serialization context */;
var loaded = new WorkStopData();
loaded.Deserialize(reader);
{{ This struct is intentionally minimal: it represents a single boolean flag and relies on the game's Colossal.Serialization.Entities IWriter/IReader for persistence. When modifying or extending this component, ensure compatibility with the serialization format and consider versioning if adding fields later. }}