Game.ContentPrerequisiteData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct (public)
Base: System.ValueType, Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.ISerializable
Summary:
Represents an ECS component that stores a reference to a prerequisite content entity for prefabs. This struct is used by the prefab/content system to record dependencies between content items and supports runtime serialization through the Colossal.Serialization system. Because it implements IComponentData it can be attached to entities managed by Unity's ECS (DOTS) and can be used as a query parameter via IQueryTypeParameter.
Fields
public Unity.Entities.Entity m_ContentPrerequisite
Holds an Entity reference that points to the prerequisite content/prefab. When present on a prefab/entity this indicates that the referenced content must be available/loaded for the owning prefab to satisfy its prerequisites. This field is serialized/deserialized by the implemented ISerializable methods.
Properties
- This type has no properties.
Constructors
public ContentPrerequisiteData()
Default value-type constructor. As a struct, a default instance has m_ContentPrerequisite equal to the default Entity (typically an invalid/null entity).
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the m_ContentPrerequisite Entity to the provided writer. Used by the game's serialization pipeline to persist this component's data. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads an Entity value from the provided reader into m_ContentPrerequisite. Used when loading/deserializing component data.
Usage Example
// Create or obtain an EntityManager and the entity to attach the component to
EntityManager entityManager = world.EntityManager;
Entity myPrefabEntity = /* existing prefab entity */;
Entity prerequisiteEntity = /* entity representing required content */;
// Assign the prerequisite component to the prefab/entity
var prereq = new Game.Prefabs.ContentPrerequisiteData
{
m_ContentPrerequisite = prerequisiteEntity
};
entityManager.AddComponentData(myPrefabEntity, prereq);
// During serialization the Serialize<TWriter> method is invoked by the serializer.
// During loading the Deserialize<TReader> method restores the m_ContentPrerequisite field.