internal void WasDespawned()
 {
     CancelInvoke();
     IsSpawned = false;
     Despawned?.Invoke(this);
     BroadcastMessage("OnDespawned", SendMessageOptions.DontRequireReceiver);
 }
Exemple #2
0
    private IEnumerator DieAsync()
    {
        Vector3     startScale = transform.localScale;
        const float duration   = 1;

        for (float time = 0; time < 1; time += Time.deltaTime)
        {
            float t = time / duration;
            transform.localScale = Vector3.Lerp(startScale, Vector3.zero, t);
            yield return(null);
        }

        Destroy(gameObject);
        Despawned?.Invoke();
        Destroy(gameObject);
    }
Exemple #3
0
 public void Despawn()
 {
     _despawnTimer?.Dispose();
     Despawned?.Invoke(this, null);
 }
Exemple #4
0
 /// <summary>
 /// Despawn a tree into the pool
 /// </summary>
 /// <param name="obj"></param>
 public void Despawn(GameObject obj)
 {
     Despawned?.Invoke();
     obj.SetActive(false);
     m_TreePool.Push(obj);
 }
Exemple #5
0
 public void Despawn()
 {
     gameObject.SetActive(false);
     Despawned?.Invoke();
 }