Example #1
0
        public override void Parse(MetaFile meta, CBlockDesc CBlockDesc)
        {
            this.Meta          = meta;
            this.MetaStructure = CBlockDesc;

            this.Version    = CBlockDesc.version;
            this.Flags      = CBlockDesc.flags;
            this.Name       = MetaUtils.GetString(Meta, CBlockDesc.name) ?? "GTAUtil";
            this.ExportedBy = MetaUtils.GetString(Meta, CBlockDesc.exportedBy) ?? "GTAUtil";
            this.Owner      = MetaUtils.GetString(Meta, CBlockDesc.owner) ?? "GTAUtil";
            this.Time       = MetaUtils.GetString(Meta, CBlockDesc.time) ?? DateTime.UtcNow.ToString("dd MMMM yyyy HH:mm");
        }
Example #2
0
        public override void Parse(MetaFile meta, CExtensionDefExplosionEffect CExtensionDefExplosionEffect)
        {
            this.Meta          = meta;
            this.MetaStructure = CExtensionDefExplosionEffect;

            this.Name           = CExtensionDefExplosionEffect.name;
            this.OffsetPosition = CExtensionDefExplosionEffect.offsetPosition;
            this.OffsetRotation = CExtensionDefExplosionEffect.offsetRotation;
            this.ExplosionName  = MetaUtils.GetString(Meta, CExtensionDefExplosionEffect.explosionName);
            this.BoneTag        = CExtensionDefExplosionEffect.boneTag;
            this.ExplosionTag   = CExtensionDefExplosionEffect.explosionTag;
            this.ExplosionType  = CExtensionDefExplosionEffect.explosionType;
            this.Flags          = CExtensionDefExplosionEffect.flags;
        }
Example #3
0
        public override void Parse(MetaFile meta, Unk_1701774085 Unk_1701774085)
        {
            this.Meta          = meta;
            this.MetaStructure = Unk_1701774085;

            this.OwnerName         = MetaUtils.GetString(Meta, Unk_1701774085.OwnerName);
            this.Rotation          = Unk_1701774085.Rotation;
            this.Position          = Unk_1701774085.Position;
            this.Normal            = Unk_1701774085.Normal;
            this.CapsuleRadius     = Unk_1701774085.CapsuleRadius;
            this.CapsuleLen        = Unk_1701774085.CapsuleLen;
            this.CapsuleHalfHeight = Unk_1701774085.CapsuleHalfHeight;
            this.CapsuleHalfWidth  = Unk_1701774085.CapsuleHalfWidth;
            this.Flags             = Unk_1701774085.Flags;
        }
Example #4
0
        public override void Parse(MetaFile meta, CExtensionDefParticleEffect CExtensionDefParticleEffect)
        {
            this.Meta          = meta;
            this.MetaStructure = CExtensionDefParticleEffect;

            this.Name           = CExtensionDefParticleEffect.name;
            this.OffsetPosition = CExtensionDefParticleEffect.offsetPosition;
            this.OffsetRotation = CExtensionDefParticleEffect.offsetRotation;
            this.FxName         = MetaUtils.GetString(Meta, CExtensionDefParticleEffect.fxName);
            this.FxType         = CExtensionDefParticleEffect.fxType;
            this.BoneTag        = CExtensionDefParticleEffect.boneTag;
            this.Scale          = CExtensionDefParticleEffect.scale;
            this.Probability    = CExtensionDefParticleEffect.probability;
            this.Flags          = CExtensionDefParticleEffect.flags;
            this.Color          = CExtensionDefParticleEffect.color;
        }
Example #5
0
        public override void Parse(MetaFile meta, CMloRoomDef CMloRoomDef)
        {
            this.Meta          = meta;
            this.MetaStructure = CMloRoomDef;

            this.Name                   = MetaUtils.GetString(Meta, CMloRoomDef.name);
            this.BbMin                  = CMloRoomDef.bbMin;
            this.BbMax                  = CMloRoomDef.bbMax;
            this.Blend                  = CMloRoomDef.blend;
            this.TimecycleName          = CMloRoomDef.timecycleName;
            this.SecondaryTimecycleName = CMloRoomDef.secondaryTimecycleName;
            this.Flags                  = CMloRoomDef.flags;
            this.PortalCount            = CMloRoomDef.portalCount;
            this.FloorId                = CMloRoomDef.floorId;
            this.ExteriorVisibiltyDepth = CMloRoomDef.exteriorVisibiltyDepth;
            this.AttachedObjects        = MetaUtils.ConvertDataArray <uint>(meta, CMloRoomDef.attachedObjects.Pointer, CMloRoomDef.attachedObjects.Count1)?.ToList();
        }
Example #6
0
        private static void WriteNode(StringBuilder sb, int indent, MetaCont cont, int blockId, int offset, XmlTagMode tagMode = XmlTagMode.None, MetaName structName = 0, string metaName = "")
        {
            var block = cont.Meta.GetBlock(blockId);

            if (block == null)
            {
                ErrorXml(sb, indent, "Couldn't find block " + blockId + "!");
                return;
            }

            if (structName == 0)
            {
                structName = (MetaName)block.StructureNameHash;
            }

            var name = HashString(structName);
            var data = Array.ConvertAll(block.Data.Data.ToArray(), e => (byte)e);

            var structInfo = cont.GetStructureInfo(structName);

            if (structInfo == null)
            {
                ErrorXml(sb, indent, "Couldn't find structure info " + name + "!");
                return;
            }
            if (structInfo.Entries == null)
            {
                ErrorXml(sb, indent, "Couldn't find structure info entries for " + name + "!");
                return;
            }


            switch (tagMode)
            {
            case XmlTagMode.Structure:
                OpenTag(sb, indent, name, true, metaName);
                break;

            case XmlTagMode.Item:
                OpenTag(sb, indent, "Item", true, metaName);
                break;

            case XmlTagMode.ItemAndType:
                OpenTag(sb, indent, "Item type=\"" + name + "\"", true, metaName);
                break;
            }

            var cind = indent + 1;
            StructureEntryInfo arrEntry = new StructureEntryInfo();

            for (int i = 0; i < structInfo.Entries.Count; i++)
            {
                var entry = structInfo.Entries[i];
                if ((MetaName)entry.EntryNameHash == MetaName.ARRAYINFO)
                {
                    arrEntry = entry;
                    continue;
                }
                var ename   = HashString((MetaName)entry.EntryNameHash);
                var eoffset = offset + entry.DataOffset;
                switch (entry.DataType)
                {
                default:
                    ErrorXml(sb, cind, ename + ": Unexpected entry DataType: " + entry.DataType.ToString());
                    break;

                case StructureEntryDataType.Array:

                    WriteArrayNode(sb, cind, cont, data, arrEntry, ename, eoffset);

                    break;

                case StructureEntryDataType.ArrayOfBytes:

                    WriteParsedArrayOfBytesNode(sb, cind, data, ename, eoffset, entry, arrEntry);

                    break;

                case StructureEntryDataType.ArrayOfChars:
                    OpenTag(sb, cind, ename, false);
                    uint charArrLen = (uint)entry.ReferenceKey;
                    for (int n = 0; n < charArrLen; n++)
                    {
                        var bidx = eoffset + n;
                        if ((bidx >= 0) && (bidx < data.Length))
                        {
                            byte b = data[bidx];
                            if (b == 0)
                            {
                                break;
                            }
                            sb.Append((char)b);
                        }
                    }
                    CloseTag(sb, 0, ename);
                    break;

                case StructureEntryDataType.Boolean:
                    var boolVal = BitConverter.ToBoolean(data, eoffset);
                    ValueTag(sb, cind, ename, boolVal?"true":"false");
                    break;

                case StructureEntryDataType.ByteEnum:
                    var byteEnumVal = data[eoffset];
                    ValueTag(sb, cind, ename, byteEnumVal.ToString());
                    break;

                case StructureEntryDataType.CharPointer:
                    var    charPtr = MetaUtils.ConvertData <CharPointer>(data, eoffset);
                    string charStr = MetaUtils.GetString(cont.Meta, charPtr);
                    OneLineTag(sb, cind, ename, charStr);
                    break;

                case StructureEntryDataType.DataBlockPointer:
                    OpenTag(sb, cind, ename);
                    var dataPtr = MetaUtils.ConvertData <DataBlockPointer>(data, eoffset);
                    ErrorXml(sb, cind + 1, "DataBlockPointer not currently supported here!");     //TODO! ymap occludeModels vertices data is this type!
                    CloseTag(sb, cind, ename);
                    break;

                case StructureEntryDataType.Float:
                    var floatVal = BitConverter.ToSingle(data, eoffset);
                    ValueTag(sb, cind, ename, floatVal.ToString(CultureInfo.InvariantCulture));
                    break;

                case StructureEntryDataType.Float_XYZ:
                    var v3 = MetaUtils.ConvertData <Vector3>(data, eoffset);
                    SelfClosingTag(sb, cind, ename + " x=\"" + v3.X.ToString(CultureInfo.InvariantCulture) + "\" y=\"" + v3.Y.ToString(CultureInfo.InvariantCulture) + "\" z=\"" + v3.Z.ToString(CultureInfo.InvariantCulture) + "\"");
                    break;

                case StructureEntryDataType.Float_XYZW:
                    var v4 = MetaUtils.ConvertData <Vector4>(data, eoffset);
                    SelfClosingTag(sb, cind, ename + " x=\"" + v4.X.ToString(CultureInfo.InvariantCulture) + "\" y=\"" + v4.Y.ToString(CultureInfo.InvariantCulture) + "\" z=\"" + v4.Z.ToString(CultureInfo.InvariantCulture) + "\" w=\"" + v4.W.ToString(CultureInfo.InvariantCulture) + "\"");
                    break;

                case StructureEntryDataType.Hash:
                    var hashVal = (MetaName)MetaUtils.ConvertData <uint>(data, eoffset);
                    var hashStr = HashString(hashVal);
                    StringTag(sb, cind, ename, hashStr);
                    break;

                case StructureEntryDataType.IntEnum:
                    var intEnumVal = BitConverter.ToInt32(data, eoffset);
                    var intEnumStr = GetEnumString(cont, entry, intEnumVal);
                    StringTag(sb, cind, ename, intEnumStr);
                    break;

                case StructureEntryDataType.IntFlags1:
                    var intFlags1Val = BitConverter.ToInt32(data, eoffset);
                    var intFlags1Str = GetEnumString(cont, entry, intFlags1Val);
                    StringTag(sb, cind, ename, intFlags1Str);
                    break;

                case StructureEntryDataType.IntFlags2:
                    var intFlags2Val = BitConverter.ToInt32(data, eoffset);
                    var intFlags2Str = GetEnumString(cont, entry, intFlags2Val);
                    StringTag(sb, cind, ename, intFlags2Str);
                    break;

                case StructureEntryDataType.ShortFlags:
                    var shortFlagsVal = BitConverter.ToInt16(data, eoffset);
                    var shortFlagsStr = shortFlagsVal.ToString();     // GetEnumString(cont, entry, shortFlagsVal);
                    StringTag(sb, cind, ename, shortFlagsStr);
                    break;

                case StructureEntryDataType.SignedByte:
                    sbyte sbyteVal = (sbyte)data[eoffset];
                    ValueTag(sb, cind, ename, sbyteVal.ToString());
                    break;

                case StructureEntryDataType.SignedInt:
                    var intVal = BitConverter.ToInt32(data, eoffset);
                    ValueTag(sb, cind, ename, intVal.ToString());
                    break;

                case StructureEntryDataType.SignedShort:
                    var shortVal = BitConverter.ToInt16(data, eoffset);
                    ValueTag(sb, cind, ename, shortVal.ToString());
                    break;

                case StructureEntryDataType.Structure:
                    OpenTag(sb, cind, ename);
                    WriteNode(sb, cind, cont, blockId, eoffset, XmlTagMode.None, (MetaName)entry.ReferenceKey);
                    CloseTag(sb, cind, ename);
                    break;

                case StructureEntryDataType.StructurePointer:
                    OpenTag(sb, cind, ename);
                    ErrorXml(sb, cind + 1, "StructurePointer not supported here! Tell dexy!");
                    CloseTag(sb, cind, ename);
                    break;

                case StructureEntryDataType.UnsignedByte:
                    var byteVal = data[eoffset];
                    ValueTag(sb, cind, ename, byteVal.ToString());
                    //ValueTag(sb, cind, ename, "0x" + byteVal.ToString("X").PadLeft(2, '0'));
                    break;

                case StructureEntryDataType.UnsignedInt:
                    var uintVal = BitConverter.ToUInt32(data, eoffset);
                    switch ((MetaName)entry.EntryNameHash)
                    {
                    default:
                        ValueTag(sb, cind, ename, uintVal.ToString());
                        break;

                    case MetaName.color:
                        ValueTag(sb, cind, ename, "0x" + uintVal.ToString("X").PadLeft(8, '0'));
                        break;
                    }

                    break;

                case StructureEntryDataType.UnsignedShort:
                    var ushortVal = BitConverter.ToUInt16(data, eoffset);
                    ValueTag(sb, cind, ename, ushortVal.ToString());    // "0x" + ushortVal.ToString("X").PadLeft(4, '0'));
                    break;
                }
            }

            switch (tagMode)
            {
            case XmlTagMode.Structure:
                CloseTag(sb, indent, name);
                break;

            case XmlTagMode.Item:
            case XmlTagMode.ItemAndType:
                CloseTag(sb, indent, "Item");
                break;
            }
        }