Game.WorkStop
Assembly: Assembly-CSharp
Namespace: Game.Routes
Type: struct
Base: System.ValueType
Implements: IComponentData, IQueryTypeParameter, IEmptySerializable
Summary:
WorkStop is an empty/tag ECS component used by the routing system (Game.Routes) to mark an entity as a "work stop" (a route stop used for work-related routing logic). It contains no data; its presence/absence on an entity conveys the semantic. The struct is attributed with StructLayout(LayoutKind.Sequential, Size = 1) to ensure it has a non-zero size for interoperability and serialization. Implementing IEmptySerializable and IQueryTypeParameter makes it compatible with Colossal's serialization pipeline and usable in ECS query builders (e.g., WithAll
Fields
- This struct declares no fields. It is intentionally empty and functions as a tag component.
Properties
- This struct declares no properties.
Constructors
public WorkStop()
(implicit default constructor)
The type is a value type; you can create it withdefault(WorkStop)
ornew WorkStop()
when needed, but typically you add it to an entity via ECS APIs rather than storing instances.
Methods
- This type declares no methods.
Usage Example
using Unity.Entities;
using Game.Routes;
public partial class WorkStopExampleSystem : SystemBase
{
protected override void OnCreate()
{
base.OnCreate();
var em = World.DefaultGameObjectInjectionWorld.EntityManager;
// Create an entity and add the WorkStop tag component
var entity = em.CreateEntity();
em.AddComponent<WorkStop>(entity);
// Alternatively, add tag to an existing entity
// em.AddComponent<WorkStop>(existingEntity);
// Query all entities that are marked as WorkStop
Entities
.WithAll<WorkStop>()
.ForEach((Entity e) =>
{
// Handle work stop entities here
})
.Schedule();
}
protected override void OnUpdate()
{
// Query usage can also be in OnUpdate; shown above for demonstration.
}
}
Additional notes:
- Because WorkStop is a tag component, prefer EntityManager.AddComponent