當前位置: 首頁>>代碼示例>>C#>>正文


C# Player.IsAuthenticated方法代碼示例

本文整理匯總了C#中Terraria.Player.IsAuthenticated方法的典型用法代碼示例。如果您正苦於以下問題:C# Player.IsAuthenticated方法的具體用法?C# Player.IsAuthenticated怎麽用?C# Player.IsAuthenticated使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Terraria.Player的用法示例。


在下文中一共展示了Player.IsAuthenticated方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SavePlayerData

        public static bool SavePlayerData(IDbConnection ctx, IDbTransaction txn, bool save, Player player)
#endif
        {
            if (!player.IsAuthenticated()) return false;

            //If using a flat based system ensure the MODE is stored
            string authName = null;
            if (Mode == CharacterMode.AUTH)
            {
                var auth = player.GetAuthenticatedAs();
                if (!String.IsNullOrEmpty(auth))
                    authName = auth;
            }
            else if (Mode == CharacterMode.UUID)
            {
                if (!String.IsNullOrEmpty(player.ClientUUId))
                    authName = player.ClientUUId + '@' + player.name;
            }

            if (!String.IsNullOrEmpty(authName))
            {
                if (Storage.IsAvailable)
                {
                    var auth = player.GetAuthenticatedAs();

#if ENTITY_FRAMEWORK_6
                    int userId = 0;
                    if (Mode == CharacterMode.AUTH)
                    {
                        var user = AuthenticatedUsers.GetUser(auth);

                        if (user == null)
                        {
                            OTA.Logging.ProgramLog.Error.Log("No user found ");
                            return false;
                        }

                        userId = user.Id;
                    }
                    else if (Mode != CharacterMode.UUID)
                        return false;

                    //Sync the character
                    var character = ctx.GetCharacter(Mode, userId, player.ClientUUId);
                    if (null == character)
                    {
                        character = ctx.AddCharacter(userId, player);
                    }
                    else character.UpdateCharacter(userId, player);

                    //Sync items
                    var items = ctx.Items.Where(x => x.CharacterId == character.Id).ToArray();

                    if (!SaveCharacterItems(ctx, save, player, character.Id, player.inventory, ItemType.Inventory, items)) return false;
                    if (!SaveCharacterItems(ctx, save, player, character.Id, player.armor, ItemType.Armor, items)) return false;
                    if (!SaveCharacterItems(ctx, save, player, character.Id, player.dye, ItemType.Dye, items)) return false;
                    if (!SaveCharacterItems(ctx, save, player, character.Id, player.miscEquips, ItemType.Equipment, items)) return false;
                    if (!SaveCharacterItems(ctx, save, player, character.Id, player.miscDyes, ItemType.MiscDyes, items)) return false;
                    if (!SaveCharacterItem(ctx, save, player, character.Id, ItemType.Trash, player.trashItem, 0, items)) return false;


#elif ENTITY_FRAMEWORK_7
#else
                    var character = Tables.CharacterTable.GetCharacter(ctx, txn, Mode, auth, player.ClientUUId);
                    if (character == null)
                    {
//                        if (player.ClearPluginData(Key_NewCharacter))
//                        {
                        character = Tables.CharacterTable.NewCharacter
                            (
                            ctx,
                            txn,
                            Mode,
                            auth,
                            player.ClientUUId,
                            player.statLife,
                            player.statLifeMax,
                            player.statMana,
                            player.statManaMax,
                            player.SpawnX,
                            player.SpawnY,
                            player.hair,
                            player.hairDye,
                            player.hideVisual,
                            player.difficulty,
                            player.hairColor,
                            player.skinColor,
                            player.eyeColor,
                            player.shirtColor,
                            player.underShirtColor,
                            player.pantsColor,
                            player.shoeColor,
                            player.anglerQuestsFinished
                        );
//                        }
//                        else
//                        {
//                            ProgramLog.Error.Log("Failed to save SSC for player: {0}", player.name);
//                            return false;
//                        }
//.........這裏部分代碼省略.........
開發者ID:DeathCradle,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:101,代碼來源:CharacterManager.cs


注:本文中的Terraria.Player.IsAuthenticated方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。