diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs
index d582149d57..9817cf71b9 100644
--- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs
@@ -32,14 +32,16 @@ using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.Framework.Interfaces
{
///
- /// Temporary interface. More methods to come at some point to make NPCs more object oriented rather than
- /// controlling purely through module level interface calls (e.g. sit/stand).
+ /// Temporary interface. More methods to come at some point to make NPCs
+ /// more object oriented rather than controlling purely through module
+ /// level interface calls (e.g. sit/stand).
///
public interface INPC
{
///
- /// Should this NPC be sensed by LSL sensors as an 'agent' (interpreted here to mean a normal user)
- /// rather than an OpenSim specific NPC extension?
+ /// Should this NPC be sensed by LSL sensors as an 'agent'
+ /// (interpreted here to mean a normal user) rather than an OpenSim
+ /// specific NPC extension?
///
bool SenseAsAgent { get; }
}
@@ -53,35 +55,42 @@ namespace OpenSim.Region.Framework.Interfaces
///
///
///
- /// Make the NPC show up as an agent on LSL sensors. The default is that they
- /// show up as the NPC type instead, but this is currently an OpenSim-only extension.
+ /// Make the NPC show up as an agent on LSL sensors. The default is
+ /// that they show up as the NPC type instead, but this is currently
+ /// an OpenSim-only extension.
///
///
- /// The avatar appearance to use for the new NPC.
- /// The UUID of the ScenePresence created. UUID.Zero if there was a failure.
- UUID CreateNPC(
- string firstname,
- string lastname,
- Vector3 position,
- UUID owner,
- bool senseAsAgent,
- Scene scene,
- AvatarAppearance appearance);
+ ///
+ /// The avatar appearance to use for the new NPC.
+ ///
+ ///
+ /// The UUID of the ScenePresence created. UUID.Zero if there was a
+ /// failure.
+ ///
+ UUID CreateNPC(string firstname, string lastname, Vector3 position,
+ UUID owner, bool senseAsAgent, Scene scene,
+ AvatarAppearance appearance);
///
/// Check if the agent is an NPC.
///
///
///
- /// True if the agent is an NPC in the given scene. False otherwise.
+ ///
+ /// True if the agent is an NPC in the given scene. False otherwise.
+ ///
bool IsNPC(UUID agentID, Scene scene);
///
- /// Get the NPC. This is not currently complete - manipulation of NPCs still occurs through the region interface
+ /// Get the NPC.
///
+ ///
+ /// This is not currently complete - manipulation of NPCs still occurs
+ /// through the region interface.
+ ///
///
///
- /// The NPC. null if it does not exist.
+ /// The NPC. null if it does not exist.
INPC GetNPC(UUID agentID, Scene scene);
///
@@ -89,7 +98,10 @@ namespace OpenSim.Region.Framework.Interfaces
///
///
///
- /// true if they do, false if they don't or if there's no NPC with the given ID.
+ ///
+ /// true if they do, false if they don't or if there's no NPC with the
+ /// given ID.
+ ///
bool CheckPermissions(UUID npcID, UUID callerID);
///
@@ -98,8 +110,12 @@ namespace OpenSim.Region.Framework.Interfaces
///
///
///
- /// True if the operation succeeded, false if there was no such agent or the agent was not an NPC
- bool SetNPCAppearance(UUID agentID, AvatarAppearance appearance, Scene scene);
+ ///
+ /// True if the operation succeeded, false if there was no such agent
+ /// or the agent was not an NPC.
+ ///
+ bool SetNPCAppearance(UUID agentID, AvatarAppearance appearance,
+ Scene scene);
///
/// Move an NPC to a target over time.
@@ -108,23 +124,29 @@ namespace OpenSim.Region.Framework.Interfaces
///
///
///
- /// If true, then the avatar will attempt to walk to the location even if it's up in the air.
- /// This is to allow walking on prims.
+ /// If true, then the avatar will attempt to walk to the location even
+ /// if it's up in the air. This is to allow walking on prims.
///
///
/// If true and the avatar is flying when it reaches the target, land.
/// name="running">
/// If true, NPC moves with running speed.
- /// True if the operation succeeded, false if there was no such agent or the agent was not an NPC
- ///
- bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget, bool running);
+ ///
+ /// True if the operation succeeded, false if there was no such agent
+ /// or the agent was not an NPC.
+ ///
+ bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly,
+ bool landAtTarget, bool running);
///
/// Stop the NPC's current movement.
///
/// The UUID of the NPC
///
- /// True if the operation succeeded, false if there was no such agent or the agent was not an NPC
+ ///
+ /// True if the operation succeeded, false if there was no such agent
+ /// or the agent was not an NPC.
+ ///
bool StopMoveToTarget(UUID agentID, Scene scene);
///
@@ -133,7 +155,10 @@ namespace OpenSim.Region.Framework.Interfaces
/// The UUID of the NPC
///
///
- /// True if the operation succeeded, false if there was no such agent or the agent was not an NPC
+ ///
+ /// True if the operation succeeded, false if there was no such agent
+ /// or the agent was not an NPC.
+ ///
bool Say(UUID agentID, Scene scene, string text);
///
@@ -143,7 +168,10 @@ namespace OpenSim.Region.Framework.Interfaces
///
///
///
- /// True if the operation succeeded, false if there was no such agent or the agent was not an NPC
+ ///
+ /// True if the operation succeeded, false if there was no such agent
+ /// or the agent was not an NPC.
+ ///
bool Say(UUID agentID, Scene scene, string text, int channel);
///
@@ -153,7 +181,10 @@ namespace OpenSim.Region.Framework.Interfaces
///
///
///
- /// True if the operation succeeded, false if there was no such agent or the agent was not an NPC
+ ///
+ /// True if the operation succeeded, false if there was no such agent
+ /// or the agent was not an NPC.
+ ///
bool Shout(UUID agentID, Scene scene, string text, int channel);
///
@@ -163,7 +194,10 @@ namespace OpenSim.Region.Framework.Interfaces
///
///
///
- /// True if the operation succeeded, false if there was no such agent or the agent was not an NPC
+ ///
+ /// True if the operation succeeded, false if there was no such agent
+ /// or the agent was not an NPC.
+ ///
bool Whisper(UUID agentID, Scene scene, string text, int channel);
///
@@ -188,7 +222,9 @@ namespace OpenSim.Region.Framework.Interfaces
///
///
///
- /// true if the touch is actually attempted, false if not
+ ///
+ /// true if the touch is actually attempted, false if not.
+ ///
bool Touch(UUID agentID, UUID partID);
///
@@ -196,14 +232,20 @@ namespace OpenSim.Region.Framework.Interfaces
///
/// The UUID of the NPC
///
- /// True if the operation succeeded, false if there was no such agent or the agent was not an NPC
+ ///
+ /// True if the operation succeeded, false if there was no such agent
+ /// or the agent was not an NPC.
+ ///
bool DeleteNPC(UUID agentID, Scene scene);
///
/// Get the owner of a NPC
///
/// The UUID of the NPC
- /// UUID of owner if the NPC exists, UUID.Zero if there was no such agent, the agent is unowned or the agent was not an NPC
+ ///
+ /// UUID of owner if the NPC exists, UUID.Zero if there was no such
+ /// agent, the agent is unowned or the agent was not an NPC.
+ ///
UUID GetOwner(UUID agentID);
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index b372c88d8a..41e70970cb 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -29,14 +29,16 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using System.Threading;
+using Timer = System.Timers.Timer;
+
using log4net;
using Nini.Config;
using Mono.Addins;
using OpenMetaverse;
+
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Framework;
-using Timer=System.Timers.Timer;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.OptionalModules.World.NPC
@@ -44,9 +46,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
public class NPCModule : INPCModule, ISharedRegionModule
{
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ private static readonly ILog m_log = LogManager.GetLogger(
+ MethodBase.GetCurrentMethod().DeclaringType);
- private Dictionary m_avatars = new Dictionary();
+ private Dictionary m_avatars =
+ new Dictionary();
public bool Enabled { get; private set; }
@@ -89,8 +93,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
public bool IsNPC(UUID agentId, Scene scene)
{
- // FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect
- // that directly).
+ // FIXME: This implementation could not just use the
+ // ScenePresence.PresenceType (and callers could inspect that
+ // directly).
ScenePresence sp = scene.GetScenePresence(agentId);
if (sp == null || sp.IsChildAgent)
return false;
@@ -99,7 +104,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
return m_avatars.ContainsKey(agentId);
}
- public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene)
+ public bool SetNPCAppearance(UUID agentId,
+ AvatarAppearance appearance, Scene scene)
{
ScenePresence npc = scene.GetScenePresence(agentId);
if (npc == null || npc.IsChildAgent)
@@ -112,34 +118,35 @@ namespace OpenSim.Region.OptionalModules.World.NPC
// Delete existing npc attachments
scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false);
- // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet since it doesn't transfer attachments
- AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
+ // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet
+ // since it doesn't transfer attachments
+ AvatarAppearance npcAppearance = new AvatarAppearance(appearance,
+ true);
npc.Appearance = npcAppearance;
-
+
// Rez needed npc attachments
scene.AttachmentsModule.RezAttachments(npc);
- IAvatarFactoryModule module = scene.RequestModuleInterface();
+ IAvatarFactoryModule module =
+ scene.RequestModuleInterface();
module.SendAppearance(npc.UUID);
-
+
return true;
}
- public UUID CreateNPC(
- string firstname,
- string lastname,
- Vector3 position,
- UUID owner,
- bool senseAsAgent,
- Scene scene,
- AvatarAppearance appearance)
+ public UUID CreateNPC(string firstname, string lastname,
+ Vector3 position, UUID owner, bool senseAsAgent, Scene scene,
+ AvatarAppearance appearance)
{
- NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, senseAsAgent, scene);
- npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue);
+ NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position,
+ owner, senseAsAgent, scene);
+ npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0,
+ int.MaxValue);
m_log.DebugFormat(
- "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}",
- firstname, lastname, npcAvatar.AgentId, owner, senseAsAgent, position, scene.RegionInfo.RegionName);
+ "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}",
+ firstname, lastname, npcAvatar.AgentId, owner,
+ senseAsAgent, position, scene.RegionInfo.RegionName);
AgentCircuitData acd = new AgentCircuitData();
acd.AgentID = npcAvatar.AgentId;
@@ -147,42 +154,55 @@ namespace OpenSim.Region.OptionalModules.World.NPC
acd.lastname = lastname;
acd.ServiceURLs = new Dictionary();
- AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
+ AvatarAppearance npcAppearance = new AvatarAppearance(appearance,
+ true);
acd.Appearance = npcAppearance;
-// for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++)
-// {
-// m_log.DebugFormat(
-// "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}",
-// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);
-// }
+ /*
+ for (int i = 0;
+ i < acd.Appearance.Texture.FaceTextures.Length; i++)
+ {
+ m_log.DebugFormat(
+ "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}",
+ acd.AgentID, i,
+ acd.Appearance.Texture.FaceTextures[i]);
+ }
+ */
lock (m_avatars)
{
- scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
+ scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode,
+ acd);
scene.AddNewClient(npcAvatar, PresenceType.Npc);
ScenePresence sp;
if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
{
-// m_log.DebugFormat(
-// "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
+ /*
+ m_log.DebugFormat(
+ "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}",
+ sp.Name, sp.UUID);
+ */
sp.CompleteMovement(npcAvatar, false);
m_avatars.Add(npcAvatar.AgentId, npcAvatar);
- m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name);
+ m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}",
+ npcAvatar.AgentId, sp.Name);
return npcAvatar.AgentId;
}
else
{
- m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
+ m_log.WarnFormat(
+ "[NPC MODULE]: Could not find scene presence for NPC {0} {1}",
+ sp.Name, sp.UUID);
return UUID.Zero;
}
}
}
- public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget, bool running)
+ public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos,
+ bool noFly, bool landAtTarget, bool running)
{
lock (m_avatars)
{
@@ -192,12 +212,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC
if (scene.TryGetScenePresence(agentID, out sp))
{
m_log.DebugFormat(
- "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}",
- sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget);
+ "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}",
+ sp.Name, pos, scene.RegionInfo.RegionName,
+ noFly, landAtTarget);
sp.MoveToTarget(pos, noFly, landAtTarget);
sp.SetAlwaysRun = running;
-
+
return true;
}
}
@@ -270,9 +291,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
ScenePresence sp;
if (scene.TryGetScenePresence(agentID, out sp))
{
- sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero);
- // sp.HandleAgentSit(m_avatars[agentID], agentID);
-
+ sp.HandleAgentRequestSit(m_avatars[agentID], agentID,
+ partID, Vector3.Zero);
+ //sp.HandleAgentSit(m_avatars[agentID], agentID);
+
return true;
}
}
@@ -281,7 +303,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
return false;
}
- public bool Whisper(UUID agentID, Scene scene, string text, int channel)
+ public bool Whisper(UUID agentID, Scene scene, string text,
+ int channel)
{
lock (m_avatars)
{
@@ -356,16 +379,23 @@ namespace OpenSim.Region.OptionalModules.World.NPC
NPCAvatar av;
if (m_avatars.TryGetValue(agentID, out av))
{
-// m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove", agentID, av.Name);
+ /*
+ m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove",
+ agentID, av.Name);
+ */
scene.RemoveClient(agentID, false);
m_avatars.Remove(agentID);
-
- m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", agentID, av.Name);
+ /*
+ m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}",
+ agentID, av.Name);
+ */
return true;
}
}
-
-// m_log.DebugFormat("[NPC MODULE]: Could not find {0} to remove", agentID);
+ /*
+ m_log.DebugFormat("[NPC MODULE]: Could not find {0} to remove",
+ agentID);
+ */
return false;
}
@@ -389,7 +419,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
/// true if they do, false if they don't.
private bool CheckPermissions(NPCAvatar av, UUID callerID)
{
- return callerID == UUID.Zero || av.OwnerID == UUID.Zero || av.OwnerID == callerID;
+ return callerID == UUID.Zero || av.OwnerID == UUID.Zero ||
+ av.OwnerID == callerID;
}
}
}