-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUndressItemManager.cs
212 lines (181 loc) · 4.19 KB
/
UndressItemManager.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using COM3D2.UndressUtil.Plugin.UndressItem;
namespace COM3D2.UndressUtil.Plugin
{
class UndressItemManager: MonoBehaviour
{
private PartsData data;
private UIButton button;
private UITexture icon;
private Dictionary<Maid, IUndressItem>
maidUndressItemLookup = new Dictionary<Maid, IUndressItem>();
private Dictionary<Maid, IUndressItem>
maidHalfUndressItemLookup = new Dictionary<Maid, IUndressItem>();
private Color defaultColor = Color.white;
Maid selectedMaid;
UndressWindowManager.UndressMode currentMode;
void Awake()
{
button = base.GetComponent<UIButton>();
icon = base.GetComponent<UITexture>();
}
void Start()
{
EventDelegate.Add(this.button.onClick, new EventDelegate.Callback(this.Toggle));
}
public bool IsEnable
{
get
{
return this.button.isEnabled;
}
}
public void Init(MPN mpn, PartsData data)
{
this.data = data;
this.icon.mainTexture = this.data.DefaultIcon;
}
public void SetMaid(Maid maid, UndressWindowManager.UndressMode mode)
{
selectedMaid = maid;
currentMode = mode;
if (maid != null)
{
if (mode == UndressWindowManager.UndressMode.NORMAL)
{
AddMaidUndressData(maid);
}
else
{
AddMaidHalfUndressData(maid);
}
}
this.UpdateState();
}
public void Reset()
{
maidUndressItemLookup.Clear();
maidHalfUndressItemLookup.Clear();
selectedMaid = null;
currentMode = UndressWindowManager.UndressMode.NORMAL;
}
public IUndressItem GetUndressItem()
{
if (selectedMaid == null) return null;
var lookup = maidUndressItemLookup;
if (currentMode == UndressWindowManager.UndressMode.HALFUNDRESS)
{
lookup = maidHalfUndressItemLookup;
}
return lookup[selectedMaid];
}
public void Dress()
{
var item = GetUndressItem();
if (item != null)
{
item.Dress();
UpdateState();
}
}
public void Undress()
{
var item = GetUndressItem();
if (item != null)
{
item.Undress();
UpdateState();
}
}
public void Toggle()
{
var item = GetUndressItem();
if (item != null)
{
item.Toggle();
UpdateState();
}
}
public void ReapplyAllMaids(UndressWindowManager.UndressMode mode)
{
var lookup = maidUndressItemLookup;
if (mode == UndressWindowManager.UndressMode.HALFUNDRESS)
{
lookup = maidHalfUndressItemLookup;
}
foreach(var item in lookup.Values)
{
item.Apply();
}
}
public void UpdateMaid(Maid maid, UndressWindowManager.UndressMode mode)
{
if (mode == UndressWindowManager.UndressMode.NORMAL)
{
AddMaidUndressData(maid);
}
else
{
AddMaidHalfUndressData(maid);
}
}
void AddMaidUndressData(Maid maid)
{
if (!maidUndressItemLookup.ContainsKey(maid))
{
this.maidUndressItemLookup[maid] = UndressItem.UndressItem.ForMaid(maid, this.data);
}
else
{
this.maidUndressItemLookup[maid].Update();
}
}
void AddMaidHalfUndressData(Maid maid)
{
if (!maidHalfUndressItemLookup.ContainsKey(maid))
{
if (!maid.IsCrcBody)
{
this.maidHalfUndressItemLookup[maid] = UndressItem.HalfUndressItem.ForMaid(maid, this.data);
}
else
{
this.maidHalfUndressItemLookup[maid] = CostumeItem.ForMaid(maid, this.data);
}
}
else
{
this.maidHalfUndressItemLookup[maid].Update();
}
}
private void SetDisabled()
{
this.icon.mainTexture = this.data.DefaultIcon;
this.button.isEnabled = false;
this.button.defaultColor = this.defaultColor;
this.gameObject.SetActive(false);
}
void UpdateState()
{
var item = GetUndressItem();
if (item != null && item.Available)
{
this.icon.mainTexture = item.Icon ?? this.data.DefaultIcon;
this.button.defaultColor = item.Color;
this.button.isEnabled = true;
this.button.UpdateColor(false);
this.gameObject.SetActive(true);
}
else
{
SetDisabled();
}
}
public bool Available => GetUndressItem()?.Available ?? false;
}
}