Game.Prefabs.MailBoxData
Assembly:
Assembly-CSharp.dll
Namespace:
Game.Prefabs
Type:
struct
Base:
IComponentData, IQueryTypeParameter, ISerializable
Summary:
MailBoxData is an ECS component (Unity.Entities.IComponentData) used to store mailbox-specific data for a prefab — currently it holds the integer mail capacity. It also implements Colossal.Serialization.ISerializable so the m_MailCapacity value can be written to and read from the game's serialization streams. This struct is suitable to be added to entities that represent mailbox prefabs and participates in queries via IQueryTypeParameter.
Fields
public System.Int32 m_MailCapacity
Holds the mailbox capacity (number of mail items the mailbox can store). This value is serialized/deserialized by the Serialize/Deserialize methods.
Properties
- No public properties are defined on this struct.
Constructors
public MailBoxData()
Implicit default struct constructor. By default m_MailCapacity is 0. You can create an instance and set m_MailCapacity before adding it to an entity or serializing it.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the m_MailCapacity value into the provided writer. This method is part of the Colossal.Serialization.ISerializable contract and is called by the game's serialization system to persist the component state. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads an Int32 from the provided reader into m_MailCapacity. This implements the ISerializable contract for restoring component state from a saved stream.
Usage Example
// Create and assign the component (example in a system or prefab setup)
var mailbox = new MailBoxData { m_MailCapacity = 50 };
entityManager.AddComponentData(entity, mailbox);
// Example of how the serialization methods would be used by a writer/reader.
// (IWriter/IReader are provided by Colossal.Serialization; writer/reader instances
// are supplied by the game's serialization infrastructure.)
// Serializing
void SaveComponent<TWriter>(ref MailBoxData data, TWriter writer) where TWriter : IWriter
{
data.Serialize(writer);
}
// Deserializing
void LoadComponent<TReader>(out MailBoxData data, TReader reader) where TReader : IReader
{
data = new MailBoxData();
data.Deserialize(reader);
}