Exemple #1
0
        public void OnVoxelDestroyed(Voxel v)
        {
            if (v.IsEmpty)
            {
                return;
            }

            Voxel Voxel = v;

            RoomBuilder.OnVoxelDestroyed(v);

            List <Stockpile> toRemove          = new List <Stockpile>();
            List <Stockpile> currentStockpiles = new List <Stockpile>();

            currentStockpiles.AddRange(Stockpiles);
            foreach (Stockpile s in currentStockpiles)
            {
                if (s.ContainsVoxel(Voxel))
                {
                    s.RemoveVoxel(Voxel);
                }

                if (s.Voxels.Count == 0)
                {
                    toRemove.Add(s);
                }
            }

            foreach (Stockpile s in toRemove)
            {
                Stockpiles.Remove(s);
                s.Destroy();
            }
        }
Exemple #2
0
        public void OnVoxelDestroyed(VoxelHandle V)
        {
            if (!V.IsValid)
            {
                return;
            }
            RoomBuilder.OnVoxelDestroyed(V);

            var toRemove = new List <Stockpile>();

            foreach (var s in new List <Stockpile>(Stockpiles).Where(stockpile => stockpile.IsBuilt))
            {
                if (s.ContainsVoxel(V))
                {
                    s.RemoveVoxel(V);
                }

                if (s.Voxels.Count == 0)
                {
                    toRemove.Add(s);
                }
            }

            foreach (Stockpile s in toRemove)
            {
                Stockpiles.Remove(s);
                s.Destroy();
            }
        }
Exemple #3
0
        public void OnVoxelDestroyed(VoxelHandle V)
        {
            if (!V.IsValid)
            {
                return;
            }
            RoomBuilder.OnVoxelDestroyed(V);

            var toRemove = new List <Stockpile>();

            foreach (var s in new List <Stockpile>(Stockpiles).Where(stockpile => stockpile.IsBuilt))
            {
                if (s.ContainsVoxel(V))
                {
                    s.RemoveVoxel(V);
                }

                if (s.Voxels.Count == 0)
                {
                    toRemove.Add(s);
                }
            }

            foreach (Stockpile s in toRemove)
            {
                foreach (var resource in s.Resources)
                {
                    var resourceType = ResourceLibrary.GetResourceByName(resource.ResourceType);

                    foreach (var tag in resourceType.Tags)
                    {
                        if (CachedResourceTagCounts.ContainsKey(tag))
                        {
                            CachedResourceTagCounts[tag] -= resource.NumResources;
                            Trace.Assert(CachedResourceTagCounts[tag] >= 0);
                        }
                    }
                }
                RecomputeCachedVoxelstate();
                Stockpiles.Remove(s);
                s.Destroy();
            }
        }