Impact Interaction System API
Impact.Utility.Extensions Class Reference

Static Public Member Functions

static int SetBit (this int bitmask, int pos)
 Sets the bit at the given position to 1. More...
 
static int UnsetBit (this int bitmask, int pos)
 Sets the bit at the given position to 0. More...
 
static bool IsBitSet (this int bitmask, int pos)
 Is the bit at the given position set to 1? More...
 
static T GetOrAddComponent< T > (this GameObject gameObject, bool checkParents)
 Either gets a component on the given game object or adds one. More...
 
static int IndexOf< T > (this T[] array, Predicate< T > predicate)
 Gets the index of the first element matching the given predicate. More...
 

Member Function Documentation

◆ GetOrAddComponent< T >()

static T Impact.Utility.Extensions.GetOrAddComponent< T > ( this GameObject  gameObject,
bool  checkParents 
)
static

Either gets a component on the given game object or adds one.

Template Parameters
TThe component type.
Parameters
gameObjectThe game object to get or add the component to.
checkParentsShould we look for the component in parent objects?
Returns
A reference to the existing or new component.
Type Constraints
T :Component 

◆ IndexOf< T >()

static int Impact.Utility.Extensions.IndexOf< T > ( this T[]  array,
Predicate< T >  predicate 
)
static

Gets the index of the first element matching the given predicate.

Template Parameters
TThe array type.
Parameters
arrayThe array.
predicateThe predicate to match.
Returns
The index of the first element matching the given predicate.

◆ IsBitSet()

static bool Impact.Utility.Extensions.IsBitSet ( this int  bitmask,
int  pos 
)
static

Is the bit at the given position set to 1?

Parameters
bitmaskThe bitmask to check against.
posThe index of the bit to check.
Returns
True if the bit is set to 1, false otherwise.

◆ SetBit()

static int Impact.Utility.Extensions.SetBit ( this int  bitmask,
int  pos 
)
static

Sets the bit at the given position to 1.

Parameters
bitmaskThe bitmask to modify.
posThe index of the bit to set.
Returns
The bitmask with the bit at the given position set to 1.

◆ UnsetBit()

static int Impact.Utility.Extensions.UnsetBit ( this int  bitmask,
int  pos 
)
static

Sets the bit at the given position to 0.

Parameters
bitmaskThe bitmask to modify.
posThe index of the bit to unset.
Returns
The bitmask with the bit at the given position set to 0.