Skip to content

Game.Prefabs.RenterObject

Assembly: Assembly-CSharp (typical Unity project assembly)
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
RenterObject is a prefab authoring component used to declare occupant-related requirements for an object prefab. It exposes boolean flags (m_Require*) that control which ObjectRequirementElement entries are added to the entity's ObjectRequirementElement dynamic buffer during conversion/initialization. These entries encode required or excluded attributes (via ObjectRequirementFlags) and are used by the game systems that match objects to citizens (renters) or other population groups.


Fields

  • public bool m_RequireEmpty
    Controls whether the "empty" requirement flag is set in the second flags parameter passed to ObjectRequirementElement. When true, objectRequirementFlags2 gets the Renter flag (see LateInitialize).

  • public bool m_RequireRenter
    When true, adds the Renter bit to the main object requirement flags (objectRequirementFlags). Indicates the object requires a renter.

  • public bool m_RequireGoodWealth
    When true, adds the GoodWealth bit to objectRequirementFlags. Indicates the object requires occupants of good wealth.

  • public bool m_RequireDogs
    When true, adds the Dogs bit to objectRequirementFlags. Indicates the object requires occupants that have dogs.

  • public bool m_RequireHomeless
    When true, adds the Homeless bit to objectRequirementFlags. Indicates the object should match homeless occupants.

  • public bool m_RequireChildren
    When true, adds a variant requirement entry that includes the Children bit in objectRequirementFlags (in addition to other flags). Used to create a children-specific requirement entry.

  • public bool m_RequireTeens
    When true, adds a variant requirement entry that includes the Teens bit in objectRequirementFlags (in addition to other flags). Used to create a teens-specific requirement entry.

Properties

  • (none declared on this class)

Constructors

  • public RenterObject()
    Default CLR constructor generated by the compiler. Instances are normally configured in the Unity editor (inspector) by toggling the public boolean fields to control requirements.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the required component types for the prefab. This implementation ensures ObjectRequirementElement is present for read/write by adding ComponentType.ReadWrite() to the provided set. This signals the conversion system that the prefab needs a dynamic buffer of ObjectRequirementElement on the entity.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    No archetype components are added by this component (method intentionally empty).

  • public override void LateInitialize(EntityManager entityManager, Entity entity)
    Populates the entity's DynamicBuffer with one or more ObjectRequirementElement entries based on the boolean flags on this component.

Behavior details: - Reads the existing buffer length (used as the last constructor parameter for ObjectRequirementElement). - Builds two flag bitmasks: - objectRequirementFlags: accumulates required flags (Renter, GoodWealth, Dogs, Homeless) based on corresponding booleans. - objectRequirementFlags2: currently used to capture the "empty" requirement; if m_RequireEmpty is true it sets the Renter bit on this mask. - Adds one default ObjectRequirementElement with (objectRequirementFlags, objectRequirementFlags2, length) when neither m_RequireChildren nor m_RequireTeens are set. - If m_RequireChildren is true, adds an entry with objectRequirementFlags | Children. - If m_RequireTeens is true, adds an entry with objectRequirementFlags | Teens. - Each added ObjectRequirementElement uses the pre-add buffer length as the third parameter, which can be used by downstream systems to identify the origin/index.

Usage Example

// Typical usage: configure the RenterObject component on a prefab in the Unity inspector
// by toggling the public m_Require* booleans. During entity conversion / initialization,
// LateInitialize will populate the ObjectRequirementElement dynamic buffer accordingly.

// Example: subclassing to extend behavior (optional)
public class MySpecialRenterObject : RenterObject
{
    public override void LateInitialize(EntityManager entityManager, Entity entity)
    {
        // Keep base behavior (populate requirement elements)
        base.LateInitialize(entityManager, entity);

        // Add custom logic here, e.g. additional buffer entries or metadata
    }
}

Notes and related types: - Depends on ObjectRequirementElement and ObjectRequirementFlags (enum) to encode requirements. - Interacts with Unity.Entities types: EntityManager, Entity, DynamicBuffer, ComponentType. - The component is intended for prefab authoring and conversion; booleans are typically set in the Unity editor inspector.