Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
MapTile.cs
Go to the documentation of this file.
1namespace Terraria.Map;
2
3public struct MapTile
4{
5 public ushort Type;
6
7 public byte Light;
8
9 private byte _extraData;
10
11 public bool IsChanged
12 {
13 get
14 {
15 return (_extraData & 0x80) == 128;
16 }
17 set
18 {
19 if (value)
20 {
21 _extraData |= 128;
22 }
23 else
24 {
25 _extraData &= 127;
26 }
27 }
28 }
29
30 public byte Color
31 {
32 get
33 {
34 return (byte)(_extraData & 0x7Fu);
35 }
36 set
37 {
38 _extraData = (byte)((_extraData & 0x80u) | (value & 0x7Fu));
39 }
40 }
41
42 private MapTile(ushort type, byte light, byte extraData)
43 {
44 Type = type;
45 Light = light;
46 _extraData = extraData;
47 }
48
49 public bool Equals(ref MapTile other)
50 {
51 if (Light == other.Light && Type == other.Type)
52 {
53 return Color == other.Color;
54 }
55 return false;
56 }
57
58 public bool EqualsWithoutLight(ref MapTile other)
59 {
60 if (Type == other.Type)
61 {
62 return Color == other.Color;
63 }
64 return false;
65 }
66
67 public void Clear()
68 {
69 Type = 0;
70 Light = 0;
71 _extraData = 0;
72 }
73
74 public MapTile WithLight(byte light)
75 {
76 return new MapTile(Type, light, (byte)(_extraData | 0x80u));
77 }
78
79 public static MapTile Create(ushort type, byte light, byte color)
80 {
81 return new MapTile(type, light, (byte)(color | 0x80u));
82 }
83}
MapTile WithLight(byte light)
Definition MapTile.cs:74
bool Equals(ref MapTile other)
Definition MapTile.cs:49
static MapTile Create(ushort type, byte light, byte color)
Definition MapTile.cs:79
bool EqualsWithoutLight(ref MapTile other)
Definition MapTile.cs:58
MapTile(ushort type, byte light, byte extraData)
Definition MapTile.cs:42