Elin Decompiled Documentation EA 23.190 Nightly
Loading...
Searching...
No Matches
SourcePref.cs
Go to the documentation of this file.
1using System;
2using System.IO;
3using System.Text;
4using IniParser;
5using IniParser.Model;
6using Newtonsoft.Json;
7using UnityEngine;
8
9[Serializable]
10public class SourcePref : EClass, ISerializationCallbackReceiver
11{
12 [JsonProperty]
13 public int[] ints = new int[25];
14
16
17 public int test
18 {
19 get
20 {
21 Validate();
22 return ints[0];
23 }
24 }
25
27 {
28 get
29 {
30 return ints[1].ToEnum<PrefFlag>();
31 }
32 set
33 {
34 ints[1] = (int)value;
35 }
36 }
37
38 public int shadow
39 {
40 get
41 {
42 return ints[0];
43 }
44 set
45 {
46 ints[0] = value;
47 }
48 }
49
50 public float height
51 {
52 get
53 {
54 return (float)ints[3] * 0.01f;
55 }
56 set
57 {
58 ints[3] = (int)(value * 100f);
59 }
60 }
61
62 public int liquidMod
63 {
64 get
65 {
66 return ints[16];
67 }
68 set
69 {
70 ints[16] = value;
71 }
72 }
73
74 public int liquidModMax
75 {
76 get
77 {
78 return ints[21];
79 }
80 set
81 {
82 ints[21] = value;
83 }
84 }
85
86 public float hatY
87 {
88 get
89 {
90 return (float)ints[23] * 0.01f;
91 }
92 set
93 {
94 ints[23] = (int)(value * 100f);
95 }
96 }
97
98 public float stackX
99 {
100 get
101 {
102 return (float)ints[17] * 0.01f;
103 }
104 set
105 {
106 ints[17] = (int)(value * 100f);
107 }
108 }
109
110 public float x
111 {
112 get
113 {
114 return (float)ints[4] * 0.01f;
115 }
116 set
117 {
118 ints[4] = (int)(value * 100f);
119 }
120 }
121
122 public float y
123 {
124 get
125 {
126 return (float)ints[5] * 0.01f;
127 }
128 set
129 {
130 ints[5] = (int)(value * 100f);
131 }
132 }
133
134 public float z
135 {
136 get
137 {
138 return (float)ints[2] * 0.01f;
139 }
140 set
141 {
142 ints[2] = (int)(value * 100f);
143 }
144 }
145
146 public int pivotX
147 {
148 get
149 {
150 return ints[6];
151 }
152 set
153 {
154 ints[6] = value;
155 }
156 }
157
158 public int pivotY
159 {
160 get
161 {
162 return ints[7];
163 }
164 set
165 {
166 ints[7] = value;
167 }
168 }
169
170 public int shadowX
171 {
172 get
173 {
174 return ints[8];
175 }
176 set
177 {
178 ints[8] = value;
179 }
180 }
181
182 public int shadowY
183 {
184 get
185 {
186 return ints[9];
187 }
188 set
189 {
190 ints[9] = value;
191 }
192 }
193
194 public int shadowRX
195 {
196 get
197 {
198 return ints[10];
199 }
200 set
201 {
202 ints[10] = value;
203 }
204 }
205
206 public int shadowRY
207 {
208 get
209 {
210 return ints[11];
211 }
212 set
213 {
214 ints[11] = value;
215 }
216 }
217
218 public int shadowBX
219 {
220 get
221 {
222 return ints[12];
223 }
224 set
225 {
226 ints[12] = value;
227 }
228 }
229
230 public int shadowBY
231 {
232 get
233 {
234 return ints[13];
235 }
236 set
237 {
238 ints[13] = value;
239 }
240 }
241
242 public int shadowBRX
243 {
244 get
245 {
246 return ints[14];
247 }
248 set
249 {
250 ints[14] = value;
251 }
252 }
253
254 public int shadowBRY
255 {
256 get
257 {
258 return ints[15];
259 }
260 set
261 {
262 ints[15] = value;
263 }
264 }
265
266 public int equipX
267 {
268 get
269 {
270 return ints[18];
271 }
272 set
273 {
274 ints[18] = value;
275 }
276 }
277
278 public int equipY
279 {
280 get
281 {
282 return ints[19];
283 }
284 set
285 {
286 ints[19] = value;
287 }
288 }
289
290 public int scaleIcon
291 {
292 get
293 {
294 return ints[20];
295 }
296 set
297 {
298 ints[20] = value;
299 }
300 }
301
302 public bool bypassShadow
303 {
304 get
305 {
306 return _bits1[0];
307 }
308 set
309 {
310 _bits1[0] = value;
311 }
312 }
313
314 public bool UsePref => (ints[1] & 1) != 0;
315
316 public bool Float => (ints[1] & 4) != 0;
317
318 public bool Surface => (ints[1] & 8) != 0;
319
320 public bool FloatUnderwater => (ints[1] & 0x10) != 0;
321
322 public void OnAfterDeserialize()
323 {
324 if (ints.Length >= 25)
325 {
326 _bits1.SetInt(ints[22]);
327 }
328 else
329 {
330 Validate();
331 }
332 }
333
334 public void OnBeforeSerialize()
335 {
336 ints[22] = _bits1.ToInt();
337 }
338
339 public void Validate()
340 {
341 if (ints.Length < 25)
342 {
343 Array.Resize(ref ints, 25);
344 }
345 }
346
347 public void WriteIni(string path)
348 {
349 FileIniDataParser fileIniDataParser = new FileIniDataParser();
350 if (File.Exists(path))
351 {
352 EClass.ui.Say("Ini file already exists.");
353 return;
354 }
355 File.CreateText(path).Close();
356 IniData iniData = fileIniDataParser.ReadFile(path, Encoding.UTF8);
357 iniData.Global["x"] = ints[4].ToString() ?? "";
358 iniData.Global["y"] = ints[5].ToString() ?? "";
359 iniData.Global["z"] = ints[2].ToString() ?? "";
360 iniData.Global["pivotX"] = pivotX.ToString() ?? "";
361 iniData.Global["pivotY"] = pivotY.ToString() ?? "";
362 iniData.Global["shadow"] = shadow.ToString() ?? "";
363 iniData.Global["shadowX"] = shadowX.ToString() ?? "";
364 iniData.Global["shadowY"] = shadowY.ToString() ?? "";
365 iniData.Global["height"] = ints[3].ToString() ?? "";
366 iniData.Global["scaleIcon"] = scaleIcon.ToString() ?? "";
367 iniData.Global["liquidMod"] = liquidMod.ToString() ?? "";
368 iniData.Global["hatY"] = ints[23].ToString() ?? "";
369 iniData.Global["flags"] = ints[1].ToString() ?? "";
370 fileIniDataParser.WriteFile(path, iniData);
371 }
372
373 public static SourcePref ReadFromIni(string path)
374 {
375 SourcePref sourcePref = new SourcePref();
376 IniData iniData = new FileIniDataParser().ReadFile(path, Encoding.UTF8);
377 sourcePref.ints[4] = iniData.Global["x"].ToInt();
378 sourcePref.ints[5] = iniData.Global["y"].ToInt();
379 sourcePref.ints[2] = iniData.Global["z"].ToInt();
380 sourcePref.pivotX = iniData.Global["pivotX"].ToInt();
381 sourcePref.pivotY = iniData.Global["pivotY"].ToInt();
382 sourcePref.shadow = iniData.Global["shadow"].ToInt();
383 sourcePref.shadowX = iniData.Global["shadowX"].ToInt();
384 sourcePref.shadowRX = -sourcePref.shadowX;
385 int num2 = (sourcePref.shadowRY = iniData.Global["shadowY"].ToInt());
386 sourcePref.shadowY = num2;
387 sourcePref.ints[3] = iniData.Global["height"].ToInt();
388 sourcePref.scaleIcon = iniData.Global["scaleIcon"].ToInt();
389 sourcePref.liquidMod = iniData.Global["liquidMod"].ToInt();
390 sourcePref.ints[23] = iniData.Global["hatY"].ToInt();
391 sourcePref.ints[1] = iniData.Global["flags"].ToInt();
392 return sourcePref;
393 }
394}
PrefFlag
Definition: PrefFlag.cs:5
Definition: EClass.cs:5
static UI ui
Definition: EClass.cs:16
void OnAfterDeserialize()
Definition: SourcePref.cs:322
bool bypassShadow
Definition: SourcePref.cs:303
int liquidModMax
Definition: SourcePref.cs:75
bool FloatUnderwater
Definition: SourcePref.cs:320
bool Surface
Definition: SourcePref.cs:318
int shadowBRY
Definition: SourcePref.cs:255
float height
Definition: SourcePref.cs:51
void WriteIni(string path)
Definition: SourcePref.cs:347
bool UsePref
Definition: SourcePref.cs:314
int liquidMod
Definition: SourcePref.cs:63
int shadowBRX
Definition: SourcePref.cs:243
bool Float
Definition: SourcePref.cs:316
int shadowRX
Definition: SourcePref.cs:195
int shadowRY
Definition: SourcePref.cs:207
static SourcePref ReadFromIni(string path)
Definition: SourcePref.cs:373
PrefFlag flags
Definition: SourcePref.cs:27
int shadowBY
Definition: SourcePref.cs:231
int[] ints
Definition: SourcePref.cs:13
int shadowBX
Definition: SourcePref.cs:219
int scaleIcon
Definition: SourcePref.cs:291
int shadow
Definition: SourcePref.cs:39
float stackX
Definition: SourcePref.cs:99
BitArray32 _bits1
Definition: SourcePref.cs:15
void OnBeforeSerialize()
Definition: SourcePref.cs:334
float hatY
Definition: SourcePref.cs:87
void Validate()
Definition: SourcePref.cs:339
void SetInt(int i)
Definition: BitArray32.cs:89
int ToInt()
Definition: BitArray32.cs:84