Skip to content

Game.Prefabs.PlantData

Assembly:
Assembly-CSharp (game) — present in the game's compiled assemblies; when used in a mod, replace with your mod assembly name.

Namespace:
Game.Prefabs

Type:
struct

Base:
System.ValueType, IComponentData, IQueryTypeParameter, IEmptySerializable

Summary:
PlantData is an empty/tag component used by the game's ECS to mark entities that represent plants (prefab plant objects). The struct is explicitly given a memory size of 1 byte via [StructLayout(LayoutKind.Sequential, Size = 1)] to avoid zero-sized-type issues with serializers or native interop. Implementing IComponentData makes it usable in Unity's ECS; IQueryTypeParameter allows it to be used directly in query APIs; IEmptySerializable is used by Colossal's serialization infrastructure to treat it as an empty-serializable marker.


Fields

  • This struct defines no data fields; it is intentionally empty and used purely as a tag.

Properties

  • None.

Constructors

  • public PlantData() (implicit)
    The default value-type constructor exists implicitly. No initialization is required because the component carries no data.

Methods

  • None defined. The type is a plain marker component with no behavior.

Usage Example

// Add the marker to an existing entity:
entityManager.AddComponentData(entity, new PlantData());

// Create an entity archetype that includes the PlantData tag:
var archetype = entityManager.CreateArchetype(typeof(Translation), typeof(RenderMesh), typeof(PlantData));
var plantEntity = entityManager.CreateEntity(archetype);

// Query all plant entities with an ECS query using the tag:
Entities
    .WithAll<PlantData>()
    .ForEach((Entity e, in Translation t) =>
    {
        // Process plant entity...
    })
    .Schedule();

Notes: - The [StructLayout(LayoutKind.Sequential, Size = 1)] attribute ensures the component is non-zero-sized at runtime which can be required by some serialization or interop subsystems. - Use this component as a lightweight marker — storing no per-entity data — making it efficient for filtering and tagging in queries.