SceneEvents.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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 libsecondlife;
  29. using System;
  30. using OpenSim.Framework;
  31. using OpenSim.Region.Environment.Interfaces;
  32. using OpenSim.Region.Environment.LandManagement;
  33. namespace OpenSim.Region.Environment.Scenes
  34. {
  35. /// <summary>
  36. /// A class for triggering remote scene events.
  37. /// </summary>
  38. public class EventManager
  39. {
  40. public delegate void OnFrameDelegate();
  41. public event OnFrameDelegate OnFrame;
  42. public delegate void ClientMovement(ScenePresence client);
  43. public event ClientMovement OnClientMovement;
  44. public delegate void OnBackupDelegate(IRegionDataStore datastore);
  45. public event OnBackupDelegate OnBackup;
  46. public delegate void OnNewClientDelegate(IClientAPI client);
  47. public event OnNewClientDelegate OnNewClient;
  48. public delegate void OnNewPresenceDelegate(ScenePresence presence);
  49. public event OnNewPresenceDelegate OnNewPresence;
  50. public delegate void OnRemovePresenceDelegate(LLUUID agentId);
  51. public event OnRemovePresenceDelegate OnRemovePresence;
  52. public delegate void OnParcelPrimCountUpdateDelegate();
  53. public event OnParcelPrimCountUpdateDelegate OnParcelPrimCountUpdate;
  54. public delegate void OnParcelPrimCountAddDelegate(SceneObjectGroup obj);
  55. public event OnParcelPrimCountAddDelegate OnParcelPrimCountAdd;
  56. public delegate void OnPluginConsoleDelegate(string[] args);
  57. public event OnPluginConsoleDelegate OnPluginConsole;
  58. public delegate void OnShutdownDelegate();
  59. public event OnShutdownDelegate OnShutdown;
  60. public delegate void ObjectGrabDelegate(uint localID, LLVector3 offsetPos, IClientAPI remoteClient);
  61. public delegate void OnPermissionErrorDelegate(LLUUID user, string reason);
  62. public event ObjectGrabDelegate OnObjectGrab;
  63. public event OnPermissionErrorDelegate OnPermissionError;
  64. public delegate void NewRezScript(uint localID, LLUUID itemID, string script);
  65. public event NewRezScript OnRezScript;
  66. public delegate void RemoveScript(uint localID, LLUUID itemID);
  67. public event RemoveScript OnRemoveScript;
  68. public delegate bool SceneGroupMoved(LLUUID groupID, LLVector3 delta);
  69. public event SceneGroupMoved OnSceneGroupMove;
  70. public delegate void SceneGroupGrabed(LLUUID groupID, LLVector3 offset, LLUUID userID);
  71. public event SceneGroupGrabed OnSceneGroupGrab;
  72. public delegate void LandObjectAdded(Land newParcel, LLUUID regionUUID);
  73. public event LandObjectAdded OnLandObjectAdded;
  74. public delegate void LandObjectRemoved(LLUUID globalID);
  75. public event LandObjectRemoved OnLandObjectRemoved;
  76. public delegate void AvatarEnteringNewParcel(ScenePresence avatar, int localLandID, LLUUID regionID);
  77. public event AvatarEnteringNewParcel OnAvatarEnteringNewParcel;
  78. public delegate void NewGridInstantMessage(GridInstantMessage message);
  79. public event NewGridInstantMessage OnGridInstantMessageToIMModule;
  80. public event NewGridInstantMessage OnGridInstantMessageToFriendsModule;
  81. public event NewGridInstantMessage OnGridInstantMessageToGroupsModule;
  82. public delegate void ClientClosed(LLUUID clientID);
  83. public event ClientClosed OnClientClosed;
  84. public delegate void ScriptChangedEvent(uint localID, uint change);
  85. public event ScriptChangedEvent OnScriptChangedEvent;
  86. public class MoneyTransferArgs : System.EventArgs
  87. {
  88. public LLUUID sender;
  89. public LLUUID reciever;
  90. // Always false. The SL protocol sucks.
  91. public bool authenticated = false;
  92. public int amount;
  93. public int transactiontype;
  94. public string description;
  95. public MoneyTransferArgs(LLUUID asender, LLUUID areciever, int aamount, int atransactiontype, string adescription) {
  96. sender = asender;
  97. reciever = areciever;
  98. amount = aamount;
  99. transactiontype = atransactiontype;
  100. description = adescription;
  101. }
  102. }
  103. public delegate void MoneyTransferEvent(Object sender, MoneyTransferArgs e);
  104. public event MoneyTransferEvent OnMoneyTransfer;
  105. public void TriggerOnScriptChangedEvent(uint localID, uint change)
  106. {
  107. if (OnScriptChangedEvent != null)
  108. OnScriptChangedEvent(localID,change);
  109. }
  110. public void TriggerOnClientMovement(ScenePresence avatar)
  111. {
  112. if (OnClientMovement != null)
  113. OnClientMovement(avatar);
  114. }
  115. public void TriggerPermissionError(LLUUID user, string reason)
  116. {
  117. if (OnPermissionError != null)
  118. OnPermissionError(user, reason);
  119. }
  120. public void TriggerOnPluginConsole(string[] args)
  121. {
  122. if (OnPluginConsole != null)
  123. OnPluginConsole(args);
  124. }
  125. public void TriggerOnFrame()
  126. {
  127. if (OnFrame != null)
  128. {
  129. OnFrame();
  130. }
  131. }
  132. public void TriggerOnNewClient(IClientAPI client)
  133. {
  134. if (OnNewClient != null)
  135. OnNewClient(client);
  136. }
  137. public void TriggerOnNewPresence(ScenePresence presence)
  138. {
  139. if (OnNewPresence != null)
  140. OnNewPresence(presence);
  141. }
  142. public void TriggerOnRemovePresence(LLUUID agentId)
  143. {
  144. if (OnRemovePresence != null)
  145. {
  146. OnRemovePresence(agentId);
  147. }
  148. }
  149. public void TriggerOnBackup(IRegionDataStore dstore)
  150. {
  151. if (OnBackup != null)
  152. {
  153. OnBackup(dstore);
  154. }
  155. }
  156. public void TriggerParcelPrimCountUpdate()
  157. {
  158. if (OnParcelPrimCountUpdate != null)
  159. {
  160. OnParcelPrimCountUpdate();
  161. }
  162. }
  163. public void TriggerMoneyTransfer(Object sender, MoneyTransferArgs e)
  164. {
  165. if (OnMoneyTransfer != null)
  166. {
  167. OnMoneyTransfer(sender, e);
  168. }
  169. }
  170. public void TriggerParcelPrimCountAdd(SceneObjectGroup obj)
  171. {
  172. if (OnParcelPrimCountAdd != null)
  173. {
  174. OnParcelPrimCountAdd(obj);
  175. }
  176. }
  177. public void TriggerShutdown()
  178. {
  179. if (OnShutdown != null)
  180. OnShutdown();
  181. }
  182. public void TriggerObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
  183. {
  184. if (OnObjectGrab != null)
  185. {
  186. OnObjectGrab(localID, offsetPos, remoteClient);
  187. }
  188. }
  189. public void TriggerRezScript(uint localID, LLUUID itemID, string script)
  190. {
  191. if (OnRezScript != null)
  192. {
  193. OnRezScript(localID, itemID, script);
  194. }
  195. }
  196. public void TriggerRemoveScript(uint localID, LLUUID itemID)
  197. {
  198. if (OnRemoveScript != null)
  199. {
  200. OnRemoveScript(localID, itemID);
  201. }
  202. }
  203. public bool TriggerGroupMove(LLUUID groupID, LLVector3 delta)
  204. {
  205. if (OnSceneGroupMove != null)
  206. {
  207. return OnSceneGroupMove(groupID, delta);
  208. }
  209. return true;
  210. }
  211. public void TriggerGroupGrab(LLUUID groupID, LLVector3 offset, LLUUID userID)
  212. {
  213. if (OnSceneGroupGrab != null)
  214. {
  215. OnSceneGroupGrab(groupID, offset, userID);
  216. }
  217. }
  218. public void TriggerLandObjectAdded(Land newParcel, LLUUID regionID)
  219. {
  220. if (OnLandObjectAdded != null)
  221. {
  222. OnLandObjectAdded(newParcel, regionID);
  223. }
  224. }
  225. public void TriggerLandObjectRemoved(LLUUID globalID)
  226. {
  227. if (OnLandObjectRemoved != null)
  228. {
  229. OnLandObjectRemoved(globalID);
  230. }
  231. }
  232. public void TriggerLandObjectUpdated(uint localParcelID, Land newParcel)
  233. {
  234. //triggerLandObjectRemoved(localParcelID);
  235. TriggerLandObjectAdded(newParcel, newParcel.m_scene.RegionInfo.RegionID);
  236. }
  237. public void TriggerAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, LLUUID regionID)
  238. {
  239. if (OnAvatarEnteringNewParcel != null)
  240. {
  241. OnAvatarEnteringNewParcel(avatar, localLandID, regionID);
  242. }
  243. }
  244. ///<summary>Used to pass instnat messages around between the Scene, the Friends Module and the Instant Messsage Module</summary>
  245. ///<param name="message">Object containing the Instant Message Data</param>
  246. ///<param name="whichModule">A bit vector containing the modules to send the message to</param>
  247. public void TriggerGridInstantMessage(GridInstantMessage message, InstantMessageReceiver whichModule)
  248. {
  249. if ((whichModule & InstantMessageReceiver.IMModule) != 0)
  250. {
  251. if (OnGridInstantMessageToIMModule != null)
  252. {
  253. OnGridInstantMessageToIMModule(message);
  254. }
  255. }
  256. if ((whichModule & InstantMessageReceiver.FriendsModule) != 0)
  257. {
  258. if (OnGridInstantMessageToFriendsModule != null)
  259. {
  260. OnGridInstantMessageToFriendsModule(message);
  261. }
  262. }
  263. }
  264. public void TriggerClientClosed(LLUUID ClientID)
  265. {
  266. if (OnClientClosed != null)
  267. {
  268. OnClientClosed(ClientID);
  269. }
  270. }
  271. }
  272. }