Implement osNpcStand(<npc-id>)

Allows you to stand an NPC that has sat.
remove-scene-viewer
Justin Clark-Casey (justincc) 2011-10-17 01:56:25 +01:00
parent ddcb88ff53
commit de161585c0
6 changed files with 48 additions and 2 deletions

View File

@ -103,6 +103,14 @@ namespace OpenSim.Region.Framework.Interfaces
/// <returns>true if the sit succeeded, false if not</returns>
bool Sit(UUID agentID, UUID partID, Scene scene);
/// <summary>
/// Stand a sitting NPC.
/// </summary>
/// <param name="agentID"></param>
/// <param name="scene"></param>
/// <returns>true if the stand succeeded, false if not</returns>
bool Stand(UUID agentID, Scene scene);
/// <summary>
/// Delete an NPC.
/// </summary>

View File

@ -217,6 +217,23 @@ namespace OpenSim.Region.OptionalModules.World.NPC
return false;
}
public bool Stand(UUID agentID, Scene scene)
{
lock (m_avatars)
{
if (m_avatars.ContainsKey(agentID))
{
ScenePresence sp;
scene.TryGetScenePresence(agentID, out sp);
sp.StandUp();
return true;
}
}
return false;
}
public bool DeleteNPC(UUID agentID, Scene scene)
{
lock (m_avatars)

View File

@ -231,7 +231,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
}
[Test]
public void TestSit()
public void TestSitAndStand()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
@ -249,9 +249,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
part.SitTargetPosition = new Vector3(0, 0, 1);
npcModule.Sit(npc.UUID, part.UUID, scene);
// Assertions?
Assert.That(part.SitTargetAvatar, Is.EqualTo(npcId));
Assert.That(npc.ParentID, Is.EqualTo(part.LocalId));
npcModule.Stand(npc.UUID, scene);
Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
Assert.That(npc.ParentID, Is.EqualTo(0));
}
}
}

View File

@ -2362,6 +2362,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
public void osNpcStand(LSL_Key npc)
{
CheckThreatLevel(ThreatLevel.High, "osNpcStand");
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
{
module.Stand(new UUID(npc.m_string), World);
}
}
public void osNpcRemove(LSL_Key npc)
{
CheckThreatLevel(ThreatLevel.High, "osNpcRemove");

View File

@ -179,6 +179,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
void osNpcStopMoveToTarget(LSL_Key npc);
void osNpcSay(key npc, string message);
void osNpcSit(key npc, key target, int options);
void osNpcStand(LSL_Key npc);
void osNpcRemove(key npc);
LSL_Key osOwnerSaveAppearance(string notecard);

View File

@ -533,6 +533,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_OSSL_Functions.osNpcSit(npc, target, options);
}
public void osNpcStand(LSL_Key npc)
{
m_OSSL_Functions.osNpcStand(npc);
}
public void osNpcRemove(key npc)
{
m_OSSL_Functions.osNpcRemove(npc);