本文整理汇总了C#中OpenSim.Region.Framework.Scenes.ScenePresence.GetAttachments方法的典型用法代码示例。如果您正苦于以下问题:C# ScenePresence.GetAttachments方法的具体用法?C# ScenePresence.GetAttachments怎么用?C# ScenePresence.GetAttachments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenSim.Region.Framework.Scenes.ScenePresence
的用法示例。
在下文中一共展示了ScenePresence.GetAttachments方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CrossAttachmentsIntoNewRegion
protected bool CrossAttachmentsIntoNewRegion(GridRegion destination, ScenePresence sp, bool silent)
{
List<SceneObjectGroup> m_attachments = sp.GetAttachments();
// Validate
// foreach (SceneObjectGroup gobj in m_attachments)
// {
// if (gobj == null || gobj.IsDeleted)
// return false;
// }
foreach (SceneObjectGroup gobj in m_attachments)
{
// If the prim group is null then something must have happened to it!
if (gobj != null && !gobj.IsDeleted)
{
// Set the parent localID to 0 so it transfers over properly.
gobj.RootPart.SetParentLocalId(0);
gobj.AbsolutePosition = gobj.RootPart.AttachedPos;
gobj.IsAttachment = false;
//gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}", gobj.UUID, destination.RegionName);
CrossPrimGroupIntoNewRegion(destination, gobj, silent);
}
}
sp.ClearAttachments();
return true;
}
示例2: ReInstantiateScripts
protected void ReInstantiateScripts(ScenePresence sp)
{
int i = 0;
if (sp.InTransitScriptStates.Count > 0)
{
List<SceneObjectGroup> attachments = sp.GetAttachments();
foreach (SceneObjectGroup sog in attachments)
{
if (i < sp.InTransitScriptStates.Count)
{
sog.SetState(sp.InTransitScriptStates[i++], sp.Scene);
sog.CreateScriptInstances(0, false, sp.Scene.DefaultScriptEngine, 0);
sog.ResumeScripts();
}
else
m_log.ErrorFormat(
"[ENTITY TRANSFER MODULE]: InTransitScriptStates.Count={0} smaller than Attachments.Count={1}",
sp.InTransitScriptStates.Count, attachments.Count);
}
sp.InTransitScriptStates.Clear();
}
}
示例3: GetAttachmentsReport
private void GetAttachmentsReport(ScenePresence sp, StringBuilder sb)
{
sb.AppendFormat("Attachments for {0}\n", sp.Name);
ConsoleDisplayTable ct = new ConsoleDisplayTable() { Indent = 2 };
ct.Columns.Add(new ConsoleDisplayTableColumn("Attachment Name", 50));
ct.Columns.Add(new ConsoleDisplayTableColumn("Local ID", 10));
ct.Columns.Add(new ConsoleDisplayTableColumn("Item ID", 36));
ct.Columns.Add(new ConsoleDisplayTableColumn("Attach Point", 14));
ct.Columns.Add(new ConsoleDisplayTableColumn("Position", 15));
// sb.AppendFormat(
// " {0,-36} {1,-10} {2,-36} {3,-14} {4,-15}\n",
// "Attachment Name", "Local ID", "Item ID", "Attach Point", "Position");
List<SceneObjectGroup> attachmentObjects = sp.GetAttachments();
foreach (SceneObjectGroup attachmentObject in attachmentObjects)
{
// InventoryItemBase attachmentItem
// = m_scenes[0].InventoryService.GetItem(new InventoryItemBase(attachmentObject.FromItemID));
// if (attachmentItem == null)
// {
// sb.AppendFormat(
// "WARNING: Couldn't find attachment for item {0} at point {1}\n",
// attachmentData.ItemID, (AttachmentPoint)attachmentData.AttachPoint);
// continue;
// }
// else
// {
// sb.AppendFormat(
// " {0,-36} {1,-10} {2,-36} {3,-14} {4,-15}\n",
// attachmentObject.Name, attachmentObject.LocalId, attachmentObject.FromItemID,
// (AttachmentPoint)attachmentObject.AttachmentPoint, attachmentObject.RootPart.AttachedPos);
ct.AddRow(
attachmentObject.Name,
attachmentObject.LocalId,
attachmentObject.FromItemID,
((AttachmentPoint)attachmentObject.AttachmentPoint),
attachmentObject.RootPart.AttachedPos);
// }
}
ct.AddToStringBuilder(sb);
sb.Append("\n");
}
示例4: Teleport
public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags)
{
if (!sp.Scene.Permissions.CanTeleport(sp.UUID))
return;
IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
// Reset animations; the viewer does that in teleports.
sp.Animator.ResetAnimations();
try
{
if (regionHandle == sp.Scene.RegionInfo.RegionHandle)
{
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}",
position, sp.Scene.RegionInfo.RegionName);
// Teleport within the same region
if (IsOutsideRegion(sp.Scene, position) || position.Z < 0)
{
Vector3 emergencyPos = new Vector3(128, 128, 128);
m_log.WarnFormat(
"[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
position, sp.Name, sp.UUID, emergencyPos);
position = emergencyPos;
}
// TODO: Get proper AVG Height
float localAVHeight = 1.56f;
float posZLimit = 22;
// TODO: Check other Scene HeightField
if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize)
{
posZLimit = (float)sp.Scene.Heightmap[(int)position.X, (int)position.Y];
}
float newPosZ = posZLimit + localAVHeight;
if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
{
position.Z = newPosZ;
}
sp.ControllingClient.SendTeleportStart(teleportFlags);
sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
sp.Teleport(position);
foreach (SceneObjectGroup grp in sp.GetAttachments())
{
if (grp.IsDeleted)
sp.Scene.EventManager.TriggerOnScriptChangedEvent(grp.LocalId, (uint)Changed.TELEPORT);
}
}
else // Another region possibly in another simulator
{
uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion reg = m_aScene.GridService.GetRegionByPosition(sp.Scene.RegionInfo.ScopeID, (int)x, (int)y);
if (reg != null)
{
GridRegion finalDestination = GetFinalDestination(reg);
if (finalDestination == null)
{
m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Final destination is having problems. Unable to teleport agent.");
sp.ControllingClient.SendTeleportFailed("Problem at destination");
return;
}
uint curX = 0, curY = 0;
Utils.LongToUInts(sp.Scene.RegionInfo.RegionHandle, out curX, out curY);
int curCellX = (int)(curX / Constants.RegionSize);
int curCellY = (int)(curY / Constants.RegionSize);
int destCellX = (int)(finalDestination.RegionLocX / Constants.RegionSize);
int destCellY = (int)(finalDestination.RegionLocY / Constants.RegionSize);
// m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Source co-ords are x={0} y={1}", curRegionX, curRegionY);
//
// m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final dest is x={0} y={1} {2}@{3}",
// destRegionX, destRegionY, finalDestination.RegionID, finalDestination.ServerURI);
// Check that these are not the same coordinates
if (finalDestination.RegionLocX == sp.Scene.RegionInfo.RegionLocX &&
finalDestination.RegionLocY == sp.Scene.RegionInfo.RegionLocY)
{
// Can't do. Viewer crashes
sp.ControllingClient.SendTeleportFailed("Space warp! You would crash. Move to a different region and try again.");
return;
}
if (Math.Abs(curCellX - destCellX) > MaxTransferDistance || Math.Abs(curCellY - destCellY) > MaxTransferDistance)
{
sp.ControllingClient.SendTeleportFailed(
string.Format(
"Can't teleport to {0} ({1},{2}) from {3} ({4},{5}), destination is more than {6} regions way",
finalDestination.RegionName, destCellX, destCellY,
sp.Scene.RegionInfo.RegionName, curCellX, curCellY,
//.........这里部分代码省略.........
示例5: CrossAttachmentsIntoNewRegion
/// <summary>
/// Cross the attachments for an avatar into the destination region.
/// </summary>
/// <remarks>
/// This is only invoked for simulators released prior to April 2011. Versions of OpenSimulator since then
/// transfer attachments in one go as part of the ChildAgentDataUpdate data passed in the update agent call.
/// </remarks>
/// <param name='destination'></param>
/// <param name='sp'></param>
/// <param name='silent'></param>
protected void CrossAttachmentsIntoNewRegion(GridRegion destination, ScenePresence sp, bool silent)
{
List<SceneObjectGroup> attachments = sp.GetAttachments();
// m_log.DebugFormat(
// "[ENTITY TRANSFER MODULE]: Crossing {0} attachments into {1} for {2}",
// m_attachments.Count, destination.RegionName, sp.Name);
foreach (SceneObjectGroup gobj in attachments)
{
// If the prim group is null then something must have happened to it!
if (gobj != null && !gobj.IsDeleted)
{
SceneObjectGroup clone = (SceneObjectGroup)gobj.CloneForNewScene();
clone.RootPart.GroupPosition = gobj.RootPart.AttachedPos;
clone.IsAttachment = false;
//gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}",
clone.UUID, destination.RegionName);
CrossPrimGroupIntoNewRegion(destination, Vector3.Zero, clone, silent);
}
}
sp.ClearAttachments();
}
示例6: TeleportAgentWithinRegion
/// <summary>
/// Teleports the agent within its current region.
/// </summary>
/// <param name="sp"></param>
/// <param name="position"></param>
/// <param name="lookAt"></param>
/// <param name="teleportFlags"></param>
private void TeleportAgentWithinRegion(ScenePresence sp, Vector3 position, Vector3 lookAt, uint teleportFlags)
{
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Teleport for {0} to {1} within {2}",
sp.Name, position, sp.Scene.RegionInfo.RegionName);
// Teleport within the same region
if (!sp.Scene.PositionIsInCurrentRegion(position) || position.Z < 0)
{
Vector3 emergencyPos = new Vector3(128, 128, 128);
m_log.WarnFormat(
"[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2} in {3}. Substituting {4}",
position, sp.Name, sp.UUID, Scene.Name, emergencyPos);
position = emergencyPos;
}
// TODO: Get proper AVG Height
float localAVHeight = 1.56f;
float posZLimit = 22;
// TODO: Check other Scene HeightField
posZLimit = (float)sp.Scene.Heightmap[(int)position.X, (int)position.Y];
float newPosZ = posZLimit + localAVHeight;
if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
{
position.Z = newPosZ;
}
if (sp.Flying)
teleportFlags |= (uint)TeleportFlags.IsFlying;
m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring);
sp.ControllingClient.SendTeleportStart(teleportFlags);
sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
sp.TeleportFlags = (Constants.TeleportFlags)teleportFlags;
sp.Velocity = Vector3.Zero;
sp.Teleport(position);
m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.ReceivedAtDestination);
foreach (SceneObjectGroup grp in sp.GetAttachments())
{
sp.Scene.EventManager.TriggerOnScriptChangedEvent(grp.LocalId, (uint)Changed.TELEPORT);
}
m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp);
}
示例7: CheckAppearanceForAttachmentCount
/// <summary>
/// Check whether the attachments of the given presence are too heavy
/// to be allowed to be used in an outfit
/// </summary>
/// <param name="presence"></param>
/// <returns></returns>
private bool CheckAppearanceForAttachmentCount(ScenePresence presence)
{
int totalAttachmentLandImpact = 0;
foreach(SceneObjectGroup grp in presence.GetAttachments())
{
totalAttachmentLandImpact += grp.LandImpact;
}
return totalAttachmentLandImpact < m_maxLandImpactAllowedByOutfitAttachments;
}
示例8: OnMakeRootAgent
protected void OnMakeRootAgent(ScenePresence sp)
{
m_log.InfoFormat("[WATER WARS]: Processing OnMakeRootAgent for {0}", sp.Name);
List<SceneObjectGroup> attachments = sp.GetAttachments();
lock (attachments)
{
foreach (SceneObjectGroup sog in attachments)
{
if (sog.Name != HudView.IN_WORLD_NAME)
continue;
RegisterHud(sp.UUID, sog.RootPart);
}
}
}
示例9: TeleportAgentWithinRegion
/// <summary>
/// Teleports the agent within its current region.
/// </summary>
/// <param name="sp"></param>
/// <param name="position"></param>
/// <param name="lookAt"></param>
/// <param name="teleportFlags"></param
private void TeleportAgentWithinRegion(ScenePresence sp, Vector3 position, Vector3 lookAt, uint teleportFlags)
{
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Teleport for {0} to {1} within {2}",
sp.Name, position, sp.Scene.RegionInfo.RegionName);
if (!SetInTransit(sp.UUID))
{
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Ignoring within region teleport request of {0} {1} to {2} - agent is already in transit.",
sp.Name, sp.UUID, position);
return;
}
// Teleport within the same region
if (IsOutsideRegion(sp.Scene, position) || position.Z < 0)
{
Vector3 emergencyPos = new Vector3(128, 128, 128);
m_log.WarnFormat(
"[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
position, sp.Name, sp.UUID, emergencyPos);
position = emergencyPos;
}
// TODO: Get proper AVG Height
float localAVHeight = 1.56f;
float posZLimit = 22;
// TODO: Check other Scene HeightField
if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize)
{
posZLimit = (float)sp.Scene.Heightmap[(int)position.X, (int)position.Y];
}
float newPosZ = posZLimit + localAVHeight;
if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
{
position.Z = newPosZ;
}
UpdateInTransit(sp.UUID, AgentTransferState.Transferring);
sp.ControllingClient.SendTeleportStart(teleportFlags);
sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
sp.Velocity = Vector3.Zero;
sp.Teleport(position);
UpdateInTransit(sp.UUID, AgentTransferState.ReceivedAtDestination);
foreach (SceneObjectGroup grp in sp.GetAttachments())
{
sp.Scene.EventManager.TriggerOnScriptChangedEvent(grp.LocalId, (uint)Changed.TELEPORT);
}
UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp);
ResetFromTransit(sp.UUID);
}
示例10: RezSingleAttachmentFromInventory
public ISceneEntity RezSingleAttachmentFromInventory(ScenePresence sp, UUID itemID, uint AttachmentPt)
{
// m_log.DebugFormat(
// "[ATTACHMENTS MODULE]: RezSingleAttachmentFromInventory to point {0} from item {1} for {2}",
// (AttachmentPoint)AttachmentPt, itemID, sp.Name);
// TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
// be removed when that functionality is implemented in opensim
AttachmentPt &= 0x7f;
// Viewer 2/3 sometimes asks to re-wear items that are already worn (and show up in it's inventory as such).
// This often happens during login - not sure the exact reason.
// For now, we will ignore the request. Unfortunately, this means that we need to dig through all the
// ScenePresence attachments. We can't use the data in AvatarAppearance because that's present at login
// before anything has actually been attached.
bool alreadyOn = false;
List<SceneObjectGroup> existingAttachments = sp.GetAttachments();
foreach (SceneObjectGroup so in existingAttachments)
{
if (so.GetFromItemID() == itemID)
{
alreadyOn = true;
break;
}
}
// if (sp.Appearance.GetAttachmentForItem(itemID) != null)
if (alreadyOn)
{
// m_log.WarnFormat(
// "[ATTACHMENTS MODULE]: Ignoring request by {0} to wear item {1} at {2} since it is already worn",
// sp.Name, itemID, AttachmentPt);
return null;
}
SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt);
if (att == null)
DetachSingleAttachmentToInv(itemID, sp.ControllingClient);
return att;
}