Moving examples, mapgenerator, and VisualParamGenerator to Programs folder (SVN is seriously ruined still, don't check out yet)

git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1961 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
John Hurliman
2008-07-22 23:21:49 +00:00
parent ef71c02528
commit f2dde3daae
153 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
using System;
using OpenMetaverse;
namespace OpenMetaverse.TestClient
{
public class CrouchCommand : Command
{
public CrouchCommand(TestClient testClient)
{
Name = "crouch";
Description = "Starts or stops crouching. Usage: crouch [start/stop]";
}
public override string Execute(string[] args, LLUUID fromAgentID)
{
bool start = true;
if (args.Length == 1 && args[0].ToLower() == "stop")
start = false;
if (start)
{
Client.Self.Crouch(true);
return "Started crouching";
}
else
{
Client.Self.Crouch(false);
return "Stopped crouching";
}
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using OpenMetaverse;
namespace OpenMetaverse.TestClient
{
public class FlyCommand : Command
{
public FlyCommand(TestClient testClient)
{
Name = "fly";
Description = "Starts or stops flying. Usage: fly [start/stop]";
}
public override string Execute(string[] args, LLUUID fromAgentID)
{
bool start = true;
if (args.Length == 1 && args[0].ToLower() == "stop")
start = false;
if (start)
{
Client.Self.Fly(true);
return "Started flying";
}
else
{
Client.Self.Fly(false);
return "Stopped flying";
}
}
}
}

View File

@@ -0,0 +1,156 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.TestClient
{
public class FollowCommand: Command
{
public FollowCommand(TestClient testClient)
{
Name = "follow";
Description = "Follow another avatar. (usage: follow [FirstName LastName]) If no target is set then will follow master.";
testClient.Network.RegisterCallback(PacketType.AlertMessage, new NetworkManager.PacketCallback(AlertMessageHandler));
}
public override string Execute(string[] args, LLUUID fromAgentID)
{
string target = String.Empty;
for (int ct = 0; ct < args.Length; ct++)
target = target + args[ct] + " ";
target = target.TrimEnd();
if (target.Length > 0)
{
if (Follow(target))
return "Following " + target;
else
return "Unable to follow " + target + ". Client may not be able to see that avatar.";
}
else
{
if (Follow(Client.MasterKey))
return "Following " + Client.MasterKey;
else
return "No target specified and no master not found. usage: follow [FirstName LastName])";
}
}
const float DISTANCE_BUFFER = 3.0f;
uint targetLocalID = 0;
bool Follow(string name)
{
lock (Client.Network.Simulators)
{
for (int i = 0; i < Client.Network.Simulators.Count; i++)
{
Avatar target = Client.Network.Simulators[i].ObjectsAvatars.Find(
delegate(Avatar avatar)
{
return avatar.Name == name;
}
);
if (target != null)
{
targetLocalID = target.LocalID;
Active = true;
return true;
}
}
}
Active = false;
return false;
}
bool Follow(LLUUID id)
{
lock (Client.Network.Simulators)
{
for (int i = 0; i < Client.Network.Simulators.Count; i++)
{
Avatar target = Client.Network.Simulators[i].ObjectsAvatars.Find(
delegate(Avatar avatar)
{
return avatar.ID == id;
}
);
if (target != null)
{
targetLocalID = target.LocalID;
Active = true;
return true;
}
}
}
Active = false;
return false;
}
public override void Think()
{
// Find the target position
lock (Client.Network.Simulators)
{
for (int i = 0; i < Client.Network.Simulators.Count; i++)
{
Avatar targetAv;
if (Client.Network.Simulators[i].ObjectsAvatars.TryGetValue(targetLocalID, out targetAv))
{
float distance = 0.0f;
if (Client.Network.Simulators[i] == Client.Network.CurrentSim)
{
distance = LLVector3.Dist(targetAv.Position, Client.Self.SimPosition);
}
else
{
// FIXME: Calculate global distances
}
if (distance > DISTANCE_BUFFER)
{
uint regionX, regionY;
Helpers.LongToUInts(Client.Network.Simulators[i].Handle, out regionX, out regionY);
double xTarget = (double)targetAv.Position.X + (double)regionX;
double yTarget = (double)targetAv.Position.Y + (double)regionY;
double zTarget = targetAv.Position.Z - 2f;
Logger.DebugLog(String.Format("[Autopilot] {0} meters away from the target, starting autopilot to <{1},{2},{3}>",
distance, xTarget, yTarget, zTarget), Client);
Client.Self.AutoPilot(xTarget, yTarget, zTarget);
}
else
{
// We are in range of the target and moving, stop moving
Client.Self.AutoPilotCancel();
}
}
}
}
base.Think();
}
private void AlertMessageHandler(Packet packet, Simulator simulator)
{
AlertMessagePacket alert = (AlertMessagePacket)packet;
string message = Helpers.FieldToUTF8String(alert.AlertData.Message);
if (message.Contains("Autopilot cancel"))
{
Logger.Log("Server cancelled the autopilot", Helpers.LogLevel.Info, Client);
}
}
}
}

View File

@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.TestClient
{
public class GotoCommand: Command
{
public GotoCommand(TestClient testClient)
{
Name = "goto";
Description = "Teleport to a location (e.g. \"goto Hooper/100/100/30\")";
}
public override string Execute(string[] args, LLUUID fromAgentID)
{
if (args.Length < 1)
return "Usage: goto sim/x/y/z";
string destination = String.Empty;
// Handle multi-word sim names by combining the arguments
foreach (string arg in args)
{
destination += arg + " ";
}
destination = destination.Trim();
string[] tokens = destination.Split(new char[] { '/' });
if (tokens.Length != 4)
return "Usage: goto sim/x/y/z";
string sim = tokens[0];
float x, y, z;
if (!float.TryParse(tokens[1], out x) ||
!float.TryParse(tokens[2], out y) ||
!float.TryParse(tokens[3], out z))
{
return "Usage: goto sim/x/y/z";
}
if (Client.Self.Teleport(sim, new LLVector3(x, y, z)))
return "Teleported to " + Client.Network.CurrentSim;
else
return "Teleport failed: " + Client.Self.TeleportMessage;
}
}
}

View File

@@ -0,0 +1,20 @@
using System;
using OpenMetaverse;
namespace OpenMetaverse.TestClient
{
public class JumpCommand: Command
{
public JumpCommand(TestClient testClient)
{
Name = "jump";
Description = "Jumps or flies up";
}
public override string Execute(string[] args, LLUUID fromAgentID)
{
Client.Self.Jump();
return "Jumped";
}
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.TestClient
{
public class LocationCommand: Command
{
public LocationCommand(TestClient testClient)
{
Name = "location";
Description = "Show the location.";
}
public override string Execute(string[] args, LLUUID fromAgentID)
{
return "CurrentSim: '" + Client.Network.CurrentSim.ToString() + "' Position: " +
Client.Self.SimPosition.ToString();
}
}
}

View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenMetaverse.TestClient.Commands.Movement
{
class MovetoCommand : Command
{
public MovetoCommand(TestClient client)
{
Name = "moveto";
Description = "Moves the avatar to the specified global position using simulator autopilot. Usage: moveto x y z";
}
public override string Execute(string[] args, LLUUID fromAgentID)
{
if (args.Length != 3)
return "Usage: moveto x y z";
uint regionX, regionY;
Helpers.LongToUInts(Client.Network.CurrentSim.Handle, out regionX, out regionY);
double x, y, z;
if (!Double.TryParse(args[0], out x) ||
!Double.TryParse(args[1], out y) ||
!Double.TryParse(args[2], out z))
{
return "Usage: moveto x y z";
}
// Convert the local coordinates to global ones by adding the region handle parts to x and y
x += (double)regionX;
y += (double)regionY;
Client.Self.AutoPilot(x, y, z);
return String.Format("Attempting to move to <{0},{1},{2}>", x, y, z);
}
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.TestClient
{
public class SetHomeCommand : Command
{
public SetHomeCommand(TestClient testClient)
{
Name = "sethome";
Description = "Sets home to the current location.";
}
public override string Execute(string[] args, LLUUID fromAgentID)
{
Client.Self.SetHome();
return "Home Set";
}
}
}

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.TestClient
{
public class SitCommand: Command
{
public SitCommand(TestClient testClient)
{
Name = "sit";
Description = "Attempt to sit on the closest prim";
}
public override string Execute(string[] args, LLUUID fromAgentID)
{
Primitive closest = null;
double closestDistance = Double.MaxValue;
Client.Network.CurrentSim.ObjectsPrimitives.ForEach(
delegate(Primitive prim)
{
float distance = LLVector3.Dist(Client.Self.SimPosition, prim.Position);
if (closest == null || distance < closestDistance)
{
closest = prim;
closestDistance = distance;
}
}
);
if (closest != null)
{
Client.Self.RequestSit(closest.ID, LLVector3.Zero);
Client.Self.Sit();
return "Sat on " + closest.ID + " (" + closest.LocalID + "). Distance: " + closestDistance;
}
else
{
return "Couldn't find a nearby prim to sit on";
}
}
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.TestClient
{
public class SitOnCommand : Command
{
public SitOnCommand(TestClient testClient)
{
Name = "siton";
Description = "Attempt to sit on a particular prim, with specified UUID";
}
public override string Execute(string[] args, LLUUID fromAgentID)
{
if (args.Length != 1)
return "Usage: siton UUID";
LLUUID target;
if (LLUUID.TryParse(args[0], out target))
{
Primitive targetPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find(
delegate(Primitive prim)
{
return prim.ID == target;
}
);
if (targetPrim != null)
{
Client.Self.RequestSit(targetPrim.ID, LLVector3.Zero);
Client.Self.Sit();
return "Requested to sit on prim " + targetPrim.ID.ToString() +
" (" + targetPrim.LocalID + ")";
}
}
return "Couldn't find a prim to sit on with UUID " + args[0];
}
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.TestClient
{
public class StandCommand: Command
{
public StandCommand(TestClient testClient)
{
Name = "stand";
Description = "Stand";
}
public override string Execute(string[] args, LLUUID fromAgentID)
{
Client.Self.Stand();
return "Standing up.";
}
}
}