Package info.ata4.unity.serdes.db

Examples of info.ata4.unity.serdes.db.FieldTypeMap


        try (InputStream is = getHTTPInputStream(unityUrl)) {
            Files.copy(is, tmpFile);
        }
       
        // load bundle for validation and to get revision
        AssetBundle ab = new AssetBundle();
        ab.load(tmpFile);
       
        // create version sub-directory
        String version = ab.getEngineVersion().toString();
        String versionDirName = version.substring(0, 3);
       
        L.log(Level.INFO, "Revision: {0}", version);
       
        Path versionDir = baseDir.resolve(versionDirName);
View Full Code Here


    @Override
    public void processAsset(AssetFile asset) throws IOException {
        List<ObjectPath> paths = asset.getPaths();
        List<AssetRef> refTable = asset.getReferences();
        AssetHeader header = asset.getHeader();
        TypeTree typeTree = asset.getTypeTree();
       
        ps.println("Header");
        ps.println("  File size: " + StringUtils.humanReadableByteCount(header.getFileSize(), true));
        ps.println("  Tree size: " + StringUtils.humanReadableByteCount(header.getTreeSize(), true));
        ps.println("  Format: " + header.getFormat());
        ps.println("  Data offset: " + header.getDataOffset());
        ps.println();
       
        ps.println("Serialized data");
        ps.println("  Revision: " + typeTree.getEngineVersion());
        ps.println("  Version: " + typeTree.getVersion());
View Full Code Here

            String className = ClassID.getNameForID(path.getClassID(), true);
           
            AssetFile subAsset = new AssetFile();
            subAsset.getHeader().setFormat(asset.getHeader().getFormat());
           
            ObjectPath subFieldPath = new ObjectPath();
            subFieldPath.setClassID1(path.getClassID1());
            subFieldPath.setClassID2(path.getClassID2());
            subFieldPath.setLength(path.getLength());
            subFieldPath.setOffset(0);
            subFieldPath.setPathID(1);
            subAsset.getPaths().add(subFieldPath);
           
            TypeTree subTypeTree = subAsset.getTypeTree();
            subTypeTree.setEngineVersion(typeTree.getEngineVersion());
            subTypeTree.setVersion(-2);
View Full Code Here

        }
       
        Set<Integer> classIDs = asset.getClassIDs();
       
        for (Integer classID : classIDs) {
            TypeField classField = typeTree.getFields().get(classID);
           
            // skip filtered classes
            if (cf != null && !cf.accept(classID)) {
                continue;
            }
View Full Code Here

        bb.order(ByteOrder.LITTLE_ENDIAN);

        in = DataInputReader.newReader(bb);
       
        Map<Integer, TypeField> typeFields = asset.getTypeTree().getFields();
        TypeField type = typeFields.get(path.getClassID());
       
        // check if the type information is available
        if (type == null) {
            throw new IllegalArgumentException("Class not found in type tree");
        }
View Full Code Here

        // there should be exactly two fields in an array object: size and data
        if (subTypes.size() != 2) {
            throw new IOException("Unexpected number of array fields: " + subTypes.size());
        }
       
        TypeField typeSize = subTypes.get(0);
        TypeField typeData = subTypes.get(1);
       
        // check name of the two array fields
        if (!typeSize.getName().equals("size")) {
            throw new IOException("Unexpected array size field: " + typeSize);
        }
       
        if (!typeData.getName().equals("data")) {
            throw new IOException("Unexpected array data field: " + typeData);
        }
       
        // read the size field
        int size = (int) readValue(typeSize);
       
        UnityValue value = new UnityValue();
        value.setType(typeData.getType());
       
        switch (typeData.getType()) {
            // read byte arrays natively and wrap them as ByteBuffers,
            // which is much faster and more efficient than a list of wrappped
            // Byte/Integer objects
            case "SInt8":
            case "UInt8":
View Full Code Here

    public TypeField get(int classID, UnityVersion revision) {
        return get(classID, revision, true);
    }

    public TypeField get(int classID, UnityVersion version, boolean strict) {
        TypeField fieldNode = get(new ImmutablePair<>(classID, version));

        // if set to strict, only return exact matches or null
        if (fieldNode != null || strict) {
            return fieldNode;
        }

        TypeField fieldNodeB = null;
        UnityVersion versionB = null;

        TypeField fieldNodeC = null;
        UnityVersion versionC = null;

        for (Map.Entry<Pair<Integer, UnityVersion>, TypeField> entry : entrySet()) {
            Pair<Integer, UnityVersion> fieldNodeKey = entry.getKey();
            if (fieldNodeKey.getLeft() == classID) {
                TypeField fieldNodeEntry = entry.getValue();
                UnityVersion revisionEntry = fieldNodeKey.getRight();

                if (revisionEntry.getMajor() == version.getMajor()) {
                    if (revisionEntry.getMinor() == version.getMinor()) {
                        // if major and minor versions match, it will probably work
View Full Code Here

        }
    }

    public void split() throws IOException {
        List<ObjectPath> pathTable = asset.getPaths();
        TypeTree typeTree = asset.getTypeTree();

        // assets with just one object can't be split any further
        if (pathTable.size() == 1) {
            L.warning("Asset doesn't contain sub-assets!");
            return;
        }
       
        for (ObjectPath path : pathTable) {
            // skip filtered classes
            if (cf != null && !cf.accept(path)) {
                continue;
            }

            String className = ClassID.getNameForID(path.getClassID(), true);
           
            AssetFile subAsset = new AssetFile();
            subAsset.getHeader().setFormat(asset.getHeader().getFormat());
           
            ObjectPath subFieldPath = new ObjectPath();
            subFieldPath.setClassID1(path.getClassID1());
            subFieldPath.setClassID2(path.getClassID2());
            subFieldPath.setLength(path.getLength());
            subFieldPath.setOffset(0);
            subFieldPath.setPathID(1);
            subAsset.getPaths().add(subFieldPath);
           
            TypeTree subTypeTree = subAsset.getTypeTree();
            subTypeTree.setEngineVersion(typeTree.getEngineVersion());
            subTypeTree.setVersion(-2);
            subTypeTree.setFormat(typeTree.getFormat());
            subTypeTree.getFields().put(path.getClassID(), typeTree.getFields().get(path.getClassID()));

            subAsset.setDataBuffer(asset.getPathBuffer(path));
           
            Path subAssetDir = outputDir.resolve(className);
            if (Files.notExists(subAssetDir)) {
View Full Code Here

       
        indentLevel--;
    }
   
    public void dumpStruct() throws IOException {
        TypeTree typeTree = asset.getTypeTree();
       
        if (typeTree.getFields().isEmpty()) {
            L.info("No type tree available");
            return;
        }
       
        Set<Integer> classIDs = asset.getClassIDs();
       
        for (Integer classID : classIDs) {
            TypeField classField = typeTree.getFields().get(classID);
           
            // skip filtered classes
            if (cf != null && !cf.accept(classID)) {
                continue;
            }
View Full Code Here

    @Override
    public void processAsset(AssetFile asset) throws IOException {
        List<ObjectPath> paths = asset.getPaths();
        List<AssetRef> refTable = asset.getReferences();
        AssetHeader header = asset.getHeader();
        TypeTree typeTree = asset.getTypeTree();
       
        ps.println("Header");
        ps.println("  File size: " + StringUtils.humanReadableByteCount(header.getFileSize(), true));
        ps.println("  Tree size: " + StringUtils.humanReadableByteCount(header.getTreeSize(), true));
        ps.println("  Format: " + header.getFormat());
        ps.println("  Data offset: " + header.getDataOffset());
        ps.println();
       
        ps.println("Serialized data");
        ps.println("  Revision: " + typeTree.getEngineVersion());
        ps.println("  Version: " + typeTree.getVersion());
        ps.println("  Type tree: " + BooleanUtils.toStringYesNo(!typeTree.getFields().isEmpty()));
        ps.println("  Objects: " + paths.size());
        ps.println();
       
        if (!refTable.isEmpty()) {
            ps.println("External references");
View Full Code Here

TOP

Related Classes of info.ata4.unity.serdes.db.FieldTypeMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.