RuneI
Class Exploding

source: c:\runehov\RuneI\Classes\Exploding.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.ParticleSystem
         |
         +--RuneI.Exploding
Direct Known Subclasses:None

class Exploding
extends Engine.ParticleSystem

//USAGE: //Place slightly away from originating wall (particles are larger, so may occlude if too close) //Choose specific Mode (TriggerConstant, Constant, TriggerSingle) //NOTE: Please try and use TriggerConstant in place of TriggerSingle whenenver possible. //If using TriggerSingle, enter desired Duration (time to fade out is extra....) //Try to setup MaxForce and direction so that particles don't reach other walls... //VelocityRadius describes the MaxRadius in the direction that particles can travel...(think of a cone)
Variables
 float CurDuration
           Only used for EXPM_TriggerSingle
 enum EExplodingMode
           Only used for EXPM_TriggerSingle
 float ExpDuration
           Only used for EXPM_TriggerSingle
 float MaxForce
 float VelocityRadius

States
EmmissionDead, EmmissionDie, EmmissionBegin

Function Summary
 
simulated
Debug(Canvas canvas, int mode)
 
simulated
PostBeginPlay()
 void Trigger(Actor other, Pawn eventInstigator)


State EmmissionDead Function Summary


State EmmissionDie Function Summary


State EmmissionBegin Function Summary



Source Code


00001	//=============================================================================
00002	// Exploding.
00003	//=============================================================================
00004	
00005	//USAGE:
00006	//Place slightly away from originating wall (particles are larger, so may occlude if too close)
00007	//Choose specific Mode (TriggerConstant, Constant, TriggerSingle)
00008	//NOTE: Please try and use TriggerConstant in place of TriggerSingle whenenver possible.
00009	//If using TriggerSingle, enter desired Duration (time to fade out is extra....)
00010	//Try to setup MaxForce and direction so that particles don't reach other walls...
00011	//VelocityRadius describes the MaxRadius in the direction that particles can travel...(think of a cone)
00012	
00013	class Exploding expands ParticleSystem;
00014	
00015	var() float VelocityRadius;
00016	var() float MaxForce;
00017	var() float ExpDuration;	//Only used for EXPM_TriggerSingle
00018	
00019	
00020	var() enum EExplodingMode
00021	{
00022		EXPM_TriggerConstant,	// Constant explosion.  Requires a Trigger message to start.							
00023		EXPM_Constant,			//Constant explosion.  Initially active.
00024		EXPM_TriggerSingle		// Explode for a specified duration once triggered...
00025	} ExplodingMode;
00026	
00027	var float CurDuration;
00028	
00029	simulated function PostBeginPlay()
00030	{
00031		local vector temp, rotVect;
00032		
00033		Super.PostBeginPlay();
00034		
00035		bDirectional = false;	//Turn off so particles behave correctly...
00036		
00037		if(ExplodingMode != EXPM_Constant)
00038			bHidden = true;			//Hide it initially (unless EXPM_Constant)...
00039		
00040		rotVect = vector(Rotation);
00041		
00042		temp = rotVect cross vect(0,0,1) * VelocityRadius + rotVect cross vect(0,1,0) * VelocityRadius +
00043			rotVect cross vect(1,0,0) * VelocityRadius;		//Set up conic shape to travel within....
00044		
00045		VelocityMax = (rotVect * MaxForce) + temp;		
00046		VelocityMin = (rotVect * MaxForce) - temp;
00047	}
00048	
00049	
00050	function Trigger(actor other, pawn eventInstigator)
00051	{
00052		bHidden = false;
00053		if(ExplodingMode == EXPM_TriggerSingle)
00054		{
00055			CurDuration = ExpDuration;
00056			GotoState('EmmissionBegin');	
00057		}
00058	}
00059	
00060			//System stays in this state until time elapsed...
00061	State EmmissionBegin
00062	{
00063		ignores Trigger;
00064		
00065		event Tick(float DeltaTime)
00066		{	
00067			CurDuration -= DeltaTime;
00068			if(CurDuration <= 0)
00069			{
00070				CurDuration = 0;
00071				GotoState('EmmissionDie');
00072			}
00073		}
00074		
00075		Begin:
00076	}
00077	
00078			//System is currently fading away now...
00079	State EmmissionDie
00080	{
00081		ignores Trigger;
00082		
00083		event Tick(float DeltaTime)
00084		{	
00085			if(AlphaStart <= 0)
00086			{
00087				if(ParticleCount > 1)
00088					ParticleCount--;
00089				else
00090					GotoState('EmmissionDead');
00091			}
00092			else
00093				AlphaStart -= 1 * (Rand(2));
00094		}
00095		
00096		Begin:
00097	}
00098	
00099			//Dormant State..
00100	State EmmissionDead
00101	{
00102		ignores Trigger, Tick;
00103	
00104		Begin:
00105			bHidden = true;
00106	}
00107	
00108	
00109	simulated function Debug(Canvas canvas, int mode)
00110	{
00111		Super.Debug(canvas, mode);
00112			
00113		Canvas.DrawLine3D(Location, Location + VelocityMax, 255,0,0);
00114		Canvas.DrawLine3D(Location, Location + VelocityMin, 0, 0, 255);	
00115	}
00116	
00117	defaultproperties
00118	{
00119	     VelocityRadius=100.000000
00120	     MaxForce=300.000000
00121	     ExpDuration=5.000000
00122	     bSpriteInEditor=True
00123	     ParticleCount=30
00124	     ParticleTexture(0)=FireTexture'RuneFX.Flame'
00125	     VelocityMin=(X=25.000000,Y=-50.000000)
00126	     VelocityMax=(X=50.000000,Y=50.000000)
00127	     ScaleMin=3.000000
00128	     ScaleMax=4.000000
00129	     ScaleDeltaX=2.000000
00130	     ScaleDeltaY=2.000000
00131	     LifeSpanMin=0.900000
00132	     LifeSpanMax=1.500000
00133	     AlphaStart=100
00134	     AlphaEnd=50
00135	     bAlphaFade=True
00136	     bApplyGravity=True
00137	     GravityScale=-0.025000
00138	     SpawnOverTime=2.000000
00139	     bDirectional=True
00140	     Style=STY_Translucent
00141	}

End Source Code