// Copyright Epic Games, Inc. All Rights Reserved.
#include "CommonUserSubsystem.h"
#include "Engine/GameViewportClient.h"
#include "Engine/Engine.h"
#include "Engine/LocalPlayer.h"
#include "GameFramework/PlayerController.h"
#include "GameFramework/PlayerState.h"
#include "GenericPlatform/GenericPlatformInputDeviceMapper.h"
#include "TimerManager.h"
#include "UObject/UObjectHash.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(CommonUserSubsystem)
#if COMMONUSER_OSSV1
#include "OnlineSubsystem.h"
#include "OnlineSubsystemUtils.h"
#else
#include "Online/Auth.h"
#include "Online/ExternalUI.h"
#include "Online/OnlineServices.h"
#include "Online/OnlineServicesEngineUtils.h"
#include "Online/Privileges.h"
using namespace UE::Online;
#endif
DECLARE_LOG_CATEGORY_EXTERN(LogCommonUser, Log, All);
DEFINE_LOG_CATEGORY(LogCommonUser);
UE_DEFINE_GAMEPLAY_TAG(FCommonUserTags::SystemMessage_Error, "SystemMessage.Error");
UE_DEFINE_GAMEPLAY_TAG(FCommonUserTags::SystemMessage_Warning, "SystemMessage.Warning");
UE_DEFINE_GAMEPLAY_TAG(FCommonUserTags::SystemMessage_Display, "SystemMessage.Display");
UE_DEFINE_GAMEPLAY_TAG(FCommonUserTags::SystemMessage_Error_InitializeLocalPlayerFailed, "SystemMessage.Error.InitializeLocalPlayerFailed");
UE_DEFINE_GAMEPLAY_TAG(FCommonUserTags::Platform_Trait_RequiresStrictControllerMapping, "Platform.Trait.RequiresStrictControllerMapping");
UE_DEFINE_GAMEPLAY_TAG(FCommonUserTags::Platform_Trait_SingleOnlineUser, "Platform.Trait.SingleOnlineUser");
//////////////////////////////////////////////////////////////////////
// UCommonUserInfo
UCommonUserInfo::FCachedData* UCommonUserInfo::GetCachedData(ECommonUserOnlineContext Context)
{
// Look up directly, game has a separate cache than default
FCachedData* FoundData = CachedDataMap.Find(Context);
if (FoundData)
{
return FoundData;
}
// Now try system resolution
UCommonUserSubsystem* Subsystem = GetSubsystem();
ECommonUserOnlineContext ResolvedContext = Subsystem->ResolveOnlineContext(Context);
return CachedDataMap.Find(ResolvedContext);
}
const UCommonUserInfo::FCachedData* UCommonUserInfo::GetCachedData(ECommonUserOnlineContext Context) const
{
return const_cast<UCommonUserInfo*>(this)->GetCachedData(Context);
}
void UCommonUserInfo::UpdateCachedPrivilegeResult(ECommonUserPrivilege Privilege, ECommonUserPrivilegeResult Result, ECommonUserOnlineContext Context)
{
// This should only be called with a resolved and valid type
FCachedData* GameCache = GetCachedData(ECommonUserOnlineContext::Game);
FCachedData* ContextCache = GetCachedData(Context);
if (!ensure(GameCache && ContextCache))
{
// Should always be valid
return;
}
// Update direct cache first
ContextCache->CachedPrivileges.Add(Privilege, Result);
if (GameCache != ContextCache)
{
// Look for another context to merge into game
ECommonUserPrivilegeResult GameContextResult = Result;
ECommonUserPrivilegeResult OtherContextResult = ECommonUserPrivilegeResult::Available;
for (TPair<ECommonUserOnlineContext, FCachedData>& Pair : CachedDataMap)
{
if (&Pair.Value != ContextCache && &Pair.Value != GameCache)
{
ECommonUserPrivilegeResult* FoundResult = Pair.Value.CachedPrivileges.Find(Privilege);
if (FoundResult)
{
OtherContextResult = *FoundResult;
}
else
{
OtherContextResult = ECommonUserPrivilegeResult::Unknown;
}
break;
}
}
if (GameContextResult == ECommonUserPrivilegeResult::Available && OtherContextResult != ECommonUserPrivilegeResult::Available)
{
// Other context is worse, use that
GameContextResult = OtherContextResult;
}
GameCache->CachedPrivileges.Add(Privilege, GameContextResult);
}
}
void UCommonUserInfo::UpdateCachedNetId(const FUniqueNetIdRepl& NewId, ECommonUserOnlineContext Context)
{
FCachedData* ContextCache = GetCachedData(Context);
if (ensure(ContextCache))
{
ContextCache->CachedNetId = NewId;
}
// We don't merge the ids because of how guests work
}
class UCommonUserSubsystem* UCommonUserInfo::GetSubsystem() const
{
return Cast<UCommonUserSubsystem>(GetOuter());
}
ECommonUserPrivilegeResult UCommonUserInfo::GetCachedPrivilegeResult(ECommonUserPrivilege Privilege, ECommonUserOnlineContext Context) const
{
const FCachedData* FoundCached = GetCachedData(Context);
if (FoundCached)
{
const ECommonUserPrivilegeResult* FoundResult = FoundCached->CachedPrivileges.Find(Privilege);
if (FoundResult)
{
return *FoundResult;
}
}
return ECommonUserPrivilegeResult::Unknown;
}
ECommonUserAvailability UCommonUserInfo::GetPrivilegeAvailability(ECommonUserPrivilege Privilege) const
{
// Bad feature or user
if ((int32)Privilege < 0 || (int32)Privilege >= (int32)ECommonUserPrivilege::Invalid_Count || InitializationState == ECommonUserInitializationState::Invalid)
{
return ECommonUserAvailability::Invalid;
}
ECommonUserPrivilegeResult CachedResult = GetCachedPrivilegeResult(Privilege, ECommonUserOnlineContext::Game);
// First handle explicit failures
switch (CachedResult)
{
case ECommonUserPrivilegeResult::LicenseInvalid:
case ECommonUserPrivilegeResult::VersionOutdated:
case ECommonUserPrivilegeResult::AgeRestricted:
return ECommonUserAvailability::AlwaysUnavailable;
case ECommonUserPrivilegeResult::NetworkConnectionUnavailable:
case ECommonUserPrivilegeResult::AccountTypeRestricted:
case ECommonUserPrivilegeResult::AccountUseRestricted:
case ECommonUserPrivilegeResult::PlatformFailure:
return ECommonUserAvailability::CurrentlyUnavailable;
default:
break;
}
if (bIsGuest)
{
// Guests can only play, cannot use online features
if (Privilege == ECommonUserPrivilege::CanPlay)
{
return ECommonUserAvailability::NowAvailable;
}
else
{
return ECommonUserAvailability::AlwaysUnavailable;
}
}
// Check network status
if (Privilege == ECommonUserPrivilege::CanPlayOnline ||
Privilege == ECommonUserPrivilege::CanUseCrossPlay ||
Privilege == ECommonUserPrivilege::CanCommunicateViaTextOnline ||
Privilege == ECommonUserPrivilege::CanCommunicateViaVoiceOnline)
{
UCommonUserSubsystem* Subsystem = GetSubsystem();
if (ensure(Subsystem) && !Subsystem->HasOnlineConnection(ECommonUserOnlineContext::Game))
{
return ECommonUserAvailability::CurrentlyUnavailable;
}
}
if (InitializationState == ECommonUserInitializationState::FailedtoLogin)
{
// Failed a prior login attempt
return ECommonUserAvailability::CurrentlyUnavailable;
}
else if (InitializationState == ECommonUserInitializationState::Unknown || InitializationState == ECommonUserInitializationState::DoingInitialLogin)
{
// Haven't logged in yet
return ECommonUserAvailability::PossiblyAvailable;
}
else if (InitializationState == ECommonUserInitializationState::LoggedInLocalOnly || InitializationState == ECommonUserInitializationState::DoingNetworkLogin)
{
// Local login succeeded so play checks are valid
if (Privilege == ECommonUserPrivilege::CanPlay && CachedResult == ECommonUserPrivilegeResult::Available)
{
return ECommonUserAvailability::NowAvailable;
}
// Haven't logged in online yet
return ECommonUserAvailability::PossiblyAvailable;
}
else if (InitializationState == ECommonUserInitializationState::LoggedInOnline)
{
// Fully logged in
if (CachedResult == ECommonUserPrivilegeResult::Available)
{
return ECommonUserAvailability::NowAvailable;
}
// Failed for other reason
return ECommonUserAvailability::CurrentlyUnavailable;
}
return ECommonUserAvailability::Unknown;
}
FUniqueNetIdRepl UCommonUserInfo::GetNetId(ECommonUserOnlineContext Context) const
{
const FCachedData* FoundCached = GetCachedData(Context);
if (FoundCached)
{
return FoundCached->CachedNetId;
}
return FUniqueNetIdRepl();
}
FString UCommonUserInfo::GetNickname() const
{
if (bIsGuest)
{
return NSLOCTEXT("CommonUser", "GuestNickname", "Guest").ToString();
}
const UCommonUserSubsystem* Subsystem = GetSubsystem();
if (ensure(Subsystem))
{
#if COMMONUSER_OSSV1
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【项目说明】 1.项目代码均经过功能验证ok,确保稳定可靠运行。欢迎下载食用体验! 2.主要针对各个计算机相关专业,包括计算机科学、信息安全、数据科学与大数据技术、人工智能、通信、物联网等领域的在校学生、专业教师、企业员工。 3.项目具有丰富的拓展空间,不仅可作为入门进阶,也可直接作为毕设、课程设计、大作业、初期项目立项演示等用途。 4.当然也鼓励大家基于此进行二次开发。在使用过程中,如有问题或建议,请及时沟通。 5.期待你能在项目中找到乐趣和灵感,也欢迎你的分享和反馈! 【资源介绍】 基于C++的自制战旗小游戏源码+项目说明(课程作业).zip基于C++的自制战旗小游戏源码+项目说明(课程作业).zip基于C++的自制战旗小游戏源码+项目说明(课程作业).zip基于C++的自制战旗小游戏源码+项目说明(课程作业).zip基于C++的自制战旗小游戏源码+项目说明(课程作业).zip基于C++的自制战旗小游戏源码+项目说明(课程作业).zip基于C++的自制战旗小游戏源码+项目说明(课程作业).zip 基于C++的自制战旗小游戏源码+项目说明(课程作业).zip基于C++的自制战旗小游戏源码+项目说明(课程作业).zip 基于C++的自制战旗小游戏源码+项目说明(课程作业).zip
资源推荐
资源详情
资源评论
收起资源包目录
基于C++的自制战旗小游戏源码+项目说明(课程作业).zip (1181个子文件)
Game.archive 11KB
Game.archive 11KB
ProjectV.code-workspace 372B
CommonUserSubsystem.cpp 88KB
CommonSessionSubsystem.cpp 48KB
GridMapFunctionLibrary.cpp 46KB
GridMapManager.cpp 31KB
LoadingScreenManager.cpp 22KB
Tilemap3DEditorViewportClient.cpp 16KB
AsyncMixin.cpp 16KB
Tilemap3DPathfindingGenerator.cpp 15KB
CommonPlayerInputKey.cpp 14KB
GridChessPieceMovementComponent.cpp 14KB
MasterInputComponent.cpp 13KB
GridTurnBaseMasterComponent.cpp 13KB
GridExperienceManagerComponent.cpp 13KB
UIExtensionSystem.cpp 13KB
GridMasterComponent.cpp 13KB
GridGameMode.cpp 12KB
GridAssetManager.cpp 11KB
GameSettingListEntry.cpp 11KB
K2Node_AsyncAction_ListenForGameplayMessages.cpp 10KB
TilemapExtensionComponent.cpp 10KB
GridPlayerHand.cpp 9KB
GridFrontendStateComponent.cpp 9KB
GridChessPieceHealthComponent.cpp 9KB
GridChessPieceExtensionComponent.cpp 9KB
GridPawnExtensionComponent.cpp 9KB
GameSetting.cpp 8KB
ChessDirectionComponent.cpp 8KB
GridCardInfo.cpp 8KB
Tilemap3DEditModeWidget.cpp 8KB
MasterMovementComponent.cpp 8KB
Tilemap3DPropertiesTabBody.cpp 8KB
Tilemap3DTerrainGenerator.cpp 7KB
GameSettingPanel.cpp 7KB
GameSettingValueDiscreteDynamic.cpp 7KB
GridAbilitySystemComponent.cpp 7KB
TilemapPathfindingComponent.cpp 7KB
TilemapDrawRangeComponent.cpp 7KB
GameSettingValueScalarDynamic.cpp 7KB
GridCard.cpp 7KB
GridChessPieceComponent.cpp 7KB
CommonGameInstance.cpp 6KB
GameUIPolicy.cpp 6KB
GridPlayerHandComponent.cpp 6KB
GameplayMessageSubsystem.cpp 6KB
GridTileParent.cpp 6KB
MaterialProgressBar.cpp 6KB
TilemapAsset.cpp 6KB
GameSettingDetailView.cpp 6KB
GridChessPiece.cpp 6KB
GridGameAbility_Move.cpp 6KB
GameFeatureAction_AddWidget.cpp 6KB
GridPlayerSpawningManagerComponent.cpp 6KB
ChessBlueprintLibrary.cpp 6KB
GridGameplayTags.cpp 5KB
GameFeatureAction_AddInputContextMapping.cpp 5KB
GridHealthSet.cpp 5KB
CommonUIExtensions.cpp 5KB
GridPlayerState.cpp 5KB
GridSettingsLocal.cpp 5KB
Tilemap3DEditorToolkit.cpp 5KB
UIExtensionPointWidget.cpp 5KB
MenuManager.cpp 5KB
TilemapStateComponent.cpp 5KB
PrimaryGameLayout.cpp 5KB
GridMapNode.cpp 5KB
GridGameplayAbility_Card.cpp 5KB
GridTurnManagerComponent.cpp 4KB
GridAbilitySet.cpp 4KB
GameSettingRegistry.cpp 4KB
GridChessExtensionComponent.cpp 4KB
GridGameplayAbility_ChessPiece.cpp 4KB
ChessPackageComponent.cpp 4KB
TileSetGalleyWidget.cpp 4KB
Tilemap3DPlayerChessMode.cpp 4KB
GridInputModifiers.cpp 4KB
GridCharacter.cpp 4KB
GameSettingPressAnyKey.cpp 4KB
SGameResponsivePanel.cpp 4KB
GridChessPieceAIStateMachineComponent.cpp 4KB
SubtitleDisplay.cpp 4KB
GridChessPieceSpawnComponent.cpp 4KB
GridHeroInfo.cpp 4KB
CursorEventComponent.cpp 4KB
GridChessPieceSkillComponent.cpp 4KB
GameSettingFilterState.cpp 4KB
GridCardDrawPile.cpp 4KB
AsyncAction_ListenForGameplayMessage.cpp 4KB
Tilemap3DAddMeshMode.cpp 4KB
GridPlayerHandStateComponent.cpp 3KB
GameSettingCollection.cpp 3KB
Tilemap3DSpawnChessMode.cpp 3KB
AsyncAction_ExperienceReady.cpp 3KB
CommonGameDialog.cpp 3KB
AsyncAction_CreateWidgetAsync.cpp 3KB
AsyncAction_CommonUserInitialize.cpp 3KB
AsyncAction_ShowConfirmation.cpp 3KB
GridSkillInfo.cpp 3KB
共 1181 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
资源评论
.whl
- 粉丝: 3813
- 资源: 4636
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 获取CPU的序列号的Python脚本
- 4354图446546546546546
- 邮箱管理技巧:减少垃圾邮件的9项实用措施
- 三汇SMG 系列D 型模拟网关用户手册,用于三汇SMG系列网关配置
- Siemens Automation Framework V1.2
- 单个IO口检测多个按键
- 汇川EASY32x固件6.3.0.0
- 高分成品毕业设计《基于SSM(Spring、Spring MVC、MyBatis)+MySQL开发个人财务管理系统》+源码+论文+说明文档+数据库
- 高分成品毕业设计《基于SSM(Spring、Spring MVC、MyBatis)+MySQL开发B2C电子商务平台》+源码+论文+说明文档+数据库
- HKJC_3in1_TR_PROD_L3.0R1An_Build10229.apk
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功