Table of Contents

Class TrashContainer

Namespace
S1API.Trash
Assembly
S1API.dll

Provides managed access to an existing native trash container.

public sealed class TrashContainer
Inheritance
TrashContainer
Inherited Members
Extension Methods

Remarks

This wrapper does not add persistence or replacement replication for custom containers.

Properties

CanBeBagged

Gets whether the native container currently has enough contents to create a trash bag.

public bool CanBeBagged { get; }

Property Value

bool

Capacity

Gets the maximum number of capacity units the container can hold.

public int Capacity { get; }

Property Value

int

Contents

Gets an immutable managed snapshot of the current content entries.

public IReadOnlyList<TrashContentEntry> Contents { get; }

Property Value

IReadOnlyList<TrashContentEntry>

GameObject

Gets the game object that owns the native trash container.

public GameObject? GameObject { get; }

Property Value

GameObject

Level

Gets the current number of capacity units used by the container contents.

public int Level { get; }

Property Value

int

NormalizedLevel

Gets the current level divided by the container capacity.

public float NormalizedLevel { get; }

Property Value

float

Methods

FindInScene(bool)

Finds native trash containers in the loaded scene.

public static TrashContainer[] FindInScene(bool includeInactive = false)

Parameters

includeInactive bool

Whether to include containers on inactive game objects.

Returns

TrashContainer[]

A snapshot of the trash containers found in the scene.

FromGameObject(GameObject)

Gets a trash container attached directly to a game object.

public static TrashContainer? FromGameObject(GameObject gameObject)

Parameters

gameObject GameObject

The game object to inspect.

Returns

TrashContainer

A trash-container wrapper, or null when the game object has no container component.

Exceptions

ArgumentNullException

gameObject is null or destroyed.

TryBagTrash()

Bags the current contents through the native server-authoritative path when eligible.

public bool TryBagTrash()

Returns

bool

true when native bagging was invoked; otherwise, false.

Events

OnTrashAdded

Occurs after the native container adds trash.

public event Action<string> OnTrashAdded

Event Type

Action<string>

Remarks

A handler may be removed through any wrapper for the same native container. Duplicate subscriptions are removed one at a time.

OnTrashLevelChanged

Occurs after the native container level changes.

public event Action OnTrashLevelChanged

Event Type

Action

Remarks

A handler may be removed through any wrapper for the same native container. Duplicate subscriptions are removed one at a time.