本文整理匯總了Golang中github.com/eaigner/hood.Hood.Find方法的典型用法代碼示例。如果您正苦於以下問題:Golang Hood.Find方法的具體用法?Golang Hood.Find怎麽用?Golang Hood.Find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/eaigner/hood.Hood
的用法示例。
在下文中一共展示了Hood.Find方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: LoadWorldmap
func LoadWorldmap(_hood *hood.Hood) {
if loaded {
panic("Worldmap has already been loaded!")
}
// Load maps
var maps []entities.Map
if err := _hood.Find(&maps); err != nil {
panic(err)
}
if len(maps) > 0 {
for _, mapEntity := range maps {
mapId := int(mapEntity.MapId)
worldmap[mapId] = NewTilePointTable(mapEntity.Name)
}
numOfProcessRoutines = len(maps)
go internalLoadWorldmap(_hood)
waitForLoadComplete()
} else {
log.Warning("World", "LoadWorldmap", "No maps found in the database")
}
loaded = true
}
示例2: loadMoves
func loadMoves(_hood *hood.Hood) {
log.Verbose("Pokemon.Manager", "loadMoves", "Loading pokemon moves from database")
var moves []entities.Move
if err := _hood.Find(&moves); err != nil {
log.Error("Pokemon.Manager", "loadMoves", "Error while loading moves: %s", err.Error())
} else {
for _, moveEntity := range moves {
move := NewMove(&moveEntity)
movesStore[move.GetMoveId()] = move
}
}
}
示例3: GetWorkers
func GetWorkers(tx *hood.Hood) []*Worker {
var results []Worker
err := tx.Find(&results)
if err != nil {
panic(err)
}
// Should return pointers to the result objects so that
// they can be mutated
pointerResults := make([]*Worker, len(results))
for i := range results {
pointerResults[i] = &results[i]
}
return pointerResults
}
示例4: loadMap
func loadMap(_hood *hood.Hood, _mapId int, _tilePointTable *TilePointTable) {
// Create select query to get all tilepoints and layers as one result
_hood.Select("tilepoint", "tilepoint.x", "tilepoint.y", "tilepointlayer.level", "tilepointlayer.blocking", "tilepointtilelayer.layer", "tilepointtilelayer.tileId")
_hood.Join(hood.LeftJoin, "tilepointlayer", "tilepointlayer.tilePointId", "tilepoint.tilePointId")
_hood.Join(hood.LeftJoin, "tilepointtilelayer", "tilepointtilelayer.tilePointLayerId", "tilepointlayer.tilePointLayerId")
var tilePointRows []TilePointRow
if err := _hood.Find(&tilePointRows); err != nil {
log.Error("World", "loadMap", "Error fetching tilepoints from database:\n%s", err.Error())
} else {
for _, row := range tilePointRows {
processTilePoints(row, _tilePointTable)
}
}
processExitChan <- true
}
示例5: loadPokemon
func loadPokemon(_hood *hood.Hood) {
log.Verbose("Pokemon.Manager", "loadPokemon", "Loading pokemon from database")
var pokemon []entities.Pokemon
if err := _hood.Find(&pokemon); err != nil {
log.Error("Pokemon.Manager", "loadPokemon", "Error while loading pokemon: %s", err.Error())
} else {
for _, pokemonEntity := range pokemon {
poke := NewPokemon(&pokemonEntity)
if err := poke.LinkMoves(_hood); err != nil {
log.Error("Pokemon.Manager", "loadPokemon", "Failed to link moves to Pokemon %d. Error: %s", poke.GetPokemonId(), err.Error())
} else {
pokemonStore[poke.GetPokemonId()] = poke
}
}
}
}