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

◆ oceanCave()

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

Definition at line 70364 of file WorldGen.cs.

70365 {
70367 {
70368 GenVars.numOceanCaveTreasure = 0;
70369 }
70370 Vector2D vector2D = default(Vector2D);
70371 vector2D.X = i;
70372 vector2D.Y = j;
70373 Vector2D vector2D2 = default(Vector2D);
70374 if (i < Main.maxTilesX / 2)
70375 {
70376 vector2D2.X = 0.25 + genRand.NextDouble() * 0.25;
70377 }
70378 else
70379 {
70380 vector2D2.X = -0.35 - genRand.NextDouble() * 0.5;
70381 }
70382 vector2D2.Y = 0.4 + genRand.NextDouble() * 0.25;
70383 ushort num = 264;
70384 ushort num12 = 53;
70385 ushort num15 = 397;
70386 double num16 = genRand.Next(17, 25);
70387 double num17 = genRand.Next(600, 800);
70388 double num18 = 4.0;
70389 bool flag = true;
70390 while (num16 > num18 && num17 > 0.0)
70391 {
70392 bool flag2 = true;
70393 bool flag3 = true;
70394 bool flag4 = true;
70395 if (vector2D.X > (double)(beachDistance - 50) && vector2D.X < (double)(Main.maxTilesX - beachDistance + 50))
70396 {
70397 num16 *= 0.96;
70398 num17 *= 0.96;
70399 }
70400 if (num16 < num18 + 2.0 || num17 < 20.0)
70401 {
70402 flag4 = false;
70403 }
70404 if (flag)
70405 {
70406 num16 -= 0.01 + genRand.NextDouble() * 0.01;
70407 num17 -= 0.5;
70408 }
70409 else
70410 {
70411 num16 -= 0.02 + genRand.NextDouble() * 0.02;
70412 num17 -= 1.0;
70413 }
70414 if (flag4)
70415 {
70418 }
70419 int num19 = (int)(vector2D.X - num16 * 3.0);
70420 int num20 = (int)(vector2D.X + num16 * 3.0);
70421 int num21 = (int)(vector2D.Y - num16 * 3.0);
70422 int num2 = (int)(vector2D.Y + num16 * 3.0);
70423 if (num19 < 1)
70424 {
70425 num19 = 1;
70426 }
70427 if (num20 > Main.maxTilesX - 1)
70428 {
70429 num20 = Main.maxTilesX - 1;
70430 }
70431 if (num21 < 1)
70432 {
70433 num21 = 1;
70434 }
70435 if (num2 > Main.maxTilesY - 1)
70436 {
70437 num2 = Main.maxTilesY - 1;
70438 }
70439 for (int k = num19; k < num20; k++)
70440 {
70441 for (int l = num21; l < num2; l++)
70442 {
70443 if (badOceanCaveTiles(k, l))
70444 {
70445 continue;
70446 }
70447 double num3 = new Vector2D(Math.Abs((double)k - vector2D.X), Math.Abs((double)l - vector2D.Y)).Length();
70448 if (flag4 && num3 < num16 * 0.5 + 1.0)
70449 {
70450 Main.tile[k, l].type = num;
70451 Main.tile[k, l].active(active: false);
70452 }
70453 else if (num3 < num16 * 1.5 + 1.0 && Main.tile[k, l].type != num)
70454 {
70455 if ((double)l < vector2D.Y)
70456 {
70457 if ((vector2D2.X < 0.0 && (double)k < vector2D.X) || (vector2D2.X > 0.0 && (double)k > vector2D.X))
70458 {
70459 if (num3 < num16 * 1.1 + 1.0)
70460 {
70461 Main.tile[k, l].type = num15;
70462 if (Main.tile[k, l].liquid == byte.MaxValue)
70463 {
70464 Main.tile[k, l].wall = 0;
70465 }
70466 }
70467 else if (Main.tile[k, l].type != num15)
70468 {
70469 Main.tile[k, l].type = num12;
70470 }
70471 }
70472 }
70473 else if ((vector2D2.X < 0.0 && k < i) || (vector2D2.X > 0.0 && k > i))
70474 {
70475 if (Main.tile[k, l].liquid == byte.MaxValue)
70476 {
70477 Main.tile[k, l].wall = 0;
70478 }
70479 Main.tile[k, l].type = num12;
70480 Main.tile[k, l].active(active: true);
70481 if (k == (int)vector2D.X && flag2)
70482 {
70483 flag2 = false;
70484 int num4 = 50 + genRand.Next(3);
70485 int num5 = 43 + genRand.Next(3);
70486 int num6 = 20 + genRand.Next(3);
70487 int num7 = k;
70488 int num8 = k + num6;
70489 if (vector2D2.X < 0.0)
70490 {
70491 num7 = k - num6;
70492 num8 = k;
70493 }
70494 if (num17 < 100.0)
70495 {
70496 num4 = (int)((double)num4 * (num17 / 100.0));
70497 num5 = (int)((double)num5 * (num17 / 100.0));
70498 num6 = (int)((double)num6 * (num17 / 100.0));
70499 }
70500 if (num16 < num18 + 5.0)
70501 {
70502 double num9 = (num16 - num18) / 5.0;
70503 num4 = (int)((double)num4 * num9);
70504 num5 = (int)((double)num5 * num9);
70505 num6 = (int)((double)num6 * num9);
70506 }
70507 for (int m = num7; m <= num8; m++)
70508 {
70509 for (int n = l; n < l + num4 && !badOceanCaveTiles(m, n); n++)
70510 {
70511 if (n > l + num5)
70512 {
70513 if (SolidTile(m, n) && Main.tile[m, n].type != num12)
70514 {
70515 break;
70516 }
70517 Main.tile[m, n].type = num15;
70518 }
70519 else
70520 {
70521 Main.tile[m, n].type = num12;
70522 }
70523 Main.tile[m, n].active(active: true);
70524 if (genRand.Next(3) == 0)
70525 {
70526 Main.tile[m - 1, n].type = num12;
70527 Main.tile[m - 1, n].active(active: true);
70528 }
70529 if (genRand.Next(3) == 0)
70530 {
70531 Main.tile[m + 1, n].type = num12;
70532 Main.tile[m + 1, n].active(active: true);
70533 }
70534 }
70535 }
70536 }
70537 }
70538 }
70540 {
70541 Main.tile[k, l].liquid = byte.MaxValue;
70542 }
70543 if (!flag3 || k != (int)vector2D.X || !((double)l > vector2D.Y))
70544 {
70545 continue;
70546 }
70547 flag3 = false;
70548 int num10 = 100;
70549 int num11 = 2;
70550 for (int num13 = k - num11; num13 <= k + num11; num13++)
70551 {
70552 for (int num14 = l; num14 < l + num10; num14++)
70553 {
70555 {
70556 Main.tile[num13, num14].liquid = byte.MaxValue;
70557 }
70558 }
70559 }
70560 }
70561 }
70563 vector2D2.X += genRand.NextDouble() * 0.1 - 0.05;
70564 vector2D2.Y += genRand.NextDouble() * 0.1 - 0.05;
70565 if (flag)
70566 {
70567 if (vector2D.Y > (Main.worldSurface * 2.0 + Main.rockLayer) / 3.0 && vector2D.Y > (double)(j + 30))
70568 {
70569 flag = false;
70570 }
70571 vector2D2.Y = Utils.Clamp(vector2D2.Y, 0.35, 1.0);
70572 }
70573 else
70574 {
70575 if (vector2D.X < (double)(Main.maxTilesX / 2))
70576 {
70577 if (vector2D2.X < 0.5)
70578 {
70579 vector2D2.X += 0.02;
70580 }
70581 }
70582 else if (vector2D2.X > -0.5)
70583 {
70584 vector2D2.X -= 0.02;
70585 }
70586 if (!flag4)
70587 {
70588 if (vector2D2.Y < 0.0)
70589 {
70590 vector2D2.Y *= 0.95;
70591 }
70592 vector2D2.Y += 0.04;
70593 }
70594 else if (vector2D.Y < (Main.worldSurface * 4.0 + Main.rockLayer) / 5.0)
70595 {
70596 if (vector2D2.Y < 0.0)
70597 {
70598 vector2D2.Y *= 0.97;
70599 }
70600 vector2D2.Y += 0.02;
70601 }
70602 else if (vector2D2.Y > -0.1)
70603 {
70604 vector2D2.Y *= 0.99;
70605 vector2D2.Y -= 0.01;
70606 }
70607 vector2D2.Y = Utils.Clamp(vector2D2.Y, -1.0, 1.0);
70608 }
70609 if (vector2D.X < (double)(Main.maxTilesX / 2))
70610 {
70611 vector2D2.X = Utils.Clamp(vector2D2.X, 0.1, 1.0);
70612 }
70613 else
70614 {
70615 vector2D2.X = Utils.Clamp(vector2D2.X, -1.0, -0.1);
70616 }
70617 }
70619 }
static readonly int maxOceanCaveTreasure
Definition GenVars.cs:102
static Point[] oceanCaveTreasure
Definition GenVars.cs:106
static UnifiedRandom genRand
Definition WorldGen.cs:1455
static bool badOceanCaveTiles(int x, int y)
static readonly int beachDistance
Definition WorldGen.cs:1166

References 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, and Terraria.Main.worldSurface.