Beispiel #1
0
        public bool Remove(int id)
        {
            if (!IdIndex.TryGetValue(id, out MeshSource source))
            {
                return(false);
            }

            NativeList <int2> tileCoords = NativeBuildUtitls.GetOverlappingTiles(BuildSettings, source.Info.Bounds);

            for (int i = 0; i < tileCoords.Length; i++)
            {
                int2 coord = tileCoords[i];

                int sourceId;
                NativeMultiHashMapIterator <int2> iterator;
                bool found = TileSources.TryGetFirstValue(coord, out sourceId, out iterator);

                while (found && sourceId == id)
                {
                    TileSources.Remove(iterator);
                    found = TileSources.TryGetNextValue(out sourceId, ref iterator);
                }
            }

            IdIndex.Remove(source.Id);
            CustomIdToIdIndex.Remove(source.Info.CustomData);
            source.Dispose();

            return(true);
        }
Beispiel #2
0
        public void Add(MeshSource source)
        {
            if (IdIndex.TryGetValue(source.Id, out MeshSource existing))
            {
                existing.Dispose();
                IdIndex.Remove(source.Id);
                CustomIdToIdIndex.Remove(source.Info.CustomData);
            }

            IdIndex.TryAdd(source.Id, source);
            CustomIdToIdIndex.TryAdd(source.Info.CustomData, source.Id);

            NativeList <int2> tileCoords = NativeBuildUtitls.GetOverlappingTiles(BuildSettings, source.Info.Bounds);

            for (int i = 0; i < tileCoords.Length; i++)
            {
                int2 coord = tileCoords[i];
                TileSources.Add(coord, source.Id);
            }
            tileCoords.Dispose();
        }