INPCModule.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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 OpenSimulator 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. using OpenMetaverse;
  28. using OpenSim.Framework;
  29. using OpenSim.Region.Framework.Scenes;
  30. namespace OpenSim.Region.Framework.Interfaces
  31. {
  32. /// <summary>
  33. /// Temporary interface. More methods to come at some point to make NPCs
  34. /// more object oriented rather than controlling purely through module
  35. /// level interface calls (e.g. sit/stand).
  36. /// </summary>
  37. public interface INPC
  38. {
  39. /// <summary>
  40. /// Should this NPC be sensed by LSL sensors as an 'agent'
  41. /// (interpreted here to mean a normal user) rather than an OpenSim
  42. /// specific NPC extension?
  43. /// </summary>
  44. bool SenseAsAgent { get; }
  45. }
  46. public interface INPCModule
  47. {
  48. /// <summary>
  49. /// Create an NPC
  50. /// </summary>
  51. /// <param name="firstname"></param>
  52. /// <param name="lastname"></param>
  53. /// <param name="position"></param>
  54. /// <param name="senseAsAgent">
  55. /// Make the NPC show up as an agent on LSL sensors. The default is
  56. /// that they show up as the NPC type instead, but this is currently
  57. /// an OpenSim-only extension.
  58. /// </param>
  59. /// <param name="scene"></param>
  60. /// <param name="appearance">
  61. /// The avatar appearance to use for the new NPC.
  62. /// </param>
  63. /// <returns>
  64. /// The UUID of the ScenePresence created. UUID.Zero if there was a
  65. /// failure.
  66. /// </returns>
  67. UUID CreateNPC(string firstname, string lastname, Vector3 position,
  68. UUID owner, bool senseAsAgent, Scene scene,
  69. AvatarAppearance appearance);
  70. /// <summary>
  71. /// Create an NPC with a user-supplied agentID
  72. /// </summary>
  73. /// <param name="firstname"></param>
  74. /// <param name="lastname"></param>
  75. /// <param name="position"></param>
  76. /// <param name="agentID"></param>
  77. /// The desired agent ID
  78. /// <param name="owner"></param>
  79. /// <param name="senseAsAgent">
  80. /// Make the NPC show up as an agent on LSL sensors. The default is
  81. /// that they show up as the NPC type instead, but this is currently
  82. /// an OpenSim-only extension.
  83. /// </param>
  84. /// <param name="scene"></param>
  85. /// <param name="appearance">
  86. /// The avatar appearance to use for the new NPC.
  87. /// </param>
  88. /// <returns>
  89. /// The UUID of the ScenePresence created. UUID.Zero if there was a
  90. /// failure.
  91. /// </returns>
  92. UUID CreateNPC(string firstname, string lastname,
  93. Vector3 position, UUID agentID, UUID owner, bool senseAsAgent, Scene scene,
  94. AvatarAppearance appearance);
  95. /// <summary>
  96. /// Check if the agent is an NPC.
  97. /// </summary>
  98. /// <param name="agentID"></param>
  99. /// <param name="scene"></param>
  100. /// <returns>
  101. /// True if the agent is an NPC in the given scene. False otherwise.
  102. /// </returns>
  103. bool IsNPC(UUID agentID, Scene scene);
  104. /// <summary>
  105. /// Get the NPC.
  106. /// </summary>
  107. /// <remarks>
  108. /// This is not currently complete - manipulation of NPCs still occurs
  109. /// through the region interface.
  110. /// </remarks>
  111. /// <param name="agentID"></param>
  112. /// <param name="scene"></param>
  113. /// <returns>The NPC. null if it does not exist.</returns>
  114. INPC GetNPC(UUID agentID, Scene scene);
  115. /// <summary>
  116. /// Check if the caller has permission to manipulate the given NPC.
  117. /// </summary>
  118. /// <remarks>
  119. /// A caller has permission if
  120. /// * An NPC exists with the given npcID.
  121. /// * The caller UUID given is UUID.Zero.
  122. /// * The avatar is unowned (owner is UUID.Zero).
  123. /// * The avatar is owned and the owner and callerID match.
  124. /// * The avatar is owned and the callerID matches its agentID.
  125. /// </remarks>
  126. /// <param name="av"></param>
  127. /// <param name="callerID"></param>
  128. /// <returns>true if they do, false if they don't.</returns>
  129. /// <param name="npcID"></param>
  130. /// <param name="callerID"></param>
  131. /// <returns>
  132. /// true if they do, false if they don't or if there's no NPC with the
  133. /// given ID.
  134. /// </returns>
  135. bool CheckPermissions(UUID npcID, UUID callerID);
  136. /// <summary>
  137. /// Set the appearance for an NPC.
  138. /// </summary>
  139. /// <param name="agentID"></param>
  140. /// <param name="appearance"></param>
  141. /// <param name="scene"></param>
  142. /// <returns>
  143. /// True if the operation succeeded, false if there was no such agent
  144. /// or the agent was not an NPC.
  145. /// </returns>
  146. bool SetNPCAppearance(UUID agentID, AvatarAppearance appearance,
  147. Scene scene);
  148. /// <summary>
  149. /// Move an NPC to a target over time.
  150. /// </summary>
  151. /// <param name="agentID">The UUID of the NPC</param>
  152. /// <param name="scene"></param>
  153. /// <param name="pos"></param>
  154. /// <param name="noFly">
  155. /// If true, then the avatar will attempt to walk to the location even
  156. /// if it's up in the air. This is to allow walking on prims.
  157. /// </param>
  158. /// <param name="landAtTarget">
  159. /// If true and the avatar is flying when it reaches the target, land.
  160. /// </param> name="running">
  161. /// If true, NPC moves with running speed.
  162. /// <returns>
  163. /// True if the operation succeeded, false if there was no such agent
  164. /// or the agent was not an NPC.
  165. /// </returns>
  166. bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly,
  167. bool landAtTarget, bool running);
  168. /// <summary>
  169. /// Stop the NPC's current movement.
  170. /// </summary>
  171. /// <param name="agentID">The UUID of the NPC</param>
  172. /// <param name="scene"></param>
  173. /// <returns>
  174. /// True if the operation succeeded, false if there was no such agent
  175. /// or the agent was not an NPC.
  176. /// </returns>
  177. bool StopMoveToTarget(UUID agentID, Scene scene);
  178. /// <summary>
  179. /// Get the NPC to say something.
  180. /// </summary>
  181. /// <param name="agentID">The UUID of the NPC</param>
  182. /// <param name="scene"></param>
  183. /// <param name="text"></param>
  184. /// <returns>
  185. /// True if the operation succeeded, false if there was no such agent
  186. /// or the agent was not an NPC.
  187. /// </returns>
  188. bool Say(UUID agentID, Scene scene, string text);
  189. /// <summary>
  190. /// Get the NPC to say something.
  191. /// </summary>
  192. /// <param name="agentID">The UUID of the NPC</param>
  193. /// <param name="scene"></param>
  194. /// <param name="text"></param>
  195. /// <param name="channel"></param>
  196. /// <returns>
  197. /// True if the operation succeeded, false if there was no such agent
  198. /// or the agent was not an NPC.
  199. /// </returns>
  200. bool Say(UUID agentID, Scene scene, string text, int channel);
  201. /// <summary>
  202. /// Get the NPC to shout something.
  203. /// </summary>
  204. /// <param name="agentID">The UUID of the NPC</param>
  205. /// <param name="scene"></param>
  206. /// <param name="text"></param>
  207. /// <param name="channel"></param>
  208. /// <returns>
  209. /// True if the operation succeeded, false if there was no such agent
  210. /// or the agent was not an NPC.
  211. /// </returns>
  212. bool Shout(UUID agentID, Scene scene, string text, int channel);
  213. /// <summary>
  214. /// Get the NPC to whisper something.
  215. /// </summary>
  216. /// <param name="agentID">The UUID of the NPC</param>
  217. /// <param name="scene"></param>
  218. /// <param name="text"></param>
  219. /// <param name="channel"></param>
  220. /// <returns>
  221. /// True if the operation succeeded, false if there was no such agent
  222. /// or the agent was not an NPC.
  223. /// </returns>
  224. bool Whisper(UUID agentID, Scene scene, string text, int channel);
  225. /// <summary>
  226. /// Sit the NPC.
  227. /// </summary>
  228. /// <param name="agentID"></param>
  229. /// <param name="partID"></param>
  230. /// <param name="scene"></param>
  231. /// <returns>true if the sit succeeded, false if not</returns>
  232. bool Sit(UUID agentID, UUID partID, Scene scene);
  233. /// <summary>
  234. /// Stand a sitting NPC.
  235. /// </summary>
  236. /// <param name="agentID"></param>
  237. /// <param name="scene"></param>
  238. /// <returns>true if the stand succeeded, false if not</returns>
  239. bool Stand(UUID agentID, Scene scene);
  240. /// <summary>
  241. /// Get the NPC to touch an object.
  242. /// </summary>
  243. /// <param name="agentID"></param>
  244. /// <param name="partID"></param>
  245. /// <returns>
  246. /// true if the touch is actually attempted, false if not.
  247. /// </returns>
  248. bool Touch(UUID agentID, UUID partID);
  249. /// <summary>
  250. /// Delete an NPC.
  251. /// </summary>
  252. /// <param name="agentID">The UUID of the NPC</param>
  253. /// <param name="scene"></param>
  254. /// <returns>
  255. /// True if the operation succeeded, false if there was no such agent
  256. /// or the agent was not an NPC.
  257. /// </returns>
  258. bool DeleteNPC(UUID agentID, Scene scene);
  259. /// <summary>
  260. /// Get the owner of a NPC
  261. /// </summary>
  262. /// <param name="agentID">The UUID of the NPC</param>
  263. /// <returns>
  264. /// UUID of owner if the NPC exists, UUID.Zero if there was no such
  265. /// agent, the agent is unowned or the agent was not an NPC.
  266. /// </returns>
  267. UUID GetOwner(UUID agentID);
  268. }
  269. }