Engine
Class WeaponSwipe

source: c:\runehov\Engine\Classes\WeaponSwipe.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.ParticleSystem
         |
         +--Engine.WeaponSwipe
Direct Known Subclasses:WeaponSwipeBlue, WeaponSwipeFire, WeaponSwipeGray, WeaponSwipeGreen, WeaponSwipePurple, WeaponSwipeRed, WeaponSwipeVamp, WeaponSwipeVampHealthTrail, WeaponSwipeYellow

class WeaponSwipe
extends Engine.ParticleSystem

//============================================================================= // WeaponSwipe. //=============================================================================

Function Summary
 void CreateSwipeParticle(float DeltaTime, vector B1, vector E1, vector B2, vector E2)
     
//==========================================================================
//
// CreateSwipeParticle
//
//==========================================================================
 
simulated
SwipeSystemTick(float DeltaTime)
     
//==========================================================================
//
// SwipeSystemTick
//
//==========================================================================
 
simulated
SwipeTick(float DeltaTime)
     
//==========================================================================
//
// SwipeTick
//
//==========================================================================
 
simulated
SystemInit()
     
//==========================================================================
//
// SystemInit
//
//==========================================================================
 
simulated
Tick(float DeltaTime)



Source Code


00001	//=============================================================================
00002	// WeaponSwipe.
00003	//=============================================================================
00004	class WeaponSwipe expands ParticleSystem
00005		abstract;
00006	
00007	//==========================================================================
00008	//
00009	// SystemInit
00010	//
00011	//==========================================================================
00012	
00013	simulated function SystemInit()
00014	{
00015		local int i;
00016	
00017		if(Owner == None)
00018		{
00019			IsLoaded = false;
00020			return;
00021		}
00022	
00023		for(i = 0; i < ParticleCount; i++)
00024		{
00025			ParticleArray[i].Valid = false;
00026		}
00027	
00028		OldBaseLocation = Owner.GetJointPos(BaseJointIndex);
00029		OldOffsetLocation = Owner.GetJointPos(OffsetJointIndex);
00030	
00031		IsLoaded = true;
00032		HasValidCoords = false;
00033	}
00034	
00035	//==========================================================================
00036	//
00037	// SwipeSystemTick
00038	//
00039	//==========================================================================
00040	
00041	simulated function SwipeSystemTick(float DeltaTime)
00042	{	
00043		local vector NewBase, NewOffset;
00044	
00045		if(Owner == None)
00046		{
00047			IsLoaded = false;
00048			return;
00049		}
00050	
00051		// System LifeSpan
00052		if(SystemLifeSpan > 0)
00053		{ // Only calculate LifeSpan if the particle has a lifespan
00054			SystemLifeSpan -= DeltaTime;
00055			if(SystemLifeSpan <= 0.0)
00056			{
00057				Destroy();
00058			}
00059	
00060			// If a SwipeSystem has a lifespan, that means that the system
00061			// will be removed soon and is only still valid so that any remaining
00062			// particles can be rendered
00063			return;
00064		}
00065	
00066		// Compute the new base/offset locations
00067		NewBase = Owner.GetJointPos(BaseJointIndex);
00068		NewOffset = Owner.GetJointPos(OffsetJointIndex);
00069	
00070		CreateSwipeParticle(DeltaTime, OldBaseLocation, OldOffsetLocation, NewBase, NewOffset);
00071	
00072		// Set the old locations to the new locations
00073		OldBaseLocation = NewBase;
00074		OldOffsetLocation = NewOffset;
00075	}
00076	
00077	//==========================================================================
00078	//
00079	// CreateSwipeParticle
00080	//
00081	//==========================================================================
00082	
00083	function CreateSwipeParticle(float DeltaTime, vector B1, vector E1, vector B2, vector E2)
00084	{
00085		local int i, j;
00086		local float alpha;
00087	
00088		// Spawn a new swipe particle
00089		for(i = 0; i < ParticleCount; i++)
00090		{
00091			if(ParticleArray[i].Valid)
00092			{
00093				continue;
00094			}
00095	
00096			ParticleArray[i].Valid = true;
00097			ParticleArray[i].Style = Style;
00098			ParticleArray[i].TextureIndex = 0;
00099	
00100			alpha = float(AlphaStart) / 255.0;
00101			ParticleArray[i].Alpha.X = alpha;
00102			ParticleArray[i].Alpha.Y = alpha;
00103			ParticleArray[i].Alpha.Z = alpha;
00104	
00105			// Set the 4 corner points for the particle (CW order)
00106			ParticleArray[i].Points[0] = E2;
00107			ParticleArray[i].Points[1] = E1;
00108			ParticleArray[i].Points[2] = B1;
00109			ParticleArray[i].Points[3] = B2;
00110	
00111			// Set the UV coordinates
00112			ParticleArray[i].U0 = -DeltaTime * SwipeSpeed;
00113			if(ParticleArray[i].U0 < -0.99)
00114				ParticleArray[i].U0 = -0.99;
00115	
00116			ParticleArray[i].V0 = 0;
00117			ParticleArray[i].U1 = 0;
00118			ParticleArray[i].V1 = 0.99;
00119	
00120			// Set the Location to the average of the 4 points
00121			ParticleArray[i].Location = ParticleArray[i].Points[0];
00122			for(j = 1; j < 4; j++)
00123			{
00124				ParticleArray[i].Location += ParticleArray[i].Points[j];
00125			}			
00126			ParticleArray[i].Location /= 4;
00127			break;
00128		}
00129	}
00130	
00131	//==========================================================================
00132	//
00133	// SwipeTick
00134	//
00135	//==========================================================================
00136	
00137	simulated function SwipeTick(float DeltaTime)
00138	{
00139		local int ix;
00140	
00141		for(ix = 0; ix < ParticleCount; ix++)
00142		{
00143			if(!ParticleArray[ix].Valid)
00144			{
00145				continue;
00146			}
00147	
00148			// Update the UV coordinates on the particle (all 4 pts)
00149			ParticleArray[ix].U0 += DeltaTime * SwipeSpeed;
00150			ParticleArray[ix].U1 += DeltaTime * SwipeSpeed;
00151	
00152			// Clamp the coordinates (just to be safe)
00153			if(ParticleArray[ix].U1 > 0.99)
00154			{
00155				ParticleArray[ix].U1 = 0.99;
00156			}
00157			if(ParticleArray[ix].U0 > 0.99)
00158			{ // Remove the particle if the all UV coordinates are beyond the right edge
00159				ParticleArray[ix].Valid = false;
00160			}
00161		}
00162	}
00163	
00164	simulated function Tick(float DeltaTime)
00165	{
00166		SwipeSystemTick(DeltaTime);
00167		SwipeTick(DeltaTime);
00168	}
00169	
00170	defaultproperties
00171	{
00172	     ParticleCount=64
00173	     ParticleType=PART_Generic
00174	     ParticleSpriteType=PSPRITE_QuadUV
00175	     AlphaStart=255
00176	     AlphaEnd=255
00177	     SwipeSpeed=7.000000
00178	     bEventSystemInit=True
00179	     bStasis=False
00180	     bNet=False
00181	     bNetSpecial=False
00182	     Style=STY_Translucent
00183	}

End Source Code