MW UNITY NAMESPACE








































public static class

Utils


Helper Variables and Functions.



public static bool

InFOV (Vector3 Face, Vector3 Self, Vector3 Target, float SearchAngle)

Summary:

If Self can see Target within SearchAngle degrees while facing Face.

Params:

Face:

        The direction Self is facing.

Self:

        The Transform searching for Target.

Target:

        The position to look out for.

SearchAngle:

        The maximum degrees to search for Target.

Returns:

True if Self can see Target within SearchAngle while facing Face.



public static bool

InFOV (Vector3 Face, Transform Self, Vector3 Target, float SearchAngle)

Summary:

If Self can see Target within SearchAngle degrees while facing Face.

Params:

Face:

        The direction Self is facing.

Self:

        The Transform searching for Target.

Target:

        The position to look out for.

SearchAngle:

        The maximum degrees to search for Target.

Returns:

True if Self can see Target within SearchAngle while facing Face.



public static bool

LineOfSight (Vector3 Self, Vector3 To, LayerMask Obstacles)

Summary:

If Self has an unobstructed line of sight to To.

Params:

Self:

        The Vector3 position to look from.

To:

        The Vector3 position to look to.

Obstacles:

        The LayerMask obstacles to consider obtrusive.



public static bool

LineOfSight (Vector3 Self, Vector3 To)

Summary:

If Self has an unobstructed line of sight to To.

Params:

Self:

        The Vector3 position to look from.

To:

        The Vector3 position to look to.



public static float

RoundToDP (float Value, int DecimalPlaces)

Summary:

The Value rounded to DecimalPlaces.

Params:

Value:

        The value to be rounded.

DecimalPlaces:

        The decimal places to be included.



public static void

FlipFlop (bool& bBool)

Summary:

Flip-Flops bBool.



public static void

FlipFlop (bool& bBool, Action CallbackTrue, Action CallbackFalse)

Summary:

Flip-Flops bBool.

CallbackTrue:

        The method to call if the flip-flop is true.

CallbackFalse:

        The method to call if the flip-flop is false.



public static bool

IsWithin (float Value, float From, float Limit)

Summary:

If Value is within the +- Limit of From.

Params:

Value:

        The value to check.

From:

        The value to compare.

Limit:

        The limits to consider.



public static Vector3

Max (Vector3 L, Vector3 R)

Summary:

The largest Vector3 between L and R, according to Vector3.sqrMagnitude.



public static Vector3

Min (Vector3 L, Vector3 R)

Summary:

The largest Vector3 between L and R, according to Vector3.sqrMagnitude.



public static int

Fibonacci (int N)

Summary:

Returns the N'th Fibonacci number.



public static Vector3[]

GenerateEqualSphere (int Resolution, float GoldenRatioModifier)

Summary:

Generates spherical points with an equal distribution.

Params:

Resolution:

        The number of points to generate.

GoldenRatioModifier:

        Adjusts the golden ratio.

Returns:

The Vector3[] points for the sphere.



public static Vector3[]

Bridge (MVector Origin, MVector Target, int Resolution, float Height)

Summary:

Generates the points to 'bridge' Origin and Target together at a Height as an arc.

Params:

Origin:

        The Vector3 starting point of the bridge.

Target:

        The Vector3 ending point of the bridge.

Resolution:

        The number of points for the bridge.

Height:

        The maximum height of the bridge.

Returns:

The Vector3[] points for the bridge.



public static float

MirrorNumber (float Number, float Minimum, float Maximum)

Summary:

Mirrors Number about Minimum and Maximum, inclusive.

Params:

Number:

        The number to anchor a reflection.

Minimum:

        The minimum number that can be reflected.

Maximum:

        The maximum number that can be reflected.

Returns:

The reflected number.



public static int

MirrorNumber (int Number, int Minimum, int Maximum)

Summary:

Mirrors Number about Minimum and Maximum, inclusive. Not to be confused with MArray.Reflect(int, int).

Params:

Number:

        The number to anchor a reflection.

Minimum:

        The minimum number that can be reflected.

Maximum:

        The maximum number that can be reflected.

Returns:

The reflected number.



public static void

SwapT (T& L, T& R)

Summary:

Swaps L and R.



public static void

Clamp (int& I, int Min, int Max)

Summary:

Clamps I to be between Min and Max.

Params:

I:

        A reference to the Integer to clamp.

Min:

        The Minimum value of I.

Max:

        The Maximum value of I.



public static void

ClampMin (int& I, int Min)

Summary:

Clamps I to not fall below Min.

Params:

I:

        A reference to the Integer to clamp.

Min:

        The Minimum value I can be.



public static void

ClampMax (int& I, int Max)

Summary:

Clamps I to not exceed Max.

Params:

I:

        A reference to the Integer to clamp.

Max:

        The Maximum value I can be.



public static void

ClampMin (float& F, float Min)

Summary:

Clamps F to not fall below Min.

Params:

F:

        A reference to the Float to clamp.

Min:

        The Minimum value F can be.



public static void

ClampMax (float& F, float Max)

Summary:

Clamps F to not exceed Max.

Params:

F:

        A reference to the Float to clamp.

Max:

        The Maximum value F can be.



public static void

Clamp (float& F, float Min, float Max)

Summary:

Clamps F to be between Min and Max.

Params:

F:

        A reference to the Float to clamp.

Min:

        The Minimum value of F.

Max:

        The Maximum value of F.



public static float

Max (float F1, float F2)

Summary:

The larger value between F1 and F2.

Returns:

The larger of the two given floats.



public static float

Min (float F1, float F2)

Summary:

The smaller value between F1 and F2.

Returns:

The smaller of the two given floats.



public static int

Max (int I1, int I2)

Summary:

The larger value between I1 and I2.

Returns:

The larger of the two given ints.



public static int

Min (int I1, int I2)

Summary:

The smaller value between I1 and I2.

Returns:

The smaller of the two given ints.



public static void

Abs (int& I)

Summary:

Modifies I to be its Absolute Value.

Remarks:

Ref& version of FastAbs().

Params:

I:

        A reference to the int to modify.



public static void

Abs (float& F)

Summary:

Modifies F to be its Absolute Value.

Remarks:

Ref& version of FastAbs().

Params:

F:

        A reference to the float to modify.



public static MVector

Abs (MVector V)

Summary:

Abs() on all V's components.

Params:

V:

        The Vector to Abs.

Returns:

An MVector with all positive components.



public static void

Abs (MVector& V)

Summary:

Modifies V to be positive on all components.

Params:

V:

        The Vector to modify.



public static bool

IsZero (float F, float Tolerance)

Summary:

Whether or not a float is considered to be zero.

Params:

F:

        The float to check.

Tolerance:

        The threshold for F to be considered zero.

Returns:

True if F is +- Tolerance of zero.



public static void

LockCursor (bool bLockCursor, bool bHideCursorOnLock)

Summary:

Locks or unlocks the Cursor and optionally hide it.

Remarks:

Unlocking the cursor will always enable the Cursor's visibility.

Params:

bLockCursor:

        True to lock the Cursor.

bHideCursorOnLock:

        True to hide the Cursor when it's locked.



public static int

FPS ()

Summary:

Gets the number of frames per second during runtime.

Returns:

The number of frames per second.



public static IEnumerator

Delay (MonoBehaviour Owner, float Seconds, Action Function)

Summary:

Executes a Delayed call to Function after Seconds by Owner.

Params:

Owner:

        The MonoBehaviour which owns this delayed call.

Seconds:

        The number of seconds to wait until Function is called.

Function:

        The Function to execute after Seconds has elapsed.

Returns:

The IEnumerator responsible for handling this delayed call.



public static IEnumerator

Delay (MonoBehaviour Owner, IEnumerator Dependent, Action Function)

Summary:

Executes a Delayed call to Function after another Dependent delayed call by Owner.

Params:

Owner:

        The MonoBehaviour which owns this delayed call.

Dependent:

        The other delayed call to wait until Function can be executed.

Function:

        The Function to execute after Dependent has finished.

Returns:

The IEnumerator responsible for handling this delayed call.



public static IEnumerator

Delay (MonoBehaviour Owner, IEnumerator Dependent, float AdditionalSeconds, Action Function)

Summary:

Executes a Delayed call to Function after a Dependent delayed call, followed by AdditionalSeconds, by Owner.

Params:

Owner:

        The MonoBehaviour which owns this delayed call.

Dependent:

        The other delayed call to wait until Function can be executed.

AdditionalSeconds:

        The number of seconds to wait after Dependent has finished.

Function:

        The Function to execute after Dependent has finished and AdditionalSeconds has elapsed.

Returns:

The IEnumerator responsible for handling this delayed call.



public static float

Compare (string BaseString, string CompString, bool bCaseSensitive, bool bConsiderSpaces)

Summary:

Compares two strings for similarity.

Params:

BaseString:

        The string to compare against.

CompString:

        The string to compare to.

bCaseSensitive:

        True to consider character casing in the similarity calculation.

bConsiderSpaces:

        True to consider space ' ' characters in the similarity calculation.

Returns:

A score between 0 to 1 depending on how similar CompString is to BaseString. 0 = Completely different, 1 = Identical.