Game.Net.Gate
Assembly: Game
Namespace: Game.Net
Type: struct
Base: System.ValueType
Implements: IComponentData, IQueryTypeParameter, IEmptySerializable
Summary:
Gate is a small ECS component type used to reference a "domain" entity from another entity. It is intended for use with Unity's DOTS/ECS systems inside Cities: Skylines 2 mod code and is marked so it can participate in Colossal's serialization pipeline and be used in query type parameters. The component holds a single Entity handle that links a gate entity to its corresponding domain entity. Use this to associate entities that represent network/connection gates with their domain object in other systems.
Fields
public Unity.Entities.Entity m_Domain
Stores the Entity handle of the domain associated with this gate. This is an ECS Entity value (may be Entity.Null when not set). Use EntityManager or Entity queries to resolve and operate on the referenced domain entity. Do not assume the referenced entity remains valid; check for Entity.Null and lifecycle changes.
Properties
- None
Constructors
- Default struct constructor (implicit)
The implicit parameterless constructor initializes m_Domain to the default Entity value (typically Entity.Null). You can create an instance with an initializer:new Gate { m_Domain = domainEntity }
.
Methods
- None (plain data component)
Usage Example
using Unity.Entities;
using Game.Net;
public partial class GateExampleSystem : SystemBase
{
protected override void OnUpdate()
{
var em = EntityManager;
// Create a domain entity (example)
Entity domainEntity = em.CreateEntity();
// ... initialize domainEntity as needed ...
// Create a gate entity and attach a Gate component referencing the domain
Entity gateEntity = em.CreateEntity();
em.AddComponentData(gateEntity, new Gate { m_Domain = domainEntity });
// Querying Gate components
Entities
.ForEach((ref Gate gate) =>
{
if (gate.m_Domain != Entity.Null)
{
// operate on gate.m_Domain
}
})
.Schedule();
}
}
Notes: - Treat m_Domain as an entity reference (handle). Verify it is not Entity.Null before using it. - Gate implements IQueryTypeParameter to allow its use in certain query constructs and IEmptySerializable to participate in the game's serialization conventions; the exact serialization behavior is governed by the Colossal.Serialization framework used by the game.