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