diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 8c9c006..226608a 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | |||
@@ -116,7 +116,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
116 | return false; | 116 | return false; |
117 | 117 | ||
118 | // Delete existing npc attachments | 118 | // Delete existing npc attachments |
119 | scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false); | 119 | if(scene.AttachmentsModule != null) |
120 | scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false); | ||
120 | 121 | ||
121 | // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet | 122 | // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet |
122 | // since it doesn't transfer attachments | 123 | // since it doesn't transfer attachments |
@@ -125,7 +126,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
125 | npc.Appearance = npcAppearance; | 126 | npc.Appearance = npcAppearance; |
126 | 127 | ||
127 | // Rez needed npc attachments | 128 | // Rez needed npc attachments |
128 | scene.AttachmentsModule.RezAttachments(npc); | 129 | if (scene.AttachmentsModule != null) |
130 | scene.AttachmentsModule.RezAttachments(npc); | ||
129 | 131 | ||
130 | IAvatarFactoryModule module = | 132 | IAvatarFactoryModule module = |
131 | scene.RequestModuleInterface<IAvatarFactoryModule>(); | 133 | scene.RequestModuleInterface<IAvatarFactoryModule>(); |
@@ -168,26 +170,27 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
168 | } | 170 | } |
169 | */ | 171 | */ |
170 | 172 | ||
171 | ManualResetEvent ev = new ManualResetEvent(false); | 173 | // ManualResetEvent ev = new ManualResetEvent(false); |
172 | 174 | ||
173 | Util.FireAndForget(delegate(object x) { | 175 | // Util.FireAndForget(delegate(object x) { |
174 | lock (m_avatars) | 176 | lock (m_avatars) |
175 | { | 177 | { |
176 | scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); | 178 | scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); |
177 | scene.AddNewClient(npcAvatar, PresenceType.Npc); | 179 | scene.AddNewAgent(npcAvatar, PresenceType.Npc); |
178 | 180 | ||
179 | ScenePresence sp; | 181 | ScenePresence sp; |
180 | if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) | 182 | if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) |
181 | { | 183 | { |
184 | |||
182 | sp.CompleteMovement(npcAvatar, false); | 185 | sp.CompleteMovement(npcAvatar, false); |
183 | m_avatars.Add(npcAvatar.AgentId, npcAvatar); | 186 | m_avatars.Add(npcAvatar.AgentId, npcAvatar); |
184 | // m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name); | 187 | // m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name); |
185 | } | 188 | } |
186 | } | 189 | } |
187 | ev.Set(); | 190 | // ev.Set(); |
188 | }); | 191 | // }); |
189 | 192 | ||
190 | ev.WaitOne(); | 193 | // ev.WaitOne(); |
191 | 194 | ||
192 | // m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId); | 195 | // m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId); |
193 | 196 | ||
@@ -205,8 +208,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
205 | if (scene.TryGetScenePresence(agentID, out sp)) | 208 | if (scene.TryGetScenePresence(agentID, out sp)) |
206 | { | 209 | { |
207 | // m_log.DebugFormat( | 210 | // m_log.DebugFormat( |
208 | // "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", | 211 | // "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", |
209 | // sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); | 212 | // sp.Name, pos, scene.RegionInfo.RegionName, |
213 | // noFly, landAtTarget); | ||
210 | 214 | ||
211 | sp.MoveToTarget(pos, noFly, landAtTarget); | 215 | sp.MoveToTarget(pos, noFly, landAtTarget); |
212 | sp.SetAlwaysRun = running; | 216 | sp.SetAlwaysRun = running; |
@@ -283,9 +287,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
283 | ScenePresence sp; | 287 | ScenePresence sp; |
284 | if (scene.TryGetScenePresence(agentID, out sp)) | 288 | if (scene.TryGetScenePresence(agentID, out sp)) |
285 | { | 289 | { |
286 | sp.HandleAgentRequestSit(m_avatars[agentID], agentID, | 290 | sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero); |
287 | partID, Vector3.Zero); | ||
288 | //sp.HandleAgentSit(m_avatars[agentID], agentID); | ||
289 | 291 | ||
290 | return true; | 292 | return true; |
291 | } | 293 | } |
@@ -375,10 +377,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
375 | m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove", | 377 | m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove", |
376 | agentID, av.Name); | 378 | agentID, av.Name); |
377 | */ | 379 | */ |
378 | scene.RemoveClient(agentID, false); | 380 | |
381 | scene.CloseAgent(agentID, false); | ||
382 | |||
379 | m_avatars.Remove(agentID); | 383 | m_avatars.Remove(agentID); |
380 | 384 | ||
381 | // m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", agentID, av.Name); | 385 | /* |
386 | m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", | ||
387 | agentID, av.Name); | ||
388 | */ | ||
382 | return true; | 389 | return true; |
383 | } | 390 | } |
384 | } | 391 | } |