Avatar.Update.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /*
  2. * Copyright (c) Contributors, http://www.openmetaverse.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSim Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *
  27. */
  28. using System;
  29. using System.Collections.Generic;
  30. using System.Text;
  31. using libsecondlife;
  32. using libsecondlife.Packets;
  33. using OpenSim.Physics.Manager;
  34. using OpenSim.Framework.Interfaces;
  35. using OpenSim.Framework.Types;
  36. namespace OpenSim.Region.Scenes
  37. {
  38. partial class Avatar
  39. {
  40. /// <summary>
  41. ///
  42. /// </summary>
  43. public override void update()
  44. {
  45. if (this.childAvatar == false)
  46. {
  47. if (this.newForce)
  48. {
  49. this.SendTerseUpdateToALLClients();
  50. _updateCount = 0;
  51. }
  52. else if (movementflag != 0)
  53. {
  54. _updateCount++;
  55. if (_updateCount > 3)
  56. {
  57. this.SendTerseUpdateToALLClients();
  58. _updateCount = 0;
  59. }
  60. }
  61. this.CheckForBorderCrossing();
  62. }
  63. }
  64. /// <summary>
  65. ///
  66. /// </summary>
  67. /// <param name="remoteAvatar"></param>
  68. public void SendUpdateToOtherClient(Avatar remoteAvatar)
  69. {
  70. }
  71. /// <summary>
  72. ///
  73. /// </summary>
  74. /// <returns></returns>
  75. public ObjectUpdatePacket CreateUpdatePacket()
  76. {
  77. return null;
  78. }
  79. /// <summary>
  80. ///
  81. /// </summary>
  82. public void SendInitialPosition()
  83. {
  84. this.ControllingClient.SendAvatarData(m_regionInfo, this.firstname, this.lastname, this.uuid, this.localid, new LLVector3(128, 128, 60));
  85. }
  86. /// <summary>
  87. ///
  88. /// </summary>
  89. public void SendOurAppearance()
  90. {
  91. }
  92. /// <summary>
  93. ///
  94. /// </summary>
  95. /// <param name="OurClient"></param>
  96. public void SendOurAppearance(IClientAPI OurClient)
  97. {
  98. this.ControllingClient.SendWearables(this.Wearables);
  99. }
  100. /// <summary>
  101. ///
  102. /// </summary>
  103. /// <param name="avatarInfo"></param>
  104. public void SendAppearanceToOtherAgent(Avatar avatarInfo)
  105. {
  106. }
  107. /// <summary>
  108. ///
  109. /// </summary>
  110. /// <param name="texture"></param>
  111. /// <param name="visualParam"></param>
  112. public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
  113. {
  114. }
  115. /// <summary>
  116. ///
  117. /// </summary>
  118. public void StopMovement()
  119. {
  120. }
  121. /// <summary>
  122. ///
  123. /// </summary>
  124. /// <param name="animID"></param>
  125. /// <param name="seq"></param>
  126. public void SendAnimPack(LLUUID animID, int seq)
  127. {
  128. }
  129. /// <summary>
  130. ///
  131. /// </summary>
  132. public void SendAnimPack()
  133. {
  134. }
  135. /// <summary>
  136. ///
  137. /// </summary>
  138. protected void CheckForBorderCrossing()
  139. {
  140. LLVector3 pos2 = this.Pos;
  141. LLVector3 vel = this.Velocity;
  142. float timeStep = 0.3f;
  143. pos2.X = pos2.X + (vel.X * timeStep);
  144. pos2.Y = pos2.Y + (vel.Y * timeStep);
  145. pos2.Z = pos2.Z + (vel.Z * timeStep);
  146. if ((pos2.X < 0) || (pos2.X > 256))
  147. {
  148. this.CrossToNewRegion();
  149. }
  150. if ((pos2.Y < 0) || (pos2.Y > 256))
  151. {
  152. this.CrossToNewRegion();
  153. }
  154. }
  155. /// <summary>
  156. ///
  157. /// </summary>
  158. protected void CrossToNewRegion()
  159. {
  160. LLVector3 pos = this.Pos;
  161. LLVector3 newpos = new LLVector3(pos.X, pos.Y, pos.Z);
  162. uint neighbourx = this.m_regionInfo.RegionLocX;
  163. uint neighboury = this.m_regionInfo.RegionLocY;
  164. if (pos.X < 2)
  165. {
  166. neighbourx -= 1;
  167. newpos.X = 254;
  168. }
  169. if (pos.X > 253)
  170. {
  171. neighbourx += 1;
  172. newpos.X = 1;
  173. }
  174. if (pos.Y < 2)
  175. {
  176. neighboury -= 1;
  177. newpos.Y = 254;
  178. }
  179. if (pos.Y > 253)
  180. {
  181. neighboury += 1;
  182. newpos.Y = 1;
  183. }
  184. LLVector3 vel = this.velocity;
  185. ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury* 256));
  186. RegionInfo neighbourRegion = this.m_world.RequestNeighbouringRegionInfo(neighbourHandle);
  187. if (neighbourRegion != null)
  188. {
  189. this.m_world.InformNeighbourOfCrossing(neighbourHandle, this.ControllingClient.AgentId, newpos);
  190. this.DownGradeAvatar();
  191. this.ControllingClient.CrossRegion(neighbourHandle, newpos, vel, System.Net.IPAddress.Parse(neighbourRegion.IPListenAddr), (ushort)neighbourRegion.IPListenPort);
  192. }
  193. }
  194. }
  195. }