Class BuildEvents
Provides events for the building system, allowing mods to customize items as they're placed. Subscribe to these events instead of using Harmony patches on BuildManager.
public static class BuildEvents
- Inheritance
-
BuildEvents
- Inherited Members
Examples
// Customize materials when items are placed
BuildEvents.OnGridItemCreated += (args) =>
{
if (args.ItemId == "my_custom_rack")
{
MaterialHelper.ReplaceMaterials(args.GameObject, ...);
}
};
Events
OnBuildableItemInitialized
Event raised after a buildable item component is initialized. This event fires for all buildable items and can be used for additional setup.
public static event Action<BuildEventArgs>? OnBuildableItemInitialized
Event Type
Remarks
Storage is null for items that are not storage containers.
OnGhostCreated
Event raised when the placement ghost of a grid, surface or procedural grid item is created, before the player sees it.
public static event Action<GhostCreatedEventArgs>? OnGhostCreated
Event Type
Remarks
GameObject is the ghost; filter by ItemId. The game has already disabled colliders, navigation and networking on the ghost hierarchy that exists when the handler runs. A part a handler adds is not covered: the mod must disable those components on that part itself. Each handler runs on its own: one that throws is logged and the others still run.
OnGridItemCreated
Event raised after a grid item (wall-mounted or floor-placed) is created in the world. This is the most common build event for furniture and storage items.
public static event Action<BuildEventArgs>? OnGridItemCreated
Event Type
Remarks
Subscribers receive a BuildEventArgs containing the item and GameObject. The GameObject can be modified to change appearance or behavior. Storage is null for items that are not storage containers.
OnSurfaceItemCreated
Event raised after a surface item (table-top item) is created.
public static event Action<BuildEventArgs>? OnSurfaceItemCreated
Event Type
Remarks
Storage is null for items that are not storage containers.