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.
- Listed in Global namespace: A to B
- Inherits or implements
NetworkEntityBehaviour
Constructors
| Member | What it is |
|---|---|
BuildupChild() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
10 private and internal fields
| Member | What it is |
|---|---|
private Pickup basePickup | The pickup this slot belongs to. |
private MonoBehaviour[] childComponents | Components implementing IGetChild that are told when a child is added or lost. |
private Pickup childPickup | The child's common pickup, if it has one. |
private bool hasPickup | Whether the child has a pickup. |
private bool hasPullup | Whether a PullPickup was found under this slot. |
private int index | This slot's index in the parent BuildupPickup. |
private ToggleUnityEvent inverseToggleHasChild | Event fired with the opposite of has-child. |
private Pickup pullupPickup | Pickup of a PullPickup under this slot, if any. |
private ToggleUnityEvent toggleHasChild | Event fired with whether the slot has a child. |
private NetworkPrefab toSpawn | Backing field for Prefab. |
Properties
| Member | What 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
| Member | What it is |
|---|---|
event Action<int, bool> LostChild | Raised with the slot index when the child is grabbed or destroyed. BuildupPickup listens and calls Dispose. |
1 private and internal event
Methods
| Member | What 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
| Member | What 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: