本文整理汇总了Golang中stabbey/interfaces.Entity.IsTangible方法的典型用法代码示例。如果您正苦于以下问题:Golang Entity.IsTangible方法的具体用法?Golang Entity.IsTangible怎么用?Golang Entity.IsTangible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stabbey/interfaces.Entity
的用法示例。
在下文中一共展示了Entity.IsTangible方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SwapPositionWith
func (e *Entity) SwapPositionWith(other interfaces.Entity) {
if !e.IsTangible() || !other.IsTangible() {
log.Fatalf("Swap only makes sense for tangible entities. Got %v & %v",
e.GetName(), other.GetName())
}
/* It's crucial that two tagnible entities don't end up on same tile */
boardId, x, y := e.GetPosition()
boardId2, x2, y2 := other.GetPosition()
e.BoardId, e.X, e.Y = boardId2, x2, y2
/* Can work since both entities are technically in the same place */
other.SetPosition(boardId, x, y)
/* Manually trigger trodden functions since we didn't SetPosition */
for _, entity := range e.Game.GetEntitiesAtSpace(e.GetPosition()) {
entity.Trodden(e)
}
/* other's reposition function will be called by SetPosition */
e.RepositionFunction(boardId, x, y, boardId2, x2, y2)
}