Game.Vehicles.CarTrailer
Assembly: Assembly-CSharp
Namespace: Game.Vehicles
Type: struct
Base: IComponentData, IQueryTypeParameter, Colossal.Serialization.Entities.IEmptySerializable
Summary:
CarTrailer is an empty (marker) ECS component used by the game's entity system. It carries no data and exists solely to mark or tag entities (typically vehicle entities) that should be considered as having a car trailer. The struct is annotated with a fixed layout and size to ensure it is serializable and has non-zero size for the game's serialization/interop requirements.
Fields
- This type defines no instance fields.
The struct is intentionally empty; the [StructLayout(LayoutKind.Sequential, Size = 1)] attribute gives it a non-zero size for serialization and native interop.
Properties
- This type defines no properties.
Constructors
public CarTrailer()
Structs have an implicit public parameterless constructor. No explicit constructors are defined in the source; the implicit default constructor is used when adding this component to an entity.
Methods
- This type defines no methods.
Remarks
- Attributes:
[StructLayout(LayoutKind.Sequential, Size = 1)]
— ensures the struct is laid out sequentially and occupies 1 byte, making it safe for the game's serialization system and preventing zero-sized type issues.- Implemented interfaces:
IComponentData
— marks this as a Unity Entities ECS component.IQueryTypeParameter
— allows the type to be used as a parameter in query APIs.IEmptySerializable
— indicates the type is treated as an empty serializable entity by Colossal's serialization infrastructure.
Usage Example
// Add the marker component to an entity (EntityManager is typically available in systems or initialization code)
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity vehicleEntity = entityManager.CreateEntity(typeof(SomeVehicleComponent)); // example
entityManager.AddComponentData(vehicleEntity, new Game.Vehicles.CarTrailer());
// Query for vehicles with the CarTrailer tag
Entities
.WithAll<Game.Vehicles.CarTrailer>()
.ForEach((Entity e, in SomeVehicleComponent vehicle) =>
{
// Handle vehicles that have a trailer
})
.Schedule();