EventManager.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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 libsecondlife;
  31. using OpenSim.Framework;
  32. namespace OpenSim.Grid.ScriptEngine.DotNetEngine
  33. {
  34. /// <summary>
  35. /// Prepares events so they can be directly executed upon a script by EventQueueManager, then queues it.
  36. /// </summary>
  37. [Serializable]
  38. internal class EventManager
  39. {
  40. private ScriptEngine myScriptEngine;
  41. //public IScriptHost TEMP_OBJECT_ID;
  42. public EventManager(ScriptEngine _ScriptEngine)
  43. {
  44. myScriptEngine = _ScriptEngine;
  45. // TODO: HOOK EVENTS UP TO SERVER!
  46. //myScriptEngine.m_logger.Verbose("ScriptEngine", "EventManager Start");
  47. // TODO: ADD SERVER HOOK TO LOAD A SCRIPT THROUGH myScriptEngine.ScriptManager
  48. // Hook up a test event to our test form
  49. myScriptEngine.Log.Verbose("ScriptEngine", "Hooking up to server events");
  50. myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
  51. myScriptEngine.World.EventManager.OnRezScript += OnRezScript;
  52. myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript;
  53. }
  54. public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
  55. {
  56. // Add to queue for all scripts in ObjectID object
  57. //myScriptEngine.m_logger.Verbose("ScriptEngine", "EventManager Event: touch_start");
  58. //Console.WriteLine("touch_start localID: " + localID);
  59. myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", new object[] {(int) 1});
  60. }
  61. public void OnRezScript(uint localID, LLUUID itemID, string script)
  62. {
  63. //myScriptEngine.myScriptManager.StartScript(
  64. // Path.Combine("ScriptEngines", "Default.lsl"),
  65. // new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost()
  66. //);
  67. Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " +
  68. script.Length);
  69. myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script);
  70. }
  71. public void OnRemoveScript(uint localID, LLUUID itemID)
  72. {
  73. //myScriptEngine.myScriptManager.StartScript(
  74. // Path.Combine("ScriptEngines", "Default.lsl"),
  75. // new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost()
  76. //);
  77. Console.WriteLine("OnRemoveScript localID: " + localID + " LLUID: " + itemID.ToString());
  78. myScriptEngine.m_ScriptManager.StopScript(
  79. localID,
  80. itemID
  81. );
  82. }
  83. // TODO: Replace placeholders below
  84. // These needs to be hooked up to OpenSim during init of this class
  85. // then queued in EventQueueManager.
  86. // When queued in EventQueueManager they need to be LSL compatible (name and params)
  87. //public void state_entry() { } //
  88. public void state_exit()
  89. {
  90. }
  91. //public void touch_start() { }
  92. public void touch()
  93. {
  94. }
  95. public void touch_end()
  96. {
  97. }
  98. public void collision_start()
  99. {
  100. }
  101. public void collision()
  102. {
  103. }
  104. public void collision_end()
  105. {
  106. }
  107. public void land_collision_start()
  108. {
  109. }
  110. public void land_collision()
  111. {
  112. }
  113. public void land_collision_end()
  114. {
  115. }
  116. public void timer()
  117. {
  118. }
  119. public void listen()
  120. {
  121. }
  122. public void on_rez()
  123. {
  124. }
  125. public void sensor()
  126. {
  127. }
  128. public void no_sensor()
  129. {
  130. }
  131. public void control()
  132. {
  133. }
  134. public void money()
  135. {
  136. }
  137. public void email()
  138. {
  139. }
  140. public void at_target()
  141. {
  142. }
  143. public void not_at_target()
  144. {
  145. }
  146. public void at_rot_target()
  147. {
  148. }
  149. public void not_at_rot_target()
  150. {
  151. }
  152. public void run_time_permissions()
  153. {
  154. }
  155. public void changed()
  156. {
  157. }
  158. public void attach()
  159. {
  160. }
  161. public void dataserver()
  162. {
  163. }
  164. public void link_message()
  165. {
  166. }
  167. public void moving_start()
  168. {
  169. }
  170. public void moving_end()
  171. {
  172. }
  173. public void object_rez()
  174. {
  175. }
  176. public void remote_data()
  177. {
  178. }
  179. public void http_response()
  180. {
  181. }
  182. }
  183. }