/// <summary>
/// The object has been picked up.
/// </summary>
/// <param name="pickedUpBy">A reference to the object that picked up the object.</param>
protected virtual void ObjectPickedUp(GameObject pickedUpBy)
{
// The object may not have been instantiated within the scene.
if (m_GameObject == null) {
return;
}
m_IsDepleted = true;
// Send an event notifying of the pickup.
EventHandler.ExecuteEvent(pickedUpBy, "OnObjectPickedUp", this);
// Optionally play a pickup sound if the object picking up the item is attached to a camera.
// A null GameObject indicates that the clip will play from the AudioManager.
var foundCamera = Shared.Camera.CameraUtility.FindCamera(pickedUpBy);
if (foundCamera != null) {
m_PickupAudioClipSet.PlayAtPosition(m_Transform.position);
}
if (m_DestroyDelay == 0) {
DestroyPickup();
} else if (m_DestroyDelay > 0) {
Scheduler.Schedule(m_DestroyDelay, DestroyPickup);
}
}
public virtual void DestroyPickup()
{
if (ObjectPoolBase.InstantiatedWithPool(m_GameObject)) {
#if ULTIMATE_CHARACTER_CONTROLLER_MULTIPLAYER
if (NetworkObjectPool.IsNetworkActive()) {
NetworkObjectPool.Destroy(m_GameObject);
return;
}
#endif
ObjectPoolBase.Destroy(m_GameObject);
} else {
// Deactivate the pickup for now. It can appear again if a Respawner component is attached to the GameObject.
m_GameObject.SetActive(false);
}
}