A game framework written with osu! in mind.
at master 1.0 kB view raw
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2// See the LICENCE file in the repository root for full licence text. 3 4#nullable enable 5 6namespace osu.Framework.Timing 7{ 8 /// <summary> 9 /// A framed clock which allows an offset to be added or subtracted from an underlying source clock's time. 10 /// </summary> 11 public class FramedOffsetClock : FramedClock 12 { 13 public override double CurrentTime => base.CurrentTime + offset; 14 15 private double offset; 16 17 /// <summary> 18 /// The offset to be applied. 19 /// </summary> 20 /// <remarks> 21 /// A positive offset will move time forward. 22 /// </remarks> 23 public double Offset 24 { 25 get => offset; 26 set 27 { 28 LastFrameTime += value - offset; 29 offset = value; 30 } 31 } 32 33 public FramedOffsetClock(IClock source, bool processSource = true) 34 : base(source, processSource) 35 { 36 } 37 } 38}