func (library *ReleaseStoreLibrary) serializeChunkStore(store chunk.Store) []byte { buffer := serial.NewByteStore() consumer := dosChunk.NewChunkConsumer(buffer) ids := store.IDs() for _, id := range ids { blockStore := store.Get(id) consumer.Consume(id, blockStore) } consumer.Finish() return buffer.Data() }
// NewLevel returns a new instance of a Level structure. func NewLevel(store chunk.Store, id int) *Level { baseStoreID := 4000 + id*100 level := &Level{ id: id, store: store, tileMapStore: store.Get(res.ResourceID(baseStoreID + 5)), tileMap: nil, objectListStore: store.Get(res.ResourceID(baseStoreID + 8)), crossrefListStore: store.Get(res.ResourceID(baseStoreID + 9))} level.tileMap = logic.DecodeTileMap(level.tileMapStore.BlockData(0), 64, 64) level.crossrefList = logic.DecodeCrossReferenceList(level.crossrefListStore.BlockData(0)) { blockData := level.objectListStore.BlockData(0) level.objectList = make([]data.LevelObjectEntry, len(blockData)/data.LevelObjectEntrySize) reader := bytes.NewReader(blockData) binary.Read(reader, binary.LittleEndian, &level.objectList) level.objectChain = logic.NewLevelObjectChain(&level.objectList[0], func(index data.LevelObjectChainIndex) logic.LevelObjectChainLink { return &level.objectList[index] }) } return level }