Add "show status" command to pCambot
parent
40750b44a0
commit
8e2e4c47d9
|
@ -93,6 +93,11 @@ namespace pCampBot
|
||||||
"Shutdown bots and exit",
|
"Shutdown bots and exit",
|
||||||
HandleShutdown);
|
HandleShutdown);
|
||||||
|
|
||||||
|
m_console.Commands.AddCommand("bot", false, "show status",
|
||||||
|
"show status",
|
||||||
|
"Shows the status of all bots",
|
||||||
|
HandleShowStatus);
|
||||||
|
|
||||||
// m_console.Commands.AddCommand("bot", false, "add bots",
|
// m_console.Commands.AddCommand("bot", false, "add bots",
|
||||||
// "add bots <number>",
|
// "add bots <number>",
|
||||||
// "Add more bots", HandleAddBots);
|
// "Add more bots", HandleAddBots);
|
||||||
|
@ -157,7 +162,8 @@ namespace pCampBot
|
||||||
pb.OnConnected += handlebotEvent;
|
pb.OnConnected += handlebotEvent;
|
||||||
pb.OnDisconnected += handlebotEvent;
|
pb.OnDisconnected += handlebotEvent;
|
||||||
|
|
||||||
m_lBot.Add(pb);
|
lock (m_lBot)
|
||||||
|
m_lBot.Add(pb);
|
||||||
|
|
||||||
Thread pbThread = new Thread(pb.startup);
|
Thread pbThread = new Thread(pb.startup);
|
||||||
pbThread.Name = pb.Name;
|
pbThread.Name = pb.Name;
|
||||||
|
@ -194,10 +200,9 @@ namespace pCampBot
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void doBotShutdown()
|
public void doBotShutdown()
|
||||||
{
|
{
|
||||||
foreach (PhysicsBot pb in m_lBot)
|
lock (m_lBot)
|
||||||
{
|
foreach (PhysicsBot pb in m_lBot)
|
||||||
pb.shutdown();
|
pb.shutdown();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -215,6 +220,21 @@ namespace pCampBot
|
||||||
doBotShutdown();
|
doBotShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandleShowStatus(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
string outputFormat = "{0,-30} {1,-14}";
|
||||||
|
MainConsole.Instance.OutputFormat(outputFormat, "Name", "Status");
|
||||||
|
|
||||||
|
lock (m_lBot)
|
||||||
|
{
|
||||||
|
foreach (PhysicsBot pb in m_lBot)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.OutputFormat(
|
||||||
|
outputFormat, pb.Name, (pb.IsConnected ? "Connected" : "Disconnected"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
private void HandleQuit(string module, string[] cmd)
|
private void HandleQuit(string module, string[] cmd)
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,6 +51,11 @@ namespace pCampBot
|
||||||
public BotManager BotManager { get; private set; }
|
public BotManager BotManager { get; private set; }
|
||||||
private IConfig startupConfig; // bot config, passed from BotManager
|
private IConfig startupConfig; // bot config, passed from BotManager
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Is this bot connected to the grid?
|
||||||
|
/// </summary>
|
||||||
|
public bool IsConnected { get; private set; }
|
||||||
|
|
||||||
public string FirstName { get; private set; }
|
public string FirstName { get; private set; }
|
||||||
public string LastName { get; private set; }
|
public string LastName { get; private set; }
|
||||||
public string Name { get; private set; }
|
public string Name { get; private set; }
|
||||||
|
@ -181,24 +186,23 @@ namespace pCampBot
|
||||||
|
|
||||||
if (client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name"))
|
if (client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name"))
|
||||||
{
|
{
|
||||||
if (OnConnected != null)
|
IsConnected = true;
|
||||||
{
|
|
||||||
Thread.Sleep(somthing.Next(1000, 10000));
|
Thread.Sleep(somthing.Next(1000, 10000));
|
||||||
m_actionThread = new Thread(Action);
|
m_actionThread = new Thread(Action);
|
||||||
m_actionThread.Start();
|
m_actionThread.Start();
|
||||||
|
|
||||||
// OnConnected(this, EventType.CONNECTED);
|
// OnConnected(this, EventType.CONNECTED);
|
||||||
if (wear == "save")
|
if (wear == "save")
|
||||||
{
|
{
|
||||||
client.Appearance.SetPreviousAppearance();
|
client.Appearance.SetPreviousAppearance();
|
||||||
SaveDefaultAppearance();
|
SaveDefaultAppearance();
|
||||||
}
|
|
||||||
else if (wear != "no")
|
|
||||||
{
|
|
||||||
MakeDefaultAppearance(wear);
|
|
||||||
}
|
|
||||||
client.Self.Jump(true);
|
|
||||||
}
|
}
|
||||||
|
else if (wear != "no")
|
||||||
|
{
|
||||||
|
MakeDefaultAppearance(wear);
|
||||||
|
}
|
||||||
|
client.Self.Jump(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -392,8 +396,6 @@ namespace pCampBot
|
||||||
{
|
{
|
||||||
// m_log.ErrorFormat("Fired Network_OnDisconnected");
|
// m_log.ErrorFormat("Fired Network_OnDisconnected");
|
||||||
|
|
||||||
// Only pass on the disconnect message when we receive a SimShutdown type shutdown. We have to ignore
|
|
||||||
// the earlier ClientInitiated shutdown callback.
|
|
||||||
// if (
|
// if (
|
||||||
// (args.Reason == NetworkManager.DisconnectType.SimShutdown
|
// (args.Reason == NetworkManager.DisconnectType.SimShutdown
|
||||||
// || args.Reason == NetworkManager.DisconnectType.NetworkTimeout)
|
// || args.Reason == NetworkManager.DisconnectType.NetworkTimeout)
|
||||||
|
@ -406,6 +408,7 @@ namespace pCampBot
|
||||||
&& OnDisconnected != null)
|
&& OnDisconnected != null)
|
||||||
// if (OnDisconnected != null)
|
// if (OnDisconnected != null)
|
||||||
{
|
{
|
||||||
|
IsConnected = false;
|
||||||
OnDisconnected(this, EventType.DISCONNECTED);
|
OnDisconnected(this, EventType.DISCONNECTED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue