Game.Buildings.ElectricityConsumerFlags
Assembly: Assembly-CSharp (game assembly)
Namespace: Game.Buildings
Type: public enum (flags)
Base: System.Enum (underlying type: System.Byte)
Summary: ElectricityConsumerFlags is a bitmask enum used to represent the electricity-related state and UI warning flags for a building's electricity consumer component. The [Flags] attribute allows combining multiple values to represent composite states (for example, Connected combined with BottleneckWarning). The underlying storage is a byte, which is suitable for compact storage in large building arrays.
Fields
-
None = 0
Represents no flags set — the consumer has no special electricity state or warnings. -
Connected = 1
Indicates the consumer is connected to the electrical network (has a power connection). -
NoElectricityWarning = 2
Indicates that a "no electricity" warning should be shown for this consumer (e.g., building lacks power). Can be combined with other flags. -
BottleneckWarning = 4
Indicates a bottleneck/power capacity warning for the consumer (e.g., insufficient power throughput). Can be combined with other flags.
Properties
- This enum type does not declare properties. Use enum values directly and standard System.Enum/bitwise operations to examine or modify flags.
Constructors
- Enums do not declare custom constructors. The default value (0) corresponds to ElectricityConsumerFlags.None.
Methods
- The enum itself does not define instance methods beyond those provided by System.Enum and System.ValueType. Commonly used operations include:
- Bitwise operations (|, &, ~) to combine, test, and remove flags.
- Enum.HasFlag(ElectricityConsumerFlags flag) to test for a flag (convenient but slightly slower than bitwise test).
- Casting to/from the underlying byte when you need compact storage or interop.
Examples of common checks: - (flags & ElectricityConsumerFlags.Connected) != 0 — fast check for Connected. - flags.HasFlag(ElectricityConsumerFlags.NoElectricityWarning) — readable check using HasFlag.
Usage Example
// Set multiple flags
var flags = ElectricityConsumerFlags.Connected | ElectricityConsumerFlags.BottleneckWarning;
// Test flags (fast bitwise check)
bool isConnected = (flags & ElectricityConsumerFlags.Connected) != 0;
// Test flags (readable, uses Enum.HasFlag)
bool hasNoPowerWarning = flags.HasFlag(ElectricityConsumerFlags.NoElectricityWarning);
// Remove a flag
flags &= ~ElectricityConsumerFlags.BottleneckWarning;
// Store/restore from a byte field (for compact storage)
byte stored = (byte)flags;
var restored = (ElectricityConsumerFlags)stored;
Notes: - Prefer bitwise checks ((flags & FLAG) != 0) in performance-sensitive code (e.g., hot loops updating many buildings). - Because the enum is backed by a byte, it is suitable for packing into compact arrays or structs used by the game's simulation systems.