Skip to content

Game.Vehicles.EnergyTypes

Assembly: (not specified)
Namespace: Game.Vehicles

Type: enum

Base: byte

Summary:
Enumeration representing the types of energy a vehicle can use. The underlying type is byte. The defined values allow representing fuel, electricity, both, or none. Note that FuelAndElectricity has the numeric value 3, which is the bitwise combination of Fuel (1) and Electricity (2), so the enum can be used in bitwise checks even though it is not annotated with the [Flags] attribute in the source.


Fields

  • Fuel = 1
    Represents vehicles that use fuel (internal-combustion). Value = 1.

  • Electricity = 2
    Represents vehicles that use electric power. Value = 2.

  • FuelAndElectricity = 3
    Represents vehicles that can use both fuel and electricity. Value = 3 (1 | 2).

  • None = 0
    Represents vehicles with no energy type or unspecified. Value = 0.

Properties

  • (none)
    This enum does not declare any properties. It only defines named constant values.

Constructors

  • (none declared)
    Enums do not have explicit constructors in user code. The runtime provides the default behavior for the underlying byte values.

Methods

  • (none declared)
    No methods are declared on this enum in the source file. Standard System.Enum/bitwise operations apply when used.

Usage Example

using Game.Vehicles;

public void HandleVehicleEnergy(EnergyTypes energy)
{
    // Check explicitly
    if (energy == EnergyTypes.Fuel)
    {
        // handle fuel-only vehicle
    }
    else if (energy == EnergyTypes.Electricity)
    {
        // handle electric vehicle
    }
    else if (energy == EnergyTypes.FuelAndElectricity)
    {
        // handle hybrid vehicle
    }
    else if (energy == EnergyTypes.None)
    {
        // no energy type
    }

    // Bitwise check (works because values are defined as bit flags, though [Flags] is not present)
    bool canUseElectric = (energy & EnergyTypes.Electricity) == EnergyTypes.Electricity;
    bool canUseFuel = (energy & EnergyTypes.Fuel) == EnergyTypes.Fuel;
}