* Moves Name, GlobalID and WorldPosition into new IEntity interface.

* Avatar and Object now inherit from IEntity.
* Avatar.Position is now Avatar.WorldPosition to match IObject property.
* Implements event World.OnChat += delegate(IWorld sender, ChatEventArgs e);
0.6.5-rc1
Adam Frisby 2009-04-09 11:09:24 +00:00
parent 1b56fff7c8
commit b529750548
5 changed files with 98 additions and 22 deletions

View File

@ -32,10 +32,8 @@ using OpenMetaverse;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
public interface IAvatar public interface IAvatar : IEntity
{ {
string Name { get; }
UUID GlobalID { get; }
Vector3 Position { get; }
} }
} }

View File

@ -48,7 +48,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
public delegate void OnTouchDelegate(IObject sender, TouchEventArgs e); public delegate void OnTouchDelegate(IObject sender, TouchEventArgs e);
public interface IObject public interface IObject : IEntity
{ {
#region Events #region Events
@ -91,17 +91,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
/// </summary> /// </summary>
uint LocalID { get; } uint LocalID { get; }
/// <summary>
/// The global 'world-unique' ID for this object.
/// (Note, may not actually be world unique)
/// </summary>
UUID GlobalID { get; }
/// <summary>
/// The name of this Object.
/// </summary>
String Name { get; set; }
/// <summary> /// <summary>
/// The description assigned to this object. /// The description assigned to this object.
/// </summary> /// </summary>
@ -140,11 +129,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
/// </summary> /// </summary>
Quaternion OffsetRotation { get; set; } Quaternion OffsetRotation { get; set; }
/// <summary>
/// The position of the object relative to the Scene
/// </summary>
Vector3 WorldPosition { get; set; }
/// <summary> /// <summary>
/// The position of the object relative to a parent object /// The position of the object relative to a parent object
/// If root, works the same as WorldPosition /// If root, works the same as WorldPosition

View File

@ -25,13 +25,25 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
public class ChatEventArgs : EventArgs
{
public string Text;
public IEntity Sender;
}
public delegate void OnChatDelegate(IWorld sender, ChatEventArgs e);
public interface IWorld public interface IWorld
{ {
IObjectAccessor Objects { get; } IObjectAccessor Objects { get; }
IAvatar[] Avatars { get; } IAvatar[] Avatars { get; }
IParcel[] Parcels { get; } IParcel[] Parcels { get; }
IHeightmap Terrain { get; } IHeightmap Terrain { get; }
event OnChatDelegate OnChat;
} }
} }

View File

@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
@ -49,6 +50,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
public string Name public string Name
{ {
get { return GetSP().Name; } get { return GetSP().Name; }
set { throw new InvalidOperationException("Avatar Names are a read-only property."); }
} }
public UUID GlobalID public UUID GlobalID
@ -56,9 +58,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
get { return m_ID; } get { return m_ID; }
} }
public Vector3 Position public Vector3 WorldPosition
{ {
get { return GetSP().AbsolutePosition; } get { return GetSP().AbsolutePosition; }
set { GetSP().AbsolutePosition = value; }
} }
} }
} }

View File

@ -26,6 +26,7 @@
*/ */
using System.Collections.Generic; using System.Collections.Generic;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
@ -45,6 +46,84 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
m_objs = new ObjectAccessor(m_internalScene); m_objs = new ObjectAccessor(m_internalScene);
} }
#region Events
#region OnChat
private event OnChatDelegate _OnChat;
private bool _OnChatActive;
public event OnChatDelegate OnChat
{
add
{
if (!_OnChatActive)
{
_OnChatActive = true;
m_internalScene.EventManager.OnChatFromClient += EventManager_OnChatFromClient;
m_internalScene.EventManager.OnChatFromWorld += EventManager_OnChatFromWorld;
}
_OnChat += value;
}
remove
{
_OnChat -= value;
if (_OnChat == null)
{
_OnChatActive = false;
m_internalScene.EventManager.OnChatFromClient -= EventManager_OnChatFromClient;
m_internalScene.EventManager.OnChatFromWorld -= EventManager_OnChatFromWorld;
}
}
}
void EventManager_OnChatFromWorld(object sender, OpenSim.Framework.OSChatMessage chat)
{
if (_OnChat != null)
{
HandleChatPacket(chat);
return;
}
}
private void HandleChatPacket(OSChatMessage chat)
{
// Object?
if (chat.Sender == null && chat.SenderObject != null)
{
ChatEventArgs e = new ChatEventArgs();
e.Sender = new SOPObject(m_internalScene, ((SceneObjectPart) chat.SenderObject).LocalId);
e.Text = chat.Message;
_OnChat(this, e);
return;
}
// Avatar?
if (chat.SenderObject != null && chat.SenderObject == null)
{
ChatEventArgs e = new ChatEventArgs();
e.Sender = new SPAvatar(m_internalScene, chat.SenderUUID);
e.Text = chat.Message;
_OnChat(this, e);
return;
}
// Skip if other
}
void EventManager_OnChatFromClient(object sender, OpenSim.Framework.OSChatMessage chat)
{
if (_OnChat != null)
{
HandleChatPacket(chat);
return;
}
}
#endregion
#endregion
public IObjectAccessor Objects public IObjectAccessor Objects
{ {
get { return m_objs; } get { return m_objs; }