From 98eda9ebdb168957725c0476abc12cca4dcccd88 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 9 Apr 2009 13:22:27 +0000 Subject: * 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) --- .../OptionalModules/Scripting/Minimodule/IWorld.cs | 8 ++++ .../OptionalModules/Scripting/Minimodule/World.cs | 43 +++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs index e7d9024..acb569f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs @@ -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; } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index 34f66d8..2280022 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -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) { -- cgit v1.1