From 7eccad05c9623d9fe80c29d3e30a6511caf00531 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 1 Apr 2009 06:55:39 +0000 Subject: * Adds World.Avatars[] to MRM Scripting. Contains an enumerable array containing IAvatar instances for each avatar in the region. * Adds Test/TestModule.cs which demonstrates a very quick and simple MRM Test. --- .../Scripting/Minimodule/IAvatar.cs | 2 +- .../OptionalModules/Scripting/Minimodule/IWorld.cs | 1 + .../Scripting/Minimodule/SPAvatar.cs | 37 ++++++++++++++++++++++ .../Scripting/Minimodule/Test/TestModule.cs | 17 ++++++++++ .../OptionalModules/Scripting/Minimodule/World.cs | 17 ++++++++++ 5 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs (limited to 'OpenSim/Region/OptionalModules/Scripting') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs index e979378..a500154 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs @@ -32,7 +32,7 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - interface IAvatar + public interface IAvatar { string Name { get; } UUID GlobalID { get; } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs index 63fdc74..bfa6b65 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs @@ -34,6 +34,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public interface IWorld { IObject[] Objects { get; } + IAvatar[] Avatars { get; } IHeightmap Terrain { get; } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs new file mode 100644 index 0000000..6011e0b --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs @@ -0,0 +1,37 @@ +using OpenMetaverse; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class SPAvatar : IAvatar + { + private readonly Scene m_rootScene; + private readonly UUID m_ID; + + public SPAvatar(Scene scene, UUID ID) + { + m_rootScene = scene; + m_ID = ID; + } + + private ScenePresence GetSP() + { + return m_rootScene.GetScenePresence(m_ID); + } + + public string Name + { + get { return GetSP().Name; } + } + + public UUID GlobalID + { + get { return m_ID; } + } + + public Vector3 Position + { + get { return GetSP().AbsolutePosition; } + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs new file mode 100644 index 0000000..abbef0b --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs @@ -0,0 +1,17 @@ +using OpenSim.Region.OptionalModules.Scripting.Minimodule; + +namespace OpenSim +{ + class MiniModule : MRMBase + { + public override void Start() + { + Host.Console.Info("Hello World!"); + } + + public override void Stop() + { + + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index cdefe16..4ba6778 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -58,6 +58,23 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } } + public IAvatar[] Avatars + { + get + { + List ents = m_internalScene.Entities.GetAllByType(); + IAvatar[] rets = new IAvatar[ents.Count]; + + for (int i = 0; i < ents.Count; i++) + { + EntityBase ent = ents[i]; + rets[i] = new SPAvatar(m_internalScene, ent.UUID); + } + + return rets; + } + } + public IHeightmap Terrain { get { return m_heights; } -- cgit v1.1