Skip to content

Game.Prefabs.AttractionData

Assembly: Game (inferred; adjust if different)
Namespace: Game.Prefabs

Type: struct

Base: System.ValueType, IComponentData, IQueryTypeParameter, ICombineData, ISerializable

Summary:
Represents the attractiveness value of an attraction prefab in the ECS world. This value-type component stores a single integer attractiveness score, can be combined with other AttractionData instances (useful for aggregation/reduction across entities), and supports binary serialization/deserialization via the Colossal.Serialization interfaces.


Fields

  • public int m_Attractiveness
    Stores the attractiveness score for the attraction. Used for accumulation and logic that depends on how “attractive” a prefab is. Default value is 0 for a default-constructed struct.

Properties

  • This struct defines no properties.

Constructors

  • public AttractionData()
    Implicit default parameterless constructor provided by the C# value type. You can also initialize with an object initializer, e.g. new AttractionData { m_Attractiveness = 10 }.

Methods

  • public void Combine(AttractionData otherData)
    Adds the attractiveness value from otherData into this instance (m_Attractiveness += otherData.m_Attractiveness). Useful for combining component values during aggregation/reduce operations in systems.

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the m_Attractiveness integer to the provided writer. Used by the Colossal.Serialization pipeline to persist component data.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads an integer from reader into m_Attractiveness. Used when loading component data back into memory.

Usage Example

// Combine two attraction components
var a = new AttractionData { m_Attractiveness = 5 };
var b = new AttractionData { m_Attractiveness = 8 };
a.Combine(b); // a.m_Attractiveness == 13

// Example: attach to an entity (pseudo-code, depends on your ECS setup)
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var entity = entityManager.CreateEntity();
entityManager.AddComponentData(entity, new AttractionData { m_Attractiveness = 10 });

// Serialization example (pseudo-code, depends on available writer/reader implementations)
SomeWriter writer = /* obtain writer */;
var data = new AttractionData { m_Attractiveness = 20 };
data.Serialize(writer);

// Deserialization
SomeReader reader = /* obtain reader */;
var loaded = new AttractionData();
loaded.Deserialize(reader);