private void LoadResourceManager(IReader reader)
        {
            ITag zoneTag           = _tags.FindTagByClass("zone");
            ITag playTag           = _tags.FindTagByClass("play");
            bool haveZoneLayout    = _buildInfo.Layouts.HasLayout("resource gestalt");
            bool havePlayLayout    = _buildInfo.Layouts.HasLayout("resource layout table");
            bool haveAltPlayLayout = _buildInfo.Layouts.HasLayout("resource layout table alt");
            bool canLoadZone       = (zoneTag != null && zoneTag.MetaLocation != null && haveZoneLayout);
            bool canLoadPlay       = (playTag != null && playTag.MetaLocation != null && havePlayLayout);

            if (canLoadZone || canLoadPlay)
            {
                ThirdGenResourceGestalt     gestalt     = null;
                ThirdGenResourceLayoutTable layoutTable = null;
                if (canLoadZone)
                {
                    gestalt = new ThirdGenResourceGestalt(reader, zoneTag, MetaArea, Allocator, StringIDs, _buildInfo, _expander);
                }

                if (canLoadPlay)
                {
                    layoutTable = new ThirdGenResourceLayoutTable(playTag, MetaArea, Allocator, _buildInfo, _expander);
                }
                else if (canLoadZone && haveAltPlayLayout)
                {
                    layoutTable = new ThirdGenResourceLayoutTable(zoneTag, MetaArea, Allocator, _buildInfo, _expander);
                    _zoneOnly   = true;
                }


                _resources = new ThirdGenResourceManager(gestalt, layoutTable, _tags, MetaArea, Allocator, _buildInfo, _expander);
            }
        }
		/// <summary>
		///     Initializes a new instance of the <see cref="ThirdGenResourceManager" /> class.
		/// </summary>
		/// <param name="gestalt">The cache file's resource gestalt.</param>
		/// <param name="layoutTable">The cache file's resource layout table.</param>
		/// <param name="tags">The cache file's tag table.</param>
		/// <param name="metaArea">The cache file's meta area.</param>
		/// <param name="allocator">The cache file's tag data allocator.</param>
		/// <param name="buildInfo">The cache file's build information.</param>
		public ThirdGenResourceManager(ThirdGenResourceGestalt gestalt, ThirdGenResourceLayoutTable layoutTable, TagTable tags,
			FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo)
		{
			_gestalt = gestalt;
			_layoutTable = layoutTable;
			_tags = tags;
			_metaArea = metaArea;
			_allocator = allocator;
			_buildInfo = buildInfo;
		}
 /// <summary>
 ///     Initializes a new instance of the <see cref="ThirdGenResourceManager" /> class.
 /// </summary>
 /// <param name="gestalt">The cache file's resource gestalt.</param>
 /// <param name="layoutTable">The cache file's resource layout table.</param>
 /// <param name="tags">The cache file's tag table.</param>
 /// <param name="metaArea">The cache file's meta area.</param>
 /// <param name="allocator">The cache file's tag data allocator.</param>
 /// <param name="buildInfo">The cache file's build information.</param>
 public ThirdGenResourceManager(ThirdGenResourceGestalt gestalt, ThirdGenResourceLayoutTable layoutTable, TagTable tags,
                                FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo)
 {
     _gestalt     = gestalt;
     _layoutTable = layoutTable;
     _tags        = tags;
     _metaArea    = metaArea;
     _allocator   = allocator;
     _buildInfo   = buildInfo;
 }
        private void LoadResources(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, BuildInformation buildInfo, ThirdGenTagTable tags, ThirdGenResourceLayoutTable layoutInfo)
        {
            int count = (int)values.GetInteger("number of resources");
            uint address = values.GetInteger("resource table address");
            var layout = buildInfo.GetLayout("resource table entry");
            var entries = ReflexiveReader.ReadReflexive(count, address, reader, layout, metaArea);

            _resources = new ThirdGenResource[entries.Length];
            for (ushort i = 0; i < entries.Length; i++)
                _resources[i] = new ThirdGenResource(entries[i], i, tags, layoutInfo);
        }
        private void Load(StructureValueCollection values, ushort index, ThirdGenTagTable tags, ThirdGenResourceLayoutTable layoutInfo)
        {
            Index = new DatumIndex((ushort)values.GetInteger("datum index salt"), index);

            DatumIndex tagIndex = new DatumIndex(values.GetInteger("parent tag datum index"));
            if (tagIndex.IsValid)
                ParentTag = tags[tagIndex.Index];

            int segmentIndex = (int)values.GetInteger("segment index");
            if (segmentIndex >= 0 && segmentIndex < layoutInfo.Segments.Length)
                _segment = layoutInfo.Segments[segmentIndex];
        }
		private void LoadResourceManager(IReader reader)
		{
			ITag zoneTag = _tags.FindTagByClass("zone");
			ITag playTag = _tags.FindTagByClass("play");
			bool haveZoneLayout = _buildInfo.Layouts.HasLayout("resource gestalt");
			bool havePlayLayout = _buildInfo.Layouts.HasLayout("resource layout table");
			bool canLoadZone = (zoneTag != null && haveZoneLayout);
			bool canLoadPlay = (playTag != null && havePlayLayout);
			if (canLoadZone || canLoadPlay)
			{
				ThirdGenResourceGestalt gestalt = null;
				ThirdGenResourceLayoutTable layoutTable = null;
				if (canLoadZone)
					gestalt = new ThirdGenResourceGestalt(reader, zoneTag, MetaArea, Allocator, StringIDs, _buildInfo);
				if (canLoadPlay)
					layoutTable = new ThirdGenResourceLayoutTable(playTag, MetaArea, Allocator, _buildInfo);

				_resources = new ThirdGenResourceManager(gestalt, layoutTable, _tags, MetaArea, Allocator, _buildInfo);
			}
		}
 private void Load(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, BuildInformation buildInfo, ThirdGenTagTable tags, ThirdGenResourceLayoutTable layoutInfo)
 {
     LoadResources(values, reader, metaArea, buildInfo, tags, layoutInfo);
 }
 public ThirdGenResource(StructureValueCollection values, ushort index, ThirdGenTagTable tags, ThirdGenResourceLayoutTable layoutInfo)
 {
     Load(values, index, tags, layoutInfo);
 }
Exemple #9
0
 private void LoadResourceManager(IReader reader)
 {
     ITag zoneTag = _tags.FindTagByClass("zone");
     ITag playTag = _tags.FindTagByClass("play");
     if (zoneTag != null && playTag != null && _buildInfo.Layouts.HasLayout("resource gestalt") &&
         _buildInfo.Layouts.HasLayout("resource layout table"))
     {
         var gestalt = new ThirdGenResourceGestalt(reader, zoneTag, MetaArea, Allocator, StringIDs, _buildInfo);
         var layoutTable = new ThirdGenResourceLayoutTable(playTag, MetaArea, Allocator, _buildInfo);
         _resources = new ThirdGenResourceManager(gestalt, layoutTable, _tags, MetaArea, Allocator, _buildInfo);
     }
 }
        private ThirdGenResourceGestalt LoadResourceGestalt(IReader reader, ThirdGenResourceLayoutTable resourceLayout)
        {
            if (_tags == null || resourceLayout == null || !_buildInfo.HasLayout("resource gestalt"))
                return null;

            StructureLayout layout = _buildInfo.GetLayout("resource gestalt");

            ITag zone = _tags.FindTagByClass("zone");
            if (zone == null)
                return null;

            reader.SeekTo(zone.MetaLocation.AsOffset());
            StructureValueCollection values = StructureReader.ReadStructure(reader, layout);
            return new ThirdGenResourceGestalt(values, reader, MetaArea, _buildInfo, _tags, resourceLayout);
        }