本文整理汇总了C#中ISceneEntity.GetAttachmentPoint方法的典型用法代码示例。如果您正苦于以下问题:C# ISceneEntity.GetAttachmentPoint方法的具体用法?C# ISceneEntity.GetAttachmentPoint怎么用?C# ISceneEntity.GetAttachmentPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISceneEntity
的用法示例。
在下文中一共展示了ISceneEntity.GetAttachmentPoint方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateKnownItem
/// <summary>
/// Update the attachment asset for the new sog details if they have changed.
/// </summary>
///
/// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects,
/// these details are not stored on the region.
///
/// <param name="remoteClient"></param>
/// <param name="grp"></param>
/// <param name="itemID"></param>
/// <param name="agentID"></param>
protected void UpdateKnownItem (IClientAPI remoteClient, ISceneEntity grp, UUID itemID, UUID agentID)
{
if (grp != null)
{
if (!grp.HasGroupChanged)
{
//m_log.WarnFormat("[ATTACHMENTS MODULE]: Save request for {0} which is unchanged", grp.UUID);
return;
}
//let things like state saves and another async things be performed before we serialize the object
grp.BackupPreparation();
m_log.InfoFormat(
"[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
grp.UUID, grp.GetAttachmentPoint());
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat((SceneObjectGroup)grp);
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
item = m_scene.InventoryService.GetItem(item);
if (item != null)
{
AssetBase asset = new AssetBase(UUID.Random(), grp.Name,
AssetType.Object, remoteClient.AgentId);
asset.Description = grp.RootChild.Description;
asset.Data = Utils.StringToBytes(sceneObjectXml);
asset.ID = m_scene.AssetService.Store(asset);
if (item.Folder == UUID.Zero)
{
InventoryFolderBase folder = m_scene.InventoryService.GetFolderForType (remoteClient.AgentId, InventoryType.Unknown, AssetType.Object);
if (folder == null)
return;//Probably a non user (bot)
item.Folder = folder.ID;
}
item.AssetID = asset.ID;
item.Description = asset.Description;
item.Name = asset.Name;
item.AssetType = asset.Type;
item.InvType = (int)InventoryType.Object;
m_scene.InventoryService.UpdateItem(item);
// this gets called when the agent logs off!
if (remoteClient != null)
remoteClient.SendInventoryItemCreateUpdate(item, 0);
}
else
{
m_log.Warn("[AttachmentModule]: Could not find inventory item for attachment to update!");
}
}
}
示例2: FindAttachmentPoint
/// <summary>
/// Attach the object to the avatar
/// </summary>
/// <param name="remoteClient">The client that is having the attachment done</param>
/// <param name="localID">The localID (SceneObjectPart) that is being attached (for the attach script event)</param>
/// <param name="group">The group (SceneObjectGroup) that is being attached</param>
/// <param name="AttachmentPt">The point to where the attachment will go</param>
/// <param name="item">If this is not null, it saves a query in this method to the InventoryService
/// This is the Item that the object is in (if it is in one yet)</param>
protected void FindAttachmentPoint (IClientAPI remoteClient, uint localID, ISceneEntity group,
int AttachmentPt, InventoryItemBase item)
{
//Make sure that we arn't over the limit of attachments
ISceneEntity[] attachments = GetAttachmentsForAvatar (remoteClient.AgentId);
if (attachments.Length + 1 > m_maxNumberOfAttachments)
{
//Too many
remoteClient.SendAgentAlertMessage(
"You are wearing too many attachments. Take one off to attach this object", false);
return;
}
Vector3 attachPos = group.GetAttachmentPos();
bool hasMultipleAttachmentsSet = (AttachmentPt & 0x7f) != 0 || AttachmentPt == 0;
if(!m_allowMultipleAttachments)
hasMultipleAttachmentsSet = false;
AttachmentPt &= 0x7f; //Disable it! Its evil!
//Did the attachment change position or attachment point?
bool changedPositionPoint = false;
// If the attachment point isn't the same as the one previously used
// set it's offset position = 0 so that it appears on the attachment point
// and not in a weird location somewhere unknown.
//Simplier terms: the attachment point changed, set it to the default 0,0,0 location
if (AttachmentPt != 0 && AttachmentPt != (int)(group.GetAttachmentPoint() & 0x7f))
{
attachPos = Vector3.Zero;
changedPositionPoint = true;
}
else
{
// AttachmentPt 0 means the client chose to 'wear' the attachment.
if (AttachmentPt == 0)
{
// Check object for stored attachment point
AttachmentPt = (int)group.GetSavedAttachmentPoint() & 0x7f;
attachPos = group.GetAttachmentPos();
}
//Check state afterwards... use the newer GetSavedAttachmentPoint and Pos above first
if (AttachmentPt == 0)
{
// Check object for older stored attachment point
AttachmentPt = group.RootChild.Shape.State & 0x7f;
//attachPos = group.AbsolutePosition;
}
// if we still didn't find a suitable attachment point, force it to the default
//This happens on the first time an avatar 'wears' an object
if (AttachmentPt == 0)
{
// Stick it on right hand with Zero Offset from the attachment point.
AttachmentPt = (int)AttachmentPoint.RightHand;
//Default location
attachPos = Vector3.Zero;
changedPositionPoint = true;
}
}
group.HasGroupChanged = changedPositionPoint;
//Update where we are put
group.SetAttachmentPoint((byte)AttachmentPt);
//Fix the position with the one we found
group.AbsolutePosition = attachPos;
// Remove any previous attachments
IScenePresence presence = m_scene.GetScenePresence (remoteClient.AgentId);
if (presence == null)
return;
UUID itemID = UUID.Zero;
//Check for multiple attachment bits and whether we should remove the old
if(!hasMultipleAttachmentsSet)
{
foreach (ISceneEntity grp in attachments)
{
if (grp.GetAttachmentPoint() == (byte)AttachmentPt)
{
itemID = grp.RootChild.FromUserInventoryItemID;
break;
}
}
if (itemID != UUID.Zero)
DetachSingleAttachmentToInventory(itemID, remoteClient);
}
itemID = group.RootChild.FromUserInventoryItemID;
group.RootChild.AttachedAvatar = presence.UUID;
//.........这里部分代码省略.........
示例3: DetachSingleAttachmentGroupToInventoryInternal
private void DetachSingleAttachmentGroupToInventoryInternal (UUID itemID, IClientAPI remoteClient, bool fireEvent, ISceneEntity group)
{
if (fireEvent)
{
m_scene.EventManager.TriggerOnAttach (group.LocalId, itemID, UUID.Zero);
group.DetachToInventoryPrep ();
}
IScenePresence presence = m_scene.GetScenePresence (remoteClient.AgentId);
if (presence != null)
{
AvatarAttachments attModule = presence.RequestModuleInterface<AvatarAttachments> ();
if (attModule != null)
attModule.RemoveAttachment (group);
presence.RemoveAttachment (group);
}
m_log.Debug ("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint ()).ToString ());
//Update the saved attach points
if (group.RootChild.AttachedPos != group.RootChild.SavedAttachedPos ||
group.RootChild.SavedAttachmentPoint != group.RootChild.AttachmentPoint)
{
group.RootChild.SavedAttachedPos = group.RootChild.AttachedPos;
group.RootChild.SavedAttachmentPoint = group.RootChild.AttachmentPoint;
//Make sure we get updated
group.HasGroupChanged = true;
}
// If an item contains scripts, it's always changed.
// This ensures script state is saved on detach
foreach (ISceneChildEntity p in group.ChildrenEntities ())
{
if (p.Inventory.ContainsScripts ())
{
group.HasGroupChanged = true;
break;
}
}
UpdateKnownItem (remoteClient, group, group.RootChild.FromUserInventoryItemID, group.OwnerID);
}
示例4: UpdateKnownItem
/// <summary>
/// Update the attachment asset for the new sog details if they have changed.
/// </summary>
/// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects,
/// these details are not stored on the region.
/// <param name="remoteClient"></param>
/// <param name="grp"></param>
/// <param name="itemID"></param>
/// <param name="agentID"></param>
protected UUID UpdateKnownItem(IClientAPI remoteClient, ISceneEntity grp, UUID itemID, UUID agentID)
{
if (grp != null)
{
if (!grp.HasGroupChanged)
{
//MainConsole.Instance.WarnFormat("[ATTACHMENTS MODULE]: Save request for {0} which is unchanged", grp.UUID);
return UUID.Zero;
}
//let things like state saves and another async things be performed before we serialize the object
grp.BackupPreparation();
MainConsole.Instance.InfoFormat(
"[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
grp.UUID, grp.GetAttachmentPoint());
string sceneObjectXml = SceneEntitySerializer.SceneObjectSerializer.ToOriginalXmlFormat(grp);
AssetBase asset = new AssetBase(UUID.Random(), grp.Name,
AssetType.Object, remoteClient.AgentId)
{
Description = grp.RootChild.Description,
Data = Utils.StringToBytes(sceneObjectXml)
};
asset.ID = m_scene.AssetService.Store(asset);
m_scene.InventoryService.UpdateAssetIDForItem(itemID, asset.ID);
// this gets called when the agent logs off!
//remoteClient.SendInventoryItemCreateUpdate(item, 0);
return asset.ID;
}
return UUID.Zero;
}