Compare commits
No commits in common. "9f961f2c6556e82aea185062ed7b6d92c2d5fe52" and "6a862fa8141a7f7ab85381fb6bcf2d23964a64ca" have entirely different histories.
9f961f2c65
...
6a862fa814
@ -53,20 +53,8 @@ public class OpenCS2hock
|
||||
case "OnRoundWin":
|
||||
this._cs2GSI.OnRoundWin += (cs2EventArgs) => shocker.Control(Settings.StringToAction(kv.Value));
|
||||
break;
|
||||
case "OnDamageTaken":
|
||||
this._cs2GSI.OnDamageTaken += (cs2EventArgs) =>
|
||||
shocker.Control(Settings.StringToAction(kv.Value),
|
||||
intensity: MapInt(cs2EventArgs.ValueAsOrDefault<int>(), 0, 100,
|
||||
_settings.IntensityRange.Min, _settings.IntensityRange.Max));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int MapInt(int input, int fromLow, int fromHigh, int toLow, int toHigh)
|
||||
{
|
||||
int mappedValue = (input - fromLow) * (toHigh - toLow) / (fromHigh - fromLow) + toLow;
|
||||
return mappedValue;
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CS2GSI" Version="1.0.3" />
|
||||
<PackageReference Include="CS2GSI" Version="1.0.2" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -32,8 +32,7 @@ public struct Settings
|
||||
{"OnRoundStart", "Vibrate"},
|
||||
{"OnRoundEnd", "Nothing"},
|
||||
{"OnRoundWin", "Beep"},
|
||||
{"OnRoundLoss", "Nothing"},
|
||||
{"OnDamageTaken", "Vibrate"}
|
||||
{"OnRoundLoss", "Nothing"}
|
||||
};
|
||||
|
||||
public Settings()
|
||||
|
@ -12,18 +12,18 @@ internal abstract class Shocker
|
||||
|
||||
internal enum ControlAction { Beep, Vibrate, Shock, Nothing }
|
||||
|
||||
internal void Control(ControlAction action, string? shockerId = null, int? intensity = null, int? duration = null)
|
||||
internal void Control(ControlAction action, string? shockerId = null)
|
||||
{
|
||||
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}");
|
||||
int intensity = _intensity.GetValue();
|
||||
int duration = _duration.GetValue();
|
||||
this.Logger?.Log(LogLevel.Information, $"{action} {intensity} {duration}");
|
||||
if (action is ControlAction.Nothing)
|
||||
return;
|
||||
if(shockerId is null)
|
||||
foreach (string shocker in _shockerIds)
|
||||
ControlInternal(action, shocker, i, d);
|
||||
ControlInternal(action, shocker, intensity, duration);
|
||||
else
|
||||
ControlInternal(action, shockerId, i, d);
|
||||
ControlInternal(action, shockerId, intensity, duration);
|
||||
}
|
||||
|
||||
protected abstract void ControlInternal(ControlAction action, string shockerId, int intensity, int duration);
|
||||
|
Loading…
x
Reference in New Issue
Block a user