diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Examples/SimpleApp/MyWorld.cs | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs new file mode 100644 index 0000000..3c69420 --- /dev/null +++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs | |||
@@ -0,0 +1,93 @@ | |||
1 | using System.Collections.Generic; | ||
2 | using libsecondlife; | ||
3 | using OpenSim.Framework; | ||
4 | using OpenSim.Framework.Communications; | ||
5 | using OpenSim.Framework.Interfaces; | ||
6 | using OpenSim.Framework.Servers; | ||
7 | using OpenSim.Framework.Types; | ||
8 | using OpenSim.Region.Caches; | ||
9 | using OpenSim.Region.Environment.Scenes; | ||
10 | using Avatar=OpenSim.Region.Environment.Scenes.ScenePresence; | ||
11 | |||
12 | namespace SimpleApp | ||
13 | { | ||
14 | public class MyWorld : Scene | ||
15 | { | ||
16 | private List<ScenePresence> m_avatars; | ||
17 | |||
18 | public MyWorld(ClientManager clientManager, RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer) | ||
19 | : base(clientManager, regionInfo, authen, commsMan, assetCach, httpServer) | ||
20 | { | ||
21 | m_avatars = new List<Avatar>(); | ||
22 | } | ||
23 | |||
24 | public override void SendLayerData(IClientAPI remoteClient) | ||
25 | { | ||
26 | float[] map = new float[65536]; | ||
27 | |||
28 | for (int i = 0; i < 65536; i++) | ||
29 | { | ||
30 | int x = i % 256; | ||
31 | int y = i / 256; | ||
32 | |||
33 | map[i] = (float)(x + y / 2); | ||
34 | } | ||
35 | |||
36 | remoteClient.SendLayerData(map); | ||
37 | } | ||
38 | |||
39 | #region IWorld Members | ||
40 | |||
41 | override public void AddNewClient(IClientAPI client, bool child) | ||
42 | |||
43 | { | ||
44 | LLVector3 pos = new LLVector3(128, 128, 128); | ||
45 | |||
46 | client.OnRegionHandShakeReply += SendLayerData; | ||
47 | client.OnChatFromViewer += | ||
48 | delegate(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) | ||
49 | { | ||
50 | // Echo it (so you know what you typed) | ||
51 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | ||
52 | client.SendChatMessage("Ready.", 1, pos, "System", LLUUID.Zero ); | ||
53 | }; | ||
54 | |||
55 | client.OnRequestWearables += SendWearables; | ||
56 | client.OnAddPrim += AddNewPrim; | ||
57 | client.OnUpdatePrimGroupPosition += this.UpdatePrimPosition; | ||
58 | client.OnRequestMapBlocks += this.RequestMapBlocks; | ||
59 | client.OnTeleportLocationRequest += this.RequestTeleportLocation; | ||
60 | client.OnGrapUpdate += this.MoveObject; | ||
61 | client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest; | ||
62 | |||
63 | client.OnCompleteMovementToRegion += delegate() | ||
64 | { | ||
65 | client.MoveAgentIntoRegion(m_regInfo, pos, LLVector3.Zero ); | ||
66 | }; | ||
67 | |||
68 | client.OnCompleteMovementToRegion += delegate() | ||
69 | { | ||
70 | client.SendAvatarData(m_regInfo.RegionHandle, client.FirstName, | ||
71 | client.LastName, client.AgentId, 0, | ||
72 | pos, null); | ||
73 | |||
74 | client.SendChatMessage("Welcome to My World.", 1, pos, "System", LLUUID.Zero ); | ||
75 | |||
76 | |||
77 | |||
78 | }; | ||
79 | |||
80 | client.SendRegionHandshake(m_regInfo); | ||
81 | |||
82 | CreateAndAddScenePresence(client); | ||
83 | |||
84 | } | ||
85 | |||
86 | private void SendWearables( IClientAPI client ) | ||
87 | { | ||
88 | client.SendWearables( AvatarWearable.DefaultWearables ); | ||
89 | } | ||
90 | |||
91 | #endregion | ||
92 | } | ||
93 | } | ||