Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
EnchantedSwordBiome.cs
Go to the documentation of this file.
3using Newtonsoft.Json;
5using Terraria.ID;
7
9
11{
12 [JsonProperty("ChanceOfEntrance")]
13 private double _chanceOfEntrance;
14
15 [JsonProperty("ChanceOfRealSword")]
16 private double _chanceOfRealSword;
17
18 public override bool Place(Point origin, StructureMap structures)
19 {
21 WorldUtils.Gen(new Point(origin.X - 25, origin.Y - 25), new Shapes.Rectangle(50, 50), new Actions.TileScanner(0, 1).Output(dictionary));
22 if (dictionary[0] + dictionary[1] < 1250)
23 {
24 return false;
25 }
26 Point result;
27 bool flag = WorldUtils.Find(origin, Searches.Chain(new Searches.Up(1000), new Conditions.IsSolid().AreaOr(1, 50).Not()), out result);
28 if (WorldUtils.Find(origin, Searches.Chain(new Searches.Up(origin.Y - result.Y), new Conditions.IsTile(53)), out var _))
29 {
30 return false;
31 }
32 if (!flag)
33 {
34 return false;
35 }
36 result.Y += 50;
39 Point point = new Point(origin.X, origin.Y + 20);
40 Point point2 = new Point(origin.X, origin.Y + 30);
41 bool[] array = new bool[TileID.Sets.GeneralPlacementTiles.Length];
42 for (int i = 0; i < array.Length; i++)
43 {
44 array[i] = TileID.Sets.GeneralPlacementTiles[i];
45 }
46 array[21] = false;
47 array[467] = false;
48 double num = 0.8 + GenBase._random.NextDouble() * 0.5;
49 if (!structures.CanPlace(new Rectangle(point.X - (int)(20.0 * num), point.Y - 20, (int)(40.0 * num), 40), array))
50 {
51 return false;
52 }
53 if (!structures.CanPlace(new Rectangle(origin.X, result.Y + 10, 1, origin.Y - result.Y - 9), array, 2))
54 {
55 return false;
56 }
57 WorldUtils.Gen(point, new Shapes.Slime(20, num, 1.0), Actions.Chain(new Modifiers.Blotches(2, 0.4), new Actions.ClearTile(frameNeighbors: true).Output(shapeData)));
58 WorldUtils.Gen(point2, new Shapes.Mound(14, 14), Actions.Chain(new Modifiers.Blotches(2, 1, 0.8), new Actions.SetTile(0), new Actions.SetFrames(frameNeighbors: true).Output(shapeData2)));
59 shapeData.Subtract(shapeData2, point, point2);
62 WorldUtils.Gen(point, new ModShapes.All(shapeData), Actions.Chain(new Actions.PlaceWall(68), new Modifiers.OnlyTiles(2), new Modifiers.Offset(0, 1), new ActionVines(3, 5, 382)));
64 {
65 ShapeData data = new ShapeData();
66 WorldUtils.Gen(new Point(origin.X, result.Y + 10), new Shapes.Rectangle(1, origin.Y - result.Y - 9), Actions.Chain(new Modifiers.Blotches(2, 0.2), new Modifiers.SkipTiles(191, 192), new Actions.ClearTile().Output(data), new Modifiers.Expand(1), new Modifiers.OnlyTiles(53), new Actions.SetTile(397).Output(data)));
67 WorldUtils.Gen(new Point(origin.X, result.Y + 10), new ModShapes.All(data), new Actions.SetFrames(frameNeighbors: true));
68 }
69 if (GenBase._random.NextDouble() <= _chanceOfRealSword)
70 {
71 WorldGen.PlaceTile(point2.X, point2.Y - 15, 187, mute: true, forced: false, -1, 17);
72 }
73 else
74 {
75 WorldGen.PlaceTile(point2.X, point2.Y - 15, 186, mute: true, forced: false, -1, 15);
76 }
78 structures.AddProtectedStructure(new Rectangle(point.X - (int)(20.0 * num), point.Y - 20, (int)(40.0 * num), 40), 10);
79 return true;
80 }
81}
override bool Place(Point origin, StructureMap structures)
static bool[] GeneralPlacementTiles
Definition TileID.cs:221
TileScanner Output(Dictionary< ushort, int > resultsOutput)
Definition Actions.cs:86
static GenAction Chain(params GenAction[] actions)
Definition Actions.cs:470
GenAction Output(ShapeData data)
Definition GenAction.cs:39
static UnifiedRandom _random
Definition GenBase.cs:9
GenCondition AreaOr(int width, int height)
static GenSearch Chain(GenSearch search, params GenCondition[] conditions)
Definition Searches.cs:123
void AddProtectedStructure(Rectangle area, int padding=0)
bool CanPlace(Rectangle area, int padding=0)
static bool Find(Point origin, GenSearch search, out Point result)
Definition WorldUtils.cs:27
static bool Gen(Point origin, GenShape shape, GenAction action)
Definition WorldUtils.cs:17
static bool PlaceTile(int i, int j, int Type, bool mute=false, bool forced=false, int plr=-1, int style=0)
static bool tenthAnniversaryWorldGen
Definition WorldGen.cs:1160