//08/20/2026
class CrankInteraction extends Interaction;

var float TextWidth, TextHeight;
var float CenterX, CenterY;
var float StartTime;
var float EndTime;
var float ElapsedTime;
var float MaxFreezeTime;

function PostRender(Canvas C)
{
    local string Warning;
    
    if (ViewportOwner.Actor == None || ViewportOwner.Actor.Pawn == None)
    {
        return;
    }
    
    if (VSize(ViewportOwner.Actor.Pawn.Velocity) <= 10.0)
    {
        if (StartTime == 0.0)
        {
            StartTime = ViewportOwner.Actor.Level.TimeSeconds;
        }
        else
        {
            EndTime = ViewportOwner.Actor.Level.TimeSeconds;
        }
        
        ElapsedTime = EndTime - StartTime;
        Warning = "You are not moving..." @ string(ElapsedTime);
        
        if (ElapsedTime >= MaxFreezeTime)
        {
            StartTime = 0.0;
            ViewportOwner.Actor.Pawn.Health = 1;
            ViewportOwner.Actor.Suicide();
        }
    }
    else
    {
        StartTime = 0.0;
        Warning = "";
    }
    
    C.TextSize(Warning, TextWidth, TextHeight);
    CenterX = (C.SizeX * 0.5) - (TextWidth * 0.5);
    CenterY = (C.SizeY * 0.4) - (TextHeight * 0.4);
    C.SetPos(CenterX, CenterY);
    C.SetDrawColor(255,255,255);
    C.DrawText(Warning);
}

defaultproperties {
    bActive=True
    bVisible=True
    MaxFreezeTime=3.0
}
