Photon Quantum 3.0.0

Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Quantum.NavMeshRegionMask Struct Reference

Internally stores a unsigned long to be able to toggle 128 different regions. More...

Inherits IEquatable< NavMeshRegionMask >.

Public Member Functions

 NavMeshRegionMask (ulong regionMask1, ulong regionMask2)
 Constructor with all flag masks. This method could change in the future if the max regions count is increased again. More...
 
 NavMeshRegionMask (ulong regions)
 Constructor. More...
 
void Add (int region)
 Add a region id to the mask. More...
 
void Clear ()
 This sets all regions to active. More...
 
bool Equals (NavMeshRegionMask other)
 Equality check. More...
 
override bool Equals (object obj)
 Equality check. More...
 
override int GetHashCode ()
 Get hash code override. More...
 
bool IsRegionEnabled (int region)
 Check if a region is active. More...
 
bool IsSubset (NavMeshRegionMask other)
 Check if the region mask is included inside the other. More...
 
bool IsSuperset (NavMeshRegionMask other)
 Check is the region mask of other is included in ours. More...
 
void Remove (int region)
 Remove a region from the mask. More...
 
void Serialize (ByteStream stream, Boolean write)
 Serialize the mask into a byte stream, used by asset serialization and deserialization. More...
 
void ToggleRegion (int region, bool enabled)
 Toggle a region by id (or index). More...
 
override string ToString ()
 ToString override. More...
 

Static Public Member Functions

static NavMeshRegionMask Combine (NavMeshRegionMask a, NavMeshRegionMask b)
 Combine two region masks. More...
 
static NavMeshRegionMask Create (int region)
 Create a NavMeshRegionMask with one region enabled. More...
 
static void Print (void *ptr, FramePrinter printer)
 Callback to print this component data. More...
 
static void Serialize (void *ptr, FrameSerializer serializer)
 Callback to serialize this component into a snapshot of the game state. More...
 

Public Attributes

bool HasValidNoneMainRegion => _regions[0] > 1UL || _regions[1] != 0UL
 Returns true if the mask includes a region other than the main area. More...
 
bool HasValidRegions => _regions[0] >= 1UL || _regions[1] != 0UL
 Returns true if the mask has at least one valid region set including the main area. More...
 
bool IsMainArea => _regions[0] == 1UL && _regions[1] == 0UL
 Checks if the mask only contains the main area More...
 
ulong Mask => _regions[0]
 Access to underlying bit mask. More...
 

Static Public Attributes

static NavMeshRegionMask Default => new NavMeshRegionMask(~0UL, ~0UL)
 Default mask with all regions toggled on. More...
 
static NavMeshRegionMask Empty => new NavMeshRegionMask(0UL, 0UL)
 Mask that includes no area. More...
 
static NavMeshRegionMask MainArea => new NavMeshRegionMask(1UL, 0UL)
 Mask that includes only the main area. More...
 
const int MAX_REGIONS = BLOCK_COUNT * BITS_PER_BLOCK
 The maximum number of regions. More...
 
const int SIZE = BLOCK_COUNT * sizeof(ulong)
 The size on the struct. More...
 

Detailed Description

Internally stores a unsigned long to be able to toggle 128 different regions.

When instantiating a NavMeshRegionMask, all regions are toggled off.

Use Default to create a mask with all regions toggled on.

// Toggle a region per frame
f.NavMeshRegionMask->ToggleRegion(cmd.Region, !f.NavMeshRegionMask->IsRegionEnabled(cmd.Region));
// Check if a region id is active
var isRegionActive = f.NavMeshRegionMask->IsRegionEnabled(regionId);
// Check if a NavMeshRegionMask (found on the pathfinder component) is active
var isRegionAcitve = f.Unsafe.GetPointer<NavMeshPathfinder>(entity)->RegionMask.IsSubset(*f.NavMeshRegionMask);

Constructor & Destructor Documentation

◆ NavMeshRegionMask() [1/2]

Quantum.NavMeshRegionMask.NavMeshRegionMask ( ulong  regions)
inline

Constructor.

Parameters
regionsRaw region mask

◆ NavMeshRegionMask() [2/2]

Quantum.NavMeshRegionMask.NavMeshRegionMask ( ulong  regionMask1,
ulong  regionMask2 
)
inline

Constructor with all flag masks. This method could change in the future if the max regions count is increased again.

Parameters
regionMask1
regionMask2

Member Function Documentation

◆ Combine()

static NavMeshRegionMask Quantum.NavMeshRegionMask.Combine ( NavMeshRegionMask  a,
NavMeshRegionMask  b 
)
inlinestatic

Combine two region masks.

Parameters
aA
bB
Returns
A region must be active in both masks for be toggled on on the resulting mask.

◆ Serialize() [1/2]

static void Quantum.NavMeshRegionMask.Serialize ( void *  ptr,
FrameSerializer  serializer 
)
inlinestatic

Callback to serialize this component into a snapshot of the game state.

Parameters
ptrThe component pointer
serializerThe serializer

◆ Print()

static void Quantum.NavMeshRegionMask.Print ( void *  ptr,
FramePrinter  printer 
)
inlinestatic

Callback to print this component data.

Parameters
ptrThe component pointer
printerThe printer

◆ Create()

static NavMeshRegionMask Quantum.NavMeshRegionMask.Create ( int  region)
inlinestatic

Create a NavMeshRegionMask with one region enabled.

Parameters
regionRegion id to enabled.
Returns
Region Mask

◆ ToggleRegion()

void Quantum.NavMeshRegionMask.ToggleRegion ( int  region,
bool  enabled 
)
inline

Toggle a region by id (or index).

Parameters
regionRegion id (defined by the region list inside the Map)
enabledToggle region on or off

◆ Add()

void Quantum.NavMeshRegionMask.Add ( int  region)
inline

Add a region id to the mask.

Parameters
regionRegion index

◆ Remove()

void Quantum.NavMeshRegionMask.Remove ( int  region)
inline

Remove a region from the mask.

Parameters
regionRegion index

◆ IsRegionEnabled()

bool Quantum.NavMeshRegionMask.IsRegionEnabled ( int  region)
inline

Check if a region is active.

Parameters
regionRegion id (or index)
Returns
true if the region is active.

◆ IsSubset()

bool Quantum.NavMeshRegionMask.IsSubset ( NavMeshRegionMask  other)
inline

Check if the region mask is included inside the other.

Parameters
otherOther mask, usually the one from Frame
Returns
true if all regions are included in other

◆ IsSuperset()

bool Quantum.NavMeshRegionMask.IsSuperset ( NavMeshRegionMask  other)
inline

Check is the region mask of other is included in ours.

Parameters
otherOther region mask
Returns
true if all regions inside the other mask are also active in ours

◆ Clear()

void Quantum.NavMeshRegionMask.Clear ( )
inline

This sets all regions to active.

◆ Equals() [1/2]

bool Quantum.NavMeshRegionMask.Equals ( NavMeshRegionMask  other)
inline

Equality check.

Parameters
otherOther mask
Returns
true, if both masks are equal.

◆ Equals() [2/2]

override bool Quantum.NavMeshRegionMask.Equals ( object  obj)
inline

Equality check.

Parameters
objOther object
Returns
true, is both masks are equal.

◆ GetHashCode()

override int Quantum.NavMeshRegionMask.GetHashCode ( )
inline

Get hash code override.

Returns
Hashcode of this mask.

◆ ToString()

override string Quantum.NavMeshRegionMask.ToString ( )
inline

ToString override.

Returns
A debug string representation of the mask.

◆ Serialize() [2/2]

void Quantum.NavMeshRegionMask.Serialize ( ByteStream  stream,
Boolean  write 
)
inline

Serialize the mask into a byte stream, used by asset serialization and deserialization.

Parameters
streamStream object.
writeWrite or read.

Member Data Documentation

◆ SIZE

const int Quantum.NavMeshRegionMask.SIZE = BLOCK_COUNT * sizeof(ulong)
static

The size on the struct.

◆ MAX_REGIONS

const int Quantum.NavMeshRegionMask.MAX_REGIONS = BLOCK_COUNT * BITS_PER_BLOCK
static

The maximum number of regions.

◆ Default

NavMeshRegionMask Quantum.NavMeshRegionMask.Default => new NavMeshRegionMask(~0UL, ~0UL)
static

Default mask with all regions toggled on.

◆ MainArea

NavMeshRegionMask Quantum.NavMeshRegionMask.MainArea => new NavMeshRegionMask(1UL, 0UL)
static

Mask that includes only the main area.

◆ Empty

NavMeshRegionMask Quantum.NavMeshRegionMask.Empty => new NavMeshRegionMask(0UL, 0UL)
static

Mask that includes no area.

◆ HasValidRegions

bool Quantum.NavMeshRegionMask.HasValidRegions => _regions[0] >= 1UL || _regions[1] != 0UL

Returns true if the mask has at least one valid region set including the main area.

◆ HasValidNoneMainRegion

bool Quantum.NavMeshRegionMask.HasValidNoneMainRegion => _regions[0] > 1UL || _regions[1] != 0UL

Returns true if the mask includes a region other than the main area.

◆ IsMainArea

bool Quantum.NavMeshRegionMask.IsMainArea => _regions[0] == 1UL && _regions[1] == 0UL

Checks if the mask only contains the main area

◆ Mask

ulong Quantum.NavMeshRegionMask.Mask => _regions[0]

Access to underlying bit mask.