From a8e64cd59a7a296b7cae6fc0a66255a7f566e10d Mon Sep 17 00:00:00 2001 From: dahlia Date: Sat, 1 Feb 2014 04:09:20 -0800 Subject: Overload INPCModule.CreateNPC() to allow agentID to be specified. Note: this is intended for use in region modules and is not exposed to scripts. --- OpenSim/Region/Framework/Interfaces/INPCModule.cs | 26 ++++++++++++++++++++++ .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 15 ++++++++++++- .../Region/OptionalModules/World/NPC/NPCModule.cs | 26 ++++++++++++++++++++-- 3 files changed, 64 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs index 9817cf7..d5dcddd 100644 --- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs +++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs @@ -72,6 +72,32 @@ namespace OpenSim.Region.Framework.Interfaces AvatarAppearance appearance); /// + /// Create an NPC with a user-supplied agentID + /// + /// + /// + /// + /// + /// The desired agent ID + /// + /// + /// 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 agentID, UUID owner, bool senseAsAgent, Scene scene, + AvatarAppearance appearance); + + /// /// Check if the agent is an NPC. /// /// diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index a895ee1..fb644b7 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -61,7 +61,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC private readonly string m_firstname; private readonly string m_lastname; private readonly Vector3 m_startPos; - private readonly UUID m_uuid = UUID.Random(); + private readonly UUID m_uuid; private readonly Scene m_scene; private readonly UUID m_ownerID; @@ -71,6 +71,19 @@ namespace OpenSim.Region.OptionalModules.World.NPC m_firstname = firstname; m_lastname = lastname; m_startPos = position; + m_uuid = UUID.Random(); + m_scene = scene; + m_ownerID = ownerID; + SenseAsAgent = senseAsAgent; + } + + public NPCAvatar( + string firstname, string lastname, UUID agentID, Vector3 position, UUID ownerID, bool senseAsAgent, Scene scene) + { + m_firstname = firstname; + m_lastname = lastname; + m_startPos = position; + m_uuid = agentID; m_scene = scene; m_ownerID = ownerID; SenseAsAgent = senseAsAgent; diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index fffe1ab..8a2da6e 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -140,8 +140,30 @@ namespace OpenSim.Region.OptionalModules.World.NPC Vector3 position, UUID owner, bool senseAsAgent, Scene scene, AvatarAppearance appearance) { - NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, - owner, senseAsAgent, scene); + return CreateNPC(firstname, lastname, position, UUID.Zero, owner, senseAsAgent, scene, appearance); + } + + public UUID CreateNPC(string firstname, string lastname, + Vector3 position, UUID agentID, UUID owner, bool senseAsAgent, Scene scene, + AvatarAppearance appearance) + { + NPCAvatar npcAvatar = null; + + try + { + if (agentID == UUID.Zero) + npcAvatar = new NPCAvatar(firstname, lastname, position, + owner, senseAsAgent, scene); + else + npcAvatar = new NPCAvatar(firstname, lastname, agentID, position, + owner, senseAsAgent, scene); + } + catch (Exception e) + { + m_log.Info("[NPC MODULE]: exception creating NPC avatar: " + e.ToString()); + return UUID.Zero; + } + npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); -- cgit v1.1