Skip to main content

PickupArea

A class in Root.Township, the global namespace.

A trigger that tracks which pickups with any of the allowed tags are inside it and raises events as they come and go.

Constructors​

MemberWhat it is
PickupArea()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

5 private and internal fields
MemberWhat it is
private PickupEvent addedBacking field for Added.
private List<PickupTag> allowedTagsPickup tags that count. A pickup needs at least one.
private HashSet<Pickup> containedBacking field for Contained.
private bool isAllowingCraftedWhether crafted pickups count.
private PickupEvent removedBacking field for Removed.

Properties​

MemberWhat it is
PickupEvent Added { get; }Event raised when an allowed pickup enters.
HashSet<Pickup> Contained { get; }The allowed pickups inside right now.
PickupEvent Removed { get; }Event raised when a pickup leaves, is destroyed, or the area is disabled.

Methods​

4 private and internal methods
MemberWhat it is
private void Destroyed(NetworkEntity entity, bool isUnload)Private: removes a contained pickup when it is destroyed and raises Removed.
private void OnDisable()Private: raises Removed for every contained pickup and clears the set.
private void OnTriggerEnter(Collider other)Private: adds a pickup that has an allowed tag and is not being destroyed. Crafted ones only if isAllowingCrafted.
private void OnTriggerExit(Collider other)Private: removes a pickup that leaves and raises Removed.

Used in​

Members of other types that take, return or hold a PickupArea: