Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for PhysBones handling. #37

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions ShockOsc/Config/Group.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ public sealed class Group

public bool OverrideCooldownTime { get; set; }
public uint CooldownTime { get; set; } = 5000;

public bool SuppressPhysBoneReleaseAction { get; set; }
}
1 change: 1 addition & 0 deletions ShockOsc/Models/ProgramGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public sealed class ProgramGroup
public DateTime LastActive { get; set; }
public DateTime LastExecuted { get; set; }
public DateTime LastVibration { get; set; }
public DateTime PhysBoneGrabLimitTime { get; set; }
public ushort LastDuration { get; set; }
public byte LastIntensity { get; set; }
public float LastStretchValue { get; set; }
Expand Down
12 changes: 11 additions & 1 deletion ShockOsc/Services/ShockOsc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

if (!_configManager.Config.Osc.OscQuery)
{
FoundVrcClient(null, null);

Check warning on line 93 in ShockOsc/Services/ShockOsc.cs

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.

Check warning on line 93 in ShockOsc/Services/ShockOsc.cs

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.

Check warning on line 93 in ShockOsc/Services/ShockOsc.cs

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.

Check warning on line 93 in ShockOsc/Services/ShockOsc.cs

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.

Check warning on line 93 in ShockOsc/Services/ShockOsc.cs

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.

Check warning on line 93 in ShockOsc/Services/ShockOsc.cs

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.
}

_logger.LogInformation("Started ShockOsc.cs");
Expand Down Expand Up @@ -415,6 +415,13 @@
}
}

if (!programGroup.IsGrabbed && isGrabbed)
{
// on physbone grab
ushort TheDuration = GetDuration(programGroup);
programGroup.PhysBoneGrabLimitTime = DateTime.UtcNow.AddMilliseconds(TheDuration);
_logger.LogDebug("Limiting hold duration of Group {Group} to {Duration}ms", programGroup.Name, TheDuration);
}
programGroup.IsGrabbed = isGrabbed;
return;
// Normal shocker actions
Expand Down Expand Up @@ -540,10 +547,12 @@
_configManager.Config.Behaviour.WhileBoneHeld !=
BehaviourConf.BoneHeldAction.None &&
!isActiveOrOnCooldown &&
!_underscoreConfig.KillSwitch &&
programGroup.IsGrabbed &&
programGroup.PhysBoneGrabLimitTime > DateTime.UtcNow &&
programGroup.LastVibration < DateTime.UtcNow.Subtract(TimeSpan.FromMilliseconds(100)))
{
var pullIntensityTranslated = Math.Max(Convert.ToByte(programGroup.LastStretchValue * 100f), (byte)1);
var pullIntensityTranslated = GetPhysbonePullIntensity(programGroup, programGroup.LastStretchValue);
programGroup.LastVibration = DateTime.UtcNow;

_logger.LogDebug("Vibrating/Shocking {Shocker} at {Intensity}", pos, pullIntensityTranslated);
Expand Down Expand Up @@ -586,6 +595,7 @@

if (programGroup.TriggerMethod == TriggerMethod.PhysBoneRelease)
{
if (programGroup.ConfigGroup is { SuppressPhysBoneReleaseAction: true }) { return; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs to be handled for global config (_All)

intensity = GetPhysbonePullIntensity(programGroup, programGroup.LastStretchValue);
programGroup.LastStretchValue = 0;

Expand Down
4 changes: 4 additions & 0 deletions ShockOsc/Ui/Pages/Dash/Tabs/GroupsTab.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@using System.Globalization

Check warning on line 1 in ShockOsc/Ui/Pages/Dash/Tabs/GroupsTab.razor

View workflow job for this annotation

GitHub Actions / build

Illegal Parameter 'Outline' on 'MudToggleGroup' using 'V7IgnoreCase' source location '(407,20)-(407,75)' (https://mudblazor.com/features/analyzers)

Check warning on line 1 in ShockOsc/Ui/Pages/Dash/Tabs/GroupsTab.razor

View workflow job for this annotation

GitHub Actions / build

Illegal Parameter 'Dense' on 'MudToggleGroup' using 'V7IgnoreCase' source location '(417,20)-(417,73)' (https://mudblazor.com/features/analyzers)

Check warning on line 1 in ShockOsc/Ui/Pages/Dash/Tabs/GroupsTab.razor

View workflow job for this annotation

GitHub Actions / build

Illegal Parameter 'Outline' on 'MudToggleGroup' using 'V7IgnoreCase' source location '(407,20)-(407,75)' (https://mudblazor.com/features/analyzers)

Check warning on line 1 in ShockOsc/Ui/Pages/Dash/Tabs/GroupsTab.razor

View workflow job for this annotation

GitHub Actions / build

Illegal Parameter 'Dense' on 'MudToggleGroup' using 'V7IgnoreCase' source location '(417,20)-(417,73)' (https://mudblazor.com/features/analyzers)

Check warning on line 1 in ShockOsc/Ui/Pages/Dash/Tabs/GroupsTab.razor

View workflow job for this annotation

GitHub Actions / build

Illegal Parameter 'Outline' on 'MudToggleGroup' using 'V7IgnoreCase' source location '(821,20)-(821,76)' (https://mudblazor.com/features/analyzers)
@using System.Text.RegularExpressions
@using OpenShock.ShockOsc.Backend
@using OpenShock.ShockOsc.Config
Expand Down Expand Up @@ -244,6 +244,10 @@
</MudCollapse>
</MudPaper>

<MudPaper Outlined="true" Class="rounded-lg mud-paper-padding-margin">
<MudCheckBox Class="checkbox-title" @bind-Value="@CurrentGroup.SuppressPhysBoneReleaseAction" Label="Suppress PhysBone Release Action" @bind-Value:after="OnGroupSettingsValueChange" />
</MudPaper>

<MudPaper Outlined="true" Class="rounded-lg mud-paper-padding-margin">
<MudText>Shockers in Group</MudText>
<MudDivider/>
Expand Down
Loading