From f560d581bbeb420dccdfa80c574724deada8038b Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Sun, 11 Nov 2012 20:42:55 +0000 Subject: document & 80-character width terminal formatting Signed-off-by: Diva Canto --- .../Region/OptionalModules/World/NPC/NPCModule.cs | 129 +++++++++++++-------- 1 file changed, 80 insertions(+), 49 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index b372c88..41e7097 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; } } } -- cgit v1.1