Game.Buildings.Renter
Assembly: Assembly-CSharp
Namespace: Game.Buildings
Type: struct
Base: IBufferElementData, IEmptySerializable
Summary:
Renter is a lightweight ECS buffer element used to store a reference to an Entity that represents a renter (e.g., a citizen or occupant) associated with another entity such as a building. It implements IBufferElementData so it can be stored in a DynamicBuffer
Fields
-
public Entity m_Renter
Holds the Entity reference for the renter. This is the payload of the buffer element; when stored in a DynamicBuffereach element represents one renter Entity associated with the owner entity (for example, a building's list of tenants). -
// (no other fields)
The struct is intentionally minimal to keep buffer memory footprint small and to be compatible with the game's serialization approach (IEmptySerializable).
Properties
- (none)
This struct exposes no properties. The Entity can be accessed directly via the m_Renter field or via the implicit conversion operator.
Constructors
- (default)
public Renter()
No explicit constructors are defined. The default parameterless constructor is used by ECS when creating buffer elements.
Methods
public static implicit operator Entity(Renter renter)
Implicit conversion operator that returns renter.m_Renter. This allows code to use a Renter instance where an Entity is expected, which can make buffer access code more concise: Example: Entity e = buffer[i]; // buffer[i] is Renter but implicitly converted to Entity.
Usage Example
// Add a DynamicBuffer<Renter> to a building entity and add a renter Entity.
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity buildingEntity = /* obtain building entity */;
Entity renterEntity = /* obtain renter entity to associate */;
// Ensure the building has a buffer of Renter elements
if (!em.HasComponent<Renter>(buildingEntity))
{
em.AddBuffer<Renter>(buildingEntity);
}
DynamicBuffer<Game.Buildings.Renter> renters = em.GetBuffer<Game.Buildings.Renter>(buildingEntity);
// Add a renter
renters.Add(new Game.Buildings.Renter { m_Renter = renterEntity });
// Retrieve the first renter via implicit conversion
Entity firstRenter = renters[0]; // Renter -> implicit Entity conversion
// Or read the field explicitly
Entity sameRenter = renters[0].m_Renter;
Additional notes: - Assembly name is commonly Assembly-CSharp for Cities: Skylines 2 mods; verify in your project if different. - Because Renter implements IBufferElementData, it can be used with EntityManager/GetBuffer, AddBuffer, and DynamicBuffer APIs. - IEmptySerializable marks the type for the game's custom serialization; the struct remains minimal to avoid extra serialized state.