implement osNpcStopMoveTo() to cancel any current move target

bulletsim
Justin Clark-Casey (justincc) 2011-08-10 00:26:38 +01:00
parent cba54090c7
commit 195c1dc9b8
6 changed files with 66 additions and 9 deletions

View File

@ -566,8 +566,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
/// <param name="silent"></param> /// <param name="silent"></param>
protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent)
{ {
m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", Name, avatar.Name, m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}",
attachmentpoint, attachOffset, so.RootPart.AttachedPos); so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos);
so.DetachFromBackup(); so.DetachFromBackup();

View File

@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="agentID"></param> /// <param name="agentID"></param>
/// <param name="appearance"></param> /// <param name="appearance"></param>
/// <param name="scene"></param> /// <param name="scene"></param>
/// <returns></returns> /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns>
bool SetNPCAppearance(UUID agentID, AvatarAppearance appearance, Scene scene); bool SetNPCAppearance(UUID agentID, AvatarAppearance appearance, Scene scene);
/// <summary> /// <summary>
@ -67,7 +67,16 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="agentID">The UUID of the NPC</param> /// <param name="agentID">The UUID of the NPC</param>
/// <param name="scene"></param> /// <param name="scene"></param>
/// <param name="pos"></param> /// <param name="pos"></param>
void MoveToTarget(UUID agentID, Scene scene, Vector3 pos); /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns>
bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos);
/// <summary>
/// Stop the NPC's current movement.
/// </summary>
/// <param name="agentID">The UUID of the NPC</param>
/// <param name="scene"></param>
/// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns>
bool StopMoveToTarget(UUID agentID, Scene scene);
/// <summary> /// <summary>
/// Get the NPC to say something. /// Get the NPC to say something.
@ -75,13 +84,15 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="agentID">The UUID of the NPC</param> /// <param name="agentID">The UUID of the NPC</param>
/// <param name="scene"></param> /// <param name="scene"></param>
/// <param name="text"></param> /// <param name="text"></param>
void Say(UUID agentID, Scene scene, string text); /// <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> /// <summary>
/// Delete an NPC. /// Delete an NPC.
/// </summary> /// </summary>
/// <param name="agentID">The UUID of the NPC</param> /// <param name="agentID">The UUID of the NPC</param>
/// <param name="scene"></param> /// <param name="scene"></param>
void DeleteNPC(UUID agentID, Scene scene); /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns>
bool DeleteNPC(UUID agentID, Scene scene);
} }
} }

View File

@ -217,7 +217,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
return npcAvatar.AgentId; return npcAvatar.AgentId;
} }
public void MoveToTarget(UUID agentID, Scene scene, Vector3 pos) public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos)
{ {
lock (m_avatars) lock (m_avatars)
{ {
@ -230,22 +230,49 @@ namespace OpenSim.Region.OptionalModules.World.NPC
"[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName);
sp.MoveToTarget(pos); sp.MoveToTarget(pos);
}
return true;
} }
} }
public void Say(UUID agentID, Scene scene, string text) return false;
}
public bool StopMoveToTarget(UUID agentID, Scene scene)
{
lock (m_avatars)
{
if (m_avatars.ContainsKey(agentID))
{
ScenePresence sp;
scene.TryGetScenePresence(agentID, out sp);
sp.Velocity = Vector3.Zero;
sp.ResetMoveToTarget();
return true;
}
}
return false;
}
public bool Say(UUID agentID, Scene scene, string text)
{ {
lock (m_avatars) lock (m_avatars)
{ {
if (m_avatars.ContainsKey(agentID)) if (m_avatars.ContainsKey(agentID))
{ {
m_avatars[agentID].Say(text); m_avatars[agentID].Say(text);
}
return true;
} }
} }
public void DeleteNPC(UUID agentID, Scene scene) return false;
}
public bool DeleteNPC(UUID agentID, Scene scene)
{ {
lock (m_avatars) lock (m_avatars)
{ {
@ -253,8 +280,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC
{ {
scene.RemoveClient(agentID); scene.RemoveClient(agentID);
m_avatars.Remove(agentID); m_avatars.Remove(agentID);
return true;
} }
} }
return false;
} }
public void PostInitialise() public void PostInitialise()

View File

@ -2213,6 +2213,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
public void osNpcStopMoveTo(LSL_Key npc)
{
CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo");
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
module.StopMoveToTarget(new UUID(npc.m_string), World);
}
public void osNpcSay(LSL_Key npc, string message) public void osNpcSay(LSL_Key npc, string message)
{ {
CheckThreatLevel(ThreatLevel.High, "osNpcSay"); CheckThreatLevel(ThreatLevel.High, "osNpcSay");

View File

@ -173,6 +173,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_Key osNpcSaveAppearance(string avatar, string notecardName); LSL_Key osNpcSaveAppearance(string avatar, string notecardName);
void osNpcLoadAppearance(string avatar, string notecardNameOrUuid); void osNpcLoadAppearance(string avatar, string notecardNameOrUuid);
void osNpcMoveTo(key npc, vector position); void osNpcMoveTo(key npc, vector position);
void osNpcStopMoveTo(LSL_Key npc);
void osNpcSay(key npc, string message); void osNpcSay(key npc, string message);
void osNpcRemove(key npc); void osNpcRemove(key npc);

View File

@ -498,6 +498,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_OSSL_Functions.osNpcMoveTo(npc, position); m_OSSL_Functions.osNpcMoveTo(npc, position);
} }
public void osNpcStopMoveTo(LSL_Key npc)
{
m_OSSL_Functions.osNpcStopMoveTo(npc);
}
public void osNpcSay(key npc, string message) public void osNpcSay(key npc, string message)
{ {
m_OSSL_Functions.osNpcSay(npc, message); m_OSSL_Functions.osNpcSay(npc, message);