public void do_fov_rec_shadowcast(int x, int y, int radius)
    {
        FOV_set_this_run.Fill(false);
        in_FOV.Fill(false);

        Action <int, int> ff = (int xx, int yy) =>
        {
            in_FOV.AtSet(xx, yy, true);
            fogofwar.AtSet(xx, yy, false);
            Etilesprite et = displaychar.AtGet(xx, yy);
            //new debug
            if ((int)et < 0 || (int)et > 255)
            {
                Debug.Log("ET OUT OF BOUNDS =" + (int)et);
            }
            //end new debug
            playermemory.AtSet(xx, yy, et);

            if (itemgrid[xx, yy] != null && itemgrid[xx, yy].ismob == false)
            {
                minimap.SetPixel(xx, yy, (Color)minimapcolours[(int)itemgrid[xx, yy].tile]);
            }
            else
            {
                if (buildings[xx, yy] != Etilesprite.EMPTY)
                {
                    minimap.SetPixel(xx, yy, (Color)minimapcolours[(int)buildings[xx, yy]]);
                }
                else
                {
                    minimap.SetPixel(xx, yy, (Color)minimapcolours[(int)et]);
                }
            }
            //if (et == Etilesprite.WALL) minimap.SetPixel(xx, yy, Color.grey);
            //else if (et == Etilesprite.FLOOR) minimap.SetPixel(xx, yy, Color.black);
        };

        for (sbyte i = 0; i < 8; i++)
        {
            cast_light(x, y, radius, 1, 1.0f, 0.0f, multipliers[0, i],
                       multipliers[1, i], multipliers[2, i], multipliers[3, i],
                       ff
                       );
        }
        ff(x, y);

        minimap.SetPixel(this.player.posx, this.player.posy, Color.magenta);
        minimap.Apply(false);
    }
    public void do_fov_foradynamiclight(int callx, int cally, int radius, Color clr)
    {
        FOV_set_this_run.Fill(false);

        //

        Action <int, int> ff = (int xx, int yy) =>
        {
            dolight(callx, cally, xx, yy, radius, clr, false);//dynamiclight.AtGet(xx, yy)); new 18 jan
        };

        for (int i = 0; i < 8; i++)
        {
            cast_light(callx, cally, radius, 1, 1.0f, 0.0f, multipliers[0, i],
                       multipliers[1, i], multipliers[2, i], multipliers[3, i],
                       ff
                       );
        }
        ff(callx, cally);
    }
    void do_fov_foralight(int callx, int cally, int radius, Color clr, sbyte directional = -1)
    {
        //if (directional != 1) return;
        FOV_set_this_run.Fill(false);

        //auto ff = [this, callx, cally, radius, clr,directional](uint xx, uint yy){
        Action <int, int> ff = (int xx, int yy) =>
        {
            if (directional == -1)
            {
                goto lightit;
            }
            if (callx == xx && cally == yy)
            {
                goto lightit;
            }
            switch (directional)
            {
            case 0:    //n
                if (yy >= cally)
                {
                    return;
                }
                break;

            case 1:    //s
                if (yy <= cally)
                {
                    return;
                }
                break;

            case 2:    //e
                if (xx <= callx)
                {
                    return;
                }
                break;

            case 3:    //w
                if (xx >= callx)
                {
                    return;
                }
                break;
            }
lightit:
            dolight(callx, cally, xx, yy, radius, clr, true);//staticlight.AtGet(xx, yy)); new 18 jan
        };



        for (uint i = 0; i < 8; i++)
        {
            cast_light(callx, cally, radius, 1, 1.0f, 0.0f, multipliers[0, i],
                       multipliers[1, i], multipliers[2, i], multipliers[3, i],
                       ff//crash
                       );
        }
        ff(callx, cally);
    }