Photon Quantum 3.0.1

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

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

Inherits IEquatable< NavMeshRegionMask >.

Public Member Functions

 NavMeshRegionMask (ulong regionMask1, ulong regionMask2=0UL, ulong regionMask3=0UL, ulong regionMask4=0UL, ulong regionMask5=0UL, ulong regionMask6=0UL, ulong regionMask7=0UL, ulong regionMask8=0UL)
 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...
 
readonly bool IsRegionEnabled (int region)
 Check if a region is active. More...
 
readonly bool IsSubset (in NavMeshRegionMask other)
 Check if the region mask is included inside the other. More...
 
readonly bool IsSuperset (in NavMeshRegionMask other)
 Check is the region mask of other is included in ours. More...
 
readonly bool Overlaps (in NavMeshRegionMask other)
 Returns true if the mask and other have at least one region in common. More...
 
void Remove (int region)
 Remove a region from the mask. More...
 
void Serialize (ByteStream stream, Boolean write, int blockCount=BLOCK_COUNT)
 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, in NavMeshRegionMask b)
 Combine two region masks. More...
 
static NavMeshRegionMask Create (int region)
 Create a NavMeshRegionMask with one region enabled. More...
 
static NavMeshRegionMask Create (int[] regionList)
 Create a mask using a list of region ids. More...
 
static NavMeshRegionMask Create (System.Collections.Generic.List< int > regionList)
 Create a mask using a list of region ids. 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

ulong Mask => _regions[0]
 Access to underlying bit mask. More...
 

Static Public Attributes

static NavMeshRegionMask Default => new NavMeshRegionMask(~0UL, ~0UL, ~0UL, ~0UL, ~0UL, ~0UL, ~0UL, ~0UL)
 Default mask with all regions toggled on. More...
 
static NavMeshRegionMask Empty => new NavMeshRegionMask(0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL)
 Mask that includes no area. More...
 
static NavMeshRegionMask MainArea => new NavMeshRegionMask(1UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 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...
 

Properties

readonly bool HasValidNoneMainRegion [get]
 Returns true if the mask includes a region other than the main area. More...
 
readonly bool HasValidRegions [get]
 Returns true if the mask has at least one valid region set including the main area. More...
 
readonly bool IsMainArea [get]
 Checks if the mask only contains the main area More...
 

Detailed Description

Internally stores a unsigned long to be able to toggle 512 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 isTriangleActive = f.Unsafe.GetPointer<NavMeshPathfinder>(entity)->RegionMask.Overlaps(*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 = 0UL,
ulong  regionMask3 = 0UL,
ulong  regionMask4 = 0UL,
ulong  regionMask5 = 0UL,
ulong  regionMask6 = 0UL,
ulong  regionMask7 = 0UL,
ulong  regionMask8 = 0UL 
)
inline

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

Parameters
regionMask1
regionMask2
regionMask3
regionMask4
regionMask5
regionMask6
regionMask7
regionMask8

Member Function Documentation

◆ Combine()

static NavMeshRegionMask Quantum.NavMeshRegionMask.Combine ( NavMeshRegionMask  a,
in 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() [1/3]

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

Create a NavMeshRegionMask with one region enabled.

Parameters
regionRegion id to enabled.
Returns
Region Mask

◆ Create() [2/3]

static NavMeshRegionMask Quantum.NavMeshRegionMask.Create ( int[]  regionList)
inlinestatic

Create a mask using a list of region ids.

Parameters
regionListList of region ids/indices
Returns
Region mask

◆ Create() [3/3]

static NavMeshRegionMask Quantum.NavMeshRegionMask.Create ( System.Collections.Generic.List< int >  regionList)
inlinestatic

Create a mask using a list of region ids.

Parameters
regionListList of region ids/indices
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()

readonly 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()

readonly bool Quantum.NavMeshRegionMask.IsSubset ( in 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()

readonly bool Quantum.NavMeshRegionMask.IsSuperset ( in 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

◆ Overlaps()

readonly bool Quantum.NavMeshRegionMask.Overlaps ( in NavMeshRegionMask  other)
inline

Returns true if the mask and other have at least one region in common.

Parameters
otherOther region mask
Returns
true if masks have one region in common

◆ 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,
int  blockCount = BLOCK_COUNT 
)
inline

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

Parameters
streamStream object.
writeWrite or read.
blockCountOptionally customize block count.

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, ~0UL, ~0UL, ~0UL, ~0UL, ~0UL, ~0UL)
static

Default mask with all regions toggled on.

◆ MainArea

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

Mask that includes only the main area.

◆ Empty

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

Mask that includes no area.

◆ Mask

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

Access to underlying bit mask.

Property Documentation

◆ HasValidRegions

readonly bool Quantum.NavMeshRegionMask.HasValidRegions
get

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

◆ HasValidNoneMainRegion

readonly bool Quantum.NavMeshRegionMask.HasValidNoneMainRegion
get

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

◆ IsMainArea

readonly bool Quantum.NavMeshRegionMask.IsMainArea
get

Checks if the mask only contains the main area