MapEditor.SetupPaintTileBounds C# (CSharp) Method

SetupPaintTileBounds() public method

public SetupPaintTileBounds ( TileBounds, b, int idx ) : void
b TileBounds,
idx int
return void
    void SetupPaintTileBounds(TileBounds b, int idx)
    {
        Map m = (Map)target;
        float s = m.sideLength;
        float h = m.tileHeight;
        int y = idx/(int)m.size.x;
        int x = idx-(y*(int)m.size.x);
        int z = editZ;
        if(!m.HasTileAt(x,y,z)) {
            //just go ahead and give up
            b.center = Vector3.zero;
            b.size = Vector3.zero;
        } else {
            int zMaxHeight = 1;
            MapTile t = m.TileAt(x,y,z);
            if(t != null) {
                z = t.z;
                zMaxHeight = t.maxHeight;
            }
            Vector3 hereTop = m.transform.position + new Vector3(x*s, (z+zMaxHeight-1)*h, y*s);
            b.center = hereTop + new Vector3(0, -(zMaxHeight*h)/2, 0);
            b.size = new Vector3(s, h*zMaxHeight, s);
        }
        if(idx < tiles.Count) {
            tiles[idx] = b;
        } else {
            tiles.Add(b);
        }
    }