Class TrashManager
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
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
idstringThe ID of the trash item to create.
positionVector3The position to create the trash at.
rotationQuaternionThe rotation of the trash item.
initialVelocityVector3Optional initial velocity.
guidstringOptional 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
idstringThe 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
idstringStable trash ID used for spawning and persistence.
trashPrefabGameObjectPrefab containing a native TrashItem component.
replaceExistingboolWhether 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.