EntityBase.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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. using System;
  28. using System.Reflection;
  29. using System.Runtime.Serialization;
  30. using System.Security.Permissions;
  31. using log4net;
  32. using OpenSim.Framework;
  33. using OpenMetaverse;
  34. namespace OpenSim.Region.Framework.Scenes
  35. {
  36. public abstract class EntityBase : ISceneEntity
  37. {
  38. // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  39. /// <summary>
  40. /// The scene to which this entity belongs
  41. /// </summary>
  42. protected Scene m_scene;
  43. public Scene Scene
  44. {
  45. get { return m_scene; }
  46. }
  47. protected UUID m_uuid;
  48. public virtual UUID UUID
  49. {
  50. get { return m_uuid; }
  51. set { m_uuid = value; }
  52. }
  53. /// <summary>
  54. /// The name of this entity
  55. /// </summary>
  56. public osUTF8 osUTF8Name;
  57. public virtual string Name
  58. {
  59. get { return osUTF8Name == null ? string.Empty : osUTF8Name.ToString(); }
  60. set { osUTF8Name = value == null? null : new osUTF8(value); }
  61. }
  62. /// <summary>
  63. /// id local to scene
  64. /// </summary>
  65. protected uint m_localId;
  66. public virtual uint LocalId
  67. {
  68. get
  69. {
  70. return m_localId;
  71. }
  72. set
  73. {
  74. m_localId = value;
  75. // m_log.DebugFormat("[ENTITY BASE]: Set part {0} to local id {1}", Name, m_localId);
  76. }
  77. }
  78. /// <summary>
  79. /// Signals whether this entity was in a scene but has since been removed from it.
  80. /// </summary>
  81. public bool IsDeleted { get; protected internal set; }
  82. /// <summary>
  83. /// Absolute position of this entity in a scene.
  84. /// </summary>
  85. protected Vector3 m_pos;
  86. public virtual Vector3 AbsolutePosition
  87. {
  88. get
  89. {
  90. return m_pos;
  91. }
  92. set
  93. {
  94. m_pos = value;
  95. }
  96. }
  97. /// <summary>
  98. /// Current velocity of the entity.
  99. /// </summary>
  100. protected Vector3 m_velocity;
  101. public virtual Vector3 Velocity
  102. {
  103. get { return m_velocity; }
  104. set { m_velocity = value; }
  105. }
  106. /// <summary>
  107. /// Creates a new Entity (should not occur on it's own)
  108. /// </summary>
  109. public EntityBase()
  110. {
  111. }
  112. /// <summary>
  113. /// Performs any updates that need to be done at each frame, as opposed to immediately.
  114. /// These included scheduled updates and updates that occur due to physics processing.
  115. /// </summary>
  116. public virtual void Update()
  117. {
  118. }
  119. /// <summary>
  120. /// Copies the entity
  121. /// </summary>
  122. /// <returns></returns>
  123. public virtual EntityBase Copy()
  124. {
  125. return (EntityBase) MemberwiseClone();
  126. }
  127. }
  128. //Nested Classes
  129. public class EntityIntersection
  130. {
  131. public Vector3 ipoint = new Vector3(0, 0, 0);
  132. public Vector3 normal = new Vector3(0, 0, 0);
  133. public Vector3 AAfaceNormal = new Vector3(0, 0, 0);
  134. public int face = -1;
  135. public bool HitTF = false;
  136. public SceneObjectPart obj;
  137. public float distance = 0;
  138. public EntityIntersection()
  139. {
  140. }
  141. public EntityIntersection(Vector3 _ipoint, Vector3 _normal, bool _HitTF)
  142. {
  143. ipoint = _ipoint;
  144. normal = _normal;
  145. HitTF = _HitTF;
  146. }
  147. }
  148. }