Game.Objects.Quantity
Assembly: Assembly-CSharp
Namespace: Game.Objects
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary:
Quantity is a small Unity ECS component that stores a single byte representing the "fullness" or quantity level of an object. It is designed to be memory-efficient (byte-sized) and supports serialization for save/load by implementing ISerializable. It also implements IQueryTypeParameter so it can be used in entity queries.
Fields
public byte m_Fullness
Represents the stored quantity/fullness as a single byte (0–255). Default value is 0 for a newly created struct. The value is written/read directly during serialization via Write/Read on the provided writer/reader.
Properties
- None.
This struct exposes its payload as the public field m_Fullness. Use the field directly or wrap it in helper methods if you need validation or clamping.
Constructors
- Implicit default constructor (public Quantity())
There is no explicit constructor defined in the source; use object initializer syntax to set m_Fullness, e.g.: new Quantity { m_Fullness = 128 };
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the m_Fullness byte into the provided writer. Used during saving/streaming of entity data. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads a byte from the provided reader into m_Fullness. Used when loading/deserializing entity data.
Usage Example
// Creating and adding as a component to an entity
var q = new Game.Objects.Quantity { m_Fullness = 200 };
entityManager.AddComponentData(entity, q);
// Serializing (pseudo-code; depends on concrete IWriter implementation)
writer.Write(q.m_Fullness);
// Deserializing (pseudo-code; depends on concrete IReader implementation)
Game.Objects.Quantity q2;
reader.Read(out q2.m_Fullness);