
class goCounter extends Counter;

var int NumToCountA;
var bool bShowMessageA;
var localized string CountMessageA;
var localized string CompleteMessageA;
var int OriginalNumA;
var class<actor> prototypeA;

function BeginPlay()
{
	OriginalNumA = NumToCountA;
}

function Reset()
{
	NumToCountA = OriginalNumA;
}

function Trigger(actor Other, pawn EventInstigator)
{
	local string S;
	local string Num;
	local int i;
	local actor A;

	if (NumToCountA > 0)
	{
		if (--NumToCountA == 0)
		{
			if (bShowMessageA && Len(CompleteMessageA)>0)
				BroadcastMessage(CompleteMessageA, false);
			if( Event != '' )
            foreach AllActors( class 'Actor', A, Event )
               A.Trigger(Other, EventInstigator);
		}
		else if (bShowMessageA && CountMessageA != "")
		{
			switch (NumToCountA)
			{
			case 1:
				Num="one";
				break;
			case 2:
				Num="two";
				break;
			case 3:
				Num="three";
				break;
			case 4:
				Num="four";
				break;
			case 5:
				Num="five";
				break;
			case 6:
				Num="six";
				break;
			default:
				Num=string(NumToCountA);
				break;
			}
			S = CountMessageA;
			while (InStr(S, "%i") >= 0)
			{
				i = InStr(S, "%i");
				S = Left(S,i) $ Num $ Mid(S,i+2);
			}
			BroadcastMessage(S @ prototypeA @ " to go...", false);
		}
	}
}

defaultproperties
{
	bShowMessageA=True
	NumToCountA=2
	CountMessageA="Thing factory has only %i more"      
	CompleteMessageA="Thing factory is empty. Completed!"
	Texture=Texture'Engine.S_Counter'
}