Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
MeshPass Class Reference
Inheritance diagram for MeshPass:

Public Member Functions

void Init ()
 
void Add (Point point, float tile=0f, float color=0f)
 
void Add (ref Vector3 v, float tile=0f, float color=0f)
 
void Add (float x, float y, float z, float tile=0f, float color=0f)
 
void AddWithScale (float x, float y, float z, int tile, float scale)
 
void AddShadow (MeshPassParam p, ref Vector3 fix)
 
void AddShadow (float x, float y, float z, ShadowData.Item s, SourcePref pref, int dir=0, bool snow=false)
 
void AddWithRotation (float x, float y, float z, float sx, float sy, int tile, float angle, bool flip)
 
void Add (MeshPassParam p)
 
void Add (float x, float y, float z, float tile, float color, float matColor=0f)
 
void Add (MeshPassParam p, float tile, float color, float matColor=0f)
 
void Draw ()
 
void DrawEmpty ()
 
void NextBatch ()
 
override string ToString ()
 
void Refresh ()
 
void OnValidate ()
 
void _Refresh ()
 

Public Attributes

MeshPass subPass
 
MeshPass snowPass
 
MeshPass shadowPass
 
Material mat
 
Mesh mesh
 
ProceduralMesh pmesh
 
Sprite sprite
 
bool setTile
 
bool setColor
 
bool setMatColor
 
bool setExtra
 
int renderQueue
 
MeshPassParam _p = new MeshPassParam()
 
FilterMode filter
 
int lastCount
 
int lastBatchCount
 
bool haveSubPass
 
bool haveShadowPass
 
bool haveSnowPass
 
int idx
 
int batchIdx
 
int batchSize = 1023
 
List< MeshBatchbatches = new List<MeshBatch>()
 
Texture preserveTex
 

Static Public Attributes

const int TokenLiquid = 10000
 
const int TokenLowWall = 1000000
 
const int TokenLowWallDefault = 3000000
 

Properties

float meshX [get, set]
 

Private Member Functions

Mesh SpriteToMesh (Sprite sprite)
 

Private Attributes

bool initialized
 
bool resize
 
MeshBatch _batch
 
Vector3 tempV = Vector3.zero
 
Vector2 tempE = Vector2.zero
 
bool first = true
 

Detailed Description

Definition at line 7 of file MeshPass.cs.

Member Function Documentation

◆ _Refresh()

void MeshPass._Refresh ( )
inline

Definition at line 466 of file MeshPass.cs.

467 {
471 if (!mesh)
472 {
473 if ((bool)pmesh)
474 {
475 mesh = pmesh.GetMesh();
476 }
477 else if ((bool)sprite)
478 {
480 }
481 }
482 if (haveSnowPass)
483 {
484 snowPass.mesh = mesh;
485 }
486 if (haveSubPass)
487 {
488 subPass.mesh = mesh;
489 }
490 if (haveShadowPass)
491 {
492 shadowPass.mesh = mesh;
493 }
494 }
MeshPass subPass
Definition: MeshPass.cs:15
Sprite sprite
Definition: MeshPass.cs:27
ProceduralMesh pmesh
Definition: MeshPass.cs:25
MeshPass snowPass
Definition: MeshPass.cs:17
bool haveSubPass
Definition: MeshPass.cs:48
bool haveShadowPass
Definition: MeshPass.cs:51
Mesh SpriteToMesh(Sprite sprite)
Definition: MeshPass.cs:432
MeshPass shadowPass
Definition: MeshPass.cs:19
Mesh mesh
Definition: MeshPass.cs:23
bool haveSnowPass
Definition: MeshPass.cs:54

References ProceduralMesh.GetMesh(), haveShadowPass, haveSnowPass, haveSubPass, mesh, pmesh, shadowPass, snowPass, sprite, SpriteToMesh(), and subPass.

Referenced by Init().

◆ Add() [1/6]

void MeshPass.Add ( float  x,
float  y,
float  z,
float  tile,
float  color,
float  matColor = 0f 
)
inline

Definition at line 306 of file MeshPass.cs.

307 {
309 _batch.matrices[idx].m03 = x;
310 _batch.matrices[idx].m13 = y;
311 _batch.matrices[idx].m23 = z;
312 _batch.tiles[idx] = tile;
313 if (setColor)
314 {
315 _batch.colors[idx] = color;
316 }
317 if (setMatColor)
318 {
319 _batch.matColors[idx] = matColor;
320 }
321 idx++;
322 if (idx == batchSize)
323 {
324 NextBatch();
325 }
326 }
float[] matColors
Definition: MeshBatch.cs:11
Matrix4x4[] matrices
Definition: MeshBatch.cs:5
float[] tiles
Definition: MeshBatch.cs:7
float[] colors
Definition: MeshBatch.cs:9
int batchIdx
Definition: MeshPass.cs:60
bool setMatColor
Definition: MeshPass.cs:33
void NextBatch()
Definition: MeshPass.cs:417
int batchSize
Definition: MeshPass.cs:63
bool setColor
Definition: MeshPass.cs:31
MeshBatch _batch
Definition: MeshPass.cs:77
List< MeshBatch > batches
Definition: MeshPass.cs:66
int idx
Definition: MeshPass.cs:57

References _batch, batches, batchIdx, batchSize, MeshBatch.colors, idx, MeshBatch.matColors, MeshBatch.matrices, NextBatch(), setColor, setMatColor, and MeshBatch.tiles.

◆ Add() [2/6]

void MeshPass.Add ( float  x,
float  y,
float  z,
float  tile = 0f,
float  color = 0f 
)
inline

Definition at line 159 of file MeshPass.cs.

160 {
162 _batch.matrices[idx].m03 = x;
163 _batch.matrices[idx].m13 = y;
164 _batch.matrices[idx].m23 = z;
165 _batch.tiles[idx] = tile;
166 if (setColor)
167 {
168 _batch.colors[idx] = color;
169 }
170 idx++;
171 if (idx == batchSize)
172 {
173 NextBatch();
174 }
175 }

References _batch, batches, batchIdx, batchSize, MeshBatch.colors, idx, MeshBatch.matrices, NextBatch(), setColor, and MeshBatch.tiles.

◆ Add() [3/6]

void MeshPass.Add ( MeshPassParam  p)
inline

Definition at line 281 of file MeshPass.cs.

282 {
284 _batch.matrices[idx].m03 = p.x;
285 _batch.matrices[idx].m13 = p.y;
286 _batch.matrices[idx].m23 = p.z;
287 if (setTile)
288 {
289 _batch.tiles[idx] = p.tile;
290 }
291 if (setColor)
292 {
293 _batch.colors[idx] = p.color;
294 }
295 if (setMatColor)
296 {
298 }
299 idx++;
300 if (idx == batchSize)
301 {
302 NextBatch();
303 }
304 }
bool setTile
Definition: MeshPass.cs:29

References _batch, batches, batchIdx, batchSize, MeshPassParam.color, MeshBatch.colors, idx, MeshPassParam.matColor, MeshBatch.matColors, MeshBatch.matrices, NextBatch(), setColor, setMatColor, setTile, MeshPassParam.tile, MeshBatch.tiles, MeshPassParam.x, MeshPassParam.y, and MeshPassParam.z.

◆ Add() [4/6]

void MeshPass.Add ( MeshPassParam  p,
float  tile,
float  color,
float  matColor = 0f 
)
inline

Definition at line 328 of file MeshPass.cs.

329 {
331 _batch.matrices[idx].m03 = p.x;
332 _batch.matrices[idx].m13 = p.y;
333 _batch.matrices[idx].m23 = p.z;
334 _batch.tiles[idx] = tile;
335 if (setColor)
336 {
337 _batch.colors[idx] = color;
338 }
339 if (setMatColor)
340 {
341 _batch.matColors[idx] = matColor;
342 }
343 idx++;
344 if (idx == batchSize)
345 {
346 NextBatch();
347 }
348 }

References _batch, batches, batchIdx, batchSize, MeshBatch.colors, idx, MeshBatch.matColors, MeshBatch.matrices, NextBatch(), setColor, setMatColor, MeshBatch.tiles, MeshPassParam.x, MeshPassParam.y, and MeshPassParam.z.

◆ Add() [5/6]

◆ Add() [6/6]

void MeshPass.Add ( ref Vector3  v,
float  tile = 0f,
float  color = 0f 
)
inline

Definition at line 141 of file MeshPass.cs.

142 {
144 _batch.matrices[idx].m03 = v.x;
145 _batch.matrices[idx].m13 = v.y;
146 _batch.matrices[idx].m23 = v.z;
147 _batch.tiles[idx] = tile;
148 if (setColor)
149 {
150 _batch.colors[idx] = color;
151 }
152 idx++;
153 if (idx == batchSize)
154 {
155 NextBatch();
156 }
157 }

References _batch, batches, batchIdx, batchSize, MeshBatch.colors, idx, MeshBatch.matrices, NextBatch(), setColor, and MeshBatch.tiles.

◆ AddShadow() [1/2]

void MeshPass.AddShadow ( float  x,
float  y,
float  z,
ShadowData::Item  s,
SourcePref  pref,
int  dir = 0,
bool  snow = false 
)
inline

Definition at line 213 of file MeshPass.cs.

214 {
215 int angle = s.angle;
216 float num = (float)s.scaleX * 0.01f;
217 float num2 = (float)s.scaleY * 0.01f;
218 bool flag = dir % 2 == 1;
219 int num3 = (flag ? 1 : (-1));
221 Matrix4x4[] matrices = _batch.matrices;
222 matrices[idx].m03 = x - 0.01f * (float)((dir < 2) ? (flag ? pref.shadowRX : pref.shadowX) : (flag ? pref.shadowBRX : pref.shadowBX)) + ((0.7f * (0f - num) + 0.7f) * (float)num3 + (float)s.x * 0.01f) * (float)num3;
223 matrices[idx].m13 = y - 0.01f * (float)((dir < 2) ? (flag ? pref.shadowRY : pref.shadowY) : (flag ? pref.shadowBRY : pref.shadowBY)) + 0.6f * (0f - num2) + 0.6f + (float)s.y * 0.01f;
224 matrices[idx].m23 = z;
225 matrices[idx].m00 = num;
226 matrices[idx].m11 = num2;
227 if (angle == 0)
228 {
229 matrices[idx].m00 = num;
230 matrices[idx].m01 = 0f;
231 matrices[idx].m10 = 0f;
232 matrices[idx].m11 = num2;
233 }
234 else
235 {
236 tempV.z = -angle;
237 Quaternion quaternion = Quaternion.Euler(0f, 0f, -angle);
238 tempE.x = 1f - quaternion.z * quaternion.z * 2f;
239 tempE.y = (0f - quaternion.w) * quaternion.z * 2f;
240 matrices[idx].m00 = tempE.x * num;
241 matrices[idx].m01 = tempE.y * num2;
242 matrices[idx].m10 = (0f - tempE.y) * num;
243 matrices[idx].m11 = tempE.x * num2;
244 }
245 _batch.tiles[idx] = (s.tile + (snow ? 1000 : 0)) * num3;
246 idx++;
247 if (idx == batchSize)
248 {
249 NextBatch();
250 }
251 }
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
Vector2 tempE
Definition: MeshPass.cs:81
int shadowBRY
Definition: SourcePref.cs:251
int shadowBRX
Definition: SourcePref.cs:239
int shadowBY
Definition: SourcePref.cs:227
int shadowBX
Definition: SourcePref.cs:215

References _batch, batches, batchIdx, batchSize, idx, if(), MeshBatch.matrices, NextBatch(), SourcePref.shadowBRX, SourcePref.shadowBRY, SourcePref.shadowBX, SourcePref.shadowBY, SourcePref.shadowX, SourcePref.shadowY, tempE, and MeshBatch.tiles.

◆ AddShadow() [2/2]

void MeshPass.AddShadow ( MeshPassParam  p,
ref Vector3  fix 
)
inline

Definition at line 195 of file MeshPass.cs.

196 {
198 _batch.matrices[idx].SetTRS(Vector3.zero, Quaternion.Euler(0f, 0f, 0f), Vector3.one);
199 _batch.matrices[idx].m03 = p.x + fix.x;
200 _batch.matrices[idx].m13 = p.y + fix.y;
201 _batch.matrices[idx].m23 = p.z + fix.z;
202 if (setTile)
203 {
204 _batch.tiles[idx] = p.tile;
205 }
206 idx++;
207 if (idx == batchSize)
208 {
209 NextBatch();
210 }
211 }

References _batch, batches, batchIdx, batchSize, idx, MeshBatch.matrices, NextBatch(), setTile, MeshPassParam.tile, and MeshBatch.tiles.

Referenced by CardRenderer.Draw(), BaseTileMap.DrawTile(), TileMapElona.DrawTile(), and GrowSystem.OnRenderTileMap().

◆ AddWithRotation()

void MeshPass.AddWithRotation ( float  x,
float  y,
float  z,
float  sx,
float  sy,
int  tile,
float  angle,
bool  flip 
)
inline

Definition at line 253 of file MeshPass.cs.

254 {
255 float num = 1f;
256 float num2 = 1f;
257 int num3 = ((!flip) ? 1 : (-1));
259 Matrix4x4[] matrices = _batch.matrices;
260 matrices[idx].m03 = x + ((0.7f * (0f - num) + 0.7f) * (float)num3 + sx * 0.01f) * (float)num3;
261 matrices[idx].m13 = y + 0.6f * (0f - num2) + 0.6f + sy * 0.01f;
262 matrices[idx].m23 = z;
263 matrices[idx].m00 = num;
264 matrices[idx].m11 = num2;
265 tempV.z = 0f - angle;
266 Quaternion quaternion = Quaternion.Euler(0f, 0f, 0f - angle);
267 tempE.x = 1f - quaternion.z * quaternion.z * 2f;
268 tempE.y = (0f - quaternion.w) * quaternion.z * 2f;
269 matrices[idx].m00 = tempE.x * num;
270 matrices[idx].m01 = tempE.y * num2;
271 matrices[idx].m10 = (0f - tempE.y) * num;
272 matrices[idx].m11 = tempE.x * num2;
273 _batch.tiles[idx] = tile * num3;
274 idx++;
275 if (idx == batchSize)
276 {
277 NextBatch();
278 }
279 }

References _batch, batches, batchIdx, batchSize, idx, MeshBatch.matrices, NextBatch(), tempE, and MeshBatch.tiles.

◆ AddWithScale()

void MeshPass.AddWithScale ( float  x,
float  y,
float  z,
int  tile,
float  scale 
)
inline

Definition at line 177 of file MeshPass.cs.

178 {
180 Matrix4x4[] matrices = _batch.matrices;
181 float num = (0f - scale) / 2f + 0.5f;
182 matrices[idx].m03 = x + num;
183 matrices[idx].m13 = y + num;
184 matrices[idx].m23 = z;
185 matrices[idx].m00 = scale;
186 matrices[idx].m11 = scale;
187 _batch.tiles[idx] = tile;
188 idx++;
189 if (idx == batchSize)
190 {
191 NextBatch();
192 }
193 }

References _batch, batches, batchIdx, batchSize, idx, MeshBatch.matrices, NextBatch(), and MeshBatch.tiles.

◆ Draw()

void MeshPass.Draw ( )
inline

Definition at line 350 of file MeshPass.cs.

351 {
352 if (haveSnowPass)
353 {
354 snowPass.Draw();
355 }
356 if (haveSubPass)
357 {
358 subPass.Draw();
359 }
360 if (haveShadowPass)
361 {
363 }
364 if (idx == 0 && batchIdx == 0)
365 {
366 return;
367 }
368 for (int i = 0; i < batchIdx + 1; i++)
369 {
370 int num = ((i == batchIdx) ? idx : batches[i].size);
371 if (num == 0)
372 {
373 break;
374 }
375 if (setTile)
376 {
377 batches[i].mpb.SetFloatArray("_Tiles", batches[i].tiles);
378 }
379 if (setColor)
380 {
381 batches[i].mpb.SetFloatArray("_Color", batches[i].colors);
382 }
383 if (setMatColor)
384 {
385 batches[i].mpb.SetFloatArray("_MatColor", batches[i].matColors);
386 }
387 if (renderQueue != 0)
388 {
389 if (batches[i].mat == null)
390 {
391 batches[i].mat = new Material(mat);
392 }
393 batches[i].mat.renderQueue = renderQueue + i;
394 Graphics.DrawMeshInstanced(mesh, 0, batches[i].mat, batches[i].matrices, num, batches[i].mpb, ShadowCastingMode.Off, receiveShadows: false, 0, Camera.main);
395 }
396 else
397 {
398 Graphics.DrawMeshInstanced(mesh, 0, mat, batches[i].matrices, num, batches[i].mpb, ShadowCastingMode.Off, receiveShadows: false, 0, Camera.main);
399 }
400 }
403 idx = (batchIdx = 0);
404 if (resize)
405 {
406 Debug.Log("#pass Resize Pass:" + base.name);
407 resize = false;
408 batches[0] = new MeshBatch(this);
409 }
410 }
void Draw()
Definition: MeshPass.cs:350
int lastCount
Definition: MeshPass.cs:43
int lastBatchCount
Definition: MeshPass.cs:45
Material mat
Definition: MeshPass.cs:21
int renderQueue
Definition: MeshPass.cs:37
bool resize
Definition: MeshPass.cs:72

References batches, batchIdx, batchSize, Debug, Draw(), haveShadowPass, haveSnowPass, haveSubPass, idx, lastBatchCount, lastCount, mat, Material, mesh, renderQueue, resize, setColor, setMatColor, setTile, shadowPass, snowPass, and subPass.

Referenced by Draw(), Scene.DrawPass(), and HoardActor.Update().

◆ DrawEmpty()

void MeshPass.DrawEmpty ( )
inline

Definition at line 412 of file MeshPass.cs.

413 {
414 idx = (batchIdx = 0);
415 }

References batchIdx, and idx.

Referenced by Scene.DrawPass().

◆ Init()

void MeshPass.Init ( )
inline

Definition at line 98 of file MeshPass.cs.

99 {
100 batchSize = ((batches.Count > 0) ? batches[0].size : 1023);
101 if (!initialized || mesh == null)
102 {
103 if ((bool)subPass)
104 {
105 subPass.Init();
106 }
107 if ((bool)snowPass)
108 {
109 snowPass.Init();
110 }
111 if ((bool)shadowPass)
112 {
114 }
115 batches.Add(new MeshBatch(this));
116 _Refresh();
117 initialized = true;
118 }
119 idx = (batchIdx = 0);
120 }
void Init()
Definition: MeshPass.cs:98
bool initialized
Definition: MeshPass.cs:69
void _Refresh()
Definition: MeshPass.cs:466

References _Refresh(), batches, batchIdx, batchSize, idx, Init(), initialized, mesh, shadowPass, snowPass, and subPass.

Referenced by HoardActor.Activate(), Init(), Scene.InitPass(), and Refresh().

◆ NextBatch()

◆ OnValidate()

void MeshPass.OnValidate ( )
inline

Definition at line 461 of file MeshPass.cs.

462 {
463 Refresh();
464 }
void Refresh()
Definition: MeshPass.cs:446

References Refresh().

◆ Refresh()

void MeshPass.Refresh ( )
inline

Definition at line 446 of file MeshPass.cs.

447 {
448 if (Application.isPlaying)
449 {
450 UnityEngine.Object.DestroyImmediate(mesh);
451 MeshPass[] passes = Core.Instance.scene.passes;
452 foreach (MeshPass obj in passes)
453 {
454 obj.initialized = false;
455 obj.batches.Clear();
456 obj.Init();
457 }
458 }
459 }
Definition: Core.cs:14
static new Core Instance
Definition: Core.cs:15
Scene scene
Definition: Core.cs:65
MeshPass[] passes
Definition: Scene.cs:115

References batches, Init(), Core.Instance, mesh, Scene.passes, and Core.scene.

Referenced by OnValidate().

◆ SpriteToMesh()

Mesh MeshPass.SpriteToMesh ( Sprite  sprite)
inlineprivate

Definition at line 432 of file MeshPass.cs.

433 {
434 Mesh obj = new Mesh();
435 obj.SetVertices(Array.ConvertAll(sprite.vertices, (Converter<Vector2, Vector3>)((Vector2 c) => c)).ToList());
436 obj.uv = sprite.uv;
437 obj.SetTriangles(Array.ConvertAll(sprite.triangles, (Converter<ushort, int>)((ushort c) => c)), 0);
438 return obj;
439 }

References sprite.

Referenced by _Refresh().

◆ ToString()

override string MeshPass.ToString ( )
inline

Definition at line 441 of file MeshPass.cs.

442 {
443 return base.name;
444 }

Member Data Documentation

◆ _batch

MeshBatch MeshPass._batch
private

Definition at line 77 of file MeshPass.cs.

Referenced by Add(), AddShadow(), AddWithRotation(), and AddWithScale().

◆ _p

MeshPassParam MeshPass._p = new MeshPassParam()

Definition at line 39 of file MeshPass.cs.

◆ batches

◆ batchIdx

◆ batchSize

◆ filter

FilterMode MeshPass.filter

Definition at line 41 of file MeshPass.cs.

◆ first

bool MeshPass.first = true
private

Definition at line 84 of file MeshPass.cs.

◆ haveShadowPass

bool MeshPass.haveShadowPass

Definition at line 51 of file MeshPass.cs.

Referenced by _Refresh(), and Draw().

◆ haveSnowPass

bool MeshPass.haveSnowPass

Definition at line 54 of file MeshPass.cs.

Referenced by _Refresh(), and Draw().

◆ haveSubPass

bool MeshPass.haveSubPass

Definition at line 48 of file MeshPass.cs.

Referenced by _Refresh(), and Draw().

◆ idx

◆ initialized

bool MeshPass.initialized
private

Definition at line 69 of file MeshPass.cs.

Referenced by Init().

◆ lastBatchCount

int MeshPass.lastBatchCount

Definition at line 45 of file MeshPass.cs.

Referenced by Draw().

◆ lastCount

int MeshPass.lastCount

Definition at line 43 of file MeshPass.cs.

Referenced by Draw().

◆ mat

◆ mesh

Mesh MeshPass.mesh

Definition at line 23 of file MeshPass.cs.

Referenced by _Refresh(), Draw(), Init(), and Refresh().

◆ pmesh

◆ preserveTex

Texture MeshPass.preserveTex

Definition at line 75 of file MeshPass.cs.

◆ renderQueue

int MeshPass.renderQueue

Definition at line 37 of file MeshPass.cs.

Referenced by Draw().

◆ resize

bool MeshPass.resize
private

Definition at line 72 of file MeshPass.cs.

Referenced by Draw(), and NextBatch().

◆ setColor

bool MeshPass.setColor

Definition at line 31 of file MeshPass.cs.

Referenced by Add(), Draw(), and MeshBatch.MeshBatch().

◆ setExtra

bool MeshPass.setExtra

Definition at line 35 of file MeshPass.cs.

Referenced by MeshBatch.MeshBatch().

◆ setMatColor

bool MeshPass.setMatColor

Definition at line 33 of file MeshPass.cs.

Referenced by Add(), Draw(), and MeshBatch.MeshBatch().

◆ setTile

bool MeshPass.setTile

Definition at line 29 of file MeshPass.cs.

Referenced by Add(), AddShadow(), and Draw().

◆ shadowPass

MeshPass MeshPass.shadowPass

Definition at line 19 of file MeshPass.cs.

Referenced by _Refresh(), Draw(), RenderData.DrawShadow(), and Init().

◆ snowPass

◆ sprite

Sprite MeshPass.sprite

Definition at line 27 of file MeshPass.cs.

Referenced by _Refresh(), and SpriteToMesh().

◆ subPass

◆ tempE

Vector2 MeshPass.tempE = Vector2.zero
private

Definition at line 81 of file MeshPass.cs.

Referenced by AddShadow(), and AddWithRotation().

◆ tempV

Vector3 MeshPass.tempV = Vector3.zero
private

Definition at line 79 of file MeshPass.cs.

◆ TokenLiquid

const int MeshPass.TokenLiquid = 10000
static

Definition at line 9 of file MeshPass.cs.

◆ TokenLowWall

const int MeshPass.TokenLowWall = 1000000
static

Definition at line 11 of file MeshPass.cs.

◆ TokenLowWallDefault

const int MeshPass.TokenLowWallDefault = 3000000
static

Definition at line 13 of file MeshPass.cs.

Property Documentation

◆ meshX

float MeshPass.meshX
getset

Definition at line 86 of file MeshPass.cs.

87 {
88 get
89 {
90 return pmesh.size.x;
91 }
92 set
93 {
94 pmesh.size.x = value;
95 }
96 }

The documentation for this class was generated from the following file: