refactor: Move ScenePresence.RezAttachments() into AttachmentsModule
This adds an incomplete IScenePresence to match ISceneEntityremove-scene-viewer
parent
a90e1cf3aa
commit
04bafd2122
|
@ -95,6 +95,44 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
|||
client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv;
|
||||
client.OnObjectDrop -= DetachSingleAttachmentToGround;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RezAttachments. This should only be called upon login on the first region.
|
||||
/// Attachment rezzings on crossings and TPs are done in a different way.
|
||||
/// </summary>
|
||||
public void RezAttachments(IScenePresence sp)
|
||||
{
|
||||
if (null == sp.Appearance)
|
||||
{
|
||||
m_log.WarnFormat("[ATTACHMENTS MODULE]: Appearance has not been initialized for agent {0}", sp.UUID);
|
||||
return;
|
||||
}
|
||||
|
||||
List<AvatarAttachment> attachments = sp.Appearance.GetAttachments();
|
||||
foreach (AvatarAttachment attach in attachments)
|
||||
{
|
||||
int p = attach.AttachPoint;
|
||||
UUID itemID = attach.ItemID;
|
||||
|
||||
//UUID assetID = attach.AssetID;
|
||||
// For some reason assetIDs are being written as Zero's in the DB -- need to track tat down
|
||||
// But they're not used anyway, the item is being looked up for now, so let's proceed.
|
||||
//if (UUID.Zero == assetID)
|
||||
//{
|
||||
// m_log.DebugFormat("[ATTACHMENT]: Cannot rez attachment in point {0} with itemID {1}", p, itemID);
|
||||
// continue;
|
||||
//}
|
||||
|
||||
try
|
||||
{
|
||||
RezSingleAttachmentFromInventory(sp.ControllingClient, itemID, (uint)p);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[ATTACHMENTS MODULE]: Unable to rez attachment: {0}{1}", e.Message, e.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by client
|
||||
|
|
|
@ -35,6 +35,12 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
{
|
||||
public interface IAttachmentsModule
|
||||
{
|
||||
/// <summary>
|
||||
/// RezAttachments. This should only be called upon login on the first region.
|
||||
/// Attachment rezzings on crossings and TPs are done in a different way.
|
||||
/// </summary>
|
||||
void RezAttachments(IScenePresence sp);
|
||||
|
||||
/// <summary>
|
||||
/// Attach an object to an avatar from the world.
|
||||
/// </summary>
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Region.Framework.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// An agent in the scene.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Interface is a work in progress. Please feel free to add other required properties and methods.
|
||||
/// </remarks>
|
||||
public interface IScenePresence : ISceneEntity
|
||||
{
|
||||
/// <value>
|
||||
/// The client controlling this presence
|
||||
/// </value>
|
||||
IClientAPI ControllingClient { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Avatar appearance data.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
// Because appearance setting is in a module, we actually need
|
||||
// to give it access to our appearance directly, otherwise we
|
||||
// get a synchronization issue.
|
||||
/// </remarks>
|
||||
AvatarAppearance Appearance { get; set; }
|
||||
}
|
||||
}
|
|
@ -2578,7 +2578,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
if (aCircuit.child == false)
|
||||
{
|
||||
sp.IsChildAgent = false;
|
||||
Util.FireAndForget(delegate(object o) { sp.RezAttachments(); });
|
||||
Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public delegate void SendCourseLocationsMethod(UUID scene, ScenePresence presence, List<Vector3> coarseLocations, List<UUID> avatarUUIDs);
|
||||
|
||||
public class ScenePresence : EntityBase, ISceneEntity
|
||||
public class ScenePresence : EntityBase, IScenePresence
|
||||
{
|
||||
// ~ScenePresence()
|
||||
// {
|
||||
|
@ -444,9 +444,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
protected PhysicsActor m_physicsActor;
|
||||
|
||||
/// <value>
|
||||
/// The client controlling this presence
|
||||
/// </value>
|
||||
public IClientAPI ControllingClient
|
||||
{
|
||||
get { return m_controllingClient; }
|
||||
|
@ -2689,9 +2686,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
UUID, m_appearance.VisualParams, m_appearance.Texture.GetBytes());
|
||||
}
|
||||
|
||||
// Because appearance setting is in a module, we actually need
|
||||
// to give it access to our appearance directly, otherwise we
|
||||
// get a synchronization issue.
|
||||
public AvatarAppearance Appearance
|
||||
{
|
||||
get { return m_appearance; }
|
||||
|
@ -3813,44 +3807,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
return flags;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RezAttachments. This should only be called upon login on the first region.
|
||||
/// Attachment rezzings on crossings and TPs are done in a different way.
|
||||
/// </summary>
|
||||
public void RezAttachments()
|
||||
{
|
||||
if (null == m_appearance)
|
||||
{
|
||||
m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID);
|
||||
return;
|
||||
}
|
||||
|
||||
List<AvatarAttachment> attachments = m_appearance.GetAttachments();
|
||||
foreach (AvatarAttachment attach in attachments)
|
||||
{
|
||||
int p = attach.AttachPoint;
|
||||
UUID itemID = attach.ItemID;
|
||||
|
||||
//UUID assetID = attach.AssetID;
|
||||
// For some reason assetIDs are being written as Zero's in the DB -- need to track tat down
|
||||
// But they're not used anyway, the item is being looked up for now, so let's proceed.
|
||||
//if (UUID.Zero == assetID)
|
||||
//{
|
||||
// m_log.DebugFormat("[ATTACHMENT]: Cannot rez attachment in point {0} with itemID {1}", p, itemID);
|
||||
// continue;
|
||||
//}
|
||||
|
||||
try
|
||||
{
|
||||
m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[ATTACHMENT]: Unable to rez attachment: {0}{1}", e.Message, e.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ReprioritizeUpdates()
|
||||
{
|
||||
if (Scene.IsReprioritizationEnabled && Scene.UpdatePrioritizationScheme != UpdatePrioritizationSchemes.Time)
|
||||
|
|
|
@ -155,7 +155,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
|||
|
||||
AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
|
||||
sp.Appearance = npcAppearance;
|
||||
sp.RezAttachments();
|
||||
scene.AttachmentsModule.RezAttachments(sp);
|
||||
|
||||
IAvatarFactory module = scene.RequestModuleInterface<IAvatarFactory>();
|
||||
module.SendAppearance(sp.UUID);
|
||||
|
|
Loading…
Reference in New Issue