public static void LoadBotDefinitions(SqlDatabaseClient MySqlClient) { mBotDefinitions.Clear(); mDefinedResponses.Clear(); mDefinedSpeech.Clear(); mPetHandlerIndex.Clear(); DataTable ResponseTable = MySqlClient.ExecuteQueryTable("SELECT bot_id,triggers,responses,response_serve_id FROM bot_responses"); foreach (DataRow Row in ResponseTable.Rows) { BotResponse Response = new BotResponse(Row["triggers"].ToString().Split('|').ToList(), Row["responses"].ToString().Split('|').ToList(), (int)Row["response_serve_id"]); if (!mDefinedResponses.ContainsKey((uint)Row["bot_id"])) { mDefinedResponses.Add((uint)Row["bot_id"], new List<BotResponse>()); } mDefinedResponses[(uint)Row["bot_id"]].Add(Response); } DataTable SpeechTable = MySqlClient.ExecuteQueryTable("SELECT bot_id,message FROM bots_speech"); foreach (DataRow Row in SpeechTable.Rows) { if (!mDefinedSpeech.ContainsKey((uint)Row["bot_id"])) { mDefinedSpeech.Add((uint)Row["bot_id"], new List<string>()); } mDefinedSpeech[(uint)Row["bot_id"]].Add((string)Row["message"]); } MySqlClient.SetParameter("enabled", "1"); DataTable BotTable = MySqlClient.ExecuteQueryTable("SELECT * FROM bots WHERE enabled = @enabled"); foreach (DataRow Row in BotTable.Rows) { BotWalkMode WMode = BotWalkMode.STAND; switch ((string)Row["walk_mode"]) { case "freeroam": WMode = BotWalkMode.FREEROAM; break; case "defined": WMode = BotWalkMode.SPECIFIED_RANGE; break; } List<Vector2> DefinedPositions = new List<Vector2>(); string[] DefPosBits = Row["pos_defined_range"].ToString().Split(';'); foreach (string DefPosBit in DefPosBits) { DefinedPositions.Add(Vector2.FromString(DefPosBit)); } Bot Bot = new Bot((uint)Row["id"], (uint)Row["id"], (string)Row["ai_type"], (string)Row["name"], (string)Row["look"], (string)Row["motto"], (uint)Row["room_id"], Vector3.FromString((string)Row["pos_start"]), Vector2.FromString((string)Row["pos_serve"]), DefinedPositions, WMode, (Row["kickable"].ToString() == "1"), (int)Row["rotation"], (mDefinedResponses.ContainsKey((uint)Row["id"]) ? mDefinedResponses[(uint)Row["id"]] : new List<BotResponse>()), (int)Row["effect"], (int)Row["response_distance"]); mBotDefinitions.Add((uint)Row["id"], Bot); int PetHandler = (int)Row["pet_type_handler_id"]; if ((string)Row["ai_type"] == "pet") { mPetHandlerIndex.Add(PetHandler, Bot); } } }
public static void LoadBotDefinitions(SqlDatabaseClient MySqlClient) { mBotDefinitions.Clear(); mDefinedResponses.Clear(); mDefinedSpeech.Clear(); mPetHandlerIndex.Clear(); DataTable ResponseTable = MySqlClient.ExecuteQueryTable("SELECT bot_id,triggers,responses,response_serve_id FROM bot_responses"); foreach (DataRow Row in ResponseTable.Rows) { BotResponse Response = new BotResponse(Row["triggers"].ToString().Split('|').ToList(), Row["responses"].ToString().Split('|').ToList(), (int)Row["response_serve_id"]); if (!mDefinedResponses.ContainsKey((uint)Row["bot_id"])) { mDefinedResponses.Add((uint)Row["bot_id"], new List <BotResponse>()); } mDefinedResponses[(uint)Row["bot_id"]].Add(Response); } DataTable SpeechTable = MySqlClient.ExecuteQueryTable("SELECT bot_id,message FROM bots_speech"); foreach (DataRow Row in SpeechTable.Rows) { if (!mDefinedSpeech.ContainsKey((uint)Row["bot_id"])) { mDefinedSpeech.Add((uint)Row["bot_id"], new List <string>()); } mDefinedSpeech[(uint)Row["bot_id"]].Add((string)Row["message"]); } MySqlClient.SetParameter("enabled", "1"); DataTable BotTable = MySqlClient.ExecuteQueryTable("SELECT * FROM bots WHERE enabled = @enabled"); foreach (DataRow Row in BotTable.Rows) { BotWalkMode WMode = BotWalkMode.STAND; switch ((string)Row["walk_mode"]) { case "freeroam": WMode = BotWalkMode.FREEROAM; break; case "defined": WMode = BotWalkMode.SPECIFIED_RANGE; break; } List <Vector2> DefinedPositions = new List <Vector2>(); string[] DefPosBits = Row["pos_defined_range"].ToString().Split(';'); foreach (string DefPosBit in DefPosBits) { DefinedPositions.Add(Vector2.FromString(DefPosBit)); } Bot Bot = new Bot((uint)Row["id"], (uint)Row["id"], (string)Row["ai_type"], (string)Row["name"], (string)Row["look"], (string)Row["motto"], (uint)Row["room_id"], Vector3.FromString((string)Row["pos_start"]), Vector2.FromString((string)Row["pos_serve"]), DefinedPositions, WMode, (Row["kickable"].ToString() == "1"), (int)Row["rotation"], (mDefinedResponses.ContainsKey((uint)Row["id"]) ? mDefinedResponses[(uint)Row["id"]] : new List <BotResponse>()), (int)Row["effect"], (int)Row["response_distance"]); mBotDefinitions.Add((uint)Row["id"], Bot); int PetHandler = (int)Row["pet_type_handler_id"]; if (PetHandler > 0) { mPetHandlerIndex.Add(PetHandler, Bot); } } }