Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
RenderData.cs
Go to the documentation of this file.
1using System;
2using UnityEngine;
3
5{
6 public const int HeldLightMod = 1572864;
7
8 public static Quaternion deadRotation = Quaternion.Euler(0f, 0f, 90f);
9
10 protected Vector3 _offset;
11
13
14 public int idShadow;
15
16 public MeshPass pass;
17
18 public Vector3 offset;
19
20 public Vector3 offsetBack;
21
22 public Vector3 offsetShadow;
23
24 public Vector3 heldPos;
25
26 public Vector2 imagePivot = new Vector2(0.5f, 0.25f);
27
28 public Vector2 imageScale = new Vector2(1f, 1f);
29
30 public Vector2 size;
31
32 public bool multiSize;
33
34 public bool animate;
35
36 public bool useOffsetBack;
37
38 public bool persistActor;
39
40 public bool symmetry = true;
41
42 public float hangedFixZ;
43
44 public float stackZ;
45
47
49
51
52 [NonSerialized]
53 public bool initialized;
54
55 [NonSerialized]
56 private Sprite _sprite;
57
58 [NonSerialized]
59 public bool hasSubPass;
60
61 [NonSerialized]
62 public bool hasSnowPass;
63
64 private float orgX;
65
66 private float orgY;
67
68 private float orgZ;
69
70 public static Quaternion shadowRotation => Quaternion.Euler(0f, 0f, renderSetting.shadowAngle);
71
72 public static Vector3 shadowScale => renderSetting.shadowScale;
73
74 public static Vector3 shadowOffset => renderSetting.shadowOffset;
75
76 public virtual bool SkipOnMap => false;
77
78 public virtual string pathSprite => "Scene/Render/Data/";
79
80 public virtual string prefabName => "ThingActor";
81
82 public virtual bool ForceAltHeldPosition => false;
83
84 public virtual CardActor CreateActor()
85 {
86 return null;
87 }
88
89 private void Awake()
90 {
91 Init();
92 }
93
94 public void Init()
95 {
96 if (!initialized)
97 {
98 initialized = true;
102 OnInit();
103 }
104 }
105
106 public virtual void OnInit()
107 {
108 }
109
110 public int ConvertTile(int tile)
111 {
112 return tile / 100 * (int)pass.pmesh.tiling.x + tile % 100;
113 }
114
116 {
117 Vector3 renderPos = EClass.scene.camSupport.renderPos;
118 if (multiSize)
119 {
120 renderPos.y -= 0.8f;
121 }
122 p.x = renderPos.x;
123 p.y = renderPos.y;
124 p.z = renderPos.z;
125 Draw(p);
126 }
127
128 public void Draw(RenderParam p, int tile)
129 {
130 p.tile = tile;
131 Draw(p);
132 }
133
134 public virtual void Draw(RenderParam p)
135 {
137 MeshBatch meshBatch = meshPass.batches[meshPass.batchIdx];
138 int num = ((p.tile > 0f) ? 1 : (-1));
139 if (useOffsetBack)
140 {
141 _offset = ((p.dir == 2 || p.dir == 3) ? offsetBack : offset);
142 }
143 if (meshPass == pass.subPass)
144 {
145 meshBatch.colors[meshPass.idx] = p.color - 1572864f;
147 }
148 else
149 {
150 meshBatch.colors[meshPass.idx] = p.color;
151 meshBatch.matrices[meshPass.idx].m03 = p.x + _offset.x * (float)num;
152 meshBatch.matrices[meshPass.idx].m13 = p.y + _offset.y;
153 meshBatch.matrices[meshPass.idx].m23 = p.z + _offset.z;
154 }
155 meshBatch.tiles[meshPass.idx] = p.tile + (float)(p.liquidLv * 10000 * num);
156 meshPass.idx++;
157 if (meshPass.idx == meshPass.batchSize)
158 {
159 meshPass.NextBatch();
160 }
161 }
162
163 private void OnValidate()
164 {
165 _offset = offset;
166 }
167
168 public void DrawRepeatTo(RenderParam p, float maxY, float height, ref Vector3 peakFix, bool skipFirst = false, int fire = 0, bool isBlock = false)
169 {
170 int num = (int)((maxY + height + peakFix.x - p.y) / peakFix.y);
171 bool snow = p.snow;
172 if (num == 0)
173 {
174 if (!skipFirst)
175 {
176 Draw(p);
177 }
178 return;
179 }
180 orgY = p.y;
181 orgZ = p.z;
182 p.snow = !isBlock && snow;
183 for (int i = 0; i < num + 1; i++)
184 {
185 if (i == num)
186 {
187 p.y = maxY + height - peakFix.y;
188 p.z -= peakFix.z + peakFix.x;
189 p.snow = snow;
190 }
191 if (skipFirst)
192 {
193 if (i != 0 && num > 1)
194 {
195 Draw(p);
196 }
197 }
198 else
199 {
200 Draw(p);
201 }
202 if (fire > 0 && i != num)
203 {
205 fire--;
206 }
207 p.y += peakFix.y;
208 p.z += peakFix.z;
209 }
210 p.y = orgY;
211 p.z = orgZ;
212 }
213
214 public void DrawRepeat(RenderParam p, int count, float size, bool skipFirst = false)
215 {
216 if (count == 1)
217 {
218 if (!skipFirst)
219 {
220 Draw(p);
221 }
222 return;
223 }
224 bool snow = p.snow;
225 orgY = p.y;
226 orgZ = p.z;
227 p.snow = false;
228 for (int i = 0; i < count; i++)
229 {
230 if (i == count - 1)
231 {
232 p.snow = snow;
233 }
234 if (i != 0 || !skipFirst)
235 {
236 Draw(p);
237 }
238 p.y += renderSetting.peakFix.y * size;
239 p.z += renderSetting.peakFix.z * size;
240 }
241 p.y = orgY;
242 p.z = orgZ;
243 }
244
245 public virtual void DrawWithRotation(RenderParam p, float angle)
246 {
247 }
248
249 public virtual void DrawShadow(RenderParam p)
250 {
251 int num = ((p.tile > 0f) ? 1 : (-1));
252 MeshPass shadowPass = pass.shadowPass;
253 MeshBatch meshBatch = shadowPass.batches[shadowPass.batchIdx];
254 meshBatch.matrices[shadowPass.idx].SetTRS(p.NewVector3 + offset + shadowOffset, shadowRotation, shadowScale);
255 meshBatch.tiles[shadowPass.idx] = p.tile;
256 shadowPass.idx++;
257 if (shadowPass.idx == shadowPass.batchSize)
258 {
259 shadowPass.NextBatch();
260 }
261 if (multiSize)
262 {
263 shadowPass = pass.shadowPass;
264 MeshBatch meshBatch2 = shadowPass.batches[shadowPass.batchIdx];
265 meshBatch2.matrices[shadowPass.idx].SetTRS(p.v + offsetShadow, shadowRotation, shadowScale);
266 meshBatch2.tiles[shadowPass.idx] = p.tile - pass.pmesh.tiling.x * (float)num;
267 shadowPass.idx++;
268 if (shadowPass.idx == shadowPass.batchSize)
269 {
270 shadowPass.NextBatch();
271 }
272 }
273 }
274}
BaseTileMap tileMap
RenderDataEffect rendererEffect
Definition: BaseTileMap.cs:229
Vector3 renderPos
Definition: EClass.cs:5
static Scene scene
Definition: EClass.cs:30
static BaseGameScreen screen
Definition: EClass.cs:32
Matrix4x4[] matrices
Definition: MeshBatch.cs:5
float[] tiles
Definition: MeshBatch.cs:7
float[] colors
Definition: MeshBatch.cs:9
MeshPass subPass
Definition: MeshPass.cs:15
int batchIdx
Definition: MeshPass.cs:60
ProceduralMesh pmesh
Definition: MeshPass.cs:25
MeshPass snowPass
Definition: MeshPass.cs:17
void NextBatch()
Definition: MeshPass.cs:417
int batchSize
Definition: MeshPass.cs:63
MeshPass shadowPass
Definition: MeshPass.cs:19
List< MeshBatch > batches
Definition: MeshPass.cs:66
int idx
Definition: MeshPass.cs:57
new void Draw(RenderParam p, int tile=0)
static Quaternion shadowRotation
Definition: RenderData.cs:70
bool animate
Definition: RenderData.cs:34
const int HeldLightMod
Definition: RenderData.cs:6
void DrawRepeatTo(RenderParam p, float maxY, float height, ref Vector3 peakFix, bool skipFirst=false, int fire=0, bool isBlock=false)
Definition: RenderData.cs:168
float orgZ
Definition: RenderData.cs:68
static GameSetting.RenderSetting renderSetting
Definition: RenderData.cs:12
virtual void DrawWithRotation(RenderParam p, float angle)
Definition: RenderData.cs:245
virtual bool ForceAltHeldPosition
Definition: RenderData.cs:82
virtual bool SkipOnMap
Definition: RenderData.cs:76
static Vector3 shadowOffset
Definition: RenderData.cs:74
void Draw(RenderParam p, int tile)
Definition: RenderData.cs:128
bool hasSubPass
Definition: RenderData.cs:59
Vector3 offsetBack
Definition: RenderData.cs:20
void OnValidate()
Definition: RenderData.cs:163
virtual void OnInit()
Definition: RenderData.cs:106
Vector3 offsetShadow
Definition: RenderData.cs:22
float orgY
Definition: RenderData.cs:66
virtual string prefabName
Definition: RenderData.cs:80
bool symmetry
Definition: RenderData.cs:40
void RenderToRenderCam(RenderParam p)
Definition: RenderData.cs:115
SubPassData subCrate
Definition: RenderData.cs:46
bool useOffsetBack
Definition: RenderData.cs:36
static Vector3 shadowScale
Definition: RenderData.cs:72
static Quaternion deadRotation
Definition: RenderData.cs:8
bool initialized
Definition: RenderData.cs:53
RenderData subData
Definition: RenderData.cs:50
Vector3 _offset
Definition: RenderData.cs:10
void DrawRepeat(RenderParam p, int count, float size, bool skipFirst=false)
Definition: RenderData.cs:214
Vector2 imagePivot
Definition: RenderData.cs:26
Vector2 imageScale
Definition: RenderData.cs:28
Vector3 offset
Definition: RenderData.cs:18
void Init()
Definition: RenderData.cs:94
float stackZ
Definition: RenderData.cs:44
int ConvertTile(int tile)
Definition: RenderData.cs:110
virtual void Draw(RenderParam p)
Definition: RenderData.cs:134
bool multiSize
Definition: RenderData.cs:32
Sprite _sprite
Definition: RenderData.cs:56
bool hasSnowPass
Definition: RenderData.cs:62
virtual CardActor CreateActor()
Definition: RenderData.cs:84
SourcePref shadowPref
Definition: RenderData.cs:48
virtual void DrawShadow(RenderParam p)
Definition: RenderData.cs:249
float orgX
Definition: RenderData.cs:64
int idShadow
Definition: RenderData.cs:14
void Awake()
Definition: RenderData.cs:89
float hangedFixZ
Definition: RenderData.cs:42
Vector3 heldPos
Definition: RenderData.cs:24
bool persistActor
Definition: RenderData.cs:38
MeshPass pass
Definition: RenderData.cs:16
virtual string pathSprite
Definition: RenderData.cs:78
Vector2 size
Definition: RenderData.cs:30
int liquidLv
Definition: RenderParam.cs:7
Vector3 NewVector3
Definition: RenderParam.cs:23
Vector3 v
Definition: RenderParam.cs:19
CameraSupport camSupport
Definition: Scene.cs:41
Quaternion rotation
Definition: SubPassData.cs:15
Vector3 scale
Definition: SubPassData.cs:13
static SubPassData Current
Definition: SubPassData.cs:9
Vector3 offset
Definition: SubPassData.cs:11