Skip to content

Game.Prefabs.MatchPieceVertices

Assembly:
Assembly-CSharp (Game) {{ commonly found in the game's main modding assembly; replace with your mod assembly if different }}

Namespace: Game.Prefabs

Type:
class MatchPieceVertices

Base:
ComponentBase

Summary:
A prefab component intended for net-piece prefabs that supplies per-vertex offset data to the ECS component NetVertexMatchData. When the prefab is converted to an entity, this component registers the NetVertexMatchData component for the prefab and writes up to three offset values (X, Y, Z) from its serialized m_Offsets float array into the entity's NetVertexMatchData.m_Offsets fields. If no offsets are provided the component data remains initialized with float.NaN values.


Fields

  • public float[] m_Offsets
    A serialized array of floats (typically length 0–3) representing per-axis offsets for a net vertex match. During Initialize, the first element (if present) is assigned to componentData.m_Offsets.x, the second to .y, and the third to .z. If m_Offsets is null or has fewer elements, the corresponding components are left as float.NaN (the code initializes the vector to NaN before assignment).

Properties

  • (none)

Constructors

  • public MatchPieceVertices()
    Default constructor (compiler-generated). The class relies on serialized field m_Offsets for configuration (no special construction logic).

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Registers required component types for the prefab conversion. This implementation adds ComponentType.ReadWrite() so that entities created from this prefab will include the NetVertexMatchData component and be writable at runtime.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    No archetype-level components are added here (method intentionally left empty). The prefab-level registration is handled in GetPrefabComponents.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called during prefab -> entity initialization. Behavior:

  • Calls base.Initialize(entityManager, entity).
  • Prepares a NetVertexMatchData instance and initializes its m_Offsets to float.NaN.
  • If this.m_Offsets is non-null, assigns up to three values:
    • m_Offsets[0] -> componentData.m_Offsets.x
    • m_Offsets[1] -> componentData.m_Offsets.y
    • m_Offsets[2] -> componentData.m_Offsets.z
  • Writes the prepared NetVertexMatchData into the entity using entityManager.SetComponentData(entity, componentData).

Notes: - The code assumes NetVertexMatchData has a field m_Offsets with accessible x/y/z members (Vector3-like or custom struct). - Using float.NaN indicates an unset axis; systems reading the component should handle NaN appropriately.

Usage Example

// Example: set up the prefab component on a prefab game object in code
var match = prefabGameObject.AddComponent<Game.Prefabs.MatchPieceVertices>();
match.m_Offsets = new float[] { 0.0f, 1.5f, -0.25f };

// During conversion, the resulting entity will receive a NetVertexMatchData component
// with m_Offsets.x = 0.0f, m_Offsets.y = 1.5f, m_Offsets.z = -0.25f.

Additional notes: - The class is decorated with [ComponentMenu("Net/", new Type[] { typeof(NetPiecePrefab) })], which places it in the editor component menu under the "Net/" category (and associates it with NetPiecePrefab in that menu). - Ensure systems that consume NetVertexMatchData handle NaN values (meaning "unset") and that the NetVertexMatchData struct layout matches the code's expectations.