1
0

INPCModule.cs 12 KB

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