Table of Contents

Class Util

Namespace
AO
Assembly
CoreAssembly.dll
public static class Util
Inheritance
Util
Inherited Members

Methods

Assert(bool, string)

public static void Assert(bool condition, string message = null)

Parameters

condition bool
message string

DerivesFrom(Type, Type)

public static bool DerivesFrom(this Type derived, Type @base)

Parameters

derived Type
base Type

Returns

bool

FindAndOrderedRemoveOrDefault<T>(List<T>, Func<T, bool>)

public static T FindAndOrderedRemoveOrDefault<T>(this List<T> list, Func<T, bool> predicate)

Parameters

list List<T>
predicate Func<T, bool>

Returns

T

Type Parameters

T

FindAndUnorderedRemoveOrDefault<T>(List<T>, Func<T, bool>)

public static T FindAndUnorderedRemoveOrDefault<T>(this List<T> list, Func<T, bool> predicate)

Parameters

list List<T>
predicate Func<T, bool>

Returns

T

Type Parameters

T

FormatDouble(double, int, int, string, bool)

public static string FormatDouble(double value, int roundAtDigits = 4, int roundToDigits = 2, string separator = "", bool forceSign = false)

Parameters

value double
roundAtDigits int
roundToDigits int
separator string
forceSign bool

Returns

string

GetRandomIndex<T>(List<T>, Random)

public static int GetRandomIndex<T>(this List<T> list, Random rng = null)

Parameters

list List<T>
rng Random

Returns

int

Type Parameters

T

GetRandomIndex<T>(List<T>, ref ulong)

public static int GetRandomIndex<T>(this List<T> list, ref ulong rng)

Parameters

list List<T>
rng ulong

Returns

int

Type Parameters

T

GetRandomIndex<T>(T[], Random)

public static int GetRandomIndex<T>(this T[] array, Random rng = null)

Parameters

array T[]
rng Random

Returns

int

Type Parameters

T

GetRandomIndex<T>(T[], ref ulong)

public static int GetRandomIndex<T>(this T[] array, ref ulong rng)

Parameters

array T[]
rng ulong

Returns

int

Type Parameters

T

GetRandom<T>(List<T>, Random)

public static T GetRandom<T>(this List<T> list, Random rng = null)

Parameters

list List<T>
rng Random

Returns

T

Type Parameters

T

GetRandom<T>(List<T>, ref ulong)

public static T GetRandom<T>(this List<T> list, ref ulong rng)

Parameters

list List<T>
rng ulong

Returns

T

Type Parameters

T

GetRandom<T>(T[], Random)

public static T GetRandom<T>(this T[] array, Random rng = null)

Parameters

array T[]
rng Random

Returns

T

Type Parameters

T

GetRandom<T>(T[], ref ulong)

public static T GetRandom<T>(this T[] array, ref ulong rng)

Parameters

array T[]
rng ulong

Returns

T

Type Parameters

T

Has(string)

public static bool Has(this string str)

Parameters

str string

Returns

bool

IndexClamped<T>(T[], int)

public static T IndexClamped<T>(this T[] array, int index)

Parameters

array T[]
index int

Returns

T

Type Parameters

T

IsNullOrEmpty(string)

public static bool IsNullOrEmpty(this string str)

Parameters

str string

Returns

bool

Jitter(float, float)

public static float Jitter(float t, float freq = 16)

Parameters

t float
freq float

Returns

float

Lerp(float, float, float)

public static float Lerp(float a, float b, float t)

Parameters

a float
b float
t float

Returns

float

Modulo(int, int)

public static int Modulo(int a, int b)

Parameters

a int
b int

Returns

int

NextDouble(Random, double, double)

public static double NextDouble(this Random rng, double lo = 0, double hi = 1)

Parameters

rng Random
lo double
hi double

Returns

double

NextFloat(Random, float, float)

public static float NextFloat(this Random rng, float lo = 0, float hi = 1)

Parameters

rng Random
lo float
hi float

Returns

float

OneTime(bool, ref bool)

public static bool OneTime(bool condition, ref bool alreadyDone)

Parameters

condition bool
alreadyDone bool

Returns

bool

OrderedRemoveAt<T>(List<T>, int)

public static void OrderedRemoveAt<T>(this List<T> list, int index)

Parameters

list List<T>
index int

Type Parameters

T

OrderedRemove<T>(List<T>, T)

public static void OrderedRemove<T>(this List<T> list, T element)

Parameters

list List<T>
element T

Type Parameters

T

Pluralize(string, string, int)

public static string Pluralize(string singular, string plural, int count)

Parameters

singular string
plural string
count int

Returns

string

PopFront<T>(List<T>)

public static T PopFront<T>(this List<T> list)

Parameters

list List<T>

Returns

T

Type Parameters

T

Pop<T>(List<T>)

public static T Pop<T>(this List<T> list)

Parameters

list List<T>

Returns

T

Type Parameters

T

Punch(float)

public static float Punch(float t)

Parameters

t float

Returns

float

RandomPositionInBox(Vector2, Vector2, Random)

public static Vector2 RandomPositionInBox(Vector2 min, Vector2 max, Random rng)

Parameters

min Vector2
max Vector2
rng Random

Returns

Vector2

RandomPositionInBox(ref ulong, Vector2, Vector2)

public static Vector2 RandomPositionInBox(ref ulong rng, Vector2 min, Vector2 max)

Parameters

rng ulong
min Vector2
max Vector2

Returns

Vector2

RandomPositionOnUnitCircle(ref ulong)

public static Vector2 RandomPositionOnUnitCircle(ref ulong rng)

Parameters

rng ulong

Returns

Vector2

RandomPositionOnUnitDisc(ref ulong)

public static Vector2 RandomPositionOnUnitDisc(ref ulong rng)

Parameters

rng ulong

Returns

Vector2

RemoveRandom<T>(List<T>, Random)

public static T RemoveRandom<T>(this List<T> list, Random rng = null)

Parameters

list List<T>
rng Random

Returns

T

Type Parameters

T

RollClustered(Random, int, int, float)

public static int RollClustered(Random rng, int lo, int hi, float clustering)

Parameters

rng Random
lo int
hi int
clustering float

Returns

int

RollClustered(ref ulong, int, int, float)

public static int RollClustered(ref ulong rng, int lo, int hi, float clustering)

Parameters

rng ulong
lo int
hi int
clustering float

Returns

int

SampleParabolaArc(float, float, float)

public static float SampleParabolaArc(float height, float range, float x)

Parameters

height float
range float
x float

Returns

float

SampleWeightedList<T>(List<T>, Func<T, int>, Random)

public static (T, int) SampleWeightedList<T>(List<T> list, Func<T, int> weightGetter, Random rng = null)

Parameters

list List<T>
weightGetter Func<T, int>
rng Random

Returns

(T, int)

Type Parameters

T

SampleWeightedList<T>(List<T>, ref ulong, Func<T, int>)

public static (T, int) SampleWeightedList<T>(this List<T> list, ref ulong rng, Func<T, int> weightGetter)

Parameters

list List<T>
rng ulong
weightGetter Func<T, int>

Returns

(T, int)

Type Parameters

T

Shuffle<T>(List<T>, Random)

public static void Shuffle<T>(this List<T> list, Random rng = null)

Parameters

list List<T>
rng Random

Type Parameters

T

Shuffle<T>(List<T>, ref ulong)

public static void Shuffle<T>(this List<T> list, ref ulong rng)

Parameters

list List<T>
rng ulong

Type Parameters

T

Timer(ref double, double)

public static bool Timer(ref double acc, double time)

Parameters

acc double
time double

Returns

bool

Timer(ref float, float)

public static bool Timer(ref float acc, float time)

Parameters

acc float
time float

Returns

bool

TryGetClosest<T>(List<T>, Vector2, float)

public static T TryGetClosest<T>(List<T> list, Vector2 point, float range = 3.4028235E+38) where T : Component

Parameters

list List<T>
point Vector2
range float

Returns

T

Type Parameters

T

UnorderedRemoveAt<T>(List<T>, int)

public static void UnorderedRemoveAt<T>(this List<T> list, int index)

Parameters

list List<T>
index int

Type Parameters

T

UnorderedRemove<T>(List<T>, T)

public static void UnorderedRemove<T>(this List<T> list, T element) where T : class

Parameters

list List<T>
element T

Type Parameters

T