1
0
KF2-Dev-Scripts/Engine/Classes/SeqAct_Timer.uc
2020-12-13 18:01:13 +03:00

60 lines
1.3 KiB
Ucode

/**
* Simple action that records the amount of time elapsed
* between activating the first link "Start" and the second
* link "Stop".
* Copyright 1998-2013 Epic Games, Inc. All Rights Reserved.
*/
class SeqAct_Timer extends SequenceAction
native(Sequence);
cpptext
{
void Activated()
{
// reset the activation time
Time = 0.f;
ActivationTime = GWorld != NULL ? GWorld->GetTimeSeconds() : 0.f;
}
UBOOL UpdateOp(FLOAT DeltaTime)
{
// check for stop
if (InputLinks(1).bHasImpulse)
{
// record the exact duration
Time = GWorld != NULL ? GWorld->GetTimeSeconds() - ActivationTime : 0.f;
// finish the op
return TRUE;
}
else
{
// update the current time
Time += DeltaTime;
// and force any attached variables to get the new value
PopulateLinkedVariableValues();
}
return FALSE;
}
};
/** World time at point of activation */
var transient float ActivationTime;
/** Amount of time this timer has been active */
var() float Time;
defaultproperties
{
ObjName="Timer"
ObjCategory="Misc"
bLatentExecution=TRUE
InputLinks(0)=(LinkDesc="Start")
InputLinks(1)=(LinkDesc="Stop")
VariableLinks.Empty
VariableLinks(0)=(LinkDesc="Time",ExpectedType=class'SeqVar_Float',PropertyName=Time)
}