//=============================================================================
// TAD.
//=============================================================================
class JailTimer extends ElectronicDevices;

var int timertron;
var bool bInUse;
var(events) name DoorName;
var string NewName;

Replication
{
	Reliable if (Role == ROLE_Authority)
		NewName, UpdateName;
}

function tick (float deltatime)
{
	unfamiliarName = timertron $ " seconds prison time remaining";
	NewName = unfamiliarName;
	UpdateName();

	Super.Tick(deltatime);
}

Function Frob(actor frobber, inventory frobwith)
{
	if (frobber.IsA('DeusExPlayer'))
		DeusExPlayer(Frobber).ClientMessage(timertron $ " seconds prison time remaining");
}


simulated function UpdateName()
{
	UnfamiliarName = NewName;
}


function LetsGo()
{
	timertron = 60;
	bInUse=True;
	SetTimer(1, False);
}

function Timer()
{
	EachSec();
}

Function EachSec()
{
	local actor A;
	local JailTimerTrigger J;
	local DeusExPlayer P;

	If (timertron != 0)
	{
		timertron-=1;
		SetTimer(1,False);
	}

	If (timertron == 0)
	{
		ForEach AllActors (class'Actor', A)
		{
			if (A.Tag == DoorName)
			{
				A.Trigger(Self, None);
			}
		}
		ForEach AllActors (class'JailTimerTrigger', J)
		{
			if (J.CellName == DoorName)
			{
				P = J.Player;
				P.ClientMessage("You have been released!");
			}
		}
		return;	
	}
}

defaultproperties
{
     Physics=PHYS_None;
     ItemName="Countdown Timer"
     Mesh=LodMesh'DeusExDeco.TAD'
     CollisionRadius=7.400000
     CollisionHeight=2.130000
     Mass=10.000000
     Buoyancy=5.000000
}
