class Plasma : ActionRole(), ContactListenerRole, Switchable { var on = true override fun switch(value: bool) { on = value if (on) { actor.event("on") replaceAction(createAction()) } else { actor.event("off") replaceAction(null) } } override fun createAction() = ( EventAction(actor, "default") then Delay(0.05) ).forever() override fun beginContact(contact: Contact, otherActor: Actor) { if (on) { val otherRole = otherActor.role if (otherRole is DollPart) { val doll = (otherRole as DollPart).doll if ( ! doll.ending ) { doll.zapped() // No zap sounds on the Options scene. if (director !is Menu) { actor.event( "zap" ) } } } } } override fun endContact(contact: Contact, otherActor: Actor) {} }