Exemplo n.º 1
0
void UDemoNetDriver::SpawnDemoRecSpectator( UNetConnection* Connection )
{
	check( Connection != NULL );

	UClass* C = StaticLoadClass( AActor::StaticClass(), NULL, *DemoSpectatorClass, NULL, LOAD_None, NULL );

	if ( C == NULL )
	{
		UE_LOG( LogDemo, Error, TEXT( "UDemoNetDriver::SpawnDemoRecSpectator: Failed to load demo spectator class." ) );
		return;
	}

	APlayerController* Controller = World->SpawnActor<APlayerController>( C );

	if ( Controller == NULL )
	{
		UE_LOG( LogDemo, Error, TEXT( "UDemoNetDriver::SpawnDemoRecSpectator: Failed to spawn demo spectator." ) );
		return;
	}

	for ( FActorIterator It( World ); It; ++It)
	{
		if ( It->IsA( APlayerStart::StaticClass() ) )
		{
			Controller->SetInitialLocationAndRotation( It->GetActorLocation(), It->GetActorRotation() );
			break;
		}
	}

	Controller->SetReplicates( true );
	Controller->SetAutonomousProxy( true );

	Controller->SetPlayer( Connection );
}
Exemplo n.º 2
0
void FPlayerMuteList::ServerMutePlayer(APlayerController* OwningPC, const FUniqueNetIdRepl& MuteId)
{
	UWorld* World = OwningPC->GetWorld();

	const TSharedPtr<const FUniqueNetId>& PlayerIdToMute = MuteId.GetUniqueNetId();

	// Don't reprocess if they are already muted
	AddIdToMuteList(VoiceMuteList, PlayerIdToMute);

	// Add them to the packet filter list if not already on it
	AddIdToMuteList(VoicePacketFilter, PlayerIdToMute);

	// Replicate mute state to client
	OwningPC->ClientMutePlayer(MuteId);

	// Find the muted player's player controller so it can be notified
	APlayerController* OtherPC = GetPlayerControllerFromNetId(World, *PlayerIdToMute);
	if (OtherPC != NULL)
	{
		// Update their packet filter list too
		OtherPC->MuteList.ClientMutePlayer(OtherPC, OwningPC->PlayerState->UniqueId);

		// Tell the other PC to mute this one
		OtherPC->ClientMutePlayer(OwningPC->PlayerState->UniqueId);
	}
}
Exemplo n.º 3
0
void APickUpItem::Prox_Implementation(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32
	OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
	// if the overlapped actor is NOT the player,
	// you simply should return
	if (Cast<AActor>(OtherActor) == nullptr)
	{
		return;
	}
	// Get a reference to the player avatar, to give him
	// the item
	AAvatar *avatar = Cast<AAvatar>(UGameplayStatics::GetPlayerPawn(
		GetWorld(), 0));
	// Let the player pick up item
	// Notice use of keyword this!
	// That is how _this_ Pickup can refer to itself.
	avatar->Pickup(this);
	
	if (CoinSound != NULL)
	{
		UGameplayStatics::PlaySoundAtLocation(this, CoinSound, GetActorLocation());
	}
	// Get a reference to the controller
	APlayerController* PController = GetWorld() ->GetFirstPlayerController();
	// Get a reference to the HUD from the controller
	AMyHUD* hud = Cast<AMyHUD>(PController->GetHUD());
	hud->addMessage(Message(Icon, FString("Picked up ") + FString(" ") + Name + FString(" ")+FString::FromInt(Quantity), 2.0f, FColor::Black, FColor::Black));
	Destroy();

	
}
Exemplo n.º 4
0
void APawn::PreInitializeComponents()
{
	Super::PreInitializeComponents();

	if (Instigator == nullptr)
	{
		Instigator = this;
	}

	if (AutoPossessPlayer != EAutoReceiveInput::Disabled && GetNetMode() != NM_Client )
	{
		const int32 PlayerIndex = int32(AutoPossessPlayer.GetValue()) - 1;

		APlayerController* PC = UGameplayStatics::GetPlayerController(this, PlayerIndex);
		if (PC)
		{
			PC->Possess(this);
		}
		else
		{
			GetWorld()->PersistentLevel->RegisterActorForAutoReceiveInput(this, PlayerIndex);
		}
	}

	UpdateNavigationRelevance();
}
Exemplo n.º 5
0
// Called every frame
void ACameraDirector::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

	const float TimeBetweenCameraChanges = 2.0f;
	const float SmoothBlendTime = 0.75f;
	TimeToNextCameraChange -= DeltaTime;
	if (TimeToNextCameraChange <= 0.0f)
	{
		TimeToNextCameraChange += TimeBetweenCameraChanges;

		// Find the actor that handles control for the local player.
		APlayerController* OurPlayerController = UGameplayStatics::GetPlayerController(this, 0);
		if (OurPlayerController)
		{
			if ((OurPlayerController->GetViewTarget() != CameraOne) && (CameraOne != nullptr))
			{
				// Cut instantly to camera one.
				OurPlayerController->SetViewTarget(CameraOne);
			}
			else if ((OurPlayerController->GetViewTarget() != CameraTwo) && (CameraTwo != nullptr))
			{
				// Blend smoothly to camera two.
				OurPlayerController->SetViewTargetWithBlend(CameraTwo, SmoothBlendTime);
			}
		}
	}
}
Exemplo n.º 6
0
/**
 * Delegate fired when the joining process for an online session has completed
 *
 * @param SessionName the name of the session this callback is for
 * @param bWasSuccessful true if the async action completed without error, false if there was an error
 */
void UOnlineSessionClient::OnJoinSessionComplete(FName SessionName, EOnJoinSessionCompleteResult::Type Result)
{
	UE_LOG(LogOnline, Verbose, TEXT("OnJoinSessionComplete %s bSuccess: %d"), *SessionName.ToString(), static_cast<int32>(Result));
	SessionInt->ClearOnJoinSessionCompleteDelegate(OnJoinSessionCompleteDelegate);

	if (Result == EOnJoinSessionCompleteResult::Success)
	{
		FString URL;
		if (SessionInt->GetResolvedConnectString(SessionName, URL))
		{
			APlayerController* PC = GetPlayerController();
			if (PC)
			{
				if (bIsFromInvite)
				{
					URL += TEXT("?bIsFromInvite");
					bIsFromInvite = false;
				}
				PC->ClientTravel(URL, TRAVEL_Absolute);
			}
		}
		else
		{
			UE_LOG(LogOnline, Warning, TEXT("Failed to join session %s"), *SessionName.ToString());
		}
	}
}
Exemplo n.º 7
0
void AGameModeBase::PostSeamlessTravel()
{
	if (GameSession)
	{
		GameSession->PostSeamlessTravel();
	}

	// We have to make a copy of the controller list, since the code after this will destroy
	// and create new controllers in the world's list
	TArray<TAutoWeakObjectPtr<AController> >	OldControllerList;
	for (auto It = GetWorld()->GetControllerIterator(); It; ++It)
	{
		OldControllerList.Add(*It);
	}

	// Handle players that are already loaded
	for (FConstControllerIterator Iterator = OldControllerList.CreateConstIterator(); Iterator; ++Iterator)
	{
		AController* Controller = *Iterator;
		if (Controller->PlayerState)
		{
			APlayerController* PlayerController = Cast<APlayerController>(Controller);
			if (!PlayerController || PlayerController->HasClientLoadedCurrentWorld())
			{
				// Don't handle if player is still loading world, that gets called in ServerNotifyLoadedWorld
				HandleSeamlessTravelPlayer(Controller);
			}
		}
	}
}
void FPlatformerIngameMenu::ReturnToMainMenu()
{	
	APlatformerPlayerController * PlatformPC = (PCOwner.IsValid())? Cast<APlatformerPlayerController>(PCOwner.Get()) : NULL;
	FString RemoteReturnReason = NSLOCTEXT("NetworkErrors", "HostHasLeft", "Host has left the game.").ToString();
	FString LocalReturnReason(TEXT(""));

	if ( PlatformPC )
	{
		if (PlatformPC->GetNetMode() < NM_Client)
		{
			for(auto Iterator = PlatformPC->GetWorld()->GetPlayerControllerIterator(); Iterator; ++Iterator)
			{
				APlayerController* Controller = *Iterator;
				if (Controller && Controller->IsPrimaryPlayer() && Controller != PlatformPC) 
				{
					Controller->ClientReturnToMainMenu(RemoteReturnReason);
				}
			}
			PlatformPC->ClientReturnToMainMenu(LocalReturnReason);
		}
		else
		{
			PlatformPC->ClientReturnToMainMenu(LocalReturnReason);
		}
	}
	DestroyRootMenu();

}
void ANetworkController::ReceivedSelectCamera(msgpack_object* Data) {
	FString name = Unpack<FString>(Data);
	APlayerController* PlayerController = NULL;
	for (auto Iterator = GetWorld()->GetPlayerControllerIterator(); Iterator; ++Iterator) {
		PlayerController = *Iterator;
		break;
	}
	if (!PlayerController) {
		return;
	}

	//PlayerController->PlayerCameraManager->PlayCameraAnim()

	for (TActorIterator<ACameraActor> ObjIt(GetWorld()); ObjIt; ++ObjIt) {
		ACameraActor* Camera = *ObjIt;
		//GEngine->AddOnScreenDebugMessage(-1, 60.f, FColor::Yellow, Camera->GetName());
		if (Camera->GetName() == name) {
			PlayerController->SetViewTarget(Camera);

			AFollowRoadCamera* FollowRoadCamera = Cast<AFollowRoadCamera>(Camera);

			if (FollowRoadCamera) {
				FollowRoadCamera->Start(false, 0);
			}

			return;
		}
	}
}
void UTDCSpectatorPawnMovement::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

	if (!PawnOwner || !UpdatedComponent)
	{
		return;
	}

	APlayerController* PlayerController = Cast<APlayerController>(PawnOwner->GetController());
	if (PlayerController && PlayerController->IsLocalController())
	{
		if (!bInitialLocationSet)
		{
			PawnOwner->SetActorRotation(PlayerController->GetControlRotation());
			PawnOwner->SetActorLocation(PlayerController->GetSpawnLocation());
			bInitialLocationSet = true;
		}

		FVector MyLocation = UpdatedComponent->GetComponentLocation();
		ATDCSpectatorPawn* SpectatorPawn = Cast<ATDCSpectatorPawn>(PlayerController->GetSpectatorPawn());
		if ((SpectatorPawn != NULL) && (SpectatorPawn->GetCameraComponent() != NULL))
		{
			SpectatorPawn->GetCameraComponent()->ClampCameraLocation(PlayerController, MyLocation);
		}
		UpdatedComponent->SetWorldLocation(MyLocation, false);
	}
}
Exemplo n.º 11
0
void UNetGameInstance::OnCompleted(FName SessionName, EOnJoinSessionCompleteResult::Type Result)
{
	
	
	APlayerController* PC = GetWorld()->GetFirstPlayerController();
	
	FFrame::KismetExecutionMessage(TEXT("Yeeee Join succesful"), ELogVerbosity::Warning);

	
	auto Sessions = Online::GetSessionInterface();
	if (Sessions.IsValid())
	{
		Sessions->ClearOnJoinSessionCompleteDelegate(Delegate);

		if (Result == EOnJoinSessionCompleteResult::Success)
		{
			// Client travel to the server
			FString ConnectString;
			if (Sessions->GetResolvedConnectString(GameSessionName, ConnectString) && PC->IsValidLowLevel())
			{
				//UE_LOG(Network, Log, TEXT("Join session: traveling to %s"), *ConnectString);
					
				PC->ClientTravel(ConnectString, TRAVEL_Absolute);
					
				return;
			}
		}
	}
	

	
}
Exemplo n.º 12
0
PyObject *py_ue_get_player_pawn(ue_PyUObject *self, PyObject * args)
{

	ue_py_check(self);

	int controller_id = 0;
	if (!PyArg_ParseTuple(args, "|i:get_player_pawn", &controller_id))
	{
		return NULL;
	}

	UWorld *world = ue_get_uworld(self);
	if (!world)
		return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject");

	APlayerController *controller = UGameplayStatics::GetPlayerController(world, controller_id);
	if (!controller)
		return PyErr_Format(PyExc_Exception, "unable to retrieve controller %d", controller_id);

	// the controller could not have a pawn
	if (!controller->GetPawn())
		Py_RETURN_NONE;

	Py_RETURN_UOBJECT(controller->GetPawn());
}
void ACameraDirector::ProcessTransition()
{
	APlayerController* PlayerController = UGameplayStatics::GetPlayerController(this, 0);

	if (PlayerController)
	{
		FCameraStruct CameraData = ManagedCameras[CurrentCameraIndex];
		AActor* Camera = CameraData.Camera;
		float LinearBlend = CameraData.LinearBlend;

		if (Camera)
		{
			if (LinearBlend > 0.f)
			{
				PlayerController->SetViewTargetWithBlend(Camera, LinearBlend);
			}
			else
			{
				PlayerController->SetViewTarget(Camera);
			}
		}
	}

	CurrentCameraIndex++;
	CurrentCameraIndex = CurrentCameraIndex == ManagedCameras.Num() ? 0 : CurrentCameraIndex;
	TimeToNextCameraChange = ManagedCameras[CurrentCameraIndex].TransitionTime;
}
Exemplo n.º 14
0
// Called every frame
void ACameraDirector::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	const float TimeBetweenCameraChanges = 60.f;
	const float SmoothBlendTime = 59.0f;
	TimeToNextCameraChange -= DeltaTime;

	if (TimeToNextCameraChange <= 0.0f)
	{
		TimeToNextCameraChange += TimeBetweenCameraChanges;

		//Find actor that handles ctonrtol for local player.

		APlayerController* OurPlayerController = UGameplayStatics::GetPlayerController(this, 0);

		if (OurPlayerController)
		{

			if (CameraTwo && (OurPlayerController->GetViewTarget() == CameraOne))
			{
				//Blend smoothly to camera two.
				OurPlayerController->SetViewTargetWithBlend(CameraTwo, SmoothBlendTime);
			}
			else if (CameraOne)
			{
				//Cut instantly to camera one.
				//OurPlayerController->SetViewTarget(CameraOne);
				OurPlayerController->SetViewTargetWithBlend(CameraOne, SmoothBlendTime);
			}
		}

	}

}
Exemplo n.º 15
0
void AGameModeBase::InitSeamlessTravelPlayer(AController* NewController)
{
	APlayerController* NewPC = Cast<APlayerController>(NewController);
	// Find a start spot
	AActor* StartSpot = FindPlayerStart(NewController);

	if (StartSpot == nullptr)
	{
		UE_LOG(LogGameMode, Warning, TEXT("Could not find a starting spot"));
	}
	else
	{
		FRotator StartRotation(0, StartSpot->GetActorRotation().Yaw, 0);
		NewController->SetInitialLocationAndRotation(StartSpot->GetActorLocation(), StartRotation);
	}

	NewController->StartSpot = StartSpot;

	if (NewPC != nullptr)
	{
		NewPC->PostSeamlessTravel();

		if (MustSpectate(NewPC))
		{
			NewPC->StartSpectatingOnly();
		}
		else
		{
			NewPC->bPlayerIsWaiting = true;
			NewPC->ChangeState(NAME_Spectating);
			NewPC->ClientGotoState(NAME_Spectating);
		}
	}
}
void AUETutorialGameMode::HandleNewState(EUETutorialGameModeState State)
{
	switch (State)
	{
		case EUETutorialGameModeState::EPlaying:
		{
			for (ASpawnVolume * Volume : SpawnVolumeActors)
			{
				Volume->EnableSpawning();
			}
			break;
		}
		case EUETutorialGameModeState::EGameOver:
		{
			for (ASpawnVolume * Volume : SpawnVolumeActors)
			{
				Volume->DisableSpawning();
			}
			APlayerController * PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);
			PlayerController->SetCinematicMode(true, true, true);
			break;
		}
		case EUETutorialGameModeState::EUnknown:
		default:
			break;
	}
}
Exemplo n.º 17
0
void AGameModeBase::GenericPlayerInitialization(AController* C)
{
	APlayerController* PC = Cast<APlayerController>(C);
	if (PC != nullptr)
	{
		InitializeHUDForPlayer(PC);

		// Notify the game that we can now be muted and mute others
		UpdateGameplayMuteList(PC);

		// Tell the player to enable voice by default or use the push to talk method
		PC->ClientEnableNetworkVoice(!GameSession->RequiresPushToTalk());

		ReplicateStreamingStatus(PC);

		bool HidePlayer = false, HideHUD = false, DisableMovement = false, DisableTurning = false;

		// Check to see if we should start in cinematic mode (matinee movie capture)
		if (ShouldStartInCinematicMode(PC, HidePlayer, HideHUD, DisableMovement, DisableTurning))
		{
			PC->SetCinematicMode(true, HidePlayer, HideHUD, DisableMovement, DisableTurning);
		}

		// Add the player to any matinees running so that it gets in on any cinematics already running, etc
		TArray<AMatineeActor*> AllMatineeActors;
		GetWorld()->GetMatineeActors(AllMatineeActors);
		for (int32 i = 0; i < AllMatineeActors.Num(); i++)
		{
			AllMatineeActors[i]->AddPlayerToDirectorTracks(PC);
		}
	}
}
Exemplo n.º 18
0
void ATotemCharacter::CheckShiftKey()
{
	//For Sprint, designed only execute on owning client
	if (Controller)
	{
		if (Controller->IsLocalPlayerController())
		{
			APlayerController* PlayerController = Cast<APlayerController>(Controller);
			if (PlayerController)
			{
				if (PlayerController->IsInputKeyDown(EKeys::LeftShift))
				{
					// if no move state && on the ground
					if (TotemCharacterMoveState == ETotemCharacterMoveState::NoMove && GetCharacterMovement()->IsWalking())
					{
						SetTotemCharacterMoveState(ETotemCharacterMoveState::Sprint);
					}
				}
				else
				{
					if (TotemCharacterMoveState == ETotemCharacterMoveState::Sprint)
					{
						SetTotemCharacterMoveState(ETotemCharacterMoveState::NoMove);
					}
				}
			}
		}
	}
}
Exemplo n.º 19
0
void FBehaviorTreeDebugger::FindLockedDebugActor(UWorld* World)
{
	APlayerController* LocalPC = GEngine->GetFirstLocalPlayerController(World);
	if (LocalPC && LocalPC->GetHUD() && LocalPC->GetPawnOrSpectator())
	{
		AGameplayDebuggingReplicator* DebuggingReplicator = NULL;
		for (TActorIterator<AGameplayDebuggingReplicator> It(World); It; ++It)
		{
			AGameplayDebuggingReplicator* A = *It;
			if (!A->IsPendingKill())
			{
				DebuggingReplicator = A;
				break;
			}
		}

		const APawn* LockedPawn = DebuggingReplicator != NULL ? Cast<APawn>(DebuggingReplicator->GetSelectedActorToDebug()) : NULL;
		UBehaviorTreeComponent* TestInstance = FindInstanceInActor((APawn*)LockedPawn);
		if (TestInstance)
		{
			TreeInstance = TestInstance;

#if USE_BEHAVIORTREE_DEBUGGER
			ActiveStepIndex = TestInstance->DebuggerSteps.Num() - 1;
#endif
		}
	}
}
Exemplo n.º 20
0
void AGameSession::HandleMatchHasEnded()
{
	if (STATS && !UE_BUILD_SHIPPING)
	{
		if (FParse::Param(FCommandLine::Get(), TEXT("MatchAutoStatCapture")))
		{
			UE_LOG(LogGameSession, Log, TEXT("Match has ended - end automatic stat capture"));
			GEngine->Exec(GetWorld(), TEXT("stat stopfile"));
		}
	}

	UWorld* World = GetWorld();
	if (UOnlineEngineInterface::Get()->DoesSessionExist(World, SessionName))
	{
		for (FConstPlayerControllerIterator Iterator = World->GetPlayerControllerIterator(); Iterator; ++Iterator)
		{
			APlayerController* PlayerController = *Iterator;
			if (!PlayerController->IsLocalController())
			{
				PlayerController->ClientEndOnlineSession();
			}
		}

		FOnlineSessionStartComplete CompletionDelegate = FOnlineSessionEndComplete::CreateUObject(this, &AGameSession::OnEndSessionComplete);
		UOnlineEngineInterface::Get()->EndSession(World, SessionName, CompletionDelegate);
	}
}
Exemplo n.º 21
0
void APawn::PawnClientRestart()
{
	Restart();

	APlayerController* PC = Cast<APlayerController>(Controller);
	if (PC && PC->IsLocalController())
	{
		// Handle camera possession
		if (PC->bAutoManageActiveCameraTarget)
		{
			PC->AutoManageActiveCameraTarget(this);
		}

		// Set up player input component, if there isn't one already.
		if (InputComponent == NULL)
		{
			InputComponent = CreatePlayerInputComponent();
			if (InputComponent)
			{
				SetupPlayerInputComponent(InputComponent);
				InputComponent->RegisterComponent();
				if (UInputDelegateBinding::SupportsInputDelegate(GetClass()))
				{
					InputComponent->bBlockInput = bBlockInput;
					UInputDelegateBinding::BindInputDelegates(GetClass(), InputComponent);
				}

			}
		}
	}
}
Exemplo n.º 22
0
void AAvatar::ToggleInventory()
{
	APlayerController* PController = GetWorld()->GetFirstPlayerController();
	AMyHUD* hud = Cast<AMyHUD>( PController->GetHUD() );
	
	// If inventory is displayed, undisplay it.
	if( inventoryShowing )
	{
		hud->clearWidgets();
		inventoryShowing = false;
		PController->bShowMouseCursor = false;
		return;
	}

	// Otherwise, display the player's inventory
	inventoryShowing = true;
	PController->bShowMouseCursor = true;
	for( TMap<FString,int>::TIterator it = Backpack.CreateIterator(); it; ++it )
	{
		// Combine string name of the item, with qty eg Cow x 5
		FString fs = it->Key + FString::Printf( TEXT(" x %d"), it->Value );
		UTexture2D* tex = NULL;
		if( Icons.Find( it->Key ) )
		{
			tex = Icons[it->Key];
			Widget w( Icon( fs, tex ), Classes[it->Key] );
			w.bpSpell = Spells[it->Key];
			hud->addWidget( w );
		}
	}
}
Exemplo n.º 23
0
void UCheatManager::TestCollisionDistance()
{
	APlayerController* PC = GetOuterAPlayerController();
	if(PC)
	{
		// Get view location to act as start point
		FVector ViewLoc;
		FRotator ViewRot;
		PC->GetPlayerViewPoint(ViewLoc, ViewRot);

		FlushPersistentDebugLines( GetOuterAPlayerController()->GetWorld() );//change the GetWorld

		// calculate from viewloc
		for (FObjectIterator Iter(AVolume::StaticClass()); Iter; ++Iter)
		{
			AVolume * Volume = Cast<AVolume>(*Iter);

			if (Volume->GetClass()->GetDefaultObject() != Volume)
			{
				FVector ClosestPoint(0,0,0);
				float Distance = Volume->GetBrushComponent()->GetDistanceToCollision(ViewLoc, ClosestPoint);
				float NormalizedDistance = FMath::Clamp<float>(Distance, 0.f, 1000.f)/1000.f;
				FColor DrawColor(255*NormalizedDistance, 255*(1-NormalizedDistance), 0);
				DrawDebugLine(GetWorld(), ViewLoc, ClosestPoint, DrawColor, true);

				UE_LOG(LogCheatManager, Log, TEXT("Distance to (%s) is %0.2f"), *Volume->GetName(), Distance);
			}
		}
	}
}
Exemplo n.º 24
0
PyObject *py_ue_is_input_key_down(ue_PyUObject *self, PyObject * args)
{

	ue_py_check(self);

	char *key;
	int controller_id = 0;
	if (!PyArg_ParseTuple(args, "s|i:is_input_key_down", &key, &controller_id))
	{
		return NULL;
	}

	UWorld *world = ue_get_uworld(self);
	if (!world)
		return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject");

	APlayerController *controller = UGameplayStatics::GetPlayerController(world, controller_id);
	if (!controller)
		return PyErr_Format(PyExc_Exception, "unable to retrieve controller %d", controller_id);

	if (controller->IsInputKeyDown(key))
	{
		Py_INCREF(Py_True);
		return Py_True;
	}

	Py_INCREF(Py_False);
	return Py_False;
}
Exemplo n.º 25
0
bool AOpenBarrierConsole::OnInteract()
{
	/*When the player interact with the console it activates the camera to enter in puzzle mode*/
	UWorld* World = GetWorld();
	if (World)
	{
		APlayerController* PlayerController = World->GetFirstPlayerController();
		if (PlayerController)
		{
			ATGCOPlayerState* PlayerState = Cast<ATGCOPlayerState>(PlayerController->PlayerState);
			if (PlayerState)
			{
				if (PlayerState->eCurrentState == EPlayerStatus::IN_GAME)
				{
					PlayerState->SwitchGamePuzzle(CameraPuzzle);
				}
				else
				{
					if (PlayerState->eCurrentState == EPlayerStatus::IN_PUZZLE_GAME)
					{
						PlayerState->SwitchGamePuzzle(PlayerController->GetCharacter());
					}
				}
			}
		}
	}
	return true;
}
Exemplo n.º 26
0
PyObject *py_ue_input_key(ue_PyUObject * self, PyObject * args)
{

	ue_py_check(self);

	PyObject *py_fkey;
	int event_type;
	float amount = 0.0;
	PyObject *py_gamepad = nullptr;

	int controller_id = 0;
	if (!PyArg_ParseTuple(args, "Oi|fO:input_key", &py_fkey, &event_type, &amount, &py_gamepad))
	{
		return nullptr;;
	}

	APlayerController *controller = ue_py_check_type<APlayerController>(self);
	if (!controller)
		return PyErr_Format(PyExc_Exception, "object is not a APlayerController");

	FKey *key = ue_py_check_struct<FKey>(py_fkey);
	if (!key)
		return PyErr_Format(PyExc_Exception, "argument is not a FKey");

	if (controller->InputKey(*key, (EInputEvent)event_type, amount, py_gamepad && PyObject_IsTrue(py_gamepad)))
	{
		Py_RETURN_TRUE;
	}

	Py_RETURN_FALSE;
}
Exemplo n.º 27
0
PyObject *py_ue_input_axis(ue_PyUObject * self, PyObject * args)
{

	ue_py_check(self);

	PyObject *py_fkey;
	float delta;
	float delta_time;
	int num_samples = 1;
	PyObject *py_gamepad = nullptr;

	int controller_id = 0;
	if (!PyArg_ParseTuple(args, "Off|iO:input_axis", &py_fkey, &delta, &delta_time, &num_samples, &py_gamepad))
	{
		return nullptr;;
	}

	APlayerController *controller = ue_py_check_type<APlayerController>(self);
	if (!controller)
		return PyErr_Format(PyExc_Exception, "object is not a APlayerController");

	FKey *key = ue_py_check_struct<FKey>(py_fkey);
	if (!key)
		return PyErr_Format(PyExc_Exception, "argument is not a FKey");

	if (controller->InputAxis(*key, delta, delta_time, num_samples, py_gamepad && PyObject_IsTrue(py_gamepad)))
	{
		Py_RETURN_TRUE;
	}

	Py_RETURN_FALSE;
}
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());
	}
}
Exemplo n.º 29
0
// @TODO: DEPRECATED, remove.
void ADefaultPawn::Turn(float Val)
{
	APlayerController* PC = Cast<APlayerController>(GetController());
	if (PC)
	{
		PC->AddYawInput(Val);
	}
}
Exemplo n.º 30
0
// @TODO: DEPRECATED, remove.
void ADefaultPawn::LookUp(float Val)
{
	APlayerController* PC = Cast<APlayerController>(GetController());
	if (PC)
	{
		PC->AddPitchInput(Val);
	}
}