resonance 1.0.1
Loading...
Searching...
No Matches
LinearAnim Class Reference

Value that moves toward a target at a fixed rate, read through a linear mapping. More...

#include <linearanim.h>

Public Member Functions

 LinearAnim ()
 Start at 0 with no time recorded, mapping 0 through 1 onto 0 through 100 over 240 units.
void SetParams (float flFrom, float flTo, float flDuration)
 Set the mapping and the rate.
void SetTarget (float flTarget)
 Set the raw value to move toward.
void Jump (float flTarget)
 Set the target and move the raw value almost onto it at once.
float Val () const
 Report the mapped value.
int Execute (float flTime)
 Move the raw value toward the target by the time elapsed since the last call.

Detailed Description

Value that moves toward a target at a fixed rate, read through a linear mapping.

The class is not polymorphic and emits no RTTI. Its name comes from the debugging symbols of the North American demo release. The head-up display and the tunnel both embed it by value.

The raw value runs from 0 toward mTarget at mRate per unit of Execute()'s time, and Val() reports it as mCurrent * mScale + mOffset. SetParams() fixes the mapping and the rate.

Constructor & Destructor Documentation

◆ LinearAnim()

LinearAnim::LinearAnim ( )

Start at 0 with no time recorded, mapping 0 through 1 onto 0 through 100 over 240 units.

Ghidra address:
NTSC-U/C: 0x00411878
Ghidra address:
PAL: 0x0044b340

Member Function Documentation

◆ SetParams()

void LinearAnim::SetParams ( float flFrom,
float flTo,
float flDuration )

Set the mapping and the rate.

A raw value of 0 maps to flFrom and 1 maps to flTo, and the raw value covers that span in flDuration units of time.

Parameters
flFromThe mapped value at raw 0.
flToThe mapped value at raw 1.
flDurationThe time the raw value takes to cover 0 through 1.
Ghidra address:
NTSC-U/C: 0x004118d0
Ghidra address:
PAL: 0x0044b398

◆ SetTarget()

void LinearAnim::SetTarget ( float flTarget)

Set the raw value to move toward.

Parameters
flTargetThe raw target.
Ghidra address:
NTSC-U/C: 0x00411900
Ghidra address:
PAL: 0x0044b3c8

◆ Jump()

void LinearAnim::Jump ( float flTarget)

Set the target and move the raw value almost onto it at once.

The raw value lands one millionth short of the target, computed in double precision. The next Execute() then finishes the move and reports a change. The title is inferred.

Parameters
flTargetThe raw target.
Ghidra address:
NTSC-U/C: 0x00411908
Ghidra address:
PAL: 0x0044b3d0

◆ Val()

float LinearAnim::Val ( ) const

Report the mapped value.

Returns
mCurrent * mScale + mOffset.
Ghidra address:
NTSC-U/C: 0x00411958
Ghidra address:
PAL: 0x0044b420

◆ Execute()

int LinearAnim::Execute ( float flTime)

Move the raw value toward the target by the time elapsed since the last call.

The first call after construction only records the time. A step that would overshoot lands on the target.

Parameters
flTimeThe current time.
Returns
1 when the raw value was away from the target on entry, and 0 when it was already there.
Ghidra address:
NTSC-U/C: 0x00411970
Ghidra address:
PAL: 0x0044b438

The documentation for this class was generated from the following file: