diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs | 174 | ||||
-rw-r--r-- | OpenSim/Region/Examples/SimpleApp/MyWorld.cs | 27 | ||||
-rw-r--r-- | OpenSim/Region/Examples/SimpleApp/Program.cs | 25 |
3 files changed, 217 insertions, 9 deletions
diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs new file mode 100644 index 0000000..1c267c6 --- /dev/null +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs | |||
@@ -0,0 +1,174 @@ | |||
1 | using System.Collections.Generic; | ||
2 | using System.Net; | ||
3 | using System.Timers; | ||
4 | using System; | ||
5 | using System.Text; | ||
6 | |||
7 | using libsecondlife; | ||
8 | using libsecondlife.Packets; | ||
9 | |||
10 | using OpenSim.Framework; | ||
11 | using OpenSim.Framework.Interfaces; | ||
12 | using OpenSim.Framework.Types; | ||
13 | using OpenSim.Framework.Data; | ||
14 | using OpenSim.Framework.Utilities; | ||
15 | |||
16 | namespace SimpleApp | ||
17 | { | ||
18 | public class MyNpcCharacter : IClientAPI | ||
19 | { | ||
20 | private uint movementDirection = 0; | ||
21 | private bool fly = true; | ||
22 | private LLQuaternion bodyDirection = LLQuaternion.Identity; | ||
23 | |||
24 | public event ImprovedInstantMessage OnInstantMessage; | ||
25 | public event ChatFromViewer OnChatFromViewer; | ||
26 | public event RezObject OnRezObject; | ||
27 | public event ModifyTerrain OnModifyTerrain; | ||
28 | public event SetAppearance OnSetAppearance; | ||
29 | public event StartAnim OnStartAnim; | ||
30 | public event LinkObjects OnLinkObjects; | ||
31 | public event RequestMapBlocks OnRequestMapBlocks; | ||
32 | public event TeleportLocationRequest OnTeleportLocationRequest; | ||
33 | |||
34 | public event GenericCall4 OnDeRezObject; | ||
35 | public event GenericCall OnRegionHandShakeReply; | ||
36 | public event GenericCall OnRequestWearables; | ||
37 | public event GenericCall2 OnCompleteMovementToRegion; | ||
38 | public event UpdateAgent OnAgentUpdate; | ||
39 | public event GenericCall OnRequestAvatarsData; | ||
40 | public event AddNewPrim OnAddPrim; | ||
41 | public event ObjectDuplicate OnObjectDuplicate; | ||
42 | public event UpdateVector OnGrapObject; | ||
43 | public event ObjectSelect OnDeGrapObject; | ||
44 | public event MoveObject OnGrapUpdate; | ||
45 | |||
46 | public event UpdateShape OnUpdatePrimShape; | ||
47 | public event ObjectSelect OnObjectSelect; | ||
48 | public event GenericCall7 OnObjectDescription; | ||
49 | public event GenericCall7 OnObjectName; | ||
50 | public event UpdatePrimFlags OnUpdatePrimFlags; | ||
51 | public event UpdatePrimTexture OnUpdatePrimTexture; | ||
52 | public event UpdateVector OnUpdatePrimGroupPosition; | ||
53 | public event UpdateVector OnUpdatePrimSinglePosition; | ||
54 | public event UpdatePrimRotation OnUpdatePrimGroupRotation; | ||
55 | public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; | ||
56 | public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation; | ||
57 | public event UpdateVector OnUpdatePrimScale; | ||
58 | public event StatusChange OnChildAgentStatus; | ||
59 | public event GenericCall2 OnStopMovement; | ||
60 | public event NewAvatar OnNewAvatar; | ||
61 | public event GenericCall6 OnRemoveAvatar; | ||
62 | |||
63 | public event UUIDNameRequest OnNameFromUUIDRequest; | ||
64 | |||
65 | public event ParcelPropertiesRequest OnParcelPropertiesRequest; | ||
66 | public event ParcelDivideRequest OnParcelDivideRequest; | ||
67 | public event ParcelJoinRequest OnParcelJoinRequest; | ||
68 | public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; | ||
69 | |||
70 | public event ParcelSelectObjects OnParcelSelectObjects; | ||
71 | |||
72 | public event EstateOwnerMessageRequest OnEstateOwnerMessage; | ||
73 | |||
74 | private LLUUID myID = LLUUID.Random(); | ||
75 | public MyNpcCharacter() | ||
76 | { | ||
77 | |||
78 | } | ||
79 | |||
80 | public virtual LLVector3 StartPos | ||
81 | { | ||
82 | get { return new LLVector3(128, 100, 2); } | ||
83 | set { } | ||
84 | } | ||
85 | |||
86 | public virtual LLUUID AgentId | ||
87 | { | ||
88 | get { return myID; } | ||
89 | } | ||
90 | |||
91 | public virtual string FirstName | ||
92 | { | ||
93 | get { return "Annoying"; } | ||
94 | } | ||
95 | |||
96 | public virtual string LastName | ||
97 | { | ||
98 | get { return "NPC"; } | ||
99 | } | ||
100 | |||
101 | public virtual void OutPacket(Packet newPack) { } | ||
102 | public virtual void SendWearables(AvatarWearable[] wearables) { } | ||
103 | public virtual void SendStartPingCheck(byte seq) { } | ||
104 | public virtual void SendKillObject(ulong regionHandle, uint avatarLocalID) { } | ||
105 | public virtual void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId) { } | ||
106 | public virtual void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { } | ||
107 | public virtual void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { } | ||
108 | public virtual void SendInstantMessage(string message, LLUUID target, string fromName) { } | ||
109 | public virtual void SendLayerData(float[] map) { } | ||
110 | public virtual void SendLayerData(int px, int py, float[] map) { } | ||
111 | public virtual void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look) { } | ||
112 | public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) { } | ||
113 | public virtual AgentCircuitData RequestClientInfo() { return new AgentCircuitData(); } | ||
114 | public virtual void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint newRegionExternalEndPoint) { } | ||
115 | public virtual void SendMapBlock(List<MapBlockData> mapBlocks) { } | ||
116 | public virtual void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags) { } | ||
117 | public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags) { } | ||
118 | public virtual void SendTeleportCancel() { } | ||
119 | public virtual void SendTeleportLocationStart() { } | ||
120 | public virtual void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance) { } | ||
121 | |||
122 | public virtual void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry) { } | ||
123 | public virtual void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity) { } | ||
124 | |||
125 | public virtual void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint) { } | ||
126 | public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags) { } | ||
127 | public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID, uint flags) { } | ||
128 | public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) { } | ||
129 | public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) { } | ||
130 | public virtual void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation) { } | ||
131 | |||
132 | public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items) { } | ||
133 | public virtual void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item) { } | ||
134 | public virtual void SendNameReply(LLUUID profileId, string firstname, string lastname) { } | ||
135 | |||
136 | public virtual void SendRegionHandshake(RegionInfo regionInfo) | ||
137 | { | ||
138 | this.OnRegionHandShakeReply(this); | ||
139 | this.OnCompleteMovementToRegion(); | ||
140 | this.StartMovement(); | ||
141 | } | ||
142 | |||
143 | public void StartMovement() | ||
144 | { | ||
145 | Timer timer = new Timer(); | ||
146 | timer.Enabled = true; | ||
147 | timer.Interval = 10000; | ||
148 | timer.Elapsed += new ElapsedEventHandler(this.Heartbeat); | ||
149 | } | ||
150 | |||
151 | public void Heartbeat(object sender, EventArgs e) | ||
152 | { | ||
153 | |||
154 | Encoding enc = Encoding.ASCII; | ||
155 | |||
156 | this.OnAgentUpdate(this, movementDirection, bodyDirection); | ||
157 | |||
158 | if (this.fly) | ||
159 | { | ||
160 | movementDirection = (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY | (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG; | ||
161 | fly = false; | ||
162 | } | ||
163 | else | ||
164 | { | ||
165 | movementDirection = (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY | (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS; | ||
166 | fly = true; | ||
167 | } | ||
168 | |||
169 | this.OnChatFromViewer(enc.GetBytes("Kind of quiet around here isn't it! \0"), 2, new LLVector3(128, 128, 26), this.FirstName + " " + this.LastName, this.AgentId); | ||
170 | |||
171 | |||
172 | } | ||
173 | } | ||
174 | } | ||
diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs index 777d4ae..29b255b 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs | |||
@@ -47,14 +47,15 @@ namespace SimpleApp | |||
47 | LLVector3 pos = new LLVector3(128, 128, 128); | 47 | LLVector3 pos = new LLVector3(128, 128, 128); |
48 | 48 | ||
49 | client.OnRegionHandShakeReply += SendLayerData; | 49 | client.OnRegionHandShakeReply += SendLayerData; |
50 | client.OnChatFromViewer += | 50 | /*client.OnChatFromViewer += |
51 | delegate(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) | 51 | delegate(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) |
52 | { | 52 | { |
53 | // Echo it (so you know what you typed) | 53 | // Echo it (so you know what you typed) |
54 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | 54 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); |
55 | client.SendChatMessage("Ready.", 1, pos, "System", LLUUID.Zero ); | 55 | client.SendChatMessage("Ready.", 1, pos, "System", LLUUID.Zero ); |
56 | }; | 56 | }; |
57 | 57 | */ | |
58 | client.OnChatFromViewer += this.SimChat; | ||
58 | client.OnAddPrim += AddNewPrim; | 59 | client.OnAddPrim += AddNewPrim; |
59 | client.OnUpdatePrimGroupPosition += this.UpdatePrimPosition; | 60 | client.OnUpdatePrimGroupPosition += this.UpdatePrimPosition; |
60 | client.OnRequestMapBlocks += this.RequestMapBlocks; | 61 | client.OnRequestMapBlocks += this.RequestMapBlocks; |
@@ -70,9 +71,27 @@ namespace SimpleApp | |||
70 | client.SendRegionHandshake(m_regInfo); | 71 | client.SendRegionHandshake(m_regInfo); |
71 | 72 | ||
72 | ScenePresence avatar = CreateAndAddScenePresence(client); | 73 | ScenePresence avatar = CreateAndAddScenePresence(client); |
73 | avatar.Pos = new LLVector3(128, 128, 26); | 74 | avatar.Pos = new LLVector3(128, 128, 26); |
74 | } | 75 | } |
75 | 76 | ||
77 | public override void Update() | ||
78 | { | ||
79 | foreach (LLUUID UUID in Entities.Keys) | ||
80 | { | ||
81 | Entities[UUID].updateMovement(); | ||
82 | } | ||
83 | |||
84 | lock (this.m_syncRoot) | ||
85 | { | ||
86 | this.phyScene.Simulate(timeStep); | ||
87 | } | ||
88 | |||
89 | foreach (LLUUID UUID in Entities.Keys) | ||
90 | { | ||
91 | Entities[UUID].update(); | ||
92 | } | ||
93 | } | ||
94 | |||
76 | #endregion | 95 | #endregion |
77 | } | 96 | } |
78 | } | 97 | } |
diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index 82a62a3..0c688ba 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs | |||
@@ -15,6 +15,7 @@ using OpenSim.Region.Communications.Local; | |||
15 | using OpenSim.Region.GridInterfaces.Local; | 15 | using OpenSim.Region.GridInterfaces.Local; |
16 | using System.Timers; | 16 | using System.Timers; |
17 | using OpenSim.Region.Environment.Scenes; | 17 | using OpenSim.Region.Environment.Scenes; |
18 | using OpenSim.Framework.Data; | ||
18 | 19 | ||
19 | namespace SimpleApp | 20 | namespace SimpleApp |
20 | { | 21 | { |
@@ -25,6 +26,7 @@ namespace SimpleApp | |||
25 | uint m_localId; | 26 | uint m_localId; |
26 | public MyWorld world; | 27 | public MyWorld world; |
27 | private SceneObject m_sceneObject; | 28 | private SceneObject m_sceneObject; |
29 | public MyNpcCharacter m_character; | ||
28 | 30 | ||
29 | private void Run() | 31 | private void Run() |
30 | { | 32 | { |
@@ -65,22 +67,35 @@ namespace SimpleApp | |||
65 | world.PhysScene = physManager.GetPhysicsScene("basicphysics"); //PhysicsScene.Null; | 67 | world.PhysScene = physManager.GetPhysicsScene("basicphysics"); //PhysicsScene.Null; |
66 | 68 | ||
67 | world.LoadWorldMap(); | 69 | world.LoadWorldMap(); |
68 | world.ParcelManager.NoParcelDataFromStorage(); | 70 | world.PhysScene.SetTerrain(world.Terrain.getHeights1D()); |
69 | 71 | ||
70 | udpServer.LocalWorld = world; | 72 | udpServer.LocalWorld = world; |
71 | 73 | ||
72 | httpServer.Start(); | 74 | httpServer.Start(); |
73 | udpServer.ServerListener(); | 75 | udpServer.ServerListener(); |
74 | 76 | ||
77 | UserProfileData masterAvatar = communicationsManager.UserServer.SetupMasterUser("Test", "User", "test"); | ||
78 | if (masterAvatar != null) | ||
79 | { | ||
80 | world.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID; | ||
81 | world.ParcelManager.NoParcelDataFromStorage(); | ||
82 | } | ||
83 | |||
75 | PrimitiveBaseShape shape = PrimitiveBaseShape.DefaultBox(); | 84 | PrimitiveBaseShape shape = PrimitiveBaseShape.DefaultBox(); |
76 | shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f); | 85 | shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f); |
77 | LLVector3 pos = new LLVector3(129, 129, 27); | 86 | LLVector3 pos = new LLVector3(138, 129, 27); |
87 | |||
88 | m_sceneObject = new MySceneObject(world, world.EventManager, LLUUID.Zero, world.PrimIDAllocate(), pos, shape); | ||
89 | world.AddNewEntity(m_sceneObject); | ||
90 | |||
91 | m_character = new MyNpcCharacter(); | ||
92 | world.AddNewClient(m_character, false); | ||
93 | |||
94 | world.StartTimer(); | ||
78 | 95 | ||
79 | m_sceneObject = new MySceneObject(world,world.EventManager, LLUUID.Zero, world.PrimIDAllocate(), pos, shape); | ||
80 | world.AddNewEntity(m_sceneObject); | ||
81 | |||
82 | m_log.WriteLine(LogPriority.NORMAL, "Press enter to quit."); | 96 | m_log.WriteLine(LogPriority.NORMAL, "Press enter to quit."); |
83 | m_log.ReadLine(); | 97 | m_log.ReadLine(); |
98 | |||
84 | } | 99 | } |
85 | 100 | ||
86 | #region conscmd_callback Members | 101 | #region conscmd_callback Members |