Compare commits

...

2 Commits

Author SHA1 Message Date
baz 594ef5f158 Create Has Patrol Route Decorator 2024-02-09 21:16:09 +00:00
baz a8d9ca1783 Create Set Movement Speed Task 2024-02-09 21:15:55 +00:00
9 changed files with 143 additions and 0 deletions

BIN
Content/Enemy/Worker/PatrolMovementSpeed.uasset (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,14 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "../Decorators/BTDHasPatrolRoute.h"
#include "Nakatomi/EnemyAIController.h"
bool UBTDHasPatrolRoute::CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const
{
AEnemyAIController* enemyController = Cast<AEnemyAIController>(OwnerComp.GetAIOwner());
AEnemyCharacter* enemyPawn = Cast<AEnemyCharacter>(enemyController->GetPawn());
return enemyPawn->CurrentPatrolRoute ? true : false;
}

View File

@ -0,0 +1,19 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "BehaviorTree/BTDecorator.h"
#include "BTDHasPatrolRoute.generated.h"
/**
*
*/
UCLASS(Blueprintable)
class NAKATOMI_API UBTDHasPatrolRoute : public UBTDecorator
{
GENERATED_BODY()
public:
virtual bool CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const override;
};

View File

@ -0,0 +1,4 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "EPatrolMovementEnum.h"

View File

@ -0,0 +1,15 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
/**
*
*/
UENUM(BlueprintType)
enum class EPatrolMovementEnum : uint8
{
SLOWWALK UMETA(DisplayName = "Slow Walk"),
WALK UMETA(DisplayName = "Walk"),
};

View File

@ -19,6 +19,12 @@ void UNakatomiCMC::InitializeComponent()
NakatomiCharacterOwner = Cast<ANakatomiCharacter>(GetOwner());
}
void UNakatomiCMC::BeginPlay()
{
Super::BeginPlay();
DefaultMaxWalkSpeed = Walk_MaxWalkSpeed;
}
// Checks if we can combine the NewMove with the current move to save on data.
// If all the data in a saved move is identical, if true, we cam tell the server to run the existing move instead.
bool UNakatomiCMC::FSavedMove_Nakatomi::CanCombineWith(const FSavedMovePtr& NewMove, ACharacter* InCharacter,
@ -271,6 +277,16 @@ bool UNakatomiCMC::IsCustomMovementMode(ECustomMovementMove InCustomMovementMode
return MovementMode == MOVE_Custom && CustomMovementMode == InCustomMovementMode;
}
void UNakatomiCMC::SetMaxWalkSpeed(float newMaxSpeed)
{
Walk_MaxWalkSpeed = newMaxSpeed;
}
void UNakatomiCMC::SetMaxWalkSpeedToDefault()
{
Walk_MaxWalkSpeed = DefaultMaxWalkSpeed;
}
void UNakatomiCMC::EnterSlide()
{
Safe_bWantsToSlide = true;

View File

@ -108,6 +108,8 @@ class NAKATOMI_API UNakatomiCMC : public UCharacterMovementComponent
UPROPERTY(Transient)
ANakatomiCharacter* NakatomiCharacterOwner;
float DefaultMaxWalkSpeed;
public:
UPROPERTY(BlueprintAssignable)
FDashStartDelegate DashStartDelegate;
@ -118,6 +120,8 @@ public:
protected:
virtual void InitializeComponent() override;
virtual void BeginPlay() override;
virtual FNetworkPredictionData_Client* GetPredictionData_Client() const override;
protected:
@ -167,6 +171,12 @@ public:
UFUNCTION()
bool IsCustomMovementMode(ECustomMovementMove InCustomMovementMode) const;
UFUNCTION()
void SetMaxWalkSpeed(float newMaxSpeed);
UFUNCTION()
void SetMaxWalkSpeedToDefault();
private:
void EnterSlide();
void ExitSlide();

View File

@ -0,0 +1,30 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "../Tasks/BTTSetMovementSpeed.h"
#include "Nakatomi/EnemyAIController.h"
#include "Nakatomi/NakatomiCMC.h"
enum class EPatrolMovementEnum : uint8;
EBTNodeResult::Type UBTTSetMovementSpeed::ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory)
{
AEnemyAIController* enemyController = Cast<AEnemyAIController>(owner.GetAIOwner());
AEnemyCharacter* enemyPawn = Cast<AEnemyCharacter>(enemyController->GetPawn());
switch (MaxWalkSpeedKey)
{
case EPatrolMovementEnum::SLOWWALK:
enemyPawn->GetCharacterMovementComponent()->SetMaxWalkSpeed(slowWalkSpeed);
break;
case EPatrolMovementEnum::WALK:
enemyPawn->GetCharacterMovementComponent()->SetMaxWalkSpeed(walkSpeed);
break;
default:
enemyPawn->GetCharacterMovementComponent()->SetMaxWalkSpeedToDefault();
break;
}
return EBTNodeResult::Succeeded;
}

View File

@ -0,0 +1,32 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "BehaviorTree/BTTaskNode.h"
#include "Nakatomi/EPatrolMovementEnum.h"
#include "BTTSetMovementSpeed.generated.h"
/**
*
*/
UCLASS()
class NAKATOMI_API UBTTSetMovementSpeed : public UBTTaskNode
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, Category = "Options",
Meta = (AllowPrivateAccess = "true", DisplayName = "Max Walk Speed Key"))
EPatrolMovementEnum MaxWalkSpeedKey;
private:
float slowWalkSpeed = 250.0f;
float walkSpeed = 500.0f;
public:
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory) override;
};