private void PickItUp(CrystalPickup pickup) { if (!pickup) { held = null; onPickedUp?.Invoke(CrystalType.None); droppedEvent.Invoke(); if (!isPedestal) { audioSource.PlayOneShot(placeCrystal); } return; } held = pickup; pickup.OnPickedUp(this); onPickedUp?.Invoke(pickup.type); pickedUpEvent.Invoke(); if (!isPedestal) { audioSource.PlayOneShot(pickupCrystal); } }
private void Awake() { if (held) { PickItUp(held); } else if (initialPrefab) { if (IsAllowedType(initialPrefab.type)) { var pickup = Instantiate(initialPrefab, transform.position, transform.rotation); PickItUp(pickup); initialPrefab = null; } else { Debug.LogError("initial prefab's crystal type is not allowed for this holder", this); } } }