本文整理汇总了C#中CmdRequest.IsTrue方法的典型用法代码示例。如果您正苦于以下问题:C# CmdRequest.IsTrue方法的具体用法?C# CmdRequest.IsTrue怎么用?C# CmdRequest.IsTrue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CmdRequest
的用法示例。
在下文中一共展示了CmdRequest.IsTrue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteRequest
public override CmdResult ExecuteRequest(CmdRequest args)
{
bool moveInsteadOfCopy = args.IsTrue("--move");
if (!args.ContainsKey("items") || !args.ContainsKey("to"))
{
return ShowUsage();
}
int argsUsed;
List<SimObject> allTargets;
if (!args.TryGetValue("to", out allTargets))
{
return Failure("Cannot find avatar/objects 'to' give to");
}
Success("Going to give to " + allTargets.Count + " avatar/objects");
var man = Client.BotInventory;
var found = man.FindAll(args.GetProperty("items"), false,
inventoryName => Failure("No inventory item named " + inventoryName + " found."));
int given = 0;
foreach (var dest in allTargets)
{
foreach (InventoryBase item in found)
{
GiveAll(man, item, dest, moveInsteadOfCopy);
}
}
return SuccessOrFailure();
}
示例2: ExecuteRequest
public override CmdResult ExecuteRequest(CmdRequest args)
{
if (args.Length < 1)
return ShowUsage(); // " siton UUID";
int argsUsed;
SimPosition pos;
if (!args.TryGetValue("on", out pos))
{
sittingOnGround = WorldSystem.TheSimAvatar.SitOnGround();
return !sittingOnGround
? Failure("$bot did not yet sit on the ground.")
: Success("$bot sat on the ground.");
}
if (pos is SimObject)
{
if (WorldSystem.TheSimAvatar.SitOn(pos as SimObject)) Success("$bot sat on " + pos);
if (!args.IsTrue("down")) return Failure("$bot did not yet sit on " + pos);
}
else if (pos == null)
{
return Failure("$bot did not yet find " + args.str);
}
// @todo use autoppoiolot to the location andf then sit
TheSimAvatar.GotoTargetAStar(pos);
sittingOnGround = WorldSystem.TheSimAvatar.SitOnGround();
if (sittingOnGround) return Success("$bot sat at " + pos);
return Failure("$bot did not sit at " + pos);
}
示例3: ExecuteRequest
public override CmdResult ExecuteRequest(CmdRequest args)
{
AutoResetEvent appearanceEvent = new AutoResetEvent(false);
EventHandler<AppearanceSetEventArgs> callback = (s, e) => appearanceEvent.Set();
// Start the appearance setting process (with baking enabled or disabled)
bool bake = !args.IsTrue("nobake");
bool send = args.IsTrue("send");
bool wait = args.IsTrue("wait");
if (wait)
{
// Register a handler for the appearance event
Client.Appearance.AppearanceSet += callback;
}
if (send)
{
Client.Appearance.RequestSetAppearance();
}
else
{
Client.Appearance.RequestSetAppearance(bake);
}
if (wait)
{
bool success = false;
//// Wait for the process to complete or time out
if (appearanceEvent.WaitOne(1000*120, false))
success = true;
//// Unregister the handler
Client.Appearance.AppearanceSet -= callback;
//// Return success or failure message
if (!success) return Failure("Timed out while setting appearance");
}
return Success("Successfully set appearance bake=" + bake);
}
示例4: ExecuteRequest
public override CmdResult ExecuteRequest(CmdRequest args)
{
bool asLocal = args.IsTrue("--local");
SimPosition pos, pos2;
if (!args.TryGetValue("start", out pos)) pos = TheSimAvatar;
if (!args.TryGetValue("end", out pos2)) pos = TheSimAvatar;
Vector3d from, to;
if (pos2 == null)
{
pos2 = pos;
pos = TheSimAvatar;
}
from = pos.GlobalPosition;
to = pos2.GlobalPosition;
Vector3d offset = Vector3d.Zero;
if (asLocal)
{
offset = pos.PathStore.GlobalStart;
}
bool onlyStart, faked;
var path = SimPathStore.GetPath(null, from, to, 1, out onlyStart, out faked);
WriteLine("onlyStart=" + onlyStart);
WriteLine("faked=" + faked);
WriteLine("start=" + VectorRoundString(from - offset));
WriteLine("end=" + VectorRoundString(to - offset));
WriteLine("pstart=" + pos);
WriteLine("pend=" + pos2);
WriteLine("len=" + path.Count);
int step = 0;
foreach (Vector3d vector3D in path)
{
WriteLine("p" + step + "=" + VectorRoundString(vector3D - offset));
step++;
}
return Success("SUCCESS " + Name);
}
示例5: ExecuteRequest
public override CmdResult ExecuteRequest(CmdRequest args)
{
//base.acceptInput(verb, args);
BotClient Client = TheBotClient;
string onlyShow = "";
args.SetValue("--kill", true);
bool thread = args.IsTrue("--thread");
bool queue = args.IsTrue("--queue");
bool all = args.IsTrue("--all");
bool current = args.IsTrue("--current");
bool movement = args.IsTrue("--movement");
bool pointing = args.IsTrue("--pointing");
ThreadCommand.ExecuteRequestProc(args, this);
if (all)
{
current = true;
movement = true;
pointing = true;
}
if (current && TheSimAvatar.CurrentAction != null)
{
WriteLine("Killing " + TheSimAvatar.CurrentAction);
TheSimAvatar.CurrentAction = null;
IncrResult("killed", 1);
}
if (movement)
{
WriteLine("Killing movement");
WorldSystem.TheSimAvatar.StopMoving();
}
if (pointing)
{
Client.ExecuteCommand("pointat", args.CallerAgent, WriteLine, CMDFLAGS.Backgrounded);
}
return Success("Stopped " + base.ResultValue("killed"));
}
示例6: ExecuteRequest
public override CmdResult ExecuteRequest(CmdRequest args)
{
//AutoResetEvent are = new AutoResetEvent(false);
// AppearanceManager.AppearanceUpdatedCallback callback = (Primitive.TextureEntry te) => are.Set();
try
{
//Client.Appearance.OnAppearanceUpdated += callback;
// base.acceptInput(verb, args);
string target = String.Empty;
if (args.Length == 0) return ShowUsage();
bool bake = true;
string wear = args.str.Trim();
if (args.IsTrue("nobake"))
{
bake = false;
wear = wear.Substring(6).Trim();
}
if (args.IsTrue("test"))
{
bake = true;
wear = wear.Substring(4).Trim();
TheBotClient.wearFolder(wear);
// if (!are.WaitOne(WEARABLE_TIMEOUT * 2))
// return Success("Timeout wearing " + wear + " " + (bake ? " (baked)" : " (not baked)");
// else
return Success("wearing folder: " + wear + " " + (bake ? " (baked)" : " (not baked)"));
}
try
{
WriteLine("wearing folder: " + wear + " " + (bake ? " (baked)" : " (not baked)"));
if (false)
{
List<InventoryItem> outfit = Client.GetFolderItems(wear);
if (outfit != null)
{
Client.Appearance.ReplaceOutfit(outfit);
return Success(wear);
}
WriteLine("no folder found attaching item: " + wear);
}
string lwear = wear.ToLower();
BotInventoryEval searcher = new BotInventoryEval(Client);
InventoryFolder rootFolder = Client.Inventory.Store.RootFolder;
if (rootFolder.UUID == UUID.Zero) return Success("Cant get roiot folder yet");
bool found = searcher.findInFolders(rootFolder, (ib) =>
{
if (ib.Name.ToLower() == lwear)
{
if (ib is InventoryItem)
{
Client.Appearance.Attach(
ib as InventoryItem,
AttachmentPoint.Default);
return true;
}
else
{
var fldr = ib as InventoryFolder;
List<InventoryBase>
clientInventoryFolderContents =
Client.Inventory.
FolderContents(ib.UUID,
Client.
Self.
AgentID,
false,
true,
InventorySortOrder
.
ByName,
40000);
if (clientInventoryFolderContents ==
null)
return false;
List<InventoryItem> items =
new List<InventoryItem>();
foreach (
InventoryBase content in
clientInventoryFolderContents
)
{
var it =
content as InventoryItem;
if (it != null) items.Add(it);
}
if (items.Count > 0)
{
Client.Appearance.ReplaceOutfit(
items);
return true;
}
}
}
return false;
});
if (found) return Success("attaching " + wear);
return Failure("did not find " + wear);
// if (!are.WaitOne(WEARABLE_TIMEOUT * 2))
// return Success("Timeout wearing " + wear + " " + (bake ? " (baked)" : " (not baked)");
// else
//.........这里部分代码省略.........
示例7: ExecuteRequest
public override CmdResult ExecuteRequest(CmdRequest args)
{
bool kill = args.IsTrue("--kill");
bool createFresh;
string id = GetTaskID(args, out createFresh);
if (kill && createFresh)
{
return Failure("Cannot create and kill in the same operation");
}
int secondsOfSleep;
if (!args.TryGetValue("seconds", out secondsOfSleep))
{
return ShowUsage();
}
// remove the time
string[] cmdS;
args.TryGetValue("command", out cmdS);
string cmd = Parser.Rejoin(cmdS, 0);
ThreadStart thread = () =>
{
try
{
while (true)
{
try
{
Client.ExecuteCommand(cmd, args.CallerAgent, WriteLine,
args.CmdFlags);
}
catch (ThreadAbortException e)
{
WriteLine("Aborting " + cmd);
}
catch (Exception e)
{
WriteLine("Problem with " + cmd + " " + e);
return;
}
Thread.Sleep(secondsOfSleep*1000);
}
}
finally
{
try
{
TheBotClient.RemoveThread(Thread.CurrentThread);
}
catch (OutOfMemoryException)
{
}
catch (StackOverflowException)
{
}
catch (Exception)
{
}
WriteLine("done with " + cmd);
}
};
String threadName = "Repeating " + cmd;
string message = TheBotClient.CreateTask(id, thread, threadName, createFresh, kill, null, WriteLine);
SetResult("taskid", id);
return Success(message);
}
示例8: ExecuteRequestProc
public static CmdResult ExecuteRequestProc(CmdRequest args, Command thizcmd)
{
var TheBotClient = thizcmd.TheBotClient;
OutputDelegate WriteLine = thizcmd.WriteLine;
bool thread = args.IsTrue("--thread");
bool queue = args.IsTrue("--queue");
bool all = args.IsTrue("--all");
bool kill = args.IsTrue("--kill");
bool asyc = args.IsTrue("--async") || thread;
TimeSpan wait;
ManualResetEvent mre = null;
if (args.TryGetValue("--wait", out wait))
{
mre = new ManualResetEvent(false);
}
bool newDebug = args.IsTrue("--debug");
bool changeDebug = newDebug || args.IsTrue("--nodebug");
bool createFresh = false;
string id = args.Length == 0 ? "list" : GetTaskID(args, out createFresh);
id = (id == "list") ? "" : id;
int n = 0;
int found = 0;
if (id == "" || kill || changeDebug)
{
List<string> list = new List<string>();
lock (TaskQueueHandler.TaskQueueHandlers)
{
var atq = TheBotClient != null
? TheBotClient.AllTaskQueues()
: ClientManager.SingleInstance.AllTaskQueues();
foreach (var queueHandler in atq)
{
if (!queueHandler.MatchesId(id)) continue;
bool isQueue = queueHandler.Impl == queueHandler;
if (isQueue) found++;
else n++;
if (changeDebug) queueHandler.DebugQueue = newDebug;
if (queueHandler.IsAlive)
{
string str = queueHandler.ToDebugString(true);
if (kill)
{
if (!all)
{
if (!isQueue && !thread || isQueue && !queue)
{
WriteLine("Not killing " + str);
continue;
}
}
queueHandler.Abort();
str = "Killing " + str;
thizcmd.IncrResult("killed", 1);
}
WriteLine(str);
}
else
{
list.Add(queueHandler.ToDebugString(true));
}
}
}
foreach (var s in list)
{
WriteLine(s);
}
}
if (kill && createFresh)
{
return thizcmd.Failure("Cannot create and kill in the same operation");
}
string[] cmdS;
args.TryGetValue("command", out cmdS);
thizcmd.IncrResult("taskqueues", found);
thizcmd.IncrResult("threads", n);
if (cmdS == null || cmdS.Length == 0)
{
return thizcmd.Success("TaskQueueHandlers: " + found + ", threads: " + n);
}
/// task is killed if request.. now making a new one
string cmd = Parser.Rejoin(cmdS, 0);
bool needResult = mre != null;
CmdResult[] result = null;
if (createFresh) needResult = false;
if (needResult)
{
result = new CmdResult[1];
}
CMDFLAGS flags = needResult ? CMDFLAGS.ForceResult : CMDFLAGS.Inherit;
if (asyc) flags |= CMDFLAGS.ForceAsync;
ThreadStart task = () =>
{
try
{
var res = TheBotClient.ExecuteCommand(cmd, args.CallerAgent, args.Output,
//.........这里部分代码省略.........
示例9: ExecuteRequest
public override CmdResult ExecuteRequest(CmdRequest args)
{
bool detatchAll = args.IsTrue("--detatchall");
SimAvatar simAv;
if (args.TryGetValue("target", out simAv))
{
UUID target = simAv.ID;
string targetName = simAv.GetName();
targetName += String.Format(" ({0})", target);
if (Client.Appearances.ContainsKey(target))
{
#region AvatarAppearance to AgentSetAppearance
AvatarAppearancePacket appearance = TheBotClient.Appearances[target];
AgentSetAppearancePacket set = Client.Appearance.MakeAppearancePacket();
set.AgentData.AgentID = Client.Self.AgentID;
set.AgentData.SessionID = Client.Self.SessionID;
set.AgentData.SerialNum = SerialNum++;
set.AgentData.Size = new Vector3(2f, 2f, 2f); // HACK
set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[0];
set.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[appearance.VisualParam.Length];
for (int i = 0; i < appearance.VisualParam.Length; i++)
{
set.VisualParam[i] = new AgentSetAppearancePacket.VisualParamBlock();
set.VisualParam[i].ParamValue = appearance.VisualParam[i].ParamValue;
}
set.ObjectData.TextureEntry = appearance.ObjectData.TextureEntry;
#endregion AvatarAppearance to AgentSetAppearance
// Detach everything we are currently wearing
if (detatchAll) Client.Appearance.AddAttachments(new List<InventoryItem>(), true);
// Send the new appearance packet
Client.Network.SendPacket(set);
return Success("Cloned " + targetName);
}
else
{
/// allow clone thyself
if (Client.Self.AgentID == target)
{
AgentSetAppearancePacket set = Client.Appearance.MakeAppearancePacket();
Client.Network.SendPacket(set);
Logger.DebugLog("Send AgentSetAppearance packet");
return Success("Cloned " + targetName);
}
return Failure("Don't know the appearance of avatar " + targetName);
}
}
else
{
return Failure("Couldn't find avatar " + args.str);
}
}