Esempio n. 1
0
        public byte[] Save()
        {
            byte[] data = ResourceBuilder.Build(DrawableDict, 165); //ydd is type/version 165...

            return(data);
        }
Esempio n. 2
0
        public byte[] Save()
        {
            byte[] data = ResourceBuilder.Build(TextureDict, 13); //ytd is type/version 13...

            return data;
        }
Esempio n. 3
0
        public byte[] Save()
        {
            MetaBuilder mb = new MetaBuilder();

            var mdb = mb.EnsureBlock(MetaName.CMapTypes);

            CMapTypes mapTypes = _CMapTypes;

            if (Extensions == null || Extensions.Length <= 0)
            {
                mapTypes.extensions = new Array_StructurePointer();
            }
            else
            {
                mapTypes.extensions = mb.AddWrapperArrayPtr(Extensions);
            }

            if ((AllArchetypes != null) && (AllArchetypes.Length > 0))
            {
                for (int i = 0; i < AllArchetypes.Length; i++)
                {
                    var arch = AllArchetypes[i]; //save the extensions first..
                    if (arch._BaseArchetypeDef.extensions.Count1 > 0)
                    {
                        arch._BaseArchetypeDef.extensions = mb.AddWrapperArrayPtr(arch.Extensions);
                    }
                }

                MetaPOINTER[] ptrs = new MetaPOINTER[AllArchetypes.Length];
                for (int i = 0; i < AllArchetypes.Length; i++)
                {
                    var arch = AllArchetypes[i];
                    switch (arch)
                    {
                    case TimeArchetype t:
                        ptrs[i] = mb.AddItemPtr(MetaName.CTimeArchetypeDef, t._TimeArchetypeDef);
                        break;

                    case MloArchetype m:
                        try
                        {
                            m._MloArchetypeDef._MloArchetypeDef.entities           = mb.AddWrapperArrayPtr(m.entities);
                            m._MloArchetypeDef._MloArchetypeDef.rooms              = mb.AddWrapperArray(m.rooms);
                            m._MloArchetypeDef._MloArchetypeDef.portals            = mb.AddWrapperArray(m.portals);
                            m._MloArchetypeDef._MloArchetypeDef.entitySets         = mb.AddWrapperArray(m.entitySets);
                            m._MloArchetypeDef._MloArchetypeDef.timeCycleModifiers = mb.AddItemArrayPtr(MetaName.CMloTimeCycleModifier, m.timeCycleModifiers);
                        }
                        catch    /* (Exception e)*/
                        {
                            //todo: log save error.
                        }
                        ptrs[i] = mb.AddItemPtr(MetaName.CMloArchetypeDef, m._MloArchetypeDef);
                        break;

                    case Archetype a:
                        ptrs[i] = mb.AddItemPtr(MetaName.CBaseArchetypeDef, a._BaseArchetypeDef);
                        break;
                    }
                }
                mapTypes.archetypes = mb.AddPointerArray(ptrs);
            }
            else
            {
                mapTypes.archetypes = new Array_StructurePointer();
            }

            if (CompositeEntityTypes != null && CompositeEntityTypes.Length > 0)
            {
                var cptrs = new MetaPOINTER[CompositeEntityTypes.Length];

                for (int i = 0; i < cptrs.Length; i++)
                {
                    var cet = CompositeEntityTypes[i];
                    cptrs[i] = mb.AddItemPtr(MetaName.CCompositeEntityType, cet);
                }
                mapTypes.compositeEntityTypes = mb.AddItemArrayPtr(MetaName.CCompositeEntityType, cptrs);
            }

            mapTypes.name         = NameHash;
            mapTypes.dependencies = new Array_uint(); // is this never used? possibly a todo?

            mb.AddStructureInfo(MetaName.CMapTypes);

            if ((AllArchetypes != null && AllArchetypes.Length > 0))
            {
                mb.AddStructureInfo(MetaName.CBaseArchetypeDef);
                mb.AddEnumInfo(MetaName.rage__fwArchetypeDef__eAssetType); // ASSET_TYPE_
            }

            if ((AllArchetypes != null) && (AllArchetypes.Any(x => x is MloArchetype)))
            {
                mb.AddStructureInfo(MetaName.CMloArchetypeDef);
                mb.AddStructureInfo(MetaName.CMloRoomDef);
                mb.AddStructureInfo(MetaName.CMloPortalDef);
                mb.AddStructureInfo(MetaName.CMloEntitySet);
                mb.AddStructureInfo(MetaName.CMloTimeCycleModifier);
            }

            if ((AllArchetypes != null) && (AllArchetypes.Any(x => x is MloArchetype m && m.entities.Length > 0)))
            {
                mb.AddStructureInfo(MetaName.CEntityDef);
                mb.AddEnumInfo(MetaName.rage__eLodType);       //LODTYPES_
                mb.AddEnumInfo(MetaName.rage__ePriorityLevel); //PRI_
            }

            if ((AllArchetypes != null) && (AllArchetypes.Any(x => x is TimeArchetype)))
            {
                mb.AddStructureInfo(MetaName.CTimeArchetypeDef);
            }

            if (CompositeEntityTypes?.Length > 0)
            {
                mb.AddStructureInfo(MetaName.CCompositeEntityType);
            }


            mb.AddItem(MetaName.CMapTypes, mapTypes);

            Meta meta = mb.GetMeta();

            byte[] data = ResourceBuilder.Build(meta, 2);

            HasChanged = false;

            return(data);
        }
Esempio n. 4
0
        public byte[] Save()
        {
            byte[] data = ResourceBuilder.Build(ExpressionDictionary, 25); //yed is type/version 25...

            return(data);
        }
Esempio n. 5
0
        public byte[] Save()
        {
            byte[] data = ResourceBuilder.Build(PtfxList, 68); //ypt is type/version 68...

            return(data);
        }
Esempio n. 6
0
        public byte[] Save()
        {
            byte[] data = ResourceBuilder.Build(Bounds, 43); //ybn is type/version 43...

            return(data);
        }
Esempio n. 7
0
        public byte[] Save()
        {
            byte[] data = ResourceBuilder.Build(Waypoints, 1); //ywr is type/version 1...

            return(data);
        }
Esempio n. 8
0
        public byte[] Save()
        {
            MetaBuilder mb = new MetaBuilder();

            var mdb = mb.EnsureBlock(MetaName.CMapTypes);

            CMapTypes mapTypes = CMapTypes;

            if ((AllArchetypes != null) && (AllArchetypes.Length > 0))
            {
                MetaPOINTER[] archPtrs = new MetaPOINTER[AllArchetypes.Length];

                for (int i = 0; i < AllArchetypes.Length; i++)
                {
                    var arch = AllArchetypes[i];
                    arch._BaseArchetypeDef.extensions = mb.AddWrapperArrayPtr(arch.Extensions);
                }

                for (int i = 0; i < archPtrs.Length; i++)
                {
                    var arch = AllArchetypes[i];

                    if (arch is MloArchetype)
                    {
                        var mloArch = arch as MloArchetype;

                        mloArch._BaseMloArchetypeDef._MloArchetypeDef.entities           = mb.AddWrapperArrayPtr(mloArch.entities);
                        mloArch._BaseMloArchetypeDef._MloArchetypeDef.rooms              = mb.AddWrapperArray(mloArch.rooms);
                        mloArch._BaseMloArchetypeDef._MloArchetypeDef.portals            = mb.AddWrapperArray(mloArch.portals);
                        mloArch._BaseMloArchetypeDef._MloArchetypeDef.entitySets         = mb.AddWrapperArray(mloArch.entitySets);
                        mloArch._BaseMloArchetypeDef._MloArchetypeDef.timeCycleModifiers = mb.AddItemArrayPtr(MetaName.CTimeCycleModifier, mloArch.timeCycleModifiers);

                        archPtrs[i] = mb.AddItemPtr(MetaName.CMloArchetypeDef, mloArch.BaseMloArchetypeDef);
                    }
                    else if (arch is TimeArchetype)
                    {
                        var timeArch = arch as TimeArchetype;
                        archPtrs[i] = mb.AddItemPtr(MetaName.CTimeArchetypeDef, timeArch.TimeArchetypeDef);
                    }
                    else
                    {
                        archPtrs[i] = mb.AddItemPtr(MetaName.CBaseArchetypeDef, arch.BaseArchetypeDef);
                    }
                }

                mapTypes.archetypes = mb.AddPointerArray(archPtrs);
            }

            if ((CompositeEntityTypes != null) && (CompositeEntityTypes.Length > 0))
            {
                MetaPOINTER[] cetPtrs = new MetaPOINTER[CompositeEntityTypes.Length];

                for (int i = 0; i < cetPtrs.Length; i++)
                {
                    var cet = CompositeEntityTypes[i];
                    cetPtrs[i] = mb.AddItemPtr(MetaName.CCompositeEntityType, cet);
                }

                mapTypes.compositeEntityTypes = mb.AddItemArrayPtr(MetaName.CCompositeEntityType, cetPtrs);
            }

            mb.AddItem(MetaName.CMapTypes, mapTypes);

            mb.AddStructureInfo(MetaName.CMapTypes);
            mb.AddStructureInfo(MetaName.CBaseArchetypeDef);
            mb.AddStructureInfo(MetaName.CMloArchetypeDef);
            mb.AddStructureInfo(MetaName.CTimeArchetypeDef);
            mb.AddStructureInfo(MetaName.CMloRoomDef);
            mb.AddStructureInfo(MetaName.CMloPortalDef);
            mb.AddStructureInfo(MetaName.CMloEntitySet);
            mb.AddStructureInfo(MetaName.CCompositeEntityType);

            mb.AddEnumInfo((MetaName)1991964615);
            mb.AddEnumInfo((MetaName)1294270217);
            mb.AddEnumInfo((MetaName)1264241711);
            mb.AddEnumInfo((MetaName)648413703);
            mb.AddEnumInfo((MetaName)3573596290);
            mb.AddEnumInfo((MetaName)700327466);
            mb.AddEnumInfo((MetaName)193194928);
            mb.AddEnumInfo((MetaName)2266515059);

            Meta = mb.GetMeta();

            byte[] data = ResourceBuilder.Build(Meta, 2); //ymap is version 2...

            return(data);
        }
Esempio n. 9
0
        public byte[] Save()
        {
            //direct save to a raw, compressed ymap file (openIV-compatible format)


            //since Ymap object contents have been modified, need to recreate the arrays which are what is saved.
            BuildCEntityDefs();
            BuildCCarGens();


            //TODO:
            //BuildInstances();
            //BuildLodLights();
            //BuildDistantLodLights();
            //BuildTimecycleModifiers(); //already being saved - update them..
            //BuildBoxOccluders();
            //BuildOccludeModels();
            //BuildContainerLods();



            MetaBuilder mb = new MetaBuilder();


            var mdb = mb.EnsureBlock(MetaName.CMapData);

            CMapData mapdata = CMapData;


            if (CEntityDefs != null)
            {
                for (int i = 0; i < CEntityDefs.Length; i++)
                {
                    var yent = AllEntities[i]; //save the extensions..
                    CEntityDefs[i].extensions = mb.AddWrapperArrayPtr(yent.Extensions);
                }
            }

            mapdata.entities = mb.AddItemPointerArrayPtr(MetaName.CEntityDef, CEntityDefs);

            mapdata.timeCycleModifiers = mb.AddItemArrayPtr(MetaName.CTimeCycleModifier, CTimeCycleModifiers);

            mapdata.physicsDictionaries = mb.AddHashArrayPtr(physicsDictionaries);

            mapdata.carGenerators = mb.AddItemArrayPtr(MetaName.CCarGen, CCarGens);

            if (CMloInstanceDefs != null)
            {
                LogSaveWarning("CMloInstanceDefs were present, may not save properly. (TODO!)");
            }

            //clear everything out for now - TODO: fix
            if (mapdata.containerLods.Count1 != 0)
            {
                LogSaveWarning("containerLods were not saved. (TODO!)");
            }
            if (mapdata.occludeModels.Count1 != 0)
            {
                LogSaveWarning("occludeModels were not saved. (TODO!)");
            }
            if (mapdata.boxOccluders.Count1 != 0)
            {
                LogSaveWarning("boxOccluders were not saved. (TODO!)");
            }
            if (mapdata.instancedData.GrassInstanceList.Count1 != 0)
            {
                LogSaveWarning("instancedData.GrassInstanceList was not saved. (TODO!)");
            }
            if (mapdata.instancedData.PropInstanceList.Count1 != 0)
            {
                LogSaveWarning("instancedData.PropInstanceList was not saved. (TODO!)");
            }
            if (mapdata.LODLightsSOA.direction.Count1 != 0)
            {
                LogSaveWarning("LODLightsSOA was not saved. (TODO!)");
            }
            if (mapdata.DistantLODLightsSOA.position.Count1 != 0)
            {
                LogSaveWarning("DistantLODLightsSOA was not saved. (TODO!)");
            }
            mapdata.containerLods       = new Array_Structure();
            mapdata.occludeModels       = new Array_Structure();
            mapdata.boxOccluders        = new Array_Structure();
            mapdata.instancedData       = new rage__fwInstancedMapData();
            mapdata.LODLightsSOA        = new CLODLight();
            mapdata.DistantLODLightsSOA = new CDistantLODLight();



            var block = new CBlockDesc();

            block.name       = mb.AddStringPtr(Path.GetFileNameWithoutExtension(Name));
            block.exportedBy = mb.AddStringPtr("CodeWalker");
            block.time       = mb.AddStringPtr(DateTime.UtcNow.ToString("dd MMMM yyyy HH:mm"));

            mapdata.block = block;


            string name     = Path.GetFileNameWithoutExtension(Name);
            uint   nameHash = JenkHash.GenHash(name);

            mapdata.name = new MetaHash(nameHash);//make sure name is upto date...


            mb.AddItem(MetaName.CMapData, mapdata);



            //make sure all the relevant structure and enum infos are present.
            mb.AddStructureInfo(MetaName.rage__fwInstancedMapData);
            mb.AddStructureInfo(MetaName.CLODLight);
            mb.AddStructureInfo(MetaName.CDistantLODLight);
            mb.AddStructureInfo(MetaName.CBlockDesc);
            mb.AddStructureInfo(MetaName.CMapData);
            mb.AddStructureInfo(MetaName.CEntityDef);
            mb.AddStructureInfo(MetaName.CTimeCycleModifier);
            if ((CCarGens != null) && (CCarGens.Length > 0))
            {
                mb.AddStructureInfo(MetaName.CCarGen);
            }

            mb.AddEnumInfo((MetaName)1264241711); //LODTYPES_
            mb.AddEnumInfo((MetaName)648413703);  //PRI_


            Meta meta = mb.GetMeta();

            byte[] data = ResourceBuilder.Build(meta, 2); //ymap is version 2...


            return(data);
        }
Esempio n. 10
0
        public byte[] Save()
        {
            byte[] data = ResourceBuilder.Build(Fragment, 162); //yft is type/version 162...

            return(data);
        }
Esempio n. 11
0
        public byte[] Save()
        {
            byte[] data = ResourceBuilder.Build(Records, 1); //yvr is type/version 1...

            return(data);
        }
Esempio n. 12
0
        public byte[] Save()
        {
            byte[] data = ResourceBuilder.Build(ClothDictionary, 8); //yld is type/version 8...

            return(data);
        }