Class ResourceDefinition
ENGINE LAYER: Defines a single resource type (gold, manpower, prestige, etc.)
This is the data structure that represents a resource's properties. Resources are loaded from JSON5 files and registered in ResourceRegistry.
Architecture:
- Engine layer provides the mechanism (ResourceDefinition + ResourceSystem)
- Game layer provides the policy (which resources exist, their properties)
- Data files define specific resources (gold, manpower, etc.)
[Serializable]
public class ResourceDefinition
- Inheritance
-
objectResourceDefinition
Fields
category
Optional: Category for grouping (e.g., "economic", "military", "diplomatic")
public string category
Field Value
- string
color
Color for UI display (hex format: #FFD700 for gold)
public string color
Field Value
- string
description
Optional: Tooltip description for UI
public string description
Field Value
- string
displayName
Display name for UI (e.g., "Gold", "Manpower")
public string displayName
Field Value
- string
icon
Icon identifier for UI (e.g., "icon_gold", "icon_manpower") Maps to sprite resources
public string icon
Field Value
- string
id
Unique identifier for this resource (e.g., "gold", "manpower") Used in commands, save files, and lookups
public string id
Field Value
- string
maxValue
Maximum value this resource can have (default: infinity) Use 0 for no maximum
public float maxValue
Field Value
- float
minValue
Minimum value this resource can have (default: 0) Can be negative for resources like prestige
public float minValue
Field Value
- float
startingAmount
Starting amount for all countries at game start
public float startingAmount
Field Value
- float
Methods
GetColor()
Get Unity Color from hex string
public Color GetColor()
Returns
GetMaxValueFixed()
Get FixedPoint64 max value
public FixedPoint64 GetMaxValueFixed()
Returns
GetMinValueFixed()
Get FixedPoint64 min value
public FixedPoint64 GetMinValueFixed()
Returns
GetStartingAmountFixed()
Get FixedPoint64 value from float (for deterministic storage)
public FixedPoint64 GetStartingAmountFixed()
Returns
Validate(out string)
Validate this resource definition (called after loading from JSON5)
public bool Validate(out string errorMessage)
Parameters
errorMessagestring
Returns
- bool