Exemplo n.º 1
0
        public void SetTile(Vector3Int position, LayerTile tile, Matrix4x4?matrixTransform = null, Color?color = null)
        {
            if (Layers.TryGetValue(tile.LayerType, out var layer))
            {
                if (Application.isPlaying == false)
                {
                    layer.SetTile(position, tile,
                                  matrixTransform.GetValueOrDefault(Matrix4x4.identity),
                                  color.GetValueOrDefault(Color.white));
                }


                TileLocation TileLcation = null;
                lock (PresentTiles)
                {
                    PresentTiles[layer].TryGetValue(position, out TileLcation);
                }

                if (TileLcation != null)
                {
                    TileLcation.Tile            = tile;
                    TileLcation.TransformMatrix = matrixTransform.GetValueOrDefault(Matrix4x4.identity);
                    TileLcation.Colour          = color.GetValueOrDefault(Color.white);
                    TileLcation.OnStateChange();
                }
                else
                {
                    TileLcation                    = GetPooledTile();
                    TileLcation.PresentlyOn        = layer;
                    TileLcation.PresentMetaTileMap = this;
                    TileLcation.TileCoordinates    = position;

                    TileLcation.Tile            = tile;
                    TileLcation.TransformMatrix = matrixTransform.GetValueOrDefault(Matrix4x4.identity);
                    TileLcation.Colour          = color.GetValueOrDefault(Color.white);
                    lock (PresentTiles)
                    {
                        PresentTiles[layer][position] = TileLcation;
                    }

                    TileLcation.OnStateChange();
                }

                // layer.SetTile(position, tile,
                // matrixTransform.GetValueOrDefault(Matrix4x4.identity),
                // color.GetValueOrDefault(Color.white));
            }
            else
            {
                LogMissingLayer(position, tile.LayerType);
            }
        }
Exemplo n.º 2
0
        public void RemoveTileWithlayer(Vector3Int position, LayerType refLayer)
        {
            if (refLayer == LayerType.Objects)
            {
                return;
            }

            if (Layers.TryGetValue(refLayer, out var layer))
            {
                if (layer.LayerType == LayerType.Underfloor)
                {
                    (layer as UnderFloorLayer).RemoveSpecifiedTile(position, null, true);
                }


                TileLocation TileLcation = null;
                lock (PresentTiles)
                {
                    PresentTiles[layer].TryGetValue(position, out TileLcation);
                }

                if (TileLcation != null)
                {
                    TileLcation.Tile = null;
                    TileLcation.OnStateChange();
                }

                //layer.RemoveTile(position);
            }
            else
            {
                LogMissingLayer(position, refLayer);
            }
        }
Exemplo n.º 3
0
        public void RemoveTile(Vector3Int position, bool RemoveAll = true)
        {
            TileLocation TileLcation = null;

            foreach (var layer in LayersValues)
            {
                if (layer.LayerType == LayerType.Objects)
                {
                    continue;
                }
                if (Application.isPlaying == false)
                {
                    if (layer.RemoveTile(position))
                    {
                        if (RemoveAll == false)
                        {
                            return;
                        }
                    }
                    continue;
                }

                lock (PresentTiles)
                {
                    PresentTiles[layer].TryGetValue(position, out TileLcation);
                }

                if (TileLcation != null)
                {
                    TileLcation.Tile = null;
                    TileLcation.OnStateChange();
                    if (RemoveAll == false)
                    {
                        return;
                    }
                }
            }

            // for (var i = 0; i < LayersValues.Length; i++)
            // {
            // Layer layer = LayersValues[i]; //layer.LayerType < refLayer &&
            // TODO: @Bod9001 What is the purpose of this strange conditional logic?
            // idk - Bod9001
            // if (
            // !(refLayer == LayerType.Objects && layer.LayerType == LayerType.Floors) &&
            // refLayer != LayerType.Grills)
            // {
            // if (layer.RemoveTile(position) && RemoveAll == false)
            // {
            // return;
            // }
            // }
            // }
        }