fixes
This commit is contained in:
parent
c6bd342e87
commit
2d429fcb6b
@ -11,7 +11,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CS2GSI" Version="1.0.7" />
|
||||
<PackageReference Include="CShocker" Version="2.3.1" />
|
||||
<PackageReference Include="CShocker" Version="2.4.0" />
|
||||
<PackageReference Include="GlaxLogger" Version="1.0.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
@ -8,11 +8,11 @@ namespace OpenCS2hock;
|
||||
public struct ShockerAction
|
||||
{
|
||||
public CS2Event TriggerEvent;
|
||||
// ReSharper disable thrice FieldCanBeMadeReadOnly.Global JsonDeserializer will throw a fit
|
||||
public int ShockerId;
|
||||
public ControlAction Action;
|
||||
public bool ValueFromInput;
|
||||
public IntegerRange IntensityRange, DurationRange;
|
||||
// ReSharper disable MemberCanBePrivate.Global -> exposed
|
||||
public readonly int ShockerId;
|
||||
public readonly ControlAction Action;
|
||||
public readonly bool ValueFromInput;
|
||||
public readonly IntegerRange IntensityRange, DurationRange;
|
||||
|
||||
public ShockerAction(CS2Event trigger, int shockerId, ControlAction action, bool valueFromInput, IntegerRange intensityRange, IntegerRange durationRange)
|
||||
{
|
||||
@ -28,23 +28,18 @@ public struct ShockerAction
|
||||
{
|
||||
if (!shockers.ContainsKey(ShockerId))
|
||||
return;
|
||||
int intensity = ValueFromInput ? IntensityFromCS2Event(cs2EventArgs) : RandomValueFromRange(IntensityRange);
|
||||
int duration = RandomValueFromRange(DurationRange);
|
||||
int intensity = ValueFromInput ? IntensityFromCS2Event(cs2EventArgs) : IntensityRange.RandomValueWithinLimits();
|
||||
int duration = DurationRange.RandomValueWithinLimits();
|
||||
shockers[ShockerId].Control(Action, intensity, duration);
|
||||
}
|
||||
|
||||
private static int RandomValueFromRange(IntegerRange range)
|
||||
{
|
||||
return Random.Shared.Next(range.Min, range.Max);
|
||||
}
|
||||
|
||||
private int IntensityFromCS2Event(CS2EventArgs cs2EventArgs)
|
||||
{
|
||||
return TriggerEvent switch
|
||||
{
|
||||
CS2Event.OnDamageTaken => MapInt(cs2EventArgs.ValueAsOrDefault<int>(), 0, 100, IntensityRange.Min, IntensityRange.Max),
|
||||
CS2Event.OnArmorChange => MapInt(cs2EventArgs.ValueAsOrDefault<int>(), 0, 100, IntensityRange.Min, IntensityRange.Max),
|
||||
_ => RandomValueFromRange(IntensityRange)
|
||||
_ => IntensityRange.RandomValueWithinLimits()
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user