Code cleanup.

This commit is contained in:
2023-02-18 14:46:08 +08:00
parent 274a823d02
commit a1f7418d32
10 changed files with 78 additions and 66 deletions

View File

@@ -164,8 +164,8 @@ namespace Cryville.Crtr {
protected void Dispose(bool disposing) {
if (disposing) {
Deactivate();
foreach (var proxy in _tproxies.Values) {
proxy.Source.Value.Handler.OnInput -= OnInput;
foreach (var proxy in _tproxies) {
proxy.Value.Source.Value.Handler.OnInput -= OnInput;
}
}
}
@@ -236,13 +236,14 @@ namespace Cryville.Crtr {
}
}
public void SyncTime(double time) {
foreach (var s in _sproxies.Keys) {
var h = s.Handler;
foreach (var s in _sproxies) {
var h = s.Key.Handler;
_timeOrigins[h] = h.GetCurrentTimestamp() - time;
}
}
public void ForceTick() {
foreach (var src in _sproxies.Keys) {
foreach (var s in _sproxies) {
var src = s.Key;
if (_activeCounts[src] == 0) {
OnInput(new InputIdentifier { Source = src, Id = 0 }, new InputVector(_lockTime != null ? _lockTime.Value : src.Handler.GetCurrentTimestamp()));
}
@@ -250,7 +251,8 @@ namespace Cryville.Crtr {
}
public double GetTimestampAverage() {
double result = 0;
foreach (var src in _sproxies.Keys) {
foreach (var s in _sproxies) {
var src = s.Key;
result += src.Handler.GetCurrentTimestamp() - _timeOrigins[src.Handler];
}
return result / _sproxies.Count;