Arcade
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
GameAPI.Tools Class Reference

Provides some helpful methods that don't belong anywhere else. More...

Classes

class  EventDelegate< THandler >
 

Static Public Member Functions

static string Pluralize (this string str, int count)
 Naïve conditional pluralization of a string based on the given contextual element count. Basically just adds an 's' to the end if count isn't 1. More...
 
static string Pluralize (this string singular, string plural, int count)
 Selects the appropriate string based on a contextual element count. More...
 
static string ToApproxString (this TimeSpan span)
 Formats a TimeSpan into a human readable approximation. More...
 
static bool Extends (this Type testType, Type baseType)
 Returns true if testType extends baseType. More...
 
static AStarEdge< T > Edge< T > (T dest, float cost)
 Convenience method to produce a graph connection for use when calling AStar(). More...
 
static T[] AStar< T > (T origin, T target, Func< T, IEnumerable< AStarEdge< T >>> adjFunc, Func< T, T, float > heuristicFunc)
 An implementation of the AStar path finding algorithm. More...
 
static void Shuffle< T > (this T[] array, Random rand=null)
 Fisher-Yates shuffling algorithm implementation. More...
 
static uint ReadVariableLength (this Stream stream)
 Reads an unsigned integer in the range 0 - 0x7fffffff that occupies either 2 or 4 bytes, depending on the magnitude of its value, as encoded by WriteVariableLength(). More...
 
static void WriteVariableLength (this Stream stream, uint value)
 writes an unsigned integer in the range 0 - 0x7fffffff as either 2 or 4 bytes, depending on the magnitude of its value, to be decoded by ReadVariableLength(). More...
 
static byte[] ReadBytes (this Stream stream, int count)
 
static string ToHexString (this byte[] bytes)
 
static void Clear (this Stream stream)
 
static Stream ClearWriteReset (this Stream stream, Action< Stream > write)
 
static bool HasAttribute< TAttribute > (this ICustomAttributeProvider obj, bool inherit)
 
static TAttribute GetAttribute< TAttribute > (this ICustomAttributeProvider obj, bool inherit)
 
static IEnumerable< TAttribute > GetAttributes< TAttribute > (this ICustomAttributeProvider obj, bool inherit)
 

Detailed Description

Provides some helpful methods that don't belong anywhere else.

Member Function Documentation

static T [] GameAPI.Tools.AStar< T > ( origin,
target,
Func< T, IEnumerable< AStarEdge< T >>>  adjFunc,
Func< T, T, float >  heuristicFunc 
)
inlinestatic

An implementation of the AStar path finding algorithm.

Template Parameters
TGraph node type.
Parameters
originNode to start path finding from.
targetThe goal node to reach.
adjFuncFunction returning the neighbouring connections for a node.
heuristicFuncFunction returning the estimated cost of travelling between two nodes.
Returns
A sequence of nodes representing a path if one is found, otherise an empty array.
static void GameAPI.Tools.Clear ( this Stream  stream)
inlinestatic
static Stream GameAPI.Tools.ClearWriteReset ( this Stream  stream,
Action< Stream >  write 
)
inlinestatic
static AStarEdge<T> GameAPI.Tools.Edge< T > ( dest,
float  cost 
)
inlinestatic

Convenience method to produce a graph connection for use when calling AStar().

Template Parameters
TGraph node type.
Parameters
destDestination node of the connection.
costCost of taking the connection.
static bool GameAPI.Tools.Extends ( this Type  testType,
Type  baseType 
)
inlinestatic

Returns true if testType extends baseType.

static TAttribute GameAPI.Tools.GetAttribute< TAttribute > ( this ICustomAttributeProvider  obj,
bool  inherit 
)
inlinestatic
Type Constraints
TAttribute :Attribute 
static IEnumerable<TAttribute> GameAPI.Tools.GetAttributes< TAttribute > ( this ICustomAttributeProvider  obj,
bool  inherit 
)
inlinestatic
Type Constraints
TAttribute :Attribute 
static bool GameAPI.Tools.HasAttribute< TAttribute > ( this ICustomAttributeProvider  obj,
bool  inherit 
)
inlinestatic
Type Constraints
TAttribute :Attribute 
static string GameAPI.Tools.Pluralize ( this string  str,
int  count 
)
inlinestatic

Naïve conditional pluralization of a string based on the given contextual element count. Basically just adds an 's' to the end if count isn't 1.

Parameters
strString to conditionally pluralize.
countContextual element count.
static string GameAPI.Tools.Pluralize ( this string  singular,
string  plural,
int  count 
)
inlinestatic

Selects the appropriate string based on a contextual element count.

Parameters
singularString to use if count is 1.
pluralString to use if count isn't 1.
countContextual element count.
static byte [] GameAPI.Tools.ReadBytes ( this Stream  stream,
int  count 
)
inlinestatic
static uint GameAPI.Tools.ReadVariableLength ( this Stream  stream)
inlinestatic

Reads an unsigned integer in the range 0 - 0x7fffffff that occupies either 2 or 4 bytes, depending on the magnitude of its value, as encoded by WriteVariableLength().

Parameters
streamStream to read from.
static void GameAPI.Tools.Shuffle< T > ( this T[]  array,
Random  rand = null 
)
inlinestatic

Fisher-Yates shuffling algorithm implementation.

Template Parameters
TArray element type.
Parameters
arrayArray to shuffle.
randOptional random number generator to use when shuffling.
static string GameAPI.Tools.ToApproxString ( this TimeSpan  span)
inlinestatic

Formats a TimeSpan into a human readable approximation.

Parameters
spanTimeSpan to format.
static string GameAPI.Tools.ToHexString ( this byte[]  bytes)
inlinestatic
static void GameAPI.Tools.WriteVariableLength ( this Stream  stream,
uint  value 
)
inlinestatic

writes an unsigned integer in the range 0 - 0x7fffffff as either 2 or 4 bytes, depending on the magnitude of its value, to be decoded by ReadVariableLength().

Parameters
streamStream to write to.
valueValue to write. Must be no larger than 0x7fffffff.