예제 #1
0
 public void Send(IPacketComposer composer, RoomEntity except) => this.Send(new List <IPacketComposer>()
 {
     composer
 }, new List <RoomEntity>()
 {
     except
 });
예제 #2
0
 public static void RemoveBot(RoomEntity bot)
 {
     using (DatabaseConnection dbClient = Alias.Server.DatabaseManager.GetConnection())
     {
         dbClient.AddParameter("botId", bot.Id);
         dbClient.Query("DELETE FROM `bots_room_data` WHERE `id` = @botId");
     }
 }
예제 #3
0
 public void CreateEntity(RoomEntity entity)
 {
     entity.VirtualId = NextVirtualId;
     this.Send(new RoomUsersComposer(entity));
     this.Send(new RoomUserStatusComposer(entity));
     entity.EntityType.OnEntityJoin();
     this.Room.Mapping.Tiles[entity.Position.X, entity.Position.Y].AddEntity(entity);
     this.Entities.Add(entity);
 }
예제 #4
0
 public void OnUserLeave(RoomEntity entity)
 {
     if (!entity.Disposing)
     {
         entity.Disposing = true;
         this.Send(new RoomUserRemoveComposer(entity.VirtualId));
         entity.EntityType.OnEntityLeave();
         entity.Dispose();
         this.Room.Mapping.Tiles[entity.Position.X, entity.Position.Y].RemoveEntity(entity);
         this.Entities.Remove(entity);
     }
 }
예제 #5
0
 public static void AddBot(RoomEntity bot)
 {
     using (DatabaseConnection dbClient = Alias.Server.DatabaseManager.GetConnection())
     {
         dbClient.AddParameter("botId", bot.Id);
         dbClient.AddParameter("xPos", bot.Position.X);
         dbClient.AddParameter("yPos", bot.Position.Y);
         dbClient.AddParameter("ZPos", bot.Position.Z);
         dbClient.AddParameter("Rot", bot.Position.Rotation);
         dbClient.Query("INSERT INTO `bots_room_data` (`id`, `x`, `y`, `z`, `rot`) VALUES (@botId, @xPos, @yPos, @zPos, @rot)");
     }
 }
예제 #6
0
 public static void UpdateBot(RoomEntity bot)
 {
     using (DatabaseConnection dbClient = Alias.Server.DatabaseManager.GetConnection())
     {
         dbClient.AddParameter("botId", bot.Id);
         dbClient.AddParameter("look", bot.Look);
         dbClient.AddParameter("gender", bot.Gender);
         dbClient.AddParameter("name", bot.Name);
         dbClient.AddParameter("danceId", bot.DanceId);
         dbClient.AddParameter("effectId", bot.EffectId);
         dbClient.AddParameter("canWalk", DatabaseBoolean.GetStringFromBool(bot.CanWalk));
         dbClient.Query("UPDATE `bots` SET `name` = @name, `look` = @look, `gender` = @gender, `dance_id` = @danceId, `effect_id` = @effectId, `can_walk` = @canWalk WHERE `id` = @botId");
     }
 }
예제 #7
0
        public void OnChat(string text, int colour, ChatType chatType, RoomEntity target = null)
        {
            if (colour == 1 || colour == -1 || colour == 2)
            {
                colour = 0;
            }

            if (text.Length > 100)
            {
                text = text.Substring(0, 100);
            }

            if (Alias.Server.ChatManager.GetFilter().CheckBanned(text))
            {
                if (this.Type == RoomEntityType.Player)
                {
                    Alias.Server.ModerationManager.QuickTicket(this.Player, "User said a banned word");
                }
                return;
            }

            text = Alias.Server.ChatManager.GetFilter().Filter(text);

            if (this.Type == RoomEntityType.Player && (text.StartsWith(":") && Alias.Server.ChatManager.GetCommands().Parse(this.Player.Session, text)))
            {
                return;
            }

            RoomUserChatComposer packet = new RoomUserChatComposer(this.VirtualId, text, Alias.Server.ChatManager.GetEmotions().GetEmotionsForText(text), colour, chatType);

            if (target != null)
            {
                if (target != this)
                {
                    target.Player.Session.Send(packet);
                }
                this.Player.Session.Send(packet);
            }
            else
            {
                this.Room.EntityManager.Send(packet);
            }

            if (this.Type == RoomEntityType.Player)
            {
                WordFilterDatabase.StoreMessage(this.Player.Id, this.Room.Id, text, ChatTypeToInt(chatType), target != null ? target.Player.Id : 0);
            }
        }
예제 #8
0
        public static List <RoomEntity> ReadBots(Room room)
        {
            List <RoomEntity> bots = new List <RoomEntity>();

            using (DatabaseConnection dbClient = Alias.Server.DatabaseManager.GetConnection())
            {
                dbClient.AddParameter("roomId", room.Id);
                using (MySqlDataReader Reader = dbClient.DataReader("SELECT * FROM `bots` INNER JOIN `bots_room_data` ON `bots`.`id` = `bots_room_data`.`id` WHERE `bots`.`room_id` = @roomId"))
                {
                    while (Reader.Read())
                    {
                        RoomEntity entity = new RoomEntity
                        {
                            Id       = Reader.GetInt32("id"),
                            Name     = Reader.GetString("name"),
                            Motto    = Reader.GetString("motto"),
                            Look     = Reader.GetString("look"),
                            Gender   = Reader.GetString("gender"),
                            OwnerId  = Reader.GetInt32("user_id"),
                            DanceId  = Reader.GetInt32("dance_id"),
                            EffectId = Reader.GetInt32("effect_id"),
                            CanWalk  = Reader.GetBoolean("can_walk"),
                            Type     = RoomEntityType.Bot,
                            Room     = room,
                            Position = new UserPosition()
                            {
                                X            = Reader.GetInt32("x"),
                                Y            = Reader.GetInt32("y"),
                                Z            = Reader.GetDouble("z"),
                                Rotation     = Reader.GetInt32("rot"),
                                HeadRotation = Reader.GetInt32("rot")
                            }
                        };
                        bots.Add(entity);
                    }
                }
            }
            return(bots);
        }
예제 #9
0
        public static List <RoomEntity> ReadPets(Room room)
        {
            List <RoomEntity> pets = new List <RoomEntity>();

            using (DatabaseConnection dbClient = Alias.Server.DatabaseManager.GetConnection())
            {
                dbClient.AddParameter("roomId", room.Id);
                using (MySqlDataReader Reader = dbClient.DataReader("SELECT * FROM `pets` INNER JOIN `pets_room_data` ON `pets`.`id` = `pets_room_data`.`id` WHERE `pets`.`room_id` = @roomId"))
                {
                    while (Reader.Read())
                    {
                        RoomEntity entity = new RoomEntity
                        {
                            Id       = Reader.GetInt32("id"),
                            Name     = Reader.GetString("name"),
                            Motto    = "",
                            Look     = Reader.GetInt32("type") + " " + Reader.GetInt32("race") + " " + Reader.GetString("colour") + " 2 2 4 0 0",
                            Gender   = Reader.GetInt32("type") + "",
                            OwnerId  = Reader.GetInt32("user_id"),
                            Type     = RoomEntityType.Pet,
                            Room     = room,
                            Position = new UserPosition()
                            {
                                X            = Reader.GetInt32("x"),
                                Y            = Reader.GetInt32("y"),
                                Z            = Reader.GetDouble("z"),
                                Rotation     = Reader.GetInt32("rot"),
                                HeadRotation = Reader.GetInt32("rot")
                            }
                        };
                        pets.Add(entity);
                    }
                }
            }
            return(pets);
        }