Game.Prefabs.ContentData
Assembly:
Likely Assembly-CSharp (game assembly); not explicit in source file.
Namespace:
Game.Prefabs
Type:
struct
Base:
Implements IComponentData, IQueryTypeParameter, ISerializable
Summary:
ContentData is a small ECS component used to tag prefab content with content-related metadata: flags describing the content and an integer DLC identifier. It implements Colossal.Serialization.Entities.ISerializable to control binary serialization order and Unity.Entities.IComponentData to be used as a component in the ECS world. The serialized format writes the flags (as a uint) first, then the DLC id (int).
Fields
-
public ContentFlags m_Flags
Holds content flags describing the prefab (bitmask). Serialized as a uint in Serialize and reconstructed in Deserialize. The exact semantics depend on the ContentFlags enum definition elsewhere in the codebase. -
public int m_DlcID
Integer identifier for the DLC this content belongs to. Serialized after the flags. Deserialize reads directly into this field via a ref to avoid temporary storage.
Properties
- This type declares no properties. It exposes public fields for use by ECS and serialization.
Constructors
public ContentData()
No explicit constructor is defined in source — the struct uses the default parameterless constructor (all fields default-initialized). You can create instances with new ContentData { m_Flags = ..., m_DlcID = ... }.
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component data to the provided writer in the following order:- Writes m_Flags cast to uint.
-
Writes m_DlcID as an int. This deterministic order must match readers when deserializing.
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads data from the provided reader in the same order as written: - Reads a uint into a local value, then assigns it to m_Flags after casting to ContentFlags.
- Reads an int directly into m_DlcID using a ref read to avoid an extra temporary. Be sure the reader corresponds to the writer used for serialization (same endianness/format).
Usage Example
// Creating and assigning
var content = new ContentData {
m_Flags = ContentFlags.None,
m_DlcID = 0
};
// Example: serializing to a writer (pseudo-code, depends on actual IWriter implementation)
using (var streamWriter = new BinaryWriterStream(...))
{
var writer = new SomeWriterImplementation(streamWriter);
content.Serialize(writer);
}
// Example: deserializing from a reader (pseudo-code)
var readContent = new ContentData();
using (var streamReader = new BinaryReaderStream(...))
{
var reader = new SomeReaderImplementation(streamReader);
readContent.Deserialize(reader);
}
// As an ECS component:
// entityManager.AddComponentData(entity, new ContentData { m_Flags = ..., m_DlcID = ... });
Notes and tips: - Ensure the ContentFlags enum and its numeric values match what other systems expect when serialized. - The Serialize/Deserialize order is important: flags (uint) first, then dlc id (int). - Because this is a struct and an IComponentData, prefer value semantics and avoid long-lived references to mutable instances.