forked from Ottermandias/AutoVisor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoVisorConfiguration.cs
165 lines (140 loc) · 5.56 KB
/
AutoVisorConfiguration.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
using System;
using System.Collections.Generic;
using Dalamud.Configuration;
using AutoVisor.Classes;
using AutoVisor.Managers;
namespace AutoVisor
{
public struct VisorChangeGroup
{
public VisorChangeStates VisorSet;
public VisorChangeStates VisorState;
public VisorChangeStates HideHatSet;
public VisorChangeStates HideHatState;
public VisorChangeStates HideWeaponSet;
public VisorChangeStates HideWeaponState;
public byte StandingPose;
public byte WeaponDrawnPose;
public byte SittingPose;
public byte GroundSittingPose;
public byte DozingPose;
public static VisorChangeGroup Empty = new()
{
VisorSet = 0,
VisorState = 0,
HideHatSet = 0,
HideHatState = 0,
HideWeaponSet = 0,
HideWeaponState = 0,
StandingPose = CPoseManager.UnchangedPose,
WeaponDrawnPose = CPoseManager.UnchangedPose,
SittingPose = CPoseManager.UnchangedPose,
GroundSittingPose = CPoseManager.UnchangedPose,
DozingPose = CPoseManager.UnchangedPose,
};
public VisorChangeGroup ResetPoses()
{
StandingPose = CPoseManager.UnchangedPose;
WeaponDrawnPose = CPoseManager.UnchangedPose;
SittingPose = CPoseManager.UnchangedPose;
GroundSittingPose = CPoseManager.UnchangedPose;
DozingPose = CPoseManager.UnchangedPose;
return this;
}
public bool CheckIntegrity()
{
var changes = VisorSet > PlayerConfig.Mask;
VisorSet &= PlayerConfig.Mask;
changes |= (VisorSet & VisorState) != VisorState;
VisorState &= VisorSet;
changes |= HideHatSet > PlayerConfig.Mask;
HideHatSet &= PlayerConfig.Mask;
changes |= (HideHatSet & HideHatState) != HideHatState;
HideHatState &= HideHatSet;
changes |= (HideWeaponSet & PlayerConfig.WeaponMask) != HideWeaponSet;
HideHatSet &= PlayerConfig.WeaponMask;
changes |= (HideWeaponSet & HideWeaponState) != HideWeaponState;
HideHatState &= HideHatSet;
if (StandingPose != CPoseManager.DefaultPose
&& StandingPose != CPoseManager.UnchangedPose
&& StandingPose >= CPoseManager.NumStandingPoses)
{
changes = true;
StandingPose = CPoseManager.DefaultPose;
}
if (WeaponDrawnPose != CPoseManager.DefaultPose
&& WeaponDrawnPose != CPoseManager.UnchangedPose
&& WeaponDrawnPose >= CPoseManager.NumWeaponDrawnPoses)
{
changes = true;
WeaponDrawnPose = CPoseManager.DefaultPose;
}
if (SittingPose != CPoseManager.DefaultPose
&& SittingPose != CPoseManager.UnchangedPose
&& SittingPose >= CPoseManager.NumSitPoses)
{
changes = true;
SittingPose = CPoseManager.DefaultPose;
}
if (GroundSittingPose != CPoseManager.DefaultPose
&& GroundSittingPose != CPoseManager.UnchangedPose
&& GroundSittingPose >= CPoseManager.NumGroundSitPoses)
{
changes = true;
GroundSittingPose = CPoseManager.DefaultPose;
}
if (DozingPose != CPoseManager.DefaultPose
&& DozingPose != CPoseManager.UnchangedPose
&& DozingPose >= CPoseManager.NumDozePoses)
{
changes = true;
DozingPose = CPoseManager.DefaultPose;
}
return changes;
}
}
public class PlayerConfig
{
public const VisorChangeStates Mask = (VisorChangeStates) ((1 << 13) - 1);
public const VisorChangeStates WeaponMask =
VisorChangeStates.Normal
| VisorChangeStates.Mounted
| VisorChangeStates.Flying
| VisorChangeStates.Swimming
| VisorChangeStates.Diving
| VisorChangeStates.Combat
| VisorChangeStates.Duty;
public Dictionary<Job, VisorChangeGroup> PerJob { get; internal set; } = new()
{
{ Job.Default, VisorChangeGroup.Empty },
};
public bool Enabled { get; set; } = true;
public PlayerConfig Clone()
=> (PlayerConfig) MemberwiseClone();
}
[Serializable]
public class AutoVisorConfiguration : IPluginConfiguration
{
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()
{
if (Dalamud.PluginInterface.GetPluginConfig() is AutoVisorConfiguration cfg)
return cfg;
cfg = new AutoVisorConfiguration();
cfg.Save();
return cfg;
}
public void Save()
=> Dalamud.PluginInterface.SavePluginConfig(this);
}
}