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

PROPERTYRegisteredSelectionMethods
List<(string Identifier, string Name)>

Returns 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.

PROPERTYDefaultSelectionMethodID
string

Returns the identifier of the fallback selection method used when no valid method is found.

METHODRegisterSelectionMethod
void RegisterSelectionMethod(ISelectionMethod selectionMethod)

Registers a custom selection method. The method must expose a non-empty unique Identifier.

METHODGetSelectionMethod
ISelectionMethod GetSelectionMethod(string identifier)

Retrieves 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>.SelectionMethodID stores 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

PROPERTYNewSeed
uint

Generates a fresh seed using the currently active global seed provider.

METHODSetSeedProvider
void SetSeedProvider(ISeedProvider seedProvider)

Replaces the global seed provider used by RNGNeeds.

METHODResetSeedProvider
void ResetSeedProvider()

Restores 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

METHODSetLogLevel
void SetLogLevel(LogMessageType logMessageLevel)

Changes the verbosity of RNGNeeds logging.

METHODSetLogAllowColors
void SetLogAllowColors(bool allowColors)

Enables or disables colored log output.

METHODWarmupHistoryEntries
void WarmupHistoryEntries(int count)

Pre-allocates pooled HistoryEntry instances to reduce runtime allocations during picking.


Behavior notes