UnrealI
Class MixMover

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

class MixMover
extends Engine.Mover

//============================================================================= // MixMover. //=============================================================================
Variables
 name AttachTag
 float CloseTimes[6]
 int LastKeyNum
 int MoveDirection
 int NextKeyNum
 OpenTimes [6]
 OpenTimes [6]
 OpenTimes [6]
 bool bMoveKey


Function Summary
 void BeginPlay()
 void BeginState()
 void BeginState()
 void BeginState()
 void DoClose()
 void DoOpen()
 bool HandleDoor(Pawn Other)
     
// When triggered, open, wait, then close.
//
 bool HandleDoor(Pawn Other)
     
// When triggered, open, wait, then close.
//
 void InterpolateEnd(Actor Other)
 void InterpolateEnd(Actor Other)
 void MoveKeyframe(int newKeyNum)
 void PostBeginPlay()
     
// Immediately after mover enters gameplay.
 void Trigger(Actor Other, Pawn EventInstigator)
     
// Start pounding when triggered.
//
 void Trigger(Actor Other, Pawn EventInstigator)
     
// Start pounding when triggered.
//
 void UnTrigger(Actor Other, Pawn EventInstigator)



Source Code


00001	//=============================================================================
00002	// MixMover.
00003	//=============================================================================
00004	class MixMover extends Mover;
00005	
00006	var() float OpenTimes [6];
00007	var() float CloseTimes[6];
00008	var() name  Tags      [6];
00009	var() name  Events    [6];
00010	var() name  AttachTag;
00011	
00012	var int  LastKeyNum;
00013	var int  NextKeyNum;
00014	var int  MoveDirection;
00015	var bool bMoveKey;
00016	
00017	function BeginPlay() {
00018	
00019		KeyNum = 0;
00020		bMoveKey = true;
00021		Super.BeginPlay();
00022	}
00023	
00024	
00025	// Immediately after mover enters gameplay.
00026	function PostBeginPlay()
00027	{
00028		local Actor Act;
00029		local Mover Mov;
00030	
00031		Super.PostBeginPlay();
00032	
00033		// Initialize all slaves.
00034		if( !bSlave && (AttachTag != '') )
00035		{
00036			foreach AllActors( class 'Actor', Act, AttachTag )
00037			{
00038				Mov = Mover(Act);
00039				if (Mov == None) {
00040	
00041					Act.SetBase( Self );
00042				}
00043				else if (Mov.bSlave) {
00044			
00045					Mov.GotoState('');
00046					Mov.SetBase( Self );
00047				}
00048			}
00049		}
00050	}
00051	
00052	function DoOpen() 
00053	{
00054		// Open through to the next keyframe.
00055		//
00056		bOpening = true;
00057		bDelaying = false;
00058		LastKeyNum = KeyNum;
00059		InterpolateTo (KeyNum+1, OpenTimes[Keynum]);
00060		PlaySound (OpeningSound);
00061		AmbientSound = MoveAmbientSound;
00062	}
00063	
00064	function DoClose() {
00065	
00066		// Close through to the next keyframe.
00067		//
00068		bOpening = false;
00069		bDelaying = false;
00070		LastKeyNum = KeyNum;
00071		InterpolateTo (KeyNum-1, CloseTimes[Keynum-1]);
00072		PlaySound (ClosingSound);
00073		AmbientSound = MoveAmbientSound;
00074	}
00075	
00076	
00077	function MoveKeyframe( int newKeyNum )
00078	{		
00079		if( !bMoveKey ) return;
00080	
00081		NextKeyNum = newKeyNum;
00082		if( NextKeyNum < KeyNum )
00083		{
00084			MoveDirection = -1;
00085			GotoState('ElevatorTriggerGradual','ChangeFrame');
00086		}
00087		
00088		if( NextKeyNum > KeyNum )
00089		{
00090			MoveDirection = 1;
00091			GotoState('ElevatorTriggerGradual','ChangeFrame');
00092		}
00093	}
00094	
00095	
00096	state() ElevatorTriggerGradual 
00097	{
00098		function bool HandleDoor(pawn Other)
00099		{
00100			return HandleTriggerDoor(Other);
00101		}
00102	
00103		function InterpolateEnd(actor Other) 
00104		{	
00105		}
00106	
00107		function BeginState()
00108		{
00109			bOpening = false;
00110		}
00111	
00112	ChangeFrame:
00113		bMoveKey = false;
00114	
00115		// Move the mover
00116		//
00117		if( MoveDirection > 0	)
00118		{
00119			DoOpen();
00120			FinishInterpolation();
00121			FinishedClosing();
00122		}
00123		else 
00124		{
00125			DoClose();
00126			FinishInterpolation();
00127			FinishedOpening();
00128		}
00129	
00130		// Check if there are more frames to go
00131		//
00132		if( KeyNum != NextKeyNum )
00133		{
00134			GotoState('ElevatorTriggerGradual','ChangeFrame');
00135		}
00136	
00137		bMoveKey = true;
00138		Stop;
00139	}
00140	
00141	
00142	//=======================================================================
00143	// The various states
00144	
00145	// When triggered, open, wait, then close.
00146	//
00147	state() GradualTriggerOpenTimed 
00148	{
00149		function bool HandleDoor(pawn Other)
00150		{
00151			return HandleTriggerDoor(Other);
00152		}
00153	
00154		function Trigger( actor Other, pawn EventInstigator )
00155		{
00156			SavedTrigger = Other;
00157			Instigator = EventInstigator;
00158			if ( SavedTrigger != None )
00159				SavedTrigger.BeginEvent();
00160			GotoState( 'GradualTriggerOpenTimed', 'Open' );
00161		}
00162	
00163		function InterpolateEnd(actor Other) 
00164		{	
00165		}
00166	
00167		function BeginState()
00168		{
00169			bOpening = false;
00170		}
00171	
00172	Begin:
00173		// Set Tag/Event to the first set in the Tags[] and
00174		// Events[] arrays.
00175		Tag   = Tags[0];
00176		Event = Events[0];
00177		Enable('Trigger');
00178		Stop;
00179	
00180	Open:
00181		Disable ('Trigger');
00182		DoOpen();
00183		FinishInterpolation();
00184		FinishedOpening();
00185	
00186		// Check if this is the fully opened position,
00187		// for which a delay is necessary.
00188		//
00189		if (KeyNum == NumKeys) {		// Note: NumKeys=0 means one key frame
00190			Sleep (StayOpenTime);
00191			if( bTriggerOnceOnly )
00192				// Stays in this position forever
00193				GotoState ('');
00194			else 
00195				// The closing sequence must begin
00196				GotoState ('GradualTriggerOpenTimed', 'Close');
00197		}
00198		
00199		// Check if the next Tag is the same as the current,
00200		// which would continue interpolating to the next
00201		// key-frame.
00202		//
00203		if (Tags[KeyNum] == Tags[LastKeyNum]) {
00204			GotoState ('GradualTriggerOpenTimed', 'Open');
00205		}
00206		Tag   = Tags[KeyNum];		// Change the next open conditions
00207		Event = Events[KeyNum];
00208		Enable ('Trigger');
00209		Stop;
00210		
00211	Close:
00212		Disable ('Trigger');
00213		DoClose();
00214		FinishInterpolation();
00215		FinishedClosing();	// throw the current Event, if exists
00216	
00217		if (KeyNum > 0) 		// Still more key-frames to go through
00218			GotoState ('GradualTriggerOpenTimed', 'Close');
00219	
00220		Tag   = Tags[0];		// Reset the initial state
00221		Event = Events[0];
00222		Enable ('Trigger');
00223	}
00224	
00225	
00226	// Start pounding when triggered.
00227	//
00228	state() GradualTriggerPound
00229	{
00230		function Trigger( actor Other, pawn EventInstigator )
00231		{
00232			SavedTrigger = Other;
00233			Instigator = EventInstigator;
00234			GotoState( 'GradualTriggerPound', 'Open' );
00235		}
00236	
00237		function UnTrigger( actor Other, pawn EventInstigator )
00238		{
00239			SavedTrigger = None;
00240			Instigator = None;
00241			GotoState( 'GradualTriggerPound', 'Close' );
00242		}
00243	
00244		function BeginState()
00245		{
00246			bOpening = false;
00247		}
00248	
00249	Begin:
00250		// Set Tag/Event to the first set in the Tags[] and
00251		// Events[] arrays.
00252		Tag   = Tags[0];
00253		Event = Events[0];
00254		Stop;
00255	
00256	Open:
00257		Disable ('Trigger');
00258		DoOpen();
00259		FinishInterpolation();
00260		FinishedOpening();
00261	
00262		// If the next key frame is not the last, then
00263		// keep playing back the frames.
00264		//
00265		if (Keynum < NumKeys) {
00266			GotoState ('GradualTriggerOpenTimed', 'Open');
00267		}
00268	Close:
00269		Disable ('Trigger');
00270		DoClose();
00271		FinishInterpolation();
00272		FinishedClosing();	// throw the current Event, if exists
00273	
00274		if (KeyNum > 0) 		// Still more key-frames to go through
00275			GotoState ('GradualTriggerOpenTimed', 'Close');
00276	
00277		Sleep(StayOpenTime);
00278		if( bTriggerOnceOnly )
00279			GotoState('');
00280		if( SavedTrigger != None )
00281			goto 'Open';
00282	}
00283	
00284	defaultproperties
00285	{
00286	}

End Source Code