Elin Decompiled Documentation EA 23.286 Nightly Patch 1
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 (pref == null)
225 {
226 pref = new SourcePref();
227 }
228 if (!this.renderData.initialized)
229 {
230 this.renderData.Init();
231 }
232 SetTiles();
233 string text2 = colorType;
234 if (!(text2 == "alt"))
235 {
236 if (text2 == "random")
237 {
238 useRandomColor = true;
239 }
240 }
241 else
242 {
243 useAltColor = true;
244 }
245 Dictionary<string, SourceMaterial.Row> alias = sources.materials.alias;
246 if (!alias.TryGetValue(defMat.IsEmpty("granite"), out var defaultMaterial))
247 {
248 defaultMaterial = alias["granite"];
249 Debug.LogError($"#source failed to set def mat '{defMat}' - {ModUtil.FindSourceRowPackage(this)}");
250 }
251 DefaultMaterial = defaultMaterial;
252 }
253
254 public virtual void SetTiles()
255 {
256 if ((bool)renderData && (bool)renderData.pass && _tiles.Length != tiles.Length)
257 {
258 _tiles = new int[tiles.Length];
259 for (int i = 0; i < tiles.Length; i++)
260 {
261 _tiles[i] = tiles[i] / 100 * (int)renderData.pass.pmesh.tiling.x + tiles[i] % 100;
262 }
263 }
264 }
265
266 public int ConvertTile(int tile)
267 {
268 return renderData.ConvertTile(tile);
269 }
270
271 public Sprite GetSprite(int dir = 0, int skin = 0, bool snow = false)
272 {
274 {
275 return replacer.data.GetSprite(snow);
276 }
277 int[] array = null ?? _tiles;
278 if (sprites == null)
279 {
280 sprites = new Sprite[(skins == null) ? 1 : (skins.Length + 1), (array.Length == 0) ? 1 : array.Length];
281 }
282 if (this is SourceChara.Row)
283 {
284 dir = skin;
285 skin = 0;
286 }
287 if (skin != 0 && skin >= sprites.GetLength(0))
288 {
289 skin = 0;
290 }
291 if (dir < 0)
292 {
293 dir *= -1;
294 }
295 if (dir >= array.Length)
296 {
297 dir = 0;
298 }
299 if (!sprites[skin, dir])
300 {
301 MeshPass pass = renderData.pass;
302 if ((bool)pass)
303 {
304 Texture2D texture2D = pass.mat.GetTexture("_MainTex") as Texture2D;
305 ProceduralMesh pmesh = pass.pmesh;
306 int num = 0;
307 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]));
308 int num2 = (int)((float)texture2D.width / pmesh.tiling.x);
309 int num3 = (int)((float)texture2D.height / pmesh.tiling.y);
310 int num4 = (int)((float)num % pmesh.tiling.x);
311 int num5 = (int)((float)num / pmesh.tiling.x);
312 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);
313 }
314 else
315 {
316 sprites[skin, dir] = SpriteSheet.Get(idSprite);
317 if (!sprites[skin, dir])
318 {
319 sprites[skin, dir] = Resources.Load<Sprite>(pathSprite + idSprite) ?? Resources.Load<Sprite>(pathSprite + idSprite + "_0");
320 }
321 }
322 if (!sprites[skin, dir])
323 {
324 sprites[skin, dir] = Core.Instance.refs.spriteNull;
325 }
326 }
327 return sprites[skin, dir];
328 }
329
330 public void SetSpriteRenderer(SpriteRenderer sr, Sprite sprite = null, int matCol = 0, bool setTransform = true, int dir = 0, int idSkin = 0)
331 {
332 sr.sprite = sprite ?? GetSprite(dir, idSkin);
334 {
335 sr.sprite = EClass.core.refs.spriteThingActor;
336 }
337 int num = ((matCol == 0) ? 104025 : matCol);
338 float num2 = (float)(num / 262144) * 0.01f;
339 float num3 = 0.02f;
340 float num4 = 0.3f;
341 if (num2 != 0f)
342 {
343 num3 *= num2;
344 }
345 Color color = new Color(num3 * (float)(num % 262144 / 4096) + num4, num3 * (float)(num % 4096 / 64) + num4, num3 * (float)(num % 64) + num4, 1f);
346 sr.color = color;
347 if (setTransform)
348 {
349 float num5 = sr.bounds.max.x - sr.bounds.min.x;
350 _ = sr.bounds.max;
351 _ = sr.bounds.min;
352 sr.transform.localPosition = new Vector3(-0.5f * num5, 0f, 0f);
353 }
354 }
355
356 public virtual SourcePref GetPref()
357 {
358 return pref;
359 }
360
361 public void SetImage(Image image, Sprite sprite = null, int matCol = 0, bool setNativeSize = true, int dir = 0, int idSkin = 0, Card card = null)
362 {
363 bool num = card != null && card.isChara && card.Chara.spriteReplacer != null && !card.HasHost;
364 SourcePref sourcePref = ((card != null) ? card.Pref : GetPref());
365 RenderData renderData = (num ? card.renderer.data : this.renderData);
366 SetImage(image, sprite, matCol, setNativeSize, dir, idSkin, renderData, sourcePref);
367 }
368
369 public void SetImage(Image image, Sprite sprite, int matCol, bool setNativeSize, int dir, int idSkin, RenderData _renderData, SourcePref _pref)
370 {
371 image.sprite = sprite ?? GetSprite(dir, idSkin);
372 int num = ((matCol == 0) ? 104025 : matCol);
373 float num2 = 0.02f;
374 Color color = new Color(num2 * (float)(num % 262144 / 4096), num2 * (float)(num % 4096 / 64), num2 * (float)(num % 64), (float)(num / 262144) * 0.01f);
375 color.a = 1f;
376 image.color = color;
377 RectTransform rectTransform = image.Rect();
378 rectTransform.pivot = _renderData.imagePivot - new Vector2(0.01f * (float)_pref.pivotX, 0.01f * (float)_pref.pivotY);
379 float x = Mathf.Abs(image.transform.localScale.x) * (float)((_tiles == null || _tiles.Length == 0 || _tiles[dir % _tiles.Length] >= 0) ? 1 : (-1));
380 float y = image.transform.localScale.y;
381 image.transform.localScale = new Vector3(x, y, image.transform.localScale.z);
382 _pref.Validate();
383 if (setNativeSize)
384 {
385 image.SetNativeSize();
386 if (_renderData.imageScale.x != 1f || _renderData.imageScale.y != 1f || _pref.scaleIcon != 0)
387 {
388 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));
389 }
390 }
391 }
392
393 public void SetRenderParam(RenderParam p, SourceMaterial.Row mat, int dir)
394 {
395 p.tile = GetTile(mat ?? DefaultMaterial, dir);
396 p.matColor = GetColorInt(mat ?? DefaultMaterial);
397 p.mat = mat ?? DefaultMaterial;
398 p.liquidLv = 0;
399 p.dir = dir;
400 p.cell = null;
401 }
402
403 public virtual RenderParam GetRenderParam(SourceMaterial.Row mat, int dir, Point point = null, int bridgeHeight = -1)
404 {
406 shared.tile = GetTile(mat, dir);
407 shared.matColor = GetColorInt(mat);
408 shared.mat = mat;
409 shared.liquidLv = 0;
410 shared.dir = dir;
411 shared.cell = null;
412 Vector3 vector;
413 if (point == null)
414 {
415 shared.color = 11010048f;
418 {
419 vector.y -= 0.8f;
420 }
421 }
422 else
423 {
424 shared.color = 10485760f;
426 vector = point.Position(bridgeHeight);
427 }
428 shared.x = vector.x;
429 shared.y = vector.y;
430 shared.z = vector.z;
431 return shared;
432 }
433
434 public virtual int GetTile(SourceMaterial.Row mat, int dir = 0)
435 {
436 return _tiles[dir % _tiles.Length];
437 }
438
440 {
441 if (useAltColor)
442 {
443 if (colorMod != 0)
444 {
445 return BaseTileMap.GetColorInt(ref mat.altColor, colorMod);
446 }
447 return 104025;
448 }
449 if (colorMod != 0)
450 {
451 return BaseTileMap.GetColorInt(ref mat.matColor, colorMod);
452 }
453 return 104025;
454 }
455}
CTAG
Definition: CTAG.cs:2
$
Definition: ModManager.cs:85
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:6
static Core core
Definition: EClass.cs:7
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:356
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:393
SourceManager sources
Definition: RenderRow.cs:123
int GetColorInt(SourceMaterial.Row mat)
Definition: RenderRow.cs:439
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:369
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:266
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:361
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:271
void SetSpriteRenderer(SpriteRenderer sr, Sprite sprite=null, int matCol=0, bool setTransform=true, int dir=0, int idSkin=0)
Definition: RenderRow.cs:330
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:434
virtual void SetTiles()
Definition: RenderRow.cs:254
string aliasPref
Definition: RenderRow.cs:50
virtual RenderParam GetRenderParam(SourceMaterial.Row mat, int dir, Point point=null, int bridgeHeight=-1)
Definition: RenderRow.cs:403
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:9
string GetText(string id="name", bool returnNull=false)
Definition: SourceData.cs:626
SourceMaterial materials
SourceCard cards
SourceCategory categories
int scaleIcon
Definition: SourcePref.cs:291
void Validate()
Definition: SourcePref.cs:351
Sprite GetSprite(bool snow=false)
Definition: SpriteData.cs:67
SpriteData data
bool HasSprite(string id, RenderData renderData=null)
static Sprite Get(string id)
Definition: SpriteSheet.cs:28