Skip to content

Game.Buildings.PropertyToBeOnMarket

Assembly: Assembly-CSharp
Namespace: Game.Buildings

Type: struct

Base: - Unity.Entities.IComponentData
- Unity.Entities.IQueryTypeParameter
- Colossal.Serialization.Entities.IEmptySerializable

Summary: PropertyToBeOnMarket is an empty/tag ECS component used to mark a building/property entity as intended to be placed on the market. It contains no data fields and exists solely as a marker for systems and queries. The struct is explicitly laid out with Size = 1 to ensure a non-zero size for interop/serialization reasons, and it implements IEmptySerializable to support the game's custom serialization pipeline.


Fields

  • None — this is a marker (tag) component with no instance fields.
    Note: The type is decorated with [StructLayout(LayoutKind.Sequential, Size = 1)], which gives it a 1-byte size even though it carries no fields. This is important for certain runtime/serialization behaviors.

Properties

  • None — marker components do not expose properties.

Constructors

  • public PropertyToBeOnMarket()
  • Implicit default struct constructor only; no custom construction logic. Use the default instance when adding the component to an entity.

Methods

  • None — the struct provides no methods. It relies on being used as a tag in ECS queries and systems.

Usage Example

// Using EntityManager to add the marker as data (value-based)
entityManager.AddComponentData(entity, new PropertyToBeOnMarket());

// Or add the component type (as a tag) if using APIs that support AddComponent<T>
entityManager.AddComponent<PropertyToBeOnMarket>(entity);

// In a SystemBase, mark matching entities for market:
public partial class MarkPropertiesForMarketSystem : SystemBase
{
    protected override void OnUpdate()
    {
        var em = EntityManager;
        Entities
            .WithNone<PropertyToBeOnMarket>() // only mark those not already marked
            .ForEach((Entity entity, in BuildingComponent building) =>
            {
                if (ShouldBeOnMarket(building))
                {
                    em.AddComponent<PropertyToBeOnMarket>(entity);
                }
            }).WithoutBurst().Run();
    }

    private bool ShouldBeOnMarket(in BuildingComponent building)
    {
        // custom logic to decide whether to mark it
        return true;
    }
}

Additional notes: - Implementing IEmptySerializable means the type is compatible with the game's (Colossal) serialization system for saving/loading tag components. - IQueryTypeParameter allows the type to be used conveniently in query type parameter contexts in ECS queries.