Game.Citizens.HomelessHousehold
Assembly:
(assembly not specified — likely part of the game core or mod assembly for Cities: Skylines 2)
Namespace:
Game.Citizens
Type:
struct
Base:
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.ISerializable
Summary:
HomelessHousehold is a small ECS component struct used to mark a citizen/household entity as currently homeless and to store an Entity reference to a temporary home (m_TempHome). It supports the game's serialization system so the temporary-home reference can be saved/loaded. Use this component when you need to track a household that does not have a permanent residence but has a temporary shelter entity assigned.
Fields
public Unity.Entities.Entity m_TempHome
Holds an Entity reference to the household's temporary home/shelter. This can be Entity.Null when no temporary home is assigned. This field is written and read by the component's Serialize/Deserialize methods for persistence.
Properties
- None.
(This struct exposes its data via the public field m_TempHome rather than properties.)
Constructors
- Implicit default constructor (value-type)
As a C# struct, HomelessHousehold has the implicit parameterless constructor that initializes m_TempHome to Entity.Null by default.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the m_TempHome Entity reference to the provided writer. This method is used by the game's serialization pipeline to save the component state. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the m_TempHome Entity reference from the provided reader. This method is used by the game's serialization pipeline to restore the component state when loading.
Notes: - The generic constraints ensure the methods work with the engine's IWriter/IReader abstractions from Colossal.Serialization.Entities. - The methods simply delegate to writer.Write(m_TempHome) and reader.Read(out m_TempHome); no extra validation is performed here.
Usage Example
// Add or update the HomelessHousehold component on an entity
var tempHome = /* obtain Entity for temporary shelter */;
var householdEntity = /* entity id for the household */;
// Creating the component and setting the temporary home
var homeless = new HomelessHousehold { m_TempHome = tempHome };
// Using an EntityManager to add or set the component
if (!entityManager.HasComponent<HomelessHousehold>(householdEntity))
{
entityManager.AddComponentData(householdEntity, homeless);
}
else
{
entityManager.SetComponentData(householdEntity, homeless);
}
// Reading the temporary home later
var current = entityManager.GetComponentData<HomelessHousehold>(householdEntity);
Unity.Entities.Entity assignedTempHome = current.m_TempHome;
// During save/load, the engine will call Serialize/Deserialize to persist m_TempHome.
{{ Additional information: - Typical use-case: track households that have been displaced (e.g., by disasters or policy changes) and assigned a temporary shelter entity. - Because this is a plain IComponentData, it is cheap to store on many entities and works with Unity.Entities queries and jobs. - When working with networked or cross-scene systems ensure the referenced Entity is valid in the same world/context when deserializing. }}