Game.OutOfControl
Assembly: Assembly-CSharp.dll
Namespace: Game.Vehicles
Type: struct
Base: System.ValueType, IComponentData, IQueryTypeParameter, IEmptySerializable
Summary:
OutOfControl is an empty "tag" component (IComponentData) used with Unity's ECS to mark vehicle entities that are currently out of control (for example, spinning, crashed, or otherwise uncontrolled). The struct is decorated with [StructLayout(LayoutKind.Sequential, Size = 1)] to guarantee a stable, non-zero size for interop/serialization purposes. Implementing IEmptySerializable indicates it is intended to be serialized as an empty marker by Colossal's serialization system; IQueryTypeParameter makes it usable directly in queries (Has/WithAll style).
Fields
- (none)
This struct contains no instance fields by design. It functions purely as a tag component to mark entities.
Properties
- (none)
No properties are defined.
Constructors
- Implicit parameterless constructor (compiler-generated)
There are no explicit constructors declared. As a value type it can be default-constructed (new OutOfControl() or default(OutOfControl)).
Methods
- (none)
There are no instance or static methods defined on this type. Behavior associated with the tag is implemented in systems that read/add/remove this component.
Usage Example
// Mark a vehicle entity as out-of-control
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity vehicleEntity = /* obtain vehicle Entity */;
entityManager.AddComponent<OutOfControl>(vehicleEntity);
// Later, check and process out-of-control vehicles in a SystemBase
public class HandleOutOfControlVehiclesSystem : SystemBase
{
protected override void OnUpdate()
{
// Example: iterate over entities with the OutOfControl tag
Entities
.WithAll<OutOfControl>()
.ForEach((Entity e) =>
{
// perform handling: apply forces, spawn effects, change state, etc.
// To remove the tag:
// EntityManager.RemoveComponent<OutOfControl>(e);
})
.WithoutBurst()
.Run();
}
}
Additional notes: - Because the component is empty, it's cheap to add/remove and useful for boolean-like state flags in ECS. - The StructLayout attribute with Size = 1 ensures compatibility with serialization/interop code paths that expect concrete sizes (helpful for Colossal's serialization framework). - Use EntityManager or EntityCommandBuffer to modify this component from jobs/systems depending on threading/context requirements.