Esempio n. 1
0
        public SgbGroup(SgbFile parent, byte[] buffer, int offset)
        {
            this.Parent = parent;

            var entriesOffset = offset;

            this.Header = buffer.ToStructure <HeaderData>(ref entriesOffset);
            this.Name   = buffer.ReadString(offset + Header.NameOffset);

            Entries = new ISgbGroupEntry[Header.EntryCount];
            for (var i = 0; i < Header.EntryCount; ++i)
            {
                var entryOffset = entriesOffset + BitConverter.ToInt32(buffer, entriesOffset + i * 4);

                var type = (SgbGroupEntryType)BitConverter.ToInt32(buffer, entryOffset);
                switch (type)
                {
                case SgbGroupEntryType.Model:
                    Entries[i] = new SgbModelEntry(Parent.File.Pack.Collection, buffer, entryOffset);
                    break;

                default:
                    //System.Diagnostics.Trace.WriteLine(string.Format("{0}: Type {1} at 0x{2:X} in {3}", Parent.File.Path, type, entryOffset, Name));
                    break;
                    // TODO: Work out other parts.
                }
            }
        }
Esempio n. 2
0
        public SgbGroup(SgbFile parent, byte[] buffer, int offset)
        {
            this.Parent = parent;

            var entriesOffset = offset;
            this.Header = buffer.ToStructure<HeaderData>(ref entriesOffset);
            this.Name = buffer.ReadString(offset + Header.NameOffset);

            Entries = new ISgbGroupEntry[Header.EntryCount];
            for(var i = 0; i < Header.EntryCount; ++i) {
                var entryOffset = entriesOffset + BitConverter.ToInt32(buffer, entriesOffset + i * 4);

                var type = (SgbGroupEntryType)BitConverter.ToInt32(buffer, entryOffset);
                switch (type) {
                    case SgbGroupEntryType.Model:
                        Entries[i] = new SgbModelEntry(Parent.File.Pack.Collection, buffer, entryOffset);
                        break;
                    default:
                        //System.Diagnostics.Trace.WriteLine(string.Format("{0}: Type {1} at 0x{2:X} in {3}", Parent.File.Path, type, entryOffset, Name));
                        break;
                        // TODO: Work out other parts.
                }
            }
        }
Esempio n. 3
0
        public SgbGroup(SgbFile parent, byte[] buffer, int offset, bool isOffset1C = false)
        {
            this.Parent = parent;

            var entriesOffset = offset;
            int count         = 0;

            if (isOffset1C)
            {
                this.Header         = buffer.ToStructure <HeaderData>(entriesOffset);
                this.Offset1CHeader = buffer.ToStructure <Offset1CHeaderData>(ref entriesOffset);
                this.Name           = buffer.ReadString(offset + Offset1CHeader.NameOffset);
                this.ModelFile1     = buffer.ReadString(offset + Offset1CHeader.ModelFileOffset + 1);
                this.ModelFile2     = buffer.ReadString(offset + Offset1CHeader.ModelFileOffset2 + 1);
                this.ModelFile3     = buffer.ReadString(offset + Offset1CHeader.NameOffset2 + 64);

                count   = Offset1CHeader.EntryCount;
                Entries = new ISgbGroupEntry[count];

                for (var i = 0; i < count; ++i)
                {
                    try {
                        var entryOffset = entriesOffset + (i * 24);
                        Entries[i] = new SgbGroup1CEntry(parent.File.Pack.Collection, buffer, entryOffset);
                        break;
                    }
                    catch (Exception e) {
                        System.Diagnostics.Debug.WriteLine(e.Message);
                    }
                }
            }
            else
            {
                this.Header = buffer.ToStructure <HeaderData>(ref entriesOffset);
                this.Name   = buffer.ReadString(offset + Header.NameOffset);
                count       = Header.EntryCount;
                Entries     = new ISgbGroupEntry[count];

                for (var i = 0; i < count; ++i)
                {
                    try {
                        var entryOffset = entriesOffset + BitConverter.ToInt32(buffer, entriesOffset + i * 4);

                        var type    = (SgbGroupEntryType)BitConverter.ToInt32(buffer, entryOffset);
                        var typeStr = ((Lgb.LgbEntryType)type).ToString();
                        switch (type)
                        {
                        case SgbGroupEntryType.Model:
                            Entries[i] = new SgbModelEntry(Parent.File.Pack.Collection, buffer, entryOffset);
                            break;

                        case SgbGroupEntryType.Gimmick:
                            Entries[i] = new SgbGimmickEntry(Parent.File.Pack.Collection, buffer, entryOffset);
                            break;

                        case SgbGroupEntryType.Light:
                            Entries[i] = new SgbLightEntry(Parent.File.Pack.Collection, buffer, entryOffset);
                            break;

                        case SgbGroupEntryType.Vfx:
                            Entries[i] = new SgbVfxEntry(Parent.File.Pack.Collection, buffer, entryOffset);
                            break;

                        default:
                            //System.Diagnostics.Trace.WriteLine(string.Format("{0}: Type {1} at 0x{2:X} in {3}", Parent.File.Path, type, entryOffset, Name));
                            break;
                            // TODO: Work out other parts.
                        }
                    }
                    catch (Exception e) {
                        System.Diagnostics.Debug.WriteLine(e.Message);
                    }
                }
            }
        }