Baldi's Basics Plus Glue API
Modding API for Baldi's Basics Plus
Loading...
Searching...
No Matches
BBPGlue.API.BBPPrefabs Class Referencesealed

Provides discovery, lookup, registration, and spawning helpers for BB+ prefabs and runtime-authored prefab-like objects. More...

Public Member Functions

void ClearCustomPrefabs ()
 Clears all runtime-authored prefab registrations.
object? FindPrefabByName (string name)
 Finds a prefab or prefab-like object by id/name.
object? GetCustomPrefab (string id)
 Gets a runtime-authored prefab or prefab-like object by id.
string GetItemName (object? item)
 Gets the best available name for a vanilla item object.
object? GetItemObject (BBPItemId id)
 Finds a vanilla item object template by BBPGlue item id.
object? GetItemObjectByIndex (int index)
 Gets a vanilla item object by index from the discovered item cache.
object? GetItemObjectByName (string name)
 Finds a vanilla item object by display/localization name or item type name.
object? GetItemObjectByTypeName (string typeName)
 Finds a vanilla item object by its internal item type name.
string GetNpcCharacter (object? npc)
 Gets the BB+ character identifier from an NPC prefab.
object? GetNpcPrefabByCharacter (string character)
 Finds a vanilla NPC prefab by its BB+ character identifier.
object? GetNpcPrefabByIndex (int index)
 Gets a vanilla NPC prefab by index from the discovered NPC cache.
object? GetNpcPrefabByName (string name)
 Finds a vanilla NPC prefab by Unity object name.
object? GetNpcPrefabByTypeName (string typeName)
 Finds a vanilla NPC prefab by component/runtime type name.
string GetPrefabName (object? prefab)
 Gets a best-effort readable name for a prefab or prefab-like object.
void Refresh ()
 Rebuilds the vanilla prefab cache from the current game state.
bool RegisterCustomPrefab (string id, object prefab)
 Registers a runtime-authored prefab or prefab-like object under a stable BBPGlue id.
bool RemoveCustomPrefab (string id)
 Removes a runtime-authored prefab registration.
object? SpawnAtPlayer (object prefab)
 Spawns a prefab at the player's current position.
object? SpawnAtWorld (object prefab, Vector3 position)
 Spawns a prefab at a world position.
object? SpawnByName (string name, Vector3 position)
 Finds a prefab by id/name and spawns it at a world position.

Properties

IReadOnlyDictionary< string, object > CustomPrefabs [get]
 Gets runtime-registered prefabs and prefab-like authored objects.
IReadOnlyList< object > ItemObjects [get]
 Gets the discovered vanilla item object templates.
IReadOnlyList< object > NpcPrefabs [get]
 Gets the discovered vanilla NPC prefabs.

Detailed Description

Provides discovery, lookup, registration, and spawning helpers for BB+ prefabs and runtime-authored prefab-like objects.

Member Function Documentation

◆ ClearCustomPrefabs()

void BBPGlue.API.BBPPrefabs.ClearCustomPrefabs ( )

Clears all runtime-authored prefab registrations.

Vanilla discovered prefab caches are not affected.

◆ FindPrefabByName()

object? BBPGlue.API.BBPPrefabs.FindPrefabByName ( string name)

Finds a prefab or prefab-like object by id/name.

Search order: custom authored prefabs, vanilla NPC prefabs, then vanilla item objects.

Parameters
nameCustom id, NPC prefab name, or item name.
Returns
The matching object, or null if not found.

◆ GetCustomPrefab()

object? BBPGlue.API.BBPPrefabs.GetCustomPrefab ( string id)

Gets a runtime-authored prefab or prefab-like object by id.

Parameters
idThe id passed to RegisterCustomPrefab.
Returns
The registered object, or null if no object exists for the id.

◆ GetItemName()

string BBPGlue.API.BBPPrefabs.GetItemName ( object? item)

Gets the best available name for a vanilla item object.

Parameters
itemThe item object to inspect.
Returns
Name key, item type name, prefab name, or "NULL".

◆ GetItemObject()

object? BBPGlue.API.BBPPrefabs.GetItemObject ( BBPItemId id)

Finds a vanilla item object template by BBPGlue item id.

Parameters
idThe vanilla item id to locate.
Returns
The matching vanilla item object template, or null if not found.

◆ GetItemObjectByIndex()

object? BBPGlue.API.BBPPrefabs.GetItemObjectByIndex ( int index)

Gets a vanilla item object by index from the discovered item cache.

Parameters
indexZero-based index into ItemObjects.
Returns
The item object, or null if the index is invalid.

◆ GetItemObjectByName()

object? BBPGlue.API.BBPPrefabs.GetItemObjectByName ( string name)

Finds a vanilla item object by display/localization name or item type name.

Parameters
nameThe item name, localization key, or type name to search for.
Returns
The matching vanilla item object, or null if not found.

◆ GetItemObjectByTypeName()

object? BBPGlue.API.BBPPrefabs.GetItemObjectByTypeName ( string typeName)

Finds a vanilla item object by its internal item type name.

Parameters
typeNameThe item type name to search for.
Returns
The matching vanilla item object, or null if not found.

◆ GetNpcCharacter()

string BBPGlue.API.BBPPrefabs.GetNpcCharacter ( object? npc)

Gets the BB+ character identifier from an NPC prefab.

Parameters
npcThe NPC prefab or component to inspect.
Returns
The character id, "Unknown", or "NULL".

◆ GetNpcPrefabByCharacter()

object? BBPGlue.API.BBPPrefabs.GetNpcPrefabByCharacter ( string character)

Finds a vanilla NPC prefab by its BB+ character identifier.

Parameters
characterThe character identifier to search for.
Returns
The matching vanilla NPC prefab, or null if not found.

◆ GetNpcPrefabByIndex()

object? BBPGlue.API.BBPPrefabs.GetNpcPrefabByIndex ( int index)

Gets a vanilla NPC prefab by index from the discovered NPC cache.

Parameters
indexZero-based index into NpcPrefabs.
Returns
The NPC prefab, or null if the index is invalid.

◆ GetNpcPrefabByName()

object? BBPGlue.API.BBPPrefabs.GetNpcPrefabByName ( string name)

Finds a vanilla NPC prefab by Unity object name.

Parameters
nameThe prefab object name to search for.
Returns
The matching vanilla NPC prefab, or null if not found.

◆ GetNpcPrefabByTypeName()

object? BBPGlue.API.BBPPrefabs.GetNpcPrefabByTypeName ( string typeName)

Finds a vanilla NPC prefab by component/runtime type name.

Parameters
typeNameThe runtime type name to search for.
Returns
The matching vanilla NPC prefab, or null if not found.

◆ GetPrefabName()

string BBPGlue.API.BBPPrefabs.GetPrefabName ( object? prefab)

Gets a best-effort readable name for a prefab or prefab-like object.

Parameters
prefabThe object to inspect.
Returns
Unity object name, GameObject name, type name, or "NULL".

◆ Refresh()

void BBPGlue.API.BBPPrefabs.Refresh ( )

Rebuilds the vanilla prefab cache from the current game state.

Custom prefabs registered through RegisterCustomPrefab are not cleared.

◆ RegisterCustomPrefab()

bool BBPGlue.API.BBPPrefabs.RegisterCustomPrefab ( string id,
object prefab )

Registers a runtime-authored prefab or prefab-like object under a stable BBPGlue id.

This is the general registration path used by authored NPCs, pickups, item objects, GameObjects, Components, ScriptableObjects, or other Unity objects. It does not modify BB+ resources; it only stores the object for BBPGlue lookup.

Parameters
idUnique id used to retrieve the object later.
prefabPrefab, template, component, or scriptable object to register.
Returns
True if the object was registered; otherwise false.

◆ RemoveCustomPrefab()

bool BBPGlue.API.BBPPrefabs.RemoveCustomPrefab ( string id)

Removes a runtime-authored prefab registration.

Parameters
idThe id of the custom prefab to remove.
Returns
True if an entry was removed; otherwise false.

◆ SpawnAtPlayer()

object? BBPGlue.API.BBPPrefabs.SpawnAtPlayer ( object prefab)

Spawns a prefab at the player's current position.

Parameters
prefabThe prefab or component to spawn.
Returns
The spawned object returned by the environment bridge, or null.

◆ SpawnAtWorld()

object? BBPGlue.API.BBPPrefabs.SpawnAtWorld ( object prefab,
Vector3 position )

Spawns a prefab at a world position.

Parameters
prefabThe prefab or component to spawn.
positionWorld position where the prefab should be spawned.
Returns
The spawned object returned by the environment bridge, or null.

◆ SpawnByName()

object? BBPGlue.API.BBPPrefabs.SpawnByName ( string name,
Vector3 position )

Finds a prefab by id/name and spawns it at a world position.

Parameters
nameCustom id, NPC prefab name, or item name.
positionWorld position where the prefab should be spawned.
Returns
The spawned object, or null if lookup/spawn failed.

Property Documentation

◆ CustomPrefabs

IReadOnlyDictionary<string, object> BBPGlue.API.BBPPrefabs.CustomPrefabs
get

Gets runtime-registered prefabs and prefab-like authored objects.

◆ ItemObjects

IReadOnlyList<object> BBPGlue.API.BBPPrefabs.ItemObjects
get

Gets the discovered vanilla item object templates.

◆ NpcPrefabs

IReadOnlyList<object> BBPGlue.API.BBPPrefabs.NpcPrefabs
get

Gets the discovered vanilla NPC prefabs.


The documentation for this class was generated from the following file: