-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
66 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
|
||
namespace Celeste64.TAS.Input; | ||
|
||
public record FastForward { | ||
private const float DefaultSpeed = 400f; | ||
public const float MinSpeed = 1f / 60f; | ||
|
||
public readonly int Frame; | ||
public readonly int Line; | ||
public readonly bool SaveState; | ||
public readonly float Speed; | ||
|
||
public FastForward(int frame, string modifiers, int line) { | ||
Frame = frame; | ||
Line = line; | ||
|
||
if (modifiers.StartsWith("s", StringComparison.OrdinalIgnoreCase)) { | ||
SaveState = true; | ||
modifiers = modifiers[1..]; | ||
} else { | ||
SaveState = false; | ||
} | ||
|
||
Speed = float.TryParse(modifiers, out float speed) ? speed : DefaultSpeed; | ||
if (Speed < MinSpeed) { | ||
Speed = MinSpeed; | ||
} else if (Speed > 1f) { | ||
Speed = (int) Math.Round(Speed); | ||
} | ||
} | ||
|
||
public override string ToString() { | ||
return "***" + (SaveState ? "S" : "") + Speed; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters