RuneI
Class WaterFallSplash

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

class WaterFallSplash
extends RuneI.Splash

//============================================================================= // WaterFallSplash. //=============================================================================
Variables
 vector offsetVect
 vector rotVect


Function Summary
 
simulated
Debug(Canvas canvas, int mode)
 void ParticleReset(int partIndex)
     
//Reset the passed-in Particle
 void PostBeginPlay()
 
simulated
SystemInit()
 
simulated
Tick(float DeltaTime)



Source Code


00001	//=============================================================================
00002	// WaterFallSplash.
00003	//=============================================================================
00004	class WaterFallSplash expands splash;
00005	
00006	/*
00007	Usage: Place at bottom of waterfall (middle widht, on the water (if too low, will see particles come underwater
00008			Aim outwards from the waterfall (towards the direction the player will probably be... Set RadiusSpan
00009	NOTE: Ripples are provided, but should only be used if neccessary (does SPAWN individual actors...) mc
00010	*/
00011	
00012	var(WaterFallSplash) int VerticalIntensity;
00013	var(WaterFallSplash)  int HorizontalIntensity;
00014	var(WaterFallSplash) int RadiusSpan;
00015	
00016	var(Splash) bool bCreateRipples;
00017	
00018	var vector offsetVect;
00019	var vector rotVect;
00020	
00021	function PostBeginPlay()
00022	{
00023		local int i;
00024		
00025		
00026		
00027		Super.PostBeginPlay();
00028	
00029	   //Get the vector orthogonal to the rotation, so that we know which direction to expand in....
00030	    rotVect = vector(Rotation);
00031		offsetVect = (rotVect cross vect(0,0,1)) * RadiusSpan;
00032		
00033		
00034	}
00035	
00036	
00037	simulated function SystemInit()
00038	{
00039		local int i;
00040			
00041		for (i=0; i<ParticleCount; i++)
00042		{
00043			ParticleArray[i].Valid = True;
00044			ParticleArray[i].Alpha = vect(1,1,1)*AlphaStart;
00045			ParticleArray[i].LifeSpan = LifeSpanMax;
00046			ParticleArray[i].TextureIndex = NumTextures * FRand();
00047			ParticleArray[i].Style = Style;
00048			ParticleArray[i].ScaleStartX = 0.1;
00049			ParticleArray[i].ScaleStartY = 0.1;
00050			ParticleArray[i].XScale = 0.1;
00051			ParticleArray[i].YScale = 0.1;
00052		
00053				//Set Up The Velocity of the Particles (based on the rotation, and the Horz & Vert Intensities...)	
00054			ParticleArray[i].Velocity = rotVect * HorizontalIntensity * FRand();
00055			ParticleArray[i].Velocity.Z = VerticalIntensity * FRand();
00056			
00057				//Set Location of Particle, somewhere along the orthogonal to the rotation...
00058			ParticleArray[i].Location = Location + 2 * (FRand() - 0.5) * offsetVect;
00059		}
00060			
00061		RippleDelay = 0;	//For use of delaying ripples (if used)
00062		IsLoaded=true;
00063	}
00064	
00065	
00066	simulated function Tick(float DeltaTime)
00067	{
00068		local int i;
00069	
00070		
00071		for (i=0; i<ParticleCount; i++)
00072		{
00073			if(ParticleArray[i].Valid)
00074			 {
00075			 		//Update Location
00076		     ParticleArray[i].Location =
00077		        ParticleArray[i].Location + (ParticleArray[i].Velocity * DeltaTime);
00078		    	 
00079		    	 	//If at level of the spawner AND velocity is downward, reset particle (and maybe create ripple)
00080		     if(ParticleArray[i].Velocity.Z < 0 && ParticleArray[i].Location.Z < Location.Z)
00081		     { 
00082		      if(bCreateRipples) 
00083		      {
00084		       //Check to see if it is okay to create a ripple yet (minimizes overhead of too many actors)
00085		       if(++RippleDelay >= RippleChance)
00086		       {
00087		        spawn(SpawnRipple, self, , ParticleArray[i].Location, rot(0,0,0));
00088		        RippleDelay = 0;
00089		       }
00090		      }//End if(bCreateRipples)
00091		      
00092		      ParticleReset(i);		//Reset the particle (is a never-ending system)  
00093		     }
00094			}
00095		}//End For-Loop
00096	}
00097	
00098	
00099			//Reset the passed-in Particle
00100	function ParticleReset(int partIndex)
00101	{
00102	 ParticleArray[partIndex].LifeSpan = LifeSpanMax;
00103	 ParticleArray[partIndex].Velocity = rotVect * HorizontalIntensity * FRand();
00104	 ParticleArray[partIndex].Velocity.Z = VerticalIntensity * FRand();		
00105	 ParticleArray[partIndex].Location = Location + 2 * (FRand() - 0.5) * offsetVect;
00106	}
00107	
00108	Simulated function Debug(Canvas canvas, int mode)
00109	{
00110	  	Super.Debug(canvas, mode);
00111		Canvas.DrawText("WaterFallSplash:");
00112		Canvas.CurY -= 8;
00113		
00114		Canvas.DrawLine3D(Location + offsetVect, Location - offsetVect, 0,255,255);
00115		Canvas.DrawLine3D(Location, Location + rotVect * 20, 255,255,255);
00116	}
00117	
00118	defaultproperties
00119	{
00120	     VerticalIntensity=100
00121	     HorizontalIntensity=50
00122	     RadiusSpan=60
00123	     RippleChance=15
00124	     bSystemOneShot=False
00125	     SystemLifeSpan=999999.000000
00126	     LifeSpanMin=999999.000000
00127	     LifeSpanMax=999999.000000
00128	     bWaterOnly=False
00129	     bOneShot=False
00130	     bForceRender=True
00131	     bDirectional=True
00132	     CollisionRadius=50.000000
00133	}

End Source Code