Class TrashContainer
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
Capacity
Gets the maximum number of capacity units the container can hold.
public int Capacity { get; }
Property Value
Contents
Gets an immutable managed snapshot of the current content entries.
public IReadOnlyList<TrashContentEntry> Contents { get; }
Property Value
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
NormalizedLevel
Gets the current level divided by the container capacity.
public float NormalizedLevel { get; }
Property Value
Methods
FindInScene(bool)
Finds native trash containers in the loaded scene.
public static TrashContainer[] FindInScene(bool includeInactive = false)
Parameters
includeInactiveboolWhether 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
gameObjectGameObjectThe game object to inspect.
Returns
- TrashContainer
A trash-container wrapper, or
nullwhen the game object has no container component.
Exceptions
- ArgumentNullException
gameObjectisnullor destroyed.
TryBagTrash()
Bags the current contents through the native server-authoritative path when eligible.
public bool TryBagTrash()
Returns
- bool
truewhen native bagging was invoked; otherwise,false.
Events
OnTrashAdded
Occurs after the native container adds trash.
public event Action<string> OnTrashAdded
Event Type
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
Remarks
A handler may be removed through any wrapper for the same native container. Duplicate subscriptions are removed one at a time.