本文整理汇总了C#中IScenePresence.RequestModuleInterface方法的典型用法代码示例。如果您正苦于以下问题:C# IScenePresence.RequestModuleInterface方法的具体用法?C# IScenePresence.RequestModuleInterface怎么用?C# IScenePresence.RequestModuleInterface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScenePresence
的用法示例。
在下文中一共展示了IScenePresence.RequestModuleInterface方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EventManager_OnRemovePresence
void EventManager_OnRemovePresence (IScenePresence presence)
{
ScriptControllerPresenceModule m = (ScriptControllerPresenceModule)presence.RequestModuleInterface<IScriptControllerModule> ();
if (m != null)
{
m.Close ();
presence.UnregisterModuleInterface<IScriptControllerModule> (m);
}
}
示例2: Teleport
public virtual void Teleport(IScenePresence sp, GridRegion finalDestination, Vector3 position, Vector3 lookAt,
uint teleportFlags)
{
sp.ControllingClient.SendTeleportStart(teleportFlags);
sp.ControllingClient.SendTeleportProgress(teleportFlags, "requesting");
// Reset animations; the viewer does that in teleports.
if (sp.Animator != null)
sp.Animator.ResetAnimations();
try
{
string reason = "";
if (finalDestination.RegionHandle == sp.Scene.RegionInfo.RegionHandle)
{
//First check whether the user is allowed to move at all
if (!sp.Scene.Permissions.AllowedOutgoingLocalTeleport(sp.UUID, out reason))
{
sp.ControllingClient.SendTeleportFailed(reason);
return;
}
//Now respect things like parcel bans with this
if (
!sp.Scene.Permissions.AllowedIncomingTeleport(sp.UUID, position, teleportFlags, out position,
out reason))
{
sp.ControllingClient.SendTeleportFailed(reason);
return;
}
MainConsole.Instance.DebugFormat(
"[ENTITY TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}",
position, sp.Scene.RegionInfo.RegionName);
sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
sp.RequestModuleInterface<IScriptControllerModule>()
.HandleForceReleaseControls(sp.ControllingClient, sp.UUID);
sp.Teleport(position);
}
else // Another region possibly in another simulator
{
// Make sure the user is allowed to leave this region
if (!sp.Scene.Permissions.AllowedOutgoingRemoteTeleport(sp.UUID, out reason))
{
sp.ControllingClient.SendTeleportFailed(reason);
return;
}
DoTeleport(sp, finalDestination, position, lookAt, teleportFlags);
}
}
catch (Exception e)
{
MainConsole.Instance.ErrorFormat("[ENTITY TRANSFER MODULE]: Exception on teleport: {0}\n{1}", e.Message,
e.StackTrace);
sp.ControllingClient.SendTeleportFailed("Internal error");
}
}
示例3: BuildCircuitDataForPresence
private AgentCircuitData BuildCircuitDataForPresence(IScenePresence sp, Vector3 position)
{
AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo();
agentCircuit.startpos = position;
//The agent will be a root agent
agentCircuit.child = false;
//Make sure the appearnace is right
IAvatarAppearanceModule appearance = sp.RequestModuleInterface<IAvatarAppearanceModule>();
if (appearance != null && appearance.Appearance != null)
agentCircuit.Appearance = appearance.Appearance;
else
MainConsole.Instance.Error("[EntityTransferModule]: No appearance is being packed as we could not find the appearance ? " + appearance == null);
AgentCircuitData oldCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID);
agentCircuit.ServiceURLs = oldCircuit.ServiceURLs;
agentCircuit.firstname = oldCircuit.firstname;
agentCircuit.lastname = oldCircuit.lastname;
agentCircuit.ServiceSessionID = oldCircuit.ServiceSessionID;
return agentCircuit;
}
示例4: RezAttachments
public void RezAttachments (IScenePresence presence)
{
IAvatarAppearanceModule appearance = presence.RequestModuleInterface<IAvatarAppearanceModule> ();
if(null == appearance || null == appearance.Appearance)
{
m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", presence.UUID);
return;
}
//Create the avatar attachments plugin for the av
AvatarAttachments attachmentsPlugin = new AvatarAttachments(presence);
presence.RegisterModuleInterface <AvatarAttachments>(attachmentsPlugin);
List<AvatarAttachment> attachments = appearance.Appearance.GetAttachments ();
foreach (AvatarAttachment attach in attachments)
{
int p = attach.AttachPoint;
UUID itemID = attach.ItemID;
try
{
RezSingleAttachmentFromInventory(presence.ControllingClient, itemID, p);
}
catch (Exception e)
{
m_log.ErrorFormat("[ATTACHMENT]: Unable to rez attachment: {0}{1}", e.Message, e.StackTrace);
}
}
foreach(IScenePresence sp in presence.Scene.GetScenePresences())
sp.SceneViewer.QueuePresenceForFullUpdate(presence, true);
}
示例5: EventManager_OnRemovePresence
protected void EventManager_OnRemovePresence(IScenePresence presence)
{
PerClientSelectionParticles particles = presence.RequestModuleInterface<PerClientSelectionParticles>();
if (particles != null)
{
particles.Close();
presence.UnregisterModuleInterface(particles);
}
}
示例6: SuspendAvatar
public void SuspendAvatar(IScenePresence presence, GridRegion destination)
{
IAvatarAppearanceModule appearance = presence.RequestModuleInterface<IAvatarAppearanceModule>();
presence.AttachmentsLoaded = false;
ISceneEntity[] attachments = GetAttachmentsForAvatar(presence.UUID);
foreach (ISceneEntity group in attachments)
{
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;
}
}
if (group.HasGroupChanged)
{
UUID assetID = UpdateKnownItem(presence.ControllingClient, group,
group.RootChild.FromUserInventoryItemID,
group.OwnerID);
group.RootChild.FromUserInventoryAssetID = assetID;
}
}
if (appearance != null)
{
appearance.Appearance.SetAttachments(attachments);
presence.Scene.AvatarService.SetAppearance(presence.UUID,
appearance.Appearance);
}
IBackupModule backup = presence.Scene.RequestModuleInterface<IBackupModule>();
if (backup != null)
{
bool sendUpdates = destination == null;
if (!sendUpdates)
{
List<GridRegion> regions =
presence.Scene.RequestModuleInterface<IGridRegisterModule>()
.GetNeighbors(presence.Scene);
regions.RemoveAll((r) => r.RegionID != destination.RegionID);
sendUpdates = regions.Count == 0;
}
backup.DeleteSceneObjects(attachments, false, sendUpdates);
}
}
示例7: ResumeAvatar
public void ResumeAvatar(IScenePresence presence)
{
Util.FireAndForget(delegate
{
IAvatarAppearanceModule appearance =
presence.RequestModuleInterface<IAvatarAppearanceModule>();
if (null == appearance || null == appearance.Appearance)
{
MainConsole.Instance.WarnFormat(
"[ATTACHMENT]: Appearance has not been initialized for agent {0}",
presence.UUID);
return;
}
//Create the avatar attachments plugin for the av
AvatarAttachments attachmentsPlugin = new AvatarAttachments(presence);
presence.RegisterModuleInterface(attachmentsPlugin);
List<AvatarAttachment> attachments = appearance.Appearance.GetAttachments();
MainConsole.Instance.InfoFormat(
"[ATTACHMENTS MODULE]: Found {0} attachments to attach to avatar {1}",
attachments.Count, presence.Name);
foreach (AvatarAttachment attach in attachments)
{
try
{
RezSingleAttachmentFromInventory(presence.ControllingClient,
attach.ItemID, attach.AssetID, 0, false);
}
catch (Exception e)
{
MainConsole.Instance.ErrorFormat(
"[ATTACHMENT]: Unable to rez attachment: {0}", e);
}
}
presence.AttachmentsLoaded = true;
lock (_usersToSendAttachmentsToWhenLoaded)
{
if (_usersToSendAttachmentsToWhenLoaded.ContainsKey(presence.UUID))
{
foreach (var id in _usersToSendAttachmentsToWhenLoaded[presence.UUID])
{
SendAttachmentsToPresence(id, presence);
}
_usersToSendAttachmentsToWhenLoaded.Remove(presence.UUID);
}
}
});
}
示例8: MakeChildAgent
protected void MakeChildAgent (IScenePresence presence)
{
IAvatarAppearanceModule appearance = presence.RequestModuleInterface<IAvatarAppearanceModule> ();
foreach (AvatarAttachment att in appearance.Appearance.GetAttachments ())
{
//Don't fire events as we just want to remove them
// and we don't want to remove the attachment from the av either
DetachSingleAttachmentToInventoryInternal(att.ItemID, presence.ControllingClient, false);
}
}
示例9: DoTeleport
public virtual void DoTeleport(IScenePresence sp, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags)
{
sp.ControllingClient.SendTeleportProgress(teleportFlags, "sending_dest");
if (finalDestination == null)
{
sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
return;
}
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}/{2}",
finalDestination.ServerURI, finalDestination.RegionName, position);
sp.ControllingClient.SendTeleportProgress(teleportFlags, "arriving");
// Fixing a bug where teleporting while sitting results in the avatar ending up removed from
// both regions
if (sp.ParentID != UUID.Zero)
sp.StandUp();
//Make sure that all attachments are ready for the teleport
IAttachmentsModule attModule = sp.Scene.RequestModuleInterface<IAttachmentsModule>();
if (attModule != null)
attModule.ValidateAttachments(sp.UUID);
AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo();
agentCircuit.startpos = position;
//The agent will be a root agent
agentCircuit.child = false;
//Make sure the appearnace is right
IAvatarAppearanceModule appearance = sp.RequestModuleInterface<IAvatarAppearanceModule> ();
if(appearance != null)
agentCircuit.Appearance = appearance.Appearance;
AgentData agent = new AgentData();
sp.CopyTo(agent);
//Fix the position
agent.Position = position;
IEventQueueService eq = sp.Scene.RequestModuleInterface<IEventQueueService>();
if (eq != null)
{
ISyncMessagePosterService syncPoster = sp.Scene.RequestModuleInterface<ISyncMessagePosterService>();
if (syncPoster != null)
{
AgentCircuitData oldCircuit = sp.Scene.AuthenticateHandler.AgentCircuitsByUUID[sp.UUID];
agentCircuit.ServiceURLs = oldCircuit.ServiceURLs;
agentCircuit.firstname = oldCircuit.firstname;
agentCircuit.lastname = oldCircuit.lastname;
agentCircuit.ServiceSessionID = oldCircuit.ServiceSessionID;
//This does CreateAgent and sends the EnableSimulator/EstablishAgentCommunication/TeleportFinish
// messages if they need to be called and deals with the callback
OSDMap map = syncPoster.Get(SyncMessageHelper.TeleportAgent((int)sp.DrawDistance,
agentCircuit, agent, teleportFlags, finalDestination, sp.Scene.RegionInfo.RegionHandle),
sp.UUID, sp.Scene.RegionInfo.RegionHandle);
bool result = false;
if(map != null)
result = map["Success"].AsBoolean();
if (!result)
{
// Fix the agent status
sp.IsChildAgent = false;
//Fix user's attachments
attModule.RezAttachments (sp);
if (map != null)
sp.ControllingClient.SendTeleportFailed (map["Reason"].AsString ());
else
sp.ControllingClient.SendTeleportFailed ("Teleport Failed");
return;
}
else
{
//Get the new destintation, it may have changed
if(map.ContainsKey("Destination"))
{
finalDestination = new GridRegion();
finalDestination.FromOSD((OSDMap)map["Destination"]);
}
}
}
}
MakeChildAgent(sp, finalDestination);
}
示例10: ResumeAvatar
public void ResumeAvatar(IScenePresence presence)
{
Util.FireAndForget(delegate
{
IAvatarAppearanceModule appearance = presence.RequestModuleInterface<IAvatarAppearanceModule>();
if (null == appearance || null == appearance.Appearance)
{
MainConsole.Instance.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", presence.UUID);
return;
}
//Create the avatar attachments plugin for the av
AvatarAttachments attachmentsPlugin = new AvatarAttachments(presence);
presence.RegisterModuleInterface(attachmentsPlugin);
List<AvatarAttachment> attachments = appearance.Appearance.GetAttachments();
foreach (AvatarAttachment attach in attachments)
{
try
{
RezSingleAttachmentFromInventory(presence.ControllingClient, attach.ItemID, 0);
}
catch (Exception e)
{
MainConsole.Instance.ErrorFormat("[ATTACHMENT]: Unable to rez attachment: {0}", e);
}
}
});
}
示例11: EventManager_OnRemovePresence
private void EventManager_OnRemovePresence(IScenePresence presence)
{
CombatPresence m = (CombatPresence) presence.RequestModuleInterface<ICombatPresence>();
if (m != null)
{
presence.UnregisterModuleInterface<ICombatPresence>(m);
m.Close();
}
}
示例12: AvatarEnteringParcel
private void AvatarEnteringParcel(IScenePresence avatar, ILandObject oldParcel)
{
ILandObject obj = null;
IParcelManagementModule parcelManagement = avatar.Scene.RequestModuleInterface<IParcelManagementModule>();
if (parcelManagement != null)
{
obj = parcelManagement.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
}
if (obj == null)
return;
try
{
if ((obj.LandData.Flags & (uint) ParcelFlags.AllowDamage) != 0)
{
ICombatPresence CP = avatar.RequestModuleInterface<ICombatPresence>();
CP.Health = MaximumHealth;
avatar.Invulnerable = false;
}
else
{
avatar.Invulnerable = true;
}
}
catch (Exception)
{
}
}
示例13: InBoundingBox
private bool InBoundingBox(IScenePresence avatar, Vector3 point)
{
float height = avatar.RequestModuleInterface<IAvatarAppearanceModule>().Appearance.AvatarHeight;
Vector3 b1 = avatar.AbsolutePosition + new Vector3(-0.22f, -0.22f, -height / 2);
Vector3 b2 = avatar.AbsolutePosition + new Vector3(0.22f, 0.22f, height / 2);
if (point.X > b1.X && point.X < b2.X &&
point.Y > b1.Y && point.Y < b2.Y &&
point.Z > b1.Z && point.Z < b2.Z)
return true;
return false;
}
示例14: SendFullUpdateForPresence
protected void SendFullUpdateForPresence (IScenePresence presence)
{
m_presence.ControllingClient.SendAvatarDataImmediate (presence);
//Send the animations too
presence.Animator.SendAnimPackToClient (m_presence.ControllingClient);
//Send the presence of this agent to us
IAvatarAppearanceModule module = presence.RequestModuleInterface<IAvatarAppearanceModule>();
if(module != null)
module.SendAppearanceToAgent(m_presence);
//We need to send all attachments of this avatar as well
IAttachmentsModule attmodule = m_presence.Scene.RequestModuleInterface<IAttachmentsModule>();
if (attmodule != null)
{
ISceneEntity[] entities = attmodule.GetAttachmentsForAvatar (m_presence.UUID);
foreach (ISceneEntity entity in entities)
{
foreach (ISceneChildEntity child in entity.ChildrenEntities ())
{
QueuePartForUpdate (child, PrimUpdateFlags.ForcedFullUpdate);
}
}
}
}
示例15: SaveAppearanceToNotecard
protected LSL_Key SaveAppearanceToNotecard(IScenePresence sp, string notecard)
{
IAvatarAppearanceModule aa = sp.RequestModuleInterface<IAvatarAppearanceModule> ();
if (aa != null)
{
var appearance = new AvatarAppearance (aa.Appearance);
OSDMap appearancePacked = appearance.Pack ();
TaskInventoryItem item
= SaveNotecard (notecard, "Avatar Appearance", OSDParser.SerializeLLSDXmlString(appearancePacked), true);
return new LSL_Key (item.AssetID.ToString ());
}
return new LSL_Key(UUID.Zero.ToString());
}