Skip to main content

PositionRecorder

A class in Root.Township, the global namespace.

Ring buffer of recent position and rotation records for an ImpactTool, which Impactor reads to sweep hits. Pooled through PickupTypeSettings.GetPositionRecorder.

Constructors​

MemberWhat it is
PositionRecorder()Creates a PositionRecorder with default values.

Fields​

5 private and internal fields
MemberWhat it is
private static float inverseLerp1 minus smoothLerp.
private bool isAroundTrue once the buffer has wrapped at least once.
private int nextIndexIndex the next record is written to.
private PositionRecord[] positionArrayThe record buffer, sized by PickupTypeSettings.ImpactorArraySize.
private static float smoothLerpPickupTypeSettings.SmoothLerp, read once for all recorders.

Properties​

MemberWhat it is
IEnumerable<PositionRecord> Positions { get; }The valid records in array order (not oldest first once the buffer has wrapped).
1 private and internal property
MemberWhat it is
private int End { get; }Number of valid records: the write index until the buffer wraps, then the whole array.

Methods​

MemberWhat it is
void AddDistance(Vector3 distance)Shifts every record by the given offset. Hooked to the holding player's DistanceTravelled so movement doesn't count as a swing.
void Clear()Empties the buffer.
void RecordPosition(Transform transform)Stores the transform's current position and rotation, wrapping round when the buffer is full.
void RotateAround(Vector3 pivot, Quaternion relativeRotation)Pulls every record towards the latest one by SmoothLerp. Hooked to the player's turning; its pivot and rotation arguments are not used.
1 private and internal method
MemberWhat it is
private Quaternion Lerp(Quaternion from, Quaternion to, float inverseLerp)Blends two quaternions by scaling the first and adding the second, then normalising. Used by RotateAround.

Used in​

Members of other types that take, return or hold a PositionRecorder: