Game.Triggers.TargetType
Assembly: Assembly-CSharp (game code assembly)
Namespace: Game.Triggers
Type: public enum
Base: System.Enum
Summary:
TargetType is a flags-backed enumeration used by the game's trigger system to specify which kinds of in-game objects a trigger targets. Because it is decorated with the [Flags] attribute, multiple target kinds can be combined using bitwise operations (|) to create composite target sets. Typical usages include checking whether a trigger applies to buildings, citizens, roads, etc.
Fields
-
Nothing = 0
Represents no target. Use as a default or to explicitly indicate "no selection". -
Building = 1
Targets buildings (standard building objects). -
Citizen = 2
Targets citizens (individual people entities). -
Policy = 4
Targets policies (city policies or toggles). -
Road = 8
Targets roads (street/road network elements). -
ServiceBuilding = 0x10
Targets service-specific buildings (e.g., police, fire, health service buildings). Value is 16.
Notes: values are powers of two to support bitwise combination. Use HasFlag or bitwise & to test membership.
Properties
This enum type defines no custom properties. It inherits standard behavior from System.Enum.
Constructors
Enums do not expose public constructors in C#; values are assigned at compile time. There are no custom constructors for TargetType.
Methods
No custom methods are defined on this enum. Standard System.Enum methods (ToString, HasFlag, etc.) are available.
Usage Example
// Combine targets: a trigger that applies to both buildings and service buildings
TargetType target = TargetType.Building | TargetType.ServiceBuilding;
// Check using bitwise &:
bool targetsService = (target & TargetType.ServiceBuilding) != 0;
// Or using HasFlag:
bool targetsBuilding = target.HasFlag(TargetType.Building);
// Example guard:
if (target == TargetType.Nothing)
{
// no-op or skip
}
Additional tips: - Prefer HasFlag for readability but be aware of boxing on some older runtimes; bitwise checks ((value & flag) != 0) are faster and avoid boxing. - When persisting or serializing combined flags, store the underlying integer value to preserve combinations.