RNGNeedsCore
RNGNeedsCore is the static integration and extension entry point for RNGNeeds. Use it when you want to customize package-wide behavior such as selection method registration, seed provider setup, logging, or other global integration points. For day-to-day list creation and picking values, start with ProbabilityList<T>.
When to use this type
Use RNGNeedsCore when you want to:
- register a custom
ISelectionMethod - inspect the list of available selection methods
- replace the global seed provider
- reset the seed provider back to default behavior
- pre-warm history entry pooling for allocation-sensitive scenarios
- control RNGNeeds log verbosity while debugging
Selection methods
This part of RNGNeedsCore is about discovering, registering, and resolving selection methods.
Selection method members
RegisteredSelectionMethodsReturns the currently registered selection methods as identifier/name pairs. This is useful when you want to inspect what methods are available at runtime or build your own method picker UI.
DefaultSelectionMethodIDReturns the identifier of the fallback selection method used when no valid method is found.
RegisterSelectionMethodRegisters a custom selection method. The method must expose a non-empty unique Identifier.
GetSelectionMethodRetrieves a registered selection method by identifier. If the identifier is unknown, RNGNeeds falls back to the default selection method.
Why the Identifier matters
The selection method identifier is the stable string key RNGNeeds uses to find a method.
That means it matters in several places:
- when you register a custom method
- when
ProbabilityList<T>.SelectionMethodIDstores the chosen method - when serialized data needs to resolve the correct method later
- when RNGNeeds falls back because an identifier is invalid or no longer registered
public class MySelectionMethod : SelectionMethodBase
{
public override string Identifier => "MyCustomMethod";
public override string Name => "My Custom Method";
protected override bool SelectItem(out int selectedIndex)
{
// Your custom selection logic here.
}
}
RNGNeedsCore.RegisterSelectionMethod(new MySelectionMethod());
Seed providers
This part controls how RNGNeeds generates fresh seeds at the global level.
Seed provider members
NewSeedGenerates a fresh seed using the currently active global seed provider.
SetSeedProviderReplaces the global seed provider used by RNGNeeds.
ResetSeedProviderRestores the default seed provider.
If you need deterministic runs, repeatable tests, or a custom game-wide seeding strategy, see Seed Providers.
Logging and diagnostics
This section covers the global helpers used for debugging and allocation-sensitive scenarios.
Diagnostics helpers
SetLogLevelChanges the verbosity of RNGNeeds logging.
SetLogAllowColorsEnables or disables colored log output.
WarmupHistoryEntriesPre-allocates pooled HistoryEntry instances to reduce runtime allocations during picking.
Behavior notes
Fallback behavior is intentional.
If a requested selection method identifier cannot be resolved, GetSelectionMethod(...) returns the fallback method instead of throwing. That helps keep serialized assets usable even when a custom method is missing or has been renamed.
Custom methods must use unique identifiers.
If you try to register a second method with the same identifier, RNGNeeds logs a warning and keeps the existing one.
Related pages
Need help or guidance?
If you want help shaping a custom extension, choosing an approach, or troubleshooting a setup, feel free to drop by our Support page and join the Discord from there.