-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathHooks.cs
162 lines (136 loc) · 4.52 KB
/
Hooks.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
using AIChara;
using HarmonyLib;
using UnityEngine;
namespace HS2_BoobSettings
{
public partial class HS2_BoobSettings
{
[HarmonyPrefix]
[HarmonyPatch(typeof(BustSoft), "ReCalc")]
public static bool PatchPrefix_BustSoft_ReCalc(ChaControl ___chaCtrl, ChaInfo ___info, int[] changePtn)
{
if (___chaCtrl == null ||
___info == null ||
changePtn.Length == 0)
return false;
BoobController controller = ___chaCtrl.GetComponent<BoobController>();
if (controller == null)
return true;
bool flag = true;
if (controller.boolData[BoobController.OVERRIDE_PHYSICS])
{
flag = false;
float damping = controller.floatData[BoobController.DAMPING];
float elasticity = controller.floatData[BoobController.ELASTICITY];
float stiffness = controller.floatData[BoobController.STIFFNESS];
Util.UpdateBustSoftness(
___chaCtrl.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.BreastL),
changePtn,
damping,
elasticity,
stiffness
);
Util.UpdateBustSoftness(
___chaCtrl.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.BreastR),
changePtn,
damping,
elasticity,
stiffness
);
// Inert rarely gets updated. This makes sure it does.
___chaCtrl.ChangeBustInert(false);
}
if (controller.boolData[BoobController.BUTT + BoobController.OVERRIDE_PHYSICS])
{
float damping = controller.floatData[BoobController.BUTT + BoobController.DAMPING];
float elasticity = controller.floatData[BoobController.BUTT + BoobController.ELASTICITY];
float stiffness = controller.floatData[BoobController.BUTT + BoobController.STIFFNESS];
float inert = controller.floatData[BoobController.BUTT + BoobController.INERT];
Util.UpdateButtPhysics(
___chaCtrl.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.HipL),
damping,
elasticity,
stiffness,
inert
);
Util.UpdateButtPhysics(
___chaCtrl.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.HipR),
damping,
elasticity,
stiffness,
inert
);
}
return flag;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ChaControl), "ChangeBustInert")]
public static bool PatchPrefix_ChaControl_ChangeBustInert(ChaControl __instance, bool h)
{
BoobController controller = __instance.GetComponent<BoobController>();
if (controller == null ||
!controller.boolData[BoobController.OVERRIDE_PHYSICS])
return true;
float inert = controller.floatData[BoobController.INERT];
Util.UpdateBustInert(
__instance.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.BreastL),
inert
);
Util.UpdateBustInert(
__instance.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.BreastR),
inert
);
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(BustGravity), "ReCalc")]
public static bool PatchPrefix_BustGravity_ReCalc(ChaControl ___chaCtrl, ChaInfo ___info, int[] changePtn)
{
if (___chaCtrl == null ||
___info == null ||
changePtn.Length == 0)
return false;
BoobController controller = ___chaCtrl.GetComponent<BoobController>();
if (controller == null)
return true;
bool flag = true;
if (controller.boolData[BoobController.OVERRIDE_GRAVITY])
{
flag = false;
Vector3 gravity = new Vector3(
controller.floatData[BoobController.GRAVITY_X],
controller.floatData[BoobController.GRAVITY_Y],
controller.floatData[BoobController.GRAVITY_Z]
);
Util.UpdateBustGravity(
___chaCtrl.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.BreastL),
changePtn,
gravity
);
Util.UpdateBustGravity(
___chaCtrl.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.BreastR),
changePtn,
gravity
);
}
// Butt
if (controller.boolData[BoobController.BUTT + BoobController.OVERRIDE_GRAVITY])
{
Vector3 gravity = new Vector3(
controller.floatData[BoobController.BUTT + BoobController.GRAVITY_X],
controller.floatData[BoobController.BUTT + BoobController.GRAVITY_Y],
controller.floatData[BoobController.BUTT + BoobController.GRAVITY_Z]
);
Util.UpdateButtGravity(
___chaCtrl.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.HipL),
gravity
);
Util.UpdateButtGravity(
___chaCtrl.GetDynamicBoneBustAndHip(ChaControlDefine.DynamicBoneKind.HipR),
gravity
);
}
return flag;
}
}
}