Skip to content

Game.Fixed

Assembly: Assembly-CSharp
Namespace: Game.Net

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary: Represents a small, network-serializable component used by the game's net layer. The struct contains a single integer index (m_Index) and implements Colossal.Serialization.Entities.ISerializable so it can be written to/read from network or persistence writers/readers. It also implements Unity.Entities.IComponentData so it can be attached to ECS entities and IQueryTypeParameter for use in queries.


Fields

  • public System.Int32 m_Index This integer holds the index value represented by this component. It is the single data payload for the struct and is written/read by the Serialize/Deserialize implementations. Default value is 0 when using the implicit parameterless constructor.

Properties

  • None. This type exposes its data as a public field rather than properties.

Constructors

  • Implicit parameterless constructor The struct relies on the default parameterless constructor provided by C#. There is no explicit constructor defined in the source. Initialize m_Index directly or via assignment when adding the component.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter Writes the m_Index value to the provided writer. The writer type must implement Colossal.Serialization.Entities.IWriter. This method is used to serialize the component for network or persistence operations.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader Reads an integer from the provided reader into m_Index. The reader type must implement Colossal.Serialization.Entities.IReader. This method is used to restore component state from serialized data.

Usage Example

// Create and add the component to an entity (Unity.Entities context)
var component = new Game.Net.Fixed { m_Index = 42 };
entityManager.AddComponentData(entity, component);

// Serialize example (writer must implement IWriter)
var writer = /* obtain an IWriter implementation */;
component.Serialize(writer);

// Deserialize example (reader must implement IReader)
var reader = /* obtain an IReader implementation */;
var deserialized = new Game.Net.Fixed();
deserialized.Deserialize(reader);
// deserialized.m_Index now contains the read value

{{ Additional notes: - This struct is lightweight and intended for fast ECS/network usage. - Because it uses a public field, there are no property accessors; modify m_Index directly. - Ensure the writer/reader implementations used match the serialization protocol expected by the receiver. }}