Game.Prefabs.HearseData
Assembly:
Game (assembly containing the game's prefabs; exact assembly name not specified)
Namespace:
Game.Prefabs
Type:
struct
Base:
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.ISerializable
Summary:
HearseData is a lightweight Unity ECS component that stores the corpse capacity for a hearse prefab/entity. It is used by the game's prefab/entity systems to hold the number of corpses a hearse can carry and participates in the game's serialization system via ISerializable to persist this value across save/load.
Fields
public System.Int32 m_CorpseCapacity
Holds the maximum number of corpses the hearse can carry. Serialized/deserialized as a single integer by the implemented ISerializable methods. Typical usage is to set this when creating or configuring a hearse prefab/entity.
Properties
- (none)
This struct exposes its data via the public field m_CorpseCapacity rather than properties.
Constructors
public HearseData(int corpseCapacity)
Creates a new HearseData instance initializing m_CorpseCapacity to the provided value. Use this to construct the component before attaching it to an entity or prefab.
Example:
var hearse = new HearseData(8); // hearse that can carry 8 corpses
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the m_CorpseCapacity integer to the provided writer. Used by the game's save/serialization pipeline to persist this component's value. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads an integer from the provided reader into m_CorpseCapacity. Used by the game's load/deserialization pipeline to restore this component's value.
Notes: - The serialization format is a single integer written/read in the same order as other serialized fields; ensure compatibility if changing field order or adding fields. - Generic writer/reader types are constrained by Colossal.Serialization.Entities.IWriter and IReader.
Usage Example
// Create and attach HearseData to an entity (using Unity.Entities APIs)
var hearseData = new Game.Prefabs.HearseData(corpseCapacity: 6);
entityManager.AddComponentData(hearseEntity, hearseData);
// Or update an existing component
var existing = entityManager.GetComponentData<Game.Prefabs.HearseData>(hearseEntity);
existing.m_CorpseCapacity = 10;
entityManager.SetComponentData(hearseEntity, existing);
// Serialization is handled by the game's systems via the Serialize/Deserialize methods.
// If manually using a writer/reader (rare), the methods simply write/read a single int:
writer.Write(hearseData.m_CorpseCapacity);
reader.Read(out hearseData.m_CorpseCapacity);