Game.Net.NetCondition
Assembly:
Assembly-CSharp (game code / modding runtime)
Namespace: Game.Net
Type: struct
Base:
System.ValueType
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.ISerializable
Summary: NetCondition is a small ECS component used to store "wear" data for a network object (road/tile/segment) in the game's entity-component system. It holds a Unity.Mathematics.float2 value and implements the game's serialization interfaces so it can be saved/loaded with the entity. Because it implements IComponentData it is intended to be attached to Entities and used inside DOTS systems (jobs/systems) or read/written by game code and serialization subsystems.
Fields
public Unity.Mathematics.float2 m_Wear
Stores the wear values as a two-component float vector. The semantic meaning of the two components is determined by the game (for example, it may represent different wear axes or two accumulators). Use Unity.Mathematics.float2 to manipulate components in jobs and systems.
Properties
- This type declares no properties. It exposes its data via the public field m_Wear.
Constructors
public NetCondition()
Implicit default value-type constructor. You can construct it with an object initializer, for example: new NetCondition { m_Wear = new float2(0f, 0f) };
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the m_Wear field to the provided writer. The implementation calls writer.Write(m_Wear), delegating the actual serialization format to the writer implementation used by the game. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the m_Wear field from the provided reader. The implementation calls reader.Read(out m_Wear), restoring the stored float2 value during deserialization.
Notes: - Because this struct implements Colossal.Serialization.Entities.ISerializable, the game's entity serialization system will invoke these methods to persist/restore the component state. - As an IComponentData, you can use this type with EntityManager.AddComponentData / GetComponentData / SetComponentData or with Entities.ForEach and jobified systems.
Usage Example
using Unity.Mathematics;
using Unity.Entities;
using Game.Net;
// create an instance and attach to an entity
var netCondition = new NetCondition { m_Wear = new float2(0.25f, 0.0f) };
// assuming entityManager and entity are available
entityManager.AddComponentData(entity, netCondition);
// read and modify later in a system or job (example in a system)
var cond = entityManager.GetComponentData<NetCondition>(entity);
cond.m_Wear.x += 0.1f; // adjust wear
entityManager.SetComponentData(entity, cond);
// Serialization is handled by the game's writer/reader; example signatures:
void SaveExample<TWriter>(TWriter writer, NetCondition c) where TWriter : Colossal.Serialization.Entities.IWriter
{
c.Serialize(writer); // writer.Write(c.m_Wear) is called internally
}
void LoadExample<TReader>(TReader reader, out NetCondition c) where TReader : Colossal.Serialization.Entities.IReader
{
c = new NetCondition();
c.Deserialize(reader); // reader.Read(out c.m_Wear) is called internally
}