aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/SceneBase.cs
diff options
context:
space:
mode:
authorAdam Frisby2007-07-11 08:10:25 +0000
committerAdam Frisby2007-07-11 08:10:25 +0000
commite2ff441e31328e60c8bb1d4bb32fa4ac64f91978 (patch)
tree8405b6cef57b66a58f31a24c859846085d0b81f7 /OpenSim/Region/Environment/Scenes/SceneBase.cs
parent* Wiping trunk in prep for Sugilite (diff)
parent* Applying dalien's patches from bug#177 and #179 (diff)
downloadopensim-SC-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.zip
opensim-SC-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.tar.gz
opensim-SC-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.tar.bz2
opensim-SC-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.tar.xz
* Bringing Sugilite in to trunk
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/SceneBase.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneBase.cs198
1 files changed, 198 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs
new file mode 100644
index 0000000..811f54c
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs
@@ -0,0 +1,198 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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;
29using System.Collections.Generic;
30using System.Reflection;
31using libsecondlife;
32using OpenSim.Framework.Console;
33using OpenSim.Framework.Interfaces;
34using OpenSim.Framework.Types;
35using OpenSim.Region.Caches;
36using OpenSim.Region.Terrain;
37using OpenSim.Framework;
38
39namespace OpenSim.Region.Environment.Scenes
40{
41 public abstract class SceneBase : IWorld
42 {
43 public Dictionary<LLUUID, EntityBase> Entities;
44 protected ClientManager m_clientManager;
45 protected ulong m_regionHandle;
46 protected string m_regionName;
47 protected RegionInfo m_regInfo;
48
49 public TerrainEngine Terrain;
50
51 public string m_datastore;
52 public ILocalStorage localStorage;
53
54 protected object m_syncRoot = new object();
55 private uint m_nextLocalId = 8880000;
56 protected AssetCache assetCache;
57
58 #region Update Methods
59 /// <summary>
60 /// Normally called once every frame/tick to let the world preform anything required (like running the physics simulation)
61 /// </summary>
62 public abstract void Update();
63
64 #endregion
65
66 #region Terrain Methods
67
68 /// <summary>
69 /// Loads the World heightmap
70 /// </summary>
71 public abstract void LoadWorldMap();
72
73 /// <summary>
74 /// Loads a new storage subsystem from a named library
75 /// </summary>
76 /// <param name="dllName">Storage Library</param>
77 /// <returns>Successful or not</returns>
78 public bool LoadStorageDLL(string dllName)
79 {
80 try
81 {
82 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
83 ILocalStorage store = null;
84
85 foreach (Type pluginType in pluginAssembly.GetTypes())
86 {
87 if (pluginType.IsPublic)
88 {
89 if (!pluginType.IsAbstract)
90 {
91 Type typeInterface = pluginType.GetInterface("ILocalStorage", true);
92
93 if (typeInterface != null)
94 {
95 ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
96 store = plug;
97
98 store.Initialise(this.m_datastore);
99 break;
100 }
101
102 typeInterface = null;
103 }
104 }
105 }
106 pluginAssembly = null;
107 this.localStorage = store;
108 return (store == null);
109 }
110 catch (Exception e)
111 {
112 MainLog.Instance.Warn("World.cs: LoadStorageDLL() - Failed with exception " + e.ToString());
113 return false;
114 }
115 }
116
117
118 /// <summary>
119 /// Send the region heightmap to the client
120 /// </summary>
121 /// <param name="RemoteClient">Client to send to</param>
122 public virtual void SendLayerData(IClientAPI RemoteClient)
123 {
124 RemoteClient.SendLayerData(Terrain.getHeights1D());
125 }
126
127 /// <summary>
128 /// Sends a specified patch to a client
129 /// </summary>
130 /// <param name="px">Patch coordinate (x) 0..16</param>
131 /// <param name="py">Patch coordinate (y) 0..16</param>
132 /// <param name="RemoteClient">The client to send to</param>
133 public virtual void SendLayerData(int px, int py, IClientAPI RemoteClient)
134 {
135 RemoteClient.SendLayerData(px, py, Terrain.getHeights1D());
136 }
137
138 #endregion
139
140 #region Add/Remove Agent/Avatar
141 /// <summary>
142 ///
143 /// </summary>
144 /// <param name="remoteClient"></param>
145 /// <param name="agentID"></param>
146 /// <param name="child"></param>
147 public abstract void AddNewClient(IClientAPI client, bool child);
148
149 public abstract uint AddNewPrim(LLUUID ownerId, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID texture, int flags);
150
151 /// <summary>
152 ///
153 /// </summary>
154 /// <param name="agentID"></param>
155 public abstract void RemoveClient(LLUUID agentID);
156
157 #endregion
158
159 /// <summary>
160 ///
161 /// </summary>
162 /// <returns></returns>
163 public virtual RegionInfo RegionInfo
164 {
165 get { return this.m_regInfo; }
166 }
167
168 public object SyncRoot
169 {
170 get { return m_syncRoot; }
171 }
172
173 public uint NextLocalId
174 {
175 get { return m_nextLocalId++; }
176 }
177
178 #region Shutdown
179 /// <summary>
180 /// Tidy before shutdown
181 /// </summary>
182 public virtual void Close()
183 {
184 try
185 {
186 this.localStorage.ShutDown();
187 }
188 catch (Exception e)
189 {
190 MainLog.Instance.WriteLine(LogPriority.HIGH, "World.cs: Close() - Failed with exception " + e.ToString());
191 }
192 }
193
194 #endregion
195
196
197 }
198}