Skip to content

Game.Net.SubNet

Assembly: Assembly-CSharp
Namespace: Game.Net

Type: struct

Base: System.ValueType, Unity.Entities.IBufferElementData, System.IEquatable, Colossal.Serialization.Entities.IEmptySerializable

Summary:
Represents a single subnet entry stored in an ECS dynamic buffer. This struct wraps a Unity.Entities.Entity that points to a subnet entity. It's intended to be used as a buffer element (DynamicBuffer) on other entities to reference one or more subnet entities. The struct implements IEquatable for value comparisons and IEmptySerializable to participate in the game's custom serialization.


Fields

  • public Unity.Entities.Entity m_SubNet
    Holds the Entity reference for the subnet. This is the value used for equality and hashing.

  • Attribute: [InternalBufferCapacity(0)] (applied to the struct)
    Indicates the internal buffer inline capacity is 0, meaning the dynamic buffer will not reserve inline storage in the entity and will use heap storage immediately. This attribute affects the default memory layout/optimizations of the buffer.

Properties

  • This type declares no C# properties. It exposes the subnet entity via the public field m_SubNet.

Constructors

  • public SubNet(Unity.Entities.Entity subNet)
    Initializes a new SubNet instance with the provided subnet entity.

Methods

  • public bool Equals(SubNet other)
    Compares this instance with another SubNet for equality by comparing the underlying Entity (m_SubNet). Used to implement IEquatable.

  • public override int GetHashCode()
    Returns the hash code of the underlying Entity (m_SubNet). Used for hashing collections and to match the Equals implementation.

Usage Example

// Add a subnet entity reference to an entity's DynamicBuffer<SubNet>
var subNetEntity = /* obtain or create a subnet entity */;
var hostEntity = /* entity that should reference the subnet */;

var em = World.DefaultGameObjectInjectionWorld.EntityManager;
var buffer = em.GetBuffer<Game.Net.SubNet>(hostEntity);
buffer.Add(new Game.Net.SubNet(subNetEntity));

// Check if a buffer contains a specific subnet
bool contains = false;
foreach (var entry in buffer)
{
    if (entry.Equals(new Game.Net.SubNet(subNetEntity)))
    {
        contains = true;
        break;
    }
}

Notes and tips: - Because SubNet is an IBufferElementData, use DynamicBuffer APIs to read/write instances. - The struct uses the Entity field directly for equality and hashing; two SubNet instances are equal iff their m_SubNet Entities are equal. - The IEmptySerializable interface and the Colossal.Serialization.Entities namespace indicate this type participates in the game's custom serialization system; ensure compatible serialization handling when creating custom save/load logic.