本文整理汇总了C#中LLAgent.GetChildren方法的典型用法代码示例。如果您正苦于以下问题:C# LLAgent.GetChildren方法的具体用法?C# LLAgent.GetChildren怎么用?C# LLAgent.GetChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLAgent
的用法示例。
在下文中一共展示了LLAgent.GetChildren方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ObjectAttachHandler
void ObjectAttachHandler(Packet packet, LLAgent agent)
{
ObjectAttachPacket attach = (ObjectAttachPacket)packet;
for (int i = 0; i < attach.ObjectData.Length; i++)
{
ObjectAttachPacket.ObjectDataBlock block = attach.ObjectData[i];
ISceneEntity entity;
if (m_scene.TryGetEntity(block.ObjectLocalID, out entity) && entity is LLPrimitive)
{
LLPrimitive obj = (LLPrimitive)entity;
// Permission check
if (obj.OwnerID != agent.ID)
{
m_log.Warn(agent.Name + " tried to attach " + obj.ID + " owned by " + obj.OwnerID);
continue;
}
// Sanity checks
if (obj.Parent != null)
{
m_log.Warn(agent.Name + " tried to attach child prim " + obj.ID);
continue;
}
ILinkable[] childObjs = obj.GetChildren();
for (int j = 0; j < childObjs.Length; j++)
{
if (childObjs[i] is IScenePresence)
{
m_log.Warn(agent.Name + " attempted to attach " + obj.ID + " with an avatar sitting on it");
continue;
}
}
// Determine what attach point to use
AttachmentPoint requestedAttachPoint = (AttachmentPoint)attach.AgentData.AttachmentPoint;
AttachmentPoint attachPoint = (requestedAttachPoint == AttachmentPoint.Default ? obj.LastAttachmentPoint : requestedAttachPoint);
if (attachPoint == AttachmentPoint.Default)
attachPoint = AttachmentPoint.RightHand;
// If we are attaching to a new attachment point, reset the attachment position and rotation for this object
if (attachPoint != obj.LastAttachmentPoint)
{
obj.AttachmentPosition = Vector3.Zero;
obj.AttachmentRotation = Quaternion.Identity;
}
// Check if something is already attached to the target attachment point
ILinkable[] attachments = agent.GetChildren();
for (int j = 0; j < attachments.Length; j++)
{
if (attachments[j] is LLPrimitive)
{
LLPrimitive primAttachment = (LLPrimitive)attachments[j];
if (primAttachment.Prim.PrimData.AttachmentPoint == attachPoint)
{
DetachObject(agent, primAttachment);
break;
}
}
}
// Attaching destroys undo history
obj.ClearUndoHistory();
// Set the attachment point
obj.Prim.PrimData.AttachmentPoint = attachPoint;
obj.LastAttachmentPoint = attachPoint;
obj.BeforeAttachmentRotation = block.Rotation;
// Create the inventory item for this attachment
if (m_inventory != null)
{
// Serialize this prim and any children
string contentType = LLUtil.LLAssetTypeToContentType((int)AssetType.Object);
byte[] assetData = System.Text.Encoding.UTF8.GetBytes(
OpenMetaverse.StructuredData.OSDParser.SerializeJsonString(LLPrimitive.SerializeLinkset(obj)));
LLInventoryItem item = m_inventory.ObjectToInventory(agent.ID, obj, assetData, contentType, (uint)attachPoint, true, UUID.Zero, UUID.Zero, false, 0);
if (item != null)
{
obj.Prim.Properties.ItemID = item.ID;
obj.Prim.Properties.FolderID = item.ParentID;
}
else
{
m_log.Warn(agent.Name + " failed to store attachment " + obj.ID + " to inventory");
}
}
// Do the actual attachment
obj.RelativePosition = obj.AttachmentPosition;
obj.RelativeRotation = obj.AttachmentRotation;
obj.SetParent(agent, false, false);
// Send an update out to everyone
m_scene.EntityAddOrUpdate(this, obj, UpdateFlags.Parent | UpdateFlags.Position | UpdateFlags.Rotation, (uint)LLUpdateFlags.AttachmentPoint);
//.........这里部分代码省略.........