1
0

SceneBase.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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 libsecondlife;
  30. using OpenSim.Framework;
  31. using OpenSim.Framework.Communications.Cache;
  32. using OpenSim.Framework.Console;
  33. using OpenSim.Region.Terrain;
  34. using OpenSim.Region.Environment.Interfaces;
  35. namespace OpenSim.Region.Environment.Scenes
  36. {
  37. public abstract class SceneBase : IScene
  38. {
  39. private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  40. #region Events
  41. public event restart OnRestart;
  42. #endregion
  43. #region Fields
  44. private readonly ClientManager m_clientManager = new ClientManager();
  45. public ClientManager ClientManager
  46. {
  47. get { return m_clientManager; }
  48. }
  49. protected ulong m_regionHandle;
  50. protected string m_regionName;
  51. protected RegionInfo m_regInfo;
  52. public TerrainEngine Terrain;
  53. public ITerrainChannel Heightmap;
  54. protected EventManager m_eventManager;
  55. public EventManager EventManager
  56. {
  57. get { return m_eventManager; }
  58. }
  59. protected string m_datastore;
  60. private uint m_nextLocalId = 8880000;
  61. private AssetCache m_assetCache;
  62. public AssetCache AssetCache
  63. {
  64. get { return m_assetCache; }
  65. set { m_assetCache = value; }
  66. }
  67. protected RegionStatus m_regStatus;
  68. public RegionStatus Region_Status
  69. {
  70. get { return m_regStatus; }
  71. set { m_regStatus = value; }
  72. }
  73. #endregion
  74. #region Update Methods
  75. /// <summary>
  76. /// Normally called once every frame/tick to let the world preform anything required (like running the physics simulation)
  77. /// </summary>
  78. public abstract void Update();
  79. #endregion
  80. #region Terrain Methods
  81. /// <summary>
  82. /// Loads the World heightmap
  83. /// </summary>
  84. public abstract void LoadWorldMap();
  85. /// <summary>
  86. /// Send the region heightmap to the client
  87. /// </summary>
  88. /// <param name="RemoteClient">Client to send to</param>
  89. public virtual void SendLayerData(IClientAPI RemoteClient)
  90. {
  91. RemoteClient.SendLayerData(Terrain.GetHeights1D());
  92. }
  93. #endregion
  94. #region Add/Remove Agent/Avatar
  95. /// <summary>
  96. ///
  97. /// </summary>
  98. /// <param name="remoteClient"></param>
  99. /// <param name="agentID"></param>
  100. /// <param name="child"></param>
  101. public abstract void AddNewClient(IClientAPI client, bool child);
  102. /// <summary>
  103. ///
  104. /// </summary>
  105. /// <param name="agentID"></param>
  106. public abstract void RemoveClient(LLUUID agentID);
  107. public abstract void CloseAllAgents(uint circuitcode);
  108. #endregion
  109. /// <summary>
  110. ///
  111. /// </summary>
  112. /// <returns></returns>
  113. public virtual RegionInfo RegionInfo
  114. {
  115. get { return m_regInfo; }
  116. }
  117. public uint NextLocalId
  118. {
  119. get { return m_nextLocalId++; }
  120. }
  121. #region admin stuff
  122. /// <summary>
  123. /// Region Restart - Seconds till restart.
  124. /// </summary>
  125. /// <param name="seconds"></param>
  126. public virtual void Restart(int seconds)
  127. {
  128. m_log.Error("[REGION]: passing Restart Message up the namespace");
  129. OnRestart(RegionInfo);
  130. }
  131. public virtual bool PresenceChildStatus(LLUUID avatarID)
  132. {
  133. return false;
  134. }
  135. public abstract bool OtherRegionUp(RegionInfo thisRegion);
  136. public virtual string GetSimulatorVersion()
  137. {
  138. return "OpenSimulator v0.5 SVN";
  139. }
  140. #endregion
  141. #region Shutdown
  142. /// <summary>
  143. /// Tidy before shutdown
  144. /// </summary>
  145. public virtual void Close()
  146. {
  147. try
  148. {
  149. EventManager.TriggerShutdown();
  150. }
  151. catch (Exception e)
  152. {
  153. m_log.Error("[SCENE]: SceneBase.cs: Close() - Failed with exception " + e.ToString());
  154. }
  155. }
  156. #endregion
  157. }
  158. }