[2269] | 1 | ///////////////////////////////////////////////////////////////////////////////
|
---|
| 2 | //
|
---|
| 3 | // ## ######
|
---|
| 4 | // ###### ###
|
---|
| 5 | // ## ############### Shark 3D Engine (www.shark3d.com)
|
---|
| 6 | // ########## # # #
|
---|
| 7 | // ######## Copyright (c) 1996-2006 Spinor GmbH.
|
---|
| 8 | // ######### # # # All rights reserved.
|
---|
| 9 | // ## ##########
|
---|
| 10 | // ##
|
---|
| 11 | //
|
---|
| 12 | ///////////////////////////////////////////////////////////////////////////////
|
---|
| 13 |
|
---|
| 14 | var int m_inside; // Number of characters inside the sensor volume.
|
---|
| 15 | var actor m_actu; // Actuator to send the animation commands to.
|
---|
| 16 | var actor m_speaker; // Speaker used for playing the sound.
|
---|
| 17 |
|
---|
| 18 | func public void initActor()
|
---|
| 19 | m_inside = 0;
|
---|
| 20 | m_actu = findActor( getParamStr( "actu" ) );
|
---|
| 21 | m_speaker = findActor( getParamStr( "speaker" ) );
|
---|
| 22 | end
|
---|
| 23 |
|
---|
| 24 | func public void finishActor()
|
---|
| 25 | end
|
---|
| 26 |
|
---|
| 27 | // Open the door:
|
---|
| 28 | func void open()
|
---|
| 29 | m_actu ^ play_to_end();
|
---|
| 30 | m_speaker ^ start();
|
---|
| 31 | var float duration = m_actu ^ float get_duration();
|
---|
| 32 | evtAppoint( "soundOff", duration );
|
---|
| 33 | end
|
---|
| 34 |
|
---|
| 35 | // Close the door:
|
---|
| 36 | func void close()
|
---|
| 37 | m_actu ^ play_to_start();
|
---|
| 38 | m_speaker ^ start();
|
---|
| 39 | var float duration = m_actu ^ float get_duration();
|
---|
| 40 | evtAppoint( "soundOff", duration );
|
---|
| 41 | end
|
---|
| 42 |
|
---|
| 43 | // A character enters the sensor volume:
|
---|
| 44 | func public void enter( actor sender )
|
---|
| 45 | if m_inside == 0 then
|
---|
| 46 | open();
|
---|
| 47 | end
|
---|
| 48 | m_inside = m_inside + 1;
|
---|
| 49 | end
|
---|
| 50 |
|
---|
| 51 | // A character leaves the sensor volume:
|
---|
| 52 | func public void leave( actor sender )
|
---|
| 53 | m_inside = m_inside - 1;
|
---|
| 54 | if m_inside == 0 then
|
---|
| 55 | close();
|
---|
| 56 | end
|
---|
| 57 | end
|
---|
| 58 |
|
---|
| 59 | // Disable the sound:
|
---|
| 60 | func public void soundOff()
|
---|
| 61 | m_speaker ^ stop();
|
---|
| 62 | end
|
---|
| 63 |
|
---|
| 64 | ///////////////////////////////////////////////////////////////////////////////
|
---|