Game.Net.Node
Assembly: Assembly-CSharp (typical for Cities: Skylines 2 game/mod assemblies)
Namespace: Game.Net
Type: struct
Base: IComponentData, IQueryTypeParameter, IStrideSerializable, ISerializable
Summary: A lightweight ECS component that represents a network/node transform: stores position (float3) and rotation (quaternion). Implements serialization interfaces so it can be written/read to network or other binary contexts and reports its memory stride for low-level serialization infrastructure.
Fields
-
public float3 m_Position
Holds the node's position in world space (Unity.Mathematics.float3). This field is serialized by Serialize/Deserialize and is the primary spatial coordinate for the Node component. -
public quaternion m_Rotation
Holds the node's orientation as a Unity.Mathematics.quaternion. Also serialized alongside m_Position to preserve full transform information.
Properties
- None.
This struct exposes public fields rather than properties and does not declare any auto-properties.
Constructors
- Implicit parameterless constructor (default)
No explicit constructor is defined in the source. The default struct constructor initializes m_Position and m_Rotation to their default values (zero vector and quaternion default).
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes m_Position then m_Rotation to the provided writer. Intended for binary/network serialization using the game's writer abstraction. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads values back into m_Position and m_Rotation from the provided reader. Uses out/ref to assign into the struct fields. -
public int GetStride(Context context)
Returns the byte stride required to store this type in a contiguous buffer: the sum of UnsafeUtility.SizeOf() and UnsafeUtility.SizeOf (). Used by low-level serialization/streaming systems that need fixed-size element sizes.
Usage Example
// Creating an entity with the Node component via the EntityManager (ECS)
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var nodeArchetype = entityManager.CreateArchetype(typeof(Game.Net.Node));
var entity = entityManager.CreateEntity(nodeArchetype);
// Set position and rotation
var node = new Game.Net.Node {
m_Position = new Unity.Mathematics.float3(100f, 0f, 200f),
m_Rotation = Unity.Mathematics.quaternion.identity
};
entityManager.SetComponentData(entity, node);
// Serializing a Node instance (hypothetical writer)
Game.Net.Node outNode = node;
IWriter writer = /* obtain writer from context */;
outNode.Serialize(writer);
// Deserializing into a Node instance (hypothetical reader)
IReader reader = /* obtain reader from context */;
Game.Net.Node inNode = default;
inNode.Deserialize(reader);
// Getting the stride for allocation/packing purposes
int stride = inNode.GetStride(new Context()); // Context as required by your serialization API
Notes:
- This struct is designed to be used with the Unity Entities/ECS workflow and the game's custom serialization stack (IWriter/IReader, Context).
- When using in networked or persisted contexts, ensure the writer/reader pair and Context match the expected format/version used by the game/mod.