Add Overwrite to Shocker.Control for intensity and duration

This commit is contained in:
glax 2024-01-16 01:20:28 +01:00
parent 6a862fa814
commit f01d721281

View File

@ -12,18 +12,18 @@ internal abstract class Shocker
internal enum ControlAction { Beep, Vibrate, Shock, Nothing }
internal void Control(ControlAction action, string? shockerId = null)
internal void Control(ControlAction action, string? shockerId = null, int? intensity = null, int? duration = null)
{
int intensity = _intensity.GetValue();
int duration = _duration.GetValue();
this.Logger?.Log(LogLevel.Information, $"{action} {intensity} {duration}");
int i = intensity ?? _intensity.GetValue();
int d = duration ?? _duration.GetValue();
this.Logger?.Log(LogLevel.Information, $"{action} {(intensity is not null ? "Overwrite " : "")}{i} {(duration is not null ? "Overwrite " : "")}{d}");
if (action is ControlAction.Nothing)
return;
if(shockerId is null)
foreach (string shocker in _shockerIds)
ControlInternal(action, shocker, intensity, duration);
ControlInternal(action, shocker, i, d);
else
ControlInternal(action, shockerId, intensity, duration);
ControlInternal(action, shockerId, i, d);
}
protected abstract void ControlInternal(ControlAction action, string shockerId, int intensity, int duration);