本文整理汇总了C#中IScene.ForEachScenePresence方法的典型用法代码示例。如果您正苦于以下问题:C# IScene.ForEachScenePresence方法的具体用法?C# IScene.ForEachScenePresence怎么用?C# IScene.ForEachScenePresence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScene
的用法示例。
在下文中一共展示了IScene.ForEachScenePresence方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetDebugPacketName
/// <summary>
/// Set the debug packet level on the current scene. This level governs which packets are printed out to the
/// console.
/// </summary>
/// <param name="newDebug"></param>
void SetDebugPacketName(IScene scene, string name, bool remove)
{
scene.ForEachScenePresence(scenePresence =>
{
if (scenePresence.IsChildAgent) return;
MainConsole.Instance.DebugFormat(
"Packet debug for {0} {2} to {1}",
scenePresence.Name,
name, remove ? "removed" : "set");
scenePresence.ControllingClient.SetDebugPacketName(name, remove);
});
}
示例2: SetDebugPacketLevel
/// <summary>
/// Set the debug packet level on the current scene. This level governs which packets are printed out to the
/// console.
/// </summary>
/// <param name="newDebug"></param>
void SetDebugPacketLevel(IScene scene, int newDebug)
{
scene.ForEachScenePresence(scenePresence =>
{
if (scenePresence.IsChildAgent) return;
MainConsole.Instance.DebugFormat(
"Packet debug for {0} set to {1}",
scenePresence.Name,
newDebug);
scenePresence.ControllingClient.SetDebugPacketLevel(
newDebug);
});
}
示例3: HandleAlertConsoleCommand
/// <summary>
/// Handle an alert command from the console.
/// </summary>
/// <param name="cmdparams"></param>
protected void HandleAlertConsoleCommand (IScene scene, string [] cmdparams)
{
string message = "";
string userName = "";
string cmdType = cmdparams [1].ToLower ();
if (cmdType.StartsWith ("g", StringComparison.Ordinal) || cmdType.StartsWith ("b", StringComparison.Ordinal)) {
// general
if (cmdparams.Length > 2)
message = Util.CombineParams (cmdparams, 2);
else
message = MainConsole.Instance.Prompt ("Message to send?", "");
if (message == "")
return;
if (cmdType.StartsWith ("g", StringComparison.Ordinal)) {
MainConsole.Instance.InfoFormat ("[DIALOG]: Sending general alert in region {0} with message '{1}'",
scene.RegionInfo.RegionName, message);
// send the message
scene.ForEachScenePresence (delegate (IScenePresence sp) {
if (!sp.IsChildAgent)
sp.ControllingClient.SendAlertMessage (message);
});
} else {
MainConsole.Instance.InfoFormat ("[DIALOG]: Sending broadcast alert to all regions with message '{0}'", message);
// broadcast the message
foreach (IScene scn in MainConsole.Instance.ConsoleScenes) {
scn.ForEachScenePresence (delegate (IScenePresence sp) {
if (!sp.IsChildAgent)
sp.ControllingClient.SendAlertMessage (message);
});
}
}
return;
}
// user alert
if (cmdparams.Length >= 4)
userName = cmdparams [2] + " " + cmdparams [3];
else
userName = MainConsole.Instance.Prompt ("User name? (First Last)", "");
if (userName == "")
return;
if (cmdparams.Length > 4)
message = Util.CombineParams (cmdparams, 4);
else
message = MainConsole.Instance.Prompt ("Message to send?", "");
if (message == "")
return;
MainConsole.Instance.InfoFormat ("[DIALOG]: Sending alert in region {0} to {1} with message '{2}'",
scene.RegionInfo.RegionName, userName, message);
// send the message to the user
IScenePresence spc = scene.SceneGraph.GetScenePresence (userName);
if (spc != null && !spc.IsChildAgent)
spc.ControllingClient.SendAgentAlertMessage (message, false);
}
示例4: OnClosingClient
public void OnClosingClient (UUID clientID, IScene scene)
{
//Clear out the auth speakers list
lock (m_authorizedSpeakers)
{
if (m_authorizedSpeakers.Contains(clientID))
m_authorizedSpeakers.Remove(clientID);
}
IScenePresence presence = scene.GetScenePresence (clientID);
//Announce the closing agent if enabled
if (m_announceClosedAgents)
{
scene.ForEachScenePresence(delegate(IScenePresence 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), 1, SP.AbsolutePosition, "System",
UUID.Zero, (byte)ChatSourceType.System, (byte)ChatAudibleLevel.Fully);
}
}
);
}
}
示例5: UpdateBroker
protected void UpdateBroker(IScene scene)
{
if (String.IsNullOrEmpty(m_brokerURI))
return;
string uri = String.Format(m_brokerURI, scene.RegionInfo.RegionName, scene.RegionInfo.RegionID);
// create XML sniplet
StringBuilder list = new StringBuilder();
IEntityCountModule entityCountModule = scene.RequestModuleInterface<IEntityCountModule>();
if (entityCountModule != null)
{
list.Append(String.Format("<avatars count=\"{0}\" region_name=\"{1}\" region_uuid=\"{2}\" timestamp=\"{3}\">\n",
entityCountModule.RootAgents, scene.RegionInfo.RegionName,
scene.RegionInfo.RegionID,
DateTime.UtcNow.ToString("s")));
}
scene.ForEachScenePresence(delegate(IScenePresence sp)
{
if (!sp.IsChildAgent)
{
list.Append(String.Format(" <avatar name=\"{0}\" uuid=\"{1}\" />\n", sp.Name, sp.UUID));
list.Append("</avatars>");
}
});
string payload = list.ToString();
// post via REST to broker
HttpWebRequest updatePost = WebRequest.Create(uri) as HttpWebRequest;
updatePost.Method = "POST";
updatePost.ContentType = "text/xml";
updatePost.ContentLength = payload.Length;
updatePost.UserAgent = "WhiteCore.Concierge";
BrokerState bs = new BrokerState(uri, payload, updatePost);
bs.Timer = new Timer(delegate(object state)
{
BrokerState b = state as BrokerState;
b.Poster.Abort();
b.Timer.Dispose();
MainConsole.Instance.Debug("[Concierge]: async broker POST abort due to timeout");
}, bs, m_brokerUpdateTimeout * 1000, Timeout.Infinite);
try
{
updatePost.BeginGetRequestStream(UpdateBrokerSend, bs);
MainConsole.Instance.DebugFormat("[Concierge] async broker POST to {0} started", uri);
}
catch (WebException we)
{
MainConsole.Instance.ErrorFormat("[Concierge] async broker POST to {0} failed: {1}", uri, we.Status);
}
}