* 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
parent
1b56fff7c8
commit
b529750548
|
@ -32,10 +32,8 @@ using OpenMetaverse;
|
|||
|
||||
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
||||
{
|
||||
public interface IAvatar
|
||||
public interface IAvatar : IEntity
|
||||
{
|
||||
string Name { get; }
|
||||
UUID GlobalID { get; }
|
||||
Vector3 Position { get; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
|
||||
public delegate void OnTouchDelegate(IObject sender, TouchEventArgs e);
|
||||
|
||||
public interface IObject
|
||||
public interface IObject : IEntity
|
||||
{
|
||||
#region Events
|
||||
|
||||
|
@ -91,17 +91,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
/// </summary>
|
||||
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>
|
||||
/// The description assigned to this object.
|
||||
/// </summary>
|
||||
|
@ -140,11 +129,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
/// </summary>
|
||||
Quaternion OffsetRotation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The position of the object relative to the Scene
|
||||
/// </summary>
|
||||
Vector3 WorldPosition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The position of the object relative to a parent object
|
||||
/// If root, works the same as WorldPosition
|
||||
|
|
|
@ -25,13 +25,25 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
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
|
||||
{
|
||||
IObjectAccessor Objects { get; }
|
||||
IAvatar[] Avatars { get; }
|
||||
IParcel[] Parcels { get; }
|
||||
IHeightmap Terrain { get; }
|
||||
|
||||
event OnChatDelegate OnChat;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
|
@ -49,6 +50,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
public string Name
|
||||
{
|
||||
get { return GetSP().Name; }
|
||||
set { throw new InvalidOperationException("Avatar Names are a read-only property."); }
|
||||
}
|
||||
|
||||
public UUID GlobalID
|
||||
|
@ -56,9 +58,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
get { return m_ID; }
|
||||
}
|
||||
|
||||
public Vector3 Position
|
||||
public Vector3 WorldPosition
|
||||
{
|
||||
get { return GetSP().AbsolutePosition; }
|
||||
set { GetSP().AbsolutePosition = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
|
@ -45,6 +46,84 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
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
|
||||
{
|
||||
get { return m_objs; }
|
||||
|
|
Loading…
Reference in New Issue