fix for NPC not playing internal animations

0.7.4.1
satguru srivastava 2012-03-08 20:46:22 -06:00 committed by Melanie
parent 06dda14505
commit 35f2479858
1 changed files with 36 additions and 1 deletions

View File

@ -34,13 +34,17 @@ using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.CoreModules.World.Estate; using OpenSim.Region.CoreModules.World.Estate;
using log4net;
using System.Reflection;
using System.Xml;
namespace OpenSim.Region.OptionalModules.World.NPC namespace OpenSim.Region.OptionalModules.World.NPC
{ {
public class NPCAvatar : IClientAPI, INPC public class NPCAvatar : IClientAPI, INPC
{ {
public bool SenseAsAgent { get; set; } private static readonly Dictionary<string, UUID> m_defaultAnimations = new Dictionary<string, UUID>();
public bool SenseAsAgent { get; set; }
private readonly string m_firstname; private readonly string m_firstname;
private readonly string m_lastname; private readonly string m_lastname;
private readonly Vector3 m_startPos; private readonly Vector3 m_startPos;
@ -57,8 +61,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC
m_scene = scene; m_scene = scene;
m_ownerID = ownerID; m_ownerID = ownerID;
SenseAsAgent = senseAsAgent; SenseAsAgent = senseAsAgent;
} }
static NPCAvatar()
{
InitDefaultAnimations();
}
public IScene Scene public IScene Scene
{ {
get { return m_scene; } get { return m_scene; }
@ -130,8 +142,31 @@ namespace OpenSim.Region.OptionalModules.World.NPC
} }
private static void InitDefaultAnimations()
{
using (XmlTextReader reader = new XmlTextReader("data/avataranimations.xml"))
{
XmlDocument doc = new XmlDocument();
doc.Load(reader);
if (doc.DocumentElement != null)
foreach (XmlNode nod in doc.DocumentElement.ChildNodes)
{
if (nod.Attributes["name"] != null)
{
string name = nod.Attributes["name"].Value.ToLower();
string id = nod.InnerText;
m_defaultAnimations.Add(name, (UUID)id);
}
}
}
}
public UUID GetDefaultAnimation(string name) public UUID GetDefaultAnimation(string name)
{ {
if (m_defaultAnimations.ContainsKey(name))
{
return m_defaultAnimations[name];
}
return UUID.Zero; return UUID.Zero;
} }