Get() Methods

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
// Array
GameStat[] duplicateGameStats = gameStatList
// Additional work before making it an Array
GameStat[] duplicateSwords = gameStatList
.Where(x => x.ObjectName()
The common methods can be found in GameModuleListExtensions.cs


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.
// Get a stat, and add if not already there
GameStat gameStat = gameStatList.Get(stat, true); // Pass in a "Stat" object
GameStat gameStat = gameStatList.Get(gameStat, true); // Pass in a GameStat object
GameStat gameStat = gameStatList.Get(uid, true); // Pass in the uid of a Stat
// Get by an ObjectType()
GameStat gameStat = gameStatList.GetByObjectType(objectType, true); // Reuturns just the first object of this type


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.
// TryGet -- multiple versions accept a Stat, GameStat, or Uid
if (gameStatList.TryGet(stat, out var foundGameStat))
Debug.Log($"Got {foundGameStat.objectName}");
if (gameStatList.TryGet(gameStatt, out var foundGameStat))
Debug.Log($"Got {foundGameStat.objectName}");
if (gameStatList.TryGet(uid, out var foundGameStat))
Debug.Log($"Got {foundGameStat.objectName}");
// TryGet by ObjectType()
if (gameStatList.TryGetByObjectType(objectType, out var foundGameStat))
Debug.Log($"Got {foundGameStat.objectName} which is a {objectType}");

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.
var specificGameStat = gameStatList.GetByGameId(gameId);
if (gameStatList.TryGetGameId(gameId, out var specificGameStat))
Debug.Log($"Found the specific gameStat with gameId {specificGameStat.GameId()});

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.
Debug.Log($"The last GameStat added is {gameStatList.Last().objectName}");
Debug.Log($"The first GameStat in the list is {gameStatList.First().objectName}");


These will return an array of the type being handled. The array may be empty if there are none to return.
GameStat[] GameStatsOf(string uid) => gameStatList.GetAll(uid);
GameStat[] GameStatsOfType(string objectType) => gameStatList.GetAllOfType(objectType);

Additional Methods

// Get array of ObjectTypes represented in the list
var allObjectTypes = gameStatList.GetObjectTypes.ToArray();
// Get list of all items that are duplicates, ignoring the first of each
var duplicateStats = gameStatList.GetDuplicates.ToList();