aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs250
1 files changed, 0 insertions, 250 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs
deleted file mode 100644
index eff70ef..0000000
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs
+++ /dev/null
@@ -1,250 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Collections.Generic;
29using OpenMetaverse;
30using OpenSim.Framework;
31using OpenSim.Region.Framework.Interfaces;
32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Region.OptionalModules.Scripting.Minimodule.WorldX;
34
35namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
36{
37 public class World : System.MarshalByRefObject, IWorld, IWorldAudio
38 {
39 private readonly Scene m_internalScene;
40 private readonly ISecurityCredential m_security;
41 private readonly Heightmap m_heights;
42
43 private readonly ObjectAccessor m_objs;
44
45 public World(Scene internalScene, ISecurityCredential securityCredential)
46 {
47 m_security = securityCredential;
48 m_internalScene = internalScene;
49 m_heights = new Heightmap(m_internalScene);
50 m_objs = new ObjectAccessor(m_internalScene, securityCredential);
51 }
52
53 #region Events
54
55 #region OnNewUser
56
57 private event OnNewUserDelegate _OnNewUser;
58 private bool _OnNewUserActive;
59
60 public event OnNewUserDelegate OnNewUser
61 {
62 add
63 {
64 if (!_OnNewUserActive)
65 {
66 _OnNewUserActive = true;
67 m_internalScene.EventManager.OnNewPresence += EventManager_OnNewPresence;
68 }
69
70 _OnNewUser += value;
71 }
72 remove
73 {
74 _OnNewUser -= value;
75
76 if (_OnNewUser == null)
77 {
78 _OnNewUserActive = false;
79 m_internalScene.EventManager.OnNewPresence -= EventManager_OnNewPresence;
80 }
81 }
82 }
83
84 void EventManager_OnNewPresence(ScenePresence presence)
85 {
86 if (_OnNewUser != null)
87 {
88 NewUserEventArgs e = new NewUserEventArgs();
89 e.Avatar = new SPAvatar(m_internalScene, presence.UUID, m_security);
90 _OnNewUser(this, e);
91 }
92 }
93
94 #endregion
95
96 #region OnChat
97 private event OnChatDelegate _OnChat;
98 private bool _OnChatActive;
99
100 public IWorldAudio Audio
101 {
102 get { return this; }
103 }
104
105 public event OnChatDelegate OnChat
106 {
107 add
108 {
109 if (!_OnChatActive)
110 {
111 _OnChatActive = true;
112 m_internalScene.EventManager.OnChatFromClient += EventManager_OnChatFromClient;
113 m_internalScene.EventManager.OnChatFromWorld += EventManager_OnChatFromWorld;
114 }
115
116 _OnChat += value;
117 }
118 remove
119 {
120 _OnChat -= value;
121
122 if (_OnChat == null)
123 {
124 _OnChatActive = false;
125 m_internalScene.EventManager.OnChatFromClient -= EventManager_OnChatFromClient;
126 m_internalScene.EventManager.OnChatFromWorld -= EventManager_OnChatFromWorld;
127 }
128 }
129 }
130
131 void EventManager_OnChatFromWorld(object sender, OSChatMessage chat)
132 {
133 if (_OnChat != null)
134 {
135 HandleChatPacket(chat);
136 return;
137 }
138 }
139
140 private void HandleChatPacket(OSChatMessage chat)
141 {
142 if (string.IsNullOrEmpty(chat.Message))
143 return;
144
145 // Object?
146 if (chat.Sender == null && chat.SenderObject != null)
147 {
148 ChatEventArgs e = new ChatEventArgs();
149 e.Sender = new SOPObject(m_internalScene, ((SceneObjectPart) chat.SenderObject).LocalId, m_security);
150 e.Text = chat.Message;
151 e.Channel = chat.Channel;
152
153 _OnChat(this, e);
154 return;
155 }
156 // Avatar?
157 if (chat.Sender != null && chat.SenderObject == null)
158 {
159 ChatEventArgs e = new ChatEventArgs();
160 e.Sender = new SPAvatar(m_internalScene, chat.SenderUUID, m_security);
161 e.Text = chat.Message;
162 e.Channel = chat.Channel;
163
164 _OnChat(this, e);
165 return;
166 }
167 // Skip if other
168 }
169
170 void EventManager_OnChatFromClient(object sender, OSChatMessage chat)
171 {
172 if (_OnChat != null)
173 {
174 HandleChatPacket(chat);
175 return;
176 }
177 }
178 #endregion
179
180 #endregion
181
182 public IObjectAccessor Objects
183 {
184 get { return m_objs; }
185 }
186
187 public IParcel[] Parcels
188 {
189 get
190 {
191 List<ILandObject> m_los = m_internalScene.LandChannel.AllParcels();
192 List<IParcel> m_parcels = new List<IParcel>(m_los.Count);
193
194 foreach (ILandObject landObject in m_los)
195 {
196 m_parcels.Add(new LOParcel(m_internalScene, landObject.LandData.LocalID));
197 }
198
199 return m_parcels.ToArray();
200 }
201 }
202
203
204 public IAvatar[] Avatars
205 {
206 get
207 {
208 EntityBase[] ents = m_internalScene.Entities.GetAllByType<ScenePresence>();
209 IAvatar[] rets = new IAvatar[ents.Length];
210
211 for (int i = 0; i < ents.Length; i++)
212 {
213 EntityBase ent = ents[i];
214 rets[i] = new SPAvatar(m_internalScene, ent.UUID, m_security);
215 }
216
217 return rets;
218 }
219 }
220
221 public IHeightmap Terrain
222 {
223 get { return m_heights; }
224 }
225
226 #region Implementation of IWorldAudio
227
228 public void PlaySound(UUID audio, Vector3 position, double volume)
229 {
230 ISoundModule soundModule = m_internalScene.RequestModuleInterface<ISoundModule>();
231 if (soundModule != null)
232 {
233 soundModule.TriggerSound(audio, UUID.Zero, UUID.Zero, UUID.Zero, volume, position,
234 m_internalScene.RegionInfo.RegionHandle);
235 }
236 }
237
238 public void PlaySound(UUID audio, Vector3 position)
239 {
240 ISoundModule soundModule = m_internalScene.RequestModuleInterface<ISoundModule>();
241 if (soundModule != null)
242 {
243 soundModule.TriggerSound(audio, UUID.Zero, UUID.Zero, UUID.Zero, 1.0, position,
244 m_internalScene.RegionInfo.RegionHandle);
245 }
246 }
247
248 #endregion
249 }
250}