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())); } } } }
public void SetLocation(LocationHolder location) { this.location = location; // 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(objectId); // Broadcast change to players left behind when teleporting. if (isTeleporting) { DeleteObject deleteObject = new DeleteObject(this); foreach (RegionHolder nearbyRegion in region.GetSurroundingRegions()) { foreach (WorldObject obj in region.GetObjects()) { if (obj == this) { continue; } if (obj.IsPlayer()) { obj.AsPlayer().ChannelSend(deleteObject); } } } } } // Assign new region. region = testRegion; region.AddObject(this); // Send visible NPC information. // TODO: Exclude known NPCs? if (IsPlayer()) { foreach (WorldObject obj in WorldManager.GetVisibleObjects(this)) { if (!obj.IsNpc()) { continue; } AsPlayer().ChannelSend(new NpcInformation(obj.AsNpc())); } } } }