codeAPI Reference

s&box ICleanupEvents: Cleanup event callbacks

calendar_today May 12, 2026 schedule ~1 min read person PatrickJr verified 50

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

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?