Game.Buildings.Patient
Assembly: Assembly-CSharp
Namespace: Game.Buildings
Type: struct (value type) — implements Unity.Entities.IBufferElementData, System.IEquatable
Base: System.ValueType
Summary:
Represents a buffer element that holds a reference to an ECS Entity considered a "patient" for building-related systems. Intended to be stored in a DynamicBuffer
Fields
public Unity.Entities.Entity m_Patient
Holds the reference to the patient Entity. Used by Equals/GetHashCode and read/written by Serialize/Deserialize. Public so buffer element consumers and ECS systems can read/write it directly.
Properties
- This type exposes no properties. It is a plain buffer element struct with a single public field.
Constructors
public Patient(Unity.Entities.Entity patient)
Initializes the Patient buffer element with the given Entity (assigns to m_Patient). Use this when adding entries to a DynamicBuffer.
Methods
-
public bool Equals(Patient other)
Compares this instance to another Patient by delegating to Entity.Equals on m_Patient. Returns true when both refer to the same Entity. -
public override int GetHashCode()
Returns the hash code of the underlying Entity (m_Patient.GetHashCode()). Useful when Patient is used in hash-based collections or comparisons. -
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the contained Entity to the provided writer. Conforms to Colossal.Serialization's ISerializable pattern so buffers containing Patient can be serialized. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the Entity value back from the provided reader into m_Patient. Complements Serialize for deserialization of saved data.
Usage Example
// Add a patient Entity to a building's patient buffer
var patientEntity = /* some existing Entity representing an individual */;
var hospitalEntity = /* the Entity representing the hospital/building */;
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var buffer = entityManager.GetBuffer<Patient>(hospitalEntity);
buffer.Add(new Patient(patientEntity));
// During save/load the Serialize/Deserialize methods will be invoked by the game's serializer.