Skip to content

Game.DevTreePoints

Assembly: Assembly-CSharp
Namespace: Game.City

Type: struct

Base: Implements IComponentData, IQueryTypeParameter, ISerializable

Summary: Represents a simple ECS component that stores the number of development-tree points for an entity (e.g., a city or building/group used by game systems). The struct is serializable so it can be written to/loaded from saved game data and is usable as a query parameter in Unity's ECS queries.


Fields

  • public System.Int32 m_Points Stores the integer number of development-tree points. This is the only data carried by the component and represents the current points value used by gameplay systems or UI. It is directly serialized/deserialized by the implemented ISerializable methods.

Properties

  • This type has no properties.

Constructors

  • public DevTreePoints() The default parameterless constructor is the C# value-type default and initializes m_Points to 0. You can create an instance with an explicit value using object initializer syntax, for example: new DevTreePoints { m_Points = 5 }.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the m_Points value to the provided writer. Used by the game's save system to persist this component's state.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads an integer from the provided reader into m_Points. Used when loading saved game data to restore the component's state.

Usage Example

// Example: assign DevTreePoints to an entity and serialize manually
using Unity.Entities;

// create component with 10 points
var pointsComp = new DevTreePoints { m_Points = 10 };

// add to an entity via EntityManager (in a system or initialization code)
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity entity = em.CreateEntity();
em.AddComponentData(entity, pointsComp);

// Serialization example (pseudo-code; actual writer comes from game's save system)
void SaveComponent<TWriter>(TWriter writer, DevTreePoints comp) where TWriter : Colossal.Serialization.Entities.IWriter
{
    comp.Serialize(writer);
}

// Deserialization example (pseudo-code)
DevTreePoints LoadComponent<TReader>(TReader reader) where TReader : Colossal.Serialization.Entities.IReader
{
    var comp = new DevTreePoints();
    comp.Deserialize(reader);
    return comp;
}