Skip to content

Game.Prefabs.HouseholdData

Assembly: Assembly-CSharp (typical for game code / mods)
Namespace: Game.Prefabs

Type: struct

Base: System.ValueType, IComponentData, IQueryTypeParameter

Summary:
HouseholdData is a small, blittable ECS component that describes template/default values for a household prefab. It encodes initial wealth parameters, probabilities related to vehicle and pet ownership, counts of members by age/role, and a selection weight used when spawning or choosing household templates. This component is intended to be attached to household prefab entities or used in spawn/configuration systems to create concrete household instances.


Fields

  • public int m_InitialWealthRange
    Range applied to initial household wealth (random variation). Combined with m_InitialWealthOffset to compute starting wealth.

  • public int m_InitialWealthOffset
    Base/offset value used when computing a household's starting wealth.

  • public int m_InitialCarProbability
    Probability (typically expressed as an integer percentage or game-defined probability unit) that the household starts with a car.

  • public int m_ChildCount
    Number of children in the household template.

  • public int m_AdultCount
    Number of adults in the household template.

  • public int m_ElderCount
    Number of elders in the household template.

  • public int m_StudentCount
    Number of students in the household template.

  • public int m_FirstPetProbability
    Probability that the household has the first pet.

  • public int m_NextPetProbability
    Probability for each subsequent pet (used when deciding multiple pets).

  • public int m_Weight
    Selection weight for this household template when the game chooses which household type to spawn; higher means more likely.

Properties

  • This struct exposes no C# properties — it contains only public fields. It is used as a plain data component (IComponentData) and as an IQueryTypeParameter for ECS queries.

Constructors

  • public HouseholdData()
    No explicit constructors are defined in the source; this is a plain C# struct so a default parameterless constructor exists and will initialize all integer fields to 0. You can initialize with an object initializer when creating instances.

Methods

  • None. This is a data-only component with no behavior methods.

Usage Example

// Example: creating and assigning a HouseholdData component to an entity (EntityManager API)
var householdTemplate = new Game.Prefabs.HouseholdData {
    m_InitialWealthRange = 2000,
    m_InitialWealthOffset = 5000,
    m_InitialCarProbability = 75, // 75%
    m_ChildCount = 1,
    m_AdultCount = 2,
    m_ElderCount = 0,
    m_StudentCount = 0,
    m_FirstPetProbability = 40,
    m_NextPetProbability = 20,
    m_Weight = 10
};

Entity prefabEntity = /* obtain or create prefab entity */;
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

// Add or set the component on the prefab/entity
if (!entityManager.HasComponent<Game.Prefabs.HouseholdData>(prefabEntity))
{
    entityManager.AddComponentData(prefabEntity, householdTemplate);
}
else
{
    entityManager.SetComponentData(prefabEntity, householdTemplate);
}

Notes: - Because HouseholdData implements IComponentData, it is safe to use in jobs and high-performance ECS systems (blittable value type). - m_Weight and the various probability fields are typically interpreted by the game's spawning/configuration systems; consult those systems for exact units (percent vs. per-mille) and weighting behavior.