This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 82
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
1 parent
34739eb
commit b8a5f9a
Showing
7 changed files
with
66 additions
and
6 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 |
---|---|---|
|
@@ -507,5 +507,9 @@ | |
11612, | ||
11306, | ||
11308, | ||
33139 | ||
33139, | ||
21009, | ||
26071, | ||
26072, | ||
26064 | ||
] |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"ClickingCount": 81534, | ||
"SayingHelloCount": 72, | ||
"ClickingCount": 84394, | ||
"SayingHelloCount": 73, | ||
"SaidUsers": [] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
namespace RotationSolver.Basic.Data; | ||
|
||
/// <summary> | ||
/// Off set the whole bool | ||
/// </summary> | ||
/// <param name="getDelay"></param> | ||
public struct OffsetDelay(Func<float> getDelay) | ||
{ | ||
bool _lastValue = false; | ||
bool _nowValue = false; | ||
readonly Queue<DateTime> _changeTimes = new(); | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public readonly Func<float> GetDelay => getDelay; | ||
|
||
/// <summary> | ||
/// Delay the value to change. | ||
/// </summary> | ||
/// <param name="originData"></param> | ||
/// <returns></returns> | ||
public bool Delay(bool originData) | ||
{ | ||
if (originData != _lastValue) | ||
{ | ||
_lastValue = originData; | ||
_changeTimes.Enqueue(DateTime.Now + TimeSpan.FromSeconds(GetDelay())); | ||
} | ||
|
||
if (_changeTimes.TryPeek(out var time) && time < DateTime.Now) | ||
{ | ||
_changeTimes.Dequeue(); | ||
_nowValue = !_nowValue; | ||
} | ||
|
||
return _nowValue; | ||
} | ||
} |
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
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