Game.PlayerResource
Assembly: Assembly-CSharp (typical for Cities: Skylines 2 game code/modding)
Namespace: Game.City
Type: public enum
Base: System.Enum (underlying type: System.Int32)
Summary:
A serializable enumeration representing the different player / city resource types tracked by the simulation (electricity, water, education levels, services, etc.). Used to identify and index resource categories in systems that track supply, demand, service coverage, or statistics. The last member, Count, represents the total number of resource types and is commonly used for iteration and array sizing.
Fields
-
Electricity
Represents electrical power as a city resource (supply versus demand, outages, etc.). -
Healthcare
Represents healthcare services (hospitals, clinics, medical coverage). -
BasicEducation
Represents basic (primary) education level coverage and capacity. -
SecondaryEducation
Represents secondary (middle/high) education level coverage and capacity. -
HigherEducation
Represents higher (college/university) education level coverage and capacity. -
Garbage
Represents waste collection and garbage processing services. -
Water
Represents potable water supply and distribution. -
Mail
Represents postal service / mail delivery capacity. -
PublicTransport
Represents public transportation service capacity and usage. -
FireResponse
Represents fire service coverage and response capacity. -
Police
Represents police/public safety service coverage and capacity. -
Sewage
Represents sewage handling and wastewater services. -
Parking
Represents parking availability / parking service as a city resource. -
Count
A sentinel value representing the number of entries in the enum. Useful for loops, array allocation, and bounds checks: (int)PlayerResource.Count yields the total number of resource types.
Note: The enum is marked [Serializable] in source so it can be serialized by Unity/engine systems.
Properties
- Underlying value / intrinsic field:
public System.Int32 value__
All enum members map to integer values starting at 0 (Electricity = 0, Healthcare = 1, ...). Use explicit casts to convert between PlayerResource and int when needed.
Constructors
public PlayerResource()
(implicit)
Enums do not expose custom constructors; values are created by casting integers to the enum type or using the declared named members.
Methods
- None declared on this enum itself. Standard System.Enum methods are available (e.g., ToString(), HasFlag(), Enum.GetValues(), Enum.GetNames()).
Usage Example
// Read a resource value
PlayerResource res = PlayerResource.Water;
// Cast to int (for indexing arrays, etc.)
int idx = (int)res;
// Iterate over all resources using the Count sentinel
for (int i = 0; i < (int)PlayerResource.Count; i++)
{
PlayerResource r = (PlayerResource)i;
// process resource r (e.g., read stats, reset counters, display labels)
}
// Get all enum values
foreach (PlayerResource r in Enum.GetValues(typeof(PlayerResource)))
{
// This will include the Count sentinel, so skip if not needed:
if (r == PlayerResource.Count) continue;
// process r
}
Additional notes: - Use PlayerResource.Count for array sizing to ensure you allocate for all defined resources. - If the enum is extended in future updates (new resources added), existing code that relies on hard-coded sizes should be updated to use PlayerResource.Count to remain forward compatible.