class XORBeamMeUp : GateLocal { override fun collectable() = true var partner : XORBeamMeUp = null // A bodge, so that we con't have to curry the player var warpingPlayer : Player = null override fun invading( movement : Movement ) { warpingPlayer = movement.item as Player val seconds = 1 val spins = 3 val others = PlayDirector.instance.mainStage.findRolesByClass( XORBeamMeUp ) for ( other in others ) { if ( other != this ) { partner = other } } replaceAction( ( // Tumble the player into this gate ScaleTo( warpingPlayer.actor, seconds, 0.1, Eases.easeOut ) and TurnBy( warpingPlayer.actor.direction, seconds, Angle.degrees( 360 * spins ), Eases.easeIn ) and Fade( warpingPlayer.actor.color, seconds, 0, Eases.easeInQuad ) ) thenOnce this:>warp then ( ScaleTo( warpingPlayer.actor, seconds, 1.0, Eases.easeIn ) and TurnBy( warpingPlayer.actor.direction, seconds, Angle.degrees( 360 * spins ), Eases.easeOut ) and Fade( warpingPlayer.actor.color, seconds, 1.0, Eases.easeOutQuad ) ) thenOnce this:>postWarp ) } fun warp() { warpingPlayer.warpTo( partner.square ) } fun postWarp() { partner.exitGate( warpingPlayer ) warpingPlayer.replaceAction( warpingPlayer.createAction() ) } // Looks ENWS for the first empty square, and moves out in that direction. fun exitGate( player : Player ) { for ( dir in 0..3 ) { val next = look(dir) if (next.isEmpty()) { player.autoInstructions = Item.directionAbbreviation(dir) + player.autoInstructions return } } } override fun invaded( movement : Movement ) : boolean { movement.item.replaceAction( null ) return false } }