Game.Prefabs.ResourceData
Assembly:
Assembly-CSharp
Namespace:
Game.Prefabs
Type:
struct
Base:
IComponentData, IQueryTypeParameter
Summary:
ResourceData is an ECS component struct that describes a game resource (goods, materials, services, leisure items, etc.). It contains price information, production/trade flags, mass/weight and consumption parameters, age-group consumption weights, vehicle consumption, environmental requirements, and workforce requirements per unit. Instances of this component are intended to be attached to resource-prefab entities (or used as query parameters) to drive production, consumption and trade systems in the game.
Fields
-
public float2 m_Price
Two-component price vector. Commonly used to store price-related values (for example buy/sell, base/current price, or price and fluctuation). The meaning is context-dependent on how the economics systems interpret the two components. -
public bool m_IsProduceable
If true, the resource can be produced by city industries or facilities. -
public bool m_IsTradable
If true, the resource can be traded / exported / imported by the trade system. -
public bool m_IsMaterial
Indicates this resource is a material/raw good rather than a finished consumer good or service. -
public bool m_IsLeisure
Indicates the resource is related to leisure/tourism (affects consumption patterns and possibly desirability). -
public float m_Weight
Physical weight or transport weight of a single unit. Used by logistics/transport systems to calculate cargo loads and transport costs. -
public float m_WealthModifier
Modifier that affects consumption or demand depending on citizen wealth. Higher values typically increase demand among wealthier citizens. -
public float m_BaseConsumption
Base consumption value per capita (or per consumer) used by consumption calculations before age/wealth adjustments. -
public int m_ChildWeight
Relative weight of consumption for children. Used to scale demand per age group. -
public int m_TeenWeight
Relative weight of consumption for teenagers. -
public int m_AdultWeight
Relative weight of consumption for adults. -
public int m_ElderlyWeight
Relative weight of consumption for elderly citizens. -
public int m_CarConsumption
Amount of car usage (e.g., vehicles) consumed per unit of this resource; used to estimate traffic/vehicle demand linked to resource consumption or distribution. -
public bool m_RequireTemperature
If true, this resource requires a certain temperature range or minimum; used to gate production/availability by climate. -
public float m_RequiredTemperature
The temperature threshold required when m_RequireTemperature is true (units same as game climate data, e.g., degrees Celsius). -
public bool m_RequireNaturalResource
If true, production requires a natural resource (e.g., ore, timber) to be present/available. -
public int2 m_NeededWorkPerUnit
A two-component integer describing workforce requirements per unit of resource produced. The two components typically represent two categories of required labor (for example unskilled vs skilled, or manual vs machine hours) depending on how the production system interprets them.
Properties
- None. This struct exposes public fields and does not define properties.
Constructors
public ResourceData()
Implicit default constructor provided by the C# compiler. Initialize instances using object initializers to set required fields before attaching to entities.
Methods
- None. ResourceData is a pure data container (IComponentData) and does not implement methods.
Usage Example
// Create and populate a ResourceData instance and attach it to an existing entity
using Unity.Entities;
using Unity.Mathematics;
using Game.Prefabs;
// Example inside a System or initialization code
var resource = new ResourceData {
m_Price = new float2(10f, 8f), // example price vector (buy, sell)
m_IsProduceable = true,
m_IsTradable = true,
m_IsMaterial = true,
m_IsLeisure = false,
m_Weight = 1.25f,
m_WealthModifier = 0.15f,
m_BaseConsumption = 0.02f,
m_ChildWeight = 10,
m_TeenWeight = 20,
m_AdultWeight = 50,
m_ElderlyWeight = 20,
m_CarConsumption = 1,
m_RequireTemperature = false,
m_RequiredTemperature = 0f,
m_RequireNaturalResource = true,
m_NeededWorkPerUnit = new int2(2, 1)
};
// Assuming 'entityManager' and 'entity' are available:
entityManager.AddComponentData(entity, resource);
Notes: - This component is intended for use with Unity DOTS/ECS systems. The exact interpretation of several fields (especially float2 price and int2 needed work) depends on the consuming game systems (production, consumption, trade, transport). - Because ResourceData implements IQueryTypeParameter, it may also be used directly in entity queries where appropriate.