diff options
author | Adam Frisby | 2009-04-09 11:09:24 +0000 |
---|---|---|
committer | Adam Frisby | 2009-04-09 11:09:24 +0000 |
commit | b529750548b74ae16c5b2e0f5393e2ef87626d50 (patch) | |
tree | 5307c3abb39a6c3766ebd73e6c831a95807a0e9f /OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs | |
parent | * Implements retrieving child primitives via World.Objects[id] (MRM) (diff) | |
download | opensim-SC-b529750548b74ae16c5b2e0f5393e2ef87626d50.zip opensim-SC-b529750548b74ae16c5b2e0f5393e2ef87626d50.tar.gz opensim-SC-b529750548b74ae16c5b2e0f5393e2ef87626d50.tar.bz2 opensim-SC-b529750548b74ae16c5b2e0f5393e2ef87626d50.tar.xz |
* 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);
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index 05a6a84..e3553bf 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using OpenSim.Framework; | ||
29 | using OpenSim.Region.Framework.Interfaces; | 30 | using OpenSim.Region.Framework.Interfaces; |
30 | using OpenSim.Region.Framework.Scenes; | 31 | using OpenSim.Region.Framework.Scenes; |
31 | 32 | ||
@@ -45,6 +46,84 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
45 | m_objs = new ObjectAccessor(m_internalScene); | 46 | m_objs = new ObjectAccessor(m_internalScene); |
46 | } | 47 | } |
47 | 48 | ||
49 | #region Events | ||
50 | |||
51 | #region OnChat | ||
52 | private event OnChatDelegate _OnChat; | ||
53 | private bool _OnChatActive; | ||
54 | |||
55 | public event OnChatDelegate OnChat | ||
56 | { | ||
57 | add | ||
58 | { | ||
59 | if (!_OnChatActive) | ||
60 | { | ||
61 | _OnChatActive = true; | ||
62 | m_internalScene.EventManager.OnChatFromClient += EventManager_OnChatFromClient; | ||
63 | m_internalScene.EventManager.OnChatFromWorld += EventManager_OnChatFromWorld; | ||
64 | } | ||
65 | |||
66 | _OnChat += value; | ||
67 | } | ||
68 | remove | ||
69 | { | ||
70 | _OnChat -= value; | ||
71 | |||
72 | if (_OnChat == null) | ||
73 | { | ||
74 | _OnChatActive = false; | ||
75 | m_internalScene.EventManager.OnChatFromClient -= EventManager_OnChatFromClient; | ||
76 | m_internalScene.EventManager.OnChatFromWorld -= EventManager_OnChatFromWorld; | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | |||
81 | void EventManager_OnChatFromWorld(object sender, OpenSim.Framework.OSChatMessage chat) | ||
82 | { | ||
83 | if (_OnChat != null) | ||
84 | { | ||
85 | HandleChatPacket(chat); | ||
86 | return; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | private void HandleChatPacket(OSChatMessage chat) | ||
91 | { | ||
92 | // Object? | ||
93 | if (chat.Sender == null && chat.SenderObject != null) | ||
94 | { | ||
95 | ChatEventArgs e = new ChatEventArgs(); | ||
96 | e.Sender = new SOPObject(m_internalScene, ((SceneObjectPart) chat.SenderObject).LocalId); | ||
97 | e.Text = chat.Message; | ||
98 | |||
99 | _OnChat(this, e); | ||
100 | return; | ||
101 | } | ||
102 | // Avatar? | ||
103 | if (chat.SenderObject != null && chat.SenderObject == null) | ||
104 | { | ||
105 | ChatEventArgs e = new ChatEventArgs(); | ||
106 | e.Sender = new SPAvatar(m_internalScene, chat.SenderUUID); | ||
107 | e.Text = chat.Message; | ||
108 | |||
109 | _OnChat(this, e); | ||
110 | return; | ||
111 | } | ||
112 | // Skip if other | ||
113 | } | ||
114 | |||
115 | void EventManager_OnChatFromClient(object sender, OpenSim.Framework.OSChatMessage chat) | ||
116 | { | ||
117 | if (_OnChat != null) | ||
118 | { | ||
119 | HandleChatPacket(chat); | ||
120 | return; | ||
121 | } | ||
122 | } | ||
123 | #endregion | ||
124 | |||
125 | #endregion | ||
126 | |||
48 | public IObjectAccessor Objects | 127 | public IObjectAccessor Objects |
49 | { | 128 | { |
50 | get { return m_objs; } | 129 | get { return m_objs; } |