Exemplo n.º 1
0
        public void AddVob(T vob)
        {
            ExceptionCheck.ArgumentNull(vob);

            if (indices.ContainsKey(vob))
            {
                return;
            }

            // Despawn old vob
            T otherVob = vobs[currentIndex];

            if (otherVob != null)
            {
                indices.Remove(otherVob);
                otherVob.OnDespawn -= RemoveVobHandler;
                if (otherVob.IsSpawned)
                {
                    otherVob.Despawn();
                }
            }

            // add new vob
            vobs[currentIndex] = vob;
            indices.Add(vob, currentIndex);
            vob.OnDespawn += RemoveVobHandler;

            // change current index
            if (++currentIndex >= Capacity)
            {
                currentIndex = 0;
            }
        }
Exemplo n.º 2
0
        public void RemoveVob(T vob)
        {
            ExceptionCheck.ArgumentNull(vob);

            if (!indices.TryGetValue(vob, out int index))
            {
                return;
            }

            vobs[index] = null;
            indices.Remove(vob);
            vob.OnDespawn -= RemoveVobHandler;
        }