Game.Net.TrainTrack
Assembly: Game
Namespace: Game.Net
Type: struct
Base: System.ValueType, implements IComponentData, IQueryTypeParameter, IEmptySerializable
Summary:
TrainTrack is an empty/tag component (1-byte sized struct) used with Unity.Entities (ECS) to mark or tag entities that represent train tracks in the game's entity/component model. The struct is explicitly laid out with Size = 1 so it is non-zero-sized (useful for serialization/interoperation). Because it implements IComponentData it is usable as a component in ECS; IQueryTypeParameter enables use in entity queries; IEmptySerializable integrates with Colossal's serialization helpers.
Fields
- This type declares no instance fields.
Note: The struct is attributed with [StructLayout(LayoutKind.Sequential, Size = 1)] to force a size of 1 byte even though it contains no fields.
Properties
- This type declares no properties.
Constructors
- public implicit parameterless constructor (default struct constructor)
This struct relies on the default value-initialized constructor (no explicit constructors are declared).
Methods
- This type declares no methods.
Usage Example
using Unity.Entities;
using Game.Net;
// Add the tag component to an existing entity
var em = World.DefaultGameObjectInjectionWorld.EntityManager;
em.AddComponentData(existingEntity, new TrainTrack());
// Query for all entities that are tagged as train tracks
EntityQuery trainTrackQuery = em.CreateEntityQuery(ComponentType.ReadOnly<TrainTrack>());
// In a SystemBase, iterate over entities that have the TrainTrack tag
public partial class ExampleTrainTrackSystem : SystemBase
{
protected override void OnUpdate()
{
// Process entities that have the TrainTrack tag
Entities
.WithAll<TrainTrack>()
.ForEach((Entity e) =>
{
// Your per-entity logic here
})
.WithoutBurst()
.Run();
}
}
Additional notes: - Use this struct as a marker/tag; it carries no data by design. - The IEmptySerializable interface indicates it participates in the game's custom serialization pipeline (Colossal.Serialization). - Because it is trivially small and stateless, it's efficient for filtering and tagging entities in queries.