Skip to content
Merged
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
17 changes: 13 additions & 4 deletions ShockOsc/Services/OscHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ public async Task SendParams()
{
// TODO: maybe force resend on avatar change

await UpdateAnyActive();
var (anyActiveRemote, maxIntensityRemote) = GetRemoteAnyActive();

var anyActiveLocal = false;
var maxIntensityLocal = 0f;
var anyCooldown = false;
var anyCooldownPercentage = 0f;

Expand Down Expand Up @@ -111,15 +113,23 @@ public async Task SendParams()
await shocker.ParamCooldownPercentage.SetValue(cooldownPercentage);
await shocker.ParamIntensity.SetValue(intensity);

if (isActive)
{
anyActiveLocal = true;
maxIntensityLocal = MathF.Max(maxIntensityLocal, intensity);
}

if (onCoolDown) anyCooldown = true;
anyCooldownPercentage = MathF.Max(anyCooldownPercentage, cooldownPercentage);
}

await _paramAnyActive.SetValue(anyActiveRemote || anyActiveLocal);
await _paramAnyIntensity.SetValue(MathF.Max(maxIntensityRemote, maxIntensityLocal));
await _paramAnyCooldown.SetValue(anyCooldown);
await _paramAnyCooldownPercentage.SetValue(anyCooldownPercentage);
}

private async Task UpdateAnyActive()
private (bool AnyActive, float MaxIntensity) GetRemoteAnyActive()
{
var now = DateTimeOffset.UtcNow;
var anyActive = false;
Expand All @@ -137,8 +147,7 @@ private async Task UpdateAnyActive()
maxIntensity = MathF.Max(maxIntensity, intensity);
}

await _paramAnyActive.SetValue(anyActive);
await _paramAnyIntensity.SetValue(maxIntensity);
return (anyActive, maxIntensity);
}

public void SetLastControlCommand(LastControlLogEntry controlLogs)
Expand Down