Example #1
0
        public void Despawn_NotAddedPool_ThrowsException()
        {
            var entity = Substitute.For <PoolableEntity>();

            _poolService = new PoolService();

            Assert.Throws <ArgumentException>(() => _poolService.Despawn(entity));
        }
Example #2
0
        public void Despawn_Successfully()
        {
            var entity = Substitute.For <PoolableEntity>();

            _poolService.Despawn(entity);

            _pool.Received().Despawn(entity);
        }
Example #3
0
    private IEnumerator DespawnRoutine(float delay)
    {
        float elapsed = 0.0f;

        while (elapsed < delay)
        {
            yield return(null);

            elapsed += Time.deltaTime;
        }

        StopAllCoroutines();
        PoolService.Despawn(this);
        OnDespawn();
    }
Example #4
0
    public void Despawn(float delay = 0)
    {
        if (!m_isSpawned)
        {
            return;
        }

        if (delay == 0)
        {
            StopAllCoroutines();
            PoolService.Despawn(this);
            OnDespawn();

            return;
        }

        StartCoroutine(DespawnRoutine(delay));
    }