Skip to content

Game.Prefabs.GenderMask

Assembly:
Namespace: Game.Prefabs

Type: public enum

Base: System.Enum (underlying type: byte)

Summary:
GenderMask is a bit-flag enumeration used to represent one or more gender categories for prefabs, filters, or other game data. It is marked with the [Flags] attribute, so values can be combined with bitwise operations. The underlying type is byte, which keeps the storage footprint small. The special value Any is the combination of all defined gender bits and is commonly used as a wildcard/match-all.


Fields

  • Female = 1
    Represents the female gender bit (0x01). Can be combined with other bits.

  • Male = 2
    Represents the male gender bit (0x02). Can be combined with other bits.

  • Other = 4
    Represents a non-binary/other gender bit (0x04). Can be combined with other bits.

  • Any = 7
    Predefined combination (Female | Male | Other) (0x07). Use as a wildcard or to indicate all genders.

Properties

  • This enum does not define properties. Use the enum values directly and combine or test bits with bitwise operations or Enum.HasFlag.

Constructors

  • Enums do not expose custom constructors. Instances are represented by the enum values above.

Methods

  • The enum itself does not declare methods. Typical operations you will use in code:
  • Bitwise OR (|) to combine flags.
  • Bitwise AND (&) to test flags.
  • Enum.HasFlag for readability (note: HasFlag incurs boxing and is slower than bitwise checks).

Examples of checks: - (mask & GenderMask.Female) == GenderMask.Female — efficient check for presence of Female. - mask.HasFlag(GenderMask.Male) — readable, but less performant.

Usage Example

// Combine flags
GenderMask mask = GenderMask.Female | GenderMask.Other;

// Check for a specific gender (efficient)
bool hasFemale = (mask & GenderMask.Female) == GenderMask.Female;

// Check for a specific gender (readable)
bool hasMale = mask.HasFlag(GenderMask.Male);

// Use Any as a wildcard
if (mask == GenderMask.Any) {
    // mask contains all defined genders
}

// Example function that accepts a mask
void ApplyToGenders(GenderMask target) {
    if ((target & GenderMask.Male) != 0) {
        // apply male-specific logic
    }
    if ((target & GenderMask.Other) != 0) {
        // apply other-gender logic
    }
}

{{ This enum is intended for use in prefab definitions, filters, and gameplay logic where multiple gender categories may apply simultaneously. Prefer bitwise checks for performance-sensitive code; use Any when you need a match-all value. }}