Skip to content

Registry and references ​

Namespace: StellarStriderLib. Register from Unity's main thread during OnInitializeMelon, before the first world starts. See Content registration for examples.

Source: StriderRegistry.cs and Definitions.cs.

StriderRegistry ​

Registration and active-world lookups.

Create ​

csharp
public static ModRegistry Create(string modId, System.Reflection.Assembly assembly);

Creates or retrieves this assembly's registry. The assembly must be non-null and the mod ID unique to it. Create new owners before the first world starts.

IDs are nonempty, case-sensitive, unpadded strings without :. For example, example.firstmod is a mod ID and example.firstmod:controller is a full content key.

Status ​

PropertyTypeMeaning
WorldReadybool (get)Active world settings and lookups are ready
LastErrorstring (get)Most recently reported library error; empty when cleared

Settings lookups ​

csharp
public static bool TryGetPart(PartRef reference, out Ships.Interface.Settings.PartSettings settings);
public static bool TryGetItem(ItemRef reference, out Items.Model.ItemSettings settings);
public static bool TryGetResearch(ResearchRef reference, out Research.Interface.Values.ResearchSettings settings);

Return false with null output before world readiness or when settings are unavailable. Settings belong to the current world; do not change their numeric IDs.

Numeric lookups ​

csharp
public static bool TryGetNumericId(PartRef reference, out ushort id);
public static bool TryGetNumericId(ItemRef reference, out uint id);
public static bool TryGetNumericId(ResearchRef reference, out ushort id);

Return false with zero output before world readiness or for an unmapped key. A resolved native ID or reserved mod mapping does not prove settings exist; use a settings lookup to check.

Call on the main thread. Do not cache IDs across worlds or hard-code registered IDs.

ModRegistry ​

Obtained through StriderRegistry.Create; it has no public constructor.

Properties and key helper ​

MemberType / signatureMeaning
ModIdstring (get)Owner's mod ID
AssemblySystem.Reflection.Assembly (get)Owner of embedded resources
AssetsStellarStriderLib.Models.AssetScope (get)Assembly-scoped asset cache
Keystring Key(string localId)Validates the local ID and returns modId:localId

Registration methods ​

csharp
public void RegisterCategory(CategoryDefinition definition);
public void RegisterPart(PartDefinition definition);
public void RegisterItem(ItemDefinition definition);
public void RegisterFluid(FluidDefinition definition);
public void RegisterGas(FluidDefinition definition);
public void RegisterResearchTree(ResearchTreeDefinition definition);
public void RegisterLoadingWallpaper(LoadingWallpaperDefinition definition);

Definitions must satisfy their type-specific requirements. Registration rejects duplicate keys within the corresponding content kind. Fluids and gases share the item namespace. Research nodes share the mod's research namespace across trees.

Tree registration validates nodes before adding them. References, donors, cycles, and assets are checked when the world builds.

Registration freezes when the first world is prepared. Keep definitions unchanged; hot registration and individual mod unloading are unsupported.

World events ​

csharp
public event System.Action WorldBound;
public event System.Action WorldUnbinding;

WorldBound runs when content and lookups are ready. Resolve world references here. A thrown exception cancels binding.

WorldUnbinding runs after readiness ends and before prefabs are destroyed, including failed builds. Clear cached settings/IDs here. Cleanup exceptions are logged without stopping other subscribers.

Both run on Unity's main thread. Subscribe during initialisation and unsubscribe named handlers on shutdown if your plugin owns those subscriptions.

Typed references ​

TypeNative factoryRegistered-content factory
PartRefPartRef.Native(ushort id)PartRef.Mod(string key)
ItemRefItemRef.Native(uint id)ItemRef.Mod(string key)
ResearchRefResearchRef.Native(ushort id)ResearchRef.Mod(string key)

Each is a readonly struct. ItemRef also represents fluids and gases. Mod requires a complete validated key, such as content.Key("chip"); a local ID alone is invalid. Native refers to existing game or independent-mod numeric content, not content awaiting SSLib allocation.

These types prevent passing an item reference to a part lookup. They do not verify that the target exists until world resolution.

ContentReference ​

Readonly underlying reference type, also public:

csharp
public static ContentReference Native(uint id);
public static ContentReference Mod(string key);
PropertyTypeMeaning
Keystring (get)Full mod key, or null for native references
NativeIduint (get)Native ID; zero in a mod reference
IsNativebool (get)True when Key is null

Prefer the typed wrappers at public registration and lookup call sites.

StellarStriderLib documentation · Mods for StellarDrive