////////////////

        internal void Update()
        {
            if (!LoadHelpers.IsWorldBeingPlayed())
            {
                return;
            }

            foreach (var kv in this.Data)
            {
                foreach (var kv2 in kv.Value.ToArray())
                {
                    int      x    = kv.Key;
                    int      y    = kv2.Key;
                    TileData data = kv2.Value;

                    if (!TileDataManager.IsValidTile(x, y))
                    {
                        this.Data[x].Remove(y);
                    }
                    else if (data.Damage > 0)
                    {
                        if (data.TTL-- <= 0)
                        {
                            data.Damage = 0;
                            data.TTL    = 0;
                        }
                    }
                }
            }
        }
        public void Clear()
        {
            this.Damage   = 0;
            this.TileType = 0;
            this.TTL      = 0;

            TileDataManager.RerollCrackStyle(this);
        }
        ////////////////

        public int AddDamage(int x, int y, int damage)
        {
            if (damage == 0)
            {
                return(-1);
            }

            bool     isValid = TileDataManager.IsValidTile(x, y);
            TileData data;

            data = this.Data.Get2DOrDefault(x, y);
            if (data == null)
            {
                if (!isValid)
                {
                    return(-1);
                }

                data = new TileData();
                this.Data.Set2D(x, y, data);
            }
            else
            {
                if (!isValid)
                {
                    this.Data[x].Remove(y);
                    return(-1);
                }
            }

            data.Damage += damage;
            data.TTL     = 60 * 60;
            data.AnimationTimeDuration = TileDataManager.HitAnimationMaxDuration;
            //data.AnimationDirection = ( Main.rand.NextFloat() * 6.28318548f ).ToRotationVector2() * 2f;

            return(data.Damage);
        }
        public bool CanDrawTileOverlay(int tileX, int tileY)
        {
            /*if( !Main.SettingsEnabled_MinersWobble ) {
             *      return;
             * }*/

            Tile     tile = Framing.GetTileSafely(tileX, tileY);
            TileData data = this.Data[tileX][tileY];

            if (data.AnimationTimeDuration > 0)
            {
                data.AnimationTimeDuration--;
            }

            if (TileHelpers.IsAir(tile))
            {
                return(false);
            }
            if (!TileDataManager.IsValidTile(tileX, tileY))
            {
                return(false);
            }
            if (tile.slope() > 0)
            {
                return(false);
            }
            if (tile.halfBrick())
            {
                return(false);
            }
            if (TileLoader.IsClosedDoor(tile))
            {
                return(false);
            }

            if (tile.type == 5)
            {
                int frameX = (int)(tile.frameX / 22);
                int frameY = (int)(tile.frameY / 22);

                if (frameY < 9)
                {
                    if (!
                        ((frameX != 1 && frameX != 2) || frameY < 6 || frameY > 8) &&
                        (frameX != 3 || frameY > 2) &&
                        (frameX != 4 || frameY < 3 || frameY > 5) &&
                        (frameX != 5 || frameY < 6 || frameY > 8)
                        )
                    {
                        return(false);
                    }
                }
            }
            else if (tile.type == 72)
            {
                if (tile.frameX > 34)
                {
                    return(false);
                }
            }

            return(true);
        }