Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
WorldUtils.cs
Go to the documentation of this file.
1
using
System
;
2
using
Microsoft.Xna.Framework
;
3
4
namespace
Terraria.WorldBuilding
;
5
6
public
static
class
WorldUtils
7
{
8
public
static
Rectangle
ClampToWorld
(
Rectangle
tileRectangle)
9
{
10
int
num =
Math
.
Max
(0,
Math
.
Min
(tileRectangle.
Left
,
Main
.
maxTilesX
));
11
int
num2 =
Math
.
Max
(0,
Math
.
Min
(tileRectangle.
Top
,
Main
.
maxTilesY
));
12
int
num3 =
Math
.
Max
(0,
Math
.
Min
(tileRectangle.
Right
,
Main
.
maxTilesX
));
13
int
num4 =
Math
.
Max
(0,
Math
.
Min
(tileRectangle.
Bottom
,
Main
.
maxTilesY
));
14
return
new
Rectangle
(num, num2, num3 - num, num4 - num2);
15
}
16
17
public
static
bool
Gen
(
Point
origin,
GenShape
shape,
GenAction
action
)
18
{
19
return
shape.
Perform
(origin,
action
);
20
}
21
22
public
static
bool
Gen
(
Point
origin,
GenShapeActionPair
pair)
23
{
24
return
pair.
Shape
.
Perform
(origin, pair.
Action
);
25
}
26
27
public
static
bool
Find
(
Point
origin,
GenSearch
search, out
Point
result)
28
{
29
result = search.
Find
(origin);
30
if
(result ==
GenSearch
.
NOT_FOUND
)
31
{
32
return
false
;
33
}
34
return
true
;
35
}
36
37
public
static
void
ClearTile
(
int
x,
int
y,
bool
frameNeighbors =
false
)
38
{
39
Main
.
tile
[x, y].ClearTile();
40
if
(frameNeighbors)
41
{
42
WorldGen
.
TileFrame
(x + 1, y);
43
WorldGen
.
TileFrame
(x - 1, y);
44
WorldGen
.
TileFrame
(x, y + 1);
45
WorldGen
.
TileFrame
(x, y - 1);
46
}
47
}
48
49
public
static
void
ClearWall
(
int
x,
int
y,
bool
frameNeighbors =
false
)
50
{
51
Main
.
tile
[x, y].wall = 0;
52
if
(frameNeighbors)
53
{
54
WorldGen
.
SquareWallFrame
(x + 1, y);
55
WorldGen
.
SquareWallFrame
(x - 1, y);
56
WorldGen
.
SquareWallFrame
(x, y + 1);
57
WorldGen
.
SquareWallFrame
(x, y - 1);
58
}
59
}
60
61
public
static
void
TileFrame
(
int
x,
int
y,
bool
frameNeighbors =
false
)
62
{
63
WorldGen
.
TileFrame
(x, y, resetFrame:
true
);
64
if
(frameNeighbors)
65
{
66
WorldGen
.
TileFrame
(x + 1, y, resetFrame:
true
);
67
WorldGen
.
TileFrame
(x - 1, y, resetFrame:
true
);
68
WorldGen
.
TileFrame
(x, y + 1, resetFrame:
true
);
69
WorldGen
.
TileFrame
(x, y - 1, resetFrame:
true
);
70
}
71
}
72
73
public
static
void
ClearChestLocation
(
int
x,
int
y)
74
{
75
ClearTile
(x, y, frameNeighbors:
true
);
76
ClearTile
(x - 1, y, frameNeighbors:
true
);
77
ClearTile
(x, y - 1, frameNeighbors:
true
);
78
ClearTile
(x - 1, y - 1, frameNeighbors:
true
);
79
}
80
81
public
static
void
WireLine
(
Point
start
,
Point
end)
82
{
83
Point
point =
start
;
84
Point
point2 = end;
85
if
(end.
X
<
start
.X)
86
{
87
Utils
.Swap(ref end.
X
, ref
start
.X);
88
}
89
if
(end.
Y
<
start
.Y)
90
{
91
Utils
.Swap(ref end.
Y
, ref
start
.Y);
92
}
93
for
(
int
i =
start
.X; i <= end.
X
; i++)
94
{
95
WorldGen
.
PlaceWire
(i, point.
Y
);
96
}
97
for
(
int
j =
start
.Y; j <= end.
Y
; j++)
98
{
99
WorldGen
.
PlaceWire
(point2.
X
, j);
100
}
101
}
102
103
public
static
void
DebugRegen
()
104
{
105
WorldGen
.
clearWorld
();
106
WorldGen
.
GenerateWorld
(
Main
.
ActiveWorldFileData
.Seed);
107
Main
.
NewText
(
"World Regen Complete."
);
108
}
109
110
public
static
void
DebugRotate
()
111
{
112
int
num = 0;
113
int
num2 = 0;
114
int
maxTilesY =
Main
.
maxTilesY
;
115
for
(
int
i = 0; i < Main.maxTilesX /
Main
.
maxTilesY
; i++)
116
{
117
for
(
int
j = 0; j < maxTilesY / 2; j++)
118
{
119
for
(
int
k = j; k < maxTilesY - j; k++)
120
{
121
Tile
tile =
Main
.
tile
[k + num, j + num2];
122
Main
.
tile
[k + num, j + num2] =
Main
.
tile
[j + num, maxTilesY - k + num2];
123
Main
.
tile
[j + num, maxTilesY - k + num2] =
Main
.
tile
[maxTilesY - k + num, maxTilesY - j + num2];
124
Main
.
tile
[maxTilesY - k + num, maxTilesY - j + num2] =
Main
.
tile
[maxTilesY - j + num, k + num2];
125
Main
.
tile
[maxTilesY - j + num, k + num2] = tile;
126
}
127
}
128
num += maxTilesY;
129
}
130
}
131
}
System.Math.Min
static byte Min(byte val1, byte val2)
Definition
Math.cs:912
System.Math.Max
static byte Max(byte val1, byte val2)
Definition
Math.cs:738
System.Math
Definition
Math.cs:13
Terraria.Main.maxTilesY
static int maxTilesY
Definition
Main.cs:1116
Terraria.Main.ActiveWorldFileData
static WorldFileData ActiveWorldFileData
Definition
Main.cs:1946
Terraria.Main.NewText
static void NewText(string newText, byte R=byte.MaxValue, byte G=byte.MaxValue, byte B=byte.MaxValue)
Definition
Main.cs:61429
Terraria.Main.maxTilesX
static int maxTilesX
Definition
Main.cs:1114
Terraria.Main.tile
static Tile[,] tile
Definition
Main.cs:1675
Terraria.Main
Definition
Main.cs:79
Terraria.Tile
Definition
Tile.cs:7
Terraria.Utils
Definition
Utils.cs:29
Terraria.WorldBuilding.GenAction
Definition
GenAction.cs:6
Terraria.WorldBuilding.GenSearch.NOT_FOUND
static Point NOT_FOUND
Definition
GenSearch.cs:7
Terraria.WorldBuilding.GenSearch.Find
Point Find(Point origin)
Terraria.WorldBuilding.GenSearch
Definition
GenSearch.cs:6
Terraria.WorldBuilding.GenShape.Perform
bool Perform(Point origin, GenAction action)
Terraria.WorldBuilding.GenShape
Definition
GenShape.cs:6
Terraria.WorldBuilding.WorldUtils.DebugRotate
static void DebugRotate()
Definition
WorldUtils.cs:110
Terraria.WorldBuilding.WorldUtils.Gen
static bool Gen(Point origin, GenShapeActionPair pair)
Definition
WorldUtils.cs:22
Terraria.WorldBuilding.WorldUtils.TileFrame
static void TileFrame(int x, int y, bool frameNeighbors=false)
Definition
WorldUtils.cs:61
Terraria.WorldBuilding.WorldUtils.Find
static bool Find(Point origin, GenSearch search, out Point result)
Definition
WorldUtils.cs:27
Terraria.WorldBuilding.WorldUtils.ClearChestLocation
static void ClearChestLocation(int x, int y)
Definition
WorldUtils.cs:73
Terraria.WorldBuilding.WorldUtils.WireLine
static void WireLine(Point start, Point end)
Definition
WorldUtils.cs:81
Terraria.WorldBuilding.WorldUtils.ClearTile
static void ClearTile(int x, int y, bool frameNeighbors=false)
Definition
WorldUtils.cs:37
Terraria.WorldBuilding.WorldUtils.DebugRegen
static void DebugRegen()
Definition
WorldUtils.cs:103
Terraria.WorldBuilding.WorldUtils.ClampToWorld
static Rectangle ClampToWorld(Rectangle tileRectangle)
Definition
WorldUtils.cs:8
Terraria.WorldBuilding.WorldUtils.Gen
static bool Gen(Point origin, GenShape shape, GenAction action)
Definition
WorldUtils.cs:17
Terraria.WorldBuilding.WorldUtils.ClearWall
static void ClearWall(int x, int y, bool frameNeighbors=false)
Definition
WorldUtils.cs:49
Terraria.WorldBuilding.WorldUtils
Definition
WorldUtils.cs:7
Terraria.WorldGen.GenerateWorld
static void GenerateWorld(int seed, GenerationProgress customProgressObject=null)
Definition
WorldGen.cs:7175
Terraria.WorldGen.SquareWallFrame
static void SquareWallFrame(int i, int j, bool resetFrame=true)
Definition
WorldGen.cs:70375
Terraria.WorldGen.clearWorld
static void clearWorld()
Definition
WorldGen.cs:3373
Terraria.WorldGen.TileFrame
static void TileFrame(int i, int j, bool resetFrame=false, bool noBreak=false)
Definition
WorldGen.cs:71431
Terraria.WorldGen.PlaceWire
static bool PlaceWire(int i, int j)
Definition
WorldGen.cs:49049
Terraria.WorldGen
Definition
WorldGen.cs:32
Microsoft.Xna.Framework
Definition
AlphaTestEffect.cs:1
System.ExceptionArgument.action
@ action
System.ExceptionArgument.start
@ start
System
Definition
BlockingCollection.cs:8
Terraria.WorldBuilding
Definition
Actions.cs:8
Microsoft.Xna.Framework.Point.X
int X
Definition
Point.cs:14
Microsoft.Xna.Framework.Point.Y
int Y
Definition
Point.cs:17
Microsoft.Xna.Framework.Point
Definition
Point.cs:12
Microsoft.Xna.Framework.Rectangle.Right
int Right
Definition
Rectangle.cs:29
Microsoft.Xna.Framework.Rectangle.Left
int Left
Definition
Rectangle.cs:27
Microsoft.Xna.Framework.Rectangle.Bottom
int Bottom
Definition
Rectangle.cs:33
Microsoft.Xna.Framework.Rectangle.Top
int Top
Definition
Rectangle.cs:31
Microsoft.Xna.Framework.Rectangle
Definition
Rectangle.cs:12
Terraria.WorldBuilding.GenShapeActionPair.Action
readonly GenAction Action
Definition
GenShapeActionPair.cs:7
Terraria.WorldBuilding.GenShapeActionPair.Shape
readonly GenShape Shape
Definition
GenShapeActionPair.cs:5
Terraria.WorldBuilding.GenShapeActionPair
Definition
GenShapeActionPair.cs:4
source
Terraria.WorldBuilding
WorldUtils.cs
Generated by
1.10.0