当前位置: 首页>>代码示例>>C#>>正文


C# Thing.Save方法代码示例

本文整理汇总了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();
        }
开发者ID:Hobbitron,项目名称:WheelMUD,代码行数:46,代码来源:CreationState.cs


注:本文中的Thing.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。