Skip to content

Game.Buildings.PropertyRenter

Assembly:
Assembly-CSharp (game assembly)

Namespace:
Game.Buildings

Type:
struct

Base:
IComponentData, IQueryTypeParameter, ISerializable

Summary:
Component data that represents a renter relationship for a property/building. Stores a reference to the property Entity and the rent amount. Implements Colossal's ISerializable so it can be written to and read from saved data streams, and IQueryTypeParameter so it can be used as a query parameter in ECS queries.


Fields

  • public Entity m_Property
    Holds the Entity reference for the property (building) that this renter is associated with. This is the persisted link to the property entity when serializing/deserializing.

  • public int m_Rent
    The rent amount for the renter. Serialized/deserialized as an integer.

Properties

  • This type does not define any C# properties. It is a plain struct with public fields.

Constructors

  • public PropertyRenter()
    As a value type (struct) it has the implicit default constructor which initializes m_Property to default(Entity) and m_Rent to 0. No explicit constructors are defined in the source.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the component state to the provided writer. Order: writes the Entity (m_Property), then the rent (m_Rent). Uses Colossal.Serialization.Entities writer semantics.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the component state from the provided reader. It reads into m_Property then m_Rent. For compatibility with older save versions, it checks reader.context.version and if the saved version is older than Version.economyFix it reads and discards one extra integer (legacy data).

Notes on serialization compatibility: - The extra conditional read indicates that earlier formats contained an additional integer field that is no longer used; the code consumes that legacy value when loading older saves so subsequent reads remain aligned.

Usage Example

// Create and assign values
PropertyRenter renter = new PropertyRenter {
    m_Property = propertyEntity, // an Entity referring to the property/building
    m_Rent = 500
};

// Add the component to an entity using the EntityManager
entityManager.AddComponentData(renterEntity, renter);

// When saving/loading, the Serialize/Deserialize implementations
// will be used by the game's serialization system (IWriter/IReader).