Game.Areas.SubArea
Assembly: Assembly-CSharp
Namespace: Game.Areas
Type: struct
Base: System.ValueType, Unity.Entities.IBufferElementData, System.IEquatable
Summary:
Represents a buffer element that holds a reference to an area Entity. Used with Unity DOTS/ECS DynamicBuffer as a way to store sub-area references for an entity. The struct is marked with InternalBufferCapacity(0) (no inlined buffer capacity) and implements IEmptySerializable so it can participate in Colossal.Serialization for Cities: Skylines 2 mod data.
Fields
public Unity.Entities.Entity m_Area
Holds the Entity reference for the area associated with this sub-area entry. This is the primary payload of the buffer element.
Properties
- None. (This type exposes a public field rather than properties.)
Constructors
public SubArea(Unity.Entities.Entity area)
Initializes a SubArea with the provided Entity reference.
Methods
-
public bool Equals(SubArea other)
Compares this SubArea to another by comparing their m_Area Entity values (delegates to Entity.Equals). -
public override int GetHashCode()
Returns the hash code of the contained m_Area Entity (delegates to Entity.GetHashCode).
Usage Example
// Add a sub-area reference to an entity's DynamicBuffer<SubArea>
EntityManager entityManager = /* get your EntityManager */;
Entity subAreaOwner = /* the entity that owns the buffer */;
Entity areaEntity = /* the area Entity to reference */;
// Ensure the entity has a DynamicBuffer<SubArea> (AddBuffer if needed)
if (!entityManager.HasComponent<DynamicBuffer<SubArea>>(subAreaOwner))
{
entityManager.AddBuffer<SubArea>(subAreaOwner);
}
DynamicBuffer<SubArea> buffer = entityManager.GetBuffer<SubArea>(subAreaOwner);
buffer.Add(new SubArea(areaEntity));
// Iterate and check equality
foreach (var entry in buffer)
{
if (entry.Equals(new SubArea(areaEntity)))
{
// found matching area
}
}
Additional notes: - The [InternalBufferCapacity(0)] attribute means no elements are stored inline on the entity; buffer storage is allocated separately when elements are added. - Because this type implements IBufferElementData it is intended for use with Unity's ECS DynamicBuffer APIs. - IEmptySerializable is a marker used by Colossal.Serialization.Entities to allow (de)serialization of the struct within the game's serialization system.