Skip to content

Commit

Permalink
Small fix for bad wait frames.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ottermandias committed Oct 9, 2021
1 parent a22944f commit 1513009
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
31 changes: 21 additions & 10 deletions AutoVisorConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,31 +74,31 @@ public bool CheckIntegrity()
&& WeaponDrawnPose != CPoseManager.UnchangedPose
&& WeaponDrawnPose >= CPoseManager.NumWeaponDrawnPoses)
{
changes = true;
changes = true;
WeaponDrawnPose = CPoseManager.DefaultPose;
}

if (SittingPose != CPoseManager.DefaultPose
&& SittingPose != CPoseManager.UnchangedPose
&& SittingPose >= CPoseManager.NumSitPoses)
{
changes = true;
changes = true;
SittingPose = CPoseManager.DefaultPose;
}

if (GroundSittingPose != CPoseManager.DefaultPose
&& GroundSittingPose != CPoseManager.UnchangedPose
&& GroundSittingPose >= CPoseManager.NumGroundSitPoses)
{
changes = true;
changes = true;
GroundSittingPose = CPoseManager.DefaultPose;
}

if (DozingPose != CPoseManager.DefaultPose
&& DozingPose != CPoseManager.UnchangedPose
&& DozingPose >= CPoseManager.NumDozePoses)
{
changes = true;
changes = true;
DozingPose = CPoseManager.DefaultPose;
}

Expand All @@ -108,9 +108,9 @@ public bool CheckIntegrity()

public class PlayerConfig
{
public const VisorChangeStates Mask = (VisorChangeStates) ((1 << 13) - 1);
public const VisorChangeStates Mask = (VisorChangeStates) ((1 << 13) - 1);

public const VisorChangeStates WeaponMask =
public const VisorChangeStates WeaponMask =
VisorChangeStates.Normal
| VisorChangeStates.Mounted
| VisorChangeStates.Flying
Expand All @@ -133,10 +133,20 @@ public PlayerConfig Clone()
[Serializable]
public class AutoVisorConfiguration : IPluginConfiguration
{
public int Version { get; set; } = 2;
public bool Enabled { get; set; } = true;
public int WaitFrames { get; set; } = 30;
public Dictionary<string, PlayerConfig> States { get; set; } = new();
public const int WaitFramesMin = 1;
public const int WaitFramesMax = 3000;
private int _waitFrames = 30;

public int Version { get; set; } = 2;
public bool Enabled { get; set; } = true;

public int WaitFrames
{
get => _waitFrames;
set => _waitFrames = Math.Clamp(value, WaitFramesMin, WaitFramesMax);
}

public Dictionary<string, PlayerConfig> States { get; set; } = new();

public static AutoVisorConfiguration Load()
{
Expand All @@ -145,6 +155,7 @@ public static AutoVisorConfiguration Load()

cfg = new AutoVisorConfiguration();
cfg.Save();

return cfg;
}

Expand Down
4 changes: 2 additions & 2 deletions GUI/AutoVisorUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ private void DrawWaitFrameInput()
ImGui.SetNextItemWidth(50);
if (ImGui.InputInt("Wait Frames", ref tmp, 0, 0)
&& AutoVisor.Config.WaitFrames != tmp
&& AutoVisor.Config.WaitFrames > 0
&& AutoVisor.Config.WaitFrames < 3001)
&& tmp >= AutoVisorConfiguration.WaitFramesMin
&& tmp <= AutoVisorConfiguration.WaitFramesMax)
{
AutoVisor.Config.WaitFrames = tmp;
Save();
Expand Down

0 comments on commit 1513009

Please sign in to comment.