当前位置: 首页>>代码示例>>Golang>>正文


Golang res.ResourceID函数代码示例

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


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


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