@ SuppressWarnings ( "ConstantConditions" ) public synchronized void add ( Interactable interactable ) { TerminalPosition topLeft = interactable . toBasePane ( TerminalPosition . TOP_LEFT_CORNER ) ; TerminalSize size = interactable . getSize ( ) ; interactables . add ( interactable ) ; int index = interactables . size ( ) - 1 ; for ( int y = topLeft . getRow ( ) ; y < topLeft . getRow ( ) + size . getRows ( ) ; y ++ ) { for ( int x = topLeft . getColumn ( ) ; x < topLeft . getColumn ( ) + size . getColumns ( ) ; x ++ ) { //Make sure it's not outside the map if ( y >= 0 && y < lookupMap . length && x >= 0 && x < lookupMap [ y ] . length ) { lookupMap [ y ] [ x ] = index ; } } } }
Adds an interactable component to the lookup map