TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ DrawWaves()

void Terraria.GameContent.Shaders.WaterShaderData.DrawWaves ( )
inlineprivate

Definition at line 237 of file WaterShaderData.cs.

238 {
239 //IL_0000: Unknown result type (might be due to invalid IL or missing references)
240 //IL_0005: Unknown result type (might be due to invalid IL or missing references)
241 //IL_0020: Unknown result type (might be due to invalid IL or missing references)
242 //IL_0019: Unknown result type (might be due to invalid IL or missing references)
243 //IL_0025: Unknown result type (might be due to invalid IL or missing references)
244 //IL_0027: Unknown result type (might be due to invalid IL or missing references)
245 //IL_002c: Unknown result type (might be due to invalid IL or missing references)
246 //IL_0036: Unknown result type (might be due to invalid IL or missing references)
247 //IL_003b: Unknown result type (might be due to invalid IL or missing references)
248 //IL_003c: Unknown result type (might be due to invalid IL or missing references)
249 //IL_0041: Unknown result type (might be due to invalid IL or missing references)
250 //IL_08bc: Unknown result type (might be due to invalid IL or missing references)
251 //IL_08c1: Unknown result type (might be due to invalid IL or missing references)
252 //IL_08c2: Unknown result type (might be due to invalid IL or missing references)
253 //IL_08c7: Unknown result type (might be due to invalid IL or missing references)
254 //IL_08d6: Unknown result type (might be due to invalid IL or missing references)
255 //IL_08db: Unknown result type (might be due to invalid IL or missing references)
256 //IL_08ea: Unknown result type (might be due to invalid IL or missing references)
257 //IL_08ef: Unknown result type (might be due to invalid IL or missing references)
258 //IL_0901: Unknown result type (might be due to invalid IL or missing references)
259 //IL_0908: Unknown result type (might be due to invalid IL or missing references)
260 //IL_090f: Unknown result type (might be due to invalid IL or missing references)
261 //IL_0916: Unknown result type (might be due to invalid IL or missing references)
262 //IL_091d: Unknown result type (might be due to invalid IL or missing references)
263 //IL_0927: Unknown result type (might be due to invalid IL or missing references)
264 //IL_092c: Unknown result type (might be due to invalid IL or missing references)
265 //IL_0940: Unknown result type (might be due to invalid IL or missing references)
266 //IL_094a: Unknown result type (might be due to invalid IL or missing references)
267 //IL_0954: Unknown result type (might be due to invalid IL or missing references)
268 //IL_095e: Unknown result type (might be due to invalid IL or missing references)
269 //IL_00ee: Unknown result type (might be due to invalid IL or missing references)
270 //IL_00ef: Unknown result type (might be due to invalid IL or missing references)
271 //IL_00f9: Unknown result type (might be due to invalid IL or missing references)
272 //IL_00fe: Unknown result type (might be due to invalid IL or missing references)
273 //IL_0100: Unknown result type (might be due to invalid IL or missing references)
274 //IL_010d: Unknown result type (might be due to invalid IL or missing references)
275 //IL_0112: Unknown result type (might be due to invalid IL or missing references)
276 //IL_0114: Unknown result type (might be due to invalid IL or missing references)
277 //IL_0441: Unknown result type (might be due to invalid IL or missing references)
278 //IL_0442: Unknown result type (might be due to invalid IL or missing references)
279 //IL_044c: Unknown result type (might be due to invalid IL or missing references)
280 //IL_0451: Unknown result type (might be due to invalid IL or missing references)
281 //IL_0453: Unknown result type (might be due to invalid IL or missing references)
282 //IL_0460: Unknown result type (might be due to invalid IL or missing references)
283 //IL_0465: Unknown result type (might be due to invalid IL or missing references)
284 //IL_0467: Unknown result type (might be due to invalid IL or missing references)
285 //IL_012f: Unknown result type (might be due to invalid IL or missing references)
286 //IL_0134: Unknown result type (might be due to invalid IL or missing references)
287 //IL_0135: Unknown result type (might be due to invalid IL or missing references)
288 //IL_013a: Unknown result type (might be due to invalid IL or missing references)
289 //IL_013e: Unknown result type (might be due to invalid IL or missing references)
290 //IL_0153: Unknown result type (might be due to invalid IL or missing references)
291 //IL_0159: Unknown result type (might be due to invalid IL or missing references)
292 //IL_015b: Unknown result type (might be due to invalid IL or missing references)
293 //IL_0170: Unknown result type (might be due to invalid IL or missing references)
294 //IL_0175: Unknown result type (might be due to invalid IL or missing references)
295 //IL_017a: Unknown result type (might be due to invalid IL or missing references)
296 //IL_01c1: Unknown result type (might be due to invalid IL or missing references)
297 //IL_01c8: Unknown result type (might be due to invalid IL or missing references)
298 //IL_01cd: Unknown result type (might be due to invalid IL or missing references)
299 //IL_01d2: Unknown result type (might be due to invalid IL or missing references)
300 //IL_01ed: Unknown result type (might be due to invalid IL or missing references)
301 //IL_01f2: Unknown result type (might be due to invalid IL or missing references)
302 //IL_01fb: Unknown result type (might be due to invalid IL or missing references)
303 //IL_01fd: Unknown result type (might be due to invalid IL or missing references)
304 //IL_0204: Unknown result type (might be due to invalid IL or missing references)
305 //IL_0209: Unknown result type (might be due to invalid IL or missing references)
306 //IL_020e: Unknown result type (might be due to invalid IL or missing references)
307 //IL_0482: Unknown result type (might be due to invalid IL or missing references)
308 //IL_0487: Unknown result type (might be due to invalid IL or missing references)
309 //IL_0488: Unknown result type (might be due to invalid IL or missing references)
310 //IL_048d: Unknown result type (might be due to invalid IL or missing references)
311 //IL_04b0: Unknown result type (might be due to invalid IL or missing references)
312 //IL_04b5: Unknown result type (might be due to invalid IL or missing references)
313 //IL_04be: Unknown result type (might be due to invalid IL or missing references)
314 //IL_04c0: Unknown result type (might be due to invalid IL or missing references)
315 //IL_04c7: Unknown result type (might be due to invalid IL or missing references)
316 //IL_04cc: Unknown result type (might be due to invalid IL or missing references)
317 //IL_04d1: Unknown result type (might be due to invalid IL or missing references)
318 //IL_024b: Unknown result type (might be due to invalid IL or missing references)
319 //IL_0252: Unknown result type (might be due to invalid IL or missing references)
320 //IL_0275: Unknown result type (might be due to invalid IL or missing references)
321 //IL_027f: Unknown result type (might be due to invalid IL or missing references)
322 //IL_028e: Unknown result type (might be due to invalid IL or missing references)
323 //IL_02a1: Unknown result type (might be due to invalid IL or missing references)
324 //IL_02bc: Unknown result type (might be due to invalid IL or missing references)
325 //IL_02e8: Unknown result type (might be due to invalid IL or missing references)
326 //IL_050e: Unknown result type (might be due to invalid IL or missing references)
327 //IL_052a: Unknown result type (might be due to invalid IL or missing references)
328 //IL_0562: Unknown result type (might be due to invalid IL or missing references)
329 //IL_056c: Unknown result type (might be due to invalid IL or missing references)
330 //IL_0571: Unknown result type (might be due to invalid IL or missing references)
331 //IL_0584: Unknown result type (might be due to invalid IL or missing references)
332 //IL_059f: Unknown result type (might be due to invalid IL or missing references)
333 //IL_06f8: Unknown result type (might be due to invalid IL or missing references)
334 //IL_06f9: Unknown result type (might be due to invalid IL or missing references)
335 //IL_06fd: Unknown result type (might be due to invalid IL or missing references)
336 //IL_0702: Unknown result type (might be due to invalid IL or missing references)
337 //IL_0704: Unknown result type (might be due to invalid IL or missing references)
338 //IL_070b: Unknown result type (might be due to invalid IL or missing references)
339 //IL_0710: Unknown result type (might be due to invalid IL or missing references)
340 //IL_0712: Unknown result type (might be due to invalid IL or missing references)
341 //IL_033f: Unknown result type (might be due to invalid IL or missing references)
342 //IL_0344: Unknown result type (might be due to invalid IL or missing references)
343 //IL_0348: Unknown result type (might be due to invalid IL or missing references)
344 //IL_034d: Unknown result type (might be due to invalid IL or missing references)
345 //IL_05de: Unknown result type (might be due to invalid IL or missing references)
346 //IL_05e3: Unknown result type (might be due to invalid IL or missing references)
347 //IL_05e7: Unknown result type (might be due to invalid IL or missing references)
348 //IL_05ec: Unknown result type (might be due to invalid IL or missing references)
349 //IL_0774: Unknown result type (might be due to invalid IL or missing references)
350 //IL_0779: Unknown result type (might be due to invalid IL or missing references)
351 //IL_077a: Unknown result type (might be due to invalid IL or missing references)
352 //IL_077f: Unknown result type (might be due to invalid IL or missing references)
353 //IL_07a8: Unknown result type (might be due to invalid IL or missing references)
354 //IL_07ad: Unknown result type (might be due to invalid IL or missing references)
355 //IL_072c: Unknown result type (might be due to invalid IL or missing references)
356 //IL_0746: Unknown result type (might be due to invalid IL or missing references)
357 //IL_0382: Unknown result type (might be due to invalid IL or missing references)
358 //IL_038c: Unknown result type (might be due to invalid IL or missing references)
359 //IL_03b0: Unknown result type (might be due to invalid IL or missing references)
360 //IL_03cc: Unknown result type (might be due to invalid IL or missing references)
361 //IL_080e: Unknown result type (might be due to invalid IL or missing references)
362 //IL_081e: Unknown result type (might be due to invalid IL or missing references)
363 //IL_0832: Unknown result type (might be due to invalid IL or missing references)
364 //IL_083c: Unknown result type (might be due to invalid IL or missing references)
365 //IL_0841: Unknown result type (might be due to invalid IL or missing references)
366 //IL_0854: Unknown result type (might be due to invalid IL or missing references)
367 //IL_086f: Unknown result type (might be due to invalid IL or missing references)
368 //IL_0625: Unknown result type (might be due to invalid IL or missing references)
369 //IL_0641: Unknown result type (might be due to invalid IL or missing references)
370 Vector2 screenPosition = Main.screenPosition;
371 Vector2 vector = (Vector2)(Main.drawToScreen ? Vector2.Zero : new Vector2((float)Main.offScreenRange, (float)Main.offScreenRange));
372 Vector2 vector2 = -_lastDistortionDrawOffset / 0.25f + vector;
373 TileBatch tileBatch = Main.tileBatch;
374 _ = ((Game)Main.instance).GraphicsDevice;
375 Vector2 dimensions = default(Vector2);
376 ((Vector2)(ref dimensions))._002Ector((float)Main.screenWidth, (float)Main.screenHeight);
377 Vector2 vector3 = default(Vector2);
378 ((Vector2)(ref vector3))._002Ector(16f, 16f);
379 tileBatch.Begin();
380 GameShaders.Misc["WaterDistortionObject"].Apply();
381 if (_useNPCWaves)
382 {
383 for (int i = 0; i < 200; i++)
384 {
385 if (Main.npc[i] == null || !Main.npc[i].active || (!Main.npc[i].wet && Main.npc[i].wetCount == 0) || !Collision.CheckAABBvAABBCollision(screenPosition, dimensions, Main.npc[i].position - vector3, Main.npc[i].Size + vector3))
386 {
387 continue;
388 }
389 NPC nPC = Main.npc[i];
390 Vector2 vector4 = nPC.Center - vector2;
391 Vector2 velocity4 = nPC.velocity;
392 double radians = 0f - nPC.rotation;
393 Vector2 center = default(Vector2);
394 Vector2 vector5 = velocity4.RotatedBy(radians, center) / new Vector2((float)nPC.height, (float)nPC.width);
395 float num = ((Vector2)(ref vector5)).LengthSquared();
396 num = num * 0.3f + 0.7f * num * (1024f / (float)(nPC.height * nPC.width));
397 num = Math.Min(num, 0.08f);
398 float num8 = num;
399 center = nPC.velocity - nPC.oldVelocity;
400 num = num8 + ((Vector2)(ref center)).Length() * 0.5f;
401 ((Vector2)(ref vector5)).Normalize();
402 Vector2 velocity = nPC.velocity;
403 ((Vector2)(ref velocity)).Normalize();
404 vector4 -= velocity * 10f;
405 if (!_useViscosityFilter && (nPC.honeyWet || nPC.lavaWet))
406 {
407 num *= 0.3f;
408 }
409 if (nPC.wet)
410 {
411 tileBatch.Draw(TextureAssets.MagicPixel.Value, new Vector4(vector4.X, vector4.Y, (float)nPC.width * 2f, (float)nPC.height * 2f) * 0.25f, null, new VertexColors(new Color(vector5.X * 0.5f + 0.5f, vector5.Y * 0.5f + 0.5f, 0.5f * num)), new Vector2((float)TextureAssets.MagicPixel.Width() / 2f, (float)TextureAssets.MagicPixel.Height() / 2f), (SpriteEffects)0, nPC.rotation);
412 }
413 if (nPC.wetCount != 0)
414 {
415 num = ((Vector2)(ref nPC.velocity)).Length();
416 num = 0.195f * (float)Math.Sqrt(num);
417 float num2 = 5f;
418 if (!nPC.wet)
419 {
420 num2 = -20f;
421 }
422 QueueRipple(nPC.Center + velocity * num2, new Color(0.5f, (nPC.wet ? num : (0f - num)) * 0.5f + 0.5f, 0f, 1f) * 0.5f, new Vector2((float)nPC.width, (float)nPC.height * ((float)(int)nPC.wetCount / 9f)) * MathHelper.Clamp(num * 10f, 0f, 1f), RippleShape.Circle);
423 }
424 }
425 }
426 if (_usePlayerWaves)
427 {
428 for (int j = 0; j < 255; j++)
429 {
430 if (Main.player[j] == null || !Main.player[j].active || (!Main.player[j].wet && Main.player[j].wetCount == 0) || !Collision.CheckAABBvAABBCollision(screenPosition, dimensions, Main.player[j].position - vector3, Main.player[j].Size + vector3))
431 {
432 continue;
433 }
434 Player player = Main.player[j];
435 Vector2 vector6 = player.Center - vector2;
436 float num3 = ((Vector2)(ref player.velocity)).Length();
437 num3 = 0.05f * (float)Math.Sqrt(num3);
438 Vector2 velocity2 = player.velocity;
439 ((Vector2)(ref velocity2)).Normalize();
440 vector6 -= velocity2 * 10f;
441 if (!_useViscosityFilter && (player.honeyWet || player.lavaWet))
442 {
443 num3 *= 0.3f;
444 }
445 if (player.wet)
446 {
447 tileBatch.Draw(TextureAssets.MagicPixel.Value, new Vector4(vector6.X - (float)player.width * 2f * 0.5f, vector6.Y - (float)player.height * 2f * 0.5f, (float)player.width * 2f, (float)player.height * 2f) * 0.25f, new VertexColors(new Color(velocity2.X * 0.5f + 0.5f, velocity2.Y * 0.5f + 0.5f, 0.5f * num3)));
448 }
449 if (player.wetCount != 0)
450 {
451 float num4 = 5f;
452 if (!player.wet)
453 {
454 num4 = -20f;
455 }
456 num3 *= 3f;
457 QueueRipple(player.Center + velocity2 * num4, player.wet ? num3 : (0f - num3), new Vector2((float)player.width, (float)player.height * ((float)(int)player.wetCount / 9f)) * MathHelper.Clamp(num3 * 10f, 0f, 1f), RippleShape.Circle);
458 }
459 }
460 }
462 {
463 for (int k = 0; k < 1000; k++)
464 {
465 Projectile projectile = Main.projectile[k];
466 if (projectile.wet && !projectile.lavaWet)
467 {
468 _ = projectile.honeyWet;
469 }
470 bool flag = projectile.lavaWet;
471 bool flag2 = projectile.honeyWet;
472 bool flag3 = projectile.wet;
473 if (projectile.ignoreWater)
474 {
475 flag3 = true;
476 }
477 if (!(projectile != null && projectile.active && ProjectileID.Sets.CanDistortWater[projectile.type] && flag3) || ProjectileID.Sets.NoLiquidDistortion[projectile.type] || !Collision.CheckAABBvAABBCollision(screenPosition, dimensions, projectile.position - vector3, projectile.Size + vector3))
478 {
479 continue;
480 }
481 if (projectile.ignoreWater)
482 {
483 bool num9 = Collision.LavaCollision(projectile.position, projectile.width, projectile.height);
484 flag = Collision.WetCollision(projectile.position, projectile.width, projectile.height);
485 flag2 = Collision.honey;
486 if (!(num9 || flag || flag2))
487 {
488 continue;
489 }
490 }
491 Vector2 vector7 = projectile.Center - vector2;
492 float num5 = ((Vector2)(ref projectile.velocity)).Length();
493 num5 = 2f * (float)Math.Sqrt(0.05f * num5);
494 Vector2 velocity3 = projectile.velocity;
495 ((Vector2)(ref velocity3)).Normalize();
496 if (!_useViscosityFilter && (flag2 || flag))
497 {
498 num5 *= 0.3f;
499 }
500 float num6 = Math.Max(12f, (float)projectile.width * 0.75f);
501 float num7 = Math.Max(12f, (float)projectile.height * 0.75f);
502 tileBatch.Draw(TextureAssets.MagicPixel.Value, new Vector4(vector7.X - num6 * 0.5f, vector7.Y - num7 * 0.5f, num6, num7) * 0.25f, new VertexColors(new Color(velocity3.X * 0.5f + 0.5f, velocity3.Y * 0.5f + 0.5f, num5 * 0.5f)));
503 }
504 }
505 tileBatch.End();
506 if (_useRippleWaves)
507 {
508 tileBatch.Begin();
509 for (int l = 0; l < _rippleQueueCount; l++)
510 {
512 Vector2 size = _rippleQueue[l].Size;
514 Texture2D value = _rippleShapeTexture.Value;
515 tileBatch.Draw(value, new Vector4(vector8.X, vector8.Y, size.X, size.Y) * 0.25f, sourceRectangle, new VertexColors(_rippleQueue[l].WaveData), new Vector2((float)(sourceRectangle.Width / 2), (float)(sourceRectangle.Height / 2)), (SpriteEffects)0, _rippleQueue[l].Rotation);
516 }
517 tileBatch.End();
518 }
520 if (_useCustomWaves && this.OnWaveDraw != null)
521 {
522 tileBatch.Begin();
523 this.OnWaveDraw(tileBatch);
524 tileBatch.End();
525 }
526 }
void QueueRipple(Vector2 position, float strength=1f, RippleShape shape=RippleShape.Square, float rotation=0f)
static Dictionary< string, MiscShaderData > Misc
void Draw(Texture2D texture, Vector2 position, VertexColors colors)
Definition TileBatch.cs:173
void Begin(RasterizerState rasterizer, Matrix transformation)
Definition TileBatch.cs:101
static bool[] CanDistortWater
If true for a given projectile type (F:Terraria.Projectile.type), then that projectile can create wav...
static bool[] NoLiquidDistortion
If true for a given projectile type (F:Terraria.Projectile.type), then that projectile will never dis...

References Terraria.GameContent.Shaders.WaterShaderData._lastDistortionDrawOffset, Terraria.GameContent.Shaders.WaterShaderData._rippleQueue, Terraria.GameContent.Shaders.WaterShaderData._rippleQueueCount, Terraria.GameContent.Shaders.WaterShaderData._rippleShapeTexture, Terraria.GameContent.Shaders.WaterShaderData._useCustomWaves, Terraria.GameContent.Shaders.WaterShaderData._useNPCWaves, Terraria.GameContent.Shaders.WaterShaderData._usePlayerWaves, Terraria.GameContent.Shaders.WaterShaderData._useProjectileWaves, Terraria.GameContent.Shaders.WaterShaderData._useRippleWaves, Terraria.GameContent.Shaders.WaterShaderData._useViscosityFilter, Terraria.Entity.active, Terraria.Graphics.TileBatch.Begin(), Terraria.ID.ProjectileID.Sets.CanDistortWater, Terraria.Entity.Center, Terraria.Collision.CheckAABBvAABBCollision(), Terraria.Graphics.Light.Color, Terraria.Graphics.TileBatch.Draw(), Terraria.Main.drawToScreen, Terraria.Graphics.TileBatch.End(), Terraria.Entity.height, Terraria.Collision.honey, Terraria.Entity.honeyWet, Terraria.Projectile.ignoreWater, Terraria.Main.instance, Terraria.Collision.LavaCollision(), Terraria.Entity.lavaWet, Terraria.GameContent.TextureAssets.MagicPixel, Terraria.Graphics.Shaders.GameShaders.Misc, Terraria.ID.ProjectileID.Sets.NoLiquidDistortion, Terraria.Main.npc, Terraria.Main.offScreenRange, Terraria.GameContent.Shaders.WaterShaderData.OnWaveDraw, Terraria.Main.player, Terraria.GameContent.Shaders.WaterShaderData.Ripple.Position, Terraria.Entity.position, Terraria.Main.projectile, Terraria.GameContent.Shaders.WaterShaderData.QueueRipple(), Terraria.Main.screenHeight, Terraria.Main.screenPosition, Terraria.Main.screenWidth, Terraria.GameContent.Shaders.WaterShaderData.Ripple.Size, Terraria.Entity.Size, Terraria.GameContent.Shaders.WaterShaderData.Ripple.SourceRectangle, Terraria.Main.tileBatch, Terraria.Projectile.type, Terraria.Entity.velocity, Terraria.Entity.wet, Terraria.Collision.WetCollision(), Terraria.Entity.wetCount, and Terraria.Entity.width.

Referenced by Terraria.GameContent.Shaders.WaterShaderData.StepLiquids().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: