//=============================================================================
// BreakingGlass.
//=============================================================================
class BreakingGlass expands Effects;

#exec AUDIO IMPORT FILE="Sounds\general\glass.WAV" NAME="BreakingGlass" GROUP="General"

var() float ParticleSize;
var() float ExplosionSize;
var() float Numparticles;
var() float ExplosionDimensions;
var() texture GlassTexture;
var() sound BreakingSound;
var() bool bTranslucentGlass;
var() bool bUnlitGlass;

function PreBeginPlay()
{
	DrawType = DT_None;
}


Auto State Explode
{
	function Trigger( actor Other, pawn EventInstigator )
	{
		bOnlyTriggerable = False;
		Damage(10, EventInstigator, Location, Vector(Rotation), 'shattered');
	}

	function Touch( actor Other )
	{
		if ( Other.IsA('Projectile') )
			Trigger(Other, Other.Instigator);
	}

	function Damage( int NDamage, Pawn instigatedBy, Vector hitlocation,
						Vector momentum, name damageType)
	{
		local int i;
		local GlassFragments s;
		local actor A;
		if ( !bOnlyTriggerable ) 
		{
			Instigator = InstigatedBy;
			
			PlaySound(BreakingSound, SLOT_None,2.0);
			if( Event != '' )
				foreach AllActors( class 'Actor', A, Event )
					A.Trigger( InstigatedBy, InstigatedBy );
	
			for (i=0 ; i<NumParticles ; i++) 
			{
				s = Spawn( class 'GlassFragments', Owner);
				s.CalcVelocity(Momentum, ExplosionSize, ExplosionDimensions);
				s.DrawScale = ParticleSize;
				s.Skin = GlassTexture;
				s.bUnlit = bUnlit;
				if (bTranslucentGlass) s.Style = STY_Translucent;
			}
			Destroy();
		}
	}
}

