Game.Vehicles.Helicopter
Assembly: Assembly-CSharp
Namespace: Game.Vehicles
Type: struct
Base: IComponentData, IQueryTypeParameter, IEmptySerializable
Summary:
Helicopter is an empty tag component (an ECS marker) used to mark entities that represent helicopters in the game's ECS world. The type is defined as a 1-byte sequentially laid out struct to ensure a non-zero size for serialization and interop. It implements:
- IComponentData — so it can be attached to Entities as a component.
- IQueryTypeParameter — so it can be used in Entity queries as a parameter type.
- IEmptySerializable — indicates special handling by the game's serialization system for empty marker types (optimized serialization).
The struct contains no runtime state; its presence/absence on an entity is the meaningful data.
Fields
- This struct has no instance fields. It is intentionally empty and serves as a tag component to identify helicopter entities.
Properties
- This struct has no properties.
Constructors
public Helicopter()
As a value type, Helicopter has the default parameterless constructor which yields the empty marker value. No custom constructors are defined.
Methods
- This type defines no methods. Its behavior is entirely implicit via the presence/absence of the component on entities and via systems that query for the Helicopter component.
Remarks / Implementation Notes
- Attribute: [StructLayout(LayoutKind.Sequential, Size = 1)] — forces the struct to occupy at least one byte and ensures a stable layout for serialization/interop. This is commonly used for empty marker components that still need a non-zero size for certain serializers or native interop.
- Usage intent: Because the component contains no data, systems should only check for its presence (e.g., via HasComponent or by querying for entities with Helicopter) and not expect any associated values.
- Serialization: Implementing IEmptySerializable signals to the Colossal.Serialization system that this is an empty/component-only type and can be serialized in a compact manner.
- Query/type parameter usage: Implementing IQueryTypeParameter allows the type to participate in ECS query APIs provided by the game's Entities stack.
Usage Example
// Typical usage in a system or initialization code:
using Unity.Entities;
using Game.Vehicles;
// get the EntityManager from the current world
var em = World.DefaultGameObjectInjectionWorld.EntityManager;
// create an entity and mark it as a helicopter
var entity = em.CreateEntity();
em.AddComponentData(entity, new Helicopter());
// later, a system can query for helicopters:
Entities
.WithAll<Helicopter>()
.ForEach((Entity e, in SomeOtherComponent comp) =>
{
// handle helicopter entity
}).Run();