本文整理汇总了C#中OpenSim.Region.Framework.Scenes.Scene.TryGetScenePresence方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.TryGetScenePresence方法的具体用法?C# Scene.TryGetScenePresence怎么用?C# Scene.TryGetScenePresence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenSim.Region.Framework.Scenes.Scene
的用法示例。
在下文中一共展示了Scene.TryGetScenePresence方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNPC
public UUID CreateNPC(
string firstname,
string lastname,
Vector3 position,
UUID owner,
bool senseAsAgent,
Scene scene,
AvatarAppearance appearance)
{
NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, senseAsAgent, scene);
npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue);
m_log.DebugFormat(
"[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}",
firstname, lastname, npcAvatar.AgentId, owner, senseAsAgent, position, scene.RegionInfo.RegionName);
AgentCircuitData acd = new AgentCircuitData();
acd.AgentID = npcAvatar.AgentId;
acd.firstname = firstname;
acd.lastname = lastname;
acd.ServiceURLs = new Dictionary<string, object>();
AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
acd.Appearance = npcAppearance;
// for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++)
// {
// m_log.DebugFormat(
// "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}",
// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);
// }
lock (m_avatars)
{
scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
scene.AddNewClient(npcAvatar, PresenceType.Npc);
ScenePresence sp;
if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
{
// m_log.DebugFormat(
// "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
sp.CompleteMovement(npcAvatar, false);
m_avatars.Add(npcAvatar.AgentId, npcAvatar);
m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);
return npcAvatar.AgentId;
}
else
{
m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
return UUID.Zero;
}
}
}
示例2: CreateNPC
public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom)
{
NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene);
npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue);
m_log.DebugFormat(
"[NPC MODULE]: Creating NPC {0} {1} {2} at {3} in {4}",
firstname, lastname, npcAvatar.AgentId, position, scene.RegionInfo.RegionName);
AgentCircuitData acd = new AgentCircuitData();
acd.AgentID = npcAvatar.AgentId;
acd.firstname = firstname;
acd.lastname = lastname;
acd.ServiceURLs = new Dictionary<string, object>();
AvatarAppearance originalAppearance = GetAppearance(cloneAppearanceFrom, scene);
AvatarAppearance npcAppearance = new AvatarAppearance(originalAppearance, true);
acd.Appearance = npcAppearance;
scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
scene.AddNewClient(npcAvatar);
ScenePresence sp;
if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
{
m_log.DebugFormat(
"[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
// Shouldn't call this - temporary.
sp.CompleteMovement(npcAvatar);
// sp.SendAppearanceToAllOtherAgents();
//
// // Send animations back to the avatar as well
// sp.Animator.SendAnimPack();
}
else
{
m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
}
lock (m_avatars)
m_avatars.Add(npcAvatar.AgentId, npcAvatar);
m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);
return npcAvatar.AgentId;
}
示例3: Autopilot
public void Autopilot(UUID agentID, Scene scene, Vector3 pos)
{
lock (m_avatars)
{
if (m_avatars.ContainsKey(agentID))
{
ScenePresence sp;
scene.TryGetScenePresence(agentID, out sp);
sp.DoAutoPilot(0, pos, m_avatars[agentID]);
}
}
}
示例4: Whisper
public bool Whisper(UUID agentID, Scene scene, string text, int channel)
{
lock (m_avatars)
{
if (m_avatars.ContainsKey(agentID))
{
ScenePresence sp;
scene.TryGetScenePresence(agentID, out sp);
m_avatars[agentID].Whisper(channel, text);
return true;
}
}
return false;
}
示例5: AllowTeleport
//.........这里部分代码省略.........
{
newPosition = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
}
else
{
int LastTelehubNum = 0;
if (!LastTelehub.TryGetValue(scene.RegionInfo.RegionID, out LastTelehubNum))
LastTelehubNum = 0;
newPosition = telehub.SpawnPos[LastTelehubNum] + new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
LastTelehubNum++;
if (LastTelehubNum == telehub.SpawnPos.Count)
LastTelehubNum = 0;
LastTelehub[scene.RegionInfo.RegionID] = LastTelehubNum;
}
}
else
{
reason = "Teleport has been blocked for this region.";
return false;
}
}
else
{
//If they are owner, they don't have to have permissions checked
if (!m_scene.Permissions.GenericParcelPermission(userID, ILO, (ulong)GroupPowers.None))
{
if (ILO.LandData.LandingType == 2) //Blocked, force this person off this land
{
//Find a new parcel for them
List<ILandObject> Parcels = m_scene.LandChannel.ParcelsNearPoint(Position);
if (Parcels.Count == 0)
{
ScenePresence SP;
scene.TryGetScenePresence(userID, out SP);
newPosition = m_scene.LandChannel.GetNearestRegionEdgePosition(SP);
}
else
{
bool found = false;
//We need to check here as well for bans, can't toss someone into a parcel they are banned from
foreach (ILandObject Parcel in Parcels)
{
if (!Parcel.IsBannedFromLand(userID))
{
//Now we have to check their userloc
if (ILO.LandData.LandingType == 2)
continue; //Blocked, check next one
else if (ILO.LandData.LandingType == 1) //Use their landing spot
newPosition = Parcel.LandData.UserLocation;
else //They allow for anywhere, so dump them in the center at the ground
newPosition = m_scene.LandChannel.GetParcelCenterAtGround(Parcel);
found = true;
}
}
if (!found) //Dump them at the edge
{
if(Sp != null)
newPosition = m_scene.LandChannel.GetNearestRegionEdgePosition(Sp);
else
{
reason = "Banned from this parcel.";
return true;
}
}
}
}
示例6: Say
public bool Say(UUID agentID, Scene scene, string text)
{
lock (m_avatars)
{
if (m_avatars.ContainsKey(agentID))
{
ScenePresence sp;
scene.TryGetScenePresence(agentID, out sp);
m_avatars[agentID].Say(text);
return true;
}
}
return false;
}
示例7: Stand
public bool Stand(UUID agentID, Scene scene)
{
lock (m_avatars)
{
if (m_avatars.ContainsKey(agentID))
{
ScenePresence sp;
scene.TryGetScenePresence(agentID, out sp);
sp.StandUp();
return true;
}
}
return false;
}
示例8: MoveToTarget
public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos,
bool noFly, bool landAtTarget, bool running)
{
lock (m_avatars)
{
if (m_avatars.ContainsKey(agentID))
{
ScenePresence sp;
if (scene.TryGetScenePresence(agentID, out sp))
{
if (sp.IsSatOnObject || sp.SitGround)
return false;
// m_log.DebugFormat(
// "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}",
// sp.Name, pos, scene.RegionInfo.RegionName,
// noFly, landAtTarget);
sp.MoveToTarget(pos, noFly, landAtTarget);
sp.SetAlwaysRun = running;
return true;
}
}
}
return false;
}
示例9: OnAllowedIncomingTeleport
//.........这里部分代码省略.........
{
newPosition = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
}
else
{
int LastTelehubNum = 0;
if (!LastTelehub.TryGetValue(scene.RegionInfo.RegionID, out LastTelehubNum))
LastTelehubNum = 0;
newPosition = telehub.SpawnPos[LastTelehubNum] + new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
LastTelehubNum++;
if (LastTelehubNum == telehub.SpawnPos.Count)
LastTelehubNum = 0;
LastTelehub[scene.RegionInfo.RegionID] = LastTelehubNum;
}
}
else
{
reason = "Teleport has been blocked for this region.";
return false;
}
}
else
{
//If they are owner, they don't have to have permissions checked
if (!scene.Permissions.GenericParcelPermission(userID, ILO, (ulong)GroupPowers.None))
{
if (ILO.LandData.LandingType == 2) //Blocked, force this person off this land
{
//Find a new parcel for them
List<ILandObject> Parcels = parcelManagement.ParcelsNearPoint(Position);
if (Parcels.Count == 0)
{
ScenePresence SP;
scene.TryGetScenePresence(userID, out SP);
newPosition = parcelManagement.GetNearestRegionEdgePosition(SP);
}
else
{
bool found = false;
//We need to check here as well for bans, can't toss someone into a parcel they are banned from
foreach (ILandObject Parcel in Parcels)
{
if (!Parcel.IsBannedFromLand(userID))
{
//Now we have to check their userloc
if (ILO.LandData.LandingType == 2)
continue; //Blocked, check next one
else if (ILO.LandData.LandingType == 1) //Use their landing spot
newPosition = Parcel.LandData.UserLocation;
else //They allow for anywhere, so dump them in the center at the ground
newPosition = parcelManagement.GetParcelCenterAtGround(Parcel);
found = true;
}
}
if (!found) //Dump them at the edge
{
if (Sp != null)
newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp);
else
{
reason = "Banned from this parcel.";
return true;
}
}
}
}
示例10: Sit
public bool Sit(UUID agentID, UUID partID, Scene scene)
{
m_avatarsRwLock.AcquireReaderLock(-1);
try
{
if (m_avatars.ContainsKey(agentID))
{
ScenePresence sp;
if (scene.TryGetScenePresence(agentID, out sp))
{
sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero);
return true;
}
}
}
finally
{
m_avatarsRwLock.ReleaseReaderLock();
}
return false;
}
示例11: Stand
public bool Stand(UUID agentID, Scene scene)
{
m_avatarsRwLock.AcquireReaderLock(-1);
try
{
if (m_avatars.ContainsKey(agentID))
{
ScenePresence sp;
if (scene.TryGetScenePresence(agentID, out sp))
{
sp.StandUp();
return true;
}
}
}
finally
{
m_avatarsRwLock.ReleaseReaderLock();
}
return false;
}
示例12: StopMoveToTarget
public bool StopMoveToTarget(UUID agentID, Scene scene)
{
m_avatarsRwLock.AcquireReaderLock(-1);
try
{
if (m_avatars.ContainsKey(agentID))
{
ScenePresence sp;
if (scene.TryGetScenePresence(agentID, out sp))
{
sp.Velocity = Vector3.Zero;
sp.ResetMoveToTarget();
return true;
}
}
}
finally
{
m_avatarsRwLock.ReleaseReaderLock();
}
return false;
}
示例13: CreateNPC
public UUID CreateNPC(string firstname, string lastname,
Vector3 position, UUID agentID, UUID owner, bool senseAsAgent, Scene scene,
AvatarAppearance appearance)
{
NPCAvatar npcAvatar = null;
try
{
if (agentID == UUID.Zero)
npcAvatar = new NPCAvatar(firstname, lastname, position,
owner, senseAsAgent, scene);
else
npcAvatar = new NPCAvatar(firstname, lastname, agentID, position,
owner, senseAsAgent, scene);
}
catch (Exception e)
{
m_log.Info("[NPC MODULE]: exception creating NPC avatar: " + e.ToString());
return UUID.Zero;
}
npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0,
int.MaxValue);
m_log.DebugFormat(
"[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}",
firstname, lastname, npcAvatar.AgentId, owner,
senseAsAgent, position, scene.RegionInfo.RegionName);
AgentCircuitData acd = new AgentCircuitData();
acd.AgentID = npcAvatar.AgentId;
acd.firstname = firstname;
acd.lastname = lastname;
acd.ServiceURLs = new Dictionary<string, object>();
AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
acd.Appearance = npcAppearance;
/*
for (int i = 0;
i < acd.Appearance.Texture.FaceTextures.Length; i++)
{
m_log.DebugFormat(
"[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}",
acd.AgentID, i,
acd.Appearance.Texture.FaceTextures[i]);
}
*/
m_avatarsRwLock.AcquireWriterLock(-1);
try
{
scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode,
acd);
scene.AddNewAgent(npcAvatar, PresenceType.Npc);
ScenePresence sp;
if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
{
/*
m_log.DebugFormat(
"[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}",
sp.Name, sp.UUID);
*/
sp.CompleteMovement(npcAvatar, false);
m_avatars.Add(npcAvatar.AgentId, npcAvatar);
m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name);
return npcAvatar.AgentId;
}
else
{
m_log.WarnFormat(
"[NPC MODULE]: Could not find scene presence for NPC {0} {1}",
sp.Name, sp.UUID);
return UUID.Zero;
}
}
finally
{
m_avatarsRwLock.ReleaseWriterLock();
}
}
示例14: CreateNPC
public UUID CreateNPC(string firstname, string lastname,
Vector3 position, UUID agentID, UUID owner, string groupTitle, UUID groupID, bool senseAsAgent, Scene scene,
AvatarAppearance appearance)
{
NPCAvatar npcAvatar = null;
try
{
if (agentID == UUID.Zero)
npcAvatar = new NPCAvatar(firstname, lastname, position,
owner, senseAsAgent, scene);
else
npcAvatar = new NPCAvatar(firstname, lastname, agentID, position,
owner, senseAsAgent, scene);
}
catch (Exception e)
{
m_log.Info("[NPC MODULE]: exception creating NPC avatar: " + e.ToString());
return UUID.Zero;
}
npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0,
int.MaxValue);
// m_log.DebugFormat(
// "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}",
// firstname, lastname, npcAvatar.AgentId, owner, senseAsAgent, position, scene.RegionInfo.RegionName);
AgentCircuitData acd = new AgentCircuitData();
acd.AgentID = npcAvatar.AgentId;
acd.firstname = firstname;
acd.lastname = lastname;
acd.ServiceURLs = new Dictionary<string, object>();
AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
acd.Appearance = npcAppearance;
/*
for (int i = 0;
i < acd.Appearance.Texture.FaceTextures.Length; i++)
{
m_log.DebugFormat(
"[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}",
acd.AgentID, i,
acd.Appearance.Texture.FaceTextures[i]);
}
*/
// ManualResetEvent ev = new ManualResetEvent(false);
// Util.FireAndForget(delegate(object x) {
lock (m_avatars)
{
scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
scene.AddNewAgent(npcAvatar, PresenceType.Npc);
ScenePresence sp;
if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
{
npcAvatar.ActiveGroupId = groupID;
sp.CompleteMovement(npcAvatar, false);
sp.Grouptitle = groupTitle;
m_avatars.Add(npcAvatar.AgentId, npcAvatar);
// m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name);
}
}
// ev.Set();
// });
// ev.WaitOne();
// m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);
return npcAvatar.AgentId;
}
示例15: MoveToTarget
public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget)
{
lock (m_avatars)
{
if (m_avatars.ContainsKey(agentID))
{
ScenePresence sp;
scene.TryGetScenePresence(agentID, out sp);
m_log.DebugFormat(
"[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}",
sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget);
sp.MoveToTarget(pos, noFly, landAtTarget);
return true;
}
}
return false;
}