예제 #1
0
 public AssetDetails(AssetPPtr pointer, AssetIcon icon, string path = "", string type = "", int size = 0)
 {
     this.pointer = pointer;
     this.icon    = icon;
     this.path    = path;
     this.type    = type;
     this.size    = size;
 }
예제 #2
0
 public FsmEventTarget(AssetNameResolver namer, AssetTypeValueField field)
 {
     target         = (EventTarget)field.Get("target").GetValue().AsInt();
     excludeSelf    = new FsmBool(namer, field.Get("excludeSelf"));
     gameObject     = new FsmOwnerDefault(namer, field.Get("gameObject"));
     fsmName        = new FsmString(namer, field.Get("fsmName"));
     sendToChildren = new FsmBool(namer, field.Get("sendToChildren"));
     fsmComponent   = StructUtil.ReadNamedAssetPPtr(namer, field.Get("fsmComponent"));
 }
예제 #3
0
 public FsmTemplateControl(AssetNameResolver namer, AssetTypeValueField field)
 {
     fsmTemplate     = StructUtil.ReadAssetPPtr(field.Get("fsmTemplate"));
     fsmVarOverrides = new FsmVarOverride[field.Get("fsmVarOverrides").GetChildrenCount()];
     for (int i = 0; i < fsmVarOverrides.Length; i++)
     {
         fsmVarOverrides[i] = new FsmVarOverride(namer, field.Get("fsmVarOverrides")[i]);
     }
 }
예제 #4
0
 public ulong Read(ulong absFilePos, AssetsFileReader reader, uint format, bool bigEndian)
 {
     len   = reader.ReadUInt32();
     items = new AssetPPtr[len];
     for (int i = 0; i < len; i++)
     {
         items[i] = new AssetPPtr(reader.ReadUInt32(), reader.ReadUInt64());
     }
     return(reader.Position);
 }
예제 #5
0
        public string GetName(AssetPPtr pptr)
        {
            if (pptr.pathID == 0)
            {
                return(string.Empty);
            }
            AssetExternal extObj = am.GetExtAsset(inst, pptr.fileID, pptr.pathID, true);
            string        name   = GetAssetNameFastModded(extObj.file.file, am.classFile, extObj.info);

            return(name);
        }
예제 #6
0
        public NamedAssetPPtr GetNamedPtr(AssetPPtr pptr)
        {
            if (pptr.pathID == 0)
            {
                return(new NamedAssetPPtr(pptr.fileID, pptr.pathID, string.Empty, string.Empty));
            }
            AssetExternal extObj = am.GetExtAsset(inst, pptr.fileID, pptr.pathID, true);
            string        name   = GetAssetNameFastModded(extObj.file.file, am.classFile, extObj.info);
            string        file   = extObj.file.name;

            return(new NamedAssetPPtr(pptr.fileID, pptr.pathID, name, file));
        }
예제 #7
0
        private async void ReturnAssetToGoTo()
        {
            int    fileId     = ddFileId.SelectedIndex; //hopefully in order
            string pathIdText = boxPathId.Text;

            if (fileId < 0)
            {
                await MessageBoxUtil.ShowDialog(this, "Bad input", "File was invalid.");

                return;
            }

            if (!long.TryParse(pathIdText, out long pathId))
            {
                await MessageBoxUtil.ShowDialog(this, "Bad input", "Path ID was invalid.");

                return;
            }

            AssetPPtr pptr = new AssetPPtr(fileId, pathId);

            Close(pptr);
        }
예제 #8
0
        private static object ParseReplacer(AssetsFileReader reader, bool prefReplacersInMemory)
        {
            short replacerType = reader.ReadInt16();
            byte  fileType     = reader.ReadByte();

            if (fileType == 0) //BundleReplacer
            {
                string oldName                  = reader.ReadCountStringInt16();
                string newName                  = reader.ReadCountStringInt16();
                bool   hasSerializedData        = reader.ReadByte() != 0; //guess
                long   replacerCount            = reader.ReadInt64();
                List <AssetsReplacer> replacers = new List <AssetsReplacer>();
                for (int i = 0; i < replacerCount; i++)
                {
                    AssetsReplacer assetReplacer = (AssetsReplacer)ParseReplacer(reader, prefReplacersInMemory);
                    replacers.Add(assetReplacer);
                }

                if (replacerType == 4) //BundleReplacerFromAssets
                {
                    //we have to null the assetsfile here and call init later
                    BundleReplacer replacer = new BundleReplacerFromAssets(oldName, newName, null, replacers, 0);
                    return(replacer);
                }
            }
            else if (fileType == 1)                         //AssetsReplacer
            {
                byte   unknown01       = reader.ReadByte(); //always 1
                int    fileId          = reader.ReadInt32();
                long   pathId          = reader.ReadInt64();
                int    classId         = reader.ReadInt32();
                ushort monoScriptIndex = reader.ReadUInt16();

                List <AssetPPtr> preloadDependencies = new List <AssetPPtr>();
                int preloadDependencyCount           = reader.ReadInt32();
                for (int i = 0; i < preloadDependencyCount; i++)
                {
                    AssetPPtr pptr = new AssetPPtr(reader.ReadInt32(), reader.ReadInt64());
                    preloadDependencies.Add(pptr);
                }

                if (replacerType == 0) //remover
                {
                    AssetsReplacer replacer = new AssetsRemover(fileId, pathId, classId, monoScriptIndex);
                    if (preloadDependencyCount != 0)
                    {
                        replacer.SetPreloadDependencies(preloadDependencies);
                    }

                    return(replacer);
                }
                else if (replacerType == 2) //adder/replacer?
                {
                    Hash128?          propertiesHash = null;
                    Hash128?          scriptHash     = null;
                    ClassDatabaseFile?classData      = null;
                    AssetsReplacer    replacer;

                    bool flag1 = reader.ReadByte() != 0; //no idea, couldn't get it to be 1
                    if (flag1)
                    {
                        throw new NotSupportedException("you just found a file with the mysterious flag1 set, send the file to nes");
                    }

                    bool flag2 = reader.ReadByte() != 0; //has properties hash
                    if (flag2)
                    {
                        propertiesHash = new Hash128(reader);
                    }

                    bool flag3 = reader.ReadByte() != 0; //has script hash
                    if (flag3)
                    {
                        scriptHash = new Hash128(reader);
                    }

                    bool flag4 = reader.ReadByte() != 0; //has cldb
                    if (flag4)
                    {
                        classData = new ClassDatabaseFile();
                        classData.Read(reader);
                    }

                    long bufLength = reader.ReadInt64();
                    if (prefReplacersInMemory)
                    {
                        byte[] buf = reader.ReadBytes((int)bufLength);
                        replacer = new AssetsReplacerFromMemory(fileId, pathId, classId, monoScriptIndex, buf);
                    }
                    else
                    {
                        replacer = new AssetsReplacerFromStream(fileId, pathId, classId, monoScriptIndex, reader.BaseStream, reader.Position, bufLength);
                    }

                    if (propertiesHash != null)
                    {
                        replacer.SetPropertiesHash(propertiesHash.Value);
                    }
                    if (scriptHash != null)
                    {
                        replacer.SetScriptIDHash(scriptHash.Value);
                    }
                    if (scriptHash != null)
                    {
                        replacer.SetTypeInfo(classData, null, false); //idk what the last two are supposed to do
                    }
                    if (preloadDependencyCount != 0)
                    {
                        replacer.SetPreloadDependencies(preloadDependencies);
                    }

                    return(replacer);
                }
            }
            return(null);
        }
        public static AssetsReplacer ConvertSpriteRenderer(AssetTypeValueField baseField, ulong pathId, AssetPPtr goPPtr, AssetPPtr matPPtr, AssetPPtr spritePPtr)
        {
            AssetTypeValueField m_GameObject = baseField.Get("m_GameObject");
            AssetTypeValueField m_Materials  = baseField.Get("m_Materials").Get("Array");

            if (m_Materials.GetValue().AsArray().size != 1)
            {
                Console.WriteLine("warning, sprite material is not 1! (" + m_Materials.GetValue().AsArray().size + ")");
            }
            AssetTypeValueField m_Sprite = baseField.Get("m_Sprite");

            //GameObject refs
            m_GameObject.Get("m_FileID").GetValue().Set((int)goPPtr.fileID);
            m_GameObject.Get("m_PathID").GetValue().Set((long)goPPtr.pathID);

            //Material refs
            AssetTypeArray arr = m_Materials.value.value.asArray;

            arr.size = 1;
            m_Materials.value.value.asArray = arr;
            m_Materials.pChildren           = new AssetTypeValueField[1];
            AssetTypeValueField m_FileID = new AssetTypeValueField()
            {
                templateField = m_Materials.templateField.children[1].children[0],
                childrenCount = 0,
                pChildren     = new AssetTypeValueField[0],
                value         = new AssetTypeValue(EnumValueTypes.ValueType_Int32, (int)matPPtr.fileID)
            };
            AssetTypeValueField m_PathID = new AssetTypeValueField()
            {
                templateField = m_Materials.templateField.children[1].children[1],
                childrenCount = 0,
                pChildren     = new AssetTypeValueField[0],
                value         = new AssetTypeValue(EnumValueTypes.ValueType_Int64, (long)matPPtr.pathID)
            };
            AssetTypeValueField m_Material = new AssetTypeValueField()
            {
                templateField = m_Materials.templateField.children[1],
                childrenCount = 2,
                pChildren     = new AssetTypeValueField[2]
                {
                    m_FileID,
                    m_PathID
                },
                value = new AssetTypeValue(EnumValueTypes.ValueType_Array, 0)
            };

            //Sprite refs
            m_Sprite.Get("m_FileID").GetValue().Set((int)spritePPtr.fileID);
            m_Sprite.Get("m_PathID").GetValue().Set((long)spritePPtr.pathID);

            byte[] spriteRendererAsset;
            using (MemoryStream memStream = new MemoryStream())
                using (AssetsFileWriter writer = new AssetsFileWriter(memStream))
                {
                    writer.bigEndian = false;
                    baseField.Write(writer);
                    spriteRendererAsset = memStream.ToArray();
                }
            return(new AssetsReplacerFromMemory(0, pathId, 0xD4, 0xFFFF, spriteRendererAsset));
        }