Implement osNpcSit(). This is still in development so don't trust it
Format is osNpcSit(<npc-uuid>, <target-uuid>, OS_NPC_SIT_IMMEDIATE) e.g. osNpcSit(npc, llGetKey(), OS_NPC_SIT_IMMEDIATE); At the moment, sit only succeeds if the part has a sit target set. NPC immediately sits on the target even if miles away - they do not walk up to it. This method is in development - it may change so please don't trust it yet. Standing will follow shortly since that's kind of important once you're sitting :)remove-scene-viewer
parent
bbd0e68c06
commit
0c041ce12f
|
@ -94,6 +94,15 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
/// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns>
|
||||
bool Say(UUID agentID, Scene scene, string text);
|
||||
|
||||
/// <summary>
|
||||
/// Sit the NPC.
|
||||
/// </summary>
|
||||
/// <param name="agentID"></param>
|
||||
/// <param name="partID"></param>
|
||||
/// <param name="scene"></param>
|
||||
/// <returns>true if the sit succeeded, false if not</returns>
|
||||
bool Sit(UUID agentID, UUID partID, Scene scene);
|
||||
|
||||
/// <summary>
|
||||
/// Delete an NPC.
|
||||
/// </summary>
|
||||
|
|
|
@ -1220,14 +1220,12 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public UUID SitTargetAvatar
|
||||
{
|
||||
get { return m_sitTargetAvatar; }
|
||||
set { m_sitTargetAvatar = value; }
|
||||
}
|
||||
|
||||
|
||||
public virtual UUID RegionID
|
||||
{
|
||||
get
|
||||
|
|
|
@ -615,13 +615,13 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
set { m_isChildAgent = value; }
|
||||
}
|
||||
|
||||
private uint m_parentID;
|
||||
|
||||
public uint ParentID
|
||||
{
|
||||
get { return m_parentID; }
|
||||
set { m_parentID = value; }
|
||||
}
|
||||
private uint m_parentID;
|
||||
|
||||
public float Health
|
||||
{
|
||||
get { return m_health; }
|
||||
|
@ -1962,6 +1962,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
)
|
||||
));
|
||||
|
||||
// m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied);
|
||||
|
||||
if (SitTargetisSet && SitTargetUnOccupied)
|
||||
{
|
||||
part.SitTargetAvatar = UUID;
|
||||
|
@ -2256,7 +2258,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
*/
|
||||
|
||||
|
||||
public void HandleAgentSit(IClientAPI remoteClient, UUID agentID)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(m_nextSitAnimation))
|
||||
|
|
|
@ -199,6 +199,24 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
|||
return false;
|
||||
}
|
||||
|
||||
public bool Sit(UUID agentID, UUID partID, Scene scene)
|
||||
{
|
||||
lock (m_avatars)
|
||||
{
|
||||
if (m_avatars.ContainsKey(agentID))
|
||||
{
|
||||
ScenePresence sp;
|
||||
scene.TryGetScenePresence(agentID, out sp);
|
||||
sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero);
|
||||
sp.HandleAgentSit(m_avatars[agentID], agentID);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool DeleteNPC(UUID agentID, Scene scene)
|
||||
{
|
||||
lock (m_avatars)
|
||||
|
|
|
@ -229,5 +229,29 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
|
|||
Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on second move");
|
||||
Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSit()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
|
||||
|
||||
Vector3 startPos = new Vector3(128, 128, 30);
|
||||
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
|
||||
UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance);
|
||||
|
||||
ScenePresence npc = scene.GetScenePresence(npcId);
|
||||
SceneObjectPart part = SceneHelpers.AddSceneObject(scene);
|
||||
|
||||
// We must have a non Vector3.Zero sit target position otherwise part.SitTargetAvatar doesn't get set!
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -687,6 +687,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
/// <param name="g2">another geometry or space</param>
|
||||
private void near(IntPtr space, IntPtr g1, IntPtr g2)
|
||||
{
|
||||
// m_log.DebugFormat("[PHYSICS]: Colliding {0} and {1} in {2}", g1, g2, space);
|
||||
// no lock here! It's invoked from within Simulate(), which is thread-locked
|
||||
|
||||
// Test if we're colliding a geom with a space.
|
||||
|
|
|
@ -2351,6 +2351,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
}
|
||||
}
|
||||
|
||||
public void osNpcSit(LSL_Key npc, LSL_Key target, int options)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osNpcSit");
|
||||
|
||||
INPCModule module = World.RequestModuleInterface<INPCModule>();
|
||||
if (module != null)
|
||||
{
|
||||
module.Sit(new UUID(npc.m_string), new UUID(target.m_string), World);
|
||||
}
|
||||
}
|
||||
|
||||
public void osNpcRemove(LSL_Key npc)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osNpcRemove");
|
||||
|
|
|
@ -178,6 +178,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
|||
void osNpcSetRot(LSL_Key npc, rotation rot);
|
||||
void osNpcStopMoveToTarget(LSL_Key npc);
|
||||
void osNpcSay(key npc, string message);
|
||||
void osNpcSit(key npc, key target, int options);
|
||||
void osNpcRemove(key npc);
|
||||
|
||||
LSL_Key osOwnerSaveAppearance(string notecard);
|
||||
|
|
|
@ -600,6 +600,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
|||
public const int OS_NPC_NO_FLY = 1;
|
||||
public const int OS_NPC_LAND_AT_TARGET = 2;
|
||||
|
||||
public const int OS_NPC_SIT_IMMEDIATE = 0;
|
||||
|
||||
public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED";
|
||||
public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED";
|
||||
|
||||
|
|
|
@ -528,6 +528,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
|||
m_OSSL_Functions.osNpcSay(npc, message);
|
||||
}
|
||||
|
||||
public void osNpcSit(LSL_Key npc, LSL_Key target, int options)
|
||||
{
|
||||
m_OSSL_Functions.osNpcSit(npc, target, options);
|
||||
}
|
||||
|
||||
public void osNpcRemove(key npc)
|
||||
{
|
||||
m_OSSL_Functions.osNpcRemove(npc);
|
||||
|
|
Loading…
Reference in New Issue