ScriptEngine.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. /* Original code: Tedd Hansen */
  29. using System;
  30. using Nini.Config;
  31. using OpenSim.Framework.Console;
  32. using OpenSim.Region.Environment.Interfaces;
  33. using OpenSim.Region.Environment.Scenes;
  34. namespace OpenSim.Grid.ScriptEngine.DotNetEngine
  35. {
  36. /// <summary>
  37. /// This is the root object for ScriptEngine
  38. /// </summary>
  39. [Serializable]
  40. public class ScriptEngine : IRegionModule
  41. {
  42. internal Scene World;
  43. internal EventManager m_EventManager; // Handles and queues incoming events from OpenSim
  44. internal EventQueueManager m_EventQueueManager; // Executes events
  45. internal ScriptManager m_ScriptManager; // Load, unload and execute scripts
  46. internal AppDomainManager m_AppDomainManager;
  47. internal LSLLongCmdHandler m_LSLLongCmdHandler;
  48. private LogBase m_log;
  49. public ScriptEngine()
  50. {
  51. //Common.SendToDebug("ScriptEngine Object Initialized");
  52. Common.mySE = this;
  53. }
  54. public LogBase Log
  55. {
  56. get { return m_log; }
  57. }
  58. public void InitializeEngine(Scene Sceneworld, LogBase logger)
  59. {
  60. World = Sceneworld;
  61. m_log = logger;
  62. Log.Verbose("ScriptEngine", "DotNet & LSL ScriptEngine initializing");
  63. //m_logger.Status("ScriptEngine", "InitializeEngine");
  64. // Create all objects we'll be using
  65. m_EventQueueManager = new EventQueueManager(this);
  66. m_EventManager = new EventManager(this);
  67. m_ScriptManager = new ScriptManager(this);
  68. m_AppDomainManager = new AppDomainManager();
  69. m_LSLLongCmdHandler = new LSLLongCmdHandler(this);
  70. // Should we iterate the region for scripts that needs starting?
  71. // Or can we assume we are loaded before anything else so we can use proper events?
  72. }
  73. public void Shutdown()
  74. {
  75. // We are shutting down
  76. }
  77. //// !!!FOR DEBUGGING ONLY!!! (for executing script directly from test app)
  78. //[Obsolete("!!!FOR DEBUGGING ONLY!!!")]
  79. //public void StartScript(string ScriptID, IScriptHost ObjectID)
  80. //{
  81. // this.myEventManager.TEMP_OBJECT_ID = ObjectID;
  82. // Log.Status("ScriptEngine", "DEBUG FUNCTION: StartScript: " + ScriptID);
  83. // myScriptManager.StartScript(ScriptID, ObjectID);
  84. //}
  85. #region IRegionModule
  86. public void Initialise(Scene scene, IConfigSource config)
  87. {
  88. InitializeEngine(scene, MainLog.Instance);
  89. }
  90. public void PostInitialise()
  91. {
  92. }
  93. public void Close()
  94. {
  95. }
  96. public string Name
  97. {
  98. get { return "LSLScriptingModule"; }
  99. }
  100. public bool IsSharedModule
  101. {
  102. get { return false; }
  103. }
  104. #endregion
  105. }
  106. }