Skip to content

Game.Tourism

Assembly: Game
Namespace: Game.City

Type: struct

Base: value type (implements interfaces IComponentData, IQueryTypeParameter, IDefaultSerializable, ISerializable)

Summary:
Tourism is a component data struct used by the game's ECS to store tourism-related metrics for an entity (for example, a district, building cluster, or tile). It contains counters for current and average tourists, an attractiveness score, and a two-integer vector for lodging-related values. The struct implements serialization interfaces so it can be saved/loaded and provides a SetDefaults method to initialize fields to safe default values.


Fields

  • public int m_CurrentTourists
    Current number of tourists tracked for this component instance.

  • public int m_AverageTourists
    Average number of tourists (historical/rolling average) for this component instance.

  • public int m_Attractiveness
    Attractiveness score used by tourism systems to influence tourist behavior.

  • public int2 m_Lodging
    Two-integer vector representing lodging-related values. The exact semantic of each element depends on game logic (for example, it may encode lodging capacity and current lodging usage). Stored using Unity.Mathematics.int2.

Properties

  • (none)

This struct exposes no properties; all data is stored in public fields.

Constructors

  • (implicit) public Tourism()
    No explicit constructor is declared in the source. The auto-generated default constructor initializes value-type fields to their default values (zeros). Use SetDefaults(Context) to explicitly initialize according to the component's default policy.

Methods

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the component fields from a reader implementing IReader. Deserializes fields in the following order: m_CurrentTourists, m_AverageTourists, m_Attractiveness, m_Lodging.

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the component fields to a writer implementing IWriter. Serializes fields in the following order: m_CurrentTourists, m_AverageTourists, m_Attractiveness, m_Lodging.

  • public void SetDefaults(Context context)
    Implements IDefaultSerializable. Sets the component fields to their default values:

  • m_CurrentTourists = 0
  • m_AverageTourists = 0
  • m_Attractiveness = 0
  • m_Lodging = default(int2)

These defaults are suitable when creating new component instances or when resetting state.

Usage Example

// Create and initialize a Tourism component, then add to an entity (ECS style)
var tourism = new Tourism();
tourism.SetDefaults(context); // context is provided by the serialization/defaulting system

// Optionally customize values
tourism.m_CurrentTourists = 120;
tourism.m_AverageTourists = 95;
tourism.m_Attractiveness = 75;
tourism.m_Lodging = new int2(50, 40); // interpretation depends on game logic

// Add to an entity using EntityManager in Unity DOTS
// entityManager.AddComponentData(entity, tourism);

{{ Additional notes: - This struct is designed for use within the game's ECS. When interacting with it, prefer EntityManager or systems that operate on IComponentData. - Serialization methods follow a strict field order — do not change order unless serialization format is updated accordingly. - The semantics of m_Lodging's two components are defined elsewhere in game code; treat it as an opaque pair if unsure. }}