Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TileObjectPreviewData.cs
Go to the documentation of this file.
1using System;
2
4
6{
7 private ushort _type;
8
9 private short _style;
10
11 private int _alternate;
12
13 private int _random;
14
15 private bool _active;
16
17 private Point16 _size;
18
20
22
23 private int[,] _data;
24
26
27 private float _percentValid;
28
30
32
33 public const int None = 0;
34
35 public const int ValidSpot = 1;
36
37 public const int InvalidSpot = 2;
38
39 public bool Active
40 {
41 get
42 {
43 return _active;
44 }
45 set
46 {
47 _active = value;
48 }
49 }
50
51 public ushort Type
52 {
53 get
54 {
55 return _type;
56 }
57 set
58 {
59 _type = value;
60 }
61 }
62
63 public short Style
64 {
65 get
66 {
67 return _style;
68 }
69 set
70 {
71 _style = value;
72 }
73 }
74
75 public int Alternate
76 {
77 get
78 {
79 return _alternate;
80 }
81 set
82 {
84 }
85 }
86
87 public int Random
88 {
89 get
90 {
91 return _random;
92 }
93 set
94 {
95 _random = value;
96 }
97 }
98
100 {
101 get
102 {
103 return _size;
104 }
105 set
106 {
107 if (value.X <= 0 || value.Y <= 0)
108 {
109 throw new FormatException("PlacementData.Size was set to a negative value.");
110 }
111 if (value.X > _dataSize.X || value.Y > _dataSize.Y)
112 {
113 int num = ((value.X > _dataSize.X) ? value.X : _dataSize.X);
114 int num2 = ((value.Y > _dataSize.Y) ? value.Y : _dataSize.Y);
115 int[,] array = new int[num, num2];
116 if (_data != null)
117 {
118 for (int i = 0; i < _dataSize.X; i++)
119 {
120 for (int j = 0; j < _dataSize.Y; j++)
121 {
122 array[i, j] = _data[i, j];
123 }
124 }
125 }
126 _data = array;
127 _dataSize = new Point16(num, num2);
128 }
129 _size = value;
130 }
131 }
132
134 {
135 get
136 {
137 return _coordinates;
138 }
139 set
140 {
142 }
143 }
144
146 {
147 get
148 {
149 return _objectStart;
150 }
151 set
152 {
154 }
155 }
156
157 public int this[int x, int y]
158 {
159 get
160 {
161 if (x < 0 || y < 0 || x >= _size.X || y >= _size.Y)
162 {
163 throw new IndexOutOfRangeException();
164 }
165 return _data[x, y];
166 }
167 set
168 {
169 if (x < 0 || y < 0 || x >= _size.X || y >= _size.Y)
170 {
171 throw new IndexOutOfRangeException();
172 }
173 _data[x, y] = value;
174 }
175 }
176
177 public void Reset()
178 {
179 _active = false;
183 _percentValid = 0f;
184 _type = 0;
185 _style = 0;
186 _alternate = -1;
187 _random = -1;
188 if (_data != null)
189 {
191 }
192 }
193
195 {
196 _type = copy._type;
197 _style = copy._style;
198 _alternate = copy._alternate;
199 _random = copy._random;
200 _active = copy._active;
201 _size = copy._size;
205 if (_data == null)
206 {
207 _data = new int[copy._dataSize.X, copy._dataSize.Y];
208 _dataSize = copy._dataSize;
209 }
210 else
211 {
212 Array.Clear(_data, 0, _data.Length);
213 }
214 if (_dataSize.X < copy._dataSize.X || _dataSize.Y < copy._dataSize.Y)
215 {
216 int num = ((copy._dataSize.X > _dataSize.X) ? copy._dataSize.X : _dataSize.X);
217 int num2 = ((copy._dataSize.Y > _dataSize.Y) ? copy._dataSize.Y : _dataSize.Y);
218 _data = new int[num, num2];
219 _dataSize = new Point16(num, num2);
220 }
221 for (int i = 0; i < copy._dataSize.X; i++)
222 {
223 for (int j = 0; j < copy._dataSize.Y; j++)
224 {
225 _data[i, j] = copy._data[i, j];
226 }
227 }
228 }
229
230 public void AllInvalid()
231 {
232 for (int i = 0; i < _size.X; i++)
233 {
234 for (int j = 0; j < _size.Y; j++)
235 {
236 if (_data[i, j] != 0)
237 {
238 _data[i, j] = 2;
239 }
240 }
241 }
242 }
243}
static unsafe void Clear(Array array)
Definition Array.cs:755