Game.Common.Native
Assembly: (part of the game's code/base assembly; not specified in this file)
Namespace: Game.Common
Type: struct Native
Base: Implements - Unity.Entities.IComponentData - Unity.Entities.IQueryTypeParameter - Colossal.Serialization.Entities.IEmptySerializable
Summary:
Native is an empty, marker/tag component designed for use with Unity's DOTS/ECS and the game's serialization system. It is annotated with [StructLayout(LayoutKind.Sequential, Size = 1)] to ensure a non-zero native size (1 byte) for interop/serialization and to make it suitable for APIs that expect an unmanaged type with a defined size. Because it implements IComponentData, it can be attached to entities as a component; IQueryTypeParameter allows use in query/type-parameter contexts; IEmptySerializable indicates it participates in the game's custom serialization pipeline as an empty serializable type.
Fields
- None — this struct defines no instance fields.
The StructLayout attribute (Size = 1) is used to force a 1-byte native size even though there are no managed fields.
Properties
- None — the type exposes no properties.
Constructors
- Implicit default struct constructor (public Native())
As a value type, it has the default parameterless constructor provided by C#. There are no custom constructors defined in the source.
Methods
- None — the type declares no methods. The implemented interfaces are marker/flag interfaces and do not require additional members in this struct.
Usage Example
// Add a Native tag component to an entity
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity myEntity = entityManager.CreateEntity();
entityManager.AddComponent<Native>(myEntity);
// Check for the tag
bool hasNative = entityManager.HasComponent<Native>(myEntity);
// Use in a system query (Entities.ForEach / SystemBase)
public partial class ExampleSystem : SystemBase
{
protected override void OnUpdate()
{
// Process only entities that have the Native tag
Entities
.WithAll<Native>()
.ForEach((Entity e) =>
{
// ... logic for tagged entities ...
}).ScheduleParallel();
}
}
Notes: - Use this struct when you need a lightweight tag component that is recognized by the game's serialization layer and can be used in queries. - The StructLayout(Size = 1) ensures compatibility with native/serialization systems that expect a non-zero size for components.