Skip to content

Game.City.TaxRates

Assembly:
Namespace: Game.City

Type: struct

Base: IBufferElementData, ISerializable

Summary:
Represents a single tax-rate element intended for use with Unity's ECS dynamic buffers. This struct stores a single integer tax value and implements Colossal's ISerializable interface so it can be written to and read from the game's save data stream.


Fields

  • public int m_TaxRate
    Stores the tax value for this buffer element. The exact interpretation (percentage, basis points, or internal units) depends on surrounding game code. When used in a DynamicBuffer, each element represents the tax rate associated with an entity or applicable tax bracket.

Properties

  • This type does not declare any C# properties. It is a plain buffer element struct with a single public field.

Constructors

  • public TaxRates()
    No explicit constructors are declared. The default parameterless constructor provided by C# applies, initializing m_TaxRate to 0.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the m_TaxRate field to the provided writer. Implemented to fulfill Colossal.Serialization.Entities.ISerializable so the buffer element can be saved to disk.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads m_TaxRate from the provided reader. Implemented to restore the value when loading.

Usage Example

// Example: adding a tax rate to an entity's DynamicBuffer<TaxRates>
EntityManager entityManager = ...;
Entity entity = ...;

// Ensure the entity has a buffer and add a value
var buffer = entityManager.GetBuffer<Game.City.TaxRates>(entity);
buffer.Add(new Game.City.TaxRates { m_TaxRate = 150 }); // interpretation of 150 depends on game conventions

// During save/load, the Serialize/Deserialize methods will be used by the game's serializer