Elin Modding Docs Doc
Loading...
Searching...
No Matches
RenderRow.cs
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4using UnityEngine.UI;
5
6// Token: 0x0200004E RID: 78
7public class RenderRow : SourceData.BaseRow, IRenderSource
8{
9 // Token: 0x17000043 RID: 67
10 // (get) Token: 0x060001B2 RID: 434 RVA: 0x0000E913 File Offset: 0x0000CB13
11 public virtual string idString
12 {
13 get
14 {
15 return "";
16 }
17 }
18
19 // Token: 0x17000044 RID: 68
20 // (get) Token: 0x060001B3 RID: 435 RVA: 0x0000E91A File Offset: 0x0000CB1A
21 public virtual string RecipeID
22 {
23 get
24 {
25 return "";
26 }
27 }
28
29 // Token: 0x17000045 RID: 69
30 // (get) Token: 0x060001B4 RID: 436 RVA: 0x0000E921 File Offset: 0x0000CB21
31 public virtual string pathRenderData
32 {
33 get
34 {
35 return "Scene/Render/Data/";
36 }
37 }
38
39 // Token: 0x17000046 RID: 70
40 // (get) Token: 0x060001B5 RID: 437 RVA: 0x0000E928 File Offset: 0x0000CB28
41 public virtual string idRenderData
42 {
43 get
44 {
45 return this._idRenderData;
46 }
47 }
48
49 // Token: 0x17000047 RID: 71
50 // (get) Token: 0x060001B6 RID: 438 RVA: 0x0000E930 File Offset: 0x0000CB30
51 public virtual RenderData defaultRenderData
52 {
53 get
54 {
55 return ResourceCache.Load<RenderData>(this.pathRenderData + "_Default");
56 }
57 }
58
59 // Token: 0x17000048 RID: 72
60 // (get) Token: 0x060001B7 RID: 439 RVA: 0x0000E947 File Offset: 0x0000CB47
61 public virtual string pathSprite
62 {
63 get
64 {
65 return "Scene/Render/Data/";
66 }
67 }
68
69 // Token: 0x17000049 RID: 73
70 // (get) Token: 0x060001B8 RID: 440 RVA: 0x0000E94E File Offset: 0x0000CB4E
71 public virtual string idSprite
72 {
73 get
74 {
75 return "";
76 }
77 }
78
79 // Token: 0x1700004A RID: 74
80 // (get) Token: 0x060001B9 RID: 441 RVA: 0x0000E955 File Offset: 0x0000CB55
81 public virtual string prefabName
82 {
83 get
84 {
85 return "ThingActor";
86 }
87 }
88
89 // Token: 0x060001BA RID: 442 RVA: 0x0000E95C File Offset: 0x0000CB5C
90 public bool HasTag(CTAG _tag)
91 {
92 return this.tag.Contains(_tag.ToString());
93 }
94
95 // Token: 0x060001BB RID: 443 RVA: 0x0000E978 File Offset: 0x0000CB78
96 public virtual string GetSearchName(bool jp)
97 {
98 string result;
99 if (!jp)
100 {
101 if ((result = this._nameSearch) == null)
102 {
103 return this._nameSearch = this.name.ToLower();
104 }
105 }
106 else if ((result = this._nameSearchJP) == null)
107 {
108 result = (this._nameSearchJP = base.GetText("name", false).ToLower());
109 }
110 return result;
111 }
112
113 // Token: 0x1700004B RID: 75
114 // (get) Token: 0x060001BC RID: 444 RVA: 0x0000E9CC File Offset: 0x0000CBCC
115 public SourceCategory.Row Category
116 {
117 get
118 {
119 SourceCategory.Row result;
120 if ((result = this._category) == null)
121 {
122 result = (this._category = this.sources.categories.map[this.category]);
123 }
124 return result;
125 }
126 }
127
128 // Token: 0x1700004C RID: 76
129 // (get) Token: 0x060001BD RID: 445 RVA: 0x0000EA08 File Offset: 0x0000CC08
130 public string RecipeCat
131 {
132 get
133 {
134 string result;
135 if ((result = this._recipeCat) == null)
136 {
137 result = (this._recipeCat = this.Category.recipeCat);
138 }
139 return result;
140 }
141 }
142
143 // Token: 0x060001BE RID: 446 RVA: 0x0000EA33 File Offset: 0x0000CC33
144 public bool ContainsTag(string _tag)
145 {
146 return this.tag.Contains(_tag);
147 }
148
149 // Token: 0x1700004D RID: 77
150 // (get) Token: 0x060001BF RID: 447 RVA: 0x0000EA41 File Offset: 0x0000CC41
151 public SourceManager sources
152 {
153 get
154 {
155 return Core.Instance.sources;
156 }
157 }
158
159 // Token: 0x060001C0 RID: 448 RVA: 0x0000EA4D File Offset: 0x0000CC4D
160 public override void OnImportData(SourceData data)
161 {
162 base.OnImportData(data);
163 this._tiles = new int[0];
164 this.SetTiles();
165 }
166
167 // Token: 0x060001C1 RID: 449 RVA: 0x0000EA68 File Offset: 0x0000CC68
168 public void SetRenderData()
169 {
170 this.replacer = new SpriteReplacer();
171 if (this.idRenderData.IsEmpty())
172 {
173 this.renderData = this.defaultRenderData;
174 }
175 else if (this.idRenderData[0] == '@')
176 {
177 string[] array = this.idRenderData.Replace("@", "").Split('#', StringSplitOptions.None);
178 string text = array[0];
179 if (array.Length > 1)
180 {
181 this.aliasPref = array[1];
182 }
183 this.renderData = RenderRow.DictRenderData.TryGetValue(text, null);
184 if (this.renderData == null)
185 {
186 RenderData renderData = (ResourceCache.Load<RenderData>(this.pathRenderData + text) ?? this.defaultRenderData).Instantiate<RenderData>();
187 if (this is SourceChara.Row)
188 {
189 RenderData renderData2 = renderData;
190 renderData2.offset.x = renderData2.offset.x + renderData.pass.pmesh.size.x * 0.5f;
191 RenderData renderData3 = renderData;
192 renderData3.offset.y = renderData3.offset.y + renderData.pass.pmesh.size.y * 0.5f;
193 }
194 else
195 {
196 float num = renderData.pass.pmesh.size.x * 0.5f + renderData.pass.pmesh.pos.x;
197 float num2 = renderData.pass.pmesh.size.y * 0.5f + renderData.pass.pmesh.pos.y;
198 RenderData renderData4 = renderData;
199 renderData4.offset.x = renderData4.offset.x + num;
200 RenderData renderData5 = renderData;
201 renderData5.offset.y = renderData5.offset.y + num2;
202 RenderData renderData6 = renderData;
203 renderData6.offsetBack.x = renderData6.offsetBack.x + num;
204 RenderData renderData7 = renderData;
205 renderData7.offsetBack.y = renderData7.offsetBack.y + num2;
206 RenderData renderData8 = renderData;
207 renderData8.heldPos.x = renderData8.heldPos.x + num * 0.7f;
208 RenderData renderData9 = renderData;
209 renderData9.heldPos.y = renderData9.heldPos.y + num2 * 0.7f;
210 }
211 renderData.pass = null;
212 this.renderData = renderData;
213 RenderRow.DictRenderData[text] = renderData;
214 }
215 }
216 else
217 {
218 this.renderData = (ResourceCache.Load<RenderData>(this.pathRenderData + this.idRenderData) ?? this.defaultRenderData);
219 }
220 if (!Application.isEditor && this.pref == null)
221 {
222 if (this.aliasPref.IsEmpty())
223 {
224 this.pref = new SourcePref();
225 }
226 else
227 {
228 this.pref = this.sources.cards.map[this.aliasPref].pref;
229 }
230 }
231 if (!this.renderData.initialized)
232 {
233 this.renderData.Init();
234 }
235 this.SetTiles();
236 string a = this.colorType;
237 if (!(a == "alt"))
238 {
239 if (a == "random")
240 {
241 this.useRandomColor = true;
242 }
243 }
244 else
245 {
246 this.useAltColor = true;
247 }
248 if (this.defMat[0] == '!')
249 {
250 this.fixedMaterial = true;
251 this.defMat = this.defMat.Substring(1, this.defMat.Length - 1);
252 }
253 else
254 {
255 this.fixedMaterial = false;
256 }
257 if (!this.sources.materials.alias.ContainsKey(this.defMat))
258 {
259 Debug.Log(this.defMat);
260 }
261 this.DefaultMaterial = this.sources.materials.alias[this.defMat];
262 }
263
264 // Token: 0x060001C2 RID: 450 RVA: 0x0000EDC8 File Offset: 0x0000CFC8
265 public virtual void SetTiles()
266 {
267 if (!this.renderData || !this.renderData.pass)
268 {
269 return;
270 }
271 if (this._tiles.Length != this.tiles.Length)
272 {
273 this._tiles = new int[this.tiles.Length];
274 for (int i = 0; i < this.tiles.Length; i++)
275 {
276 this._tiles[i] = this.tiles[i] / 100 * (int)this.renderData.pass.pmesh.tiling.x + this.tiles[i] % 100;
277 }
278 }
279 }
280
281 // Token: 0x060001C3 RID: 451 RVA: 0x0000EE68 File Offset: 0x0000D068
282 public int ConvertTile(int tile)
283 {
284 return this.renderData.ConvertTile(tile);
285 }
286
287 // Token: 0x060001C4 RID: 452 RVA: 0x0000EE78 File Offset: 0x0000D078
288 public Sprite GetSprite(int dir = 0, int skin = 0, bool snow = false)
289 {
290 if (this.replacer.HasSprite(this.idSprite))
291 {
292 return this.replacer.data.GetSprite(snow);
293 }
294 int[] array = null ?? this._tiles;
295 if (this.sprites == null)
296 {
297 this.sprites = new Sprite[(this.skins == null) ? 1 : (this.skins.Length + 1), (array.Length == 0) ? 1 : array.Length];
298 }
299 if (skin != 0 && skin >= this.sprites.GetLength(0))
300 {
301 skin = 0;
302 }
303 if (dir >= array.Length)
304 {
305 dir = 0;
306 }
307 if (!this.sprites[skin, dir])
308 {
309 MeshPass pass = this.renderData.pass;
310 if (pass)
311 {
312 Texture2D texture2D = pass.mat.GetTexture("_MainTex") as Texture2D;
313 ProceduralMesh pmesh = pass.pmesh;
314 int num;
315 if (skin == 0)
316 {
317 num = Mathf.Abs(array[dir]);
318 }
319 else
320 {
321 num = Mathf.Abs(array[dir] + this.skins[skin - 1] * ((array[dir] > 0) ? 1 : -1));
322 }
323 int num2 = (int)((float)texture2D.width / pmesh.tiling.x);
324 int num3 = (int)((float)texture2D.height / pmesh.tiling.y);
325 int num4 = (int)((float)num % pmesh.tiling.x);
326 int num5 = (int)((float)num / pmesh.tiling.x);
327 this.sprites[skin, dir] = Sprite.Create(texture2D, new Rect((float)(num4 * num2), (float)(texture2D.height - (num5 + 1) * num3), (float)num2, (float)(num3 * (this.renderData.multiSize ? 2 : 1))), Vector2.zero, 100f, 0U, SpriteMeshType.FullRect);
328 }
329 else
330 {
331 this.sprites[skin, dir] = SpriteSheet.Get(this.idSprite);
332 if (!this.sprites[skin, dir])
333 {
334 this.sprites[skin, dir] = (Resources.Load<Sprite>(this.pathSprite + this.idSprite) ?? Resources.Load<Sprite>(this.pathSprite + this.idSprite + "_0"));
335 }
336 }
337 if (!this.sprites[skin, dir])
338 {
339 this.sprites[skin, dir] = Core.Instance.refs.spriteNull;
340 }
341 }
342 return this.sprites[skin, dir];
343 }
344
345 // Token: 0x060001C5 RID: 453 RVA: 0x0000F0D4 File Offset: 0x0000D2D4
346 public void SetSpriteRenderer(SpriteRenderer sr, Sprite sprite = null, int matCol = 0, bool setTransform = true, int dir = 0)
347 {
348 sr.sprite = (sprite ?? this.GetSprite(dir, 0, false));
349 if (this.renderData is RenderDataThing)
350 {
351 sr.sprite = EClass.core.refs.spriteThingActor;
352 }
353 int num = (matCol == 0) ? 104025 : matCol;
354 float num2 = (float)(num / 262144) * 0.01f;
355 float num3 = 0.02f;
356 float num4 = 0.3f;
357 if (num2 != 0f)
358 {
359 num3 *= num2;
360 }
361 Color color = new Color(num3 * (float)(num % 262144 / 4096) + num4, num3 * (float)(num % 4096 / 64) + num4, num3 * (float)(num % 64) + num4, 1f);
362 sr.color = color;
363 if (setTransform)
364 {
365 float num5 = sr.bounds.max.x - sr.bounds.min.x;
366 Vector3 max = sr.bounds.max;
367 Vector3 min = sr.bounds.min;
368 sr.transform.localPosition = new Vector3(-0.5f * num5, 0f, 0f);
369 }
370 }
371
372 // Token: 0x060001C6 RID: 454 RVA: 0x0000F1FA File Offset: 0x0000D3FA
373 public virtual SourcePref GetPref()
374 {
375 return this.pref;
376 }
377
378 // Token: 0x060001C7 RID: 455 RVA: 0x0000F204 File Offset: 0x0000D404
379 public void SetImage(Image image, Sprite sprite = null, int matCol = 0, bool setNativeSize = true, int dir = 0, int idSkin = 0)
380 {
381 image.sprite = (sprite ?? this.GetSprite(dir, idSkin, false));
382 int num = (matCol == 0) ? 104025 : matCol;
383 float num2 = 0.02f;
384 image.color = new Color(num2 * (float)(num % 262144 / 4096), num2 * (float)(num % 4096 / 64), num2 * (float)(num % 64), (float)(num / 262144) * 0.01f)
385 {
386 a = 1f
387 };
388 RectTransform rectTransform = image.Rect();
389 SourcePref sourcePref = this.GetPref();
390 rectTransform.pivot = this.renderData.imagePivot - new Vector2(0.01f * (float)sourcePref.pivotX, 0.01f * (float)sourcePref.pivotY);
391 float x = Mathf.Abs(image.transform.localScale.x) * (float)((sprite || this._tiles.Length == 0 || this._tiles[dir % this._tiles.Length] >= 0) ? 1 : -1);
392 float y = image.transform.localScale.y;
393 image.transform.localScale = new Vector3(x, y, image.transform.localScale.z);
394 sourcePref.Validate();
395 if (setNativeSize)
396 {
397 image.SetNativeSize();
398 if (this.renderData.imageScale.x != 1f || this.renderData.imageScale.y != 1f || sourcePref.scaleIcon != 0)
399 {
400 rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x * (this.renderData.imageScale.x + (float)sourcePref.scaleIcon * 0.01f), rectTransform.sizeDelta.y * (this.renderData.imageScale.y + (float)sourcePref.scaleIcon * 0.01f));
401 }
402 }
403 }
404
405 // Token: 0x060001C8 RID: 456 RVA: 0x0000F3F0 File Offset: 0x0000D5F0
406 public void SetRenderParam(RenderParam p, SourceMaterial.Row mat, int dir)
407 {
408 p.tile = (float)this.GetTile(mat ?? this.DefaultMaterial, dir);
409 p.matColor = (float)this.GetColorInt(mat ?? this.DefaultMaterial);
410 p.mat = (mat ?? this.DefaultMaterial);
411 p.liquidLv = 0;
412 p.dir = dir;
413 p.cell = null;
414 }
415
416 // Token: 0x060001C9 RID: 457 RVA: 0x0000F454 File Offset: 0x0000D654
417 public unsafe virtual RenderParam GetRenderParam(SourceMaterial.Row mat, int dir, Point point = null, int bridgeHeight = -1)
418 {
419 RenderParam shared = RenderParam.shared;
420 shared.tile = (float)this.GetTile(mat, dir);
421 shared.matColor = (float)this.GetColorInt(mat);
422 shared.mat = mat;
423 shared.liquidLv = 0;
424 shared.dir = dir;
425 shared.cell = null;
426 Vector3 vector;
427 if (point == null)
428 {
429 shared.color = 11010048f;
430 vector = Core.Instance.scene.camSupport.renderPos;
431 if (this.renderData.multiSize)
432 {
433 vector.y -= 0.8f;
434 }
435 }
436 else
437 {
438 shared.color = 10485760f;
439 BaseTileMap tileMap = Core.Instance.screen.tileMap;
440 vector = *point.Position(bridgeHeight);
441 }
442 shared.x = vector.x;
443 shared.y = vector.y;
444 shared.z = vector.z;
445 return shared;
446 }
447
448 // Token: 0x060001CA RID: 458 RVA: 0x0000F530 File Offset: 0x0000D730
449 public virtual int GetTile(SourceMaterial.Row mat, int dir = 0)
450 {
451 return this._tiles[dir % this._tiles.Length];
452 }
453
454 // Token: 0x060001CB RID: 459 RVA: 0x0000F544 File Offset: 0x0000D744
455 public int GetColorInt(SourceMaterial.Row mat)
456 {
457 if (this.useAltColor)
458 {
459 if (this.colorMod != 0)
460 {
461 return BaseTileMap.GetColorInt(ref mat.altColor, this.colorMod);
462 }
463 return 104025;
464 }
465 else
466 {
467 if (this.colorMod != 0)
468 {
469 return BaseTileMap.GetColorInt(ref mat.matColor, this.colorMod);
470 }
471 return 104025;
472 }
473 }
474
475 // Token: 0x0400046A RID: 1130
476 public static Dictionary<string, RenderData> DictRenderData = new Dictionary<string, RenderData>();
477
478 // Token: 0x0400046B RID: 1131
479 public int[] tiles;
480
481 // Token: 0x0400046C RID: 1132
482 public int[] _tiles;
483
484 // Token: 0x0400046D RID: 1133
485 public int[] skins;
486
487 // Token: 0x0400046E RID: 1134
488 public int colorMod;
489
490 // Token: 0x0400046F RID: 1135
491 public int sort;
492
493 // Token: 0x04000470 RID: 1136
494 public int value;
495
496 // Token: 0x04000471 RID: 1137
497 public int LV;
498
499 // Token: 0x04000472 RID: 1138
500 public int chance;
501
502 // Token: 0x04000473 RID: 1139
503 public int tempChance;
504
505 // Token: 0x04000474 RID: 1140
506 public int snowTile;
507
508 // Token: 0x04000475 RID: 1141
509 public string name;
510
511 // Token: 0x04000476 RID: 1142
512 public string name_JP;
513
514 // Token: 0x04000477 RID: 1143
515 public string detail;
516
517 // Token: 0x04000478 RID: 1144
518 public string detail_JP;
519
520 // Token: 0x04000479 RID: 1145
521 public string _idRenderData;
522
523 // Token: 0x0400047A RID: 1146
524 public string _tileType;
525
526 // Token: 0x0400047B RID: 1147
527 public string defMat;
528
529 // Token: 0x0400047C RID: 1148
530 public string colorType;
531
532 // Token: 0x0400047D RID: 1149
533 public string category;
534
535 // Token: 0x0400047E RID: 1150
536 public string idSound;
537
538 // Token: 0x0400047F RID: 1151
539 public string aliasPref;
540
541 // Token: 0x04000480 RID: 1152
542 public string[] components;
543
544 // Token: 0x04000481 RID: 1153
545 public string[] factory;
546
547 // Token: 0x04000482 RID: 1154
548 public string[] recipeKey;
549
550 // Token: 0x04000483 RID: 1155
551 public string[] tag;
552
553 // Token: 0x04000484 RID: 1156
554 public int W = 1;
555
556 // Token: 0x04000485 RID: 1157
557 public int H = 1;
558
559 // Token: 0x04000486 RID: 1158
560 public bool multisize;
561
562 // Token: 0x04000487 RID: 1159
563 public SourcePref pref;
564
565 // Token: 0x04000488 RID: 1160
566 [NonSerialized]
567 public RenderData renderData;
568
569 // Token: 0x04000489 RID: 1161
570 [NonSerialized]
571 public Sprite[,] sprites;
572
573 // Token: 0x0400048A RID: 1162
574 [NonSerialized]
575 public TileType tileType;
576
577 // Token: 0x0400048B RID: 1163
578 [NonSerialized]
579 public bool useAltColor;
580
581 // Token: 0x0400048C RID: 1164
582 [NonSerialized]
583 public bool useRandomColor;
584
585 // Token: 0x0400048D RID: 1165
586 [NonSerialized]
587 public bool fixedMaterial;
588
589 // Token: 0x0400048E RID: 1166
590 [NonSerialized]
591 public SourceMaterial.Row DefaultMaterial;
592
593 // Token: 0x0400048F RID: 1167
594 [NonSerialized]
595 public SpriteReplacer replacer;
596
597 // Token: 0x04000490 RID: 1168
598 [NonSerialized]
599 public string _nameSearch;
600
601 // Token: 0x04000491 RID: 1169
602 [NonSerialized]
603 public string _nameSearchJP;
604
605 // Token: 0x04000492 RID: 1170
606 [NonSerialized]
607 private SourceCategory.Row _category;
608
609 // Token: 0x04000493 RID: 1171
610 [NonSerialized]
611 private string _recipeCat;
612}
Definition Point.cs:11