These are extension methods. If you're unsure what they are or how to use them, ask ChatGPT 😍
Is() and IsNot()
This will allow you to compare any value with another and return a true or false based on Is() or IsNot() -- if they are or are not the same value.
publicstaticboolIs<T>(thisT value,T compareValue) public static bool IsNot<T>(thisT value,T compareValue)// Examplevar userInputGatePhrase = "Open the Gate";if (gate.passPhrase.Is(userInputGatePhrase))OpenTheGate();elseKillThePlayer(); // Harsh, but that's the rules of the game!
TakeRandom(), TakeRandomIndex(), and TakeRandomAndIndex()
These extend a List<T> and return either an item from the list, the int index of an item from the list, or both!
Shuffles a list using the Fisher-Yates shuffle. Optionally providing a startIndex greater than 0, and only the values from that point on will be shuffled, retaining the order of the first group.
publicstaticvoidShuffle<T>(thisList<T> list,int startOrEndIndex =0,bool fromEnd =false)// ExamplelistToShuffle.Shuffle(1); // Shuffles the list directly, but keep the first item.listToShuffle.Shuffle(2,true); // Shuffles, but keeps the last TWO items in the list
Reverse()
Reverses the order of a list. Optionally provide a startIndex, and only the items from that index on will be reversed.
publicstaticvoidReverse<T>(thisList<T> list,int startIndex =0)// ExamplenavigationPoints.Reverse(); // reverse the navigation points in the list
AddDistinct()
If the list does not already contain the item to be added, it will be added, and true will be returned. If it already contains the item, then false will be returned.
publicstaticboolAddDistinct<T>(thisList<T> list,T item)// Examplevar addedTheItem = listOfItems.AddDistinct(newItem);// In this example, we don't utilize the return value, but we can be confident that// the item will only be added if it doesn't already exist.listOfDistinctItems.AddDistinct(anotherItem);
RoundToDecimal
If the list does not already contain the item to be added, it will be added, and true will be returned. If it already contains the item, then false will be returned.
publicstaticfloatRoundToDecimal(thisfloat value,int decimals =2) // Example_text.text = $"{value.RoundToDecimal(2)}"; // Would turn 3.23234 to 3.23