mirror of
https://github.com/opensim/opensim.git
synced 2026-05-19 22:45:43 +08:00
Some work towards persisting Avatar Appearance (what is being worn). Added OnAvatarNowWearing event to IClientAPI that is triggered by AgentIsNowWearing packets. stub code to subscribe to this event in AvatarFactoryModule. Todo: code needs to be added to AvatarFactoryModule to save the uuids to a database and then read them back when that modules TryGetIntialAvatarAppearance() method is called. Done some changes to Scene to make it easier to subclass it: including changed some private fields to protected and made some methods virtual.
82 lines
2.4 KiB
C#
82 lines
2.4 KiB
C#
using System;
|
|
using libsecondlife;
|
|
using Nini.Config;
|
|
using OpenSim.Framework;
|
|
using OpenSim.Region.Environment.Interfaces;
|
|
using OpenSim.Region.Environment.Scenes;
|
|
|
|
namespace OpenSim.Region.Environment.Modules
|
|
{
|
|
public class AvatarFactoryModule : IAvatarFactory
|
|
{
|
|
private Scene m_scene = null;
|
|
|
|
public bool TryGetIntialAvatarAppearance(LLUUID avatarId, out AvatarWearable[] wearables,
|
|
out byte[] visualParams)
|
|
{
|
|
GetDefaultAvatarAppearance(out wearables, out visualParams);
|
|
return true;
|
|
}
|
|
|
|
public void Initialise(Scene scene, IConfigSource source)
|
|
{
|
|
scene.RegisterModuleInterface<IAvatarFactory>(this);
|
|
// scene.EventManager.OnNewClient += NewClient;
|
|
|
|
if (m_scene == null)
|
|
{
|
|
m_scene = scene;
|
|
}
|
|
}
|
|
|
|
public void PostInitialise()
|
|
{
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
}
|
|
|
|
public string Name
|
|
{
|
|
get { return "Default Avatar Factory"; }
|
|
}
|
|
|
|
public bool IsSharedModule
|
|
{
|
|
get { return true; }
|
|
}
|
|
|
|
public void NewClient(IClientAPI client)
|
|
{
|
|
// client.OnAvatarNowWearing += AvatarIsWearing;
|
|
}
|
|
|
|
public void RemoveClient(IClientAPI client)
|
|
{
|
|
// client.OnAvatarNowWearing -= AvatarIsWearing;
|
|
}
|
|
|
|
public void AvatarIsWearing(Object sender, AvatarWearingArgs e)
|
|
{
|
|
IClientAPI clientView = (IClientAPI) sender;
|
|
//Todo look up the assetid from the inventory cache (or something) for each itemId that is in AvatarWearingArgs
|
|
// then store assetid and itemId and wearable type in a database
|
|
foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
|
|
{
|
|
LLUUID assetID = m_scene.CommsManager.UserProfileCache.GetUserDetails(clientView.AgentId).RootFolder.HasItem(wear.ItemID).assetID;
|
|
}
|
|
}
|
|
|
|
public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams)
|
|
{
|
|
visualParams = new byte[218];
|
|
for (int i = 0; i < 218; i++)
|
|
{
|
|
visualParams[i] = 100;
|
|
}
|
|
|
|
wearables = AvatarWearable.DefaultWearables;
|
|
}
|
|
}
|
|
} |