Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SurfaceMap.cs
Go to the documentation of this file.
1
using
System
;
2
3
namespace
Terraria.GameContent.Biomes.Desert
;
4
5
public
class
SurfaceMap
6
{
7
public
readonly
double
Average
;
8
9
public
readonly
int
Bottom
;
10
11
public
readonly
int
Top
;
12
13
public
readonly
int
X
;
14
15
private
readonly
short
[]
_heights
;
16
17
public
int
Width
=>
_heights
.Length;
18
19
public
short
this
[
int
absoluteX] =>
_heights
[absoluteX -
X
];
20
21
private
SurfaceMap
(
short
[] heights,
int
x)
22
{
23
_heights
= heights;
24
X
= x;
25
int
num = 0;
26
int
num2 =
int
.MaxValue;
27
int
num3 = 0;
28
for
(
int
i = 0; i < heights.Length; i++)
29
{
30
num3 += heights[i];
31
num =
Math
.
Max
(num, heights[i]);
32
num2 =
Math
.
Min
(num2, heights[i]);
33
}
34
if
((
double
)num >
Main
.
worldSurface
- 10.0)
35
{
36
num = (int)
Main
.
worldSurface
- 10;
37
}
38
Bottom
= num;
39
Top
= num2;
40
Average
= (double)num3 / (
double
)
_heights
.Length;
41
}
42
43
public
static
SurfaceMap
FromArea
(
int
startX,
int
width)
44
{
45
int
num = Main.maxTilesY / 2;
46
short
[]
array
=
new
short
[width];
47
for
(
int
i = startX; i < startX + width; i++)
48
{
49
bool
flag =
false
;
50
int
num2 = 0;
51
for
(
int
j = 50; j < 50 + num; j++)
52
{
53
if
(
Main
.
tile
[i, j].active())
54
{
55
if
(
Main
.
tile
[i, j].type == 189 ||
Main
.
tile
[i, j].type == 196 ||
Main
.
tile
[i, j].type == 460)
56
{
57
flag =
false
;
58
}
59
else
if
(!flag)
60
{
61
num2 = j;
62
flag =
true
;
63
}
64
}
65
if
(!flag)
66
{
67
num2 = num + 50;
68
}
69
}
70
array
[i - startX] = (
short
)num2;
71
}
72
return
new
SurfaceMap
(
array
, startX);
73
}
74
}
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.GameContent.Biomes.Desert.SurfaceMap.X
readonly int X
Definition
SurfaceMap.cs:13
Terraria.GameContent.Biomes.Desert.SurfaceMap._heights
readonly short[] _heights
Definition
SurfaceMap.cs:15
Terraria.GameContent.Biomes.Desert.SurfaceMap.FromArea
static SurfaceMap FromArea(int startX, int width)
Definition
SurfaceMap.cs:43
Terraria.GameContent.Biomes.Desert.SurfaceMap.Top
readonly int Top
Definition
SurfaceMap.cs:11
Terraria.GameContent.Biomes.Desert.SurfaceMap.Width
int Width
Definition
SurfaceMap.cs:17
Terraria.GameContent.Biomes.Desert.SurfaceMap.Bottom
readonly int Bottom
Definition
SurfaceMap.cs:9
Terraria.GameContent.Biomes.Desert.SurfaceMap.SurfaceMap
SurfaceMap(short[] heights, int x)
Definition
SurfaceMap.cs:21
Terraria.GameContent.Biomes.Desert.SurfaceMap.Average
readonly double Average
Definition
SurfaceMap.cs:7
Terraria.GameContent.Biomes.Desert.SurfaceMap
Definition
SurfaceMap.cs:6
Terraria.Main.worldSurface
static double worldSurface
Definition
Main.cs:1272
Terraria.Main.tile
static Tile[,] tile
Definition
Main.cs:1675
Terraria.Main
Definition
Main.cs:79
short
System.ExceptionArgument.array
@ array
System
Definition
BlockingCollection.cs:8
Terraria.GameContent.Biomes.Desert
Definition
AnthillEntrance.cs:5
source
Terraria.GameContent.Biomes.Desert
SurfaceMap.cs
Generated by
1.10.0