PLCollection<T>

Need the practical walkthrough first? Start with PLCollection Guides, then use this page as the compact code reference for the collection API itself.

PLCollection<T> organizes multiple ProbabilityList<T> instances into one collection.

Use it when one list is not enough and you want a higher-level structure for named or indexed list groups.


Typical use cases

  • grouped loot tables
  • named dialogue pools
  • encounter categories
  • multi-biome spawn lists
  • any system where several probability lists belong together

Core collection members

Collection basics

METHODItemType
Type ItemType()

Returns the value type used by the collection and all contained lists.

PROPERTYCount
int

Number of lists in the collection.

METHODAddList
void AddList(...) / overloads

Adds an existing list or creates a new list with an optional name.

METHODRemoveList
bool RemoveList(...) / overloads

Removes a list by index or name.

METHODGetList
ProbabilityList<T> GetList(...) / overloads

Retrieves a list by index or by name.

METHODSetListName
bool SetListName(...) / overloads

Renames a list. Since names live on the underlying ProbabilityList<T>, this is the collection-friendly way to keep those names useful and consistent.

METHODMoveListUp / MoveListDown
bool MoveListUp(int index) / bool MoveListDown(int index)

Reorders lists inside the collection.


Picking through the collection

Selection helpers

METHODPickValueFrom
bool PickValueFrom(...) / overloads

Picks a single value from one named or indexed list.

METHODTryPickValueFrom
(bool ListFound, bool ValuePicked) TryPickValueFrom(...) / overloads

Safer single-pick helper when you need to distinguish missing lists from unsuccessful picks.

METHODPickValuesFrom
List<T> PickValuesFrom(...) / overloads

Picks multiple values from one list.

METHODPickValuesFromAll
List<T> PickValuesFromAll()

Picks values from all lists and merges the results into a new list.

METHODPickValueFromAll
List<T> PickValueFromAll()

Picks one value from each list and returns the collected results.


Maintenance helpers

Maintenance and state helpers

METHODClearCollection
void ClearCollection()

Removes all lists from the collection.

METHODClearList / ClearAllLists
bool ClearList(...) / void ClearAllLists()

Clears one list or all lists.

METHODIsListEmpty
(bool ListFound, bool IsEmpty) IsListEmpty(...) / overloads

Checks whether a list exists and whether it currently contains items.

METHODRefillList / RefillAllLists
bool RefillList(...) / void RefillAllLists()

Refills depletable items in one list or across all lists.


Naming vs indexing


Example

var responses = new PLCollection<string>();
responses.AddList("Friendly");
responses.AddList("Hostile");

responses.GetList("Friendly")?.AddItems("Hello", "Good to see you", "Welcome back");
responses.GetList("Hostile")?.AddItems("Go away", "Not interested", "Leave me alone");

responses.PickValueFrom("Friendly", out var line);