RemoveFast() public method

public RemoveFast ( item ) : bool
return bool
Beispiel #1
0
    public void Update()
    {
        DelayedInstantiateData instantiateData;

        for (int i = 0; i < delayedInstantiateDataBuffer.count; i++)
        {
            instantiateData = delayedInstantiateDataBuffer[i];
            if (Time.time - instantiateData.timestamp > instantiateData.delay)
            {
                var obj = PoolInstantiate(instantiateData.prefab, instantiateData.position, instantiateData.rotation);
                delayedInstantiateDataBuffer.RemoveFast(i);
                if (instantiateData.callback != null)
                {
                    instantiateData.callback(obj);
                }
            }
        }
        DelayedDestroyData destroyData;

        for (int i = 0; i < delayedDestroyDataBuffer.count; i++)
        {
            destroyData = delayedDestroyDataBuffer[i];
            if (Time.time - destroyData.timestamp > destroyData.delay)
            {
                PoolDestroy(destroyData.target, removeParent: destroyData.removeParent);
                delayedDestroyDataBuffer.RemoveFast(i);
                if (destroyData.callback != null)
                {
                    destroyData.callback();
                }
            }
        }
    }
Beispiel #2
0
    void Update()
    {
        if (_spawnAnimation)
        {
            _animT += Time.deltaTime / translationAnimDuration;
            currentPod.rigidbody.position = Vector3.LerpUnclamped(transform.position, targetPodPos, podTranslationCurve.Evaluate(_animT));
            if (_animT >= 1f)
            {
                currentPod.BeginIdleAnimation();
                _spawnAnimation = false;
            }
        }

        if (podDeployAnimActive)
        {
            if (_podParentAnim <= 1f)
            {
                _podParentAnim += Time.deltaTime / podParentDeployDuration;
                podParent.transform.position = new Vector3 {
                    z = Mathf.Lerp(podParentStartZ, podParentTargetZ, podParentDeployCurve.Evaluate(_podParentAnim))
                };
                if (_podParentAnim >= 1f)
                {
                    currentPod.transform.SetParent(null, worldPositionStays: true);
                    currentPod.rigidbody.constraints = RigidbodyConstraints2D.None;
                    exitingPods.Add(currentPod);
                    currentPod = null;
                    GameManager.instance.GoToWaitState();
                    podDeployAnimActive = false;
                }
            }
        }

        for (int i = 0; i < exitingPods.count; i++)
        {
            var pod = exitingPods[i];
            pod.FireParts();
            pod.rigidbody.AddTorque(Mathf.Sin(Time.time) * 500f * Time.fixedDeltaTime);
            var podXY    = (Vector2)pod.transform.localPosition;
            var anchorXY = (Vector2)targetPodPos;
            var dist     = (anchorXY - podXY).magnitude;
            if (dist > podKillDist)
            {
                pod.SetLayer(podDefaultLayer);
                pod.Kill();
                podDeployAnimActive = false;
                exitingPods.RemoveFast(i);
            }
        }
    }