Table of Contents

Class TrashManager

Namespace
S1API.Trash
Assembly
S1API.dll

Provides management over trash items in the game.

public static class TrashManager
Inheritance
TrashManager
Inherited Members

Fields

TrashItemLimit

Maximum number of trash items allowed in the world (2000).

public const int TrashItemLimit = 2000

Field Value

int

Methods

CreateTrashItem(string, Vector3, Quaternion, Vector3, string)

Creates a trash item at the specified position.

public static GameObject? CreateTrashItem(string id, Vector3 position, Quaternion rotation, Vector3 initialVelocity = default, string guid = "")

Parameters

id string

The ID of the trash item to create.

position Vector3

The position to create the trash at.

rotation Quaternion

The rotation of the trash item.

initialVelocity Vector3

Optional initial velocity.

guid string

Optional GUID (auto-generated if empty).

Returns

GameObject

The created trash item GameObject, or null if creation failed.

DestroyAllTrash()

Destroys all trash items in the world. Only works if called on the server/host.

public static void DestroyAllTrash()

GetRandomTrashPrefab()

Gets a random trash prefab based on generation chances.

public static GameObject? GetRandomTrashPrefab()

Returns

GameObject

A random trash prefab GameObject.

GetTrashPrefab(string)

Gets a trash prefab by its ID.

public static GameObject? GetTrashPrefab(string id)

Parameters

id string

The ID of the trash prefab.

Returns

GameObject

The trash prefab GameObject, or null if not found.

RegisterTrashPrefab(string, GameObject, bool)

Registers a stable trash prefab that can be spawned by ID and referenced by station items.

public static GameObject RegisterTrashPrefab(string id, GameObject trashPrefab, bool replaceExisting = false)

Parameters

id string

Stable trash ID used for spawning and persistence.

trashPrefab GameObject

Prefab containing a native TrashItem component.

replaceExisting bool

Whether an existing registration with the same ID may be replaced.

Returns

GameObject

The cached registered prefab.

Remarks

The supplied prefab is cloned under an inactive, persistent cache root. Registrations are reapplied after game loads so network trash spawning can resolve the same ID on every client. All clients must register the same ID and prefab behavior for multiplayer consistency.