* Adds World.OnNewUser += delegate(IWorld sender, NewUserEventArgs e);

* This event fires when a new avatar is created within the Scene. (Internally corresponds to EventManager.OnNewPresence)
0.6.5-rc1
Adam Frisby 2009-04-09 13:22:27 +00:00
parent c91c24441b
commit 98eda9ebdb
2 changed files with 50 additions and 1 deletions

View File

@ -29,6 +29,13 @@ using System;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
public class NewUserEventArgs : EventArgs
{
public IAvatar Avatar;
}
public delegate void OnNewUserDelegate(IWorld sender, NewUserEventArgs e);
public class ChatEventArgs : EventArgs public class ChatEventArgs : EventArgs
{ {
public string Text; public string Text;
@ -45,5 +52,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
IHeightmap Terrain { get; } IHeightmap Terrain { get; }
event OnChatDelegate OnChat; event OnChatDelegate OnChat;
event OnNewUserDelegate OnNewUser;
} }
} }

View File

@ -51,6 +51,47 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
#region Events #region Events
#region OnNewUser
private event OnNewUserDelegate _OnNewUser;
private bool _OnNewUserActive;
public event OnNewUserDelegate OnNewUser
{
add
{
if (!_OnNewUserActive)
{
_OnNewUserActive = true;
m_internalScene.EventManager.OnNewPresence += EventManager_OnNewPresence;
}
_OnNewUser += value;
}
remove
{
_OnNewUser -= value;
if (_OnNewUser == null)
{
_OnNewUserActive = false;
m_internalScene.EventManager.OnNewPresence -= EventManager_OnNewPresence;
}
}
}
void EventManager_OnNewPresence(ScenePresence presence)
{
if (_OnNewUser != null)
{
NewUserEventArgs e = new NewUserEventArgs();
e.Avatar = new SPAvatar(m_internalScene, presence.UUID);
_OnNewUser(this, e);
}
}
#endregion
#region OnChat #region OnChat
private event OnChatDelegate _OnChat; private event OnChatDelegate _OnChat;
private bool _OnChatActive; private bool _OnChatActive;
@ -81,7 +122,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
} }
} }
void EventManager_OnChatFromWorld(object sender, OpenSim.Framework.OSChatMessage chat) void EventManager_OnChatFromWorld(object sender, OSChatMessage chat)
{ {
if (_OnChat != null) if (_OnChat != null)
{ {