public bool FinalizeAdd(MapObject obj) { Sector sector = GetSectorByPos(obj.Position); sector.AddObject(obj, true); return(Objects.TryAdd(obj.MapObjectID, obj)); }
public void Transfer(MapObject obj, Sector to) { Objects.Remove(obj.MapObjectID); to.AddObject(obj); // we remove object first to the 'non display region' ZoneCharacter character = obj as ZoneCharacter; List<Sector> oldsectors = Map.GetSectorsOutOfRange(this, to); // The idea of this function // 1. Remove obj from map for players that are out of range // (IF PLAYER) 2. Remove objects that are out of range for obj // (IF PLAYER) 3. Spawn objects that are new in range for obj // 4. Spawn obj for all players in new range using (var removeObjPacket = Handler7.RemoveObject(obj)) // Make new packet to remove object from map for others { // Even nederlands: Kijken of we mensen kunnen vinden in range? foreach (var victimObject in Map.GetObjectsBySectors(oldsectors)) { if (victimObject is NPC) continue; // NPC's are for noobs. Can't despawn if (victimObject is ZoneCharacter) { // Remove obj for player ZoneCharacter victim = victimObject as ZoneCharacter; victim.Client.SendPacket(removeObjPacket); } if (character != null) { // Despawn victimObject for obj using (var removeVictimPacket = Handler7.RemoveObject(victimObject)) { character.Client.SendPacket(removeVictimPacket); } } } } //we remove all the drops out of the character's region if (character != null && character.Client != null) { foreach (var dropoutofrange in Map.GetDropsBySectors(oldsectors)) { using (var despawndrop = Handler6.RemoveDrop(dropoutofrange)) { character.Client.SendPacket(despawndrop); } } } //now we spawn the object to other objects in map List<Sector> newsectors = Map.GetSectorsNewInRange(this, to); List<MapObject> objects = Map.GetObjectsBySectors(newsectors); using (var packet = obj.Spawn()) { foreach (var mapObject in objects) { if (mapObject is NPC) continue; //we don't respawn NPCs if (mapObject is ZoneCharacter) { ZoneCharacter rangechar = mapObject as ZoneCharacter; // Send spawn packet of the object (can be both a character and mob) to mapObject (a player) rangechar.Client.SendPacket(packet); } if (character != null) { // Send spawn packet of mapObject to character using (var spawn = mapObject.Spawn()) { character.Client.SendPacket(spawn); } } } } if (character != null && character.Client != null) { using (var spawndrops = Handler7.ShowDrops(Map.GetDropsBySectors(newsectors))) { character.Client.SendPacket(spawndrops); } } }
public void Transfer(MapObject obj, Sector to) { Objects.Remove(obj.MapObjectID); to.AddObject(obj); // we remove object first to the 'non display region' ZoneCharacter character = obj as ZoneCharacter; List <Sector> oldsectors = Map.GetSectorsOutOfRange(this, to); // The idea of this function // 1. Remove obj from map for players that are out of range // (IF PLAYER) 2. Remove objects that are out of range for obj // (IF PLAYER) 3. Spawn objects that are new in range for obj // 4. Spawn obj for all players in new range using (var removeObjPacket = Handler7.RemoveObject(obj)) // Make new packet to remove object from map for others { // Even nederlands: Kijken of we mensen kunnen vinden in range? foreach (var victimObject in Map.GetObjectsBySectors(oldsectors)) { if (victimObject is NPC) { continue; // NPC's are for noobs. Can't despawn } if (victimObject is ZoneCharacter) { // Remove obj for player ZoneCharacter victim = victimObject as ZoneCharacter; victim.Client.SendPacket(removeObjPacket); } if (character != null) { // Despawn victimObject for obj using (var removeVictimPacket = Handler7.RemoveObject(victimObject)) { character.Client.SendPacket(removeVictimPacket); } } } } //we remove all the drops out of the character's region if (character != null && character.Client != null) { foreach (var dropoutofrange in Map.GetDropsBySectors(oldsectors)) { using (var despawndrop = Handler6.RemoveDrop(dropoutofrange)) { character.Client.SendPacket(despawndrop); } } } //now we spawn the object to other objects in map List <Sector> newsectors = Map.GetSectorsNewInRange(this, to); List <MapObject> objects = Map.GetObjectsBySectors(newsectors); using (var packet = obj.Spawn()) { foreach (var mapObject in objects) { if (mapObject is NPC) { continue; //we don't respawn NPCs } if (mapObject is ZoneCharacter) { ZoneCharacter rangechar = mapObject as ZoneCharacter; // Send spawn packet of the object (can be both a character and mob) to mapObject (a player) rangechar.Client.SendPacket(packet); } if (character != null) { // Send spawn packet of mapObject to character using (var spawn = mapObject.Spawn()) { character.Client.SendPacket(spawn); } } } } if (character != null && character.Client != null) { using (var spawndrops = Handler7.ShowDrops(Map.GetDropsBySectors(newsectors))) { character.Client.SendPacket(spawndrops); } } }