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