aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tools/pCampBot/BotManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tools/pCampBot/BotManager.cs')
-rw-r--r--OpenSim/Tools/pCampBot/BotManager.cs53
1 files changed, 48 insertions, 5 deletions
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index 51c5ff4..6433c2e 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -200,11 +200,11 @@ namespace pCampBot
200 "Can be performed on connected or disconnected bots.", 200 "Can be performed on connected or disconnected bots.",
201 HandleAddBehaviour); 201 HandleAddBehaviour);
202 202
203// m_console.Commands.AddCommand( 203 m_console.Commands.AddCommand(
204// "bot", false, "remove behaviour", "remove behaviour <abbreviated-name> <bot-number>", 204 "bot", false, "remove behaviour", "remove behaviour <abbreviated-name> <bot-number>",
205// "Remove a behaviour from a bot", 205 "Remove a behaviour from a bot",
206// "Can be performed on connected or disconnected bots.", 206 "Can be performed on connected or disconnected bots.",
207// HandleRemoveBehaviour); 207 HandleRemoveBehaviour);
208 208
209 m_console.Commands.AddCommand( 209 m_console.Commands.AddCommand(
210 "bot", false, "sit", "sit", "Sit all bots on the ground.", 210 "bot", false, "sit", "sit", "Sit all bots on the ground.",
@@ -525,6 +525,49 @@ namespace pCampBot
525 string.Join(", ", behavioursAdded.ConvertAll<string>(b => b.Name).ToArray()), bot.Name); 525 string.Join(", ", behavioursAdded.ConvertAll<string>(b => b.Name).ToArray()), bot.Name);
526 } 526 }
527 527
528 private void HandleRemoveBehaviour(string module, string[] cmd)
529 {
530 if (cmd.Length != 4)
531 {
532 MainConsole.Instance.OutputFormat("Usage: remove behaviour <abbreviated-behaviour> <bot-number>");
533 return;
534 }
535
536 string rawBehaviours = cmd[2];
537 int botNumber;
538
539 if (!ConsoleUtil.TryParseConsoleNaturalInt(MainConsole.Instance, cmd[3], out botNumber))
540 return;
541
542 Bot bot = GetBotFromNumber(botNumber);
543
544 if (bot == null)
545 {
546 MainConsole.Instance.OutputFormat("Error: No bot found with number {0}", botNumber);
547 return;
548 }
549
550 HashSet<string> abbreviatedBehavioursToRemove = new HashSet<string>();
551 List<IBehaviour> behavioursRemoved = new List<IBehaviour>();
552
553 Array.ForEach<string>(rawBehaviours.Split(new char[] { ',' }), b => abbreviatedBehavioursToRemove.Add(b));
554
555 foreach (string b in abbreviatedBehavioursToRemove)
556 {
557 IBehaviour behaviour;
558
559 if (bot.TryGetBehaviour(b, out behaviour))
560 {
561 bot.RemoveBehaviour(b);
562 behavioursRemoved.Add(behaviour);
563 }
564 }
565
566 MainConsole.Instance.OutputFormat(
567 "Removed behaviours {0} to bot {1}",
568 string.Join(", ", behavioursRemoved.ConvertAll<string>(b => b.Name).ToArray()), bot.Name);
569 }
570
528 private void HandleDisconnect(string module, string[] cmd) 571 private void HandleDisconnect(string module, string[] cmd)
529 { 572 {
530 lock (m_bots) 573 lock (m_bots)