Skip to content

Game.TilePurchaseCostFactor

Assembly:
Assembly-CSharp (or the game's runtime assembly where your mod code is compiled)

Namespace: Game.Prefabs

Type: struct

Base: Implements Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter

Summary:
Component that represents a multiplicative cost factor applied when purchasing a tile. Typically attached to tile prefab entities (or added to runtime entities) to adjust the purchase price by the stored float amount. The value is stored in the public field m_Amount and can be read or modified by ECS systems that process tile purchase logic.


Fields

  • public System.Single m_Amount
    Stores the cost multiplier (e.g., 1.0 = no change, 1.5 = +50% cost). This field is the component's payload and is used by systems that calculate or apply tile purchase prices.

Properties

  • None
    This struct exposes its data via the public field m_Amount; there are no C# properties.

Constructors

  • public TilePurchaseCostFactor(float amount)
    Creates a TilePurchaseCostFactor with the given amount. Use this to initialize the component when adding it to an entity or prefab.

Parameters: - amount: The multiplier to apply to tile purchase cost.

Methods

  • None
    This struct contains only data and no methods. It is intended for use as an IComponentData container in ECS systems.

Usage Example

// Add component to an entity (EntityManager context)
var costFactor = new TilePurchaseCostFactor(1.25f); // +25% cost
entityManager.AddComponentData(tileEntity, costFactor);

// Read/modify inside a SystemBase
public partial class TilePurchaseSystem : SystemBase
{
    protected override void OnUpdate()
    {
        Entities.ForEach((ref TilePurchaseCostFactor cost) =>
        {
            // Example: gradually increase the cost factor by 1% per update
            cost.m_Amount *= 1.01f;
        }).ScheduleParallel();
    }
}

// Querying entities with this component
var query = entityManager.CreateEntityQuery(typeof(TilePurchaseCostFactor));
using var arr = query.ToComponentDataArray<TilePurchaseCostFactor>(Allocator.Temp);
foreach (var cf in arr)
{
    UnityEngine.Debug.Log($"Tile cost factor: {cf.m_Amount}");
}