public void Despawn_NotAddedPool_ThrowsException() { var entity = Substitute.For <PoolableEntity>(); _poolService = new PoolService(); Assert.Throws <ArgumentException>(() => _poolService.Despawn(entity)); }
public void Despawn_Successfully() { var entity = Substitute.For <PoolableEntity>(); _poolService.Despawn(entity); _pool.Received().Despawn(entity); }
private IEnumerator DespawnRoutine(float delay) { float elapsed = 0.0f; while (elapsed < delay) { yield return(null); elapsed += Time.deltaTime; } StopAllCoroutines(); PoolService.Despawn(this); OnDespawn(); }
public void Despawn(float delay = 0) { if (!m_isSpawned) { return; } if (delay == 0) { StopAllCoroutines(); PoolService.Despawn(this); OnDespawn(); return; } StartCoroutine(DespawnRoutine(delay)); }