Exemplo n.º 1
0
 protected virtual void OnPropertyChanged(string Name)
 {
     if (PropertyChanged != null)
     {
         PropertyChanged(this, new PropertyChangedEventArgs(Name));
         AELogger.Log(Name);
     }
 }
Exemplo n.º 2
0
 public static void LogUnkEnum(Enum en, string parent, string Name, int Index = -1)
 {
     if (!Enum.IsDefined(en.GetType(), en))
     {
         AELogger.Log("undefined " + en.GetType().Name + " enum value: "
                      + en + " in  " + parent + " named " + Name +
                      (Index == -1 ? "" : (" at index " + Index)),
                      false
                      );
     }
 }
Exemplo n.º 3
0
 public static void LogUnkEnumFlags(Enum en, string parent, string Name, int Index = -1)
 {
     if (Char.IsDigit(en.ToString()[0]) &&
         en.ToString()[0] != '0')
     {
         AELogger.Log("undefined " + en.GetType().Name + " enum flag value: "
                      + en + " in " + parent + " named " + Name +
                      (Index == -1 ? "" : (" at index " + Index)),
                      false
                      );
     }
 }
Exemplo n.º 4
0
        public static BACFile FromFilename(string name, BCMFile bcm)
        {
            using (var fs = File.OpenRead(name))
                using (var tracker = new TrackingStream(fs))
                    using (var inFile = new BinaryReader(tracker))
                    {
                        AELogger.Log(AELogger.O_SEPARATOR, false);
                        tracker.SetLabel("Header");

                        if (new String(inFile.ReadChars(4)) != "#BAC")
                        {
                            throw new IOException("Not a valid BAC file");
                        }
                        tracker.IgnoreBytes(8);
                        inFile.BaseStream.Seek(12);

                        ushort ScriptCount         = inFile.ReadUInt16();
                        ushort VFXScriptCount      = inFile.ReadUInt16();
                        uint   HitboxTableSize     = inFile.ReadUInt32();
                        int    ScriptOffset        = inFile.ReadInt32();
                        int    VFXScriptOffset     = inFile.ReadInt32();
                        int    ScriptNameOffset    = inFile.ReadInt32();
                        int    VFXScriptNameOffset = inFile.ReadInt32();
                        int    HitboxTableOffset   = inFile.ReadInt32();

                        AELogger.Log("Header done, reading floats");

                        var bac = new BACFile();
                        for (int i = 0; i < 0x1c; i++)
                        {
                            var list = new ObservableCollection <float>();
                            for (int j = 0; j < 6; j++)
                            {
                                list.Add(inFile.ReadSingle());
                            }
                            bac.UnknownFloatData.Add(list);
                        }
                        AELogger.Log("floats done, reading scripts");

                        for (int i = 0; i < ScriptCount; i++)
                        {
                            bac.Scripts.Add(new Script(i));
                        }
                        for (int i = 0; i < VFXScriptCount; i++)
                        {
                            bac.VFXScripts.Add(new Script(i));
                        }
                        for (int i = 0; i < HitboxTableSize; i++)
                        {
                            bac.HitboxTable.Add(new HitBoxDataset(i));
                        }

                        //Link BCM
                        if (bcm != null)
                        {
                            foreach (BCM.Move move in bcm.Moves)
                            {
                                if (move.ScriptIndex != -1)
                                {
                                    move.Script = bac.Scripts[move.ScriptIndex];
                                }
                            }
                        }
                        //Read Scripts
                        readScripts(inFile, bac.Scripts, bcm, ScriptCount, ScriptOffset, ScriptNameOffset, bac);
                        readScripts(inFile, bac.VFXScripts, bcm, VFXScriptCount, VFXScriptOffset, VFXScriptNameOffset, bac);
                        AELogger.Log("scripts done, reading hitboxtable");
                        //Read Hitbox Table
                        for (int i = 0; i < HitboxTableSize; i++)
                        {
                            tracker.SetLabel("HitboxTable#" + i.ToString());
                            inFile.BaseStream.Seek(HitboxTableOffset + i * 4);
                            inFile.BaseStream.Seek(inFile.ReadUInt32());
                            if (inFile.BaseStream.Position == 0)
                            {
                                continue;
                            }
                            var dataset = bac.HitboxTable[i];
                            LoadedHitBoxCount = i;
                            for (int j = 0; j < 12; j++)
                            {
                                HitBoxData data = new HitBoxData(j);
                                dataset.Data.Add(data);
                                data.Damage = inFile.ReadInt16();
                                data.Stun   = inFile.ReadInt16();
                                data.Effect = (HitBoxData.HitBoxEffect)inFile.ReadUInt16();
                                Util.LogUnkEnum(data.Effect, "Hitbox #" + dataset.Index, "hitboxdataset", j);

                                var index = inFile.ReadInt16() + HitBoxData.getIndexOffset(data.Effect);
                                if (index > -1)
                                {
                                    data.OnHit = bac.Scripts.Where(x => x.Index == index).First();
                                }
                                else
                                {
                                    data.OnHit = new Script(index);
                                    if (index <= -1)
                                    {
                                        AELogger.Log("negative index " + index + " in hitboxdata #" + i);
                                    }
                                }

                                data.SelfHitstop = inFile.ReadUInt16();
                                data.SelfShaking = inFile.ReadUInt16();
                                data.TgtHitstop  = inFile.ReadUInt16();
                                data.TgtShaking  = inFile.ReadUInt16();
                                data.HitGFX      = inFile.ReadInt16();
                                data.Unknown1    = inFile.ReadInt32();
                                data.Unused      = (Unused16)inFile.ReadInt16();
                                data.HitGFX2     = inFile.ReadInt16();
                                data.Unused2     = (Unused32)inFile.ReadInt32();
                                data.Unused3     = (Unused16)inFile.ReadInt16();
                                data.HitSFX      = inFile.ReadInt16();
                                data.HitSFX2     = inFile.ReadInt16();
                                data.TgtSFX      = inFile.ReadInt16();

                                data.ArcadeScore = inFile.ReadUInt16();
                                data.SelfMeter   = inFile.ReadInt16();
                                data.TgtMeter    = inFile.ReadInt16();
                                data.JuggleStart = inFile.ReadInt16();
                                data.TgtAnimTime = inFile.ReadInt16();
                                data.MiscFlag    = (HitBoxData.MiscFlags)inFile.ReadInt32();
                                data.VelX        = inFile.ReadSingle();
                                data.VelY        = inFile.ReadSingle();

                                data.VelZ         = inFile.ReadSingle();
                                data.PushbackDist = inFile.ReadSingle();
                                data.AccX         = inFile.ReadSingle();
                                data.AccY         = inFile.ReadSingle();
                                data.AccZ         = inFile.ReadSingle();
                            }
                        }
                        AELogger.Log("hitbox done");
                        List <HitBoxDataset> nullHitboxData = bac.HitboxTable.Where(x => x.Data.Count() == 0).ToList();
                        foreach (HitBoxDataset tmp in nullHitboxData)
                        {
                            bac.HitboxTable.Remove(tmp);
                        }
                        FilterScripts(bac.Scripts);
                        FilterScripts(bac.VFXScripts);
                        AELogger.Log(AELogger.O_SEPARATOR, false);

                        return(bac);
                    }
        }
Exemplo n.º 5
0
        public static BCMFile FromFilename(string filename)
        {
            using (var fs = File.OpenRead(filename))
                using (var tracker = new TrackingStream(fs))
                    using (var inFile = new BinaryReader(tracker))
                    {
                        AELogger.Log(AELogger.O_SEPARATOR, false);
                        var bcm = new BCMFile();
                        tracker.SetLabel("Header");
                        var s = new string(inFile.ReadChars(4));
                        //Console.WriteLine("{0} - {1:X} bytes",s,inFile.BaseStream.Length);
                        if (s != "#BCM")
                        {
                            throw new Exception("This is not a valid BCM File!");
                        }
                        tracker.IgnoreBytes(12);
                        inFile.BaseStream.Seek(16);

                        var ChargeCount     = inFile.ReadUInt16();
                        var InputCount      = inFile.ReadUInt16();
                        var MoveCount       = inFile.ReadUInt16();
                        var CancelListCount = inFile.ReadUInt16();
                        for (int i = 0; i < CancelListCount; i++)
                        {
                            bcm.CancelLists.Add(new CancelList());
                        }
                        var ChargeOffset      = inFile.ReadUInt32();
                        var ChargeNamesOffset = inFile.ReadUInt32();

                        var InputOffset      = inFile.ReadUInt32();
                        var InputNamesOffset = inFile.ReadUInt32();

                        var MoveOffset      = inFile.ReadUInt32();
                        var MoveNamesOffset = inFile.ReadUInt32();

                        var CancelListOffset      = inFile.ReadUInt32();
                        var CancelListNamesOffset = inFile.ReadUInt32();

                        #region Read Charges
                        AELogger.Log("Header done, reading charges");
                        tracker.SetLabel("Charges");
                        for (int i = 0; i < ChargeCount; i++)
                        {
                            var charge = new Charge();
                            inFile.BaseStream.Seek(ChargeNamesOffset + i * 4);
                            inFile.BaseStream.Seek(inFile.ReadUInt32());
                            charge.Name = inFile.ReadCString();
                            inFile.BaseStream.Seek(ChargeOffset + i * 16);
                            charge.Input = (Input)inFile.ReadUInt16();
                            Util.LogUnkEnumFlags(charge.Input, "charge", charge.Name);
                            charge.Unknown1  = inFile.ReadUInt16();
                            charge.MoveFlags = (MoveFlags)inFile.ReadUInt16();
                            Util.LogUnkEnumFlags(charge.MoveFlags, "charge", charge.Name);
                            charge.Frames       = inFile.ReadUInt32();
                            charge.Unknown3     = inFile.ReadUInt16();
                            charge.StorageIndex = inFile.ReadUInt32();
                            //Console.WriteLine(charge);
                            bcm.Charges.Add(charge);
                        }

                        #endregion

                        #region Read Inputs
                        AELogger.Log("charges done, reading motions");
                        tracker.SetLabel("Inputs");
                        bcm.InputMotions.Add(InputMotion.NONE);
                        for (int i = 0; i < InputCount; i++)
                        {
                            var inputMotion = new InputMotion("tmp");
                            inFile.BaseStream.Seek(InputNamesOffset + i * 4);
                            inFile.BaseStream.Seek(inFile.ReadUInt32());
                            inputMotion.Name = inFile.ReadCString();
                            //Console.WriteLine(inputMotion.Name);

                            inFile.BaseStream.Seek(InputOffset + i * 0xC4);
                            var cnt = inFile.ReadUInt32();
                            for (int j = 0; j < cnt; j++)
                            {
                                var entry = new InputMotionEntry();
                                entry.Type = (InputType)inFile.ReadUInt16();
                                Util.LogUnkEnum(entry.Type, "motion", inputMotion.Name, j);

                                entry.Buffer = inFile.ReadUInt16();
                                System.UInt16 a = inFile.ReadUInt16();
                                if (entry.Type == InputType.CHARGE)
                                {
                                    entry.Charge = bcm.Charges[a];
                                }
                                entry.Input = (Input)a;
                                Util.LogUnkEnum(entry.Input, "motion", inputMotion.Name, j);

                                entry.MoveFlags = (MoveFlags)inFile.ReadUInt16();
                                Util.LogUnkEnumFlags(entry.MoveFlags, "motion", inputMotion.Name, j);

                                entry.Flags = (InputReqType)inFile.ReadUInt16();
                                Util.LogUnkEnum(entry.Flags, "motion", inputMotion.Name, j);
                                entry.Requirement = inFile.ReadUInt16();
                                inputMotion.Entries.Add(entry);
                                //Console.WriteLine(entry);
                            }
                            tracker.IgnoreBytes(12 * (16 - cnt));
                            bcm.InputMotions.Add(inputMotion);
                        }

                        #endregion

                        #region Read Moves
                        AELogger.Log("motions done, reading moves");
                        tracker.SetLabel("Moves");
                        for (int i = 0; i < MoveCount; i++)
                        {
                            var move = new Move();
                            inFile.BaseStream.Seek(MoveNamesOffset + i * 4);
                            inFile.BaseStream.Seek(inFile.ReadUInt32());
                            move.Name = inFile.ReadCString();
                            //Console.WriteLine(move.Name);

                            inFile.BaseStream.Seek(MoveOffset + i * 0x54);

                            move.Input = (Input)inFile.ReadUInt16();
                            Util.LogUnkEnumFlags(move.Input, "move", move.Name);

                            move.MoveFlags = (MoveFlags)inFile.ReadUInt16();
                            Util.LogUnkEnumFlags(move.MoveFlags, "move", move.Name);

                            move.PositionRestriction = (PositionRestriction)inFile.ReadUInt16();
                            Util.LogUnkEnum(move.PositionRestriction, "move", move.Name);

                            move.Restriction = (MoveRestriction)inFile.ReadUInt16();
                            Util.LogUnkEnumFlags(move.MoveFlags, "move", move.Name);

                            move.Unk1 = inFile.ReadUInt16();

                            move.StateRestriction = (Move.MoveStateRestriction)inFile.ReadUInt16();
                            Util.LogUnkEnum(move.StateRestriction, "move", move.Name);

                            move.MiscRestriction = (Move.MoveMiscRestriction)inFile.ReadUInt32();
                            Util.LogUnkEnum(move.MiscRestriction, "move", move.Name);

                            move.UltraRestriction = (Move.MoveUltraRestriction)inFile.ReadUInt32();
                            Util.LogUnkEnum(move.UltraRestriction, "move", move.Name);

                            move.PositionRestrictionDistance = inFile.ReadSingle();
                            move.EXRequirement    = inFile.ReadInt16();
                            move.EXCost           = inFile.ReadInt16();
                            move.UltraRequirement = inFile.ReadInt16();
                            move.UltraCost        = inFile.ReadInt16();
                            var index = inFile.ReadInt32();
                            if (index != -1 && index < bcm.InputMotions.Count)
                            {
                                move.InputMotion = bcm.InputMotions[index + 1];
                            }
                            else
                            {
                                move.InputMotion = InputMotion.NONE;
                            }
                            move.ScriptIndex = inFile.ReadInt32();

                            /* AI data */
                            move.Features = (MoveFeatureFlags)inFile.ReadUInt32();
                            Util.LogUnkEnumFlags(move.Features, "move", move.Name);

                            move.CpuMinRange    = inFile.ReadSingle();
                            move.CpuMaxRange    = inFile.ReadSingle();
                            move.Unk2           = inFile.ReadUInt32();
                            move.Unk3           = inFile.ReadUInt16();
                            move.CpuPassiveMove = inFile.ReadUInt16();
                            move.CpuCounterMove = inFile.ReadUInt16();
                            move.CpuVsStand     = inFile.ReadUInt16();
                            move.CpuVsCrouch    = inFile.ReadUInt16();
                            move.CpuVsAir       = inFile.ReadUInt16();
                            move.CpuVsDown      = inFile.ReadUInt16();
                            move.CpuVsStunned   = inFile.ReadUInt16();
                            move.CpuProbeMove   = inFile.ReadUInt16();
                            move.CpuVsVeryClose = inFile.ReadUInt16();
                            move.CpuVsClose     = inFile.ReadUInt16();
                            move.CpuVsMidRange  = inFile.ReadUInt16();
                            move.CpuVsFar       = inFile.ReadUInt16();
                            move.CpuVsVeryFar   = inFile.ReadUInt16();

                            bcm.Moves.Add(move);
                        }

                        #endregion

                        #region ReadCancels
                        AELogger.Log("moves done, reading cancels");
                        tracker.SetLabel("Cancels");
                        for (int i = 0; i < CancelListCount; i++)
                        {
                            var cl = bcm.CancelLists[i];
                            inFile.BaseStream.Seek(CancelListNamesOffset + i * 4);
                            inFile.BaseStream.Seek(inFile.ReadUInt32());
                            cl.Name = inFile.ReadCString();
                            //Console.WriteLine(cl.Name);

                            inFile.BaseStream.Seek(CancelListOffset + i * 0x8);
                            var count = inFile.ReadUInt32();
                            var off   = inFile.ReadUInt32();
                            inFile.BaseStream.Seek(off - 8, SeekOrigin.Current);
                            for (int j = 0; j < count; j++)
                            {
                                var x = inFile.ReadInt16();
                                //Console.WriteLine(x);
                                if (x == -1)
                                {
                                    cl.Moves.Add(Move.NULL);
                                }
                                else if (x < bcm.Moves.Count)
                                {
                                    cl.Moves.Add(bcm.Moves[x]);
                                }
                                else
                                {
                                    AELogger.Log("WARNING: Out of range move detected!!!!");
                                }
                            }
                        }
                        AELogger.Log("cancels done");
                        #endregion

                        ////Console.WriteLine(tracker.Report());
                        AELogger.Log(AELogger.O_SEPARATOR, false);
                        return(bcm);
                    }
        }