Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiple small issues with the speedrun practice timer #4

Merged
merged 1 commit into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Source/Actors/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,19 @@ public bool IsAbleToPause
&& stateMachine.State != States.StrawbGet
&& stateMachine.State != States.Cassette
&& stateMachine.State != States.Dead;
public bool IsSpeedrunPracticeTimePaused

public bool IsMidPickup
=> stateMachine.State == States.StrawbGet
|| stateMachine.State == States.Cassette;

public bool IsActive
=> stateMachine.State != States.StrawbGet
&& stateMachine.State != States.Cassette
&& stateMachine.State != States.StrawbReveal
&& stateMachine.State != States.Respawn
&& stateMachine.State != States.Dead;


public Player()
{
PointShadowAlpha = 1.0f;
Expand Down Expand Up @@ -2140,6 +2148,8 @@ private void StCassetteExit()
drawModel = drawHair = true;
cameraOverride = null;
PointShadowAlpha = 1;

Save.CurrentRecord.ResetSpeedrunPracticeTime();
}

#endregion
Expand Down
20 changes: 6 additions & 14 deletions Source/Scenes/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,9 @@ public enum EntryReasons { Entered, Returned, Respawned }

private bool IsInEndingArea => Get<Player>() is {} player && Overlaps<EndingArea>(player.Position);

private bool IsSpeedrunPracticeTimerPaused => Get<Player>() is { } player && player.IsSpeedrunPracticeTimePaused;
private bool IsPlayerMidPickup => Get<Player>() is {} player && player.IsMidPickup;

private bool IsSpeedrunPracticeTimerRunning
{
get
{
if (Game.Instance.IsMidTransition) return false;
if (Get<Player>() is not { } player) return true;
return player.IsAbleToPause;
}
}
private bool IsPlayerActive => Get<Player>() is {} player && player.IsActive;

private bool IsPauseEnabled
{
Expand Down Expand Up @@ -307,8 +299,8 @@ public override void Update()
Game.Instance.Music.Set("at_baddy", 1);
}

// increment practice timer
if (IsSpeedrunPracticeTimerRunning)
// increment practice timer (if not in the ending area)
if (IsPlayerActive && !IsInEndingArea)
{
Save.CurrentRecord.SpeedrunPracticeTime += TimeSpan.FromSeconds(Time.Delta);
}
Expand Down Expand Up @@ -817,11 +809,11 @@ public override void Render(Target target)
{
timerDisplayColor = Color.CornflowerBlue;
}
else if (Save.Instance.SpeedrunPracticeTimer && IsSpeedrunPracticeTimerPaused)
else if (Save.Instance.SpeedrunPracticeTimer && IsPlayerMidPickup)
{
timerDisplayColor = Color.Yellow;
}
else if (Save.Instance.SpeedrunPracticeTimer && !IsSpeedrunPracticeTimerRunning)
else if (Save.Instance.SpeedrunPracticeTimer && !IsPlayerActive)
{
timerDisplayColor = Color.Gray;
}
Expand Down
Loading