class CQRock : Movable { override fun begin() { speed *= 4 super.begin() } override fun myTurn() { val south = lookSouth() val below = south.item() if ( south.isEmpty() ) { moveSouth() } else if ( below is CQEnemy || below.isPlayer() ) { replaceAction( null ) below.actor.event( "squash" ) if (below.isMoving()) { (below as Movable).movement.cancel() } below.replaceAction( squashAction(below) thenOnce( this:>postMove.curry(below) ) ) } } fun postMove( below : Item ) { val mySquare = square below.kill() val soil = actor.createChild( "soil" ).role as Soil soil.actor.y -= gridSize() mySquare.neighbour( 0, -1 ).addOccupant( soil, true ) mySquare.addOccupant( this ) replaceAction( createAction() ) } fun delay() { replaceAction( Delay( 0.55 ) then createAction() ) } fun squashAction( below : Item ) : Action { return ( Fade( below.actor.color, 0.05, 0 ) then Fade( below.actor.color, 0.05, 1 ) ).repeat( 2 ) } }