Game.Prefabs.XPParameterData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: IComponentData, IQueryTypeParameter
Summary:
Component data struct that holds XP (experience) parameters used by prefabs/systems. It defines how much XP is granted per unit of population and per unit of happiness. Implementing IComponentData makes it usable as an ECS component; IQueryTypeParameter allows it to be used directly in queries or as a query parameter.
Fields
-
public System.Single m_XPPerPopulation
XP awarded per unit of population. Typical use: multiply this value by the population count to compute XP earned. Default (uninitialized) is 0.0f. -
public System.Single m_XPPerHappiness
XP awarded per unit of happiness. Typical use: scale XP by entity/town happiness. Default (uninitialized) is 0.0f.
Properties
- None. This type exposes only public fields and has no properties.
Constructors
public XPParameterData()
Implicit parameterless constructor provided by C#. Use object initializer syntax to set fields, e.g. new XPParameterData { m_XPPerPopulation = 0.5f, m_XPPerHappiness = 1.0f }.
Methods
- None. This is a plain data container (POD) used for ECS storage and queries.
Usage Example
// Create and attach to an entity (EntityManager API)
var xpData = new XPParameterData {
m_XPPerPopulation = 0.25f,
m_XPPerHappiness = 1.5f
};
entityManager.AddComponentData(entity, xpData);
// Read as a singleton inside a system (modern Entities SystemAPI)
var xpSingleton = SystemAPI.GetSingleton<XPParameterData>();
// Or retrieve from a specific entity
var xpFromEntity = entityManager.GetComponentData<XPParameterData>(entity);
{{ This struct is intended as a small configuration/component that systems can read to calculate XP gains. Because it's a value type stored in the ECS, updates must be applied via SetComponentData/AddComponentData or appropriate SystemAPI calls. }}