Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
RenderRow.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4using UnityEngine.UI;
5
6public class RenderRow : SourceData.BaseRow, IRenderSource
7{
8 public static Dictionary<string, RenderData> DictRenderData = new Dictionary<string, RenderData>();
9
10 public int[] tiles;
11
12 public int[] _tiles;
13
14 public int[] skins;
15
16 public int colorMod;
17
18 public int sort;
19
20 public int value;
21
22 public int LV;
23
24 public int chance;
25
26 public int tempChance;
27
28 public int snowTile;
29
30 public string name;
31
32 public string name_JP;
33
34 public string detail;
35
36 public string detail_JP;
37
38 public string _idRenderData;
39
40 public string _tileType;
41
42 public string defMat;
43
44 public string colorType;
45
46 public string category;
47
48 public string idSound;
49
50 public string aliasPref;
51
52 public string[] components;
53
54 public string[] factory;
55
56 public string[] recipeKey;
57
58 public string[] tag;
59
60 public int W = 1;
61
62 public int H = 1;
63
64 public bool multisize;
65
66 public bool fixedMaterial;
67
69
70 [NonSerialized]
72
73 [NonSerialized]
74 public Sprite[,] sprites;
75
76 [NonSerialized]
78
79 [NonSerialized]
80 public bool useAltColor;
81
82 [NonSerialized]
83 public bool useRandomColor;
84
85 [NonSerialized]
87
88 [NonSerialized]
90
91 [NonSerialized]
92 public string _nameSearch;
93
94 [NonSerialized]
95 public string _nameSearchJP;
96
97 [NonSerialized]
99
100 [NonSerialized]
101 private string _recipeCat;
102
103 public virtual string idString => "";
104
105 public virtual string RecipeID => "";
106
107 public virtual string pathRenderData => "Scene/Render/Data/";
108
109 public virtual string idRenderData => _idRenderData;
110
112
113 public virtual string pathSprite => "Scene/Render/Data/";
114
115 public virtual string idSprite => "";
116
117 public virtual string prefabName => "ThingActor";
118
120
121 public string RecipeCat => _recipeCat ?? (_recipeCat = Category.recipeCat);
122
124
125 public bool HasTag(CTAG _tag)
126 {
127 return tag.Contains(_tag.ToString());
128 }
129
130 public virtual string GetSearchName(bool jp)
131 {
132 object obj;
133 if (!jp)
134 {
135 obj = _nameSearch;
136 if (obj == null)
137 {
138 return _nameSearch = name.ToLower();
139 }
140 }
141 else
142 {
143 obj = _nameSearchJP ?? (_nameSearchJP = GetText().ToLower());
144 }
145 return (string)obj;
146 }
147
148 public bool ContainsTag(string _tag)
149 {
150 return tag.Contains(_tag);
151 }
152
153 public override void OnImportData(SourceData data)
154 {
155 base.OnImportData(data);
156 _tiles = new int[0];
157 SetTiles();
158 if (defMat.Length > 0 && defMat[0] == '!')
159 {
160 fixedMaterial = true;
161 defMat = defMat.Substring(1, defMat.Length - 1);
162 }
163 else
164 {
165 fixedMaterial = false;
166 }
167 }
168
169 public void SetRenderData()
170 {
171 replacer = new SpriteReplacer();
172 if (idRenderData.IsEmpty())
173 {
174 this.renderData = defaultRenderData;
175 }
176 else if (idRenderData[0] == '@')
177 {
178 string[] array = idRenderData.Replace("@", "").Split('#');
179 string text = array[0];
180 if (array.Length > 1)
181 {
182 aliasPref = array[1];
183 }
184 this.renderData = DictRenderData.TryGetValue(text);
185 if (this.renderData == null)
186 {
188 if (this is SourceChara.Row)
189 {
190 renderData.offset.x += renderData.pass.pmesh.size.x * 0.5f;
191 renderData.offset.y += renderData.pass.pmesh.size.y * 0.5f;
192 }
193 else
194 {
195 float num = renderData.pass.pmesh.size.x * 0.5f + renderData.pass.pmesh.pos.x;
196 float num2 = renderData.pass.pmesh.size.y * 0.5f + renderData.pass.pmesh.pos.y;
197 renderData.offset.x += num;
198 renderData.offset.y += num2;
199 renderData.offsetBack.x += num;
200 renderData.offsetBack.y += num2;
201 renderData.heldPos.x += num * 0.7f;
202 renderData.heldPos.y += num2 * 0.7f;
203 }
204 renderData.pass = null;
205 this.renderData = renderData;
207 }
208 }
209 else
210 {
212 }
213 if (!Application.isEditor && pref == null)
214 {
215 if (aliasPref.IsEmpty())
216 {
217 pref = new SourcePref();
218 }
219 else
220 {
222 }
223 }
224 if (!this.renderData.initialized)
225 {
226 this.renderData.Init();
227 }
228 SetTiles();
229 string text2 = colorType;
230 if (!(text2 == "alt"))
231 {
232 if (text2 == "random")
233 {
234 useRandomColor = true;
235 }
236 }
237 else
238 {
239 useAltColor = true;
240 }
242 }
243
244 public virtual void SetTiles()
245 {
246 if ((bool)renderData && (bool)renderData.pass && _tiles.Length != tiles.Length)
247 {
248 _tiles = new int[tiles.Length];
249 for (int i = 0; i < tiles.Length; i++)
250 {
251 _tiles[i] = tiles[i] / 100 * (int)renderData.pass.pmesh.tiling.x + tiles[i] % 100;
252 }
253 }
254 }
255
256 public int ConvertTile(int tile)
257 {
258 return renderData.ConvertTile(tile);
259 }
260
261 public Sprite GetSprite(int dir = 0, int skin = 0, bool snow = false)
262 {
264 {
265 return replacer.data.GetSprite(snow);
266 }
267 int[] array = null ?? _tiles;
268 if (sprites == null)
269 {
270 sprites = new Sprite[(skins == null) ? 1 : (skins.Length + 1), (array.Length == 0) ? 1 : array.Length];
271 }
272 if (skin != 0 && skin >= sprites.GetLength(0))
273 {
274 skin = 0;
275 }
276 if (dir < 0)
277 {
278 dir *= -1;
279 }
280 if (dir >= array.Length)
281 {
282 dir = 0;
283 }
284 if (!sprites[skin, dir])
285 {
286 MeshPass pass = renderData.pass;
287 if ((bool)pass)
288 {
289 Texture2D texture2D = pass.mat.GetTexture("_MainTex") as Texture2D;
290 ProceduralMesh pmesh = pass.pmesh;
291 int num = 0;
292 num = ((skin != 0) ? Mathf.Abs(array[dir] + skins[skin - 1] * ((array[dir] > 0) ? 1 : (-1))) : Mathf.Abs(array[dir]));
293 int num2 = (int)((float)texture2D.width / pmesh.tiling.x);
294 int num3 = (int)((float)texture2D.height / pmesh.tiling.y);
295 int num4 = (int)((float)num % pmesh.tiling.x);
296 int num5 = (int)((float)num / pmesh.tiling.x);
297 sprites[skin, dir] = Sprite.Create(texture2D, new Rect(num4 * num2, texture2D.height - (num5 + 1) * num3, num2, num3 * ((!renderData.multiSize) ? 1 : 2)), Vector2.zero, 100f, 0u, SpriteMeshType.FullRect);
298 }
299 else
300 {
301 sprites[skin, dir] = SpriteSheet.Get(idSprite);
302 if (!sprites[skin, dir])
303 {
304 sprites[skin, dir] = Resources.Load<Sprite>(pathSprite + idSprite) ?? Resources.Load<Sprite>(pathSprite + idSprite + "_0");
305 }
306 }
307 if (!sprites[skin, dir])
308 {
309 sprites[skin, dir] = Core.Instance.refs.spriteNull;
310 }
311 }
312 return sprites[skin, dir];
313 }
314
315 public void SetSpriteRenderer(SpriteRenderer sr, Sprite sprite = null, int matCol = 0, bool setTransform = true, int dir = 0)
316 {
317 sr.sprite = sprite ?? GetSprite(dir);
319 {
320 sr.sprite = EClass.core.refs.spriteThingActor;
321 }
322 int num = ((matCol == 0) ? 104025 : matCol);
323 float num2 = (float)(num / 262144) * 0.01f;
324 float num3 = 0.02f;
325 float num4 = 0.3f;
326 if (num2 != 0f)
327 {
328 num3 *= num2;
329 }
330 Color color = new Color(num3 * (float)(num % 262144 / 4096) + num4, num3 * (float)(num % 4096 / 64) + num4, num3 * (float)(num % 64) + num4, 1f);
331 sr.color = color;
332 if (setTransform)
333 {
334 float num5 = sr.bounds.max.x - sr.bounds.min.x;
335 _ = sr.bounds.max;
336 _ = sr.bounds.min;
337 sr.transform.localPosition = new Vector3(-0.5f * num5, 0f, 0f);
338 }
339 }
340
341 public virtual SourcePref GetPref()
342 {
343 return pref;
344 }
345
346 public void SetImage(Image image, Sprite sprite = null, int matCol = 0, bool setNativeSize = true, int dir = 0, int idSkin = 0)
347 {
348 image.sprite = sprite ?? GetSprite(dir, idSkin);
349 int num = ((matCol == 0) ? 104025 : matCol);
350 float num2 = 0.02f;
351 Color color = new Color(num2 * (float)(num % 262144 / 4096), num2 * (float)(num % 4096 / 64), num2 * (float)(num % 64), (float)(num / 262144) * 0.01f);
352 color.a = 1f;
353 image.color = color;
354 RectTransform rectTransform = image.Rect();
355 SourcePref sourcePref = GetPref();
356 rectTransform.pivot = renderData.imagePivot - new Vector2(0.01f * (float)sourcePref.pivotX, 0.01f * (float)sourcePref.pivotY);
357 float x = Mathf.Abs(image.transform.localScale.x) * (float)((_tiles == null || _tiles.Length == 0 || _tiles[dir % _tiles.Length] >= 0) ? 1 : (-1));
358 float y = image.transform.localScale.y;
359 image.transform.localScale = new Vector3(x, y, image.transform.localScale.z);
360 sourcePref.Validate();
361 if (setNativeSize)
362 {
363 image.SetNativeSize();
364 if (renderData.imageScale.x != 1f || renderData.imageScale.y != 1f || sourcePref.scaleIcon != 0)
365 {
366 rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x * (renderData.imageScale.x + (float)sourcePref.scaleIcon * 0.01f), rectTransform.sizeDelta.y * (renderData.imageScale.y + (float)sourcePref.scaleIcon * 0.01f));
367 }
368 }
369 }
370
371 public void SetRenderParam(RenderParam p, SourceMaterial.Row mat, int dir)
372 {
373 p.tile = GetTile(mat ?? DefaultMaterial, dir);
374 p.matColor = GetColorInt(mat ?? DefaultMaterial);
375 p.mat = mat ?? DefaultMaterial;
376 p.liquidLv = 0;
377 p.dir = dir;
378 p.cell = null;
379 }
380
381 public virtual RenderParam GetRenderParam(SourceMaterial.Row mat, int dir, Point point = null, int bridgeHeight = -1)
382 {
384 shared.tile = GetTile(mat, dir);
385 shared.matColor = GetColorInt(mat);
386 shared.mat = mat;
387 shared.liquidLv = 0;
388 shared.dir = dir;
389 shared.cell = null;
390 Vector3 vector;
391 if (point == null)
392 {
393 shared.color = 11010048f;
396 {
397 vector.y -= 0.8f;
398 }
399 }
400 else
401 {
402 shared.color = 10485760f;
404 vector = point.Position(bridgeHeight);
405 }
406 shared.x = vector.x;
407 shared.y = vector.y;
408 shared.z = vector.z;
409 return shared;
410 }
411
412 public virtual int GetTile(SourceMaterial.Row mat, int dir = 0)
413 {
414 return _tiles[dir % _tiles.Length];
415 }
416
418 {
419 if (useAltColor)
420 {
421 if (colorMod != 0)
422 {
423 return BaseTileMap.GetColorInt(ref mat.altColor, colorMod);
424 }
425 return 104025;
426 }
427 if (colorMod != 0)
428 {
429 return BaseTileMap.GetColorInt(ref mat.matColor, colorMod);
430 }
431 return 104025;
432 }
433}
CTAG
Definition: CTAG.cs:2
BaseTileMap tileMap
static int GetColorInt(ref Color matColor, int p)
Vector3 renderPos
Sprite spriteThingActor
Definition: CoreRef.cs:385
Sprite spriteNull
Definition: CoreRef.cs:375
Definition: Core.cs:14
CoreRef refs
Definition: Core.cs:51
SourceManager sources
Definition: Core.cs:33
static new Core Instance
Definition: Core.cs:15
Scene scene
Definition: Core.cs:65
BaseGameScreen screen
Definition: Core.cs:67
Definition: EClass.cs:5
static Core core
Definition: EClass.cs:6
ProceduralMesh pmesh
Definition: MeshPass.cs:25
Material mat
Definition: MeshPass.cs:21
Definition: Point.cs:9
bool initialized
Definition: RenderData.cs:53
Vector2 imageScale
Definition: RenderData.cs:28
void Init()
Definition: RenderData.cs:94
int ConvertTile(int tile)
Definition: RenderData.cs:110
bool multiSize
Definition: RenderData.cs:32
MeshPass pass
Definition: RenderData.cs:16
static RenderParam shared
Definition: RenderParam.cs:5
virtual SourcePref GetPref()
Definition: RenderRow.cs:341
virtual string idSprite
Definition: RenderRow.cs:115
virtual string idString
Definition: RenderRow.cs:103
string detail_JP
Definition: RenderRow.cs:36
SpriteReplacer replacer
Definition: RenderRow.cs:89
void SetRenderParam(RenderParam p, SourceMaterial.Row mat, int dir)
Definition: RenderRow.cs:371
SourceManager sources
Definition: RenderRow.cs:123
int GetColorInt(SourceMaterial.Row mat)
Definition: RenderRow.cs:417
bool multisize
Definition: RenderRow.cs:64
string[] tag
Definition: RenderRow.cs:58
virtual string pathSprite
Definition: RenderRow.cs:113
RenderData renderData
Definition: RenderRow.cs:71
void SetImage(Image image, Sprite sprite=null, int matCol=0, bool setNativeSize=true, int dir=0, int idSkin=0)
Definition: RenderRow.cs:346
int sort
Definition: RenderRow.cs:18
string[] factory
Definition: RenderRow.cs:54
string detail
Definition: RenderRow.cs:34
SourceCategory.Row Category
Definition: RenderRow.cs:119
Sprite[,] sprites
Definition: RenderRow.cs:74
virtual string pathRenderData
Definition: RenderRow.cs:107
string idSound
Definition: RenderRow.cs:48
SourcePref pref
Definition: RenderRow.cs:68
virtual RenderData defaultRenderData
Definition: RenderRow.cs:111
virtual string prefabName
Definition: RenderRow.cs:117
bool ContainsTag(string _tag)
Definition: RenderRow.cs:148
string _tileType
Definition: RenderRow.cs:40
string defMat
Definition: RenderRow.cs:42
bool HasTag(CTAG _tag)
Definition: RenderRow.cs:125
bool useAltColor
Definition: RenderRow.cs:80
string _nameSearch
Definition: RenderRow.cs:92
virtual string RecipeID
Definition: RenderRow.cs:105
string category
Definition: RenderRow.cs:46
string _idRenderData
Definition: RenderRow.cs:38
string name
Definition: RenderRow.cs:30
void SetSpriteRenderer(SpriteRenderer sr, Sprite sprite=null, int matCol=0, bool setTransform=true, int dir=0)
Definition: RenderRow.cs:315
bool useRandomColor
Definition: RenderRow.cs:83
TileType tileType
Definition: RenderRow.cs:77
string[] components
Definition: RenderRow.cs:52
string _recipeCat
Definition: RenderRow.cs:101
int ConvertTile(int tile)
Definition: RenderRow.cs:256
virtual string GetSearchName(bool jp)
Definition: RenderRow.cs:130
int[] skins
Definition: RenderRow.cs:14
int[] _tiles
Definition: RenderRow.cs:12
virtual string idRenderData
Definition: RenderRow.cs:109
int tempChance
Definition: RenderRow.cs:26
string RecipeCat
Definition: RenderRow.cs:121
void SetRenderData()
Definition: RenderRow.cs:169
int[] tiles
Definition: RenderRow.cs:10
string[] recipeKey
Definition: RenderRow.cs:56
string _nameSearchJP
Definition: RenderRow.cs:95
Sprite GetSprite(int dir=0, int skin=0, bool snow=false)
Definition: RenderRow.cs:261
int value
Definition: RenderRow.cs:20
static Dictionary< string, RenderData > DictRenderData
Definition: RenderRow.cs:8
int chance
Definition: RenderRow.cs:24
string colorType
Definition: RenderRow.cs:44
virtual int GetTile(SourceMaterial.Row mat, int dir=0)
Definition: RenderRow.cs:412
virtual void SetTiles()
Definition: RenderRow.cs:244
string aliasPref
Definition: RenderRow.cs:50
virtual RenderParam GetRenderParam(SourceMaterial.Row mat, int dir, Point point=null, int bridgeHeight=-1)
Definition: RenderRow.cs:381
SourceCategory.Row _category
Definition: RenderRow.cs:98
SourceMaterial.Row DefaultMaterial
Definition: RenderRow.cs:86
int colorMod
Definition: RenderRow.cs:16
int LV
Definition: RenderRow.cs:22
int snowTile
Definition: RenderRow.cs:28
bool fixedMaterial
Definition: RenderRow.cs:66
override void OnImportData(SourceData data)
Definition: RenderRow.cs:153
string name_JP
Definition: RenderRow.cs:32
CameraSupport camSupport
Definition: Scene.cs:41
Dictionary< string, CardRow > map
Definition: SourceCard.cs:8
string GetText(string id="name", bool returnNull=false)
Definition: SourceData.cs:553
SourceMaterial materials
SourceCard cards
SourceCategory categories
int scaleIcon
Definition: SourcePref.cs:287
void Validate()
Definition: SourcePref.cs:333
Sprite GetSprite(bool snow=false)
Definition: SpriteData.cs:58
SpriteData data
bool HasSprite(string id)
static Sprite Get(string id)
Definition: SpriteSheet.cs:28