Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Bill3621/CustomItems/llms.txt
Use this file to discover all available pages before exploring further.
Overview
CustomItems LabAPI is a plugin framework built on top of LabAPI that enables developers to create custom items for SCP: Secret Laboratory. The framework provides a robust architecture for registering, managing, and handling events for custom items throughout their lifecycle.Core components
The framework consists of several key components that work together:Plugin system
The framework is implemented as a LabAPI plugin with the following characteristics:- Load priority:
Highest- Ensures custom items are available before other plugins - Harmony patching: Uses Harmony library for runtime code modification
- Event management: Integrates with LabAPI’s
CustomHandlersManager
CustomItemsPlugin.cs:41-58
Registration system
Custom items are managed through a centralized registration system (CustomItems.API.CustomItems) that:
- Assigns unique IDs to each registered item
- Maintains dictionaries for fast lookup by ID or name
- Tracks active item instances by their serial numbers
- Provides spawn and give functionality
Event handler bridge
TheEventHandler class bridges LabAPI events to custom item event hooks:
EventHandler.cs:34-43
- Intercepts LabAPI player events
- Checks if the item involved is a custom item (by serial number)
- Delegates to the appropriate custom item instance’s event hook
Architecture diagram
Integration with game loop
Startup sequence
- Plugin initialization:
CustomItemsPlugin.Enable()is called - Harmony patching: Runtime patches are applied to game code
- Event registration: Event handler is registered with LabAPI
- Item registration: Your custom items are registered (manually or via
RegisterAll()) - Ready: Custom items are now active and responding to events
Runtime flow
When a player interacts with a custom item:- Game event occurs: Player uses, drops, picks up, or selects an item
- LabAPI intercepts: Event is captured by LabAPI’s event system
- EventHandler receives: CustomItems’ event handler processes the event
- Serial check: Handler checks if the item’s serial number is registered
- Delegate to item: If custom, the event is delegated to the specific
CustomIteminstance - Custom logic: Your item’s event hook method executes
Round lifecycle
At the start of each round:EventHandler.cs:10-26
CurrentItems dictionary is cleared to remove all custom item instances from the previous round.
Serial number tracking
The framework uses Unity’s item serial numbers to track custom item instances:- Registration: When spawned or given, the serial is mapped to a
CustomIteminstance - Lookup: Events use the serial to find the corresponding custom item
- Cleanup: Unregistration removes all instances with matching serials
CustomItems.cs:127-132
Configuration
The plugin supports configuration throughconfig.yml:
Next steps
- Learn about custom items and the
CustomItembase class - Understand the event system and available hooks
- Explore the registration system for managing items