Game.Net.SubNet
Assembly: Assembly-CSharp
Namespace: Game.Net
Type: struct
Base: System.ValueType, Unity.Entities.IBufferElementData, System.IEquatable
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
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