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

◆ DrawFreshAnimations()

void Terraria.HitTile.DrawFreshAnimations ( SpriteBatch spriteBatch)
inline

Definition at line 323 of file HitTile.cs.

324 {
325 for (int i = 0; i < data.Length; i++)
326 {
328 }
329 if (!Main.SettingsEnabled_MinersWobble)
330 {
331 return;
332 }
333 int num = 1;
334 Vector2 vector = new Vector2(Main.offScreenRange);
335 if (Main.drawToScreen)
336 {
337 vector = Vector2.Zero;
338 }
339 vector = Vector2.Zero;
340 bool flag = Main.ShouldShowInvisibleWalls();
341 for (int j = 0; j < data.Length; j++)
342 {
343 if (data[j].type != num)
344 {
345 continue;
346 }
347 int damage = data[j].damage;
348 if (damage < 20)
349 {
350 continue;
351 }
352 int x = data[j].X;
353 int y = data[j].Y;
354 if (!WorldGen.InWorld(x, y))
355 {
356 continue;
357 }
358 Tile tile = Main.tile[x, y];
359 bool flag2 = tile != null;
360 if (flag2 && num == 1)
361 {
362 flag2 = flag2 && tile.active() && Main.tileSolid[Main.tile[x, y].type] && (!tile.invisibleBlock() || flag);
363 }
364 if (flag2 && num == 2)
365 {
366 flag2 = flag2 && tile.wall != 0 && (!tile.invisibleWall() || flag);
367 }
368 if (!flag2)
369 {
370 continue;
371 }
372 bool flag3 = false;
373 bool flag4 = false;
374 if (tile.type == 10)
375 {
376 flag3 = false;
377 }
378 else if (Main.tileSolid[tile.type] && !Main.tileSolidTop[tile.type])
379 {
380 flag3 = true;
381 }
382 else if (WorldGen.IsTreeType(tile.type))
383 {
384 flag4 = true;
385 int num2 = tile.frameX / 22;
386 int num3 = tile.frameY / 22;
387 if (num3 < 9)
388 {
389 flag3 = ((num2 != 1 && num2 != 2) || num3 < 6 || num3 > 8) && (num2 != 3 || num3 > 2) && (num2 != 4 || num3 < 3 || num3 > 5) && ((num2 != 5 || num3 < 6 || num3 > 8) ? true : false);
390 }
391 }
392 else if (tile.type == 72)
393 {
394 flag4 = true;
395 if (tile.frameX <= 34)
396 {
397 flag3 = true;
398 }
399 }
400 if (!flag3 || tile.slope() != 0 || tile.halfBrick())
401 {
402 continue;
403 }
404 int num4 = 0;
405 if (damage >= 80)
406 {
407 num4 = 3;
408 }
409 else if (damage >= 60)
410 {
411 num4 = 2;
412 }
413 else if (damage >= 40)
414 {
415 num4 = 1;
416 }
417 else if (damage >= 20)
418 {
419 num4 = 0;
420 }
421 Rectangle value = new Rectangle(data[j].crackStyle * 18, num4 * 18, 16, 16);
422 value.Inflate(-2, -2);
423 if (flag4)
424 {
425 value.X = (4 + data[j].crackStyle / 2) * 18;
426 }
427 int animationTimeElapsed = data[j].animationTimeElapsed;
428 if (!((float)animationTimeElapsed >= 10f))
429 {
430 float num5 = (float)animationTimeElapsed / 10f;
431 Color color = Lighting.GetColor(x, y);
432 float rotation = 0f;
433 Vector2 zero = Vector2.Zero;
434 float num6 = 0.5f;
435 float num7 = num5 % num6;
436 num7 *= 1f / num6;
437 if ((int)(num5 / num6) % 2 == 1)
438 {
439 num7 = 1f - num7;
440 }
441 Tile tileSafely = Framing.GetTileSafely(x, y);
442 Tile tile2 = tileSafely;
443 Texture2D texture2D = Main.instance.TilePaintSystem.TryGetTileAndRequestIfNotReady(tileSafely.type, 0, tileSafely.color());
444 if (texture2D != null)
445 {
446 Vector2 vector2 = new Vector2(8f);
447 Vector2 vector3 = new Vector2(1f);
448 float num8 = num7 * 0.2f + 1f;
449 float num9 = 1f - num7;
450 num9 = 1f;
451 color *= num9 * num9 * 0.8f;
452 Vector2 scale = num8 * vector3;
453 Vector2 position = (new Vector2(x * 16 - (int)Main.screenPosition.X, y * 16 - (int)Main.screenPosition.Y) + vector + vector2 + zero).Floor();
454 spriteBatch.Draw(texture2D, position, new Rectangle(tile2.frameX, tile2.frameY, 16, 16), color, rotation, vector2, scale, SpriteEffects.None, 0f);
455 color.A = 180;
456 spriteBatch.Draw(TextureAssets.TileCrack.Value, position, value, color, rotation, vector2, scale, SpriteEffects.None, 0f);
457 }
458 }
459 }
460 }
void Draw(Texture2D texture, Vector2 position, Color color)
static Asset< Texture2D > TileCrack
HitTileObject[] data
Definition HitTile.cs:66

References Terraria.Tile.active(), Terraria.HitTile.HitTileObject.animationTimeElapsed, Terraria.Tile.color(), Terraria.HitTile.HitTileObject.crackStyle, Terraria.HitTile.HitTileObject.damage, Terraria.HitTile.data, Microsoft.Xna.Framework.Graphics.SpriteBatch.Draw(), Terraria.Main.drawToScreen, Terraria.Tile.frameX, Terraria.Tile.frameY, Terraria.Lighting.GetColor(), Terraria.Framing.GetTileSafely(), Terraria.Tile.halfBrick(), Terraria.Main.instance, Terraria.Tile.invisibleBlock(), Terraria.Tile.invisibleWall(), Terraria.WorldGen.InWorld(), Terraria.WorldGen.IsTreeType(), Terraria.Main.offScreenRange, Terraria.Main.screenPosition, Terraria.Main.SettingsEnabled_MinersWobble, Terraria.Main.ShouldShowInvisibleWalls(), Terraria.Tile.slope(), Terraria.Main.tile, Terraria.GameContent.TextureAssets.TileCrack, Terraria.Main.tileSolid, Terraria.Main.tileSolidTop, System.type, Terraria.Tile.type, System.value, Microsoft.Xna.Framework.Graphics.Vector2, Terraria.HitTile.HitTileObject.X, Terraria.HitTile.HitTileObject.Y, and Microsoft.Xna.Framework.Vector2.Zero.