aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/world/World.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/world/World.cs')
-rw-r--r--src/world/World.cs112
1 files changed, 0 insertions, 112 deletions
diff --git a/src/world/World.cs b/src/world/World.cs
deleted file mode 100644
index 158ddc2..0000000
--- a/src/world/World.cs
+++ /dev/null
@@ -1,112 +0,0 @@
1using System;
2using System.Threading;
3using System.Collections.Generic;
4using System.Text;
5using libsecondlife;
6using libsecondlife.Packets;
7
8namespace OpenSim.world
9{
10 public class World
11 {
12 public Dictionary<libsecondlife.LLUUID, Entity> Entities;
13 public float[] LandMap;
14 public ScriptEngine Scripts;
15 public uint _localNumber = 0;
16 public PhysicsEngine physics;
17
18 private libsecondlife.TerrainManager TerrainManager;
19 private Random Rand = new Random();
20
21 public World()
22 {
23 OpenSim_Main.localcons.WriteLine("World.cs - creating new entitities instance");
24 Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
25
26 OpenSim_Main.localcons.WriteLine("World.cs - creating LandMap");
27 TerrainManager = new TerrainManager(new SecondLife());
28 }
29
30 public void InitLoop()
31 {
32 OpenSim_Main.localcons.WriteLine("World.cs:StartLoop() - Initialising physics");
33 this.physics = new PhysicsEngine();
34 physics.Startup();
35 }
36
37 public void DoStuff()
38 {
39 lock (this)
40 {
41 physics.DoStuff(this);
42 this.Update();
43 }
44 }
45
46 public void Update()
47 {
48 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
49 {
50 if (Entities[UUID].needupdate)
51 {
52 Entities[UUID].update();
53
54 if (Entities[UUID] is Avatar)
55 {
56 Avatar avatar = (Avatar)Entities[UUID];
57 if ((avatar.oldpos != avatar.position) || (avatar.oldvel != avatar.velocity) || avatar.walking)
58 {
59 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = Entities[UUID].CreateTerseBlock();
60 foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values)
61 {
62 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
63 terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
64 terse.RegionData.TimeDilation = 0;
65 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
66 terse.ObjectData[0] = terseBlock;
67 client.OutPacket(terse);
68 }
69 }
70 }
71 }
72 }
73 }
74
75 public void SendLayerData(OpenSimClient RemoteClient)
76 {
77 int[] patches = new int[4];
78
79 for (int y = 0; y < 16; y++)
80 {
81 for (int x = 0; x < 16; x = x + 4)
82 {
83 patches[0] = x + 0 + y * 16;
84 patches[1] = x + 1 + y * 16;
85 patches[2] = x + 2 + y * 16;
86 patches[3] = x + 3 + y * 16;
87
88 Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches);
89 RemoteClient.OutPacket(layerpack);
90 }
91 }
92 }
93
94 public void AddViewerAgent(OpenSimClient AgentClient)
95 {
96 OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
97 Avatar NewAvatar = new Avatar(AgentClient);
98 OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world");
99 this.Entities.Add(AgentClient.AgentID, NewAvatar);
100 OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake ");
101 NewAvatar.SendRegionHandshake(this);
102 this.Update(); // will work for now, but needs to be optimised so we don't update everything in the sim for each new user
103 }
104
105 public bool Backup()
106 {
107 /* TODO: Save the current world entities state. */
108
109 return false;
110 }
111 }
112}