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


C++ ULocalPlayer类代码示例

本文整理汇总了C++中ULocalPlayer的典型用法代码示例。如果您正苦于以下问题:C++ ULocalPlayer类的具体用法?C++ ULocalPlayer怎么用?C++ ULocalPlayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ULocalPlayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FVector2D

/* After release of left mouse button, check if this unit is within selection box. */ 
void ARTSUnit::CheckForSelection()
{

	/* Find screen coordinates of the unit. */
	FVector2D MyResult = FVector2D(0, 0);

	ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(PC->Player);

	if (LocalPlayer != NULL && LocalPlayer->ViewportClient != NULL && LocalPlayer->ViewportClient->Viewport != NULL)
	{
		FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues(
			LocalPlayer->ViewportClient->Viewport,
			GetWorld()->Scene,
			LocalPlayer->ViewportClient->EngineShowFlags)
			.SetRealtimeUpdate(true));

		FVector ViewLocation;
		FRotator ViewRotation;
		FSceneView* SceneView = LocalPlayer->CalcSceneView(&ViewFamily, /*out*/ ViewLocation, /*out*/ ViewRotation, LocalPlayer->ViewportClient->Viewport);

		if (SceneView)
		{
			auto MyWorldPosition = GetActorLocation();
			MyResult;
			SceneView->WorldToPixel(MyWorldPosition, MyResult);
		}
	}

	/* If the selection box contains the screen postion: */
	if (ARTSHUD::SelectionContainsPoint(MyResult)){

		// Select this unit, and leave possibility to select others.
		Select();
	}
}
开发者ID:OpenMachines,项目名称:machines,代码行数:36,代码来源:RTSUnit.cpp

示例2: OnShowLoginUICompleted

void UShowLoginUICallbackProxy::OnShowLoginUICompleted(TSharedPtr<const FUniqueNetId> UniqueId, int LocalPlayerNum)
{
	// Update the cached unique ID for the local player and the player state.
	APlayerController* PlayerController = PlayerControllerWeakPtr.Get();
	
	if (PlayerController != nullptr)
	{
		ULocalPlayer* LocalPlayer = PlayerController->GetLocalPlayer();
		if (LocalPlayer != nullptr)
		{
			LocalPlayer->SetCachedUniqueNetId(UniqueId);
		}
		
		if (PlayerController->PlayerState != nullptr)
		{
			PlayerController->PlayerState->SetUniqueId(UniqueId);
		}
	}

	if (UniqueId.IsValid())
	{
		OnSuccess.Broadcast(PlayerControllerWeakPtr.Get());
	}
	else
	{
		OnFailure.Broadcast(PlayerControllerWeakPtr.Get());
	}
}
开发者ID:colwalder,项目名称:unrealengine,代码行数:28,代码来源:ShowLoginUICallbackProxy.cpp

示例3: Offset

FVector2D AHUD::GetCoordinateOffset() const
{
	FVector2D Offset(0.f, 0.f);

	ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(GetOwningPlayerController()->Player);

	if (LocalPlayer)
	{
		// Create a view family for the game viewport
		FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues(
			LocalPlayer->ViewportClient->Viewport,
			GetWorld()->Scene,
			LocalPlayer->ViewportClient->EngineShowFlags)
			.SetRealtimeUpdate(true));

		// Calculate a view where the player is to update the streaming from the players start location
		FVector ViewLocation;
		FRotator ViewRotation;
		FSceneView* SceneView = LocalPlayer->CalcSceneView(&ViewFamily, /*out*/ ViewLocation, /*out*/ ViewRotation, LocalPlayer->ViewportClient->Viewport);

		if (SceneView)
		{
			Offset.X = (SceneView->ViewRect.Min.X - SceneView->UnscaledViewRect.Min.X) // This accounts for the borders when the aspect ratio is locked
				- SceneView->UnscaledViewRect.Min.X;						// And this will deal with the viewport offset if its a split screen

			Offset.Y = (SceneView->ViewRect.Min.Y - SceneView->UnscaledViewRect.Min.Y)
				- SceneView->UnscaledViewRect.Min.Y;
		}
	}

	return Offset;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:32,代码来源:HUD.cpp

示例4: UE_LOG

void UAdvancedFriendsLibrary::IsAFriend(APlayerController *PlayerController, const FBPUniqueNetId UniqueNetId, bool &IsFriend)
{
	if (!PlayerController)
	{
		UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Had a bad Player Controller!"));
		return;
	}

	if (!UniqueNetId.IsValid())
	{
		UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Had a bad UniqueNetId!"));
		return;
	}

	IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface();

	if (!FriendsInterface.IsValid())
	{
		UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Failed to get friends interface!"));
		return;
	}

	ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);

	if (!Player)
	{
		UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Failed to get LocalPlayer!"));
		return;
	}

	IsFriend = FriendsInterface->IsFriend(Player->GetControllerId(), *UniqueNetId.GetUniqueNetId(), EFriendsLists::ToString(EFriendsLists::Type::Default));
}
开发者ID:ivukotic,项目名称:ATLASrift,代码行数:32,代码来源:AdvancedFriendsLibrary.cpp

示例5: IsInvertedYAxisDirty

bool UAmethystPersistentUser::IsInvertedYAxisDirty() const
{
    bool bIsInvertedYAxisDirty = false;
    if (GEngine)
    {
        TArray<APlayerController*> PlayerList;
        GEngine->GetAllLocalPlayerControllers(PlayerList);
        
        for (auto It = PlayerList.CreateIterator(); It; ++It)
        {
            APlayerController* PC = *It;
            if (!PC || !PC->Player || !PC->PlayerInput)
            {
                continue;
            }
            
            // Update key bindings for the current user only
            ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(PC->Player);
            if(!LocalPlayer || LocalPlayer->GetControllerId() != UserIndex)
            {
                continue;
            }
            
            bIsInvertedYAxisDirty |= PC->PlayerInput->GetInvertAxis("Lookup") != GetInvertedYAxis();
            bIsInvertedYAxisDirty |= PC->PlayerInput->GetInvertAxis("LookupRate") != GetInvertedYAxis();
        }
    }
    
    return bIsInvertedYAxisDirty;
}
开发者ID:1337programming,项目名称:amethystforest,代码行数:30,代码来源:AmethystPersistentUser.cpp

示例6: SetUpdateState

void UUpdateManager::StartPlatformEnvironmentCheck()
{
	IOnlineSubsystem* OnlineSubConsole = IOnlineSubsystem::GetByPlatform();
	if (!bPlatformEnvironmentDetected &&
		OnlineSubConsole != nullptr &&
		OnlineSubConsole->GetIdentityInterface().IsValid())
	{
		SetUpdateState(EUpdateState::DetectingPlatformEnvironment);

		ULocalPlayer* LP = GetGameInstance()->GetFirstGamePlayer();
		if (LP != nullptr)
		{
			const int32 ControllerId = LP->GetControllerId();
			OnLoginConsoleCompleteHandle = OnlineSubConsole->GetIdentityInterface()->AddOnLoginCompleteDelegate_Handle(
				ControllerId,
				FOnLoginCompleteDelegate::CreateUObject(this, &ThisClass::PlatformEnvironmentCheck_OnLoginConsoleComplete)
				);

			OnlineSubConsole->GetIdentityInterface()->Login(ControllerId, FOnlineAccountCredentials());
		}
	}
	else
	{
		StartHotfixCheck();
	}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:26,代码来源:UpdateManager.cpp

示例7: UE_LOG

void UGetFriendsCallbackProxy::Activate()
{
	if (!PlayerControllerWeakPtr.IsValid())
	{
		// Fail immediately
		UE_LOG(AdvancedGetFriendsLog, Warning, TEXT("GetFriends Failed received a bad player controller!"));
		TArray<FBPFriendInfo> EmptyArray;
		OnFailure.Broadcast(EmptyArray);
		return;
	}

	IOnlineFriendsPtr Friends = Online::GetFriendsInterface();
	if (Friends.IsValid())
	{	
		ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);

		Friends->ReadFriendsList(Player->GetControllerId(), EFriendsLists::ToString((EFriendsLists::Type::Default)), FriendListReadCompleteDelegate);
		return;
	}

	// Fail immediately
	TArray<FBPFriendInfo> EmptyArray;

	OnFailure.Broadcast(EmptyArray);
}
开发者ID:eternalst0rm,项目名称:ClashOfBalls,代码行数:25,代码来源:GetFriendsCallbackProxy.cpp

示例8: GetLocalPlayer

void APuzzlePresetPlayerController::OnEndTurn()
{
	/*UPuzzlePresetGameInstance* ppgi = Cast<UPuzzlePresetGameInstance>(GetGameInstance());
	ULocalPlayer* LocalPlayer = GetLocalPlayer();
	ppgi->HostSession(MakeShareable(LocalPlayer->GetControllerId()),)
	return;*/

	IOnlineSubsystem* ion = IOnlineSubsystem::Get(FName("Steam"));

	if (ion != nullptr)
	{
		ULocalPlayer* LocalPlayer = GetLocalPlayer();
		if (LocalPlayer && LocalPlayer->GetControllerId() != -1)
		{
			UE_LOG(LogTemp, Warning, TEXT("steam user name: %s"), *PlayerState->PlayerName);
			uint8 status = ion->GetIdentityInterface()->GetLoginStatus(LocalPlayer->GetControllerId());
			UE_LOG(LogTemp, Warning, TEXT("steam user status: %d"), status);
		}

		/*if (ion->InitSteamworksClient(false, 480))
		{
		UE_LOG(LogTemp, Warning, TEXT("Steam API initialized succesfully!"));
		}
		else
		{
		UE_LOG(LogTemp, Warning, TEXT("Failed to initialize Steam API :("));
		}*/
	}
}
开发者ID:alkboda,项目名称:PuzzlePreset,代码行数:29,代码来源:PuzzlePresetPlayerController.cpp

示例9: InformAboutRing_Implementation

void ATimeIsUpPlayerState::InformAboutRing_Implementation(class ATimeIsUpPlayerState* PlayerState) {
	/* Search for the player */
	for (FConstPlayerControllerIterator It = GetWorld()->GetPlayerControllerIterator(); It; ++It) {
		ATimeIsUpPlayerController *TestPC = Cast<ATimeIsUpPlayerController>(*It);
		if (TestPC) {
			ULocalPlayer *LocalPlayer = Cast<ULocalPlayer>(TestPC->Player);
			TSharedPtr<FUniqueNetId> LocalID = LocalPlayer->GetUniqueNetId();
			if (LocalID.IsValid() && *LocalPlayer->GetUniqueNetId() == *PlayerState->UniqueId) {
				TestPC->OnRingGet();
			}
		}
	}
}
开发者ID:orbv,项目名称:TimeIsUp,代码行数:13,代码来源:TimeIsUpPlayerState.cpp

示例10: GetActorBounds

void AEyeXSimpleInteractorPawn::UpdateRegion()
{
	FVector Origin;
	FVector Extents;
	GetActorBounds(false, Origin, Extents);

	auto playerController = Cast<APlayerController>(Controller);
	ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(playerController->Player);

	auto ViewFamilyArguments = FSceneViewFamily::ConstructionValues(LocalPlayer->ViewportClient->Viewport, GetWorld()->Scene, LocalPlayer->ViewportClient->EngineShowFlags);
	ViewFamilyArguments.SetRealtimeUpdate(true);
	FSceneViewFamilyContext ViewFamily(ViewFamilyArguments);

	// Calculate a view where the player is to update the streaming from the players start location
	FVector ViewLocation;
	FRotator ViewRotation;
	FSceneView* SceneView = LocalPlayer->CalcSceneView(&ViewFamily, /*out*/ ViewLocation, /*out*/ ViewRotation, LocalPlayer->ViewportClient->Viewport);

	FVector2D ExtentPoints[8];
	SceneView->WorldToPixel(Origin + FVector(Extents.X, Extents.Y, Extents.Z), ExtentPoints[0]); //Right Top Front
	SceneView->WorldToPixel(Origin + FVector(Extents.X, Extents.Y, -Extents.Z), ExtentPoints[1]); //Right Top Back
	SceneView->WorldToPixel(Origin + FVector(Extents.X, -Extents.Y, Extents.Z), ExtentPoints[2]); //Right Bottom Front
	SceneView->WorldToPixel(Origin + FVector(Extents.X, -Extents.Y, -Extents.Z), ExtentPoints[3]); //Right Bottom Back
	SceneView->WorldToPixel(Origin + FVector(-Extents.X, Extents.Y, Extents.Z), ExtentPoints[4]); //Left Top Front
	SceneView->WorldToPixel(Origin + FVector(-Extents.X, Extents.Y, -Extents.Z), ExtentPoints[5]); //Left Top Back
	SceneView->WorldToPixel(Origin + FVector(-Extents.X, -Extents.Y, Extents.Z), ExtentPoints[6]); //Left Bottom Front
	SceneView->WorldToPixel(Origin + FVector(-Extents.X, -Extents.Y, -Extents.Z), ExtentPoints[7]); //Left Bottom Back

	FVector2D TopLeft = FVector2D(std::numeric_limits<float>::max(), std::numeric_limits<float>::max());
	FVector2D BottomRight = FVector2D(std::numeric_limits<float>::min(), std::numeric_limits<float>::min());

	for (auto Point : ExtentPoints)
	{
		if (Point.X < TopLeft.X)
			TopLeft.X = Point.X;
		else if (Point.X > BottomRight.X)
			BottomRight.X = Point.X;

		if (Point.Y < TopLeft.Y)
			TopLeft.Y = Point.Y;
		else if (Point.Y > BottomRight.Y)
			BottomRight.Y = Point.Y;
	}

	MyRegion->bounds.left = TopLeft.X;
	MyRegion->bounds.top = TopLeft.Y;
	MyRegion->bounds.right = BottomRight.X;
	MyRegion->bounds.bottom = BottomRight.Y;
}
开发者ID:Temaran,项目名称:EyeXUnreal,代码行数:49,代码来源:EyeXSimpleInteractorPawn.cpp

示例11: GetShooterHUD

void AShooterPlayerController::OnDeathMessage(class AShooterPlayerState* KillerPlayerState, class AShooterPlayerState* KilledPlayerState, const UDamageType* KillerDamageType) 
{
	AShooterHUD* ShooterHUD = GetShooterHUD();
	if (ShooterHUD)
	{
		ShooterHUD->ShowDeathMessage(KillerPlayerState, KilledPlayerState, KillerDamageType);		
	}

	ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(Player);
	if (LocalPlayer && LocalPlayer->GetUniqueNetId().IsValid() && KilledPlayerState->UniqueId.IsValid())
	{
		// if this controller is the player who died, update the hero stat.
		if (*LocalPlayer->GetUniqueNetId() == *KilledPlayerState->UniqueId)
		{
			const auto Events = Online::GetEventsInterface();
			const auto Identity = Online::GetIdentityInterface();

			if (Events.IsValid() && Identity.IsValid())
			{							
				int32 UserIndex = LocalPlayer->ControllerId;
				TSharedPtr<FUniqueNetId> UniqueID = Identity->GetUniquePlayerId(UserIndex);
				if (UniqueID.IsValid())
				{				
					ACharacter* Pawn = GetCharacter();
					check(Pawn);
					FVector Location = Pawn->GetActorLocation();

					FOnlineEventParms Params;
					Params.Add( TEXT( "SectionId" ), FVariantData( (int32)1 ) );
					Params.Add( TEXT( "GameplayModeId" ), FVariantData( (int32)1 ) );
					Params.Add( TEXT( "DifficultyLevelId" ), FVariantData( (int32)0 ) );

					Params.Add( TEXT( "PlayerRoleId" ), FVariantData( (int32)0 ) );
					Params.Add( TEXT( "PlayerWeaponId" ), FVariantData( (int32)0 ) );
					Params.Add( TEXT( "EnemyRoleId" ), FVariantData( (int32)0 ) );
					Params.Add( TEXT( "EnemyWeaponId" ), FVariantData( (int32)0 ) );	
				
					Params.Add( TEXT( "LocationX" ), FVariantData( Location.X ) );
					Params.Add( TEXT( "LocationY" ), FVariantData( Location.Y ) );
					Params.Add( TEXT( "LocationZ" ), FVariantData( Location.Z ) );
										
					Events->TriggerEvent(*UniqueID, TEXT("PlayerDeath"), Params);
				}
			}
		}
	}	
}
开发者ID:rob422lou,项目名称:Perdix,代码行数:47,代码来源:ShooterPlayerController.cpp

示例12: SetMouseLockedToViewport

void ULucyFunctions::SetMouseLockedToViewport(const bool Locked)
{
	if (GEngine == nullptr)
	{
		return;
	}

	UGameViewportClient* ViewportClient = GEngine->GameViewport;
	if (ViewportClient == nullptr)
	{
		return;
	}

	TSharedPtr<SViewport> ViewportWidget = ViewportClient->GetGameViewportWidget();
	if (!ViewportWidget.IsValid())
	{
		return;
	}

	TArray<APlayerController*> LocalPlayerControllers;
	GEngine->GetAllLocalPlayerControllers(LocalPlayerControllers);

	for (APlayerController* LocalPlayerController : LocalPlayerControllers)
	{
		if (LocalPlayerController == nullptr)
		{
			continue;
		}

		ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(LocalPlayerController->Player);
		if (LocalPlayer == nullptr)
		{
			continue;
		}

		if (Locked)
		{
			LocalPlayer->GetSlateOperations().LockMouseToWidget(ViewportWidget.ToSharedRef());
		}
		else
		{
			LocalPlayer->GetSlateOperations().ReleaseMouseLock();
		}
	}
}
开发者ID:kjustynski,项目名称:Lucy,代码行数:45,代码来源:LucyFunctions.cpp

示例13: FindFocusedActor

AEyeXActorBase* AEyeXPlayerController::FindFocusedActor(FHitResult& OutHit, const FVector2D& GazePoint)
{
	// Get the scene view to deproject the gazepoint to world space
	ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(Player);

	if (!LocalPlayer)
		return nullptr;

	FSceneViewFamily ViewFamily(FSceneViewFamily::ConstructionValues(
		LocalPlayer->ViewportClient->Viewport,
		GetWorld()->Scene,
		LocalPlayer->ViewportClient->EngineShowFlags)
		.SetRealtimeUpdate(true));

	FVector ViewLocation;
	FRotator ViewRotation;
	FSceneView* View = LocalPlayer->CalcSceneView(&ViewFamily, /*out*/ ViewLocation, /*out*/ ViewRotation, LocalPlayer->ViewportClient->Viewport);

	// Initiate sweep/trace variables
	const FCollisionObjectQueryParams ObjectParams(FEyeXUtils::ECCArrayToBitField(CollisionChannels));
	const FCollisionQueryParams TraceParams(FName(TEXT("GazeTrace")), true, GetPawn());
	FHitResult HitResult;
	AEyeXActorBase* EyeXActor = nullptr;

	switch (DetectionMode)
	{
	case EEyeXDetectionMode::LineTrace:
		EyeXActor = FindByLineTrace(HitResult, View, GazePoint, ObjectParams, TraceParams);
		break;
	case EEyeXDetectionMode::BoxedLineTrace:
		EyeXActor = FindByBoxedLineTrace(HitResult, View, GazePoint, ObjectParams, TraceParams);
		break;
	case EEyeXDetectionMode::Sweep:
		EyeXActor = FindBySweep(HitResult, View, GazePoint, ObjectParams, TraceParams);
		break;
	case EEyeXDetectionMode::FrustrumIntersection:
		EyeXActor = FindByFrustumIntersection(HitResult, View, GazePoint, ObjectParams, TraceParams);
		break;
	default:
		break;
	}

	OutHit = HitResult; 
	return EyeXActor; // use out param for actor as well, alternatively use hit actor in hit result (with cast). make the method const too.
}
开发者ID:AnyKey-,项目名称:EyeXforUE4,代码行数:45,代码来源:EyeXPlayerController.cpp

示例14: FindLocalPlayerFromControllerId

void UAmethystGameInstance::HandleControllerConnectionChange(bool bIsConnection, int32 Unused, int32 GameUserIndex)
{
	if (!bIsConnection)
	{
		// Controller was disconnected

		// Find the local player associated with this user index
		ULocalPlayer * LocalPlayer = FindLocalPlayerFromControllerId(GameUserIndex);

		if (LocalPlayer == NULL)
		{
			return;		// We don't care about players we aren't tracking
		}

		// Invalidate this local player's controller id.
		LocalPlayer->SetControllerId(-1);
	}
}
开发者ID:1337programming,项目名称:amethystforest,代码行数:18,代码来源:AmethystGameInstance.cpp

示例15: IsAimSensitivityDirty

bool UAmethystPersistentUser::IsAimSensitivityDirty() const
{
    bool bIsAimSensitivityDirty = false;
    
    // Fixme: UAmethystPersistentUser is not setup to work with multiple worlds.
    // For now, user settings are global to all world instances.
    if (GEngine)
    {
        TArray<APlayerController*> PlayerList;
        GEngine->GetAllLocalPlayerControllers(PlayerList);
        
        for (auto It = PlayerList.CreateIterator(); It; ++It)
        {
            APlayerController* PC = *It;
            if (!PC || !PC->Player || !PC->PlayerInput)
            {
                continue;
            }
            
            // Update key bindings for the current user only
            ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(PC->Player);
            if(!LocalPlayer || LocalPlayer->GetControllerId() != UserIndex)
            {
                continue;
            }
            
            // check if the aim sensitivity is off anywhere
            for (int32 Idx = 0; Idx < PC->PlayerInput->AxisMappings.Num(); Idx++)
            {
                FInputAxisKeyMapping &AxisMapping = PC->PlayerInput->AxisMappings[Idx];
                if (AxisMapping.AxisName == "Lookup" || AxisMapping.AxisName == "LookupRate" || AxisMapping.AxisName == "Turn" || AxisMapping.AxisName == "TurnRate")
                {
                    if (FMath::Abs(AxisMapping.Scale) != GetAimSensitivity())
                    {
                        bIsAimSensitivityDirty = true;
                        break;
                    }
                }
            }
        }
    }
    
    return bIsAimSensitivityDirty;
}
开发者ID:1337programming,项目名称:amethystforest,代码行数:44,代码来源:AmethystPersistentUser.cpp


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