OpenSim.Region.CoreModules.Avatar.AvatarFactory.AvatarFactoryModule.AvatarIsWearing C# (CSharp) Method

AvatarIsWearing() public method

Update what the avatar is wearing using an item from their inventory.
public AvatarIsWearing ( IClientAPI client, OpenSim.Framework.AvatarWearingArgs e ) : void
client IClientAPI
e OpenSim.Framework.AvatarWearingArgs
return void
        public void AvatarIsWearing(IClientAPI client, AvatarWearingArgs e)
        {
            ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
            if (sp == null)
            {
                m_log.WarnFormat("[AVATAR FACTORY MODULE]: AvatarIsWearing unable to find presence for {0}", client.AgentId);
                return;
            }

//            m_log.WarnFormat("[AVATAR FACTORY MODULE]: AvatarIsWearing called for {0}", client.AgentId);

            AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance, false);

            foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
            {
                if (wear.Type < AvatarWearable.MAX_WEARABLES)
                    avatAppearance.Wearables[wear.Type].Add(wear.ItemID, UUID.Zero);
            }

            avatAppearance.GetAssetsFrom(sp.Appearance);

            // This could take awhile since it needs to pull inventory
            SetAppearanceAssets(sp.UUID, ref avatAppearance);

            sp.Appearance = avatAppearance;
            m_scene.AvatarService.SetAppearance(client.AgentId, sp.Appearance);
        }