本文整理匯總了Golang中github.com/kirbywarp/rogue/engine.EntityDB.Search方法的典型用法代碼示例。如果您正苦於以下問題:Golang EntityDB.Search方法的具體用法?Golang EntityDB.Search怎麽用?Golang EntityDB.Search使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/kirbywarp/rogue/engine.EntityDB
的用法示例。
在下文中一共展示了EntityDB.Search方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SystemMove
/*
SystemMove applies makes every entity with movement try to move in the map
*/
func SystemMove(db *engine.EntityDB) {
for _, eid := range db.Search("movement", "position") {
pos := db.Get(eid, "position").(*Position)
mov := db.Get(eid, "movement").(*Movement)
emap := db.Get(pos.R, "map").(*EntityMap)
// Prevent entities from moving on top of each other, temporarily
if emap.Get(pos.X+mov.Dx, pos.Y+mov.Dy, pos.Z+mov.Dz) != 0 {
continue
}
// Move and update the map
emap.Set(pos.X, pos.Y, pos.Z, 0)
pos.X += mov.Dx
pos.Y += mov.Dy
pos.Z += mov.Dz
emap.Set(pos.X, pos.Y, pos.Z, eid)
}
}
示例2: SystemAct
/*
SystemAct allows each entity with an AI to attempt to act
*/
func SystemAct(db *engine.EntityDB) {
for _, eid := range db.Search("ai", "position") {
ai := db.Get(eid, "ai").(*AI)
ai.Controller.Act(db, eid)
}
}