codeAPI Reference
s&box ICleanupEvents: Cleanup event callbacks
ICleanupEvents API Reference
ICleanupEvents is an interface for receiving callbacks when the scene is cleaned up (map reset).
Type Signature
CSHARP
public interface ICleanupEvents
{
void OnCleanup(int removedObjects, int restoredObjects);
}Method
- void OnCleanup(int removedObjects, int restoredObjects) - Called after a cleanup operation completes. Parameters indicate how many spawned objects were removed and how many destroyed baseline objects were restored.
Usage
Implement this interface on a Component to receive cleanup notifications:
CSHARP
public class MyComponent : Component, ICleanupEvents
{
public void OnCleanup(int removedObjects, int restoredObjects)
{
Log.Info($"Cleanup complete: {removedObjects} removed, {restoredObjects} restored");
}
}Notes
- CleanupSystem broadcasts this event via Game.ActiveScene?.RunEvent<ICleanupEvents>() after cleanup completes.
- The event is broadcast via RPC to all clients.
- Cleanup is typically triggered by the cleanup console command or RPC methods.
- Removed objects are spawned props that weren't in the original scene baseline.
- Restored objects are baseline objects that were destroyed and are now being recreated.
Was this helpful?