func (n *Npc) OnCreatureMove(_creature pul.ICreature, _from pul.ITile, _to pul.ITile, _teleport bool) { // Check if _creature is a Player, otherwise return if _creature.GetType() != CTYPE_PLAYER { return } canSeeFromTile := CanSeePosition(n.GetPosition(), _from.GetPosition()) canSeeToTile := CanSeePosition(n.GetPosition(), _to.GetPosition()) if canSeeFromTile && !canSeeToTile { // Leaving viewport n.RemoveVisibleCreature(_creature) _creature.RemoveVisibleCreature(n) } else if canSeeToTile && !canSeeFromTile { // Entering viewport n.AddVisibleCreature(_creature) _creature.RemoveVisibleCreature(n) } else { // Moving inside viewport n.AddVisibleCreature(_creature) _creature.AddVisibleCreature(n) } }
func (m *SendTilesMessage) AddTile(_tile pul.ITile) { m.Tiles[_tile.GetPosition().Hash()] = _tile }