Game.Net.Curve
Assembly: Assembly-CSharp
Namespace: Game.Net
Type: struct
Base: IComponentData, IQueryTypeParameter, IStrideSerializable, ISerializable
Summary: Represents a network curve (Bezier) used by the game's networking/segment systems. The struct stores a Bezier4x3 describing the cubic Bezier curve and a cached length (m_Length). The Bezier control points are serialized; the length is computed during deserialization using MathUtils.Length. This type is an ECS component (IComponentData) and supports Colossal's custom serialization and stride queries.
Fields
-
public Bezier4x3 m_Bezier
Stores the cubic Bezier curve control points (4 control points, each a float3). This is the data that gets serialized by Serialize. -
public float m_Length
Cached length of the curve. It is not written by Serialize; it gets computed in Deserialize via MathUtils.Length(m_Bezier). If you construct a Curve manually and need m_Length available, compute and set it (e.g., m_Length = MathUtils.Length(m_Bezier)).
Properties
- This type does not declare any properties.
Constructors
public Curve()
Default value-type constructor (auto-generated). When deserialized via IReader, m_Bezier is read from the stream and m_Length is computed; if you construct manually, remember to compute m_Length if needed.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the Bezier data to the provided writer. Only m_Bezier is written — m_Length is intentionally omitted (it is recomputed on read). -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads m_Bezier from the reader and then computes m_Length using MathUtils.Length(m_Bezier). After Deserialize returns, m_Length holds the length corresponding to the deserialized Bezier. -
public int GetStride(Context context)
Returns the stride used for this serializable type. Implementation returns UnsafeUtility.SizeOf(), i.e., the size of a float3 (typically 12 bytes). This indicates the per-element stride expected by the serialization/stride system (useful for low-level native buffers). The Context parameter is present to satisfy the signature but is not inspected by this implementation.
Usage Example
// Create a curve and add it as an ECS component
var bezier = new Bezier4x3
{
// assign control points (example)
a = new float3(0f, 0f, 0f),
b = new float3(1f, 0f, 0f),
c = new float3(2f, 0f, 0f),
d = new float3(3f, 0f, 0f)
};
var curve = new Curve
{
m_Bezier = bezier,
m_Length = MathUtils.Length(bezier) // compute cached length if constructing manually
};
// Using EntityManager to add component
// entityManager.AddComponentData(entity, curve);
// Example of runtime deserialization (pseudo-code):
// reader.Read(out curve.m_Bezier);
// curve.m_Length = MathUtils.Length(curve.m_Bezier);
// Note: Serialize writes only m_Bezier; Deserialize reads m_Bezier and recomputes m_Length.
{{ Additional notes: - This struct is blittable and suitable as an ECS component. - Be aware that GetStride returns the size of float3; depending on platform/packing, padding considerations may apply when interoperating with native code. - Because m_Length is not serialized, code that constructs Curve instances programmatically should compute and set m_Length if consumers expect a valid cached length. }}