public void SetLocation(float posX, float posY, float posZ, float heading) { _location.Update(posX, posY, posZ, heading); // When changing location test for appropriate region. RegionHolder testRegion = WorldManager.GetRegion(this); if (!testRegion.Equals(_region)) { if (_region != null) { // Remove this object from the region. _region.RemoveObject(this); // Broadcast change to players left behind when teleporting. if (_isTeleporting) { DeleteObject deleteObject = new DeleteObject(this); List <RegionHolder> regions = _region.GetSurroundingRegions(); for (int i = 0; i < regions.Count; i++) { List <WorldObject> objects = regions[i].GetObjects(); for (int j = 0; j < objects.Count; j++) { WorldObject nearby = objects[j]; if (nearby == this) { continue; } if (nearby.IsPlayer()) { nearby.AsPlayer().ChannelSend(deleteObject); } } } } } // Assign new region. _region = testRegion; _region.AddObject(this); // Send visible NPC information. // TODO: Exclude known NPCs? if (IsPlayer()) { List <WorldObject> objects = WorldManager.GetVisibleObjects(this); for (int i = 0; i < objects.Count; i++) { WorldObject nearby = objects[i]; if (!nearby.IsNpc()) { continue; } AsPlayer().ChannelSend(new NpcInformation(nearby.AsNpc())); } } } }