class Progress : AbstractRole { @Attribute var expectedCostumeName = "" @Attribute( rows = 3 ) var text = "" @Attribute var duration = 4 var costume :Costume var square : Square override fun activated() { actor.hide() square = PlayDirector.instance.mainStage.squareAtPoint( actor.x, actor.y ) costume = Resources.instance.costumes.find( expectedCostumeName ) } override fun tick() { if (passes()) { val player = PlayDirector.instance.player if (player != null && player.actor.stage != null ) { player.speak( text, duration ) actor.die() } } } fun passes() : boolean { val occupant = if ( square.occupant == null ) square.alternateOccupant else square.occupant if (occupant == null || occupant.actor == null) return expectedCostumeName == "" return occupant.actor.costume == costume } }