Exemplo n.º 1
0
        public static void DecompileAllPlDats(string path, string outputTxt)
        {
            using (StreamWriter w = new StreamWriter(new FileStream(outputTxt, FileMode.Create)))
                foreach (var f in Directory.GetFiles(path))
                {
                    if (Regex.IsMatch(Path.GetFileName(f), @"Pl..\.dat"))
                    {
                        HSDRawFile hsd = new HSDRawFile(f);

                        foreach (var r in hsd.Roots)
                        {
                            if (r.Data is SBM_FighterData pl)
                            {
                                w.WriteLine(r.Name);

                                ActionDecompiler d = new ActionDecompiler();

                                var sa = pl.FighterCommandTable.Commands;

                                int index = 0;
                                foreach (var v in sa)
                                {
                                    w.WriteLine(d.Decompile("Function_" + index++ + v.Name != null ? "_" + v.Name : "", v));
                                }
                            }
                        }
                    }
                }
        }
Exemplo n.º 2
0
        public static void Deconstruct(string plFilePath, string ajFilePath, string outputFolder)
        {
            var plfile = new HSDRawFile(plFilePath);

            var path = Path.GetDirectoryName(plFilePath) + "\\" + outputFolder + "\\";

            Directory.CreateDirectory(path);

            var data = plfile.Roots[0].Data as SBM_FighterData;

            if (data == null)
            {
                return;
            }

            var ajfile = new HSDRawFile(ajFilePath);

            foreach (var prop in data.GetType().GetProperties())
            {
                var val = prop.GetValue(data) as HSDAccessor;

                if (val == null)
                {
                    continue;
                }
                if (prop.PropertyType == typeof(SBM_CommonFighterAttributes))
                {
                    var attr = prop.GetValue(data) as SBM_CommonFighterAttributes;
                    using (StreamWriter w = new StreamWriter(new FileStream(path + prop.Name + ".ini", FileMode.Create)))
                    {
                        foreach (var v in attr.GetType().GetProperties())
                        {
                            if (v.Name.Equals("TrimmedSize"))
                            {
                                continue;
                            }
                            w.WriteLine($"{v.Name}={v.GetValue(attr)}");
                        }
                    }
                }
                else
                if (prop.Name.Equals("SubActionTable"))
                {
                    ScriptFile f = new ScriptFile();

                    f.Actions = new ActionGroup[val._s.Length / 0x18];

                    var ActionDecompiler = new ActionDecompiler();
                    HashSet <string> ExportedAnimations = new HashSet <string>();

                    for (int i = 0; i < f.Actions.Length; i++)
                    {
                        SBM_FighterAction subaction = new HSDRaw.Melee.Pl.SBM_FighterAction();
                        subaction._s = val._s.GetEmbeddedStruct(0x18 * i, 0x18);

                        if (!ExportedAnimations.Contains(subaction.Name) && subaction.Name != null && subaction.Name != "")
                        {
                            ExportedAnimations.Add(subaction.Name);
                            if (ajFilePath != null && File.Exists(ajFilePath))
                            {
                                using (BinaryReaderExt r = new BinaryReaderExt(new FileStream(ajFilePath, FileMode.Open)))
                                {
                                    var animdata = r.GetSection((uint)subaction.AnimationOffset, subaction.AnimationSize);
                                    File.WriteAllBytes(path + "Animations\\" + subaction.Name + ".dat", animdata);
                                }
                            }
                        }

                        ActionGroup g = new ActionGroup();
                        g.animation_name = subaction.Name;
                        g.flags          = (int)subaction.Flags;
                        g.script         = ActionDecompiler.Decompile("Func_" + i.ToString("X3"), subaction.SubAction);
                        //g.script =
                        g.off        = subaction.AnimationOffset;
                        g.size       = subaction.AnimationSize;
                        f.Actions[i] = g;

                        Console.WriteLine(i + " " + subaction.Name + " " + subaction._s.GetReference <HSDAccessor>(0x0C)._s.References.Count);
                    }

                    XmlSerializer writer = new XmlSerializer(typeof(ScriptFile));
                    using (var w = new XmlTextWriter(new FileStream(path + prop.Name + ".txt", FileMode.Create), Encoding.UTF8))
                    {
                        w.Formatting = Formatting.Indented;
                        writer.Serialize(w, f);
                    }
                }
                else
                {
                    HSDRootNode root = new HSDRootNode();

                    root.Name = prop.Name;

                    root.Data = val;

                    HSDRawFile file = new HSDRawFile();
                    file.Roots.Add(root);

                    file.Save(path + prop.Name + ".dat");

                    Console.WriteLine(prop.Name + " " + val._s.GetSubStructs().Count);
                }
            }
        }
Exemplo n.º 3
0
 public Client(IDatabase db)
 {
     _decompiler     = new ActionDecompiler();
     _csharpCompiler = new CSharpCompiler();
     _luaHandler     = new LuaHandler(db);
 }