public void RemoveBuildable(Buildable build)
        {
            var removedSomething = m_Buildables.Remove(build);

            if (removedSomething)
            {
                OnBuildablesRemoved?.Invoke(new[] { build });
            }

            if (removedSomething && !IsBeingDestroyed && !IsGlobalCluster)
            {
                VerifyAndCorrectIntegrity();
            }
        }
        private void InternalHandleDeferred()
        {
            var deferredAdd = new List <Buildable>();

            while (m_DeferredAdd.TryDequeue(out var element))
            {
                deferredAdd.Add(element);
            }

            var deferredRemove = new List <Buildable>();

            while (m_DeferredRemove.TryDequeue(out var element))
            {
                deferredRemove.Add(element);
            }

            OnBuildablesAdded?.Invoke(deferredAdd);
            OnBuildablesRemoved?.Invoke(deferredRemove);
        }
        /// <summary>
        /// Removes multiple buildables from the base. This method does not destroy any of the buildables.
        /// </summary>
        /// <param name="builds">The <see cref="IEnumerable{Buildable}"/> of <see cref="Buildable"/>s to remove from the base.</param>
        public void RemoveBuildables(List <Buildable> builds)
        {
            var removed = new List <Buildable>();

            foreach (var build in m_Buildables.Where(builds.Remove).ToList())
            {
                m_Buildables.Remove(build);
                removed.Add(build);
            }

            if (removed.Count > 0)
            {
                OnBuildablesRemoved?.Invoke(removed);
            }

            if (removed.Count > 0 && !IsBeingDestroyed && !IsGlobalCluster)
            {
                VerifyAndCorrectIntegrity();
            }
        }