Elin Decompiled Documentation EA 23.264 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 float heightFix
303 {
304 get
305 {
306 return (float)ints[24] * 0.01f;
307 }
308 set
309 {
310 ints[24] = (int)(value * 100f);
311 }
312 }
313
314 public bool bypassShadow
315 {
316 get
317 {
318 return _bits1[0];
319 }
320 set
321 {
322 _bits1[0] = value;
323 }
324 }
325
326 public bool UsePref => (ints[1] & 1) != 0;
327
328 public bool Float => (ints[1] & 4) != 0;
329
330 public bool Surface => (ints[1] & 8) != 0;
331
332 public bool FloatUnderwater => (ints[1] & 0x10) != 0;
333
334 public void OnAfterDeserialize()
335 {
336 if (ints.Length >= 25)
337 {
338 _bits1.SetInt(ints[22]);
339 }
340 else
341 {
342 Validate();
343 }
344 }
345
346 public void OnBeforeSerialize()
347 {
348 ints[22] = _bits1.ToInt();
349 }
350
351 public void Validate()
352 {
353 if (ints.Length < 25)
354 {
355 Array.Resize(ref ints, 25);
356 }
357 }
358
359 public void WriteIni(string path)
360 {
361 FileIniDataParser fileIniDataParser = new FileIniDataParser();
362 if (File.Exists(path))
363 {
364 EClass.ui.Say("Ini file already exists.");
365 return;
366 }
367 File.CreateText(path).Close();
368 IniData iniData = fileIniDataParser.ReadFile(path, Encoding.UTF8);
369 iniData.Global["x"] = ints[4].ToString() ?? "";
370 iniData.Global["y"] = ints[5].ToString() ?? "";
371 iniData.Global["z"] = ints[2].ToString() ?? "";
372 iniData.Global["pivotX"] = pivotX.ToString() ?? "";
373 iniData.Global["pivotY"] = pivotY.ToString() ?? "";
374 iniData.Global["shadow"] = shadow.ToString() ?? "";
375 iniData.Global["shadowX"] = shadowX.ToString() ?? "";
376 iniData.Global["shadowY"] = shadowY.ToString() ?? "";
377 iniData.Global["height"] = ints[3].ToString() ?? "";
378 iniData.Global["scaleIcon"] = scaleIcon.ToString() ?? "";
379 iniData.Global["liquidMod"] = liquidMod.ToString() ?? "";
380 iniData.Global["hatY"] = ints[23].ToString() ?? "";
381 iniData.Global["flags"] = ints[1].ToString() ?? "";
382 fileIniDataParser.WriteFile(path, iniData);
383 }
384
385 public static SourcePref ReadFromIni(string path)
386 {
387 SourcePref sourcePref = new SourcePref();
388 IniData iniData = new FileIniDataParser().ReadFile(path, Encoding.UTF8);
389 sourcePref.ints[4] = iniData.Global["x"].ToInt();
390 sourcePref.ints[5] = iniData.Global["y"].ToInt();
391 sourcePref.ints[2] = iniData.Global["z"].ToInt();
392 sourcePref.pivotX = iniData.Global["pivotX"].ToInt();
393 sourcePref.pivotY = iniData.Global["pivotY"].ToInt();
394 sourcePref.shadow = iniData.Global["shadow"].ToInt();
395 sourcePref.shadowX = iniData.Global["shadowX"].ToInt();
396 sourcePref.shadowRX = -sourcePref.shadowX;
397 int num2 = (sourcePref.shadowRY = iniData.Global["shadowY"].ToInt());
398 sourcePref.shadowY = num2;
399 sourcePref.ints[3] = iniData.Global["height"].ToInt();
400 sourcePref.scaleIcon = iniData.Global["scaleIcon"].ToInt();
401 sourcePref.liquidMod = iniData.Global["liquidMod"].ToInt();
402 sourcePref.ints[23] = iniData.Global["hatY"].ToInt();
403 sourcePref.ints[1] = iniData.Global["flags"].ToInt();
404 return sourcePref;
405 }
406}
PrefFlag
Definition: PrefFlag.cs:5
Definition: EClass.cs:6
static UI ui
Definition: EClass.cs:17
void OnAfterDeserialize()
Definition: SourcePref.cs:334
bool bypassShadow
Definition: SourcePref.cs:315
int liquidModMax
Definition: SourcePref.cs:75
bool FloatUnderwater
Definition: SourcePref.cs:332
bool Surface
Definition: SourcePref.cs:330
int shadowBRY
Definition: SourcePref.cs:255
float height
Definition: SourcePref.cs:51
void WriteIni(string path)
Definition: SourcePref.cs:359
bool UsePref
Definition: SourcePref.cs:326
int liquidMod
Definition: SourcePref.cs:63
int shadowBRX
Definition: SourcePref.cs:243
bool Float
Definition: SourcePref.cs:328
int shadowRX
Definition: SourcePref.cs:195
int shadowRY
Definition: SourcePref.cs:207
static SourcePref ReadFromIni(string path)
Definition: SourcePref.cs:385
PrefFlag flags
Definition: SourcePref.cs:27
float heightFix
Definition: SourcePref.cs:303
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:346
float hatY
Definition: SourcePref.cs:87
void Validate()
Definition: SourcePref.cs:351
void SetInt(int i)
Definition: BitArray32.cs:89
int ToInt()
Definition: BitArray32.cs:84