Skip to main content

BuildupChild

A class in Root.Township, the global namespace.

One slot on a BuildupPickup that holds a child entity spawned onto it. It parents and freezes the child, and reports when the child is grabbed or destroyed so the parent can drop it.

Constructors​

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

Fields​

10 private and internal fields
MemberWhat it is
private Pickup basePickupThe pickup this slot belongs to.
private MonoBehaviour[] childComponentsComponents implementing IGetChild that are told when a child is added or lost.
private Pickup childPickupThe child's common pickup, if it has one.
private bool hasPickupWhether the child has a pickup.
private bool hasPullupWhether a PullPickup was found under this slot.
private int indexThis slot's index in the parent BuildupPickup.
private ToggleUnityEvent inverseToggleHasChildEvent fired with the opposite of has-child.
private Pickup pullupPickupPickup of a PullPickup under this slot, if any.
private ToggleUnityEvent toggleHasChildEvent fired with whether the slot has a child.
private NetworkPrefab toSpawnBacking field for Prefab.

Properties​

MemberWhat it is
NetworkEntity Child { get; private set; }The child entity currently in this slot, or null.
bool HasChild { get; private set; }Whether the slot currently holds a child.
NetworkPrefab Prefab { get; }Prefab spawned into this slot.

Events​

MemberWhat it is
event Action<int, bool> LostChildRaised with the slot index when the child is grabbed or destroyed. BuildupPickup listens and calls Dispose.
1 private and internal event
MemberWhat it is
private event Action<bool> DisposedRaised by Dispose with the forced flag, for registered disposable pickups.

Methods​

MemberWhat it is
void CheckRelease(Interactable interactable, Interactor interactor)When the base pickup is let go, makes the local player also let go of the pull-up pickup.
void Dispose(bool isForced = false)Releases the child: unfreezes its rigidbody, unhooks events, resets its save mode and chunking parent on the server, and tells child components.
void RegisterChild(NetworkEntity child, int index)Takes a spawned child into the slot: parents it, freezes its pickup, and on the server saves it as a child of this prefab.
7 private and internal methods
MemberWhat it is
private void Awake()Registers this entity's own disposable pickup, if any, to be disposed with the slot.
private void CheckDestroy(NetworkEntity entity, bool isUnload)Raises LostChild when the child is destroyed other than by chunk unload.
private void ChildInteracted(Interactable interactable, Interactor interactor)Server: raises LostChild when someone grabs the child.
private void OnValidate()Fills in basePickup from a parent if empty.
private void PickupFilter(Interactor interactor, Interactable interactable, ref bool result)Lets the child be grabbed only by the player already holding the base pickup.
private void RegisterDisposable(Component component)Hooks a component's IDisposablePickup to Disposed if it isn't disposed yet.
private void SetChild(bool hasChild)Fires the has-child toggle event and its inverse.

Used in​

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