Game.Net.ResourceConnection
Assembly: Assembly-CSharp.dll
Namespace: Game.Net
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary: A small ECS component used to represent a two-integer "flow" value for a resource connection in the game's entity system. It is serializable so that the flow data can be saved/loaded or sent over the network. The interpretation of the two components of the int2 depends on the surrounding systems (e.g., they could represent directional amounts, incoming/outgoing values, or X/Y grid flow).
Fields
public Unity.Mathematics.int2 m_Flow
Holds the two-component integer flow value for the resource connection. Commonly used to store a pair of flow-related values (the exact semantic meaning is defined by the systems that read/write this component). This field is written during serialization and read during deserialization.
Properties
- None. This struct exposes a single public field and does not define properties.
Constructors
- Implicit default constructor (parameterless) Struct has no explicit constructors declared; the default value-initialized constructor is used (m_Flow defaults to int2(0,0)).
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Serializes this component into the provided writer. Implementation writes the m_Flow field: writer.Write(m_Flow); -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Deserializes this component from the provided reader. Implementation reads into the m_Flow field: reader.Read(out m_Flow);
Both methods are generic and constrained to writer/reader interfaces used by the game's serialization system, enabling integration with the engine's save/load or network serialization pipeline.
Usage Example
using Unity.Entities;
using Unity.Mathematics;
using Game.Net;
// create an entity and attach a ResourceConnection component
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity e = em.CreateEntity(typeof(ResourceConnection));
// set a flow value (semantics depend on the consuming systems)
em.SetComponentData(e, new ResourceConnection { m_Flow = new int2(5, -3) });
// manual serialization example (pseudo-code, depends on actual IWriter/IReader implementations)
var writer = /* obtain IWriter from serialization system */;
var rc = em.GetComponentData<ResourceConnection>(e);
rc.Serialize(writer);
// and deserialization
var reader = /* obtain IReader from serialization system */;
ResourceConnection rc2 = new ResourceConnection();
rc2.Deserialize(reader);
em.SetComponentData(e, rc2);