UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MassEntityHandle.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "MassEntityHandle.generated.h"
6
11USTRUCT()
13{
15
16 FMassEntityHandle() = default;
18 : Index(InIndex), SerialNumber(InSerialNumber)
19 {
20 }
21
22 UPROPERTY(VisibleAnywhere, Category = "Mass|Debug", Transient)
24
25 UPROPERTY(VisibleAnywhere, Category = "Mass|Debug", Transient)
26 int32 SerialNumber = 0;
27
28 bool operator==(const FMassEntityHandle Other) const
29 {
30 return Index == Other.Index && SerialNumber == Other.SerialNumber;
31 }
32
34 {
35 return !operator==(Other);
36 }
37
39 bool operator<(const FMassEntityHandle Other) const { return Index < Other.Index; }
40
43 bool IsSet() const
44 {
45 return Index != 0 && SerialNumber != 0;
46 }
47
48 inline bool IsValid() const
49 {
50 return IsSet();
51 }
52
53 void Reset()
54 {
55 Index = SerialNumber = 0;
56 }
57
59 uint64 AsNumber() const { return *reinterpret_cast<const uint64*>(this); } // Relying on the fact that this struct only stores 2 integers and is aligned correctly.
62 {
63 FMassEntityHandle Result;
64 *reinterpret_cast<uint64_t*>(&Result) = Value;
65 return Result;
66 }
67
69 {
70 return HashCombine(Entity.Index, Entity.SerialNumber);
71 }
72
73 friend FString LexToString(const FMassEntityHandle Entity)
74 {
75 return Entity.DebugGetDescription();
76 }
77
78 FString DebugGetDescription() const
79 {
80 return FString::Printf(TEXT("i: %d sn: %d"), Index, SerialNumber);
81 }
82};
83
84static_assert(sizeof(FMassEntityHandle) == sizeof(uint64), "Expected FMassEntityHandle to be convertible to a 64-bit integer value, so size needs to be 8 bytes.");
85static_assert(alignof(FMassEntityHandle) == sizeof(uint64), "Expected FMassEntityHandle to be convertible to a 64-bit integer value, so alignment needs to be 8 bytes.");
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define USTRUCT(...)
Definition ObjectMacros.h:746
constexpr uint32 HashCombine(uint32 A, uint32 C)
Definition TypeHash.h:36
uint32_t uint32
Definition binka_ue_file_header.h:6
U16 Index
Definition radfft.cpp:71
Definition MassEntityHandle.h:13
bool operator<(const FMassEntityHandle Other) const
Definition MassEntityHandle.h:39
bool IsSet() const
Definition MassEntityHandle.h:43
bool IsValid() const
Definition MassEntityHandle.h:48
void Reset()
Definition MassEntityHandle.h:53
friend uint32 GetTypeHash(const FMassEntityHandle Entity)
Definition MassEntityHandle.h:68
FString DebugGetDescription() const
Definition MassEntityHandle.h:78
static FMassEntityHandle FromNumber(uint64 Value)
Definition MassEntityHandle.h:61
friend FString LexToString(const FMassEntityHandle Entity)
Definition MassEntityHandle.h:73
bool operator!=(const FMassEntityHandle Other) const
Definition MassEntityHandle.h:33
int32 Index
Definition MassEntityHandle.h:23
uint64 AsNumber() const
Definition MassEntityHandle.h:59