INPCModule.cs 12 KB

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