Skip to content

Game.Citizens.LookingForPartner

Assembly: Assembly-CSharp.dll (typical Cities: Skylines 2 / Unity game assembly)
Namespace: Game.Citizens

Type: public struct

Base: System.ValueType, Unity.Entities.IBufferElementData, Colossal.Serialization.Entities.ISerializable

Summary: A buffer element used by the game's ECS to represent a citizen entry that is "looking for a partner". This struct stores a reference to another citizen Entity and the type of partner being sought. It implements IBufferElementData so it can be stored in an Entity's DynamicBuffer, and ISerializable so it can be saved/loaded using Colossal's serialization system.


Fields

  • public Unity.Entities.Entity m_Citizen Holds the Entity identifier of the citizen that is being referred to as the partner (the candidate or matched partner). When stored in a DynamicBuffer this field references the other citizen Entity.

  • public PartnerType m_PartnerType An enum value (PartnerType) describing the kind of partner relation (for example spouse, romantic partner, etc.). During serialization this enum is written/read as an int.

Properties

  • This struct exposes no properties. The data is accessed directly via the public fields m_Citizen and m_PartnerType.

Constructors

  • public LookingForPartner() The default parameterless struct constructor is used. Fields default to default(Entity) (an invalid/null entity) and the default enum value for PartnerType. Typical usage is to explicitly assign the fields after constructing a new instance.

Methods

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader Implements ISerializable.Deserialize. Reads the stored state in the same order it was written by Serialize:
  • Reads an Entity into m_Citizen.
  • Reads an int and casts it to PartnerType to populate m_PartnerType. The method uses a ref local for m_Citizen to allow the reader to write directly into the field.

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter Implements ISerializable.Serialize. Writes the struct state in a deterministic order:

  • Writes m_Citizen (Entity).
  • Writes m_PartnerType as an int (casts the enum to int). This ensures the matching Deserialize can restore the same values.

Usage Example

// Add a LookingForPartner element to an entity's buffer (ECS style)
EntityBuffer<LookingForPartner> buffer = entityManager.GetBuffer<LookingForPartner>(someEntity);
LookingForPartner entry = new LookingForPartner {
    m_Citizen = targetCitizenEntity,
    m_PartnerType = PartnerType.Spouse
};
buffer.Add(entry);

// The struct will be serialized by the game's ISerializable-aware serialization system.
// If you need to manually construct or inspect values:
var lp = new LookingForPartner();
lp.m_Citizen = someOtherEntity;
lp.m_PartnerType = PartnerType.Romantic;

Notes: - Ensure that the PartnerType enum definition is available in your mod/context. - Because this type implements ISerializable, it will be preserved across save/load when used in entities that are serialized by the game's save system.