本文整理汇总了C#中OpenSim.Region.Framework.Scenes.Scene.GetScenePresence方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.GetScenePresence方法的具体用法?C# Scene.GetScenePresence怎么用?C# Scene.GetScenePresence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenSim.Region.Framework.Scenes.Scene
的用法示例。
在下文中一共展示了Scene.GetScenePresence方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsNPC
public bool IsNPC(UUID agentId, Scene scene)
{
// FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect
// that directly).
ScenePresence sp = scene.GetScenePresence(agentId);
if (sp == null || sp.IsChildAgent)
return false;
lock (m_avatars)
return m_avatars.ContainsKey(agentId);
}
示例2: EventManager_OnClientClosed
void EventManager_OnClientClosed(UUID clientID, Scene scene)
{
ScenePresence sp = scene.GetScenePresence(clientID);
if (sp != null)
{
if (m_SeenMapBlocks.ContainsKey(clientID))
{
List<MapBlockData> mapBlocks = m_SeenMapBlocks[clientID];
foreach (MapBlockData b in mapBlocks)
{
b.Name = string.Empty;
b.Access = 254; // means 'simulator is offline'. We need this because the viewer ignores 255's
}
m_log.DebugFormat("[HG MAP]: Reseting {0} blocks", mapBlocks.Count);
sp.ControllingClient.SendMapBlock(mapBlocks, 0);
m_SeenMapBlocks.Remove(clientID);
}
}
}
示例3: SetNPCAppearance
public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene)
{
ScenePresence sp = scene.GetScenePresence(agentId);
if (sp == null || sp.IsChildAgent)
return false;
lock (m_avatars)
if (!m_avatars.ContainsKey(agentId))
return false;
scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false);
AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
sp.Appearance = npcAppearance;
scene.AttachmentsModule.RezAttachments(sp);
IAvatarFactoryModule module = scene.RequestModuleInterface<IAvatarFactoryModule>();
module.SendAppearance(sp.UUID);
return true;
}
示例4: GetAppearance
private AvatarAppearance GetAppearance(UUID target, Scene scene)
{
if (m_appearanceCache.ContainsKey(target))
return m_appearanceCache[target];
ScenePresence originalPresence = scene.GetScenePresence(target);
if (originalPresence != null)
{
AvatarAppearance originalAppearance = originalPresence.Appearance;
m_appearanceCache.Add(target, originalAppearance);
return originalAppearance;
}
else
{
m_log.DebugFormat(
"[NPC MODULE]: Avatar {0} is not in the scene for us to grab baked textures from them. Using defaults.", target);
return new AvatarAppearance();
}
}
示例5: OnClosingClient
public void OnClosingClient(UUID clientID, Scene scene)
{
//Clear out the auth speakers list
lock (m_authorizedSpeakers)
{
if (m_authorizedSpeakers.Contains(clientID))
m_authorizedSpeakers.Remove(clientID);
}
ScenePresence presence = scene.GetScenePresence(clientID);
//Announce the closing agent if enabled
if (m_announceClosedAgents)
{
scene.ForEachScenePresence(delegate(ScenePresence SP)
{
if (SP.UUID != clientID && !SP.IsChildAgent)
{
IEntityCountModule entityCountModule = scene.RequestModuleInterface<IEntityCountModule>();
if (entityCountModule != null)
SP.ControllingClient.SendChatMessage(presence.Name + " has left the region. Total Agents: " + entityCountModule.RootAgents, 1, SP.AbsolutePosition, "System",
UUID.Zero, (byte)ChatSourceType.System, (byte)ChatAudibleLevel.Fully);
}
}
);
}
}
示例6: EventManager_OnClientClosed
/// <summary>
/// Installs terrain brush hook to IClientAPI
/// </summary>
/// <param name="client"></param>
private void EventManager_OnClientClosed(UUID client, Scene scene)
{
ScenePresence presence = scene.GetScenePresence(client);
if (presence != null)
{
presence.ControllingClient.OnModifyTerrain -= client_OnModifyTerrain;
presence.ControllingClient.OnBakeTerrain -= client_OnBakeTerrain;
presence.ControllingClient.OnLandUndo -= client_OnLandUndo;
presence.ControllingClient.OnUnackedTerrain -= client_OnUnackedTerrain;
}
}
示例7: ProvisionVoiceAccountRequest
/// Callback for a client request for Voice Account Details.
public string ProvisionVoiceAccountRequest(Scene scene, string request, string path, string param,
UUID agentID, Caps caps)
{
try {
m_log.Info("[MurmurVoice]: Calling ProvisionVoiceAccountRequest...");
ScenePresence avatar = null;
if (scene == null) throw new Exception("[MurmurVoice] Invalid scene.");
avatar = scene.GetScenePresence(agentID);
while(avatar == null)
{
avatar = scene.GetScenePresence(agentID);
Thread.Sleep(100);
}
Agent agent = m_manager.Agent.GetOrCreate(agentID);
LLSDVoiceAccountResponse voiceAccountResponse =
new LLSDVoiceAccountResponse(agent.web, agent.pass, m_murmurd_exthost,
String.Format("tcp://{0}:{1}", m_murmurd_exthost, m_murmurd_port)
);
string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse);
m_log.InfoFormat("[MurmurVoice]: VoiceAccount: {0}", r);
return r;
} catch (Exception e) {
m_log.DebugFormat("[MurmurVoice]: {0} failed", e.ToString());
return "<llsd><undef /></llsd>";
}
}
示例8: ChatSessionRequest
/// Callback for a client request for a private chat channel
public string ChatSessionRequest(Scene scene, string request, string path, string param,
UUID agentID, Caps caps)
{
ScenePresence avatar = scene.GetScenePresence(agentID);
string avatarName = avatar.Name;
m_log.DebugFormat("[MurmurVoice] Chat Session: avatar \"{0}\": request: {1}, path: {2}, param: {3}",
avatarName, request, path, param);
return "<llsd>true</llsd>";
}
示例9: ProvisionVoiceAccountRequest
/// <summary>
/// Callback for a client request for Voice Account Details
/// </summary>
/// <param name="scene">current scene object of the client</param>
/// <param name="request"></param>
/// <param name="path"></param>
/// <param name="param"></param>
/// <param name="agentID"></param>
/// <param name="caps"></param>
/// <returns></returns>
public string ProvisionVoiceAccountRequest(Scene scene, string request, string path, string param,
UUID agentID, Caps caps)
{
m_log.DebugFormat(
"[FreeSwitchVoice][PROVISIONVOICE]: ProvisionVoiceAccountRequest() request: {0}, path: {1}, param: {2}", request, path, param);
ScenePresence avatar = scene.GetScenePresence(agentID);
if (avatar == null)
{
System.Threading.Thread.Sleep(2000);
avatar = scene.GetScenePresence(agentID);
if (avatar == null)
return "<llsd>undef</llsd>";
}
string avatarName = avatar.Name;
try
{
//XmlElement resp;
string agentname = "x" + Convert.ToBase64String(agentID.GetBytes());
string password = "1234";//temp hack//new UUID(Guid.NewGuid()).ToString().Replace('-','Z').Substring(0,16);
// XXX: we need to cache the voice credentials, as
// FreeSwitch is later going to come and ask us for
// those
agentname = agentname.Replace('+', '-').Replace('/', '_');
lock (m_UUIDName)
{
if (m_UUIDName.ContainsKey(agentname))
{
m_UUIDName[agentname] = avatarName;
}
else
{
m_UUIDName.Add(agentname, avatarName);
}
}
// LLSDVoiceAccountResponse voiceAccountResponse =
// new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, "http://etsvc02.hursley.ibm.com/api");
LLSDVoiceAccountResponse voiceAccountResponse =
new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm,
String.Format("http://{0}:{1}{2}/", m_openSimWellKnownHTTPAddress,
m_freeSwitchServicePort, m_freeSwitchAPIPrefix));
string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse);
// m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1}", avatarName, r);
return r;
}
catch (Exception e)
{
m_log.ErrorFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1}, retry later", avatarName, e.Message);
m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1} failed", avatarName, e.ToString());
return "<llsd>undef</llsd>";
}
}
示例10: CanDeedObject
private bool CanDeedObject(UUID user, UUID group, Scene scene)
{
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
if (m_bypassPermissions) return m_bypassPermissionsValue;
ScenePresence sp = scene.GetScenePresence(user);
IClientAPI client = sp.ControllingClient;
if ((client.GetGroupPowers(group) & (ulong)GroupPowers.DeedObject) == 0)
return false;
return true;
}
示例11: CanReturnObjects
private bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene)
{
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
if (m_bypassPermissions) return m_bypassPermissionsValue;
GroupPowers powers;
ILandObject l;
ScenePresence sp = scene.GetScenePresence(user);
if (sp == null)
return false;
IClientAPI client = sp.ControllingClient;
foreach (SceneObjectGroup g in new List<SceneObjectGroup>(objects))
{
// Any user can return their own objects at any time
//
if (GenericObjectPermission(user, g.UUID, false))
continue;
// This is a short cut for efficiency. If land is non-null,
// then all objects are on that parcel and we can save
// ourselves the checking for each prim. Much faster.
//
if (land != null)
{
l = land;
}
else
{
Vector3 pos = g.AbsolutePosition;
l = scene.LandChannel.GetLandObject(pos.X, pos.Y);
}
// If it's not over any land, then we can't do a thing
if (l == null)
{
objects.Remove(g);
continue;
}
// If we own the land outright, then allow
//
if (l.LandData.OwnerID == user)
continue;
// Group voodoo
//
if (l.LandData.IsGroupOwned)
{
powers = (GroupPowers)client.GetGroupPowers(l.LandData.GroupID);
// Not a group member, or no rights at all
//
if (powers == (GroupPowers)0)
{
objects.Remove(g);
continue;
}
// Group deeded object?
//
if (g.OwnerID == l.LandData.GroupID &&
(powers & GroupPowers.ReturnGroupOwned) == (GroupPowers)0)
{
objects.Remove(g);
continue;
}
// Group set object?
//
if (g.GroupID == l.LandData.GroupID &&
(powers & GroupPowers.ReturnGroupSet) == (GroupPowers)0)
{
objects.Remove(g);
continue;
}
if ((powers & GroupPowers.ReturnNonGroup) == (GroupPowers)0)
{
objects.Remove(g);
continue;
}
// So we can remove all objects from this group land.
// Fine.
//
continue;
}
// By default, we can't remove
//
objects.Remove(g);
}
if (objects.Count == 0)
return false;
return true;
//.........这里部分代码省略.........
示例12: SetNPCAppearance
public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene)
{
ScenePresence npc = scene.GetScenePresence(agentId);
if (npc == null || npc.IsChildAgent)
return false;
lock (m_avatars)
if (!m_avatars.ContainsKey(agentId))
return false;
// Delete existing npc attachments
scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false);
// XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet since it doesn't transfer attachments
AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
npc.Appearance = npcAppearance;
// Rez needed npc attachments
scene.AttachmentsModule.RezAttachments(npc);
IAvatarFactoryModule module = scene.RequestModuleInterface<IAvatarFactoryModule>();
module.SendAppearance(npc.UUID);
return true;
}
示例13: PollServiceInventoryEventArgs
public PollServiceInventoryEventArgs(Scene scene, string url, UUID pId) :
base(null, url, null, null, null, pId, int.MaxValue)
{
m_scene = scene;
HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); };
GetEvents = (x, y) =>
{
lock (responses)
{
try
{
return responses[x];
}
finally
{
responses.Remove(x);
}
}
};
Request = (x, y) =>
{
ScenePresence sp = m_scene.GetScenePresence(Id);
if (sp == null)
{
m_log.ErrorFormat("[INVENTORY]: Unable to find ScenePresence for {0}", Id);
return;
}
aPollRequest reqinfo = new aPollRequest();
reqinfo.thepoll = this;
reqinfo.reqID = x;
reqinfo.request = y;
reqinfo.presence = sp;
reqinfo.folders = new List<UUID>();
// Decode the request here
string request = y["body"].ToString();
request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>");
request = request.Replace("<key>fetch_folders</key><integer>0</integer>", "<key>fetch_folders</key><boolean>0</boolean>");
request = request.Replace("<key>fetch_folders</key><integer>1</integer>", "<key>fetch_folders</key><boolean>1</boolean>");
Hashtable hash = new Hashtable();
try
{
hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
}
catch (LLSD.LLSDParseException e)
{
m_log.ErrorFormat("[INVENTORY]: Fetch error: {0}{1}" + e.Message, e.StackTrace);
m_log.Error("Request: " + request);
return;
}
catch (System.Xml.XmlException)
{
m_log.ErrorFormat("[INVENTORY]: XML Format error");
}
ArrayList foldersrequested = (ArrayList)hash["folders"];
bool highPriority = false;
for (int i = 0; i < foldersrequested.Count; i++)
{
Hashtable inventoryhash = (Hashtable)foldersrequested[i];
string folder = inventoryhash["folder_id"].ToString();
UUID folderID;
if (UUID.TryParse(folder, out folderID))
{
if (!reqinfo.folders.Contains(folderID))
{
//TODO: Port COF handling from Avination
reqinfo.folders.Add(folderID);
}
}
}
if (highPriority)
m_queue.EnqueueHigh(reqinfo);
else
m_queue.EnqueueLow(reqinfo);
};
NoEvents = (x, y) =>
{
/*
lock (requests)
{
Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString());
requests.Remove(request);
}
*/
Hashtable response = new Hashtable();
response["int_response_code"] = 500;
response["str_response_string"] = "Script timeout";
response["content_type"] = "text/plain";
//.........这里部分代码省略.........
示例14: OnAllowedIncomingAgent
private bool OnAllowedIncomingAgent(Scene scene, AgentCircuitData agent, bool isRootAgent, out string reason)
{
#region Incoming Agent Checks
Vector3 Position = agent.startpos;
UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, agent.AgentID);
ScenePresence Sp = scene.GetScenePresence(agent.AgentID);
if (account == null)
{
reason = "Failed authentication.";
return false; //NO!
}
if (LoginsDisabled)
{
reason = "Logins Disabled";
return false;
}
//Check how long its been since the last TP
if (m_enabledBlockTeleportSeconds && Sp != null && !Sp.IsChildAgent)
{
if (TimeSinceLastTeleport.ContainsKey(Sp.Scene.RegionInfo.RegionID))
{
if (TimeSinceLastTeleport[Sp.Scene.RegionInfo.RegionID] > Util.UnixTimeSinceEpoch())
{
reason = "Too many teleports. Please try again soon.";
return false; // Too soon since the last TP
}
}
TimeSinceLastTeleport[Sp.Scene.RegionInfo.RegionID] = Util.UnixTimeSinceEpoch() + ((int)(SecondsBeforeNextTeleport));
}
//Gods tp freely
if ((Sp != null && Sp.GodLevel != 0) || account.UserLevel != 0)
{
reason = "";
return true;
}
//Check whether they fit any ban criteria
if (Sp != null)
{
foreach (string banstr in BanCriteria)
{
if (Sp.Name.Contains(banstr))
{
reason = "You have been banned from this region.";
return false;
}
else if (((System.Net.IPEndPoint)Sp.ControllingClient.GetClientEP()).Address.ToString().Contains(banstr))
{
reason = "You have been banned from this region.";
return false;
}
}
//Make sure they exist in the grid right now
IPresenceService presence = scene.RequestModuleInterface<IPresenceService>();
if (presence == null)
{
reason = String.Format("Failed to verify user presence in the grid for {0} in region {1}. Presence service does not exist.", account.Name, scene.RegionInfo.RegionName);
return false;
}
OpenSim.Services.Interfaces.PresenceInfo pinfo = presence.GetAgent(agent.SessionID);
if (pinfo == null)
{
reason = String.Format("Failed to verify user presence in the grid for {0}, access denied to region {1}.", account.Name, scene.RegionInfo.RegionName);
return false;
}
}
EstateSettings ES = scene.RegionInfo.EstateSettings;
IEntityCountModule entityCountModule = scene.RequestModuleInterface<IEntityCountModule>();
if (entityCountModule != null && scene.RegionInfo.RegionSettings.AgentLimit
< entityCountModule.RootAgents + 1)
{
reason = "Too many agents at this time. Please come back later.";
return false;
}
List<EstateBan> EstateBans = new List<EstateBan>(ES.EstateBans);
int i = 0;
//Check bans
foreach (EstateBan ban in EstateBans)
{
if (ban.BannedUserID == agent.AgentID)
{
if (Sp != null)
{
string banIP = ((System.Net.IPEndPoint)Sp.ControllingClient.GetClientEP()).Address.ToString();
if (ban.BannedHostIPMask != banIP) //If it changed, ban them again
{
//Add the ban with the new hostname
ES.AddBan(new EstateBan()
//.........这里部分代码省略.........
示例15: OnAllowedIncomingTeleport
private bool OnAllowedIncomingTeleport(UUID userID, Scene scene, Vector3 Position, out Vector3 newPosition, out string reason)
{
newPosition = Position;
UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, userID);
ScenePresence Sp = scene.GetScenePresence(userID);
if (account == null)
{
reason = "Failed authentication.";
return false; //NO!
}
//Make sure that this user is inside the region as well
if (Position.X < 0f || Position.Y < 0f ||
Position.X > scene.RegionInfo.RegionSizeX || Position.Y > scene.RegionInfo.RegionSizeY)
{
m_log.DebugFormat(
"[EstateService]: AllowedIncomingTeleport was given an illegal position of {0} for avatar {1}, {2}. Clamping",
Position, Name, userID);
bool changedX = false;
bool changedY = false;
while (Position.X < 0)
{
Position.X += scene.RegionInfo.RegionSizeX;
changedX = true;
}
while (Position.X > scene.RegionInfo.RegionSizeX)
{
Position.X -= scene.RegionInfo.RegionSizeX;
changedX = true;
}
while (Position.Y < 0)
{
Position.Y += scene.RegionInfo.RegionSizeY;
changedY = true;
}
while (Position.Y > scene.RegionInfo.RegionSizeY)
{
Position.Y -= scene.RegionInfo.RegionSizeY;
changedY = true;
}
if (changedX)
Position.X = scene.RegionInfo.RegionSizeX - Position.X;
if(changedY)
Position.Y = scene.RegionInfo.RegionSizeY - Position.Y;
}
//Check that we are not underground as well
float posZLimit = (float)scene.RequestModuleInterface<ITerrainChannel>()[(int)Position.X, (int)Position.Y];
if (posZLimit >= (Position.Z) && !(Single.IsInfinity(posZLimit) || Single.IsNaN(posZLimit)))
{
Position.Z = posZLimit;
}
IAgentConnector AgentConnector = DataManager.DataManager.RequestPlugin<IAgentConnector>();
IAgentInfo agentInfo = null;
if (AgentConnector != null)
agentInfo = AgentConnector.GetAgent(userID);
ILandObject ILO = null;
IParcelManagementModule parcelManagement = scene.RequestModuleInterface<IParcelManagementModule>();
if (parcelManagement != null)
ILO = parcelManagement.GetLandObject(Position.X, Position.Y);
if (ILO == null)
{
//Can't find land, give them the first parcel in the region and find a good position for them
ILO = parcelManagement.AllParcels()[0];
Position = parcelManagement.GetParcelCenterAtGround(ILO);
}
//parcel permissions
if (ILO.IsBannedFromLand(userID)) //Note: restricted is dealt with in the next block
{
if (Sp == null)
{
reason = "Banned from this parcel.";
return true;
}
if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
{
//We found a place for them, but we don't need to check any further
return true;
}
}
//Move them out of banned parcels
ParcelFlags parcelflags = (ParcelFlags)ILO.LandData.Flags;
if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup &&
(parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList &&
(parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList)
{
//One of these is in play then
if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup)
{
if (Sp == null)
{
//.........这里部分代码省略.........