예제 #1
0
파일: BotManager.cs 프로젝트: BjkGkh/Azure2
        /// <summary>
        /// Generates the bot from row.
        /// </summary>
        /// <param name="row">The row.</param>
        /// <returns>RoomBot.</returns>
        internal static RoomBot GenerateBotFromRow(DataRow row)
        {
            if (row == null)
                return null;

            var id = Convert.ToUInt32(row["id"]);

            List<string> speeches = null;
            if (!row.IsNull("speech") && !string.IsNullOrEmpty(row["speech"].ToString()))
                speeches = row["speech"].ToString().Split(';').ToList();

            RoomBot bot = new RoomBot(id, Convert.ToUInt32(row["user_id"]), AIType.Generic,
                row["is_bartender"].ToString() == "1");

            bot.Update(Convert.ToUInt32(row["room_id"]), (string)row["walk_mode"], (string)row["name"], (string)row["motto"],
                (string)row["look"],
                int.Parse(row["x"].ToString()), int.Parse(row["y"].ToString()), int.Parse(row["z"].ToString()), 4, 0, 0,
                0, 0, speeches, null, (string)row["gender"], (int)row["dance"], (int)row["speaking_interval"],
                Convert.ToInt32(row["automatic_chat"]) == 1, Convert.ToInt32(row["mix_phrases"]) == 1);

            return bot;
        }
예제 #2
0
        /// <summary>
        ///     Initializes the pets.
        /// </summary>
        internal void InitPets()
        {
            using (var queryReactor = Azure.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery($"SELECT * FROM bots WHERE room_id = '{RoomId}' AND ai_type='pet'");
                var table = queryReactor.GetTable();

                if (table == null)
                    return;

                foreach (DataRow dataRow in table.Rows)
                {
                    queryReactor.SetQuery($"SELECT * FROM pets_data WHERE id = '{dataRow["id"]}' LIMIT 1");
                    var row = queryReactor.GetRow();

                    if (row == null)
                        continue;

                    var pet = CatalogManager.GeneratePetFromRow(dataRow, row);

                    var bot = new RoomBot(pet.PetId, Convert.ToUInt32(RoomData.OwnerId), AiType.Pet, false);
                    bot.Update(RoomId, "freeroam", pet.Name, "", pet.Look, pet.X, pet.Y, ((int) pet.Z), 4, 0, 0, 0, 0,
                        null, null, "", 0, 0, false, false);
                    _roomUserManager.DeployBot(bot, pet);
                }
            }
        }