本文整理汇总了C#中IScene.AddNewClient方法的典型用法代码示例。如果您正苦于以下问题:C# IScene.AddNewClient方法的具体用法?C# IScene.AddNewClient怎么用?C# IScene.AddNewClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScene
的用法示例。
在下文中一共展示了IScene.AddNewClient方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAvatar
/// <summary>
/// Creates a new bot inworld
/// </summary>
/// <param name = "FirstName"></param>
/// <param name = "LastName"></param>
/// <param name = "cloneAppearanceFrom">UUID of the avatar whos appearance will be copied to give this bot an appearance</param>
/// <returns>ID of the bot</returns>
public UUID CreateAvatar(string FirstName, string LastName, IScene scene, UUID cloneAppearanceFrom,
UUID creatorID, Vector3 startPos)
{
AgentCircuitData m_aCircuitData = new AgentCircuitData
{
child = false,
circuitcode = (uint) Util.RandomClass.Next(),
Appearance = GetAppearance(cloneAppearanceFrom, scene)
};
//Add the circuit data so they can login
//Sets up appearance
if (m_aCircuitData.Appearance == null)
{
m_aCircuitData.Appearance = new AvatarAppearance {Wearables = AvatarWearable.DefaultWearables};
}
//Create the new bot data
Bot m_character = new Bot(scene, m_aCircuitData, creatorID) {FirstName = FirstName, LastName = LastName};
m_aCircuitData.AgentID = m_character.AgentId;
m_aCircuitData.Appearance.Owner = m_character.AgentId;
List<AvatarAttachment> attachments = m_aCircuitData.Appearance.GetAttachments();
m_aCircuitData.Appearance.ClearAttachments();
foreach (AvatarAttachment t in attachments)
{
InventoryItemBase item = scene.InventoryService.GetItem(new InventoryItemBase(t.ItemID));
if (item != null)
{
item.ID = UUID.Random();
item.Owner = m_character.AgentId;
item.Folder = UUID.Zero;
scene.InventoryService.AddItem(item);
//Now fix the ItemID
m_aCircuitData.Appearance.SetAttachment(t.AttachPoint, item.ID, t.AssetID);
}
}
scene.AuthenticateHandler.AgentCircuits.Add(m_character.CircuitCode, m_aCircuitData);
//This adds them to the scene and sets them inworld
bool done = false;
scene.AddNewClient(m_character, delegate { done = true; });
while (!done)
Thread.Sleep(3);
IScenePresence SP = scene.GetScenePresence(m_character.AgentId);
if (SP == null)
return UUID.Zero; //Failed!
m_character.Initialize(SP);
SP.MakeRootAgent(m_character.StartPos, false, true);
//Move them
SP.Teleport(startPos);
IAvatarAppearanceModule appearance = SP.RequestModuleInterface<IAvatarAppearanceModule>();
appearance.InitialHasWearablesBeenSent = true;
//Save them in the bots list
m_bots.Add(m_character.AgentId, m_character);
AddTagToBot(m_character.AgentId, "AllBots", m_character.AvatarCreatorID);
MainConsole.Instance.Info("[RexBotManager]: Added bot " + m_character.Name + " to scene.");
//Return their UUID
return m_character.AgentId;
}
示例2: AddAndWaitUntilAgentIsAdded
private static void AddAndWaitUntilAgentIsAdded(IScene scene, BotClientAPI m_character)
{
bool done = false;
scene.AddNewClient(m_character, delegate { done = true; });
while (!done)
Thread.Sleep(3);
}
示例3: CreateAvatar
/// <summary>
/// Creates a new bot inworld
/// </summary>
/// <param name="FirstName"></param>
/// <param name="LastName"></param>
/// <param name="cloneAppearanceFrom">UUID of the avatar whos appearance will be copied to give this bot an appearance</param>
/// <returns>ID of the bot</returns>
public UUID CreateAvatar (string FirstName, string LastName, IScene scene, UUID cloneAppearanceFrom, UUID creatorID, Vector3 startPos)
{
AgentCircuitData m_aCircuitData = new AgentCircuitData ();
m_aCircuitData.child = false;
//Add the circuit data so they can login
m_aCircuitData.circuitcode = (uint)Util.RandomClass.Next();
m_aCircuitData.Appearance = GetAppearance (cloneAppearanceFrom, scene);//Sets up appearance
if (m_aCircuitData.Appearance == null)
{
m_aCircuitData.Appearance = new AvatarAppearance ();
m_aCircuitData.Appearance.Wearables = AvatarWearable.DefaultWearables;
}
//Create the new bot data
Bot m_character = new Bot (scene, m_aCircuitData, creatorID);
m_character.FirstName = FirstName;
m_character.LastName = LastName;
m_aCircuitData.AgentID = m_character.AgentId;
m_aCircuitData.Appearance.Owner = m_character.AgentId;
List<AvatarAttachment> attachments = m_aCircuitData.Appearance.GetAttachments ();
m_aCircuitData.Appearance.ClearAttachments ();
for (int i = 0; i < attachments.Count; i++)
{
InventoryItemBase item = scene.InventoryService.GetItem (new InventoryItemBase (attachments[i].ItemID));
if (item != null)
{
item.ID = UUID.Random ();
item.Owner = m_character.AgentId;
item.Folder = UUID.Zero;
scene.InventoryService.AddItem (item);
//Now fix the ItemID
m_aCircuitData.Appearance.SetAttachment (attachments[i].AttachPoint, item.ID, attachments[i].AssetID);
}
}
scene.AuthenticateHandler.AgentCircuits.Add (m_character.CircuitCode, m_aCircuitData);
//This adds them to the scene and sets them inworld
scene.AddNewClient (m_character);
IScenePresence SP = scene.GetScenePresence (m_character.AgentId);
m_character.Initialize (SP);
SP.MakeRootAgent (m_character.StartPos, false);
//Move them
SP.Teleport (startPos);
IAvatarAppearanceModule appearance = SP.RequestModuleInterface<IAvatarAppearanceModule> ();
appearance.InitialHasWearablesBeenSent = true;
appearance.Appearance.SetAppearance (appearance.Appearance.Texture, appearance.Appearance.VisualParams);
appearance.SendAvatarDataToAllAgents (true);
appearance.SendAppearanceToAllOtherAgents ();
//Save them in the bots list
m_bots.Add(m_character.AgentId, m_character);
m_log.Info("[RexBotManager]: Added bot " + m_character.Name + " to scene.");
//Return their UUID
return m_character.AgentId;
}