RuneI
Class Plants

source: c:\runehov\RuneI\Classes\plants.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Decoration
         |
         +--RuneI.DecorationRune
            |
            +--RuneI.Plants
Direct Known Subclasses:Bush, Fruit_Tree, GlowPlant, PineTree, Sappling, SpongeMushroom, Tree1

class Plants
extends RuneI.DecorationRune

//============================================================================= // Plants. //=============================================================================
Variables
 float LastSoundPlayed
 float TimeBetweenBrushes


Function Summary
 void AddVelocity(vector NewVelocity)
 
simulated
Debug(Canvas canvas, int mode)
 bool JointDamaged(int Damage, Pawn EventInstigator, vector HitLoc, vector Momentum, name DamageType, int joint)
 
simulated
JointTouchedBy(Actor Other, int joint)
 EMatterType MatterForJoint(int joint)
 void PlayBrushSound(Actor Other)
 void PostBeginPlay()



Source Code


00001	//=============================================================================
00002	// Plants.
00003	//=============================================================================
00004	class Plants extends DecorationRune
00005		abstract;
00006	
00007	
00008	var(Dynamics) float Dampening;
00009	var(Dynamics) int	RotAngle;
00010	var(Dynamics) float	AccelMag;
00011	var(Dynamics) float TouchFactor;
00012	var(Dynamics) float HitFactor;
00013	var() float TimeBetweenBrushes;
00014	
00015	var(Sounds) sound BrushSound;
00016	
00017	var float LastSoundPlayed;
00018	
00019	simulated event GetAccelJointParms(int joint, out float DampFactor, out float RotThreshold)
00020	{
00021		DampFactor = Dampening;
00022		RotThreshold = RotAngle;
00023	}
00024	
00025	simulated event float GetAccelJointMagnitude(int joint)
00026	{
00027		return AccelMag;
00028	}
00029	
00030	function EMatterType MatterForJoint(int joint)
00031	{	
00032		return MATTER_NONE;
00033	}
00034	
00035	function PostBeginPlay()
00036	{
00037		LastSoundPlayed = Level.TimeSeconds;
00038		Super.PreBeginPlay();
00039	}
00040	
00041	function bool JointDamaged(int Damage, Pawn EventInstigator, vector HitLoc, vector Momentum, name DamageType, int joint)
00042	{
00043		if (joint != 0)
00044		{
00045			ApplyJointForce(joint, Momentum*HitFactor);
00046	
00047			if (Level.TimeSeconds - LastSoundPlayed > TimeBetweenBrushes)
00048			{
00049				LastSoundPlayed = Level.TimeSeconds;
00050				PlaySound(BrushSound, SLOT_None);
00051			}
00052		}
00053	
00054		Super.JointDamaged(Damage, EventInstigator, HitLoc, Momentum, DamageType, joint);
00055		return true;
00056	}
00057	
00058	simulated function JointTouchedBy(actor Other, int joint)
00059	{
00060		local vector vel;
00061	
00062		vel = Other.Velocity * TouchFactor;
00063		ApplyJointForce(joint, vel);
00064		PlayBrushSound(Other);
00065	}
00066	
00067	function PlayBrushSound(actor Other)
00068	{
00069		if (Level.TimeSeconds - LastSoundPlayed > TimeBetweenBrushes)
00070		{
00071			PlaySound(BrushSound, SLOT_None);
00072			LastSoundPlayed = Level.TimeSeconds;
00073			if (Pawn(Other) != None || Other.Instigator != None)
00074			{
00075				Other.MakeNoise(1.0);
00076			}
00077		}
00078	}
00079	
00080	function AddVelocity(vector NewVelocity)
00081	{
00082		local int ix,num;
00083		num = NumJoints();
00084		for (ix=0; ix<num; ix++)
00085		{
00086			if ((JointFlags[ix] & JOINT_FLAG_COLLISION)!=0)
00087			{
00088				ApplyJointForce(ix, NewVelocity);
00089			}
00090		}
00091	}
00092	
00093	simulated function Debug(Canvas canvas, int mode)
00094	{
00095		Super.Debug(canvas, mode);
00096		
00097		Canvas.DrawText("Dynamics:");
00098		Canvas.CurY -= 8;
00099		Canvas.DrawText(" Dampening:   "$Dampening);
00100		Canvas.CurY -= 8;
00101		Canvas.DrawText(" RotAngle:    "$RotAngle);
00102		Canvas.CurY -= 8;
00103		Canvas.DrawText(" AccelMag:    "$AccelMag);
00104		Canvas.CurY -= 8;
00105		Canvas.DrawText(" TouchFactor: "$TouchFactor);
00106		Canvas.CurY -= 8;
00107		Canvas.DrawText(" HitFactor:   "$HitFactor);
00108		Canvas.CurY -= 8;
00109	}
00110	
00111	defaultproperties
00112	{
00113	     Dampening=0.025000
00114	     RotAngle=8000
00115	     AccelMag=10000.000000
00116	     TouchFactor=0.100000
00117	     HitFactor=0.100000
00118	     TimeBetweenBrushes=1.500000
00119	     bBurnable=True
00120	     bStatic=False
00121	     DrawType=DT_SkeletalMesh
00122	     TransientSoundRadius=1200.000000
00123	     bCollideActors=True
00124	     bCollideWorld=True
00125	     bBlockActors=True
00126	     bBlockPlayers=True
00127	     bJointsTouch=True
00128	}

End Source Code