aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Examples/SimpleApp/MyWorld.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Examples/SimpleApp/MyWorld.cs101
1 files changed, 101 insertions, 0 deletions
diff --git a/OpenSim/Examples/SimpleApp/MyWorld.cs b/OpenSim/Examples/SimpleApp/MyWorld.cs
new file mode 100644
index 0000000..27775f1
--- /dev/null
+++ b/OpenSim/Examples/SimpleApp/MyWorld.cs
@@ -0,0 +1,101 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Framework.Interfaces;
5using OpenSim.Framework.Types;
6using OpenSim.Framework.Console;
7using libsecondlife;
8
9namespace SimpleApp
10{
11 public class MyWorld : IWorld
12 {
13 private RegionInfo m_regionInfo;
14
15 public MyWorld(RegionInfo regionInfo)
16 {
17 m_regionInfo = regionInfo;
18 }
19
20 private void SendLayerData(IClientAPI remoteClient)
21 {
22 float[] map = new float[65536];
23
24 for (int i = 0; i < 65536; i++)
25 {
26 int x = i % 256;
27 int y = i / 256;
28
29 map[i] = (float)(x + y / 2);
30 }
31
32 remoteClient.SendLayerData(map);
33 }
34
35 #region IWorld Members
36
37 void IWorld.AddNewAvatar(IClientAPI client, LLUUID agentID, bool child)
38 {
39 LLVector3 pos = new LLVector3(128, 128, 128);
40
41 client.OnRegionHandShakeReply += SendLayerData;
42 client.OnChatFromViewer +=
43 delegate(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
44 {
45 // Echo it (so you know what you typed)
46 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
47 client.SendChatMessage("Ready.", 1, pos, "System", LLUUID.Zero );
48 };
49
50 client.OnRequestWearables += SendWearables;
51
52 client.OnCompleteMovementToRegion += delegate()
53 {
54 client.MoveAgentIntoRegion(m_regionInfo);
55 };
56
57 client.OnCompleteMovementToRegion += delegate()
58 {
59 client.SendAvatarData(m_regionInfo, client.FirstName,
60 client.LastName, client.AgentId, 0,
61 pos);
62
63 client.SendChatMessage("Welcome to My World.", 1, pos, "System", LLUUID.Zero );
64 };
65
66 client.SendRegionHandshake(m_regionInfo);
67
68 }
69
70 private void SendWearables( IClientAPI client )
71 {
72 client.SendWearables( AvatarWearable.DefaultWearables );
73 }
74
75 void IWorld.RemoveAvatar(LLUUID agentID)
76 {
77
78 }
79
80 RegionInfo IWorld.RegionInfo
81 {
82 get { return m_regionInfo; }
83 }
84
85 object IWorld.SyncRoot
86 {
87 get { return this; }
88 }
89
90 private uint m_nextLocalId = 1;
91
92 uint IWorld.NextLocalId
93 {
94 get { return m_nextLocalId++; }
95 }
96
97 #endregion
98
99
100 }
101}