Skip to content

Instantly share code, notes, and snippets.

@xepherys
Created November 5, 2019 01:33
Show Gist options
  • Save xepherys/c4c47a83c18315591c97392f91fb28ff to your computer and use it in GitHub Desktop.
Save xepherys/c4c47a83c18315591c97392f91fb28ff to your computer and use it in GitHub Desktop.
BitFlag Enum
[System.Flags]
public enum LaserDirection
{
NONE = 0,
NORTH = 1 << 0,
NORTHEAST = 1 << 1,
EAST = 1 << 2,
SOUTHEAST = 1 << 3,
SOUTH = 1 << 4,
SOUTHWEST = 1 << 5,
WEST = 1 << 6,
NORTHWEST = 1 << 7,
OMNI = ~(~0 << 8)
}
// [System.Flags] sets the enum as a bitflag type
// NONE = 0 gives the option to have no values set
// each additional value takes 1 << x as the bitshifted value
// the final value is an "ALL" value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment