UnrealI
Class GradualMover

source: e:\games\UnrealTournament\UnrealI\Classes\GradualMover.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Brush
         |
         +--Engine.Mover
            |
            +--UnrealI.GradualMover
Direct Known Subclasses:None

class GradualMover
extends Engine.Mover

//============================================================================= // GradualMover. //=============================================================================
Variables
 int LastKeyNum
 bool bIsFullyOpen


Function Summary
 void BeginPlay()
     
// The strategy is to dynamically modify the Tag and Event 
// data members, which, I assume, are automatically checked 
// when making Event->Tag matches, using the Tags[] and 
// Events[] arrays.
// When the Mover has finished its' opening stage, the
// open state lasts for the duration specified by the
// StayOpenTime data member, whereupon the closing sequence
// begins, unless bTriggerOnceOnly is set True.
 void BeginState()
 void DoClose()
 void DoOpen()
 bool HandleDoor(Pawn Other)
     
// When triggered, open, wait, then close.
//
 void InterpolateEnd(Actor Other)
 void InterpolateEnd(Actor Other)
 void Trigger(Actor Other, Pawn EventInstigator)
 void Trigger(Actor Other, Pawn EventInstigator)
 void Trigger(Actor Other, Pawn EventInstigator)
 void UnTrigger(Actor Other, Pawn EventInstigator)



Source Code


00001	//=============================================================================
00002	// GradualMover.
00003	//=============================================================================
00004	class GradualMover extends Mover;
00005	
00006	var(GradualProperties) float OpenTimes [6];
00007	var(GradualProperties) float CloseTimes[6];
00008	var(GradualProperties) name  Tags      [6];
00009	var(GradualProperties) name  Events    [6];
00010	
00011	var int  LastKeyNum;
00012	var bool bIsFullyOpen;
00013	
00014	// The strategy is to dynamically modify the Tag and Event 
00015	// data members, which, I assume, are automatically checked 
00016	// when making Event->Tag matches, using the Tags[] and 
00017	// Events[] arrays.
00018	// When the Mover has finished its' opening stage, the
00019	// open state lasts for the duration specified by the
00020	// StayOpenTime data member, whereupon the closing sequence
00021	// begins, unless bTriggerOnceOnly is set True.
00022	
00023	function BeginPlay() {
00024	
00025	
00026		// Set Tag/Event to the first set in the Tags[] and
00027		// Events[] arrays.
00028		Tag   = Tags[0];
00029		Event = Events[0];
00030		KeyNum = 0;
00031		bIsFullyOpen = false;
00032		Super.BeginPlay();
00033	}
00034	
00035	
00036	function DoOpen() 
00037	{
00038	
00039		// Open through to the next keyframe.
00040		//
00041		bOpening = true;
00042		bDelaying = false;
00043		LastKeyNum = KeyNum;
00044		InterpolateTo (KeyNum+1, OpenTimes[Keynum]);
00045		PlaySound (OpeningSound);
00046		AmbientSound = MoveAmbientSound;
00047	}
00048	
00049	function DoClose() 
00050	{
00051	
00052		// Close through to the next keyframe.
00053		//
00054		bOpening = false;
00055		bDelaying = false;
00056		LastKeyNum = KeyNum;
00057		InterpolateTo (KeyNum-1, CloseTimes[Keynum-1]);
00058		PlaySound (ClosingSound);
00059		AmbientSound = MoveAmbientSound;
00060	}
00061	
00062	//=======================================================================
00063	// The various states
00064	
00065	// When triggered, open, wait, then close.
00066	//
00067	state() GradualTriggerOpenTimed 
00068	{
00069		function bool HandleDoor(pawn Other)
00070		{
00071			return HandleTriggerDoor(Other);
00072		}
00073	
00074		function Trigger( actor Other, pawn EventInstigator )
00075		{
00076			SavedTrigger = Other;
00077			Instigator = EventInstigator;
00078			if ( SavedTrigger != None )
00079				SavedTrigger.BeginEvent();
00080			GotoState( 'GradualTriggerOpenTimed', 'Open' );
00081		}
00082	
00083		function InterpolateEnd(actor Other) 
00084		{	
00085		}
00086	
00087		function BeginState()
00088		{
00089			bOpening = false;
00090		}
00091	
00092	Open:
00093		Disable ('Trigger');
00094		DoOpen();
00095		FinishInterpolation();
00096		FinishedOpening();
00097	
00098		// Check if this is the fully opened position,
00099		// for which a delay is necessary.
00100		//
00101		if (KeyNum == NumKeys-1) {		// Note: NumKeys=0 means one key frame
00102			Sleep (StayOpenTime);
00103			AmbientSound = None;
00104			if( bTriggerOnceOnly )
00105				// Stays in this position forever
00106				GotoState ('');
00107			else 
00108				// The closing sequence must begin
00109				GotoState ('GradualTriggerOpenTimed', 'Close');
00110		}
00111		
00112		// Check if the next Tag is the same as the current,
00113		// which would continue interpolating to the next
00114		// key-frame.
00115		//
00116		if (Tags[KeyNum] == Tags[LastKeyNum]) {
00117			GotoState ('GradualTriggerOpenTimed', 'Open');
00118		}
00119		Tag   = Tags[KeyNum];		// Change the next open conditions
00120		Event = Events[KeyNum];
00121		Enable ('Trigger');
00122		Stop;
00123		
00124	Close:
00125		Disable ('Trigger');
00126		DoClose();
00127		FinishInterpolation();
00128		FinishedClosing();	// throw the current Event, if exists
00129	
00130		if (KeyNum > 0) 		// Still more key-frames to go through
00131			GotoState ('GradualTriggerOpenTimed', 'Close');
00132	
00133		Tag   = Tags[0];		// Reset the initial state
00134		Event = Events[0];
00135		AmbientSound = None;
00136		Enable ('Trigger');
00137	}
00138	
00139	
00140	// Start pounding when triggered.
00141	//
00142	state() GradualTriggerPound
00143	{
00144		function Trigger( actor Other, pawn EventInstigator )
00145		{
00146			SavedTrigger = Other;
00147			Instigator = EventInstigator;
00148			GotoState( 'GradualTriggerPound', 'Open' );
00149		}
00150		function UnTrigger( actor Other, pawn EventInstigator )
00151		{
00152			SavedTrigger = None;
00153			Instigator = None;
00154			GotoState( 'GradualTriggerPound', 'Close' );
00155		}
00156	Open:
00157		Disable ('Trigger');
00158		DoOpen();
00159		FinishInterpolation();
00160		FinishedOpening();
00161	
00162		// If the next key frame is not the last, then
00163		// keep playing back the frames.
00164		//
00165		if (Keynum < NumKeys-1) {
00166			GotoState ('GradualTriggerOpenTimed', 'Open');
00167		}
00168	Close:
00169		Disable ('Trigger');
00170		DoClose();
00171		FinishInterpolation();
00172		FinishedClosing();	// throw the current Event, if exists
00173	
00174		if (KeyNum > 0) 		// Still more key-frames to go through
00175			GotoState ('GradualTriggerOpenTimed', 'Close');
00176	
00177		Sleep(StayOpenTime);
00178		if( bTriggerOnceOnly )
00179		{
00180			AmbientSound = None;
00181			GotoState('');
00182		}
00183		if( SavedTrigger != None )
00184			goto 'Open';
00185	}
00186	
00187	state() GradualTriggerToggle
00188	{
00189		function Trigger( actor Other, pawn EventInstigator )
00190		{
00191			SavedTrigger = Other;
00192			Instigator = EventInstigator;
00193			SavedTrigger.BeginEvent();
00194			if( bIsFullyOpen )
00195				GotoState( 'GradualTriggerToggle', 'Close' );
00196			else
00197				GotoState( 'GradualTriggerToggle', 'Open' );
00198		}
00199	
00200		function InterpolateEnd(actor Other) {	
00201		}
00202	
00203	Open:
00204		Disable ('Trigger');
00205		DoOpen();
00206		FinishInterpolation();
00207		FinishedOpening();
00208	
00209		// Check if this is the fully opened position,
00210		// which we wait in until another triggering event occurs.
00211		//
00212		if (KeyNum == NumKeys-1) {		// Note: NumKeys=0 means one key frame
00213			bIsFullyOpen = true;
00214			AmbientSound = None;
00215			Enable ('Trigger');
00216			Stop;
00217		}
00218		
00219		GotoState ('GradualTriggerToggle', 'Open');
00220		
00221	Close:
00222		Disable ('Trigger');
00223		DoClose();
00224		FinishInterpolation();
00225		FinishedClosing();	// throw the current Event, if exists
00226	
00227		if (KeyNum > 0) 		// Still more key-frames to go through
00228			GotoState ('GradualTriggerToggle', 'Close');
00229	
00230		bIsFullyOpen = false;
00231		AmbientSound = None;
00232		Enable ('Trigger');
00233	}
00234	
00235	defaultproperties
00236	{
00237	}

End Source Code