public BaseTile getFringeTile ( MisoSceneModel scene , int col , int row , Map < FringeTile , WeakReference < FringeTile > > fringes , Map < Long , BufferedImage > masks ) { // get the tileset id of the base tile we are considering int underset = adjustTileSetId ( scene . getBaseTileId ( col , row ) >> 16 ) ; // start with a clean temporary fringer map _fringers . clear ( ) ; boolean passable = true ; // walk through our influence tiles for ( int y = row - 1 , maxy = row + 2 ; y < maxy ; y ++ ) { for ( int x = col - 1 , maxx = col + 2 ; x < maxx ; x ++ ) { // we sensibly do not consider ourselves if ( ( x == col ) && ( y == row ) ) { continue ; } // determine the tileset for this tile int btid = scene . getBaseTileId ( x , y ) ; int baseset = adjustTileSetId ( ( btid <= 0 ) ? scene . getDefaultBaseTileSet ( ) : ( btid >> 16 ) ) ; // determine if it fringes on our tile int pri = _fringeconf . fringesOn ( baseset , underset ) ; if ( pri == - 1 ) { continue ; } FringerRec fringer = ( FringerRec ) _fringers . get ( baseset ) ; if ( fringer == null ) { fringer = new FringerRec ( baseset , pri ) ; _fringers . put ( baseset , fringer ) ; } // now turn on the appropriate fringebits fringer . bits |= FLAGMATRIX [ y - row + 1 ] [ x - col + 1 ] ; // See if a tile that fringes on us kills our passability, // but don't count the default base tile against us, as // we allow users to splash in the water. if ( passable && ( btid > 0 ) ) { try { BaseTile bt = ( BaseTile ) _tmgr . getTile ( btid ) ; passable = bt . isPassable ( ) ; } catch ( NoSuchTileSetException nstse ) { log . warning ( "Autofringer couldn't find a base set while attempting to " + "figure passability" , nstse ) ; } } } } // if nothing fringed, we're done int numfringers = _fringers . size ( ) ; if ( numfringers == 0 ) { return null ; } // otherwise compose a FringeTile from the specified fringes FringerRec [ ] frecs = new FringerRec [ numfringers ] ; for ( int ii = 0 , pp = 0 ; ii < 16 ; ii ++ ) { FringerRec rec = ( FringerRec ) _fringers . getValue ( ii ) ; if ( rec != null ) { frecs [ pp ++ ] = rec ; } } return composeFringeTile ( frecs , fringes , TileUtil . getTileHash ( col , row ) , passable , masks ) ; }
Compute and return the fringe tile to be inserted at the specified location .