use of info.ata4.util.collection.Node in project disunity by ata4.
the class TypeTreeV1 method writeNode.
private void writeNode(DataWriter out, Node<T> node) throws IOException {
T type = node.data();
out.writeStruct(type);
int numChildren = node.size();
out.writeInt(numChildren);
for (Node child : node) {
writeNode(out, child);
}
}
use of info.ata4.util.collection.Node in project disunity by ata4.
the class AssetTypes method printTypeNodeText.
private void printTypeNodeText(Node<? extends Type> node, int level) {
String indent = StringUtils.repeat(" ", level);
Type type = node.data();
output().printf("% 4d: %s%s %s (metaFlag: %x)%n", type.index(), indent, type.typeName(), type.fieldName(), type.metaFlag());
node.forEach(t -> printTypeNodeText(t, level + 1));
}
use of info.ata4.util.collection.Node in project disunity by ata4.
the class TypeTreeV3 method writeNode.
private void writeNode(DataWriter out, Node<T> node) throws IOException {
List<T> types = new ArrayList<>();
serializeNode(node, types, 0);
// build string table
AtomicInteger index = new AtomicInteger();
Map<String, Integer> localMap = new LinkedHashMap<>();
Map<String, Integer> commonMap = StringTable.commonStrings(revision.major()).inverse();
Function<String, Integer> addStringOffset = typeName -> {
if (commonMap.containsKey(typeName)) {
return commonMap.get(typeName);
} else if (localMap.containsKey(typeName)) {
return localMap.get(typeName);
} else {
int stringIndex = index.getAndAdd(typeName.length() + 1);
localMap.put(typeName, stringIndex);
return stringIndex;
}
};
// apply string offsets
types.forEach(type -> {
type.typeOffset(addStringOffset.apply(type.typeName()));
type.nameOffset(addStringOffset.apply(type.fieldName()));
});
out.writeInt(types.size());
out.writeInt(index.get());
for (T type : types) {
out.writeStruct(type);
}
for (String string : localMap.keySet()) {
out.writeStringNull(string);
}
}
use of info.ata4.util.collection.Node in project disunity by ata4.
the class TypeTreeV3 method read.
@Override
public void read(DataReader in) throws IOException {
revision = new UnityVersion(in.readStringNull(255));
attributes = in.readInt();
embedded = in.readBoolean();
int numBaseClasses = in.readInt();
for (int i = 0; i < numBaseClasses; i++) {
int classID = in.readInt();
TypeRoot typeRoot = new TypeRoot();
typeRoot.classID(classID);
if (classID < 0) {
UnityHash128 scriptID = new UnityHash128();
in.readStruct(scriptID);
typeRoot.scriptID(scriptID);
}
UnityHash128 oldTypeHash = new UnityHash128();
in.readStruct(oldTypeHash);
typeRoot.oldTypeHash(oldTypeHash);
if (embedded) {
Node<T> node = new Node<>();
readNode(in, node);
typeRoot.nodes(node);
}
typeMap.put(classID, typeRoot);
}
}
Aggregations