示例#1
0
        private static void WriteArrayNode(StringBuilder sb, int indent, MetaCont cont, byte[] data, StructureEntryInfo arrEntry, string ename, int eoffset)
        {
            int    aCount = 0;
            var    aind   = indent + 1;
            string arrTag = ename;

            switch (arrEntry.DataType)
            {
            default:
                ErrorXml(sb, indent, ename + ": Unexpected array entry DataType: " + arrEntry.DataType.ToString());
                break;

            case StructureEntryDataType.Structure:
                var arrStruc = MetaUtils.ConvertData <Array_Structure>(data, eoffset);
                var aBlockId = (int)arrStruc.PointerDataId;
                var aOffset  = (int)arrStruc.PointerDataOffset;
                aCount  = arrStruc.Count1;
                arrTag += " itemType=\"" + HashString((MetaName)arrEntry.ReferenceKey) + "\"";
                if (aCount > 0)
                {
                    OpenTag(sb, indent, arrTag);
                    var atyp   = cont.GetStructureInfo((MetaName)arrEntry.ReferenceKey);
                    var aBlock = cont.Meta.GetBlock(aBlockId);
                    for (int n = 0; n < aCount; n++)
                    {
                        WriteNode(sb, aind, cont, aBlockId, aOffset, XmlTagMode.Item, (MetaName)arrEntry.ReferenceKey);
                        aOffset += atyp.StructureLength;

                        if ((n < (aCount - 1)) && (aBlock != null) && (aOffset >= aBlock.DataLength))
                        {
                            aOffset = 0;
                            aBlockId++;
                            aBlock = cont.Meta.GetBlock(aBlockId);
                        }
                    }
                    CloseTag(sb, indent, ename);
                }
                else
                {
                    SelfClosingTag(sb, indent, arrTag);
                }
                break;

            case StructureEntryDataType.StructurePointer:
                var arrStrucP = MetaUtils.ConvertData <Array_StructurePointer>(data, eoffset);
                var ptrArr    = MetaUtils.GetPointerArray(cont.Meta, arrStrucP);
                aCount = ptrArr?.Length ?? 0;
                if (aCount > 0)
                {
                    OpenTag(sb, indent, arrTag);
                    for (int n = 0; n < aCount; n++)
                    {
                        var ptr    = ptrArr[n];
                        var offset = ptr.Offset;
                        WriteNode(sb, aind, cont, ptr.BlockID, offset, XmlTagMode.ItemAndType);
                    }
                    CloseTag(sb, indent, ename);
                }
                else
                {
                    SelfClosingTag(sb, indent, arrTag);
                }
                break;

            case StructureEntryDataType.UnsignedInt:
                var arrUint = MetaUtils.ConvertData <Array_uint>(data, eoffset);
                var uintArr = MetaUtils.ConvertDataArray <uint>(cont.Meta, arrUint.Pointer, arrUint.Count1);;
                WriteRawArray(sb, uintArr, indent, ename, "uint");
                break;

            case StructureEntryDataType.UnsignedShort:
                var arrUshort = MetaUtils.ConvertData <Array_ushort>(data, eoffset);
                var ushortArr = MetaUtils.ConvertDataArray <ushort>(cont.Meta, arrUshort.Pointer, arrUshort.Count1);;
                WriteRawArray(sb, ushortArr, indent, ename, "ushort");
                break;

            case StructureEntryDataType.UnsignedByte:
                var arrUbyte = MetaUtils.ConvertData <Array_byte>(data, eoffset);
                var byteArr  = MetaUtils.ConvertDataArray <byte>(cont.Meta, arrUbyte.Pointer, arrUbyte.Count1);;
                WriteRawArray(sb, byteArr, indent, ename, "byte");
                break;

            case StructureEntryDataType.Float:
                var arrFloat = MetaUtils.ConvertData <Array_float>(data, eoffset);
                var floatArr = MetaUtils.ConvertDataArray <float>(cont.Meta, arrFloat.Pointer, arrFloat.Count1);;
                WriteRawArray(sb, floatArr, indent, ename, "float");
                break;

            case StructureEntryDataType.Float_XYZ:
                var arrV3 = MetaUtils.ConvertData <Array_Vector3>(data, eoffset);
                var v4Arr = MetaUtils.ConvertDataArray <Vector4>(cont.Meta, arrV3.Pointer, arrV3.Count1);
                WriteItemArray(sb, v4Arr, indent, ename, "Vector3/4", FormatVector4);
                break;

            case StructureEntryDataType.CharPointer:
                ErrorXml(sb, indent, "CharPointer ARRAY not supported here!");
                break;

            case StructureEntryDataType.DataBlockPointer:
                ErrorXml(sb, indent, "DataBlockPointer ARRAY not supported here!");
                break;

            case StructureEntryDataType.Hash:
                var arrHash  = MetaUtils.ConvertData <Array_uint>(data, eoffset);
                var uintArr2 = MetaUtils.ConvertDataArray <uint>(cont.Meta, arrHash.Pointer, arrHash.Count1);
                var hashArr  = Array.ConvertAll(uintArr2, e => (MetaName)e);
                WriteItemArray(sb, hashArr, indent, ename, "Hash", FormatHash);
                break;
            }
        }
示例#2
0
        public override void Parse(MetaFile meta, CEntityDef CEntityDef)
        {
            this.Meta          = meta;
            this.MetaStructure = CEntityDef;

            this.ArchetypeName = CEntityDef.archetypeName;
            this.Flags         = CEntityDef.flags;
            this.Guid          = CEntityDef.guid;
            this.Position      = CEntityDef.position;
            this.Rotation      = CEntityDef.rotation;
            this.ScaleXY       = CEntityDef.scaleXY;
            this.ScaleZ        = CEntityDef.scaleZ;
            this.ParentIndex   = CEntityDef.parentIndex;
            this.LodDist       = CEntityDef.lodDist;
            this.ChildLodDist  = CEntityDef.childLodDist;
            this.LodLevel      = CEntityDef.lodLevel;
            this.NumChildren   = CEntityDef.numChildren;
            this.PriorityLevel = CEntityDef.priorityLevel;

            // Extensions
            var extptrs = MetaUtils.GetPointerArray(meta, CEntityDef.extensions);

            if (extptrs != null)
            {
                for (int i = 0; i < extptrs.Length; i++)
                {
                    var extptr = extptrs[i];
                    var block  = meta.GetBlock(extptr.BlockID);

                    switch (block.StructureNameHash)
                    {
                    case MetaName.CExtensionDefLightEffect:
                    {
                        var data = MetaUtils.GetData <CExtensionDefLightEffect>(meta, extptr);
                        var obj  = new MCExtensionDefLightEffect();
                        obj.Parse(meta, data);
                        ExtensionDefLightEffect.Add(obj);
                        break;
                    }

                    case MetaName.CExtensionDefSpawnPointOverride:
                    {
                        var data = MetaUtils.GetData <CExtensionDefSpawnPointOverride>(meta, extptr);
                        var obj  = new MCExtensionDefSpawnPointOverride();
                        obj.Parse(meta, data);
                        ExtensionDefSpawnPointOverride.Add(obj);
                        break;
                    }

                    case MetaName.CExtensionDefDoor:
                    {
                        var data = MetaUtils.GetData <CExtensionDefDoor>(meta, extptr);
                        var obj  = new MCExtensionDefDoor();
                        obj.Parse(meta, data);
                        ExtensionDefDoor.Add(obj);
                        break;
                    }

                    case MetaName.rage__phVerletClothCustomBounds:
                    {
                        var data = MetaUtils.GetData <rage__phVerletClothCustomBounds>(meta, extptr);
                        var obj  = new Mrage__phVerletClothCustomBounds();
                        obj.Parse(meta, data);
                        rage__phVerletClothCustomBounds.Add(obj);
                        break;
                    }

                    default: break;
                    }
                }
            }

            this.AmbientOcclusionMultiplier = CEntityDef.ambientOcclusionMultiplier;
            this.ArtificialAmbientOcclusion = CEntityDef.artificialAmbientOcclusion;
            this.TintValue = CEntityDef.tintValue;
        }
示例#3
0
        public override void Parse(MetaFile meta, CMapTypes CMapTypes)
        {
            this.Meta          = meta;
            this.MetaStructure = CMapTypes;

            // this.Extensions = CMapTypes.extensions;

            // CBaseArchetypeDef + CMloArchetypeDef + CTimeArchetypeDef
            var archPtrs = MetaUtils.GetPointerArray(this.Meta, this.MetaStructure.archetypes);

            if (archPtrs != null)
            {
                for (int i = 0; i < archPtrs.Length; i++)
                {
                    var ptr   = archPtrs[i];
                    var block = Meta.GetBlock(ptr.BlockID);

                    if (block == null)
                    {
                        continue;
                    }

                    if ((ptr.Offset < 0) || (block.Data == null) || (ptr.Offset >= block.Data.Length))
                    {
                        continue;
                    }

                    byte[] data = Array.ConvertAll(block.Data.ToArray(), e => (byte)e);

                    switch ((MetaName)block.StructureNameHash)
                    {
                    case MetaName.CBaseArchetypeDef:
                    {
                        var struc = PsoUtils.ConvertDataRaw <RageLib.Resources.GTA5.PC.Meta.CBaseArchetypeDef>(data, ptr.Offset);
                        var arch  = new MCBaseArchetypeDef();
                        arch.Parse(meta, struc);
                        this.Archetypes.Add(arch);
                        break;
                    }

                    case MetaName.CMloArchetypeDef:
                    {
                        var struc = PsoUtils.ConvertDataRaw <RageLib.Resources.GTA5.PC.Meta.CMloArchetypeDef>(data, ptr.Offset);
                        var arch  = new MCMloArchetypeDef();
                        arch.Parse(meta, struc);
                        this.MloArchetypes.Add(arch);
                        break;
                    }

                    case MetaName.CTimeArchetypeDef:
                    {
                        var struc = PsoUtils.ConvertDataRaw <RageLib.Resources.GTA5.PC.Meta.CTimeArchetypeDef>(data, ptr.Offset);
                        var arch  = new MCTimeArchetypeDef();
                        arch.Parse(meta, struc);
                        this.TimeArchetypes.Add(arch);
                        break;
                    }

                    default: continue;
                    }
                }
            }

            this.Name = (MetaName)CMapTypes.name;
            // this.Dependencies = CMapTypes.dependencies;
            var compositeEntityTypes = MetaUtils.ConvertDataArray <CCompositeEntityType>(meta, CMapTypes.compositeEntityTypes);

            this.CompositeEntityTypes = compositeEntityTypes?.Select(e => { var msw = new MCCompositeEntityType(); msw.Parse(meta, e); return(msw); }).ToList();
        }
示例#4
0
        public override void Parse(MetaFile meta, CBaseArchetypeDef CBaseArchetypeDef)
        {
            this.Meta          = meta;
            this.MetaStructure = CBaseArchetypeDef;

            this.LodDist            = CBaseArchetypeDef.lodDist;
            this.Flags              = CBaseArchetypeDef.flags;
            this.SpecialAttribute   = CBaseArchetypeDef.specialAttribute;
            this.BbMin              = CBaseArchetypeDef.bbMin;
            this.BbMax              = CBaseArchetypeDef.bbMax;
            this.BsCentre           = CBaseArchetypeDef.bsCentre;
            this.BsRadius           = CBaseArchetypeDef.bsRadius;
            this.HdTextureDist      = CBaseArchetypeDef.hdTextureDist;
            this.Name               = (MetaName)CBaseArchetypeDef.name;
            this.TextureDictionary  = (MetaName)CBaseArchetypeDef.textureDictionary;
            this.ClipDictionary     = (MetaName)CBaseArchetypeDef.clipDictionary;
            this.DrawableDictionary = (MetaName)CBaseArchetypeDef.drawableDictionary;
            this.PhysicsDictionary  = (MetaName)CBaseArchetypeDef.physicsDictionary;
            this.AssetType          = CBaseArchetypeDef.assetType;
            this.AssetName          = (MetaName)CBaseArchetypeDef.assetName;

            // Extensions
            var extptrs = MetaUtils.GetPointerArray(meta, CBaseArchetypeDef.extensions);

            if (extptrs != null)
            {
                for (int i = 0; i < extptrs.Length; i++)
                {
                    var extptr = extptrs[i];
                    var block  = meta.GetBlock(extptr.BlockID);

                    switch (block.StructureNameHash)
                    {
                    case MetaName.CExtensionDefLightEffect:
                    {
                        var data = MetaUtils.GetData <CExtensionDefLightEffect>(meta, extptr);
                        var obj  = new MCExtensionDefLightEffect();
                        obj.Parse(meta, data);
                        ExtensionDefLightEffects.Add(obj);
                        break;
                    }

                    case MetaName.CExtensionDefSpawnPointOverride:
                    {
                        var data = MetaUtils.GetData <CExtensionDefSpawnPointOverride>(meta, extptr);
                        var obj  = new MCExtensionDefSpawnPointOverride();
                        obj.Parse(meta, data);
                        ExtensionDefSpawnPointOverrides.Add(obj);
                        break;
                    }

                    case MetaName.CExtensionDefDoor:
                    {
                        var data = MetaUtils.GetData <CExtensionDefDoor>(meta, extptr);
                        var obj  = new MCExtensionDefDoor();
                        obj.Parse(meta, data);
                        ExtensionDefDoors.Add(obj);
                        break;
                    }

                    case MetaName.rage__phVerletClothCustomBounds:
                    {
                        var data = MetaUtils.GetData <rage__phVerletClothCustomBounds>(meta, extptr);
                        var obj  = new Mrage__phVerletClothCustomBounds();
                        obj.Parse(meta, data);
                        rage__PhVerletClothCustomBounds.Add(obj);
                        break;
                    }

                    default: break;
                    }
                }
            }
        }
示例#5
0
        public override void Parse(MetaFile meta, CMloArchetypeDef CMloArchetypeDef)
        {
            this.Meta          = meta;
            this.MetaStructure = CMloArchetypeDef;

            this.LodDist            = CMloArchetypeDef.lodDist;
            this.Flags              = CMloArchetypeDef.flags;
            this.SpecialAttribute   = CMloArchetypeDef.specialAttribute;
            this.BbMin              = CMloArchetypeDef.bbMin;
            this.BbMax              = CMloArchetypeDef.bbMax;
            this.BsCentre           = CMloArchetypeDef.bsCentre;
            this.BsRadius           = CMloArchetypeDef.bsRadius;
            this.HdTextureDist      = CMloArchetypeDef.hdTextureDist;
            this.Name               = CMloArchetypeDef.name;
            this.TextureDictionary  = CMloArchetypeDef.textureDictionary;
            this.ClipDictionary     = CMloArchetypeDef.clipDictionary;
            this.DrawableDictionary = CMloArchetypeDef.drawableDictionary;
            this.PhysicsDictionary  = CMloArchetypeDef.physicsDictionary;
            this.AssetType          = CMloArchetypeDef.assetType;
            this.AssetName          = CMloArchetypeDef.assetName;

            // Extensions
            var extptrs = MetaUtils.GetPointerArray(meta, CMloArchetypeDef.extensions);

            if (extptrs != null)
            {
                for (int i = 0; i < extptrs.Length; i++)
                {
                    var extptr = extptrs[i];
                    var block  = meta.GetBlock(extptr.BlockID);

                    switch (block.StructureNameHash)
                    {
                    case MetaName.CExtensionDefAudioCollisionSettings:
                    {
                        var data = MetaUtils.GetData <CExtensionDefAudioCollisionSettings>(meta, extptr);
                        var obj  = new MCExtensionDefAudioCollisionSettings();
                        obj.Parse(meta, data);
                        ExtensionDefAudioCollisionSettings.Add(obj);
                        break;
                    }

                    case MetaName.CExtensionDefAudioEmitter:
                    {
                        var data = MetaUtils.GetData <CExtensionDefAudioEmitter>(meta, extptr);
                        var obj  = new MCExtensionDefAudioEmitter();
                        obj.Parse(meta, data);
                        ExtensionDefAudioEmitters.Add(obj);
                        break;
                    }

                    case MetaName.CExtensionDefBuoyancy:
                    {
                        var data = MetaUtils.GetData <CExtensionDefBuoyancy>(meta, extptr);
                        var obj  = new MCExtensionDefBuoyancy();
                        obj.Parse(meta, data);
                        ExtensionDefBuoyancies.Add(obj);
                        break;
                    }

                    case MetaName.CExtensionDefExplosionEffect:
                    {
                        var data = MetaUtils.GetData <CExtensionDefExplosionEffect>(meta, extptr);
                        var obj  = new MCExtensionDefExplosionEffect();
                        obj.Parse(meta, data);
                        ExtensionDefExplosionEffects.Add(obj);
                        break;
                    }

                    case MetaName.CExtensionDefExpression:
                    {
                        var data = MetaUtils.GetData <CExtensionDefExpression>(meta, extptr);
                        var obj  = new MCExtensionDefExpression();
                        obj.Parse(meta, data);
                        ExtensionDefExpressions.Add(obj);
                        break;
                    }

                    case MetaName.CExtensionDefLadder:
                    {
                        var data = MetaUtils.GetData <CExtensionDefLadder>(meta, extptr);
                        var obj  = new MCExtensionDefLadder();
                        obj.Parse(meta, data);
                        ExtensionDefLadders.Add(obj);
                        break;
                    }

                    case MetaName.CExtensionDefLightShaft:
                    {
                        var data = MetaUtils.GetData <CExtensionDefLightShaft>(meta, extptr);
                        var obj  = new MCExtensionDefLightShaft();
                        obj.Parse(meta, data);
                        ExtensionDefLightShafts.Add(obj);
                        break;
                    }

                    case MetaName.CExtensionDefParticleEffect:
                    {
                        var data = MetaUtils.GetData <CExtensionDefParticleEffect>(meta, extptr);
                        var obj  = new MCExtensionDefParticleEffect();
                        obj.Parse(meta, data);
                        ExtensionDefParticleEffects.Add(obj);
                        break;
                    }

                    case MetaName.CExtensionDefProcObject:
                    {
                        var data = MetaUtils.GetData <CExtensionDefProcObject>(meta, extptr);
                        var obj  = new MCExtensionDefProcObject();
                        obj.Parse(meta, data);
                        ExtensionDefProcObjects.Add(obj);
                        break;
                    }

                    case MetaName.CExtensionDefSpawnPoint:
                    {
                        var data = MetaUtils.GetData <CExtensionDefSpawnPoint>(meta, extptr);
                        var obj  = new MCExtensionDefSpawnPoint();
                        obj.Parse(meta, data);
                        ExtensionDefSpawnPoints.Add(obj);
                        break;
                    }

                    case MetaName.CExtensionDefWindDisturbance:
                    {
                        var data = MetaUtils.GetData <CExtensionDefWindDisturbance>(meta, extptr);
                        var obj  = new MCExtensionDefWindDisturbance();
                        obj.Parse(meta, data);
                        ExtensionDefWindDisturbances.Add(obj);
                        break;
                    }

                    default: break;
                    }
                }
            }

            this.MloFlags = CMloArchetypeDef.mloFlags;

            this.Entities = MetaUtils.ConvertDataArray <CEntityDef>(this.Meta, CMloArchetypeDef.entities)?.Select(e => { var obj = new MCEntityDef(); obj.Parse(meta, e); return(obj); }).ToList() ?? new List <MCEntityDef>();

            var rooms = MetaUtils.ConvertDataArray <CMloRoomDef>(meta, CMloArchetypeDef.rooms);

            this.Rooms = rooms?.Select(e => { var msw = new MCMloRoomDef(this); msw.Parse(meta, e); return(msw); }).ToList();

            var portals = MetaUtils.ConvertDataArray <CMloPortalDef>(meta, CMloArchetypeDef.portals);

            this.Portals = portals?.Select(e => { var msw = new MCMloPortalDef(); msw.Parse(meta, e); return(msw); }).ToList();

            var entitySets = MetaUtils.ConvertDataArray <CMloEntitySet>(meta, CMloArchetypeDef.entitySets);

            this.EntitySets = entitySets?.Select(e => { var msw = new MCMloEntitySet(); msw.Parse(meta, e); return(msw); }).ToList();

            var timeCycleModifiers = MetaUtils.ConvertDataArray <CMloTimeCycleModifier>(meta, CMloArchetypeDef.timeCycleModifiers);

            this.TimeCycleModifiers = timeCycleModifiers?.Select(e => { var msw = new MCMloTimeCycleModifier(); msw.Parse(meta, e); return(msw); }).ToList();
        }