-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathWSNode.java
More file actions
228 lines (186 loc) · 4.81 KB
/
WSNode.java
File metadata and controls
228 lines (186 loc) · 4.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
package swg;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Cekis on 2/18/2017.
*/
public class WSNode {
private int _id;
private int _parentId;
private int _nodeIndex;
private int _objIndex;
private float _objX;
private float _objY;
private float _objZ;
private float _objW;
private float _objScale;
private float _x;
private float _y;
private float _z;
private float _type;
private int _POBCRC;
private WSNode _parent;
private List<WSNode> _childNodes;
private String template;
public WSNode(){}
public WSNode(int id, int parentId, int objIndex, byte ox, byte oy, byte oz, byte ow, byte scale, byte x, byte y, byte z, byte type, int unknown){
this._id = id;
this._parentId = parentId;
this._objIndex = objIndex;
this._objX = ox;
this._objY = oy;
this._objZ = oz;
this._objW = ow;
this._objScale = scale;
this._type = type;
this._x = x;
this._y = y;
this._z = z;
this._POBCRC = unknown;
}
public int getId(){
return _id;
}
public void setId(int id){
_id = id;
}
public int getParentId() {
return _parentId;
}
public void setParentId(int _parentId) {
this._parentId = _parentId;
}
public int getObjIndex() {
return _objIndex;
}
public void setObjIndex(int _oIndex) {
this._objIndex = _oIndex;
}
public float getObjX() {
return _objX;
}
public void setObjX(float _oX) {
this._objX = _oX;
}
public float getObjY() {
return _objY;
}
public void setObjY(float _objY) {
this._objY = _objY;
}
public float getObjZ() {
return _objZ;
}
public void setObjZ(float _objZ) {
this._objZ = _objZ;
}
public float getObjScale() {
return _objScale;
}
public void setObjScale(float _objScale) {
this._objScale = _objScale;
}
public float getX() {
return _x;
}
public void setX(float _x) {
this._x = _x;
}
public float getY() {
return _y;
}
public void setY(float _y) {
this._y = _y;
}
public float getZ() {
return _z;
}
public void setZ(float _z) {
this._z = _z;
}
public float getObjW() {
return _objW;
}
public void setObjW(float _objW) {
this._objW = _objW;
}
public float getType() {
return _type;
}
public void setType(float _type) {
this._type = _type;
}
public int getPOBCRC() {
return _POBCRC;
}
public void setPOBCRC(int _POBCRC) {
this._POBCRC = _POBCRC;
}
public WSNode getParent() {
return _parent;
}
public void setParent(WSNode _parent) {
this._parent = _parent;
}
public List<WSNode> getNodes() {
if(_childNodes == null){
_childNodes = new ArrayList<>();
}
return _childNodes;
}
public void setNodes(List<WSNode> _nodes) {
this._childNodes = _nodes;
}
public String getTemplate() {
return template;
}
public void setTemplate(String template) {
this.template = template;
}
public int getNodeIndex() {
return _nodeIndex;
}
public void setNodeIndex(int _nodeIndex) {
this._nodeIndex = _nodeIndex;
}
public boolean hasChildNodes(){
return getNodes().size() > 0;
}
public String serialize(int index, boolean relative){
String outLine = "";
outLine += getId() + "\t";
outLine += getParentId() + "\t";
outLine += getTemplate() + "\t";
outLine += index + "\t";
outLine += (relative ? ((getX() + 8192) % 2048) : getX()) + "\t";
outLine += getY() + "\t";
outLine += (relative ? ((getZ() + 8192) % 2048) : getZ()) + "\t";
outLine += getObjW() + "\t";
outLine += getObjX() + "\t";
outLine += getObjY() + "\t";
outLine += getObjZ() + "\t";
outLine += "\t";
outLine += (getPOBCRC() != 0 ? "portalProperty.crc|0|" + getPOBCRC() + "|" : "");
outLine += "$|\n";
if(hasChildNodes()){
int nSize = _childNodes.size();
for(int j = 0; j < nSize; j++){
WSNode node = _childNodes.get(j);
outLine += node.serialize(j + 1, false);
}
}
return outLine;
}
public List<WSNode> getAllNodes(){
List<WSNode> tmp = new ArrayList<>();
int i = 1;
for (WSNode node : _childNodes) {
node.setNodeIndex(i++);
tmp.add(node);
if(node.hasChildNodes()){
tmp.addAll(node.getAllNodes());
}
}
return tmp;
}
}