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

◆ PlaceChests()

void Terraria.GameContent.Biomes.CaveHouse.HouseBuilder.PlaceChests ( )
inlineprivateinherited

Definition at line 360 of file HouseBuilder.cs.

361 {
363 {
364 return;
365 }
366 bool flag = false;
367 foreach (Rectangle room in Rooms)
368 {
369 int num = room.Height - 1 + room.Y;
370 bool num2 = num > (int)Main.worldSurface;
371 ushort chestTileType = (ushort)((num2 && UsesContainers2) ? 467 : 21);
372 int style = (num2 ? ChestStyle : 0);
373 for (int i = 0; i < 10; i++)
374 {
375 if (flag = WorldGen.AddBuriedChest(_random.Next(2, room.Width - 2) + room.X, num, 0, notNearOtherChests: false, style, trySlope: false, chestTileType))
376 {
377 break;
378 }
379 }
380 if (flag)
381 {
382 break;
383 }
384 for (int j = room.X + 2; j <= room.X + room.Width - 2; j++)
385 {
386 if (flag = WorldGen.AddBuriedChest(j, num, 0, notNearOtherChests: false, style, trySlope: false, chestTileType))
387 {
388 break;
389 }
390 }
391 if (flag)
392 {
393 break;
394 }
395 }
396 if (!flag)
397 {
398 foreach (Rectangle room2 in Rooms)
399 {
400 int num3 = room2.Y - 1;
401 bool num4 = num3 > (int)Main.worldSurface;
402 ushort chestTileType2 = (ushort)((num4 && UsesContainers2) ? 467 : 21);
403 int style2 = (num4 ? ChestStyle : 0);
404 for (int k = 0; k < 10; k++)
405 {
406 if (flag = WorldGen.AddBuriedChest(_random.Next(2, room2.Width - 2) + room2.X, num3, 0, notNearOtherChests: false, style2, trySlope: false, chestTileType2))
407 {
408 break;
409 }
410 }
411 if (flag)
412 {
413 break;
414 }
415 for (int l = room2.X + 2; l <= room2.X + room2.Width - 2; l++)
416 {
417 if (flag = WorldGen.AddBuriedChest(l, num3, 0, notNearOtherChests: false, style2, trySlope: false, chestTileType2))
418 {
419 break;
420 }
421 }
422 if (flag)
423 {
424 break;
425 }
426 }
427 }
428 if (flag)
429 {
430 return;
431 }
432 for (int m = 0; m < 1000; m++)
433 {
434 int i2 = _random.Next(Rooms[0].X - 30, Rooms[0].X + 30);
435 int num5 = _random.Next(Rooms[0].Y - 30, Rooms[0].Y + 30);
436 bool num6 = num5 > (int)Main.worldSurface;
437 ushort chestTileType3 = (ushort)((num6 && UsesContainers2) ? 467 : 21);
438 int style3 = (num6 ? ChestStyle : 0);
439 if (flag = WorldGen.AddBuriedChest(i2, num5, 0, notNearOtherChests: false, style3, trySlope: false, chestTileType3))
440 {
441 break;
442 }
443 }
444 }

References Terraria.GameContent.Biomes.CaveHouse.HouseBuilder._random, Terraria.WorldGen.AddBuriedChest(), Terraria.GameContent.Biomes.CaveHouse.HouseBuilder.ChestChance, Terraria.GameContent.Biomes.CaveHouse.HouseBuilder.ChestStyle, Terraria.Utilities.UnifiedRandom.Next(), Terraria.Utilities.UnifiedRandom.NextDouble(), Terraria.GameContent.Biomes.CaveHouse.HouseBuilder.Rooms, Terraria.GameContent.Biomes.CaveHouse.HouseBuilder.UsesContainers2, Terraria.Main.worldSurface, System.X, and System.Y.

Referenced by Terraria.GameContent.Biomes.CaveHouse.HouseBuilder.Place().