本文整理汇总了Golang中gameserver/interfaces.ICreature.RemoveVisibleCreature方法的典型用法代码示例。如果您正苦于以下问题:Golang ICreature.RemoveVisibleCreature方法的具体用法?Golang ICreature.RemoveVisibleCreature怎么用?Golang ICreature.RemoveVisibleCreature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gameserver/interfaces.ICreature
的用法示例。
在下文中一共展示了ICreature.RemoveVisibleCreature方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: OnCreatureMove
func (p *Player) OnCreatureMove(_creature interfaces.ICreature, _from position.Position, _to position.Position, _teleport bool) {
// Call base function
p.Creature.OnCreatureMove(_creature, _from, _to, _teleport)
// Do nothing is creature is me
if p.GetUID() == _creature.GetUID() {
return
}
canSeeFromPosition := p.CanSeePosition(_from)
canSeeToPosition := p.CanSeePosition(_to)
if canSeeFromPosition && canSeeToPosition {
// We can see both from and to positions, meaning the creature is moving inside the viewport
p.netSendCreatureMove(_creature, _from, _to, _teleport)
} else if canSeeFromPosition && !canSeeToPosition {
// We can see the from position but not the to positioin, meaning the creature is leaving our viewport
// Send CreatureMove message to client before removing the creature from the visible creatures list
p.netSendCreatureMove(_creature, _from, _to, _teleport)
p.RemoveVisibleCreature(_creature)
_creature.RemoveVisibleCreature(p)
} else if !canSeeFromPosition && canSeeToPosition {
// We can't see the from position but we can see the to position, meaning the creature is entering our viewport
// First add the creature to our visible creature list before sending the CreatureMove message to the client
p.AddVisibleCreature(_creature)
_creature.AddVisibleCreature(p)
p.netSendCreatureMove(_creature, _from, _to, _teleport)
} else {
// Somehow it's impossible to see the creature, may this ever happen somehow
p.RemoveVisibleCreature(_creature)
_creature.RemoveVisibleCreature(p)
}
}