aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim-Source/OpenSim.RegionServer/world/WorldBase.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim-Source/OpenSim.RegionServer/world/WorldBase.cs')
-rw-r--r--OpenSim-Source/OpenSim.RegionServer/world/WorldBase.cs176
1 files changed, 176 insertions, 0 deletions
diff --git a/OpenSim-Source/OpenSim.RegionServer/world/WorldBase.cs b/OpenSim-Source/OpenSim.RegionServer/world/WorldBase.cs
new file mode 100644
index 0000000..edc5518
--- /dev/null
+++ b/OpenSim-Source/OpenSim.RegionServer/world/WorldBase.cs
@@ -0,0 +1,176 @@
1using System;
2using libsecondlife;
3using libsecondlife.Packets;
4using System.Collections.Generic;
5using System.Text;
6using System.Reflection;
7using System.IO;
8using System.Threading;
9using OpenSim.Physics.Manager;
10using OpenSim.Framework.Interfaces;
11using OpenSim.Framework.Types;
12using OpenSim.Framework.Terrain;
13using OpenSim.Framework.Inventory;
14using OpenSim.Assets;
15using OpenSim.RegionServer.world.scripting;
16using OpenSim.Terrain;
17
18namespace OpenSim.world
19{
20 public class WorldBase
21 {
22 public Dictionary<libsecondlife.LLUUID, Entity> Entities;
23 protected Dictionary<uint, ClientView> m_clientThreads;
24 protected ulong m_regionHandle;
25 protected string m_regionName;
26 protected InventoryCache _inventoryCache;
27 protected AssetCache _assetCache;
28 protected RegionInfo m_regInfo;
29
30 public TerrainEngine Terrain; //TODO: Replace TerrainManager with this.
31 protected libsecondlife.TerrainManager TerrainManager; // To be referenced via TerrainEngine
32
33 #region Properties
34 public InventoryCache InventoryCache
35 {
36 set
37 {
38 this._inventoryCache = value;
39 }
40 }
41
42 public AssetCache AssetCache
43 {
44 set
45 {
46 this._assetCache = value;
47 }
48 }
49 #endregion
50
51 #region Constructors
52 public WorldBase()
53 {
54
55 }
56 #endregion
57
58 #region Setup Methods
59 /// <summary>
60 /// Register Packet handler Methods with the packet server (which will register them with the SimClient)
61 /// </summary>
62 /// <param name="packetServer"></param>
63 public virtual void RegisterPacketHandlers(PacketServer packetServer)
64 {
65
66 }
67 #endregion
68
69 #region Update Methods
70 /// <summary>
71 /// Normally called once every frame/tick to let the world preform anything required (like running the physics simulation)
72 /// </summary>
73 public virtual void Update()
74 {
75
76 }
77 #endregion
78
79 #region Terrain Methods
80
81 /// <summary>
82 /// Loads the World heightmap
83 /// </summary>
84 public virtual void LoadWorldMap()
85 {
86
87 }
88
89 /// <summary>
90 /// Send the region heightmap to the client
91 /// </summary>
92 /// <param name="RemoteClient">Client to send to</param>
93 public virtual void SendLayerData(ClientView RemoteClient)
94 {
95 try
96 {
97 int[] patches = new int[4];
98
99 for (int y = 0; y < 16; y++)
100 {
101 for (int x = 0; x < 16; x = x + 4)
102 {
103 patches[0] = x + 0 + y * 16;
104 patches[1] = x + 1 + y * 16;
105 patches[2] = x + 2 + y * 16;
106 patches[3] = x + 3 + y * 16;
107
108 Packet layerpack = TerrainManager.CreateLandPacket(Terrain.getHeights1D(), patches);
109 RemoteClient.OutPacket(layerpack);
110 }
111 }
112 }
113 catch (Exception e)
114 {
115 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: SendLayerData() - Failed with exception " + e.ToString());
116 }
117 }
118
119 /// <summary>
120 /// Sends a specified patch to a client
121 /// </summary>
122 /// <param name="px">Patch coordinate (x) 0..16</param>
123 /// <param name="py">Patch coordinate (y) 0..16</param>
124 /// <param name="RemoteClient">The client to send to</param>
125 public void SendLayerData(int px, int py, ClientView RemoteClient)
126 {
127 try
128 {
129 int[] patches = new int[1];
130 int patchx, patchy;
131 patchx = px / 16;
132 patchy = py / 16;
133
134 patches[0] = patchx + 0 + patchy * 16;
135
136 Packet layerpack = TerrainManager.CreateLandPacket(Terrain.getHeights1D(), patches);
137 RemoteClient.OutPacket(layerpack);
138 }
139 catch (Exception e)
140 {
141 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: SendLayerData() - Failed with exception " + e.ToString());
142 }
143 }
144 #endregion
145
146 #region Add/Remove Agent/Avatar
147 /// <summary>
148 /// Add a new Agent's avatar
149 /// </summary>
150 /// <param name="agentClient"></param>
151 public virtual void AddViewerAgent(ClientView agentClient)
152 {
153
154 }
155
156 /// <summary>
157 /// Remove a Agent's avatar
158 /// </summary>
159 /// <param name="agentClient"></param>
160 public virtual void RemoveViewerAgent(ClientView agentClient)
161 {
162
163 }
164 #endregion
165
166 #region Shutdown
167 /// <summary>
168 /// Tidy before shutdown
169 /// </summary>
170 public virtual void Close()
171 {
172
173 }
174 #endregion
175 }
176}