EntityBase.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. using System.Collections.Generic;
  2. using Axiom.Math;
  3. using libsecondlife;
  4. namespace OpenSim.Region.Environment.Scenes
  5. {
  6. public abstract class EntityBase
  7. {
  8. public LLUUID uuid;
  9. protected List<EntityBase> children;
  10. protected Scene m_world;
  11. protected string m_name;
  12. /// <summary>
  13. ///
  14. /// </summary>
  15. public virtual string Name
  16. {
  17. get { return m_name; }
  18. set { m_name = value; }
  19. }
  20. protected LLVector3 m_pos;
  21. /// <summary>
  22. ///
  23. /// </summary>
  24. public virtual LLVector3 Pos
  25. {
  26. get
  27. {
  28. return m_pos;
  29. }
  30. set
  31. {
  32. m_pos = value;
  33. }
  34. }
  35. public LLVector3 m_velocity;
  36. /// <summary>
  37. ///
  38. /// </summary>
  39. public virtual LLVector3 Velocity
  40. {
  41. get
  42. {
  43. return m_velocity;
  44. }
  45. set
  46. {
  47. m_velocity = value;
  48. }
  49. }
  50. protected Quaternion m_rotation = new Quaternion(0,0,1,0);
  51. public virtual Quaternion Rotation
  52. {
  53. get
  54. {
  55. return m_rotation;
  56. }
  57. set
  58. {
  59. m_rotation = value;
  60. }
  61. }
  62. protected uint m_localId;
  63. public uint LocalId
  64. {
  65. get { return m_localId; }
  66. set { m_localId = value; }
  67. }
  68. /// <summary>
  69. /// Creates a new Entity (should not occur on it's own)
  70. /// </summary>
  71. public EntityBase()
  72. {
  73. uuid = new LLUUID();
  74. m_pos = new LLVector3();
  75. m_velocity = new LLVector3();
  76. Rotation = new Quaternion();
  77. m_name = "(basic entity)";
  78. children = new List<EntityBase>();
  79. }
  80. /// <summary>
  81. ///
  82. /// </summary>
  83. public virtual void updateMovement()
  84. {
  85. foreach (EntityBase child in children)
  86. {
  87. child.updateMovement();
  88. }
  89. }
  90. /// <summary>
  91. /// Performs any updates that need to be done at each frame. This function is overridable from it's children.
  92. /// </summary>
  93. public virtual void update()
  94. {
  95. // Do any per-frame updates needed that are applicable to every type of entity
  96. foreach (EntityBase child in children)
  97. {
  98. child.update();
  99. }
  100. }
  101. /// <summary>
  102. /// Called at a set interval to inform entities that they should back themsleves up to the DB
  103. /// </summary>
  104. public virtual void BackUp()
  105. {
  106. }
  107. /// <summary>
  108. /// Copies the entity
  109. /// </summary>
  110. /// <returns></returns>
  111. public virtual EntityBase Copy()
  112. {
  113. return (EntityBase)this.MemberwiseClone();
  114. }
  115. /// <summary>
  116. /// Infoms the entity that the land (heightmap) has changed
  117. /// </summary>
  118. public virtual void LandRenegerated()
  119. {
  120. }
  121. }
  122. }