Engine
Class AnimationProxy

source: c:\runehov\Engine\Classes\AnimationProxy.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Keypoint
         |
         +--Engine.AnimationProxy
Direct Known Subclasses:RunePlayerProxy

class AnimationProxy
extends Engine.Keypoint

//============================================================================= // AnimationProxy. //=============================================================================
Variables
 Shield curShield
           Current shield
 Weapon curWeapon
           Current weapon
 Shield newShield
           Shield being acquired
 Weapon newWeapon
           Weapon being acquired

States
Dying, Throwing, Defending, Attacking, Acquiring, Idle

Function Summary
 void AcquireInventory(Inventory item)
     
//=============================================================================
//
// State specific functions
//
//=============================================================================
 bool Attack()
 bool CanGotoPainState()
     
//=============================================================================
//
// CanGotoPainState
//
//=============================================================================
 bool CanPickup(Inventory item)
     
//=============================================================================
//
// CanPickUp
//
//=============================================================================
 bool Defend()
 name GetGroup(name sequence)
     
//=============================================================================
//
// GetGroup
//
//=============================================================================
 bool Pickup()
 void PlayAttackHigh()
 void PlayAttackLow()
 void PlayAttackVertical()
 void PlayDeath()
 void PlayDefendHigh()
 void PlayDefendLow()
 void PlayDropShield()
 void PlayDropWeapon()
 void PlayIdle()
 void PlayPickupShield()
 void PlayPickupWeapon()
     
//=============================================================================
//
// Animation functions to be overrideen in child classes
//
//=============================================================================
 void PlayThrowWeapon()
 void PostBeginPlay()
     
//=============================================================================
//
// PostBeginPlay
//
//=============================================================================
 void StopAttack()
 void SyncAnimation(float tween)
     
//=============================================================================
//
// SyncAnimation
//
// Tries to sync the current proxy anim to the master anim
//=============================================================================
 bool Throw()
 void TryLoopAnim(Name anim, optional float, optional float)
     
//=============================================================================
//
// TryLoopAnim
//
//=============================================================================
 void TryPlayAnim(Name anim, optional float, optional float)
     
//=============================================================================
//
// TryPlayAnim
//
// The Owner has entered an animation state, inform the proxy of the
// new animation
//=============================================================================
 void TryTweenAnim(Name anim, optional float)
     
//=============================================================================
//
// TryTweenAnim
//
//=============================================================================
 bool Use()
 bool WantsToPickup(Inventory item)
     
//=============================================================================
//
// WantsToPickup
//
//=============================================================================
 void WeaponActivate()
     
//=============================================================================
//
// WeaponActivate
//
// WeaponActivate Notify
//=============================================================================
 void WeaponDeactivate()
     
//=============================================================================
//
// WeaponDeactivate
//
//=============================================================================


State Dying Function Summary


State Throwing Function Summary
 void DoThrow()
     
//=========================================================================


State Defending Function Summary
 void StopDefending()


State Attacking Function Summary
 void PlayAttackAnim()
     
//=========================================================================
 bool Defend()
     
//=========================================================================
 void StopAttack()
     
//=========================================================================
 void EndState()


State Acquiring Function Summary


State Idle Function Summary
 void AnimEnd()
     
	/*
	
 bool Throw()
     
//=========================================================================
 bool Defend()
     
//=========================================================================
 bool Attack()
     
//=========================================================================



Source Code


00001	//=============================================================================
00002	// AnimationProxy.
00003	//=============================================================================
00004	class AnimationProxy expands Keypoint
00005		native;
00006	
00007	
00008	/*	Description:
00009		This actor controls any secondary animation on characters including
00010		the animation of skeletal joint groups other than 0
00011	*/
00012	
00013	var Weapon			curWeapon;		// Current weapon
00014	var Weapon			newWeapon;		// Weapon being acquired
00015	var Shield			curShield;		// Current shield
00016	var Shield			newShield;		// Shield being acquired
00017	
00018	
00019	
00020	//=============================================================================
00021	//
00022	// PostBeginPlay
00023	//
00024	//=============================================================================
00025	function PostBeginPlay()
00026	{
00027		Enable('Tick');
00028	}
00029	
00030	//=============================================================================
00031	//
00032	// AnimEnd
00033	//
00034	// Proxy animation has ended, inform the proxy owner
00035	//=============================================================================
00036	event AnimEnd()
00037	{
00038		Owner.AnimProxyEnd();
00039	}
00040	
00041	
00042	//----- Animation Playing Functions -----
00043	
00044	//=============================================================================
00045	//
00046	// Animation functions to be overrideen in child classes
00047	//
00048	//=============================================================================
00049	function PlayPickupWeapon(){}
00050	function PlayDropWeapon(){}
00051	function PlayThrowWeapon(){}
00052	function PlayPickupShield(){}
00053	function PlayDropShield(){}
00054	function PlayAttackLow(){}
00055	function PlayAttackHigh(){}
00056	function PlayAttackVertical(){}
00057	function PlayIdle(){}
00058	function PlayDefendLow(){}
00059	function PlayDefendHigh(){}
00060	function PlayDeath(){}
00061	
00062	//=============================================================================
00063	//
00064	// GetGroup
00065	//
00066	//=============================================================================
00067	
00068	function name GetGroup(name sequence)
00069	{
00070		return('');
00071	}
00072	
00073	//=============================================================================
00074	//
00075	// TryPlayAnim
00076	//
00077	// The Owner has entered an animation state, inform the proxy of the
00078	// new animation
00079	//=============================================================================
00080	function TryPlayAnim(Name anim, optional float rate, optional float tween)
00081	{
00082		if(rate == 0.0)
00083		{ // Handle optional case
00084			rate = 1.0;
00085		}
00086		if(tween == 0.0)
00087		{ // Handle optional case
00088			tween = 0.1;
00089		}
00090	
00091		PlayAnim(anim, rate, tween);
00092	}
00093	
00094	//=============================================================================
00095	//
00096	// TryLoopAnim
00097	//
00098	//=============================================================================
00099	function TryLoopAnim(Name anim, optional float rate, optional float tween)
00100	{
00101		if(rate == 0.0)
00102		{ // Handle optional case
00103			rate = 1.0;
00104		}
00105		if(tween == 0.0)
00106		{ // Handle optional case
00107			tween = 0.1;
00108		}
00109	
00110		LoopAnim(anim, rate, tween);
00111	}
00112	
00113	//=============================================================================
00114	//
00115	// TryTweenAnim
00116	//
00117	//=============================================================================
00118	function TryTweenAnim(Name anim, optional float tween)
00119	{
00120		if(tween == 0.0)
00121		{ // Handle optional case
00122			tween = 0.1;
00123		}
00124	
00125		TweenAnim(anim, tween);
00126	}
00127	
00128	//=============================================================================
00129	//
00130	// SyncAnimation
00131	//
00132	// Tries to sync the current proxy anim to the master anim
00133	//=============================================================================
00134	function SyncAnimation(float tween)
00135	{
00136		PlayAnim(Owner.AnimSequence, 1.0, tween);
00137	}
00138	
00139	//=============================================================================
00140	//
00141	// WeaponActivate
00142	//
00143	// WeaponActivate Notify
00144	//=============================================================================
00145	function WeaponActivate()
00146	{
00147		Pawn(Owner).bSwingingHigh = true;
00148		Pawn(Owner).bSwingingLow  = false;
00149	}
00150	
00151	//=============================================================================
00152	//
00153	// WeaponDeactivate
00154	//
00155	//=============================================================================
00156	function WeaponDeactivate()
00157	{
00158		Pawn(Owner).bSwingingHigh = false;
00159		Pawn(Owner).bSwingingLow  = false;
00160	}
00161	
00162	
00163	//=============================================================================
00164	//
00165	// CanGotoPainState
00166	//
00167	//=============================================================================
00168	
00169	function bool CanGotoPainState()
00170	{
00171		return(true);
00172	}
00173	
00174	//=============================================================================
00175	//
00176	// CanPickUp
00177	//
00178	//=============================================================================
00179	
00180	function bool CanPickup(Inventory item)
00181	{
00182		return(false);
00183	}
00184	
00185	//=============================================================================
00186	//
00187	// WantsToPickup
00188	//
00189	//=============================================================================
00190	
00191	function bool WantsToPickup(Inventory item)
00192	{
00193		return(false);
00194	}
00195	
00196	//=============================================================================
00197	//
00198	// State specific functions
00199	//
00200	//=============================================================================
00201	function		AcquireInventory(Inventory item)	{					}
00202	function bool	Attack()							{	return(false);	}
00203	function		StopAttack()						{					}
00204	function bool	Defend()							{	return(false);	}
00205	function bool	Throw()								{	return(false);	}
00206	function bool	Pickup()							{	return(false);	}
00207	function bool	Use()								{	return(false);	}
00208	
00209	
00210	// ----- Proxy States -----
00211	
00212	
00213	//-----------------------------------------------------------------------------
00214	//
00215	// Idle
00216	//
00217	//-----------------------------------------------------------------------------
00218	auto state Idle
00219	{
00220		//=========================================================================
00221		//
00222		// Attack
00223		//
00224		//=========================================================================
00225		function bool Attack()
00226		{
00227			GotoState('Attacking');
00228			return(true);
00229		}
00230		
00231		//=========================================================================
00232		//
00233		// Defend
00234		// 
00235		//=========================================================================
00236		function bool Defend()
00237		{
00238			GotoState('Defending');
00239			return(true);
00240		}
00241	
00242		//=========================================================================
00243		//
00244		// Throw
00245		//
00246		//=========================================================================
00247		function bool Throw()
00248		{
00249			GotoState('Throwing');
00250			return(true);
00251		}
00252		
00253		//=========================================================================
00254		// not tested
00255		// use to auto-sync proxy with parent each time anim ends
00256		//=========================================================================
00257		/*
00258		function AnimEnd()
00259		{
00260			// Sync up animation with owner
00261			if (AnimSequence != Owner.AnimSequence)
00262			{
00263				SyncAnimation(0.1);
00264			}
00265		}
00266		*/
00267	}
00268	
00269	
00270	
00271	//-----------------------------------------------------------------------------
00272	//
00273	// Acquiring
00274	//
00275	//-----------------------------------------------------------------------------
00276	state Acquiring
00277	{
00278		ignores TryPlayAnim, TryLoopAnim, TryTweenAnim;
00279	
00280	begin:
00281		if (newWeapon != None)
00282		{	// Acquiring weapon
00283		
00284			// Drop current weapon if any
00285			if (curWeapon != None)
00286			{
00287				PlayDropWeapon();
00288				FinishAnim();
00289				//Goblin.DropWeapon();
00290			}
00291	
00292			// attach new weapon
00293			Pawn(Owner).Weapon.GotoState('Active');
00294			newWeapon = None;
00295		}
00296		else
00297		{	// Acquiring shield
00298			if (curShield != None)
00299			{
00300				PlayDropShield();
00301				FinishAnim();
00302				//Goblin.DropShield();
00303			}
00304	
00305			Pawn(Owner).Shield.GotoState('Active');
00306		}
00307	
00308	done:
00309		SyncAnimation(0.4);
00310		GotoState('Idle');
00311	}
00312	
00313	
00314	//-----------------------------------------------------------------------------
00315	//
00316	// Attacking
00317	//
00318	//-----------------------------------------------------------------------------
00319	state Attacking
00320	{
00321		ignores TryPlayAnim, TryLoopAnim, TryTweenAnim;
00322	
00323		function EndState()
00324		{
00325			WeaponDeactivate();
00326		}
00327		
00328		//=========================================================================
00329		//
00330		// StopAttack
00331		//
00332		//=========================================================================
00333		function StopAttack()
00334		{		
00335			SyncAnimation(0.3);
00336			GotoState('Idle');
00337		}
00338	
00339		//=========================================================================
00340		//
00341		// Defend
00342		// 
00343		//=========================================================================
00344		function bool Defend()
00345		{
00346			GotoState('Defending');
00347			return(true);
00348		}
00349	
00350		//=========================================================================
00351		//
00352		// PlayAttackAnim
00353		// 
00354		//=========================================================================
00355		function PlayAttackAnim()
00356		{
00357			PlayAnim('AttackA', 1.0, 0.1);
00358		}
00359	
00360	begin:
00361		PlayAttackHigh();
00362		FinishAnim();
00363	
00364		SyncAnimation(0.3);
00365		GotoState('Idle');
00366	}
00367	
00368	
00369	
00370	//-----------------------------------------------------------------------------
00371	//
00372	// Defending
00373	//
00374	//-----------------------------------------------------------------------------
00375	state Defending
00376	{
00377		ignores TryPlayAnim, TryLoopAnim, TryTweenAnim;
00378	
00379		function StopDefending()
00380		{
00381			GotoState('Defending', 'end');
00382		}
00383	
00384	end:
00385		SyncAnimation(0.3);	
00386		GotoState('Idle');
00387	
00388	begin:
00389		PlayDefendHigh();
00390	}
00391	
00392	
00393	
00394	//-----------------------------------------------------------------------------
00395	//
00396	// Throwing
00397	//
00398	//-----------------------------------------------------------------------------
00399	state Throwing
00400	{
00401		ignores TryPlayAnim, TryLoopAnim, TryTweenAnim;
00402	
00403		//=========================================================================
00404		//
00405		// DoThrow
00406		// 
00407		//=========================================================================
00408		function DoThrow()
00409		{
00410			Pawn(Owner).TossWeapon();
00411		}
00412	
00413	begin:
00414		PlayThrowWeapon();
00415		FinishAnim();
00416	
00417		SyncAnimation(0.3);
00418		GotoState('Idle');
00419	}
00420	
00421	//-----------------------------------------------------------------------------
00422	//
00423	// Dying
00424	//
00425	//-----------------------------------------------------------------------------
00426	
00427	state Dying
00428	{
00429		ignores TryPlayAnim, TryLoopAnim, TryTweenAnim;
00430	
00431	begin:
00432	}
00433	
00434	defaultproperties
00435	{
00436	     bStatic=False
00437	     bFrameNotifies=True
00438	     NetPriority=3.000000
00439	}

End Source Code