Skip to content

Game.Prefabs.TaxParameterPrefab

Assembly:
Assembly-CSharp (game/mod assembly; the original class lives in the game's runtime assembly)

Namespace:
Game.Prefabs

Type:
class

Base:
PrefabBase

Summary:
TaxParameterPrefab is a prefab class that holds tax limit ranges for several economic categories (total, residential, commercial, industrial, office, job-level and resource). During LateInitialize it writes those ranges into an ECS component (TaxParameterData) on the prefab entity so systems can read the configured tax limits at runtime. It also ensures the PrefabSystem exists on the world before setting component data.


Fields

  • public Unity.Mathematics.int2 m_TotalTaxLimits
    Stores the minimum and maximum total tax limits as an int2 (x = min, y = max).

  • public Unity.Mathematics.int2 m_ResidentialTaxLimits
    Tax min/max limits for residential zones.

  • public Unity.Mathematics.int2 m_CommercialTaxLimits
    Tax min/max limits for commercial zones.

  • public Unity.Mathematics.int2 m_IndustrialTaxLimits
    Tax min/max limits for industrial zones.

  • public Unity.Mathematics.int2 m_OfficeTaxLimits
    Tax min/max limits for office zones.

  • public Unity.Mathematics.int2 m_JobLevelTaxLimits
    Tax min/max limits per job level.

  • public Unity.Mathematics.int2 m_ResourceTaxLimits
    Tax min/max limits for resource extraction/industry.

Properties

This class defines no properties.

Constructors

  • public TaxParameterPrefab()
    Default constructor (Unity/MonoBehaviour-style prefab class). Instances are typically created/managed by the game's prefab system or by Unity serialization rather than manually constructed in user code.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds component types that this prefab requires to the provided set. This implementation calls the base method and then adds ComponentType.ReadWrite() so that entities created from this prefab will include the TaxParameterData component.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Calls the base implementation. No additional archetype components are added here beyond what PrefabBase provides.

  • public override void LateInitialize(EntityManager entityManager, Entity entity)
    Called during prefab late initialization. This method:

  • Calls the base LateInitialize.
  • Ensures the world's PrefabSystem exists by calling entityManager.World.GetOrCreateSystemManaged().
  • Writes a TaxParameterData component to the given entity using entityManager.SetComponentData(...) with the values from the prefab fields (m_TotalTaxLimits, m_ResidentialTaxLimits, etc.). This makes the configured tax limits available to ECS systems via the TaxParameterData component.

Notes: - The int2 fields are packaged directly into the TaxParameterData component. TaxParameterData must be a struct component type present in the game's ECS types (not shown here). - GetPrefabComponents ensures the entity will have a read/write TaxParameterData component so SetComponentData in LateInitialize is valid.

Usage Example

// After the prefab is created/loaded by the game's prefab system and LateInitialize has run,
// you can read the TaxParameterData from the prefab entity:

using Unity.Entities;
using Unity.Mathematics;

// Acquire the world/entity manager (example)
var em = World.DefaultGameObjectInjectionWorld.EntityManager;

// Assume 'prefabEntity' is the Entity created from the TaxParameterPrefab
Entity prefabEntity = /* get the prefab entity from PrefabSystem or entity lookup */;

// Read the configured tax limits
if (em.HasComponent<TaxParameterData>(prefabEntity))
{
    TaxParameterData data = em.GetComponentData<TaxParameterData>(prefabEntity);
    int2 totalLimits = data.m_TotalTaxLimits;
    int minTotal = totalLimits.x;
    int maxTotal = totalLimits.y;
    // use limits...
}

Additional implementation notes: - To change limits you can modify the prefab fields in the inspector (if exposed) or modify the TaxParameterData on the entity at runtime. - This prefab relies on PrefabBase and the game's PrefabSystem; it is intended to be integrated into the game's prefab loading/initialization workflow.