Game.Simulation.XPReason
Assembly: Assembly-CSharp.dll
Namespace: Game.Simulation
Type: public enum
Base: System.Enum (underlying type: System.Int32)
Summary:
Defines the set of reasons/categories used by the simulation to attribute experience (XP) changes. Each enum value represents a distinct source or cause for awarding (or tracking) XP such as building services, network changes, population growth, happiness, income, and various infrastructure types. The final member (Count) is commonly used to determine the number of defined reasons.
Fields
-
Unknown
Represents an unspecified or default reason. Use when the source of XP cannot be determined. -
ServiceBuilding
XP attributed to the creation/operation of a service building (e.g., police, fire, health services). -
ServiceUpgrade
XP attributed to upgrading a service building. -
ElectricityNetwork
XP related to changes or actions in the electricity network. -
Population
XP awarded because of population growth or population-related events. -
Happiness
XP attributed to changes in city happiness metrics. -
Income
XP related to changes in income (city or player income events). -
Road
XP for actions affecting roads (construction, upgrade, removal). -
TrainTrack
XP for actions affecting train tracks. -
TramTrack
XP for actions affecting tram tracks. -
SubwayTrack
XP for actions affecting subway tracks. -
Waterway
XP for actions affecting waterways (e.g., canals, navigable channels). -
Pipe
XP for actions affecting water/sewage pipes. -
PowerLine
XP for actions affecting power lines. -
Count
Utility member representing the number of defined reasons. Useful for array sizing or validation; not itself a reason to award XP.
Properties
- This enum has no properties. (Standard System.Enum members and methods apply, e.g., ToString, GetValues, etc.)
Constructors
- Enums do not expose user-callable constructors. Values are the named constants listed above. The underlying .NET runtime provides the typical enum behavior and default value (0 = Unknown).
Methods
- No custom methods are defined on this enum. You can use standard System.Enum utilities (Enum.GetValues, Enum.TryParse, ToString, etc.) as needed.
Usage Example
// Example: awarding XP based on reason
void AwardXP(int amount, XPReason reason)
{
if (reason == XPReason.Count || reason == XPReason.Unknown)
return; // Skip invalid/unusable reasons
switch (reason)
{
case XPReason.ServiceBuilding:
// handle service building XP
break;
case XPReason.Population:
// handle population-related XP
break;
// handle other reasons...
default:
// fallback
break;
}
// Record or apply the XP...
}
// Example usage:
AwardXP(10, XPReason.ServiceUpgrade);
Notes: - Because enum values are often serialized or persisted, avoid changing the order or numeric values of the members if compatibility with saved data or other systems is required.