class GateLocal : Item { @Attribute var gatePair = "" override fun collectable() = true override fun invading( movement : Movement ) { val player = movement.item val seconds = 1.0 val spins = 3 replaceAction( ( // Tumble the player into this gate ScaleTo( player.actor, seconds, 0.1, Eases.easeOut ) and TurnBy( player.actor.direction, seconds, Angle.degrees( 360 * spins ), Eases.easeIn ) and Fade( player.actor.color, seconds, 0, Eases.easeInQuad ) ) thenOnce this:>postTumble.curry( player ) then ( // Tumble the player out of the other gate. ScaleTo( player.actor, seconds, 1.0, Eases.easeIn ) and TurnBy( player.actor.direction, seconds, Angle.degrees( 360 * spins ), Eases.easeOut ) and Fade( player.actor.color, seconds, 1.0, Eases.easeOutQuad ) ) thenOnce this:>postTumble2.curry( player ) ) } fun postTumble( item : Item ) { val others = PlayDirector.instance.mainStage.findRolesByClass( GateLocal ) for ( other in others ) { if ( other != this && other.gatePair == gatePair ) { item.warpTo( other.square ) return } } } fun postTumble2( item : Item ) { item.replaceAction( item.createAction() ) } override fun invaded( movement : Movement ) : boolean { movement.item.replaceAction( null ) return false } }