MapEditor.SetupAddRemoveTileBounds C# (CSharp) Method

SetupAddRemoveTileBounds() public method

public SetupAddRemoveTileBounds ( TileBounds, b, int idx ) : void
b TileBounds,
idx int
return void
    void SetupAddRemoveTileBounds(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;
        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);
        }
    }