Get() Methods

v4.0

Example code here is for a GameStatList, though similar methods are on other list classes as well.

Methods for specific list types are below.

Methods which return multiple objects will return an IEnumerator<T> (type depenent on the list you're dealing with), and you can convert that to a list or an array.

// List
List<GameStat> duplicateGameStats = gameStatList
    .GetDuplicatesOfType("someType")
    .ToList();

// Array
GameStat[] duplicateGameStats = gameStatList
    .GetDuplicatesOfType("someType")
    .ToArray();
    
// Additional work before making it an Array
GameStat[] duplicateSwords = gameStatList
    .GetDuplicatesOfType("Weapon")
    .Where(x => x.ObjectName()
    .Contains("Sword"))
    .ToArray();

The common methods can be found in GameModuleListExtensions.cs

Get()

Each list will have similar Get() methods. Dig into the Game[OBJECT]List.cs code to learn more.

The Get() methods have the additional addIfNull option. If true, the a new Game Module object will be created and returned, if it does not already exist.

TryGet()

The TryGet() methods will return true or false if the item exists, and return the item to an out variable if it does. These methods will NOT add the Game Modules object to the list if it does not already exist.

GetByGameId() & TryGetByGameId()

The runtime Game Module objects, such as GameStat, GameCondition, and GameItemObject, each have a unique GameId() which is created at runtime, and will stay the same even as the object is transferred.

This unique string identifies the specific instanace of the object in the game, opposed to the Uid() which is a unique string which identifies the Scriptable Object object, such as Stat, Condition, ItemObject.

In situations where a list may have multiple instances of a the same type of object, you may wish to Get() a specific instance, rather than obtaining the first found.

First() & Last()

While it's not difficult to get the first or last item in a list, we have helper methods for that as well.

GetAll()

These will return an array of the type being handled. The array may be empty if there are none to return.

Additional Methods

Last updated

Was this helpful?