Level3 #11

Merged
oleg.petruny merged 7 commits from Level3 into master 2025-02-07 13:45:00 +00:00
55 changed files with 210 additions and 126 deletions
Showing only changes of commit 46777fbc3a - Show all commits

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,49 @@
// Oleg Petruny proprietary.
#include "CustomCharacter.h"
#include "GameFramework/CharacterMovementComponent.h"
void ACustomCharacter::Tick(float DeltaTime)
{
ACharacter::Tick(DeltaTime);
// stabilize move speed by fps
AddActorLocalOffset(ConsumeMovementInputVector() * DeltaTime);
// update isMoving flag
auto loc = GetActorLocation();
bIsMoving = (loc != oldLocation);
oldLocation = std::move(loc);
}
bool ACustomCharacter::IsMoving()
{
return bIsMoving;
}
bool ACustomCharacter::IsRunning()
{
return GetCharacterMovement()->MaxWalkSpeed > moveSpeed;
}
void ACustomCharacter::FlyMode(bool on)
{
GetCharacterMovement()->GravityScale = on ? 0.0f : 1.0f;
}
void ACustomCharacter::BeginPlay()
{
ACharacter::BeginPlay();
oldLocation = GetActorLocation();
GetCharacterMovement()->MaxWalkSpeed = moveSpeed;
}
void ACustomCharacter::SwitchRun(bool run)
{
if(run)
GetCharacterMovement()->MaxWalkSpeed = moveSpeed * runSpeedMultiplier;
else
GetCharacterMovement()->MaxWalkSpeed = moveSpeed;
}

View File

@ -0,0 +1,42 @@
// Oleg Petruny proprietary.
#pragma once
#include "GameFramework/Character.h"
#include "CustomCharacter.generated.h"
/**
* Extension to the standard editor character class.
* Main intention is to expand animations capabilities.
*/
UCLASS(Blueprintable, BlueprintType)
class ACustomCharacter : public ACharacter
{
GENERATED_BODY()
public:
virtual void Tick(float DeltaTime) override;
UFUNCTION(BlueprintPure)
bool IsMoving();
UFUNCTION(BlueprintPure)
bool IsRunning();
UFUNCTION(BlueprintCallable)
void FlyMode(bool on);
protected:
virtual void BeginPlay() override;
UFUNCTION(BlueprintCallable, Category = Character)
virtual void SwitchRun(bool run);
UPROPERTY(EditAnywhere)
float moveSpeed = 200;
UPROPERTY(EditAnywhere)
float runSpeedMultiplier = 4;
bool bIsMoving = false;
FVector oldLocation;
};

View File

@ -85,7 +85,8 @@ void UDialogueManager::EnqueDialogue(FDialogueEnqueProperties properties, FDialo
nextDialogues.Enqueue(properties);
endCallbacks.Enqueue(endCallback);
PlayNextDialogue();
if(leadDialogueProperties == nullptr)
PlayNextDialogue();
}
void UDialogueManager::PlayNextDialogue()
@ -248,7 +249,11 @@ void UDialogueManager::OnDialogueEnd()
}
dialoguesLock.Unlock();
if(!endCallbacks.IsEmpty())
if(leadDialogueProperties != nullptr)
PlayNextDialogue();
if(leadDialogueProperties == nullptr && !endCallbacks.IsEmpty())
PlayNextDialogue();
{

View File

@ -27,7 +27,7 @@ UInteractableActivator::UInteractableActivator(const FObjectInitializer& ObjectI
{
for(int32 i = 0; i < ECC_MAX; ++i)
{
if(collisions->ReturnChannelNameFromContainerIndex(i) == FName{ TEXT("Interactable") })
if(collisions->ReturnChannelNameFromContainerIndex(i) == FName{ TEXT("InteractableTrace") })
{
collisionChannel = (ECollisionChannel)i;
break;

View File

@ -28,7 +28,7 @@ public:
inline void CallNextState() { ++state; NextState(); }
/** Calls specific event id in level */
UFUNCTION(BlueprintImplementableEvent)
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable)
void CallEvent(int32 id);
inline int32 GetState() { return state; };

View File

@ -26,7 +26,6 @@ namespace
}
APlayerBase::APlayerBase()
: ACharacter()
{
static ConstructorHelpers::FObjectFinder<UInputMappingContext> asset{ TEXT("/Script/EnhancedInput.InputMappingContext'/Game/Input/IMC_Player.IMC_Player'") };
context = asset.Object;
@ -53,15 +52,7 @@ APlayerBase::APlayerBase()
void APlayerBase::Tick(float DeltaTime)
{
ACharacter::Tick(DeltaTime);
// stabilize move speed by fps
AddActorLocalOffset(ConsumeMovementInputVector() * DeltaTime);
// update isMoving flag
auto loc = GetActorLocation();
bIsMoving = (loc != oldLocation);
oldLocation = std::move(loc);
ACustomCharacter::Tick(DeltaTime);
rotationInput = FRotator::ZeroRotator;
}
@ -80,14 +71,9 @@ APlayerBase* APlayerBase::Get()
void APlayerBase::BeginPlay()
{
ACharacter::BeginPlay();
ACustomCharacter::BeginPlay();
auto world = GetWorld();
oldLocation = GetActorLocation();
GetCharacterMovement()->MaxWalkSpeed = moveSpeed;
cameraManager = UGameplayStatics::GetPlayerCameraManager(world, 0);
cameraManager = UGameplayStatics::GetPlayerCameraManager(GetWorld(), 0);
if(cameraManager)
{
cameraManager->ViewPitchMin = minPitch;
@ -97,16 +83,6 @@ void APlayerBase::BeginPlay()
LoadInteractablesActivators();
}
bool APlayerBase::IsMoving()
{
return bIsMoving;
}
bool APlayerBase::IsRunning()
{
return GetCharacterMovement()->MaxWalkSpeed > moveSpeed;
}
void APlayerBase::LockPlayer(FPlayerLock lock)
{
walkLocked += lock.walk;
@ -133,11 +109,6 @@ void APlayerBase::UnlockPlayer(FPlayerLock lock)
ResetInteractions();
}
void APlayerBase::FlyMode(bool on)
{
GetCharacterMovement()->GravityScale = on ? 0.0f : 1.0f;
}
void APlayerBase::ResetInteractions()
{
InteractableDeactivated(lastInteractable, static_cast<EActivatorType>(0xFF));
@ -216,10 +187,7 @@ void APlayerBase::SwitchRun(bool run)
if(runLocked)
return;
if(run)
GetCharacterMovement()->MaxWalkSpeed = moveSpeed * runSpeedMultiplier;
else
GetCharacterMovement()->MaxWalkSpeed = moveSpeed;
ACustomCharacter::SwitchRun(run);
}
void APlayerBase::UpdatePitch(float min, float max)

View File

@ -2,7 +2,7 @@
#pragma once
#include "GameFramework/Character.h"
#include "CustomCharacter.h"
#include "PlayerBase.generated.h"
@ -32,7 +32,7 @@ struct FPlayerLock
* prepares for work with interactables, and manages basic player input.
*/
UCLASS(Blueprintable, BlueprintType)
class APlayerBase : public ACharacter
class APlayerBase : public ACustomCharacter
{
GENERATED_BODY()
@ -40,7 +40,6 @@ public:
/** setup input context, camera and inventory */
APlayerBase();
virtual void Tick(float DeltaTime) override;
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
@ -48,15 +47,12 @@ public:
static APlayerBase* Get();
UFUNCTION(BlueprintPure)
bool IsMoving();
UFUNCTION(BlueprintPure)
bool IsRunning();
FVector GetCameraLocation();
UFUNCTION(BlueprintPure)
FVector GetCameraDirection();
void LockPlayer(const FPlayerLock lock);
void UnlockPlayer(const FPlayerLock lock);
void FlyMode(bool on);
/** Force interactable activators reset */
void ResetInteractions();
@ -103,8 +99,7 @@ protected:
UFUNCTION(BlueprintCallable, Category = Character)
void MoveCharacter(FVector2D value);
virtual void Jump() override;
UFUNCTION(BlueprintCallable, Category = Character)
void SwitchRun(bool run);
virtual void SwitchRun(bool run) override;
/** Sets camera pitch range */
UFUNCTION(BlueprintCallable, Category = Character)
@ -122,11 +117,6 @@ protected:
UFUNCTION(BlueprintCallable, Category = Character)
void ShowMenu();
UPROPERTY(EditAnywhere)
float moveSpeed = 200;
UPROPERTY(EditAnywhere)
float runSpeedMultiplier = 4;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
uint8 walkLocked = 0;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
@ -148,8 +138,6 @@ protected:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
float maxPitch = 65;
bool bIsMoving = false;
class AInteractable* lastInteractable = nullptr;
TArray<class UInteractableActivator*> interactableActivators;
UPROPERTY()
@ -163,7 +151,6 @@ private:
void TakeToInventory(class AActor* actor);
void DropItem(class AActor* actor);
FVector oldLocation;
FRotator rotationInput;
bool itemDropLocked = false;

View File

@ -141,11 +141,17 @@ void UQuickTimeEventManager::OnInput(const FKey& key, bool released)
void UQuickTimeEventManager::OnInputPressed(FKey key)
{
if(key == EKeys::W || key == EKeys::A || key == EKeys::S || key == EKeys::D)
return;
OnInput(key, false);
}
void UQuickTimeEventManager::OnInputReleased(FKey key)
{
if(key == EKeys::W || key == EKeys::A || key == EKeys::S || key == EKeys::D)
return;
OnInput(key, true);
}