29 using System.Collections.Generic;
30 using System.Reflection;
34 using NUnit.Framework;
36 using OpenMetaverse.Assets;
37 using OpenMetaverse.StructuredData;
38 using OpenSim.Framework;
39 using OpenSim.Region.CoreModules.Avatar.Attachments;
40 using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
41 using OpenSim.Region.OptionalModules.World.NPC;
42 using OpenSim.Region.Framework.Scenes;
43 using OpenSim.Region.ScriptEngine.Shared;
44 using OpenSim.Region.ScriptEngine.Shared.Api;
45 using OpenSim.Region.ScriptEngine.Shared.Instance;
46 using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
47 using OpenSim.Services.Interfaces;
48 using OpenSim.Tests.Common;
50 namespace OpenSim.
Region.ScriptEngine.Shared.Tests
66 IConfigSource initConfigSource =
new IniConfigSource();
67 IConfig config = initConfigSource.AddConfig(
"XEngine");
68 config.Set(
"Enabled",
"true");
69 config.Set(
"AllowOSFunctions",
"true");
70 config.Set(
"OSFunctionThreatLevel",
"Severe");
71 config = initConfigSource.AddConfig(
"NPC");
72 config.Set(
"Enabled",
"true");
75 SceneHelpers.SetupSceneModules(
79 m_engine.Initialise(initConfigSource);
80 m_engine.AddRegion(m_scene);
89 TestHelpers.InMethod();
92 UUID userId = TestHelpers.ParseTail(0x1);
93 float newHeight = 1.9f;
95 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
96 sp.Appearance.AvatarHeight = newHeight;
99 m_scene.AddSceneObject(so);
102 osslApi.Initialize(m_engine, part, null);
104 string notecardName =
"appearanceNc";
105 osslApi.osOwnerSaveAppearance(notecardName);
108 string npcRaw = osslApi.osNpcCreate(
"Jane",
"Doe",
new LSL_Types.Vector3(128, 128, 128), notecardName);
109 Assert.That(npcRaw, Is.Not.Null);
111 UUID npcId =
new UUID(npcRaw);
113 Assert.That(npc, Is.Not.Null);
114 Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
120 TestHelpers.InMethod();
122 UUID userId = TestHelpers.ParseTail(0x1);
125 m_scene.AddSceneObject(so);
128 osslApi.Initialize(m_engine, so.RootPart, null);
130 bool gotExpectedException =
false;
133 osslApi.osNpcCreate(
"Jane",
"Doe",
new LSL_Types.Vector3(128, 128, 128),
"not existing notecard name");
137 gotExpectedException =
true;
140 Assert.That(gotExpectedException, Is.True);
149 TestHelpers.InMethod();
153 UUID userId = TestHelpers.ParseTail(0x1);
154 float newHeight = 1.9f;
156 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
157 sp.Appearance.AvatarHeight = newHeight;
160 m_scene.AddSceneObject(so);
163 osslApi.Initialize(m_engine, part, null);
165 string notecardName =
"appearanceNc";
166 osslApi.osOwnerSaveAppearance(notecardName);
169 string npcRaw = osslApi.osNpcCreate(
"Jane",
"Doe",
new LSL_Types.Vector3(128, 128, 128), sp.
UUID.ToString());
170 Assert.That(npcRaw, Is.Not.Null);
172 UUID npcId =
new UUID(npcRaw);
174 Assert.That(npc, Is.Not.Null);
175 Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
181 TestHelpers.InMethod();
185 UUID userId = TestHelpers.ParseTail(0x1);
186 float firstHeight = 1.9f;
187 float secondHeight = 2.1f;
188 string firstAppearanceNcName =
"appearanceNc1";
189 string secondAppearanceNcName =
"appearanceNc2";
191 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
192 sp.Appearance.AvatarHeight = firstHeight;
195 m_scene.AddSceneObject(so);
198 osslApi.Initialize(m_engine, part, null);
200 osslApi.osOwnerSaveAppearance(firstAppearanceNcName);
203 = osslApi.osNpcCreate(
"Jane",
"Doe",
new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName);
206 sp.Appearance.AvatarHeight = secondHeight;
207 osslApi.osOwnerSaveAppearance(secondAppearanceNcName);
209 osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName);
211 UUID npcId =
new UUID(npcRaw);
213 Assert.That(npc, Is.Not.Null);
214 Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(secondHeight));
220 TestHelpers.InMethod();
223 UUID userId = TestHelpers.ParseTail(0x1);
224 float firstHeight = 1.9f;
226 string firstAppearanceNcName =
"appearanceNc1";
227 string secondAppearanceNcName =
"appearanceNc2";
229 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
230 sp.Appearance.AvatarHeight = firstHeight;
233 m_scene.AddSceneObject(so);
236 osslApi.Initialize(m_engine, part, null);
238 osslApi.osOwnerSaveAppearance(firstAppearanceNcName);
241 = osslApi.osNpcCreate(
"Jane",
"Doe",
new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName);
243 bool gotExpectedException =
false;
246 osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName);
250 gotExpectedException =
true;
253 Assert.That(gotExpectedException, Is.True);
255 UUID npcId =
new UUID(npcRaw);
257 Assert.That(npc, Is.Not.Null);
258 Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(firstHeight));
267 TestHelpers.InMethod();
270 UUID userId = TestHelpers.ParseTail(0x1);
271 UUID otherUserId = TestHelpers.ParseTail(0x2);
272 float newHeight = 1.9f;
274 SceneHelpers.AddScenePresence(m_scene, otherUserId);
276 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
277 sp.Appearance.AvatarHeight = newHeight;
281 m_scene.AddSceneObject(so);
283 SceneObjectGroup otherSo = SceneHelpers.CreateSceneObject(1, otherUserId, 0x20);
285 m_scene.AddSceneObject(otherSo);
288 osslApi.Initialize(m_engine, part, null);
291 otherOsslApi.Initialize(m_engine, otherPart, null);
293 string notecardName =
"appearanceNc";
294 osslApi.osOwnerSaveAppearance(notecardName);
297 = osslApi.osNpcCreate(
300 otherOsslApi.osNpcRemove(npcRaw);
303 UUID npcId =
new UUID(npcRaw);
305 Assert.That(npc, Is.Not.Null);
307 osslApi.osNpcRemove(npcRaw);
309 npc = m_scene.GetScenePresence(npcId);
312 Assert.That(npc, Is.Null);
321 TestHelpers.InMethod();
325 UUID userId = TestHelpers.ParseTail(0x1);
326 float newHeight = 1.9f;
328 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
329 sp.Appearance.AvatarHeight = newHeight;
332 m_scene.AddSceneObject(so);
335 osslApi.Initialize(m_engine, part, null);
337 string notecardName =
"appearanceNc";
338 osslApi.osOwnerSaveAppearance(notecardName);
341 = osslApi.osNpcCreate(
344 osslApi.osNpcRemove(npcRaw);
346 UUID npcId =
new UUID(npcRaw);
348 Assert.That(npc, Is.Null);
void TestOsNpcCreateUsingAppearanceFromAvatar()
Test creation of an NPC where the appearance data comes from an avatar already in the region...
const int OS_NPC_CREATOR_OWNED
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
void TestOsNpcLoadAppearance()
void TestOsNpcRemoveUnowned()
Test removal of an unowned NPC.
Helpers for setting up scenes.
void TestOsNpcCreateNotExistingNotecard()
void TestOsNpcCreateUsingAppearanceFromNotecard()
Test creation of an NPC where the appearance data comes from a notecard
const int OS_NPC_NOT_OWNED
void TestOsNpcLoadAppearanceNotExistingNotecard()
void TestOsNpcRemoveOwned()
Test removal of an owned NPC.