From 7eccad05c9623d9fe80c29d3e30a6511caf00531 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 1 Apr 2009 06:55:39 +0000 Subject: [PATCH] * 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 +- .../Scripting/Minimodule/IWorld.cs | 1 + .../Scripting/Minimodule/SPAvatar.cs | 37 +++++++++++++++++++ .../Scripting/Minimodule/Test/TestModule.cs | 17 +++++++++ .../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 diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs index e9793782a3..a500154b2c 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 63fdc749bc..bfa6b6576d 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 0000000000..6011e0bef2 --- /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 0000000000..abbef0b707 --- /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 cdefe16a6c..4ba6778931 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; }