本文整理汇总了C#中Thing.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Thing.Save方法的具体用法?C# Thing.Save怎么用?C# Thing.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thing
的用法示例。
在下文中一共展示了Thing.Save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SubState_CharacterCreationCompleted
/// <summary>
/// Called upon the completion of character creation.
/// </summary>
/// <param name="newCharacter">
/// The new Character.
/// </param>
private void SubState_CharacterCreationCompleted(Thing newCharacter)
{
// Attach the new character to the current session.
this.Session.Thing = this.subStateHandler.NewCharacter;
this.Session.Write(string.Format("Saving player {0}...", newCharacter.Name), false);
// Prepare the default options and new data that will go in the special player DB.
string currentTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ");
var playerBehavior = newCharacter.FindBehavior<PlayerBehavior>();
playerBehavior.PlayerData = new PlayerRecord
{
UserName = newCharacter.Name,
Password = playerBehavior.Password,
DisplayName = newCharacter.Name,
Description = newCharacter.Description,
CurrentRoomID = MudEngineAttributes.Instance.DefaultRoomID,
LastLogin = currentTime,
CreateDate = currentTime,
LastIPAddress = this.Session.Connection.CurrentIPAddress.ToString(),
WantAnsi = true,
WantMCCP = false,
WantMXP = true
};
// If the player isn't located anywhere yet, try to drop them in the default room.
if (newCharacter.Parent == null)
{
this.PlaceCharacterInDefaultRoom(newCharacter);
}
// Saving the player's Thing should save everything we need to now.
newCharacter.Save();
this.Session.Write(string.Format(" Done saving player {0}\n\n", newCharacter.Name), false);
// Automatically authenticate (the user just created username and password) and
// get in-game when character creation is completed.)
this.Session.UserName = newCharacter.Name;
this.Session.State = new PlayingState(this.Session);
this.Session.AuthenticateSession();
}