aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.Region/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
authorMW2007-06-21 16:13:06 +0000
committerMW2007-06-21 16:13:06 +0000
commit596b3690fc59ce90efb5132d5c35a46dbd91c7d7 (patch)
tree6cb78288a9e174454ce2fbfc73f5b13076d05da6 /OpenSim/OpenSim.Region/Scenes/ScenePresence.cs
parent* Attempted fix for Mono bug. (diff)
downloadopensim-SC_OLD-596b3690fc59ce90efb5132d5c35a46dbd91c7d7.zip
opensim-SC_OLD-596b3690fc59ce90efb5132d5c35a46dbd91c7d7.tar.gz
opensim-SC_OLD-596b3690fc59ce90efb5132d5c35a46dbd91c7d7.tar.bz2
opensim-SC_OLD-596b3690fc59ce90efb5132d5c35a46dbd91c7d7.tar.xz
Some refactoring.
Diffstat (limited to 'OpenSim/OpenSim.Region/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/OpenSim.Region/Scenes/ScenePresence.cs313
1 files changed, 251 insertions, 62 deletions
diff --git a/OpenSim/OpenSim.Region/Scenes/ScenePresence.cs b/OpenSim/OpenSim.Region/Scenes/ScenePresence.cs
index e22528a..1255606 100644
--- a/OpenSim/OpenSim.Region/Scenes/ScenePresence.cs
+++ b/OpenSim/OpenSim.Region/Scenes/ScenePresence.cs
@@ -48,7 +48,6 @@ namespace OpenSim.Region.Scenes
48 public IClientAPI ControllingClient; 48 public IClientAPI ControllingClient;
49 public LLUUID current_anim; 49 public LLUUID current_anim;
50 public int anim_seq; 50 public int anim_seq;
51 private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
52 private bool updateflag = false; 51 private bool updateflag = false;
53 private byte movementflag = 0; 52 private byte movementflag = 0;
54 private List<NewForce> forcesList = new List<NewForce>(); 53 private List<NewForce> forcesList = new List<NewForce>();
@@ -59,11 +58,31 @@ namespace OpenSim.Region.Scenes
59 private AvatarWearable[] Wearables; 58 private AvatarWearable[] Wearables;
60 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); 59 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
61 private ulong m_regionHandle; 60 private ulong m_regionHandle;
62 private bool childAvatar = false; 61 private bool childAgent = false;
63 private bool newForce = false; 62 private bool newForce = false;
64 private bool newAvatar = false; 63 private bool newAvatar = false;
64 private IScenePresenceBody m_body;
65 65
66 protected RegionInfo m_regionInfo; 66 protected RegionInfo m_regionInfo;
67
68 #region Properties
69 /// <summary>
70 ///
71 /// </summary>
72 public PhysicsActor PhysActor
73 {
74 set
75 {
76 this._physActor = value;
77 }
78 get
79 {
80 return _physActor;
81 }
82 }
83 #endregion
84
85 #region Constructor(s)
67 /// <summary> 86 /// <summary>
68 /// 87 ///
69 /// </summary> 88 /// </summary>
@@ -99,38 +118,25 @@ namespace OpenSim.Region.Scenes
99 ControllingClient.OnRequestWearables += this.SendOurAppearance; 118 ControllingClient.OnRequestWearables += this.SendOurAppearance;
100 //ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance); 119 //ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance);
101 ControllingClient.OnCompleteMovementToRegion += this.CompleteMovement; 120 ControllingClient.OnCompleteMovementToRegion += this.CompleteMovement;
102 ControllingClient.OnCompleteMovementToRegion += this.SendInitialPosition; 121 ControllingClient.OnCompleteMovementToRegion += this.SendInitialData;
103 ControllingClient.OnAgentUpdate += this.HandleAgentUpdate; 122 ControllingClient.OnAgentUpdate += this.HandleAgentUpdate;
104 // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); 123 // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack);
105 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); 124 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
106 //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); 125 //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
107
108 }
109 126
110 /// <summary>
111 ///
112 /// </summary>
113 public PhysicsActor PhysActor
114 {
115 set
116 {
117 this._physActor = value;
118 }
119 get
120 {
121 return _physActor;
122 }
123 } 127 }
128 #endregion
124 129
130 #region Status Methods
125 /// <summary> 131 /// <summary>
126 /// 132 /// Not Used, most likely can be deleted
127 /// </summary> 133 /// </summary>
128 /// <param name="status"></param> 134 /// <param name="status"></param>
129 public void ChildStatusChange(bool status) 135 public void ChildStatusChange(bool status)
130 { 136 {
131 this.childAvatar = status; 137 this.childAgent = status;
132 138
133 if (this.childAvatar == true) 139 if (this.childAgent == true)
134 { 140 {
135 this.Velocity = new LLVector3(0, 0, 0); 141 this.Velocity = new LLVector3(0, 0, 0);
136 this.Pos = new LLVector3(128, 128, 70); 142 this.Pos = new LLVector3(128, 128, 70);
@@ -142,18 +148,19 @@ namespace OpenSim.Region.Scenes
142 /// 148 ///
143 /// </summary> 149 /// </summary>
144 /// <param name="pos"></param> 150 /// <param name="pos"></param>
145 public void UpGradeAvatar(LLVector3 pos) 151 public void MakeAvatar(LLVector3 pos)
146 { 152 {
147 //this.childAvatar = false; 153 //this.childAvatar = false;
148 this.Pos = pos; 154 this.Pos = pos;
149 this.newAvatar = true; 155 this.newAvatar = true;
156 this.childAgent = false;
150 } 157 }
151 158
152 protected void DownGradeAvatar() 159 protected void MakeChildAgent()
153 { 160 {
154 this.Velocity = new LLVector3(0, 0, 0); 161 this.Velocity = new LLVector3(0, 0, 0);
155 this.Pos = new LLVector3(128, 128, 70); 162 this.Pos = new LLVector3(128, 128, 70);
156 this.childAvatar = true; 163 this.childAgent = true;
157 } 164 }
158 165
159 /// <summary> 166 /// <summary>
@@ -169,46 +176,21 @@ namespace OpenSim.Region.Scenes
169 /// <summary> 176 /// <summary>
170 /// 177 ///
171 /// </summary> 178 /// </summary>
172 public override void addForces() 179 public void StopMovement()
173 { 180 {
174 newForce = false;
175 lock (this.forcesList)
176 {
177 if (this.forcesList.Count > 0)
178 {
179 for (int i = 0; i < this.forcesList.Count; i++)
180 {
181 NewForce force = this.forcesList[i];
182
183 this.updateflag = true;
184 this.Velocity = new LLVector3(force.X, force.Y, force.Z);
185 this.newForce = true;
186 }
187 for (int i = 0; i < this.forcesList.Count; i++)
188 {
189 this.forcesList.RemoveAt(0);
190 }
191 }
192 }
193 }
194 181
195 public void SendTerseUpdateToClient(IClientAPI RemoteClient)
196 {
197 LLVector3 pos = this.Pos;
198 LLVector3 vel = this.Velocity;
199 RemoteClient.SendAvatarTerseUpdate(this.m_regionHandle, 64096, this.LocalId, new LLVector3(pos.X, pos.Y, pos.Z), new LLVector3(vel.X, vel.Y, vel.Z));
200 } 182 }
183 #endregion
201 184
185 #region Event Handlers
202 /// <summary> 186 /// <summary>
203 /// 187 ///
204 /// </summary> 188 /// </summary>
205 public void SendTerseUpdateToALLClients() 189 /// <param name="texture"></param>
190 /// <param name="visualParam"></param>
191 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
206 { 192 {
207 List<ScenePresence> avatars = this.m_world.RequestAvatarList(); 193
208 for (int i = 0; i < avatars.Count; i++)
209 {
210 this.SendTerseUpdateToClient(avatars[i].ControllingClient);
211 }
212 } 194 }
213 195
214 /// <summary> 196 /// <summary>
@@ -222,9 +204,9 @@ namespace OpenSim.Region.Scenes
222 look = new LLVector3(0.99f, 0.042f, 0); 204 look = new LLVector3(0.99f, 0.042f, 0);
223 } 205 }
224 this.ControllingClient.MoveAgentIntoRegion(m_regionInfo, Pos, look); 206 this.ControllingClient.MoveAgentIntoRegion(m_regionInfo, Pos, look);
225 if (this.childAvatar) 207 if (this.childAgent)
226 { 208 {
227 this.childAvatar = false; 209 this.childAgent = false;
228 } 210 }
229 } 211 }
230 212
@@ -272,25 +254,232 @@ namespace OpenSim.Region.Scenes
272 movementflag = 0; 254 movementflag = 0;
273 } 255 }
274 } 256 }
275 257
276 } 258 }
259 #endregion
277 260
261 #region Overridden Methods
278 /// <summary> 262 /// <summary>
279 /// 263 ///
280 /// </summary> 264 /// </summary>
281 public static void LoadAnims() 265 public override void LandRenegerated()
282 { 266 {
283 267
284 } 268 }
285 269
286 /// <summary> 270 /// <summary>
287 /// 271 ///
288 /// </summary> 272 /// </summary>
289 public override void LandRenegerated() 273 public override void update()
274 {
275 if (this.childAgent == false)
276 {
277 if (this.newForce)
278 {
279 this.SendTerseUpdateToALLClients();
280 _updateCount = 0;
281 }
282 else if (movementflag != 0)
283 {
284 _updateCount++;
285 if (_updateCount > 3)
286 {
287 this.SendTerseUpdateToALLClients();
288 _updateCount = 0;
289 }
290 }
291
292 this.CheckForBorderCrossing();
293 }
294 }
295 #endregion
296
297 #region Update Client(s)
298 /// <summary>
299 ///
300 /// </summary>
301 /// <param name="RemoteClient"></param>
302 public void SendTerseUpdateToClient(IClientAPI RemoteClient)
303 {
304 LLVector3 pos = this.Pos;
305 LLVector3 vel = this.Velocity;
306 RemoteClient.SendAvatarTerseUpdate(this.m_regionHandle, 64096, this.LocalId, new LLVector3(pos.X, pos.Y, pos.Z), new LLVector3(vel.X, vel.Y, vel.Z));
307 }
308
309 /// <summary>
310 ///
311 /// </summary>
312 public void SendTerseUpdateToALLClients()
313 {
314 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
315 for (int i = 0; i < avatars.Count; i++)
316 {
317 this.SendTerseUpdateToClient(avatars[i].ControllingClient);
318 }
319 }
320
321 /// <summary>
322 ///
323 /// </summary>
324 /// <param name="remoteAvatar"></param>
325 public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar)
326 {
327 remoteAvatar.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos);
328 }
329
330 /// <summary>
331 ///
332 /// </summary>
333 public void SendInitialData()
334 {
335 this.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos);
336 if (this.newAvatar)
337 {
338 this.m_world.InformClientOfNeighbours(this.ControllingClient);
339 this.newAvatar = false;
340 }
341 }
342
343 /// <summary>
344 ///
345 /// </summary>
346 /// <param name="OurClient"></param>
347 public void SendOurAppearance(IClientAPI OurClient)
348 {
349 this.ControllingClient.SendWearables(this.Wearables);
350 }
351
352 /// <summary>
353 ///
354 /// </summary>
355 /// <param name="avatarInfo"></param>
356 public void SendAppearanceToOtherAgent(ScenePresence avatarInfo)
290 { 357 {
291 358
292 } 359 }
293 360
361 /// <summary>
362 ///
363 /// </summary>
364 /// <param name="animID"></param>
365 /// <param name="seq"></param>
366 public void SendAnimPack(LLUUID animID, int seq)
367 {
368
369
370 }
371
372 /// <summary>
373 ///
374 /// </summary>
375 public void SendAnimPack()
376 {
377
378 }
379 #endregion
380
381 #region Border Crossing Methods
382 /// <summary>
383 ///
384 /// </summary>
385 protected void CheckForBorderCrossing()
386 {
387 LLVector3 pos2 = this.Pos;
388 LLVector3 vel = this.Velocity;
389
390 float timeStep = 0.2f;
391 pos2.X = pos2.X + (vel.X * timeStep);
392 pos2.Y = pos2.Y + (vel.Y * timeStep);
393 pos2.Z = pos2.Z + (vel.Z * timeStep);
394
395 if ((pos2.X < 0) || (pos2.X > 256))
396 {
397 this.CrossToNewRegion();
398 }
399
400 if ((pos2.Y < 0) || (pos2.Y > 256))
401 {
402 this.CrossToNewRegion();
403 }
404 }
405
406 /// <summary>
407 ///
408 /// </summary>
409 protected void CrossToNewRegion()
410 {
411 LLVector3 pos = this.Pos;
412 LLVector3 newpos = new LLVector3(pos.X, pos.Y, pos.Z);
413 uint neighbourx = this.m_regionInfo.RegionLocX;
414 uint neighboury = this.m_regionInfo.RegionLocY;
415
416 if (pos.X < 2)
417 {
418 neighbourx -= 1;
419 newpos.X = 254;
420 }
421 if (pos.X > 253)
422 {
423 neighbourx += 1;
424 newpos.X = 1;
425 }
426 if (pos.Y < 2)
427 {
428 neighboury -= 1;
429 newpos.Y = 254;
430 }
431 if (pos.Y > 253)
432 {
433 neighboury += 1;
434 newpos.Y = 1;
435 }
436
437 LLVector3 vel = this.velocity;
438 ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury * 256));
439 RegionInfo neighbourRegion = this.m_world.RequestNeighbouringRegionInfo(neighbourHandle);
440 if (neighbourRegion != null)
441 {
442 this.m_world.InformNeighbourOfCrossing(neighbourHandle, this.ControllingClient.AgentId, newpos);
443 this.MakeChildAgent();
444 this.ControllingClient.CrossRegion(neighbourHandle, newpos, vel, System.Net.IPAddress.Parse(neighbourRegion.IPListenAddr), (ushort)neighbourRegion.IPListenPort);
445
446 }
447 }
448 #endregion
449
450 /// <summary>
451 ///
452 /// </summary>
453 public static void LoadAnims()
454 {
455
456 }
457
458 /// <summary>
459 ///
460 /// </summary>
461 public override void updateMovement()
462 {
463 newForce = false;
464 lock (this.forcesList)
465 {
466 if (this.forcesList.Count > 0)
467 {
468 for (int i = 0; i < this.forcesList.Count; i++)
469 {
470 NewForce force = this.forcesList[i];
471
472 this.updateflag = true;
473 this.Velocity = new LLVector3(force.X, force.Y, force.Z);
474 this.newForce = true;
475 }
476 for (int i = 0; i < this.forcesList.Count; i++)
477 {
478 this.forcesList.RemoveAt(0);
479 }
480 }
481 }
482 }
294 483
295 public class NewForce 484 public class NewForce
296 { 485 {