• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang res.ResourceID函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/inkyblackness/res.ResourceID函数的典型用法代码示例。如果您正苦于以下问题:Golang ResourceID函数的具体用法?Golang ResourceID怎么用?Golang ResourceID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ResourceID函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: NewLevel

// 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
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:31,代码来源:Level.go


示例2: TestChunkStoreIsBackedBySourceIfExisting

func (suite *ReleaseStoreLibrarySuite) TestChunkStoreIsBackedBySourceIfExisting(c *check.C) {
	suite.createChunkResource(suite.source, "fromSource.res", func(consumer chunk.Consumer) {
		consumer.Consume(res.ResourceID(1), chunk.NewBlockHolder(chunk.BasicChunkType, res.Palette, [][]byte{[]byte{}}))
	})
	store, err := suite.library.ChunkStore("fromSource.res")

	c.Assert(err, check.IsNil)
	c.Assert(store, check.NotNil)
	blockStore := store.Get(res.ResourceID(1))
	c.Check(blockStore.BlockCount(), check.Equals, uint16(1))
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:11,代码来源:ReleaseStoreLibrary_test.go


示例3: SetProperties

func (textures *Textures) SetProperties(index int, prop model.TextureProperties) {
	for i := 0; i < model.LanguageCount; i++ {
		if prop.Name[i] != nil {
			names := textures.cybstrng[i].Get(res.ResourceID(0x086A))
			names.SetBlockData(uint16(index), textures.EncodeString(prop.Name[i]))
		}
		if prop.CantBeUsed[i] != nil {
			cantBeUseds := textures.cybstrng[i].Get(res.ResourceID(0x086B))
			cantBeUseds.SetBlockData(uint16(index), textures.EncodeString(prop.CantBeUsed[i]))
		}
	}
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:12,代码来源:Textures.go


示例4: TestGetReturnsBlockFromWrapped

func (suite *DynamicChunkStoreSuite) TestGetReturnsBlockFromWrapped(c *check.C) {
	provider := suite.createChunkProvider(func(consumer chunk.Consumer) {
		consumer.Consume(res.ResourceID(1), chunk.NewBlockHolder(chunk.BasicChunkType, res.Palette, [][]byte{[]byte{}}))
	})

	wrappedStore := store.NewProviderBacked(provider, func() {})
	store := NewDynamicChunkStore(wrappedStore)

	holder := store.Get(res.ResourceID(1))

	c.Check(holder, check.NotNil)
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:12,代码来源:DynamicChunkStore_test.go


示例5: TestDelDeletesFromWrapped

func (suite *DynamicChunkStoreSuite) TestDelDeletesFromWrapped(c *check.C) {
	provider := suite.createChunkProvider(func(consumer chunk.Consumer) {
		consumer.Consume(res.ResourceID(1), chunk.NewBlockHolder(chunk.BasicChunkType, res.Palette, [][]byte{[]byte{}}))
	})

	wrappedStore := store.NewProviderBacked(provider, func() {})
	store := NewDynamicChunkStore(wrappedStore)

	store.Del(res.ResourceID(1))

	ids := store.IDs()
	c.Check(len(ids), check.Equals, 0)
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:13,代码来源:DynamicChunkStore_test.go


示例6: Properties

func (textures *Textures) Properties(index int) model.TextureProperties {
	prop := model.TextureProperties{}

	for i := 0; i < model.LanguageCount; i++ {
		names := textures.cybstrng[i].Get(res.ResourceID(0x086A))
		cantBeUseds := textures.cybstrng[i].Get(res.ResourceID(0x086B))

		prop.Name[i] = textures.DecodeString(names.BlockData(uint16(index)))
		prop.CantBeUsed[i] = textures.DecodeString(cantBeUseds.BlockData(uint16(index)))
	}

	return prop
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:13,代码来源:Textures.go


示例7: Properties

// Properties returns the current properties of a specific game object.
func (gameObjects *GameObjects) Properties(id res.ObjectID) model.GameObjectProperties {
	prop := model.GameObjectProperties{}
	index := objprop.ObjectIDToIndex(gameObjects.desc, id)

	for i := 0; i < model.LanguageCount; i++ {
		shortName := gameObjects.cybstrng[i].Get(res.ResourceID(0x086D))
		longName := gameObjects.cybstrng[i].Get(res.ResourceID(0x0024))

		prop.ShortName[i] = gameObjects.decodeString(shortName.BlockData(uint16(index)))
		prop.LongName[i] = gameObjects.decodeString(longName.BlockData(uint16(index)))
	}

	return prop
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:15,代码来源:GameObjects.go


示例8: TestBlockHolderModifiesWrapped

func (suite *DynamicChunkStoreSuite) TestBlockHolderModifiesWrapped(c *check.C) {
	provider := suite.createChunkProvider(func(consumer chunk.Consumer) {
		consumer.Consume(res.ResourceID(1), chunk.NewBlockHolder(chunk.BasicChunkType, res.Palette, [][]byte{[]byte{}}))
	})

	wrappedStore := store.NewProviderBacked(provider, func() {})
	store := NewDynamicChunkStore(wrappedStore)

	data := []byte{0x01, 0x02}
	holder := store.Get(res.ResourceID(1))
	holder.SetBlockData(0, data)

	c.Check(wrappedStore.Get(res.ResourceID(1)).BlockData(0), check.DeepEquals, data)
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:14,代码来源:DynamicChunkStore_test.go


示例9: TestSwapReplacesWrapped

func (suite *DynamicChunkStoreSuite) TestSwapReplacesWrapped(c *check.C) {
	provider1 := suite.createChunkProvider(func(consumer chunk.Consumer) {
		consumer.Consume(res.ResourceID(1), chunk.NewBlockHolder(chunk.BasicChunkType, res.Palette, [][]byte{[]byte{}}))
	})
	provider2 := suite.createChunkProvider(func(consumer chunk.Consumer) {
		consumer.Consume(res.ResourceID(2), chunk.NewBlockHolder(chunk.BasicChunkType, res.Palette, [][]byte{[]byte{}}))
	})

	testStore := NewDynamicChunkStore(store.NewProviderBacked(provider1, func() {}))
	testStore.Swap(func(oldStore chunk.Store) chunk.Store {
		return store.NewProviderBacked(provider2, func() {})
	})

	c.Check(testStore.IDs(), check.DeepEquals, []res.ResourceID{res.ResourceID(2)})
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:15,代码来源:DynamicChunkStore_test.go


示例10: TestModifyingChunkSourceSavesNewSink

func (suite *ReleaseStoreLibrarySuite) TestModifyingChunkSourceSavesNewSink(c *check.C) {
	suite.createChunkResource(suite.source, "source.res", func(consumer chunk.Consumer) {
		consumer.Consume(res.ResourceID(1), chunk.NewBlockHolder(chunk.BasicChunkType, res.Palette, [][]byte{[]byte{}}))
	})
	store, err := suite.library.ChunkStore("source.res")

	c.Assert(err, check.IsNil)
	c.Assert(store, check.NotNil)

	store.Del(res.ResourceID(1))

	time.Sleep(100 * time.Millisecond)

	c.Check(suite.sink.HasResource("source.res"), check.Equals, true)
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:15,代码来源:ReleaseStoreLibrary_test.go


示例11: Image

func (textures *Textures) Image(index int, size model.TextureSize) (bmp image.Bitmap) {
	var blockData []byte

	if size == model.TextureLarge {
		blockData = textures.images.Get(res.ResourceID(0x03E8 + index)).BlockData(0)
	} else if size == model.TextureMedium {
		blockData = textures.images.Get(res.ResourceID(0x02C3 + index)).BlockData(0)
	} else if size == model.TextureSmall {
		blockData = textures.images.Get(res.ResourceID(0x004D)).BlockData(uint16(index))
	} else if size == model.TextureIcon {
		blockData = textures.images.Get(res.ResourceID(0x004C)).BlockData(uint16(index))
	}
	bmp, _ = image.Read(bytes.NewReader(blockData))

	return
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:16,代码来源:Textures.go


示例12: TestGetReturnsNilIfWrappedDoesntHaveIt

func (suite *DynamicChunkStoreSuite) TestGetReturnsNilIfWrappedDoesntHaveIt(c *check.C) {
	provider := suite.createChunkProvider(func(consumer chunk.Consumer) {})

	wrappedStore := store.NewProviderBacked(provider, func() {})
	store := NewDynamicChunkStore(wrappedStore)

	holder := store.Get(res.ResourceID(2))

	c.Check(holder, check.IsNil)
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:10,代码来源:DynamicChunkStore_test.go


示例13: TestBlockHolderModifiesWrappedAfterSwap

func (suite *DynamicChunkStoreSuite) TestBlockHolderModifiesWrappedAfterSwap(c *check.C) {
	provider1 := suite.createChunkProvider(func(consumer chunk.Consumer) {
		consumer.Consume(res.ResourceID(1), chunk.NewBlockHolder(chunk.BasicChunkType, res.Palette, [][]byte{[]byte{}}))
	})
	provider2 := suite.createChunkProvider(func(consumer chunk.Consumer) {
		consumer.Consume(res.ResourceID(1), chunk.NewBlockHolder(chunk.BasicChunkType, res.Palette, [][]byte{[]byte{}}))
	})

	testStore := NewDynamicChunkStore(store.NewProviderBacked(provider1, func() {}))
	holder := testStore.Get(res.ResourceID(1))

	wrapped2 := store.NewProviderBacked(provider2, func() {})
	testStore.Swap(func(oldStore chunk.Store) chunk.Store { return wrapped2 })

	data := []byte{0x01, 0x02}
	holder.SetBlockData(0, data)

	c.Check(wrapped2.Get(res.ResourceID(1)).BlockData(0), check.DeepEquals, data)
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:19,代码来源:DynamicChunkStore_test.go


示例14: Properties

// Properties returns the properties of the level.
func (level *Level) Properties() (result model.LevelProperties) {
	blockData := level.store.Get(res.ResourceID(4000 + level.id*100 + 4)).BlockData(0)
	reader := bytes.NewReader(blockData)
	var info data.LevelInformation

	binary.Read(reader, binary.LittleEndian, &info)
	result.CyberspaceFlag = info.IsCyberspace()
	result.HeightShift = int(info.HeightShift)

	return
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:12,代码来源:Level.go


示例15: Icon

// Icon returns the icon image of the specified game object.
// It first tries to return the bitmap for the map icon. If that is all transparent,
// the function reverts to the object icon.
func (gameObjects *GameObjects) Icon(id res.ObjectID) (bmp image.Bitmap) {
	mapIconBlockData := gameObjects.objart.Get(res.ResourceID(0x0546)).BlockData(uint16(gameObjects.mapIconOffsets[id]))

	bmp, _ = image.Read(bytes.NewReader(mapIconBlockData))

	allZero := true
	for row := 0; row < int(bmp.ImageHeight()); row++ {
		for _, b := range bmp.Row(row) {
			if b != 0x00 {
				allZero = false
			}
		}
	}
	if allZero {
		objIconBlockData := gameObjects.objart.Get(res.ResourceID(0x0546)).BlockData(uint16(gameObjects.objIconOffsets[id]))
		bmp, _ = image.Read(bytes.NewReader(objIconBlockData))
	}

	return
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:23,代码来源:GameObjects.go


示例16: Textures

// Textures returns the texture identifier used in this level.
func (level *Level) Textures() (result []int) {
	blockData := level.store.Get(res.ResourceID(4000 + level.id*100 + 7)).BlockData(0)
	reader := bytes.NewReader(blockData)
	var ids [54]uint16

	binary.Read(reader, binary.LittleEndian, &ids)
	for _, id := range ids {
		result = append(result, int(id))
	}

	return
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:13,代码来源:Level.go


示例17: TestChunkStoreReturnsSameInstances

func (suite *ReleaseStoreLibrarySuite) TestChunkStoreReturnsSameInstances(c *check.C) {
	suite.createChunkResource(suite.source, "source.res", func(consumer chunk.Consumer) {
		consumer.Consume(res.ResourceID(1), chunk.NewBlockHolder(chunk.BasicChunkType, res.Palette, [][]byte{[]byte{}}))
	})
	store1, err1 := suite.library.ChunkStore("source.res")
	c.Assert(err1, check.IsNil)
	c.Assert(store1, check.NotNil)

	store2, err2 := suite.library.ChunkStore("source.res")
	c.Assert(err2, check.IsNil)

	c.Check(store1, check.Equals, store2)
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:13,代码来源:ReleaseStoreLibrary_test.go


示例18: SetTextures

// SetTextures sets the texture identifier for this level.
func (level *Level) SetTextures(newIds []int) {
	blockStore := level.store.Get(res.ResourceID(4000 + level.id*100 + 7))
	var ids [54]uint16
	toCopy := len(ids)

	if len(newIds) < toCopy {
		toCopy = len(newIds)
	}
	for index := 0; index < len(ids); index++ {
		ids[index] = uint16(newIds[index])
	}

	buffer := bytes.NewBuffer(nil)
	binary.Write(buffer, binary.LittleEndian, &ids)
	blockStore.SetBlockData(0, buffer.Bytes())
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:17,代码来源:Level.go


示例19: getFont

// GET /projects/{project-id}/fonts/{font-id}
func (resource *WorkspaceResource) getFont(request *restful.Request, response *restful.Response) {
	projectID := request.PathParameter("project-id")
	project, err := resource.ws.Project(projectID)

	if err == nil {
		fontID, _ := strconv.ParseInt(request.PathParameter("font-id"), 10, 16)
		var entity *model.Font

		entity, err = project.Fonts().Font(res.ResourceID(fontID))
		if err == nil {
			response.WriteEntity(*entity)
		} else {
			response.AddHeader("Content-Type", "text/plain")
			response.WriteErrorString(http.StatusBadRequest, err.Error())
		}
	} else {
		response.AddHeader("Content-Type", "text/plain")
		response.WriteErrorString(http.StatusBadRequest, err.Error())
		return
	}
}
开发者ID:inkyblackness,项目名称:shocked-server,代码行数:22,代码来源:WorkspaceResource.go


示例20: Objects

// Objects returns an array of all used objects.
func (level *Level) Objects() []model.LevelObject {
	level.mutex.Lock()
	defer level.mutex.Unlock()

	var result []model.LevelObject

	for index, rawEntry := range level.objectList {
		if rawEntry.IsInUse() {
			entry := model.LevelObject{
				Identifiable: model.Identifiable{ID: fmt.Sprintf("%d", index)},
				Class:        int(rawEntry.Class),
				Subclass:     int(rawEntry.Subclass),
				Type:         int(rawEntry.Type)}

			entry.BaseProperties.TileX = int(rawEntry.X >> 8)
			entry.BaseProperties.FineX = int(rawEntry.X & 0xFF)
			entry.BaseProperties.TileY = int(rawEntry.Y >> 8)
			entry.BaseProperties.FineY = int(rawEntry.Y & 0xFF)
			entry.BaseProperties.Z = int(rawEntry.Z)

			entry.Hacking.Unknown0013 = bytesToIntArray(rawEntry.Unknown0013[:])
			entry.Hacking.Unknown0017 = bytesToIntArray(rawEntry.Unknown0017[:])

			meta := data.LevelObjectClassMetaEntry(rawEntry.Class)
			classStore := level.store.Get(res.ResourceID(4000 + level.id*100 + 10 + entry.Class))
			blockData := classStore.BlockData(0)
			startOffset := meta.EntrySize * int(rawEntry.ClassTableIndex)
			if (startOffset + meta.EntrySize) > len(blockData) {
				fmt.Printf("!!!!! class %d meta says %d bytes size, can't reach index %d in blockData %d",
					int(entry.Class), meta.EntrySize, rawEntry.ClassTableIndex, len(blockData))
			} else {
				entry.Hacking.ClassData = bytesToIntArray(blockData[startOffset+data.LevelObjectPrefixSize : startOffset+meta.EntrySize])
			}

			result = append(result, entry)
		}
	}

	return result
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:41,代码来源:Level.go



注:本文中的github.com/inkyblackness/res.ResourceID函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang opengl.OpenGl类代码示例发布时间:2022-05-23
下一篇:
Golang testutil.Accumulator类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap