Game.Buildings.ResourceProducer
Assembly: Assembly-CSharp
Namespace: Game.Buildings
Type: struct
Base: System.ValueType, IComponentData, IQueryTypeParameter, IEmptySerializable
Summary: ResourceProducer is an empty ECS (Entity Component System) marker component used to tag entities that act as resource producers in the game. It is laid out with a 1-byte size (StructLayout Size = 1) so serialization and native layout requirements are satisfied even though it contains no data. Implementing IComponentData makes it usable in Unity's ECS, IQueryTypeParameter allows its use in query/type filters, and IEmptySerializable ensures proper handling by the game's custom serialization.
Fields
- This struct declares no instance fields. It is intentionally empty and used as a tag/marker component to identify resource-producing entities in ECS queries and systems. {{ The StructLayout attribute sets the size to 1 byte so the type is non-zero-sized for native/serialization expectations. }}
Properties
- This type exposes no properties. It is purely a marker component. {{ Use this component in queries or to add/remove the marker on entities via EntityManager or system APIs. }}
Constructors
public ResourceProducer()
{{ The default parameterless constructor is provided implicitly by the runtime. Because the struct is empty, no custom initialization is required. }}
Methods
- This type defines no methods. It is an empty marker component. {{ Interaction is performed via ECS APIs (Add/Remove component, WithAll/WithNone queries, etc.). }}
Usage Example
using Unity.Entities;
using Game.Buildings;
// Create an entity with the ResourceProducer tag
public partial class ResourceProducerBootstrapSystem : SystemBase
{
protected override void OnCreate()
{
base.OnCreate();
// Create a new entity and add the marker component
var archetype = EntityManager.CreateArchetype(typeof(ResourceProducer));
var entity = EntityManager.CreateEntity(archetype);
// Or add the marker to an existing entity:
// EntityManager.AddComponent<ResourceProducer>(existingEntity);
}
protected override void OnUpdate() { }
}
// Querying entities that have the ResourceProducer tag
public partial class ResourceProducerProcessingSystem : SystemBase
{
protected override void OnUpdate()
{
Entities
.WithAll<ResourceProducer>()
.ForEach((Entity e, in SomeOtherData data) =>
{
// Process resource-producing entities here
})
.ScheduleParallel();
}
}
{{ Because ResourceProducer is a tag, prefer AddComponent/RemoveComponent or archetypes to mark entities, and use WithAll