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