MapEditor.AdjustIsoHeightAt C# (CSharp) Method

AdjustIsoHeightAt() public method

public AdjustIsoHeightAt ( int idx, Neighbors, collidedFace, Vector3 wpos, int dh ) : void
idx int
collidedFace Neighbors,
wpos Vector3
dh int
return void
    void AdjustIsoHeightAt(int idx, Neighbors collidedFace, Vector3 wpos, int dh)
    {
        Map m = (Map)target;
        int ny = idx/(int)m.size.x;
        int nx = idx-(ny*(int)m.size.x);
        int nz = editZ;
        MapTile t = m.TileAt(nx,ny,nz);
        if(t==null) { return; }
        Vector3 tpos = m.InverseTransformPointWorld(wpos);
        Neighbors side = Neighbors.None;
        //get the fractional part of each coord
        /*		Debug.Log("adjust height at "+nx+","+ny+","+nz+", tpos "+tpos+", wpos "+wpos);*/
        tpos.x = modf(tpos.x);
        tpos.y = modf(tpos.y);
          //tpos.z = modf(tpos.z);
        bool top = tpos.z > t.z + (t.maxHeight-t.z)/2;
        /*		Debug.Log("tpos frac "+tpos.x+", "+tpos.y+", "+tpos.z);*/
        if((collidedFace & Neighbors.FrontLeft) != 0) {
            side = Neighbors.FrontLeft;
        } else if((collidedFace & Neighbors.FrontRight) != 0) {
            side = Neighbors.FrontRight;
        } else if((collidedFace & Neighbors.BackRight) != 0) {
            side = Neighbors.BackRight;
        } else if((collidedFace & Neighbors.BackLeft) != 0) {
            side = Neighbors.BackLeft;
        } else { //top or bottom
            top = (collidedFace & Neighbors.Top) != 0;
            if(tpos.x < 0.3 && tpos.y < 0.75 && tpos.y > 0.25) {
                side = Neighbors.FrontLeft;
            } else if(tpos.x > 0.3 && tpos.y < 0.75 && tpos.y > 0.25) {
                side = Neighbors.BackRight;
            } else if(tpos.y < 0.3 && tpos.x < 0.75 && tpos.x > 0.25) {
                side = Neighbors.FrontRight;
            } else if(tpos.y > 0.3 && tpos.x < 0.75 && tpos.x > 0.25) {
                side = Neighbors.BackLeft;
            }
        }
        RegisterUndo("Adjust Tile Height");
        m.AdjustHeightOnSidesOfTile(nx, ny, nz, dh, side, top);
        EditorUtility.SetDirty(target);
    }