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

◆ oceanCave()

static void Terraria.WorldGen.oceanCave ( int i,
int j )
inlinestatic

Definition at line 66402 of file WorldGen.cs.

66403 {
66404 //IL_00f3: Unknown result type (might be due to invalid IL or missing references)
66405 //IL_0104: Unknown result type (might be due to invalid IL or missing references)
66406 //IL_01f9: Unknown result type (might be due to invalid IL or missing references)
66407 //IL_020f: Unknown result type (might be due to invalid IL or missing references)
66408 //IL_0225: Unknown result type (might be due to invalid IL or missing references)
66409 //IL_023b: Unknown result type (might be due to invalid IL or missing references)
66410 //IL_01d2: Unknown result type (might be due to invalid IL or missing references)
66411 //IL_01ed: Unknown result type (might be due to invalid IL or missing references)
66412 //IL_079f: Unknown result type (might be due to invalid IL or missing references)
66413 //IL_07a0: Unknown result type (might be due to invalid IL or missing references)
66414 //IL_07a1: Unknown result type (might be due to invalid IL or missing references)
66415 //IL_07a6: Unknown result type (might be due to invalid IL or missing references)
66416 //IL_085d: Unknown result type (might be due to invalid IL or missing references)
66417 //IL_07fd: Unknown result type (might be due to invalid IL or missing references)
66418 //IL_0894: Unknown result type (might be due to invalid IL or missing references)
66419 //IL_086d: Unknown result type (might be due to invalid IL or missing references)
66420 //IL_0836: Unknown result type (might be due to invalid IL or missing references)
66421 //IL_0824: Unknown result type (might be due to invalid IL or missing references)
66422 //IL_02ac: Unknown result type (might be due to invalid IL or missing references)
66423 //IL_02bb: Unknown result type (might be due to invalid IL or missing references)
66424 //IL_02c7: Unknown result type (might be due to invalid IL or missing references)
66425 //IL_02cc: Unknown result type (might be due to invalid IL or missing references)
66426 //IL_09ba: Unknown result type (might be due to invalid IL or missing references)
66427 //IL_08fb: Unknown result type (might be due to invalid IL or missing references)
66428 //IL_08bd: Unknown result type (might be due to invalid IL or missing references)
66429 //IL_09f2: Unknown result type (might be due to invalid IL or missing references)
66430 //IL_09cc: Unknown result type (might be due to invalid IL or missing references)
66431 //IL_095d: Unknown result type (might be due to invalid IL or missing references)
66432 //IL_0922: Unknown result type (might be due to invalid IL or missing references)
66433 //IL_035b: Unknown result type (might be due to invalid IL or missing references)
66434 //IL_0998: Unknown result type (might be due to invalid IL or missing references)
66435 //IL_0713: Unknown result type (might be due to invalid IL or missing references)
66436 //IL_043c: Unknown result type (might be due to invalid IL or missing references)
66437 //IL_0366: Unknown result type (might be due to invalid IL or missing references)
66438 //IL_071f: Unknown result type (might be due to invalid IL or missing references)
66439 //IL_0452: Unknown result type (might be due to invalid IL or missing references)
66440 //IL_0382: Unknown result type (might be due to invalid IL or missing references)
66441 //IL_037a: Unknown result type (might be due to invalid IL or missing references)
66442 //IL_0399: Unknown result type (might be due to invalid IL or missing references)
66443 //IL_04c6: Unknown result type (might be due to invalid IL or missing references)
66444 //IL_0515: Unknown result type (might be due to invalid IL or missing references)
66446 {
66447 GenVars.numOceanCaveTreasure = 0;
66448 }
66449 Vector2D val = default(Vector2D);
66450 val.X = i;
66451 val.Y = j;
66452 Vector2D val2 = default(Vector2D);
66453 if (i < Main.maxTilesX / 2)
66454 {
66455 val2.X = 0.25 + genRand.NextDouble() * 0.25;
66456 }
66457 else
66458 {
66459 val2.X = -0.35 - genRand.NextDouble() * 0.5;
66460 }
66461 val2.Y = 0.4 + genRand.NextDouble() * 0.25;
66462 ushort num = 264;
66463 ushort num2 = 53;
66464 ushort num3 = 397;
66465 double num4 = genRand.Next(17, 25);
66466 double num5 = genRand.Next(600, 800);
66467 double num6 = 4.0;
66468 bool flag = true;
66469 while (num4 > num6 && num5 > 0.0)
66470 {
66471 bool flag2 = true;
66472 bool flag3 = true;
66473 bool flag4 = true;
66474 if (val.X > (double)(beachDistance - 50) && val.X < (double)(Main.maxTilesX - beachDistance + 50))
66475 {
66476 num4 *= 0.96;
66477 num5 *= 0.96;
66478 }
66479 if (num4 < num6 + 2.0 || num5 < 20.0)
66480 {
66481 flag4 = false;
66482 }
66483 if (flag)
66484 {
66485 num4 -= 0.01 + genRand.NextDouble() * 0.01;
66486 num5 -= 0.5;
66487 }
66488 else
66489 {
66490 num4 -= 0.02 + genRand.NextDouble() * 0.02;
66491 num5 -= 1.0;
66492 }
66493 if (flag4)
66494 {
66497 }
66498 int num7 = (int)(val.X - num4 * 3.0);
66499 int num8 = (int)(val.X + num4 * 3.0);
66500 int num9 = (int)(val.Y - num4 * 3.0);
66501 int num10 = (int)(val.Y + num4 * 3.0);
66502 if (num7 < 1)
66503 {
66504 num7 = 1;
66505 }
66506 if (num8 > Main.maxTilesX - 1)
66507 {
66508 num8 = Main.maxTilesX - 1;
66509 }
66510 if (num9 < 1)
66511 {
66512 num9 = 1;
66513 }
66514 if (num10 > Main.maxTilesY - 1)
66515 {
66516 num10 = Main.maxTilesY - 1;
66517 }
66518 for (int k = num7; k < num8; k++)
66519 {
66520 for (int l = num9; l < num10; l++)
66521 {
66522 if (badOceanCaveTiles(k, l))
66523 {
66524 continue;
66525 }
66526 Vector2D val3 = new Vector2D(Math.Abs((double)k - val.X), Math.Abs((double)l - val.Y));
66527 double num11 = ((Vector2D)(ref val3)).Length();
66528 if (flag4 && num11 < num4 * 0.5 + 1.0)
66529 {
66530 Main.tile[k, l].type = num;
66531 Main.tile[k, l].active(active: false);
66532 }
66533 else if (num11 < num4 * 1.5 + 1.0 && Main.tile[k, l].type != num)
66534 {
66535 if ((double)l < val.Y)
66536 {
66537 if ((val2.X < 0.0 && (double)k < val.X) || (val2.X > 0.0 && (double)k > val.X))
66538 {
66539 if (num11 < num4 * 1.1 + 1.0)
66540 {
66541 Main.tile[k, l].type = num3;
66542 if (Main.tile[k, l].liquid == byte.MaxValue)
66543 {
66544 Main.tile[k, l].wall = 0;
66545 }
66546 }
66547 else if (Main.tile[k, l].type != num3)
66548 {
66549 Main.tile[k, l].type = num2;
66550 }
66551 }
66552 }
66553 else if ((val2.X < 0.0 && k < i) || (val2.X > 0.0 && k > i))
66554 {
66555 if (Main.tile[k, l].liquid == byte.MaxValue)
66556 {
66557 Main.tile[k, l].wall = 0;
66558 }
66559 Main.tile[k, l].type = num2;
66560 Main.tile[k, l].active(active: true);
66561 if (k == (int)val.X && flag2)
66562 {
66563 flag2 = false;
66564 int num12 = 50 + genRand.Next(3);
66565 int num13 = 43 + genRand.Next(3);
66566 int num14 = 20 + genRand.Next(3);
66567 int num15 = k;
66568 int num16 = k + num14;
66569 if (val2.X < 0.0)
66570 {
66571 num15 = k - num14;
66572 num16 = k;
66573 }
66574 if (num5 < 100.0)
66575 {
66576 num12 = (int)((double)num12 * (num5 / 100.0));
66577 num13 = (int)((double)num13 * (num5 / 100.0));
66578 num14 = (int)((double)num14 * (num5 / 100.0));
66579 }
66580 if (num4 < num6 + 5.0)
66581 {
66582 double num17 = (num4 - num6) / 5.0;
66583 num12 = (int)((double)num12 * num17);
66584 num13 = (int)((double)num13 * num17);
66585 num14 = (int)((double)num14 * num17);
66586 }
66587 for (int m = num15; m <= num16; m++)
66588 {
66589 for (int n = l; n < l + num12 && !badOceanCaveTiles(m, n); n++)
66590 {
66591 if (n > l + num13)
66592 {
66593 if (SolidTile(m, n) && Main.tile[m, n].type != num2)
66594 {
66595 break;
66596 }
66597 Main.tile[m, n].type = num3;
66598 }
66599 else
66600 {
66601 Main.tile[m, n].type = num2;
66602 }
66603 Main.tile[m, n].active(active: true);
66604 if (genRand.Next(3) == 0)
66605 {
66606 Main.tile[m - 1, n].type = num2;
66607 Main.tile[m - 1, n].active(active: true);
66608 }
66609 if (genRand.Next(3) == 0)
66610 {
66611 Main.tile[m + 1, n].type = num2;
66612 Main.tile[m + 1, n].active(active: true);
66613 }
66614 }
66615 }
66616 }
66617 }
66618 }
66620 {
66621 Main.tile[k, l].liquid = byte.MaxValue;
66622 }
66623 if (!flag3 || k != (int)val.X || !((double)l > val.Y))
66624 {
66625 continue;
66626 }
66627 flag3 = false;
66628 int num18 = 100;
66629 int num19 = 2;
66630 for (int num20 = k - num19; num20 <= k + num19; num20++)
66631 {
66632 for (int num21 = l; num21 < l + num18; num21++)
66633 {
66635 {
66636 Main.tile[num20, num21].liquid = byte.MaxValue;
66637 }
66638 }
66639 }
66640 }
66641 }
66642 val += val2;
66643 val2.X += genRand.NextDouble() * 0.1 - 0.05;
66644 val2.Y += genRand.NextDouble() * 0.1 - 0.05;
66645 if (flag)
66646 {
66647 if (val.Y > (Main.worldSurface * 2.0 + Main.rockLayer) / 3.0 && val.Y > (double)(j + 30))
66648 {
66649 flag = false;
66650 }
66651 val2.Y = Utils.Clamp(val2.Y, 0.35, 1.0);
66652 }
66653 else
66654 {
66655 if (val.X < (double)(Main.maxTilesX / 2))
66656 {
66657 if (val2.X < 0.5)
66658 {
66659 val2.X += 0.02;
66660 }
66661 }
66662 else if (val2.X > -0.5)
66663 {
66664 val2.X -= 0.02;
66665 }
66666 if (!flag4)
66667 {
66668 if (val2.Y < 0.0)
66669 {
66670 val2.Y *= 0.95;
66671 }
66672 val2.Y += 0.04;
66673 }
66674 else if (val.Y < (Main.worldSurface * 4.0 + Main.rockLayer) / 5.0)
66675 {
66676 if (val2.Y < 0.0)
66677 {
66678 val2.Y *= 0.97;
66679 }
66680 val2.Y += 0.02;
66681 }
66682 else if (val2.Y > -0.1)
66683 {
66684 val2.Y *= 0.99;
66685 val2.Y -= 0.01;
66686 }
66687 val2.Y = Utils.Clamp(val2.Y, -1.0, 1.0);
66688 }
66689 if (val.X < (double)(Main.maxTilesX / 2))
66690 {
66691 val2.X = Utils.Clamp(val2.X, 0.1, 1.0);
66692 }
66693 else
66694 {
66695 val2.X = Utils.Clamp(val2.X, -1.0, -0.1);
66696 }
66697 }
66699 }
static double Abs(double value)
static readonly int maxOceanCaveTreasure
Definition GenVars.cs:102
static Point[] oceanCaveTreasure
Definition GenVars.cs:106
static UnifiedRandom genRand
Definition WorldGen.cs:1215
static bool badOceanCaveTiles(int x, int y)
static readonly int beachDistance
Definition WorldGen.cs:928

References System.Math.Abs(), Terraria.WorldBuilding.GenVars.maxOceanCaveTreasure, Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.WorldBuilding.GenVars.numOceanCaveTreasure, Terraria.WorldBuilding.GenVars.oceanCaveTreasure, Terraria.Main.rockLayer, Terraria.Enums.SolidTile, Terraria.Main.tile, Terraria.Main.worldSurface, ReLogic.Utilities.Vector2D.X, and ReLogic.Utilities.Vector2D.Y.