Skip to content

Game.Buildings.ParkingFacility

Assembly:
Namespace: Game.Buildings

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary: Represents a parking facility component used by the game's ECS. Stores a comfort factor (float) and a set of flags describing the facility state. Implements ISerializable so instances can be written to and read from the game's binary serialization streams, and implements IQueryTypeParameter so it can be used in Unity.Entities queries.


Fields

  • public float m_ComfortFactor This float stores the comfort factor of the parking facility (e.g., how comfortable or attractive the parking is). It is serialized/deserialized in the same order as the flags.

  • public ParkingFacilityFlags m_Flags A flags enum describing the parking facility's state. In serialization it is written/read as a single byte (cast to/from byte).

Properties

  • (none)

Constructors

  • (none declared — uses default value-type constructor) Since this is a struct no explicit constructor is declared; instances can be created with default(T) or object initializer syntax.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter Writes the component data to a generic writer. Implementation writes the comfort factor (float) followed by the flags cast to a byte:
  • writer.Write(m_ComfortFactor);
  • writer.Write((byte)m_Flags);

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader Reads component data from a generic reader. Implementation reads into m_ComfortFactor and reads a byte which is cast back to ParkingFacilityFlags:

  • reader.Read(out m_ComfortFactor);
  • reader.Read(out byte value);
  • m_Flags = (ParkingFacilityFlags)value;

Behavior notes: - The flags are stored on disk/stream as a single byte; ensure the ParkingFacilityFlags enum values fit into a byte if you modify them. - The serialization order is important: comfort factor first, then flags.

Usage Example

// Create and add the component to an entity using Unity.Entities API
var parking = new ParkingFacility {
    m_ComfortFactor = 1.25f,
    m_Flags = ParkingFacilityFlags.Active // example enum value
};

EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity e = entityManager.CreateEntity(typeof(ParkingFacility));
entityManager.SetComponentData(e, parking);

// Example of how the serialization methods behave (conceptual usage)
void WriteComponent<TWriter>(TWriter writer, ParkingFacility pf) where TWriter : IWriter
{
    pf.Serialize(writer); // writes float then flags-as-byte
}

ParkingFacility ReadComponent<TReader>(TReader reader) where TReader : IReader
{
    ParkingFacility pf = default;
    pf.Deserialize(reader); // reads float then flags-as-byte
    return pf;
}