M&B: Bannerlord 1.0.0
The horns sound, the ravens gather.
Loading...
Searching...
No Matches
TaleWorlds.Core.Extensions Class Reference

Static Public Member Functions

static string ToHexadecimalString (this uint number)
 Converts the numeric value of this instance to its equivalent hexadecimal string representation. More...
 
static string Description (this Enum value)
 
static float NextFloat (this Random random)
 Returns a random number between 0.0f and 1.0f. More...
 
static TSource MaxBy< TSource, TKey > (this IEnumerable< TSource > source, Func< TSource, TKey > selector)
 Returns the maximal element of the given sequence, based on the given projection. More...
 
static TSource MaxBy< TSource, TKey > (this IEnumerable< TSource > source, Func< TSource, TKey > selector, out TKey maxKey)
 Returns the maximal element of the given sequence, based on the given projection. More...
 
static TSource MaxBy< TSource, TKey > (this IEnumerable< TSource > source, Func< TSource, TKey > selector, IComparer< TKey > comparer, out TKey maxKey)
 Returns the maximal element of the given sequence, based on the given projection and the specified comparer for projected values. More...
 
static TSource MinBy< TSource, TKey > (this IEnumerable< TSource > source, Func< TSource, TKey > selector)
 Returns the minimal element of the given sequence, based on the given projection. More...
 
static TSource MinBy< TSource, TKey > (this IEnumerable< TSource > source, Func< TSource, TKey > selector, IComparer< TKey > comparer)
 Returns the minimal element of the given sequence, based on the given projection and the specified comparer for projected values. More...
 
static IEnumerable< TSource > DistinctBy< TSource, TKey > (this IEnumerable< TSource > source, Func< TSource, TKey > keySelector)
 Returns all distinct elements of the given source, where "distinctness" is determined via a projection and the default equality comparer for the projected type. More...
 
static IEnumerable< TSource > DistinctBy< TSource, TKey > (this IEnumerable< TSource > source, Func< TSource, TKey > keySelector, IEqualityComparer< TKey > comparer)
 Returns all distinct elements of the given source, where "distinctness" is determined via a projection and the specified comparer for the projected type. More...
 
static string Add (this string str, string appendant, bool newLine=true)
 
static IEnumerable< string > Split (this string str, int maxChunkSize)
 
static BattleSideEnum GetOppositeSide (this BattleSideEnum side)
 
static IEnumerable< IEnumerable< T > > Split< T > (this IEnumerable< T > source, int splitItemCount)
 
static bool IsEmpty< T > (this IEnumerable< T > source)
 If the sequence is empty or has an element. More...
 
static void Shuffle< T > (this IList< T > list)
 Randomizes the list More...
 
static T GetRandomElement< T > (this IReadOnlyList< T > e)
 
static T GetRandomElement< T > (this T[] e)
 
static T GetRandomElementInefficiently< T > (this IEnumerable< T > e)
 
static T GetRandomElementWithPredicate< T > (this IReadOnlyList< T > e, Func< T, bool > predicate)
 
static T GetRandomElementWithPredicate< T > (this IReadOnlyList< T > e, Func< T, bool > predicate, int randomSeed)
 
static List< Tuple< T1, T2 > > CombineWith< T1, T2 > (this IEnumerable< T1 > list1, IEnumerable< T2 > list2)
 Generates the combinations of the two lists More...
 

Member Function Documentation

◆ ToHexadecimalString()

static string TaleWorlds.Core.Extensions.ToHexadecimalString ( this uint  number)
static
Parameters
number
Returns
(i.e. "FF00FF00")

◆ Description()

static string TaleWorlds.Core.Extensions.Description ( this Enum  value)
static

◆ NextFloat()

static float TaleWorlds.Core.Extensions.NextFloat ( this Random  random)
static
Parameters
random
Returns

◆ MaxBy< TSource, TKey >() [1/3]

static TSource TaleWorlds.Core.Extensions.MaxBy< TSource, TKey > ( this IEnumerable< TSource >  source,
Func< TSource, TKey >  selector 
)
static

If more than one element has the maximal projected value, the first one encountered will be returned. This overload uses the default comparer for the projected type. This operator uses immediate execution, but only buffers a single result (the current maximal element).

Template Parameters
TSourceType of the source sequence
TKeyType of the projected element
Parameters
sourceSource sequence
selectorSelector to use to pick the results to compare
Returns
The maximal element, according to the projection.
Exceptions
ArgumentNullExceptionsource or selector is null
InvalidOperationExceptionsource is empty

◆ MaxBy< TSource, TKey >() [2/3]

static TSource TaleWorlds.Core.Extensions.MaxBy< TSource, TKey > ( this IEnumerable< TSource >  source,
Func< TSource, TKey >  selector,
out TKey  maxKey 
)
static

If more than one element has the maximal projected value, the first one encountered will be returned. This overload uses the default comparer for the projected type. This operator uses immediate execution, but only buffers a single result (the current maximal element).

Template Parameters
TSourceType of the source sequence
TKeyType of the projected element
Parameters
sourceSource sequence
selectorSelector to use to pick the results to compare
Returns
The maximal element, according to the projection.
Exceptions
ArgumentNullExceptionsource or selector is null
InvalidOperationExceptionsource is empty

◆ MaxBy< TSource, TKey >() [3/3]

static TSource TaleWorlds.Core.Extensions.MaxBy< TSource, TKey > ( this IEnumerable< TSource >  source,
Func< TSource, TKey >  selector,
IComparer< TKey >  comparer,
out TKey  maxKey 
)
static

If more than one element has the maximal projected value, the first one encountered will be returned. This overload uses the default comparer for the projected type. This operator uses immediate execution, but only buffers a single result (the current maximal element).

Template Parameters
TSourceType of the source sequence
TKeyType of the projected element
Parameters
sourceSource sequence
selectorSelector to use to pick the results to compare
comparerComparer to use to compare projected values
Returns
The maximal element, according to the projection.
Exceptions
ArgumentNullExceptionsource , selector or comparer is null
InvalidOperationExceptionsource is empty

◆ MinBy< TSource, TKey >() [1/2]

static TSource TaleWorlds.Core.Extensions.MinBy< TSource, TKey > ( this IEnumerable< TSource >  source,
Func< TSource, TKey >  selector 
)
static

If more than one element has the minimal projected value, the first one encountered will be returned. This overload uses the default comparer for the projected type. This operator uses immediate execution, but only buffers a single result (the current minimal element).

Template Parameters
TSourceType of the source sequence
TKeyType of the projected element
Parameters
sourceSource sequence
selectorSelector to use to pick the results to compare
Returns
The minimal element, according to the projection.
Exceptions
ArgumentNullExceptionsource or selector is null
InvalidOperationExceptionsource is empty

◆ MinBy< TSource, TKey >() [2/2]

static TSource TaleWorlds.Core.Extensions.MinBy< TSource, TKey > ( this IEnumerable< TSource >  source,
Func< TSource, TKey >  selector,
IComparer< TKey >  comparer 
)
static

If more than one element has the minimal projected value, the first one encountered will be returned. This overload uses the default comparer for the projected type. This operator uses immediate execution, but only buffers a single result (the current minimal element).

Template Parameters
TSourceType of the source sequence
TKeyType of the projected element
Parameters
sourceSource sequence
selectorSelector to use to pick the results to compare
comparerComparer to use to compare projected values
Returns
The minimal element, according to the projection.
Exceptions
ArgumentNullExceptionsource , selector or comparer is null
InvalidOperationExceptionsource is empty

◆ DistinctBy< TSource, TKey >() [1/2]

static IEnumerable< TSource > TaleWorlds.Core.Extensions.DistinctBy< TSource, TKey > ( this IEnumerable< TSource >  source,
Func< TSource, TKey >  keySelector 
)
static

This operator uses deferred execution and streams the results, although a set of already-seen keys is retained. If a key is seen multiple times, only the first element with that key is returned.

Template Parameters
TSourceType of the source sequence
TKeyType of the projected element
Parameters
sourceSource sequence
keySelectorProjection for determining "distinctness"
Returns
A sequence consisting of distinct elements from the source sequence, comparing them by the specified key projection.

◆ DistinctBy< TSource, TKey >() [2/2]

static IEnumerable< TSource > TaleWorlds.Core.Extensions.DistinctBy< TSource, TKey > ( this IEnumerable< TSource >  source,
Func< TSource, TKey >  keySelector,
IEqualityComparer< TKey >  comparer 
)
static

This operator uses deferred execution and streams the results, although a set of already-seen keys is retained. If a key is seen multiple times, only the first element with that key is returned.

Template Parameters
TSourceType of the source sequence
TKeyType of the projected element
Parameters
sourceSource sequence
keySelectorProjection for determining "distinctness"
comparerThe equality comparer to use to determine whether or not keys are equal. If null, the default equality comparer for TSource is used.
Returns
A sequence consisting of distinct elements from the source sequence, comparing them by the specified key projection.

◆ Add()

static string TaleWorlds.Core.Extensions.Add ( this string  str,
string  appendant,
bool  newLine = true 
)
static

◆ Split()

static IEnumerable< string > TaleWorlds.Core.Extensions.Split ( this string  str,
int  maxChunkSize 
)
static

◆ GetOppositeSide()

static BattleSideEnum TaleWorlds.Core.Extensions.GetOppositeSide ( this BattleSideEnum  side)
static

◆ Split< T >()

static IEnumerable< IEnumerable< T > > TaleWorlds.Core.Extensions.Split< T > ( this IEnumerable< T >  source,
int  splitItemCount 
)
static

◆ IsEmpty< T >()

static bool TaleWorlds.Core.Extensions.IsEmpty< T > ( this IEnumerable< T >  source)
static
Template Parameters
T
Parameters
source
Returns

◆ Shuffle< T >()

static void TaleWorlds.Core.Extensions.Shuffle< T > ( this IList< T >  list)
static
Template Parameters
T
Parameters
list

◆ GetRandomElement< T >() [1/2]

static T TaleWorlds.Core.Extensions.GetRandomElement< T > ( this IReadOnlyList< T >  e)
static

◆ GetRandomElement< T >() [2/2]

static T TaleWorlds.Core.Extensions.GetRandomElement< T > ( this T[]  e)
static

◆ GetRandomElementInefficiently< T >()

static T TaleWorlds.Core.Extensions.GetRandomElementInefficiently< T > ( this IEnumerable< T >  e)
static

◆ GetRandomElementWithPredicate< T >() [1/2]

static T TaleWorlds.Core.Extensions.GetRandomElementWithPredicate< T > ( this IReadOnlyList< T >  e,
Func< T, bool >  predicate 
)
static

◆ GetRandomElementWithPredicate< T >() [2/2]

static T TaleWorlds.Core.Extensions.GetRandomElementWithPredicate< T > ( this IReadOnlyList< T >  e,
Func< T, bool >  predicate,
int  randomSeed 
)
static

◆ CombineWith< T1, T2 >()

static List< Tuple< T1, T2 > > TaleWorlds.Core.Extensions.CombineWith< T1, T2 > ( this IEnumerable< T1 >  list1,
IEnumerable< T2 >  list2 
)
static
Template Parameters
T1
T2
Parameters
list1
list2
Returns