diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/World/NPC')
3 files changed, 32 insertions, 10 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 6a6c4c3..6d40a92 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | |||
@@ -31,13 +31,16 @@ using System.Net; | |||
31 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using OpenMetaverse.Packets; | 32 | using OpenMetaverse.Packets; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Region.Framework.Interfaces; | ||
34 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
35 | using OpenSim.Region.CoreModules.World.Estate; | 36 | using OpenSim.Region.CoreModules.World.Estate; |
36 | 37 | ||
37 | namespace OpenSim.Region.OptionalModules.World.NPC | 38 | namespace OpenSim.Region.OptionalModules.World.NPC |
38 | { | 39 | { |
39 | public class NPCAvatar : IClientAPI | 40 | public class NPCAvatar : IClientAPI, INPC |
40 | { | 41 | { |
42 | public bool SenseAsAgent { get; set; } | ||
43 | |||
41 | private readonly string m_firstname; | 44 | private readonly string m_firstname; |
42 | private readonly string m_lastname; | 45 | private readonly string m_lastname; |
43 | private readonly Vector3 m_startPos; | 46 | private readonly Vector3 m_startPos; |
@@ -45,13 +48,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
45 | private readonly Scene m_scene; | 48 | private readonly Scene m_scene; |
46 | private readonly UUID m_ownerID; | 49 | private readonly UUID m_ownerID; |
47 | 50 | ||
48 | public NPCAvatar(string firstname, string lastname, Vector3 position, UUID ownerID, Scene scene) | 51 | public NPCAvatar( |
52 | string firstname, string lastname, Vector3 position, UUID ownerID, bool senseAsAgent, Scene scene) | ||
49 | { | 53 | { |
50 | m_firstname = firstname; | 54 | m_firstname = firstname; |
51 | m_lastname = lastname; | 55 | m_lastname = lastname; |
52 | m_startPos = position; | 56 | m_startPos = position; |
53 | m_scene = scene; | 57 | m_scene = scene; |
54 | m_ownerID = ownerID; | 58 | m_ownerID = ownerID; |
59 | SenseAsAgent = senseAsAgent; | ||
55 | } | 60 | } |
56 | 61 | ||
57 | public IScene Scene | 62 | public IScene Scene |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index d90309f..3831d7a 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | |||
@@ -109,9 +109,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
109 | } | 109 | } |
110 | 110 | ||
111 | public UUID CreateNPC( | 111 | public UUID CreateNPC( |
112 | string firstname, string lastname, Vector3 position, UUID owner, Scene scene, AvatarAppearance appearance) | 112 | string firstname, |
113 | string lastname, | ||
114 | Vector3 position, | ||
115 | UUID owner, | ||
116 | bool senseAsAgent, | ||
117 | Scene scene, | ||
118 | AvatarAppearance appearance) | ||
113 | { | 119 | { |
114 | NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, scene); | 120 | NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, senseAsAgent, scene); |
115 | npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); | 121 | npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); |
116 | 122 | ||
117 | m_log.DebugFormat( | 123 | m_log.DebugFormat( |
@@ -266,6 +272,17 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
266 | return UUID.Zero; | 272 | return UUID.Zero; |
267 | } | 273 | } |
268 | 274 | ||
275 | public INPC GetNPC(UUID agentID, Scene scene) | ||
276 | { | ||
277 | lock (m_avatars) | ||
278 | { | ||
279 | if (m_avatars.ContainsKey(agentID)) | ||
280 | return m_avatars[agentID]; | ||
281 | else | ||
282 | return null; | ||
283 | } | ||
284 | } | ||
285 | |||
269 | public bool DeleteNPC(UUID agentID, Scene scene) | 286 | public bool DeleteNPC(UUID agentID, Scene scene) |
270 | { | 287 | { |
271 | lock (m_avatars) | 288 | lock (m_avatars) |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index d21d601..d507822 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | |||
@@ -109,7 +109,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
109 | afm.SetAppearance(sp, originalTe, null); | 109 | afm.SetAppearance(sp, originalTe, null); |
110 | 110 | ||
111 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); | 111 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); |
112 | UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, scene, sp.Appearance); | 112 | UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance); |
113 | 113 | ||
114 | ScenePresence npc = scene.GetScenePresence(npcId); | 114 | ScenePresence npc = scene.GetScenePresence(npcId); |
115 | 115 | ||
@@ -129,7 +129,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
129 | 129 | ||
130 | Vector3 startPos = new Vector3(128, 128, 30); | 130 | Vector3 startPos = new Vector3(128, 128, 30); |
131 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); | 131 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); |
132 | UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, scene, sp.Appearance); | 132 | UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance); |
133 | 133 | ||
134 | npcModule.DeleteNPC(npcId, scene); | 134 | npcModule.DeleteNPC(npcId, scene); |
135 | 135 | ||
@@ -157,7 +157,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
157 | am.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest); | 157 | am.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest); |
158 | 158 | ||
159 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); | 159 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); |
160 | UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, scene, sp.Appearance); | 160 | UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance); |
161 | 161 | ||
162 | ScenePresence npc = scene.GetScenePresence(npcId); | 162 | ScenePresence npc = scene.GetScenePresence(npcId); |
163 | 163 | ||
@@ -189,7 +189,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
189 | 189 | ||
190 | Vector3 startPos = new Vector3(128, 128, 30); | 190 | Vector3 startPos = new Vector3(128, 128, 30); |
191 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); | 191 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); |
192 | UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, scene, sp.Appearance); | 192 | UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance); |
193 | 193 | ||
194 | ScenePresence npc = scene.GetScenePresence(npcId); | 194 | ScenePresence npc = scene.GetScenePresence(npcId); |
195 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); | 195 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); |
@@ -260,7 +260,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
260 | 260 | ||
261 | Vector3 startPos = new Vector3(128, 128, 30); | 261 | Vector3 startPos = new Vector3(128, 128, 30); |
262 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); | 262 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); |
263 | UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, scene, sp.Appearance); | 263 | UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance); |
264 | 264 | ||
265 | ScenePresence npc = scene.GetScenePresence(npcId); | 265 | ScenePresence npc = scene.GetScenePresence(npcId); |
266 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); | 266 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); |
@@ -293,7 +293,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
293 | Vector3 startPos = new Vector3(1, 1, 1); | 293 | Vector3 startPos = new Vector3(1, 1, 1); |
294 | 294 | ||
295 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); | 295 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); |
296 | UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, scene, sp.Appearance); | 296 | UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, true, scene, sp.Appearance); |
297 | 297 | ||
298 | ScenePresence npc = scene.GetScenePresence(npcId); | 298 | ScenePresence npc = scene.GetScenePresence(npcId); |
299 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); | 299 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); |