Game.Vehicles.RoadMaintenanceVehicle
Assembly: Assembly-CSharp
Namespace: Game.Vehicles
Type: struct
Base: System.ValueType; implements IComponentData, IQueryTypeParameter, IEmptySerializable
Summary:
RoadMaintenanceVehicle is an empty/tag ECS component used to mark entities that represent road maintenance vehicles in the game's entity-component-system. It is decorated with [StructLayout(LayoutKind.Sequential, Size = 1)] to force a non-zero size (1 byte) for serialization and interop purposes. The implemented interfaces indicate:
- IComponentData — this is a Unity.Entities component that can be attached to entities.
- IQueryTypeParameter — can be used directly in entity queries.
- IEmptySerializable — used by the game's/Colossal serialization infrastructure to handle empty (tag) components safely.
This type contains no data; presence/absence is used as a flag for systems that process road maintenance vehicles (e.g., movement, task assignment, rendering, or specialized AI behaviors).
Fields
- This struct defines no instance fields.
The type is intentionally empty (size forced to 1 via StructLayout) so it can act as a lightweight tag component and still be serializable by the game's serialization system.
Properties
- This type exposes no properties.
Constructors
public RoadMaintenanceVehicle()
The default parameterless constructor is provided implicitly. Since the struct is empty, there's no custom initialization required.
Methods
- This type defines no methods. It is used purely as a marker/tag component.
Usage Example
using Unity.Entities;
using Game.Vehicles;
// Create an entity with the tag
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var archetype = entityManager.CreateArchetype(
typeof(RoadMaintenanceVehicle),
typeof(Unity.Transforms.Translation), // example additional components
typeof(Unity.Physics.PhysicsCollider) // example additional components
);
Entity roadMaintEntity = entityManager.CreateEntity(archetype);
// Or add the tag to an existing entity
entityManager.AddComponentData(existingEntity, new RoadMaintenanceVehicle());
// Querying for road maintenance vehicles in a system
public partial class RoadMaintenanceSystem : SystemBase
{
protected override void OnUpdate()
{
Entities
.WithAll<RoadMaintenanceVehicle>()
.ForEach((Entity e, ref SomeOtherComponent comp) =>
{
// process maintenance vehicle
}).Schedule();
}
}