Skip to content

Commit

Permalink
Changed the Alarm for Completion Count change to a Coroutine #patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Paloys committed Oct 1, 2022
1 parent faa3335 commit 1de0dd8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
5 changes: 1 addition & 4 deletions GoldenTrainer/CompletionDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ public class CompletionDisplay : Entity

private float _width;



public CompletionDisplay(Level level)
{
_level = level;
Expand All @@ -44,7 +42,7 @@ public void SetDisplayText(string text)

public float GetYPosition()
{
var posY = 10f * 16;
var posY = 10f * 16 + 10f;

if (!_level.TimerHidden)
{
Expand Down Expand Up @@ -98,7 +96,6 @@ public override void Render()

_bg.Draw(new Vector2(_width - _bg.Width + basePos.X, Y));


if (_width > _bg.Width + basePos.X)
{
Draw.Rect(0, Y, _width - _bg.Width + basePos.X, 38f, Color.Black);
Expand Down
21 changes: 13 additions & 8 deletions GoldenTrainer/GoldenTrainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using System;
using System.Collections;
using System.Net.Sockets;
using NPC09_Granny_Inside = On.Celeste.NPC09_Granny_Inside;

namespace GoldenTrainer
{
Expand Down Expand Up @@ -34,15 +37,17 @@ public int CompletionCount
set
{
_completionCount = value;
if (value == 0)
{
Display.SetDisplayText(_completionCount + "/" + Settings.NumberOfCompletions);
}
else
{
Alarm.Set(Display, 1.5f, () => Display.SetDisplayText(_completionCount + "/" + Settings.NumberOfCompletions));
}
Display?.Add(new Coroutine(DelayCountChangeRoutine()));
}
}

private IEnumerator DelayCountChangeRoutine()
{
while (_level.Tracker.GetEntity<Player>() is null || _level.Tracker.GetEntity<Player>().Dead)
{
yield return Engine.DeltaTime;
}
Display.SetDisplayText(_completionCount + "/" + Settings.NumberOfCompletions);
}


Expand Down
2 changes: 1 addition & 1 deletion everest.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- Name: GoldenTrainer
Version: 1.4.3
Version: 1.4.4
DLL: GoldenTrainer/bin/x86/Debug/GoldenTrainer.dll
Dependencies:
- Name: Everest
Expand Down

0 comments on commit 1de0dd8

Please sign in to comment.