-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMyWorld.cs
1615 lines (1465 loc) · 62 KB
/
MyWorld.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using Microsoft.Xna.Framework;
using SpiritMod.Items.Accessory;
using SpiritMod.Items.Ammo.Arrow;
using SpiritMod.Items.Consumable;
using SpiritMod.Items.Equipment;
using SpiritMod.Items.Glyphs;
using SpiritMod.Items.Material;
using SpiritMod.Items.Placeable;
using SpiritMod.Items.Placeable.Tiles;
using SpiritMod.Items.Sets.BriarChestLoot;
using SpiritMod.Items.Sets.ToolsMisc.Evergreen;
using SpiritMod.Items.Weapon.Summon;
using SpiritMod.Items.Weapon.Swung;
using SpiritMod.Items.Weapon.Magic.CreepingVine;
using SpiritMod.Items.Books;
using SpiritMod.Items.Books.MaterialPages;
using SpiritMod.Items.Weapon.Thrown;
using SpiritMod.NPCs.Town;
using SpiritMod.Tiles.Ambient;
using SpiritMod.Tiles.Ambient.SpaceCrystals;
using SpiritMod.Tiles.Block;
using SpiritMod.Tiles.Furniture;
using SpiritMod.Tiles.Furniture.SpaceJunk;
using SpiritMod.World;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Terraria;
using Terraria.GameContent.Generation;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
using SpiritMod.World.Sepulchre;
using SpiritMod.Tiles;
using Terraria.DataStructures;
using SpiritMod.Utilities;
using SpiritMod.Items.Sets.SepulchreLoot.AccursedBlade;
using SpiritMod.Items.Sets.SepulchreLoot.OldCross;
using SpiritMod.Mechanics.BackgroundSystem;
using SpiritMod.Items.Sets.SummonsMisc.Toucane;
using SpiritMod.Effects.SurfaceWaterModifications;
using SpiritMod.Mechanics.QuestSystem;
using Terraria.WorldBuilding;
using Terraria.IO;
using static SpiritMod.Utilities.ChestPoolUtils;
using Terraria.GameContent.Events;
using SpiritMod.Items.Equipment.ZiplineGun;
using SpiritMod.Items.DonatorItems;
using Terraria.Localization;
using Terraria.Chat;
using SpiritMod.NPCs;
using SpiritMod.NPCs.Boss.Scarabeus;
using SpiritMod.NPCs.Boss;
using SpiritMod.NPCs.Boss.SteamRaider;
using SpiritMod.NPCs.Boss.Atlas;
using SpiritMod.NPCs.Boss.Infernon;
using SpiritMod.NPCs.Boss.MoonWizard;
using SpiritMod.NPCs.Boss.ReachBoss;
using SpiritMod.NPCs.Boss.Dusking;
namespace SpiritMod;
public class MyWorld : ModSystem
{
public static float rotationTime = 0;
private static bool dayTimeLast;
public static bool dayTimeSwitched;
public static bool aurora = false;
public static bool ashRain = false;
public static int auroraType = 1;
public static int auroraTypeFixed;
public static int auroraChance = 4;
public static bool luminousOcean = false;
public static bool calmNight = false;
public static int luminousType = 1;
private static bool wasLanternNight = false;
public static bool VictoryDay => wasLanternNight && Main.dayTime;
public static bool stardustWeather = false;
public static bool spaceJunkWeather = false;
public static bool meteorShowerWeather = false;
public static float asteroidLight = 0;
public static float spiritLight = 0;
public static bool blueMoon = false;
public static bool jellySky = false;
public static bool rareStarfallEvent = false;
public static int CorruptHazards = 0;
public static int CrimHazards = 0;
public static bool spiritBiome = false;
public static bool rockCandy = false;
public static int asteroidSide = 0;
public static bool gennedTower = false;
public static bool gennedBandits = false;
public static bool DownedScarabeus => BossDownedTracker.IsBossDowned<Scarabeus>();
public static bool DownedAncientAvian => BossDownedTracker.IsBossDowned<AncientFlyer>();
public static bool DownedStarplate => BossDownedTracker.IsBossDowned<SteamRaiderHead>();
public static bool DownedAtlas => BossDownedTracker.IsBossDowned<Atlas>();
public static bool DownedInfernon => BossDownedTracker.IsBossDowned<InfernoSkull>();
public static bool DownedMoonWizard => BossDownedTracker.IsBossDowned<MoonWizard>();
public static bool DownedVinewrath => BossDownedTracker.IsBossDowned<ReachBoss1>();
public static bool DownedDusking => BossDownedTracker.IsBossDowned<Dusking>();
// These aren't bosses and so aren't tracked with BossDownedTracker
public static bool downedMechromancer = false;
public static bool downedOccultist = false;
public static bool downedGladeWraith = false;
public static bool downedTome = false;
public static bool downedSnaptrapper = false;
public static bool downedBeholder = false;
public static bool downedJellyDeluge = false;
public static bool downedTide = false;
public static bool downedBlueMoon = false;
public static bool downedGazer = false;
public static Point pagodaLocation;
public static Dictionary<string, bool> droppedGlyphs = new Dictionary<string, bool>();
public static HashSet<Point16> superSunFlowerPositions = new HashSet<Point16>();
public override void Load() => On_WorldGen.IslandHouse += SpiritGenPasses.StealIslandInfo;
public override void TileCountsAvailable(ReadOnlySpan<int> tileCounts)
{
CorruptHazards = tileCounts[ModContent.TileType<Corpsebloom>()] + tileCounts[ModContent.TileType<Corpsebloom1>()] + tileCounts[ModContent.TileType<Corpsebloom2>()];
CrimHazards = tileCounts[ModContent.TileType<CrimsonPustuleTile>()];
}
public override void OnWorldUnload()
{
//Reset boss/event downed flags
downedMechromancer = downedOccultist = downedGladeWraith = downedTome = downedSnaptrapper = downedBeholder = downedJellyDeluge = downedTide =
downedBlueMoon = downedGazer = false;
}
public override void SaveWorldData(TagCompound tag)
{
var downed = new List<string>();
if (downedBlueMoon)
downed.Add("bluemoon");
if (downedJellyDeluge)
downed.Add("jellyDeluge");
if (downedTide)
downed.Add("tide");
if (downedMechromancer)
downed.Add("mechromancer");
if (downedOccultist)
downed.Add("occultist");
if (downedGladeWraith)
downed.Add("gladeWraith");
if (downedTome)
downed.Add("hauntedTome");
if (downedBeholder)
downed.Add("beholder");
if (downedSnaptrapper)
downed.Add("snaptrapper");
if (downedGazer)
downed.Add("bloodGazer");
tag.Add("downed", downed);
TagCompound droppedGlyphTag = new TagCompound();
foreach (KeyValuePair<string, bool> entry in droppedGlyphs)
{
droppedGlyphTag.Add(entry.Key, entry.Value);
}
tag.Add("droppedGlyphs", droppedGlyphTag);
tag.Add("blueMoon", blueMoon);
tag.Add("jellySky", jellySky);
tag.Add("gennedBandits", gennedBandits);
tag.Add("gennedTower", gennedTower);
tag.Add("pagodaX", pagodaLocation.X);
tag.Add("pagodaY", pagodaLocation.Y);
//SaveSpecialNPCs(data);
tag.Add("superSunFlowerPositions", superSunFlowerPositions.ToList());
if (BackgroundItemManager.Loaded)
{
List<TagCompound> backgroundItems = BackgroundItemManager.Save();
tag.Add("backgroundItems", backgroundItems);
}
tag.Add("asteroidSide", asteroidSide);
tag.Add("leftOceanHeight", SurfaceWaterModifications.leftOceanHeight);
tag.Add("rightOceanHeight", SurfaceWaterModifications.rightOceanHeight);
}
public override void LoadWorldData(TagCompound tag)
{
var downed = tag.GetList<string>("downed");
downedTide = downed.Contains("tide");
downedMechromancer = downed.Contains("mechromancer");
downedOccultist = downed.Contains("occultist");
downedGladeWraith = downed.Contains("gladeWraith");
downedTome = downed.Contains("hauntedTome");
downedBeholder = downed.Contains("beholder");
downedSnaptrapper = downed.Contains("snaptrapper");
downedGazer = downed.Contains("bloodGazer");
downedBlueMoon = downed.Contains("bluemoon");
downedJellyDeluge = downed.Contains("jellyDeluge");
//LoadSpecialNPCs(tag);
TagCompound droppedGlyphTag = tag.GetCompound("droppedGlyphs");
droppedGlyphs.Clear();
foreach (KeyValuePair<string, object> entry in droppedGlyphTag)
{
droppedGlyphs.Add(entry.Key, entry.Value is byte v ? v != 0 : entry.Value as bool? ?? false);
}
blueMoon = tag.GetBool("blueMoon");
jellySky = tag.GetBool("jellySky");
gennedBandits = tag.GetBool("gennedBandits");
gennedTower = tag.GetBool("gennedTower");
pagodaLocation.X = tag.Get<int>("pagodaX");
pagodaLocation.Y = tag.Get<int>("pagodaY");
superSunFlowerPositions = new HashSet<Point16>(tag.GetList<Point16>("superSunFlowerPositions"));
// verify that there are super sunflowers at the loaded positions
foreach (Point16 point in superSunFlowerPositions.ToList())
if (Framing.GetTileSafely(point).TileType != ModContent.TileType<SuperSunFlower>())
superSunFlowerPositions.Remove(point);
var bgItems = tag.GetList<TagCompound>("backgroundItems");
BackgroundItemManager.Load(bgItems);
asteroidSide = tag.Get<int>("asteroidSide");
SurfaceWaterModifications.leftOceanHeight = tag.Get<int>("leftOceanHeight");
SurfaceWaterModifications.rightOceanHeight = tag.Get<int>("rightOceanHeight");
}
public override void NetSend(BinaryWriter writer)
{
BitsByte bosses = new BitsByte(DownedScarabeus, DownedAncientAvian, DownedStarplate, DownedInfernon, DownedDusking, DownedAtlas, DownedVinewrath, DownedMoonWizard);
BitsByte bosses2 = new BitsByte(downedTide, downedMechromancer, downedOccultist, downedGladeWraith, downedBeholder, downedSnaptrapper, downedTome, downedGazer);
writer.Write(bosses);
writer.Write(bosses2);
BitsByte environment = new BitsByte(blueMoon, jellySky, downedBlueMoon, downedJellyDeluge, aurora);
BitsByte worldgen = new BitsByte(gennedBandits, gennedTower);
writer.Write(environment);
writer.Write(worldgen);
}
public override void NetReceive(BinaryReader reader)
{
BossDownedTrackingIO.HandleBossSyncing(reader.ReadByte());
BitsByte bosses2 = reader.ReadByte();
downedTide = bosses2[0];
downedMechromancer = bosses2[1];
downedOccultist = bosses2[2];
downedGladeWraith = bosses2[3];
downedBeholder = bosses2[4];
downedSnaptrapper = bosses2[5];
downedTome = bosses2[6];
downedGazer = bosses2[7];
BitsByte environment = reader.ReadByte();
blueMoon = environment[0];
jellySky = environment[1];
downedBlueMoon = environment[2];
downedJellyDeluge = environment[3];
aurora = environment[4];
BitsByte worldgen = reader.ReadByte();
gennedBandits = worldgen[0];
gennedTower = worldgen[1];
}
public override void PreUpdateWorld()
{
rotationTime += (float)Math.PI / 60;
if (rotationTime >= Math.PI * 2)
rotationTime = 0;
}
public override void OnWorldLoad()
{
blueMoon = false;
jellySky = false;
ashRain = false;
dayTimeLast = Main.dayTime;
dayTimeSwitched = false;
if (!Main.dedServ)
AdditiveCallManager.Load();
SpiritMod.TrailManager?.ClearAllTrails(); //trails break on world unload and reload(their projectile is still counted as being active???), so this just clears them all on reload
spiritBiome = NPC.downedMechBoss3 || NPC.downedMechBoss2 || NPC.downedMechBoss1;
rockCandy = Main.hardMode;
//downedScarabeus = false;
//downedAncientFlier = false;
//downedRaider = false;
//downedInfernon = false;
//downedReachBoss = false;
//downedDusking = false;
//downedAtlas = false;
//downedMoonWizard = false;
//downedTide = false;
//downedMechromancer = false;
//downedOccultist = false;
//downedGladeWraith = false;
//downedBeholder = false;
//downedSnaptrapper = false;
//downedTome = false;
//Portrait system - Gabe
//PortraitManager.Load(); //Load portraits so the detour can access them
}
/// <summary>
/// Checks if the given area is more or less flattish.
/// Returns false if the average tile height variation is greater than the threshold.
/// Expects that the first tile is solid, and traverses from there.
/// Use the weight parameters to change the importance of up/down checks.
/// </summary>
/// <param name="startX"></param>
/// <param name="startY"></param>
/// <param name="width"></param>
/// <param name="threshold"></param>
/// <param name="goingDownWeight"></param>
/// <param name="goingUpWeight"></param>
/// <returns></returns>
public static bool CheckFlat(int startX, int startY, int width, float threshold, int goingDownWeight = 0, int goingUpWeight = 0)
{
// Fail if the tile at the other end of the check plane isn't also solid
if (!WorldGen.SolidTile(startX + width, startY))
return false;
float totalVariance = 0;
for (int i = 0; i < width; i++)
{
if (startX + i >= Main.maxTilesX)
return false;
// Fail if there is a tile very closely above the check area
for (int k = startY - 1; k > startY - 100; k--)
{
if (WorldGen.SolidTile(startX + i, k))
return false;
}
// If the tile is solid, go up until we find air
// If the tile is not, go down until we find a floor
int offset = 0;
bool goingUp = WorldGen.SolidTile(startX + i, startY);
offset += goingUp ? goingUpWeight : goingDownWeight;
while (goingUp && WorldGen.SolidTile(startX + i, startY - offset)
|| !goingUp && !WorldGen.SolidTile(startX + i, startY + offset))
{
offset++;
}
if (goingUp)
offset--; // account for going up counting the first tile
totalVariance += offset;
}
return totalVariance / width <= threshold;
}
#region MageTower
private static void PlaceTower(int i, int j, int[,] ShrineArray, int[,] HammerArray, int[,] WallsArray, int[,] LootArray)
{
for (int y = 0; y < WallsArray.GetLength(0); y++)
{ // This Loop Places Furnitures.(So that they have blocks to spawn on).
for (int x = 0; x < WallsArray.GetLength(1); x++)
{
int k = i - 3 + x;
int l = j - 6 + y;
if (WorldGen.InWorld(k, l, 30))
{
Tile tile = Framing.GetTileSafely(k, l);
switch (WallsArray[y, x])
{
case 1:
Framing.GetTileSafely(k, l).ClearTile();
WorldGen.PlaceWall(k, l, WallID.GrassUnsafe, mute: true); // Stone Slab
break;
case 2:
Framing.GetTileSafely(k, l).ClearTile();
WorldGen.PlaceWall(k, l, WallID.ArcaneRunes, mute: true); // Stone Slab
break;
case 4:
Framing.GetTileSafely(k, l).ClearTile();
WorldGen.PlaceTile(k, l, TileID.WoodenBeam, mute: true); // Platforms
tile.HasTile = true;
break;
case 5:
Framing.GetTileSafely(k, l).ClearTile();
WorldGen.PlaceWall(k, l, WallID.WoodenFence, mute: true); // Platforms
break;
case 8:
Framing.GetTileSafely(k, l).ClearTile();
WorldGen.PlaceWall(k, l, WallID.StoneSlab, mute: true); // Stone Slab
break;
}
}
}
}
for (int y = 0; y < ShrineArray.GetLength(0); y++)
{ // This loops clears the area (makes the proper hemicircle) and placed dirt in the bottom if there are no blocks (so that the chest and fireplace can be placed).
for (int x = 0; x < ShrineArray.GetLength(1); x++)
{
int k = i - 3 + x;
int l = j - 6 + y;
if (WorldGen.InWorld(k, l, 30))
{
Tile tile = Framing.GetTileSafely(k, l);
switch (ShrineArray[y, x])
{
case 0:
break; // no changes
case 1:
Framing.GetTileSafely(k, l).ClearTile();
break;
case 2:
Framing.GetTileSafely(k, l).ClearTile();
break;
case 3:
Framing.GetTileSafely(k, l).ClearTile();
break;
case 4:
Framing.GetTileSafely(k, l).ClearTile();
break;
case 5:
Framing.GetTileSafely(k, l).ClearTile();
break;
case 7:
Framing.GetTileSafely(k, l).ClearTile();
break;
case 8:
WorldGen.PlaceTile(k, l, 0, mute: true);
tile.HasTile = true;
break;
}
}
}
}
int shingleColor = WorldGen.genRand.NextBool() ? TileID.RedDynastyShingles : TileID.BlueDynastyShingles;
for (int y = 0; y < ShrineArray.GetLength(0); y++)
{ // This Loop Placzs Furnitures.(So that they have blocks to spawn on).
for (int x = 0; x < ShrineArray.GetLength(1); x++)
{
int k = i - 3 + x;
int l = j - 6 + y;
if (WorldGen.InWorld(k, l, 30))
{
Tile tile = Framing.GetTileSafely(k, l);
switch (ShrineArray[y, x])
{
case 1:
WorldGen.PlaceTile(k, l, TileID.StoneSlab, mute: true); // Stone Slab
tile.HasTile = true;
break;
case 2:
WorldGen.PlaceTile(k, l, TileID.Platforms, mute: true); // Platforms
tile.HasTile = true;
break;
case 3:
WorldGen.PlaceTile(k, l, TileID.WoodBlock, mute: true); // Wood
tile.HasTile = true;
break;
case 6:
WorldGen.PlaceTile(k, l, shingleColor, mute: true); // Roofing
tile.HasTile = true;
break;
}
}
}
}
for (int y = 0; y < LootArray.GetLength(0); y++)
{ // This Loop Placzs Furnitures.(So that they have blocks to spawn on).
for (int x = 0; x < LootArray.GetLength(1); x++)
{
int k = i - 3 + x;
int l = j - 6 + y;
if (WorldGen.InWorld(k, l, 30))
{
Tile tile = Framing.GetTileSafely(k, l);
switch (LootArray[y, x])
{
case 1:
WorldGen.PlaceTile(k, l, TileID.Pots, mute: true); // Pot
tile.HasTile = true;
break;
case 2:
WorldGen.PlaceObject(k, l, ModContent.TileType<GoblinStatueTile>(), mute: true);
break;
case 4:
WorldGen.PlaceObject(k, l - 1, ModContent.TileType<ShadowflameStone>(), mute: true);
break;
case 5:
WorldGen.PlaceObject(k, l, TileID.Books, mute: true, style: Main.rand.Next(5)); // Book
break;
case 6:
WorldGen.PlaceObject(k, l, TileID.FishingCrate, mute: true); // Crate
break;
case 7:
WorldGen.PlaceChest(k, l, (ushort)ModContent.TileType<GoblinChest>(), false, 0); // Gold Chest
break;
case 8:
WorldGen.PlaceObject(k, l, TileID.Bottles, mute: true); // Crate
break;
case 9:
WorldGen.PlaceObject(k, l - 1, ModContent.TileType<GoblinStandardTile>(), mute: true); // Crate
break;
}
}
}
}
for (int y = 0; y < HammerArray.GetLength(0); y++)
{
for (int x = 0; x < HammerArray.GetLength(1); x++)
{
int k = i - 3 + x;
int l = j - 6 + y;
if (WorldGen.InWorld(k, l, 30))
{
WorldGen.SlopeTile(k, l, HammerArray[y, x]);
if (TileID.Sets.Platforms[Main.tile[k, l].TileType])
{
WorldGen.SquareTileFrame(k, l);
}
}
}
}
}
public bool GenerateTower()
{
int[,] TowerShape = new int[,]
{
{0,0,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,1,0,0,0,4,0,0,1,0,1,0,1,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
};
bool placed = false;
int attempts = 0;
while (!placed && attempts++ < 100000)
{
// Select a place in the first 6th of the world, avoiding the oceans
int towerX = WorldGen.genRand.Next(300, Main.maxTilesX / 6); // from 50 since there's a unaccessible area at the world's borders
// 50% of choosing the last 6th of the world
// Choose which side of the world to be on randomly
if (WorldGen.genRand.NextBool())
towerX = Main.maxTilesX - towerX;
//Start at 200 tiles above the surface instead of 0, to exclude floating islands
int towerY = (int)Main.worldSurface - 200;
// We go down until we hit a solid tile or go under the world's surface
while (!WorldGen.SolidTile(towerX, towerY) && towerY <= Main.worldSurface)
{
towerY++;
}
// If we went under the world's surface, try again
if (towerY > Main.worldSurface)
{
continue;
}
Tile tile = Main.tile[towerX, towerY];
// If the type of the tile we are placing the tower on doesn't match what we want, try again
if (!(tile.TileType == TileID.Dirt
|| tile.TileType == TileID.Grass
|| tile.TileType == TileID.Stone
|| tile.TileType == TileID.Mud
|| tile.TileType == TileID.CrimsonGrass
|| tile.TileType == TileID.CorruptGrass
|| tile.TileType == TileID.JungleGrass
|| tile.TileType == TileID.Sand
|| tile.TileType == TileID.Crimsand
|| tile.TileType == TileID.Ebonsand))
{
continue;
}
// Don't place the tower if the area isn't flat
if (!CheckFlat(towerX, towerY, TowerShape.GetLength(1), 3))
continue;
// place the tower
PlaceTower(towerX, towerY - 37, TowerShape, TowerHammered, TowerWallsShape, TowerLoot);
// extend the base a bit
for (int i = towerX - 2; i < towerX + TowerShape.GetLength(1) - 4; i++)
{
for (int k = towerY + 3; k < towerY + 12; k++)
{
WorldGen.PlaceTile(i, k, TileID.StoneSlab, mute: true, forced: true);
WorldGen.SlopeTile(i, k);
}
}
// place the Rogue
int num = NPC.NewNPC(NPC.GetSource_NaturalSpawn(), (towerX + 12) * 16, (towerY - 24) * 16, ModContent.NPCType<BoundGambler>(), 0, 0f, 0f, 0f, 0f, 255);
Main.npc[num].homeTileX = -1;
Main.npc[num].homeTileY = -1;
Main.npc[num].direction = 1;
Main.npc[num].homeless = true;
placed = true;
}
if (!placed)
Mod.Logger.Error("Worldgen: FAILED to place Goblin Tower, ground not flat enough?");
return placed;
}
#endregion
#region BanditHideout
private static void PlaceBanditHideout(int i, int j, int[,] BlocksArray, int[,] WallsArray, int[,] LootArray)
{
for (int y = 0; y < WallsArray.GetLength(0); y++)
{
for (int x = 0; x < WallsArray.GetLength(1); x++)
{
int k = i - 3 + x;
int l = j - 6 + y;
if (WorldGen.InWorld(k, l, 30))
{
switch (WallsArray[y, x])
{
case 0:
break;
case 1:
WorldGen.KillWall(k, l);
Framing.GetTileSafely(k, l).ClearTile();
break;
case 2:
WorldGen.KillWall(k, l);
Framing.GetTileSafely(k, l).ClearTile();
break;
case 4:
WorldGen.KillWall(k, l);
Framing.GetTileSafely(k, l).ClearTile();
break;
case 5:
WorldGen.KillWall(k, l);
Framing.GetTileSafely(k, l).ClearTile();
break;
}
}
}
}
for (int y = 0; y < LootArray.GetLength(0); y++)
{
for (int x = 0; x < LootArray.GetLength(1); x++)
{
int k = i - 3 + x;
int l = j - 6 + y;
if (WorldGen.InWorld(k, l, 30))
{
switch (LootArray[y, x])
{
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 13:
case 14:
case 15:
case 16:
WorldGen.KillWall(k, l);
Framing.GetTileSafely(k, l).ClearTile();
break;
case 12:
WorldGen.PlaceObject(k, l, 15);
break;
}
}
}
}
for (int y = 0; y < BlocksArray.GetLength(0); y++)
{
for (int x = 0; x < BlocksArray.GetLength(1); x++)
{
int k = i - 3 + x;
int l = j - 6 + y;
if (WorldGen.InWorld(k, l, 30))
{
switch (BlocksArray[y, x])
{
case 0:
break;
case 1:
WorldGen.KillWall(k, l);
Framing.GetTileSafely(k, l).ClearTile();
break;
case 2:
WorldGen.KillWall(k, l);
Framing.GetTileSafely(k, l).ClearTile();
break;
case 3:
WorldGen.KillWall(k, l);
Framing.GetTileSafely(k, l).ClearTile();
break;
case 4:
WorldGen.KillWall(k, l);
Framing.GetTileSafely(k, l).ClearTile();
break;
case 5:
WorldGen.KillWall(k, l);
Framing.GetTileSafely(k, l).ClearTile();
break;
case 6:
WorldGen.KillWall(k, l);
Framing.GetTileSafely(k, l).ClearTile();
break;
case 9:
WorldGen.KillWall(k, l);
Framing.GetTileSafely(k, l).ClearTile();
break;
}
}
}
}
for (int y = 0; y < WallsArray.GetLength(0); y++)
{
for (int x = 0; x < WallsArray.GetLength(1); x++)
{
int k = i - 3 + x;
int l = j - 6 + y;
if (WorldGen.InWorld(k, l, 30))
{
switch (WallsArray[y, x])
{
case 0:
break;
case 4:
WorldGen.PlaceWall(k, l, 4);
break;
}
}
}
}
for (int y = 0; y < BlocksArray.GetLength(0); y++)
{
for (int x = 0; x < BlocksArray.GetLength(1); x++)
{
int k = i - 3 + x;
int l = j - 6 + y;
if (WorldGen.InWorld(k, l, 30))
{
Tile tile = Framing.GetTileSafely(k, l);
switch (BlocksArray[y, x])
{
case 0:
break;
case 1:
WorldGen.PlaceTile(k, l, 30);
tile.HasTile = true;
break;
case 2:
WorldGen.PlaceTile(k, l, 38);
tile.HasTile = true;
break;
case 3:
WorldGen.PlaceTile(k, l, 124);
tile.HasTile = true;
break;
case 4:
WorldGen.PlaceTile(k, l, 213);
tile.HasTile = true;
break;
case 5:
WorldGen.PlaceTile(k, l, 19, true, false, -1, 12);
tile.HasTile = true;
break;
case 6:
WorldGen.PlaceWall(k, l, 106);
break;
case 7:
WorldGen.PlaceTile(k, l, 19, true, false, -1, 0);