Last active
May 3, 2018 08:39
-
-
Save dorgonman/2fcb2068fdd4d044ebba7f8e5e299870 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UENUM(BlueprintType, meta = (Bitflags)) | |
enum class EHorizonPlayerSortType : uint8 | |
{ | |
Invalidated = 0, | |
Level UMETA(DisplayName = "PlayerLevel"), | |
Power UMETA(DisplayName = "Power"), | |
Speed UMETA(DisplayName = "Speed"), | |
PlaceHolder1 UMETA(DisplayName = "PlaceHolder1"), | |
PlaceHolder2 UMETA(DisplayName = "PlaceHolder2"), | |
PlaceHolder3 UMETA(DisplayName = "PlaceHolder3"), | |
PlaceHolder4 UMETA(DisplayName = "PlaceHolder4"), | |
}; | |
ENUM_CLASS_FLAGS(EHorizonPlayerSortType) | |
USTRUCT(BlueprintType) | |
struct HORIZONTWEEN_API FHorizonPlayerParameters | |
{ | |
GENERATED_BODY() | |
FHorizonPlayerParameters() | |
: PlayerSortTypeFlags((int)EHorizonPlayerSortType::Level) | |
{ | |
} | |
public: | |
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (Bitmask, BitmaskEnum = "EHorizonPlayerSortType")) | |
int PlayerSortTypeFlags; | |
}; | |
bool HasFlag(const int32& Flags, EHorizonPlayerSortType TestFlag) | |
{ | |
int32 bitFlag = static_cast<int32>(1 << (int32)TestFlag); //shift to the bit corresponding to the enum value | |
return (Flags & bitFlag ) != 0; | |
} | |
void Usage(const FHorizonPlayerParameters& param){ | |
int32 bitFlag = static_cast<int32>((1 << (INT32)EHorizonPlayerSortType::Level) | | |
(1 << (INT32)EHorizonPlayerSortType::Speed)); // 10 | |
bool b1 = HasFlag(param.PlayerSortTypeFlags, EHorizonPlayerSortType::Level); //true | |
bool b2 = HasFlag(param.PlayerSortTypeFlags, EHorizonPlayerSortType::Power); //false | |
bool b3 = HasFlag(param.PlayerSortTypeFlags, EHorizonPlayerSortType::Speed); //true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment