Skip to content

Game.Net.OutsideConnection

Assembly: Assembly-CSharp
Namespace: Game.Net

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents a small ECS component used by the game to store a delay value for "outside" connections. Implemented as a Unity.Entities component (IComponentData) and supports serialization via the generic ISerializable pattern so it can be saved/loaded or transferred. Commonly used to mark entities that represent connections to the outside map/traffic and to carry a single float delay value.


Fields

  • public float m_Delay
    This single field stores the delay value for the outside connection (float). Typical semantics: time delay in seconds (or game-time units) used by systems handling outside connections. Default value for a struct instance is 0.0f if not explicitly set.

Properties

  • None.
    This struct exposes only the public field m_Delay and does not define any properties.

Constructors

  • Implicit default constructor (value-initialized)
    Being a C# struct, OutsideConnection has an implicit parameterless constructor that initializes m_Delay to 0. Use object initializer syntax to create instances with a specific delay:
var conn = new OutsideConnection { m_Delay = 1.5f };

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the m_Delay value to the provided writer. Used by the game's serialization pipeline to persist the component state.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the m_Delay value from the provided reader into the component. Used when loading or receiving serialized component data.

Notes: - Both methods use generic writer/reader interfaces (IWriter/IReader) so the same code works with different serialization backends. - The methods operate only on the single float field, making serialization straightforward and low-overhead.

Usage Example

// Create and add the component to an entity (EntityManager usage)
var outsideConn = new OutsideConnection { m_Delay = 2.0f };
entityManager.AddComponentData(someEntity, outsideConn);

// Manual serialization example (conceptual):
// Assuming writer implements IWriter
outsideConn.Serialize(writer);

// And later, to deserialize:
var loaded = new OutsideConnection();
loaded.Deserialize(reader);
entityManager.SetComponentData(someEntity, loaded);

Additional tips: - Because this is an IComponentData struct, prefer using EntityManager or Systems (AddComponentData/SetComponentData) to manipulate it in ECS contexts. - The small size and simple serialization make this safe for frequent use in performance-sensitive systems.