Beispiel #1
0
        public override void Build(MetaBuilder mb, bool isRoot = false)
        {
            this.MetaStructure.archetypeName = this.ArchetypeName;
            this.MetaStructure.flags         = this.Flags;
            this.MetaStructure.guid          = this.Guid;
            this.MetaStructure.position      = this.Position;
            this.MetaStructure.rotation      = this.Rotation;
            this.MetaStructure.scaleXY       = this.ScaleXY;
            this.MetaStructure.scaleZ        = this.ScaleZ;
            this.MetaStructure.parentIndex   = this.ParentIndex;
            this.MetaStructure.lodDist       = this.LodDist;
            this.MetaStructure.childLodDist  = this.ChildLodDist;
            this.MetaStructure.lodLevel      = this.LodLevel;
            this.MetaStructure.numChildren   = this.NumChildren;
            this.MetaStructure.priorityLevel = this.PriorityLevel;

            // Extensions
            var extPtrs = new List <MetaPOINTER>();

            if (this.ExtensionDefLightEffect != null)
            {
                this.AddMetaPointers(mb, extPtrs, MetaName.CExtensionDefLightEffect, this.ExtensionDefLightEffect.Select(e => { e.Build(mb); return(e.MetaStructure); }));
            }

            if (this.ExtensionDefSpawnPointOverride != null)
            {
                this.AddMetaPointers(mb, extPtrs, MetaName.CExtensionDefSpawnPointOverride, this.ExtensionDefSpawnPointOverride.Select(e => { e.Build(mb); return(e.MetaStructure); }));
            }

            if (this.ExtensionDefDoor != null)
            {
                this.AddMetaPointers(mb, extPtrs, MetaName.CExtensionDefDoor, this.ExtensionDefDoor.Select(e => { e.Build(mb); return(e.MetaStructure); }));
            }

            if (this.rage__phVerletClothCustomBounds != null)
            {
                this.AddMetaPointers(mb, extPtrs, MetaName.rage__phVerletClothCustomBounds, this.rage__phVerletClothCustomBounds.Select(e => { e.Build(mb); return(e.MetaStructure); }));
            }

            this.MetaStructure.extensions = mb.AddPointerArray(extPtrs.ToArray());


            this.MetaStructure.ambientOcclusionMultiplier = this.AmbientOcclusionMultiplier;
            this.MetaStructure.artificialAmbientOcclusion = this.ArtificialAmbientOcclusion;
            this.MetaStructure.tintValue = this.TintValue;

            MCEntityDef.AddEnumAndStructureInfo(mb);

            if (isRoot)
            {
                mb.AddItem(this.MetaName, this.MetaStructure);

                this.Meta = mb.GetMeta();
            }
        }
Beispiel #2
0
        public void RemoveEntity(MCEntityDef entity)
        {
            var idx = this.AttachedObjects.IndexOf((uint)this.Parent.Entities.IndexOf(entity));

            if (idx == -1)
            {
                return;
            }

            this.AttachedObjects.RemoveAt(idx);
        }
Beispiel #3
0
        public void AddEntity(MCEntityDef entity)
        {
            var idx = this.AttachedObjects.IndexOf((uint)this.Parent.Entities.IndexOf(entity));

            if (idx != -1)
            {
                return;
            }

            this.AttachedObjects.Add((uint)idx);
        }
Beispiel #4
0
        public void RemoveEntity(MCEntityDef entity)
        {
            int idx = this.Entities.IndexOf(entity);

            if (idx == -1)
            {
                return;
            }

            this.Entities.RemoveAt(idx);
            this.Locations.RemoveAt(idx);
        }
Beispiel #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();
        }
Beispiel #6
0
 public void RemoveEntity(MCEntityDef entity)
 {
     entity.Parent = null;
     this.Entities.Remove(entity);
 }
Beispiel #7
0
 public int AddEntity(MCEntityDef entity)
 {
     entity.Parent = this;
     this.Entities.Add(entity);
     return(this.Entities.Count - 1);
 }
Beispiel #8
0
        public void ParseFast(MetaFile meta, CMapData CMapData)
        {
            this.Meta          = meta;
            this.MetaStructure = CMapData;

            this.Name                = (MetaName)CMapData.name;
            this.Parent              = (MetaName)CMapData.parent;
            this.Flags               = CMapData.flags;
            this.ContentFlags        = CMapData.contentFlags;
            this.StreamingExtentsMin = CMapData.streamingExtentsMin;
            this.StreamingExtentsMax = CMapData.streamingExtentsMax;
            this.EntitiesExtentsMin  = CMapData.entitiesExtentsMin;
            this.EntitiesExtentsMax  = CMapData.entitiesExtentsMax;

            this.Entities = MetaUtils.GetTypedDataArray <CEntityDef>(this.Meta, MetaName.CEntityDef)?.Select(e => { var obj = new MCEntityDef(this); obj.ParseWithoutExtensions(meta, e); return(obj); }).ToList() ?? new List <MCEntityDef>();

            this.MloInstances = MetaUtils.GetTypedDataArray <CMloInstanceDef>(this.Meta, MetaName.CMloInstanceDef)?.Select(e => { var obj = new MCMloInstanceDef(); obj.Parse(meta, e); return(obj); }).ToList() ?? new List <MCMloInstanceDef>();

            this.Block = new MCBlockDesc();
            this.Block.Parse(meta, CMapData.block);
        }
Beispiel #9
0
        public override void Parse(MetaFile meta, CMapData CMapData)
        {
            this.Meta          = meta;
            this.MetaStructure = CMapData;

            this.Name                = (MetaName)CMapData.name;
            this.Parent              = (MetaName)CMapData.parent;
            this.Flags               = CMapData.flags;
            this.ContentFlags        = CMapData.contentFlags;
            this.StreamingExtentsMin = CMapData.streamingExtentsMin;
            this.StreamingExtentsMax = CMapData.streamingExtentsMax;
            this.EntitiesExtentsMin  = CMapData.entitiesExtentsMin;
            this.EntitiesExtentsMax  = CMapData.entitiesExtentsMax;

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

            this.MloInstances = MetaUtils.GetTypedDataArray <CMloInstanceDef>(this.Meta, MetaName.CMloInstanceDef)?.Select(e => { var obj = new MCMloInstanceDef(); obj.Parse(meta, e); return(obj); }).ToList() ?? new List <MCMloInstanceDef>();

            this.ContainerLods = new Array_Structure();
            var boxOccluders = MetaUtils.ConvertDataArray <Unk_975711773>(meta, CMapData.boxOccluders);

            this.BoxOccluders = boxOccluders?.Select(e => { var msw = new MUnk_975711773(); msw.Parse(meta, e); return(msw); }).ToList();

            var occludeModels = MetaUtils.ConvertDataArray <Unk_2741784237>(meta, CMapData.occludeModels);

            this.OccludeModels = occludeModels?.Select(e => { var msw = new MUnk_2741784237(); msw.Parse(meta, e); return(msw); }).ToList();

            this.PhysicsDictionaries = CMapData.physicsDictionaries;
            this.InstancedData       = new Mrage__fwInstancedMapData();
            this.InstancedData.Parse(meta, CMapData.instancedData);


            var timeCycleModifiers = MetaUtils.ConvertDataArray <CTimeCycleModifier>(meta, CMapData.timeCycleModifiers);

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


            var carGenerators = MetaUtils.ConvertDataArray <CCarGen>(meta, CMapData.carGenerators);

            this.CarGenerators = carGenerators?.Select(e => { var msw = new MCCarGen(); msw.Parse(meta, e); return(msw); }).ToList();

            this.LODLightsSOA = new MCLODLight();
            this.LODLightsSOA.Parse(meta, CMapData.LODLightsSOA);
            this.DistantLODLightsSOA = new MCDistantLODLight();
            this.DistantLODLightsSOA.Parse(meta, CMapData.DistantLODLightsSOA);
            this.Block = new MCBlockDesc();
            this.Block.Parse(meta, CMapData.block);
        }
Beispiel #10
0
 public int AddEntity(MCEntityDef entity, int room)
 {
     this.Entities.Add(entity);
     return(this.Entities.IndexOf(entity));
 }
Beispiel #11
0
        public override void Parse(MetaFile meta, CMloEntitySet CMloEntitySet)
        {
            this.Meta          = meta;
            this.MetaStructure = CMloEntitySet;

            this.Name      = CMloEntitySet.name;
            this.Locations = MetaUtils.ConvertDataArray <uint>(meta, CMloEntitySet.locations.Pointer, CMloEntitySet.locations.Count1)?.ToList();
            this.Entities  = MetaUtils.ConvertDataArray <CEntityDef>(this.Meta, CMloEntitySet.entities)?.Select(e => { var obj = new MCEntityDef(); obj.Parse(meta, e); return(obj); }).ToList() ?? new List <MCEntityDef>();
        }