Skip to content

Game.SpawnLocationElement

Assembly: Assembly-CSharp
Namespace: Game.Buildings

Type: struct

Base: System.ValueType

Summary:
Buffer element used by the ECS to store a reference to a spawn location entity together with its SpawnLocationType. Marked with InternalBufferCapacity(0) so no inline storage is reserved on the entity; intended for use as a dynamic buffer element (IBufferElementData). Equality and hash-code are based on the referenced Entity (m_SpawnLocation), so two elements are considered equal when they point to the same spawn location Entity. Implements IEmptySerializable for Colossal.Serialization compatibility.


Fields

  • public Entity m_SpawnLocation
    Holds the Entity that represents the spawn location. This is used to identify the actual location object in the ECS world.

  • public SpawnLocationType m_Type
    Enum value describing the kind of spawn location (e.g., vehicle spawn, pedestrian spawn, etc.). The exact values are defined in the SpawnLocationType enum elsewhere in the codebase.

Properties

  • None.
    This struct exposes only public fields and does not declare any properties.

Constructors

  • public SpawnLocationElement(Entity spawnLocation, SpawnLocationType type)
    Creates a new SpawnLocationElement populated with the provided Entity and spawn-location type.

Methods

  • public bool Equals(SpawnLocationElement other) : System.Boolean
    Compares this element to another based on the m_SpawnLocation Entity. Returns true if both reference the same Entity.

  • public override int GetHashCode() : System.Int32
    Returns the hash code of the m_SpawnLocation Entity. Useful when using elements in hash-based collections.

Usage Example

// Example: add a spawn location element to an entity's dynamic buffer
// (inside a System or other code with access to an EntityManager)
Entity spawnEntity = /* resolved spawn location entity */;
SpawnLocationType type = SpawnLocationType.Vehicle; // example enum value
Entity buildingEntity = /* the entity that should hold the buffer */;

var buffer = EntityManager.GetBuffer<SpawnLocationElement>(buildingEntity);
buffer.Add(new SpawnLocationElement(spawnEntity, type));

// Comparing two buffer elements
var a = new SpawnLocationElement(spawnEntity, type);
var b = new SpawnLocationElement(spawnEntity, SpawnLocationType.Pedestrian);
bool same = a.Equals(b); // true because m_SpawnLocation is the same