Add pCampbot console commands to sit all bots on ground and stand all bots

0.7.6-extended
Justin Clark-Casey (justincc) 2013-08-20 17:01:12 +01:00
parent a3dd7db4a3
commit 56d1d67a34
2 changed files with 51 additions and 47 deletions

View File

@ -318,6 +318,30 @@ namespace pCampBot
} }
} }
/// <summary>
/// Sit this bot on the ground.
/// </summary>
public void SitOnGround()
{
if (ConnectionState == ConnectionState.Connected)
Client.Self.SitOnGround();
}
/// <summary>
/// Stand this bot
/// </summary>
public void Stand()
{
if (ConnectionState == ConnectionState.Connected)
{
// Unlike sit on ground, here libomv checks whether we have SEND_AGENT_UPDATES enabled.
bool prevUpdatesSetting = Client.Settings.SEND_AGENT_UPDATES;
Client.Settings.SEND_AGENT_UPDATES = true;
Client.Self.Stand();
Client.Settings.SEND_AGENT_UPDATES = prevUpdatesSetting;
}
}
public void SaveDefaultAppearance() public void SaveDefaultAppearance()
{ {
saveDir = "MyAppearance/" + FirstName + "_" + LastName; saveDir = "MyAppearance/" + FirstName + "_" + LastName;

View File

@ -194,15 +194,19 @@ namespace pCampBot
+ "If no <n> is given, then all currently connected bots are disconnected.", + "If no <n> is given, then all currently connected bots are disconnected.",
HandleDisconnect); HandleDisconnect);
m_console.Commands.AddCommand(
"bot", false, "sit", "sit", "Sit all bots on the ground.",
HandleSit);
m_console.Commands.AddCommand(
"bot", false, "stand", "stand", "Stand all bots.",
HandleStand);
m_console.Commands.AddCommand( m_console.Commands.AddCommand(
"bot", false, "show regions", "show regions", "Show regions known to bots", HandleShowRegions); "bot", false, "show regions", "show regions", "Show regions known to bots", HandleShowRegions);
m_console.Commands.AddCommand( m_console.Commands.AddCommand(
"bot", false, "show bots", "show bots", "Shows the status of all bots", HandleShowStatus); "bot", false, "show bots", "show bots", "Shows the status of all bots", HandleShowBotsStatus);
// m_console.Commands.AddCommand("bot", false, "add bots",
// "add bots <number>",
// "Add more bots", HandleAddBots);
m_bots = new List<Bot>(); m_bots = new List<Bot>();
} }
@ -340,26 +344,6 @@ namespace pCampBot
return string.Format("uri:{0}&{1}&{2}&{3}", regionName, startPos.X, startPos.Y, startPos.Z); return string.Format("uri:{0}&{1}&{2}&{3}", regionName, startPos.X, startPos.Y, startPos.Z);
} }
// /// <summary>
// /// Add additional bots (and threads) to our bot pool
// /// </summary>
// /// <param name="botcount">How Many of them to add</param>
// public void addbots(int botcount)
// {
// int len = m_td.Length;
// Thread[] m_td2 = new Thread[len + botcount];
// for (int i = 0; i < len; i++)
// {
// m_td2[i] = m_td[i];
// }
// m_td = m_td2;
// int newlen = len + botcount;
// for (int i = len; i < newlen; i++)
// {
// startupBot(Config);
// }
// }
/// <summary> /// <summary>
/// This creates a bot but does not start it. /// This creates a bot but does not start it.
/// </summary> /// </summary>
@ -496,6 +480,22 @@ namespace pCampBot
} }
} }
private void HandleSit(string module, string[] cmd)
{
lock (m_bots)
{
m_bots.ForEach(b => b.SitOnGround());
}
}
private void HandleStand(string module, string[] cmd)
{
lock (m_bots)
{
m_bots.ForEach(b => b.Stand());
}
}
private void HandleShutdown(string module, string[] cmd) private void HandleShutdown(string module, string[] cmd)
{ {
lock (m_bots) lock (m_bots)
@ -529,7 +529,7 @@ namespace pCampBot
} }
} }
private void HandleShowStatus(string module, string[] cmd) private void HandleShowBotsStatus(string module, string[] cmd)
{ {
ConsoleDisplayTable cdt = new ConsoleDisplayTable(); ConsoleDisplayTable cdt = new ConsoleDisplayTable();
cdt.AddColumn("Name", 30); cdt.AddColumn("Name", 30);
@ -563,26 +563,6 @@ namespace pCampBot
MainConsole.Instance.Output(cdl.ToString()); MainConsole.Instance.Output(cdl.ToString());
} }
/*
private void HandleQuit(string module, string[] cmd)
{
m_console.Warn("DANGER", "This should only be used to quit the program if you've already used the shutdown command and the program hasn't quit");
Environment.Exit(0);
}
*/
//
// private void HandleAddBots(string module, string[] cmd)
// {
// int newbots = 0;
//
// if (cmd.Length > 2)
// {
// Int32.TryParse(cmd[2], out newbots);
// }
// if (newbots > 0)
// addbots(newbots);
// }
internal void Grid_GridRegion(object o, GridRegionEventArgs args) internal void Grid_GridRegion(object o, GridRegionEventArgs args)
{ {
lock (RegionsKnown) lock (RegionsKnown)
@ -602,4 +582,4 @@ namespace pCampBot
} }
} }
} }
} }