Photon Quantum 2.1.1

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 64 different regions. More...

Inherits IEquatable< NavMeshRegionMask >.

Public Member Functions

 NavMeshRegionMask (ulong regions)
 Constructor. More...
 
void Clear ()
 This sets all regions to active. 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 ToggleRegion (int region, bool enabled)
 Toggle a region by id (or index). More...
 

Static Public Member Functions

static NavMeshRegionMask Combine (NavMeshRegionMask a, NavMeshRegionMask b)
 Combine two region masks. More...
 

Public Attributes

bool HasValidRegions => _regions != 0
 Returns true, when the mask has exactly one valid region set. More...
 
bool IsMainArea => _regions == 0
 Checks if the mask is zero which will be true for triangles belonging to the main navmesh area and cannot be toggled off. More...
 
ulong Mask => _regions
 Access to underlying bit mask. More...
 

Static Public Attributes

static NavMeshRegionMask Default => new NavMeshRegionMask(~0UL)
 All regions toggled on. More...
 

Detailed Description

Internally stores a unsigned long to be able to toggle 64 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()

Quantum.NavMeshRegionMask.NavMeshRegionMask ( ulong  regions)
inline

Constructor.

Parameters
regionsRaw region mask

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.

◆ 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

◆ 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.

Member Data Documentation

◆ Default

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

All regions toggled on.

◆ HasValidRegions

bool Quantum.NavMeshRegionMask.HasValidRegions => _regions != 0

Returns true, when the mask has exactly one valid region set.

◆ IsMainArea

bool Quantum.NavMeshRegionMask.IsMainArea => _regions == 0

Checks if the mask is zero which will be true for triangles belonging to the main navmesh area and cannot be toggled off.

◆ Mask

ulong Quantum.NavMeshRegionMask.Mask => _regions

Access to underlying bit mask.