-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathShellProtectorEditorViewModel.cs
More file actions
48 lines (43 loc) · 1.72 KB
/
Copy pathShellProtectorEditorViewModel.cs
File metadata and controls
48 lines (43 loc) · 1.72 KB
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
#if UNITY_EDITOR
using UnityEditor;
using UnityEditorInternal;
using VRC.SDK3.Avatars.ScriptableObjects;
namespace Shell.Protector
{
internal sealed class ShellProtectorEditorViewModel
{
readonly ShellProtector protector;
readonly SerializedProperty keySize;
readonly SerializedProperty syncSize;
readonly ReorderableList gameobjectList;
readonly ReorderableList materialList;
public ShellProtectorEditorViewModel(
ShellProtector protector,
SerializedProperty keySize,
SerializedProperty syncSize,
ReorderableList gameobjectList,
ReorderableList materialList)
{
this.protector = protector;
this.keySize = keySize;
this.syncSize = syncSize;
this.gameobjectList = gameobjectList;
this.materialList = materialList;
}
public bool HasParameterAsset { get; private set; }
public int FreeParameter { get; private set; }
public int UsedParameter { get; private set; }
public bool HasEnoughParameterSpace => HasParameterAsset && FreeParameter >= UsedParameter;
public bool HasTargets => gameobjectList.count > 0 || materialList.count > 0;
public void Refresh()
{
VRCExpressionParameters parameters = protector.GetParameter();
HasParameterAsset = parameters != null;
FreeParameter = HasParameterAsset ? 256 - parameters.CalcTotalCost() : -1;
int lockSize = 1;
int switchCount = ShellProtector.GetRequiredSwitchCount(keySize.intValue, syncSize.intValue);
UsedParameter = switchCount + lockSize + syncSize.intValue * 8;
}
}
}
#endif