diff options
author | Justin Clark-Casey (justincc) | 2013-09-03 19:05:54 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-09-03 19:05:54 +0100 |
commit | 1a2627031d8a80b1d5e21fd2d13e4dc2b123c0b4 (patch) | |
tree | e0909f8e5def5b46faefe6808b25cc7ff656a47f /OpenSim/Tools/pCampBot/BotManager.cs | |
parent | Add ability to adjust pCampbot bot behaviours whilst running with "add behavi... (diff) | |
download | opensim-SC_OLD-1a2627031d8a80b1d5e21fd2d13e4dc2b123c0b4.zip opensim-SC_OLD-1a2627031d8a80b1d5e21fd2d13e4dc2b123c0b4.tar.gz opensim-SC_OLD-1a2627031d8a80b1d5e21fd2d13e4dc2b123c0b4.tar.bz2 opensim-SC_OLD-1a2627031d8a80b1d5e21fd2d13e4dc2b123c0b4.tar.xz |
Add pCampbot "remove behaviour" console command for removing bot behaviours during operation.
Doesn't currently work very well as stopping physics, for instance, can leave bot travelling in old direction
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Tools/pCampBot/BotManager.cs | 53 |
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) |