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

◆ SupportedTilesAreFine()

static bool Terraria.GameContent.PortalHelper.SupportedTilesAreFine ( Vector2 portalCenter,
float portalAngle )
inlinestatic

Definition at line 469 of file PortalHelper.cs.

470 {
471 Point point = portalCenter.ToTileCoordinates();
472 int num = (int)Math.Round(MathHelper.WrapAngle(portalAngle) / ((float)Math.PI / 4f));
473 int num2;
474 int num3;
475 switch (num)
476 {
477 case -2:
478 case 2:
479 num2 = ((num != 2) ? 1 : (-1));
480 num3 = 0;
481 break;
482 case 0:
483 case 4:
484 num2 = 0;
485 num3 = ((num == 0) ? 1 : (-1));
486 break;
487 case -3:
488 case 3:
489 num2 = ((num == -3) ? 1 : (-1));
490 num3 = -1;
491 break;
492 case -1:
493 case 1:
494 num2 = ((num == -1) ? 1 : (-1));
495 num3 = 1;
496 break;
497 default:
498 Main.NewText("Broken portal! (over4s = " + num + " , " + portalAngle + ")");
499 return false;
500 }
501 if (num2 != 0 && num3 != 0)
502 {
503 int num4 = 3;
504 if (num2 == -1 && num3 == 1)
505 {
506 num4 = 5;
507 }
508 if (num2 == 1 && num3 == -1)
509 {
510 num4 = 2;
511 }
512 if (num2 == 1 && num3 == 1)
513 {
514 num4 = 4;
515 }
516 num4--;
517 if (SupportedSlope(point.X, point.Y, num4) && SupportedSlope(point.X + num2, point.Y - num3, num4))
518 {
519 return SupportedSlope(point.X - num2, point.Y + num3, num4);
520 }
521 return false;
522 }
523 if (num2 != 0)
524 {
525 if (num2 == 1)
526 {
527 point.X--;
528 }
529 if (SupportedNormal(point.X, point.Y) && SupportedNormal(point.X, point.Y - 1))
530 {
531 return SupportedNormal(point.X, point.Y + 1);
532 }
533 return false;
534 }
535 if (num3 != 0)
536 {
537 if (num3 == 1)
538 {
539 point.Y--;
540 }
541 if (!SupportedNormal(point.X, point.Y) || !SupportedNormal(point.X + 1, point.Y) || !SupportedNormal(point.X - 1, point.Y))
542 {
543 if (SupportedHalfbrick(point.X, point.Y) && SupportedHalfbrick(point.X + 1, point.Y))
544 {
545 return SupportedHalfbrick(point.X - 1, point.Y);
546 }
547 return false;
548 }
549 return true;
550 }
551 return true;
552 }
static float WrapAngle(float angle)
Definition MathHelper.cs:87
static decimal Round(decimal d)
Definition Math.cs:1096
const double PI
Definition Math.cs:16
static bool SupportedHalfbrick(int x, int y)
static bool SupportedSlope(int x, int y, int slope)
static bool SupportedNormal(int x, int y)

References Terraria.Main.NewText(), System.Math.PI, System.Math.Round(), Terraria.GameContent.PortalHelper.SupportedHalfbrick(), Terraria.GameContent.PortalHelper.SupportedNormal(), Terraria.GameContent.PortalHelper.SupportedSlope(), Microsoft.Xna.Framework.MathHelper.WrapAngle(), Microsoft.Xna.Framework.Point.X, and Microsoft.Xna.Framework.Point.Y.

Referenced by Terraria.GameContent.PortalHelper.AddPortal().