Пример #1
0
        public void SendCharacterLeftMap(ZoneCharacter character, bool toplayer = true)
        {
            using (var removeObjPacket = Handler7.RemoveObject(character)) // Make new packet to remove object from map for others
            {
                foreach (var victimObject in character.MapSector.Objects.Values)
                {
                    if (victimObject == character)
                    {
                        continue;                            // ...
                    }
                    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 && toplayer)
                    {
                        // Despawn victimObject for obj
                        using (var removeVictimPacket = Handler7.RemoveObject(victimObject))
                        {
                            character.Client.SendPacket(removeVictimPacket);
                        }
                    }

                    Handler14.SendPartyMemberCordChange(character.Client);
                }
            }
        }
Пример #2
0
 public void AddDrop(Drop drop)
 {
     Drops.Add(drop.ID, drop);
     using (var spawn = Handler7.ShowDrop(drop))
     {
         Broadcast(spawn);
     }
 }
Пример #3
0
        public void RemoveObject(MapObject obj)
        {
            Objects.Remove(obj.MapObjectID);
            obj.MapSector = null;

            using (var remover = Handler7.RemoveObject(obj))
            {
                Broadcast(remover);
            }
        }
Пример #4
0
        public void SendCharacterEnteredMap(ZoneCharacter character)
        {
            //we send all players in region to character
            var characters = GetCharactersInRegion(character.MapSector);

            using (var packet = Handler7.SpawnMultiPlayer(characters, character))
            {
                character.Client.SendPacket(packet);
                if (character.Mount != null)
                {
                    character.Mounting(character.Mount.Handle, true);
                }
            }

            //we send character to all players in region
            using (var packet = Handler7.SpawnSinglePlayer(character))
            {
                foreach (var charinmap in characters)
                {
                    if (charinmap == character)
                    {
                        continue;
                    }
                    charinmap.Client.SendPacket(packet);
                }
            }

            //we send moblist and NPC to local character
            var npcs     = Objects.Values.Where(o => o is Npc);
            var monsters =
                GetObjectsBySectors(character.MapSector.SurroundingSectors).Where(o => o is Mob);

            var obj = new List <MapObject>(npcs);

            obj.AddRange(monsters);
            if (obj.Count > 0)
            {
                for (var i = 0; i < obj.Count; i += 255)
                {
                    using (var packet = Handler7.MultiObjectList(obj, i, i + Math.Min(255, obj.Count - i)))
                    {
                        character.Client.SendPacket(packet);
                    }
                }
            }

            //we send all drops to the character
            using (var spawndrops = Handler7.ShowDrops(GetDropsBySectors(character.MapSector.SurroundingSectors)))
            {
                character.Client.SendPacket(spawndrops);
            }
        }
Пример #5
0
        public void SendCharacterLeftMap(ZoneCharacter character, bool toplayer = true)
        {
            using (var removeObjPacket = Handler7.RemoveObject(character)
                   ) // Make new packet to remove object from map for others
            {
                foreach (var victimObject in character.MapSector.Objects.Values)
                {
                    if (victimObject == character)
                    {
                        continue;                            // ...
                    }
                    switch (victimObject)
                    {
                    case Npc _:
                        continue;     // NPC's are for noobs. Can't despawn

                    case ZoneCharacter _:
                    {
                        // Remove obj for player
                        var victim = victimObject as ZoneCharacter;
                        victim.Client.SendPacket(removeObjPacket);
                        break;
                    }
                    }

                    if (!toplayer)
                    {
                        continue;
                    }
                    // Despawn victimObject for obj
                    using (var removeVictimPacket = Handler7.RemoveObject(victimObject))
                    {
                        character.Client.SendPacket(removeVictimPacket);
                    }
                }
            }
        }
 public void Handle(Handler7 notImportant)
 {
 }
Пример #7
0
 public RequestHandler7 <T, TR, TU, TI, TJ, TK, TL> Handle(Handler7 handler)
 {
     _executor = (request, param1, param2, param3, param4, param5, param6, param7, mediaTypeMapper1, errorHandler1, logger1)
                 => RequestExecutor.ExecuteRequest(() => handler.Invoke(param1, param2, param3, param4, param5, param6, param7), errorHandler1, logger1);
     return(this);
 }
Пример #8
0
        public void Transfer(MapObject obj, Sector to)
        {
            Objects.Remove(obj.MapObjectID);
            to.AddObject(obj);
            // we remove object first to the 'non display region'
            var character  = obj as ZoneCharacter;
            var 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
                        var 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

            var newsectors = Map.GetSectorsNewInRange(this, to);
            var 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)
                    {
                        var 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);
                }
            }
        }