Files
libremetaverse/Programs/examples/TestClient/Commands/System/ShowEffectsCommand.cs
Jim Radford 0f8677cee9 LIBOMV-686 Implements new event patterns based on the Microsoft Framework Design Guidelines in AvatarManager
* BREAKING CHANGE * this is a major shift in the way events are internally handled.
* TODO: need to complete the EventArgs class documentation
* Adds new TestClient commands "play" to play animations, and bots to detect other bots.

git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@3163 52acb1d6-8a22-11de-b505-999d5b087335
2009-10-22 04:29:25 +00:00

76 lines
2.8 KiB
C#

using System;
using OpenMetaverse;
namespace OpenMetaverse.TestClient
{
public class ShowEffectsCommand : Command
{
bool ShowEffects = false;
public ShowEffectsCommand(TestClient testClient)
{
Name = "showeffects";
Description = "Prints out information for every viewer effect that is received. Usage: showeffects [on/off]";
Category = CommandCategory.Other;
testClient.Avatars.ViewerEffect += new EventHandler<ViewerEffectEventArgs>(Avatars_ViewerEffect);
testClient.Avatars.ViewerEffectPointAt += new EventHandler<ViewerEffectPointAtEventArgs>(Avatars_ViewerEffectPointAt);
testClient.Avatars.ViewerEffectLookAt += new EventHandler<ViewerEffectLookAtEventArgs>(Avatars_ViewerEffectLookAt);
}
void Avatars_ViewerEffectLookAt(object sender, ViewerEffectLookAtEventArgs e)
{
if (ShowEffects)
Console.WriteLine(
"ViewerEffect [LookAt]: SourceID: {0} TargetID: {1} TargetPos: {2} Type: {3} Duration: {4} ID: {5}",
e.SourceID.ToString(), e.TargetID.ToString(), e.TargetPosition, e.LookType, e.Duration,
e.EffectID.ToString());
}
void Avatars_ViewerEffectPointAt(object sender, ViewerEffectPointAtEventArgs e)
{
if (ShowEffects)
Console.WriteLine(
"ViewerEffect [PointAt]: SourceID: {0} TargetID: {1} TargetPos: {2} Type: {3} Duration: {4} ID: {5}",
e.SourceID.ToString(), e.TargetID.ToString(), e.TargetPosition, e.PointType, e.Duration,
e.EffectID.ToString());
}
void Avatars_ViewerEffect(object sender, ViewerEffectEventArgs e)
{
if (ShowEffects)
Console.WriteLine(
"ViewerEffect [{0}]: SourceID: {1} TargetID: {2} TargetPos: {3} Duration: {4} ID: {5}",
e.Type, e.SourceID.ToString(), e.TargetID.ToString(), e.TargetPosition, e.Duration,
e.EffectID.ToString());
}
public override string Execute(string[] args, UUID fromAgentID)
{
if (args.Length == 0)
{
ShowEffects = true;
return "Viewer effects will be shown on the console";
}
else if (args.Length == 1)
{
if (args[0] == "on")
{
ShowEffects = true;
return "Viewer effects will be shown on the console";
}
else
{
ShowEffects = false;
return "Viewer effects will not be shown";
}
}
else
{
return "Usage: showeffects [on/off]";
}
}
}
}