Elin Decompiled Documentation EA 23.230 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 }
241 DefaultMaterial = sources.materials.alias[defMat.IsEmpty("granite")];
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 (this is SourceChara.Row)
273 {
274 dir = skin;
275 skin = 0;
276 }
277 if (skin != 0 && skin >= sprites.GetLength(0))
278 {
279 skin = 0;
280 }
281 if (dir < 0)
282 {
283 dir *= -1;
284 }
285 if (dir >= array.Length)
286 {
287 dir = 0;
288 }
289 if (!sprites[skin, dir])
290 {
291 MeshPass pass = renderData.pass;
292 if ((bool)pass)
293 {
294 Texture2D texture2D = pass.mat.GetTexture("_MainTex") as Texture2D;
295 ProceduralMesh pmesh = pass.pmesh;
296 int num = 0;
297 num = ((skin != 0) ? Mathf.Abs(array[dir] + (skins[skin - 1] / 100 * (int)renderData.pass.pmesh.tiling.x + skins[skin - 1] % 100) * ((array[dir] > 0) ? 1 : (-1))) : Mathf.Abs(array[dir]));
298 int num2 = (int)((float)texture2D.width / pmesh.tiling.x);
299 int num3 = (int)((float)texture2D.height / pmesh.tiling.y);
300 int num4 = (int)((float)num % pmesh.tiling.x);
301 int num5 = (int)((float)num / pmesh.tiling.x);
302 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);
303 }
304 else
305 {
306 sprites[skin, dir] = SpriteSheet.Get(idSprite);
307 if (!sprites[skin, dir])
308 {
309 sprites[skin, dir] = Resources.Load<Sprite>(pathSprite + idSprite) ?? Resources.Load<Sprite>(pathSprite + idSprite + "_0");
310 }
311 }
312 if (!sprites[skin, dir])
313 {
314 sprites[skin, dir] = Core.Instance.refs.spriteNull;
315 }
316 }
317 return sprites[skin, dir];
318 }
319
320 public void SetSpriteRenderer(SpriteRenderer sr, Sprite sprite = null, int matCol = 0, bool setTransform = true, int dir = 0, int idSkin = 0)
321 {
322 sr.sprite = sprite ?? GetSprite(dir, idSkin);
324 {
325 sr.sprite = EClass.core.refs.spriteThingActor;
326 }
327 int num = ((matCol == 0) ? 104025 : matCol);
328 float num2 = (float)(num / 262144) * 0.01f;
329 float num3 = 0.02f;
330 float num4 = 0.3f;
331 if (num2 != 0f)
332 {
333 num3 *= num2;
334 }
335 Color color = new Color(num3 * (float)(num % 262144 / 4096) + num4, num3 * (float)(num % 4096 / 64) + num4, num3 * (float)(num % 64) + num4, 1f);
336 sr.color = color;
337 if (setTransform)
338 {
339 float num5 = sr.bounds.max.x - sr.bounds.min.x;
340 _ = sr.bounds.max;
341 _ = sr.bounds.min;
342 sr.transform.localPosition = new Vector3(-0.5f * num5, 0f, 0f);
343 }
344 }
345
346 public virtual SourcePref GetPref()
347 {
348 return pref;
349 }
350
351 public void SetImage(Image image, Sprite sprite = null, int matCol = 0, bool setNativeSize = true, int dir = 0, int idSkin = 0, Card card = null)
352 {
353 bool num = card != null && card.isChara && card.Chara.spriteReplacer != null && !card.HasHost;
354 SourcePref sourcePref = ((card != null) ? card.Pref : GetPref());
355 RenderData renderData = (num ? card.renderer.data : this.renderData);
356 SetImage(image, sprite, matCol, setNativeSize, dir, idSkin, renderData, sourcePref);
357 }
358
359 public void SetImage(Image image, Sprite sprite, int matCol, bool setNativeSize, int dir, int idSkin, RenderData _renderData, SourcePref _pref)
360 {
361 image.sprite = sprite ?? GetSprite(dir, idSkin);
362 int num = ((matCol == 0) ? 104025 : matCol);
363 float num2 = 0.02f;
364 Color color = new Color(num2 * (float)(num % 262144 / 4096), num2 * (float)(num % 4096 / 64), num2 * (float)(num % 64), (float)(num / 262144) * 0.01f);
365 color.a = 1f;
366 image.color = color;
367 RectTransform rectTransform = image.Rect();
368 rectTransform.pivot = _renderData.imagePivot - new Vector2(0.01f * (float)_pref.pivotX, 0.01f * (float)_pref.pivotY);
369 float x = Mathf.Abs(image.transform.localScale.x) * (float)((_tiles == null || _tiles.Length == 0 || _tiles[dir % _tiles.Length] >= 0) ? 1 : (-1));
370 float y = image.transform.localScale.y;
371 image.transform.localScale = new Vector3(x, y, image.transform.localScale.z);
372 _pref.Validate();
373 if (setNativeSize)
374 {
375 image.SetNativeSize();
376 if (_renderData.imageScale.x != 1f || _renderData.imageScale.y != 1f || _pref.scaleIcon != 0)
377 {
378 rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x * (_renderData.imageScale.x + (float)_pref.scaleIcon * 0.01f), rectTransform.sizeDelta.y * (_renderData.imageScale.y + (float)_pref.scaleIcon * 0.01f));
379 }
380 }
381 }
382
383 public void SetRenderParam(RenderParam p, SourceMaterial.Row mat, int dir)
384 {
385 p.tile = GetTile(mat ?? DefaultMaterial, dir);
386 p.matColor = GetColorInt(mat ?? DefaultMaterial);
387 p.mat = mat ?? DefaultMaterial;
388 p.liquidLv = 0;
389 p.dir = dir;
390 p.cell = null;
391 }
392
393 public virtual RenderParam GetRenderParam(SourceMaterial.Row mat, int dir, Point point = null, int bridgeHeight = -1)
394 {
396 shared.tile = GetTile(mat, dir);
397 shared.matColor = GetColorInt(mat);
398 shared.mat = mat;
399 shared.liquidLv = 0;
400 shared.dir = dir;
401 shared.cell = null;
402 Vector3 vector;
403 if (point == null)
404 {
405 shared.color = 11010048f;
408 {
409 vector.y -= 0.8f;
410 }
411 }
412 else
413 {
414 shared.color = 10485760f;
416 vector = point.Position(bridgeHeight);
417 }
418 shared.x = vector.x;
419 shared.y = vector.y;
420 shared.z = vector.z;
421 return shared;
422 }
423
424 public virtual int GetTile(SourceMaterial.Row mat, int dir = 0)
425 {
426 return _tiles[dir % _tiles.Length];
427 }
428
430 {
431 if (useAltColor)
432 {
433 if (colorMod != 0)
434 {
435 return BaseTileMap.GetColorInt(ref mat.altColor, colorMod);
436 }
437 return 104025;
438 }
439 if (colorMod != 0)
440 {
441 return BaseTileMap.GetColorInt(ref mat.matColor, colorMod);
442 }
443 return 104025;
444 }
445}
CTAG
Definition: CTAG.cs:2
BaseTileMap tileMap
static int GetColorInt(ref Color matColor, int p)
Vector3 renderPos
Definition: Card.cs:11
Sprite spriteThingActor
Definition: CoreRef.cs:401
Sprite spriteNull
Definition: CoreRef.cs:391
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:346
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:383
SourceManager sources
Definition: RenderRow.cs:123
int GetColorInt(SourceMaterial.Row mat)
Definition: RenderRow.cs:429
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
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
bool useRandomColor
Definition: RenderRow.cs:83
void SetImage(Image image, Sprite sprite, int matCol, bool setNativeSize, int dir, int idSkin, RenderData _renderData, SourcePref _pref)
Definition: RenderRow.cs:359
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
void SetImage(Image image, Sprite sprite=null, int matCol=0, bool setNativeSize=true, int dir=0, int idSkin=0, Card card=null)
Definition: RenderRow.cs:351
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
void SetSpriteRenderer(SpriteRenderer sr, Sprite sprite=null, int matCol=0, bool setTransform=true, int dir=0, int idSkin=0)
Definition: RenderRow.cs:320
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:424
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:393
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:291
void Validate()
Definition: SourcePref.cs:339
Sprite GetSprite(bool snow=false)
Definition: SpriteData.cs:67
SpriteData data
bool HasSprite(string id)
static Sprite Get(string id)
Definition: SpriteSheet.cs:28