SceneBase.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 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 libsecondlife;
  31. using OpenSim.Framework;
  32. using OpenSim.Framework.Communications.Cache;
  33. using OpenSim.Framework.Console;
  34. using OpenSim.Region.Terrain;
  35. namespace OpenSim.Region.Environment.Scenes
  36. {
  37. public abstract class SceneBase : IScene
  38. {
  39. #region Fields
  40. private readonly ClientManager m_clientManager = new ClientManager();
  41. public ClientManager ClientManager
  42. {
  43. get { return m_clientManager; }
  44. }
  45. // public Dictionary<LLUUID, EntityBase> Entities;
  46. protected ulong m_regionHandle;
  47. protected string m_regionName;
  48. protected RegionInfo m_regInfo;
  49. public TerrainEngine Terrain;
  50. protected EventManager m_eventManager;
  51. public EventManager EventManager
  52. {
  53. get { return m_eventManager; }
  54. }
  55. public RegionInfo RegionsInfo
  56. {
  57. get { return m_regInfo; }
  58. }
  59. protected string m_datastore;
  60. protected object m_syncRoot = new object();
  61. private uint m_nextLocalId = 8880000;
  62. private AssetCache m_assetCache;
  63. public AssetCache AssetCache
  64. {
  65. get { return m_assetCache; }
  66. set { m_assetCache = value; }
  67. }
  68. #endregion
  69. #region Update Methods
  70. /// <summary>
  71. /// Normally called once every frame/tick to let the world preform anything required (like running the physics simulation)
  72. /// </summary>
  73. public abstract void Update();
  74. #endregion
  75. #region Terrain Methods
  76. /// <summary>
  77. /// Loads the World heightmap
  78. /// </summary>
  79. public abstract void LoadWorldMap();
  80. /// <summary>
  81. /// Send the region heightmap to the client
  82. /// </summary>
  83. /// <param name="RemoteClient">Client to send to</param>
  84. public virtual void SendLayerData(IClientAPI RemoteClient)
  85. {
  86. RemoteClient.SendLayerData(Terrain.GetHeights1D());
  87. }
  88. #endregion
  89. #region Add/Remove Agent/Avatar
  90. /// <summary>
  91. ///
  92. /// </summary>
  93. /// <param name="remoteClient"></param>
  94. /// <param name="agentID"></param>
  95. /// <param name="child"></param>
  96. public abstract void AddNewClient(IClientAPI client, bool child);
  97. /// <summary>
  98. ///
  99. /// </summary>
  100. /// <param name="agentID"></param>
  101. public abstract void RemoveClient(LLUUID agentID);
  102. #endregion
  103. /// <summary>
  104. ///
  105. /// </summary>
  106. /// <returns></returns>
  107. public virtual RegionInfo RegionInfo
  108. {
  109. get { return m_regInfo; }
  110. }
  111. public object SyncRoot
  112. {
  113. get { return m_syncRoot; }
  114. }
  115. public uint NextLocalId
  116. {
  117. get { return m_nextLocalId++; }
  118. }
  119. #region Shutdown
  120. /// <summary>
  121. /// Tidy before shutdown
  122. /// </summary>
  123. public virtual void Close()
  124. {
  125. try
  126. {
  127. EventManager.TriggerShutdown();
  128. }
  129. catch (Exception e)
  130. {
  131. MainLog.Instance.Error("SCENE", "SceneBase.cs: Close() - Failed with exception " + e.ToString());
  132. }
  133. }
  134. #endregion
  135. }
  136. }