* 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
parent
c91c24441b
commit
98eda9ebdb
|
@ -29,6 +29,13 @@ using System;
|
|||
|
||||
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 string Text;
|
||||
|
@ -45,5 +52,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
IHeightmap Terrain { get; }
|
||||
|
||||
event OnChatDelegate OnChat;
|
||||
event OnNewUserDelegate OnNewUser;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,47 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
|
||||
#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
|
||||
private event OnChatDelegate _OnChat;
|
||||
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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue