Game.Companies.LodgingProvider
Assembly: Game (inferred from project folder)
Namespace: Game.Companies
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary: LodgingProvider is an ECS component that represents a lodging (hotel/inn) provider's runtime state for a company. It stores the number of free rooms available and the current price. The struct implements Colossal.Serialization.Entities.ISerializable so its state can be written to and read from the game's save/serialization system. This component is intended to be attached to entities representing lodging providers and used by systems that manage lodging availability, pricing, and persistence.
Fields
-
public int m_FreeRooms
Holds the current number of free rooms available at the lodging provider. Used by game logic to allocate rooms to citizens and to display availability in UI. -
public int m_Price
Current price per room (units depend on game economy). Used by game logic for transaction calculations and by UI or AI to evaluate lodging costs.
Properties
- None. This struct exposes plain public fields and does not declare any C# properties.
Constructors
public LodgingProvider()
Default value-type constructor (implicit). Fields default to 0. Typically instances are created with an object initializer to set meaningful values before being added to an entity.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Serializes the component state into the provided writer. The implementation writes m_FreeRooms followed by m_Price as integers. This method is called by the game's serialization pipeline when saving component data. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Deserializes the component state from the provided reader. The implementation reads integers into m_FreeRooms and m_Price in the same order they were written. This is used when loading saved games or otherwise reconstructing component state from serialized data.
Usage Example
// Create and assign a LodgingProvider to an existing entity using Unity.Entities APIs
var lodging = new Game.Companies.LodgingProvider {
m_FreeRooms = 12,
m_Price = 180
};
EntityManager.SetComponentData(entity, lodging);
// In a system, read/modify the component:
var current = EntityManager.GetComponentData<Game.Companies.LodgingProvider>(entity);
if (current.m_FreeRooms > 0) {
current.m_FreeRooms -= 1; // allocate a room
EntityManager.SetComponentData(entity, current);
}