diff options
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
Diffstat (limited to 'OpenSim/Region/OptionalModules')
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 23 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 46 |
2 files changed, 57 insertions, 12 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 78e9b29..68f21c8 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | |||
@@ -88,25 +88,26 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
88 | 88 | ||
89 | public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene) | 89 | public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene) |
90 | { | 90 | { |
91 | ScenePresence sp = scene.GetScenePresence(agentId); | 91 | ScenePresence npc = scene.GetScenePresence(agentId); |
92 | if (sp == null || sp.IsChildAgent) | 92 | if (npc == null || npc.IsChildAgent) |
93 | return false; | 93 | return false; |
94 | 94 | ||
95 | lock (m_avatars) | 95 | lock (m_avatars) |
96 | if (!m_avatars.ContainsKey(agentId)) | 96 | if (!m_avatars.ContainsKey(agentId)) |
97 | return false; | 97 | return false; |
98 | 98 | ||
99 | // Delete existing sp attachments | 99 | // Delete existing npc attachments |
100 | scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false); | 100 | scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false); |
101 | |||
102 | AvatarAppearance app = new AvatarAppearance(appearance, true); | ||
103 | sp.Appearance = app; | ||
104 | 101 | ||
105 | // Set new sp appearance. Also sends to clients. | 102 | // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet since it doesn't transfer attachments |
106 | scene.RequestModuleInterface<IAvatarFactoryModule>().SetAppearance(sp, app); | 103 | AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); |
104 | npc.Appearance = npcAppearance; | ||
107 | 105 | ||
108 | // Rez needed sp attachments | 106 | // Rez needed npc attachments |
109 | scene.AttachmentsModule.RezAttachments(sp); | 107 | scene.AttachmentsModule.RezAttachments(npc); |
108 | |||
109 | IAvatarFactoryModule module = scene.RequestModuleInterface<IAvatarFactoryModule>(); | ||
110 | module.SendAppearance(npc.UUID); | ||
110 | 111 | ||
111 | return true; | 112 | return true; |
112 | } | 113 | } |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index d507822..36e2d4a 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | |||
@@ -139,7 +139,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
139 | } | 139 | } |
140 | 140 | ||
141 | [Test] | 141 | [Test] |
142 | public void TestAttachments() | 142 | public void TestCreateWithAttachments() |
143 | { | 143 | { |
144 | TestHelpers.InMethod(); | 144 | TestHelpers.InMethod(); |
145 | // log4net.Config.XmlConfigurator.Configure(); | 145 | // log4net.Config.XmlConfigurator.Configure(); |
@@ -179,6 +179,50 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
179 | } | 179 | } |
180 | 180 | ||
181 | [Test] | 181 | [Test] |
182 | public void TestLoadAppearance() | ||
183 | { | ||
184 | TestHelpers.InMethod(); | ||
185 | // log4net.Config.XmlConfigurator.Configure(); | ||
186 | |||
187 | UUID userId = TestHelpers.ParseTail(0x1); | ||
188 | UserAccountHelpers.CreateUserWithInventory(scene, userId); | ||
189 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); | ||
190 | |||
191 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); | ||
192 | UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance); | ||
193 | |||
194 | // Now add the attachment to the original avatar and use that to load a new appearance | ||
195 | // TODO: Could also run tests loading from a notecard though this isn't much different for our purposes here | ||
196 | UUID attItemId = TestHelpers.ParseTail(0x2); | ||
197 | UUID attAssetId = TestHelpers.ParseTail(0x3); | ||
198 | string attName = "att"; | ||
199 | |||
200 | UserInventoryHelpers.CreateInventoryItem(scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object); | ||
201 | |||
202 | am.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest); | ||
203 | |||
204 | npcModule.SetNPCAppearance(npcId, sp.Appearance, scene); | ||
205 | |||
206 | ScenePresence npc = scene.GetScenePresence(npcId); | ||
207 | |||
208 | // Check scene presence status | ||
209 | Assert.That(npc.HasAttachments(), Is.True); | ||
210 | List<SceneObjectGroup> attachments = npc.GetAttachments(); | ||
211 | Assert.That(attachments.Count, Is.EqualTo(1)); | ||
212 | SceneObjectGroup attSo = attachments[0]; | ||
213 | |||
214 | // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item | ||
215 | // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC. | ||
216 | // Assert.That(attSo.Name, Is.EqualTo(attName)); | ||
217 | |||
218 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); | ||
219 | Assert.That(attSo.IsAttachment); | ||
220 | Assert.That(attSo.UsesPhysics, Is.False); | ||
221 | Assert.That(attSo.IsTemporary, Is.False); | ||
222 | Assert.That(attSo.OwnerID, Is.EqualTo(npc.UUID)); | ||
223 | } | ||
224 | |||
225 | [Test] | ||
182 | public void TestMove() | 226 | public void TestMove() |
183 | { | 227 | { |
184 | TestHelpers.InMethod(); | 228 | TestHelpers.InMethod(); |