mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 01:06:30 +08:00
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
This commit is contained in:
@@ -29,37 +29,57 @@ 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
|
||||
{
|
||||
public class NPCModule : IRegionModule, INPCModule
|
||||
[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<UUID, NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>();
|
||||
private Dictionary<UUID, NPCAvatar> m_avatars =
|
||||
new Dictionary<UUID, NPCAvatar>();
|
||||
|
||||
public void Initialise(Scene scene, IConfigSource source)
|
||||
public bool Enabled { get; private set; }
|
||||
|
||||
public void Initialise(IConfigSource source)
|
||||
{
|
||||
IConfig config = source.Configs["NPC"];
|
||||
|
||||
if (config != null && config.GetBoolean("Enabled", false))
|
||||
{
|
||||
Enabled = (config != null && config.GetBoolean("Enabled", false));
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
if (Enabled)
|
||||
scene.RegisterModuleInterface<INPCModule>(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
scene.UnregisterModuleInterface<INPCModule>(this);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
}
|
||||
@@ -69,15 +89,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
get { return "NPCModule"; }
|
||||
}
|
||||
|
||||
public bool IsSharedModule
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
public Type ReplaceableInterface { get { return null; } }
|
||||
|
||||
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;
|
||||
@@ -86,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)
|
||||
@@ -99,30 +118,30 @@ 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>();
|
||||
IAvatarFactoryModule module =
|
||||
scene.RequestModuleInterface<IAvatarFactoryModule>();
|
||||
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}",
|
||||
@@ -134,15 +153,20 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
acd.lastname = lastname;
|
||||
acd.ServiceURLs = new Dictionary<string, object>();
|
||||
|
||||
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]);
|
||||
}
|
||||
*/
|
||||
|
||||
ManualResetEvent ev = new ManualResetEvent(false);
|
||||
|
||||
@@ -170,7 +194,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
return npcAvatar.AgentId;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -185,7 +210,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
|
||||
sp.MoveToTarget(pos, noFly, landAtTarget);
|
||||
sp.SetAlwaysRun = running;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -258,9 +283,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;
|
||||
}
|
||||
}
|
||||
@@ -269,7 +295,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)
|
||||
{
|
||||
@@ -344,7 +371,10 @@ 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);
|
||||
|
||||
@@ -352,8 +382,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user