Skip to content

Game.Areas.Surface

Assembly:
Assembly-CSharp (game assembly; if building a separate mod assembly, this type will appear in that assembly)

Namespace: Game.Areas

Type: struct

Base: IComponentData, IQueryTypeParameter, IEmptySerializable

Summary: Surface is an empty, blittable ECS component used as a tag/marker type. It is laid out with StructLayout(LayoutKind.Sequential, Size = 1) so it has a non-zero size for serialization and interop purposes. Implementing IComponentData makes it a Unity Entities component type; IQueryTypeParameter allows it to be used directly in query signatures; IEmptySerializable (Colossal.Serialization.Entities) indicates it should be treated as an empty serializable component by the game's custom serializer.


Fields

  • This type defines no instance fields. It is intentionally empty (used as a tag).

Properties

  • This type defines no properties.

Constructors

  • public Surface() (implicit)
  • As a struct, a parameterless default constructor exists implicitly. No custom constructors are defined.

Methods

  • This type defines no instance or static methods.
  • Behavior related to serialization/usage as a component is provided by the implemented marker interfaces (IComponentData, IQueryTypeParameter, IEmptySerializable) and by the StructLayout attribute rather than by methods on this type.

Usage Example

using Unity.Entities;
using Unity.Collections;
using Game.Areas;

// Create an entity with Surface as a tag using an archetype
var em = World.DefaultGameObjectInjectionWorld.EntityManager;
var archetype = em.CreateArchetype(typeof(Surface));
Entity e = em.CreateEntity(archetype);

// Or add the tag to an existing entity
em.AddComponent<Surface>(e);

// Using an EntityCommandBuffer (safe from jobs/main-thread contexts)
var ecb = new EntityCommandBuffer(Allocator.Temp);
ecb.AddComponent<Surface>(e);
ecb.Playback(em);
ecb.Dispose();

{{ NOTES }} - Purpose: Use Surface as a lightweight marker to categorize or query Entities that represent surface areas in game systems (pathfinding, rendering decisions, area classification, etc.). - The StructLayout(Size = 1) ensures the component occupies a byte; helpful for serialization systems that don't handle zero-sized components. - Because it implements IEmptySerializable, the game's Colossal serializer recognizes it as an empty serializable component — do not add fields if you intend to keep empty-serialization behavior.