## Engine
Class AudioTrigger

source: C:\XIII\Engine\Classes\AudioTrigger.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Brush
             |
             +--Engine.Volume
                |
                +--Engine.AudioTrigger

Direct Known Subclasses:None

class AudioTrigger
extends Engine.Volume

    //=============================================================================
    // AudioTrigger.
    //=============================================================================

Variables
`Actor` | `SoundActor`
`int` | `TouchCounter`
`sound` | `TouchMusic`
`sound` | `TouchSound`
`sound` | `UntouchMusic`
`sound` | `UntouchSound`
`bool` | `bOnlyOnce`
`float` | `minDelayTouchUntouch`

States
CannotBeTouched, CanBeTouched

State CannotBeTouched Function Summary

State CanBeTouched Function Summary

Source Code

    00001	//=============================================================================
    00002	// AudioTrigger.
    00003	//=============================================================================
    00004	class AudioTrigger extends Volume;
    00005
    00006	// -- variables
    00007	var() sound TouchMusic;
    00008	var() sound TouchSound;
    00009	var() sound UntouchMusic;
    00010	var() sound UntouchSound;
    00011	var() bool	bOnlyOnce;
    00012	//var() string Param1;
    00013
    00014	var int TouchCounter;
    00015	var() float minDelayTouchUntouch;
    00016	var() actor SoundActor;
    00017
    00018
    00019
    00020	auto state CanBeTouched
    00021	{
    00022	    event Touch (actor Other)
    00023	    {
    00024	        if ( Pawn(Other).IsPlayerPawn() )
    00025	        {
    00026	           // Log("CanBeTouched:Touch actor="$Other);
    00027	            PlayMusic( TouchMusic );
    00028	            if(SoundActor==none)
    00029	            {
    00030	                PlaySound( TouchSound );
    00031	            }
    00032	            else
    00033	            {
    00034	                SoundActor.PlaySound( TouchSound );
    00035	            }
    00036	            TriggerEvent( Event, Self, Pawn(Other));
    00037	            if (bOnlyOnce)
    00038	            {
    00039	                disable('touch');
    00040	            }
    00041	            else
    00042	            {
    00043	                TouchCounter++;
    00044	                GotoState('CannotBeTouched');
    00045	            }
    00046	        }
    00047	    }
    00048
    00049	    event UnTouch (actor Other)
    00050	    {
    00051	        if ( Pawn(Other).IsPlayerPawn() )
    00052	        {
    00053	            if (TouchCounter == 0 && !bOnlyOnce)
    00054	            {
    00055	                GotoState('CannotBeTouched');
    00056	            }
    00057	            else
    00058	            {
    00059	                //		Log("UnTouch actor="$Other);
    00060					if(!Other.bPendingDelete)
    00061						PlayMusic( UntouchMusic );
    00062	                if(SoundActor==none)
    00063	                {
    00064	                    PlaySound( UntouchSound );
    00065	                }
    00066	                else
    00067	                {
    00068	                    SoundActor.PlaySound( UntouchSound );
    00069	                }
    00070
    00071	                UnTriggerEvent( Event, Self, Pawn(Other));
    00072
    00073	                if (bOnlyOnce)
    00074					{
    00075	                    disable('untouch');
    00076					//	 Log("bOnlyOnce.untouch "$Other);
    00077					}
    00078	                else
    00079	                    TouchCounter--;
    00080	            }
    00081	        }
    00082
    00083	    }
    00084	}
    00085
    00086	state CannotBeTouched
    00087	{
    00088		event Timer()
    00089		{
    00090			if (TouchCounter==0)
    00091			{
    00092
    00093		//		Log("UnTouch actor on lance le son timer=0");
    00094				PlayMusic( UntouchMusic );
    00095				if(SoundActor==none)
    00096				{
    00097					PlaySound( UntouchSound );
    00098				}
    00099				else
    00100				{
    00101					SoundActor.PlaySound( UntouchSound );
    00102				}
    00103			//	UnTriggerEvent( Event, Self, Pawn(Other));
    00104			}
    00105			GotoState('CanBeTouched');
    00106		}
    00107
    00108		event Touch (actor Other)
    00109		{
    00110		//	Log("Touch CannotBeTouched");
    00111			TouchCounter++;
    00112		}
    00113
    00114		event UnTouch (actor Other)
    00115		{
    00116		//	Log("UnTouch CannotBeTouched");
    00117			TouchCounter--;
    00118		}
    00119
    00120
    00121	Begin:
    00122		SetTimer(minDelayTouchUntouch, false);
    00123
    00124	}
    00125
    00126	defaultproperties
    00127	{
    00128	     minDelayTouchUntouch=0.200000
    00129	     bStatic=False
    00130	}

End Source Code