aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authordahlia2014-02-01 04:09:20 -0800
committerdahlia2014-02-01 04:09:20 -0800
commita8e64cd59a7a296b7cae6fc0a66255a7f566e10d (patch)
tree24e1617189dc7eef0922f73233bc89085d231f89
parentIn UuidGatherer, gather materials referenced in the prim's TextureEntry (diff)
downloadopensim-SC_OLD-a8e64cd59a7a296b7cae6fc0a66255a7f566e10d.zip
opensim-SC_OLD-a8e64cd59a7a296b7cae6fc0a66255a7f566e10d.tar.gz
opensim-SC_OLD-a8e64cd59a7a296b7cae6fc0a66255a7f566e10d.tar.bz2
opensim-SC_OLD-a8e64cd59a7a296b7cae6fc0a66255a7f566e10d.tar.xz
Overload INPCModule.CreateNPC() to allow agentID to be specified. Note: this is intended for use in region modules and is not exposed to scripts.
-rw-r--r--OpenSim/Region/Framework/Interfaces/INPCModule.cs26
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs15
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs26
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
72 AvatarAppearance appearance); 72 AvatarAppearance appearance);
73 73
74 /// <summary> 74 /// <summary>
75 /// Create an NPC with a user-supplied agentID
76 /// </summary>
77 /// <param name="firstname"></param>
78 /// <param name="lastname"></param>
79 /// <param name="position"></param>
80 /// <param name="agentID"></param>
81 /// The desired agent ID
82 /// <param name="owner"></param>
83 /// <param name="senseAsAgent">
84 /// Make the NPC show up as an agent on LSL sensors. The default is
85 /// that they show up as the NPC type instead, but this is currently
86 /// an OpenSim-only extension.
87 /// </param>
88 /// <param name="scene"></param>
89 /// <param name="appearance">
90 /// The avatar appearance to use for the new NPC.
91 /// </param>
92 /// <returns>
93 /// The UUID of the ScenePresence created. UUID.Zero if there was a
94 /// failure.
95 /// </returns>
96 UUID CreateNPC(string firstname, string lastname,
97 Vector3 position, UUID agentID, UUID owner, bool senseAsAgent, Scene scene,
98 AvatarAppearance appearance);
99
100 /// <summary>
75 /// Check if the agent is an NPC. 101 /// Check if the agent is an NPC.
76 /// </summary> 102 /// </summary>
77 /// <param name="agentID"></param> 103 /// <param name="agentID"></param>
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
61 private readonly string m_firstname; 61 private readonly string m_firstname;
62 private readonly string m_lastname; 62 private readonly string m_lastname;
63 private readonly Vector3 m_startPos; 63 private readonly Vector3 m_startPos;
64 private readonly UUID m_uuid = UUID.Random(); 64 private readonly UUID m_uuid;
65 private readonly Scene m_scene; 65 private readonly Scene m_scene;
66 private readonly UUID m_ownerID; 66 private readonly UUID m_ownerID;
67 67
@@ -71,6 +71,19 @@ namespace OpenSim.Region.OptionalModules.World.NPC
71 m_firstname = firstname; 71 m_firstname = firstname;
72 m_lastname = lastname; 72 m_lastname = lastname;
73 m_startPos = position; 73 m_startPos = position;
74 m_uuid = UUID.Random();
75 m_scene = scene;
76 m_ownerID = ownerID;
77 SenseAsAgent = senseAsAgent;
78 }
79
80 public NPCAvatar(
81 string firstname, string lastname, UUID agentID, Vector3 position, UUID ownerID, bool senseAsAgent, Scene scene)
82 {
83 m_firstname = firstname;
84 m_lastname = lastname;
85 m_startPos = position;
86 m_uuid = agentID;
74 m_scene = scene; 87 m_scene = scene;
75 m_ownerID = ownerID; 88 m_ownerID = ownerID;
76 SenseAsAgent = senseAsAgent; 89 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
140 Vector3 position, UUID owner, bool senseAsAgent, Scene scene, 140 Vector3 position, UUID owner, bool senseAsAgent, Scene scene,
141 AvatarAppearance appearance) 141 AvatarAppearance appearance)
142 { 142 {
143 NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, 143 return CreateNPC(firstname, lastname, position, UUID.Zero, owner, senseAsAgent, scene, appearance);
144 owner, senseAsAgent, scene); 144 }
145
146 public UUID CreateNPC(string firstname, string lastname,
147 Vector3 position, UUID agentID, UUID owner, bool senseAsAgent, Scene scene,
148 AvatarAppearance appearance)
149 {
150 NPCAvatar npcAvatar = null;
151
152 try
153 {
154 if (agentID == UUID.Zero)
155 npcAvatar = new NPCAvatar(firstname, lastname, position,
156 owner, senseAsAgent, scene);
157 else
158 npcAvatar = new NPCAvatar(firstname, lastname, agentID, position,
159 owner, senseAsAgent, scene);
160 }
161 catch (Exception e)
162 {
163 m_log.Info("[NPC MODULE]: exception creating NPC avatar: " + e.ToString());
164 return UUID.Zero;
165 }
166
145 npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, 167 npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0,
146 int.MaxValue); 168 int.MaxValue);
147 169