Add Restricted Zone Actor for Restricted Access Areas
This commit is contained in:
parent
52229f8975
commit
fcbd125dbd
BIN
EndlessVendetta/Content/AI/BP_RestrictedZone.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/AI/BP_RestrictedZone.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/AI/Enemy/Basic/BB_BasicEnemy.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/AI/Enemy/Basic/BB_BasicEnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/AI/Enemy/Basic/BT_BasicEnemy.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/AI/Enemy/Basic/BT_BasicEnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/__ExternalActors__/Levels/AITest/E/1M/A5VMSIPC1VU25T4W5AQYEC.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/__ExternalActors__/Levels/AITest/E/1M/A5VMSIPC1VU25T4W5AQYEC.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,47 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "AI_RestrictedZone.h"
|
||||||
|
|
||||||
|
#include "EndlessVendetta/EndlessVendettaCharacter.h"
|
||||||
|
|
||||||
|
|
||||||
|
// Sets default values
|
||||||
|
AAI_RestrictedZone::AAI_RestrictedZone()
|
||||||
|
{
|
||||||
|
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||||
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
|
BoxCollision = CreateDefaultSubobject<UBoxComponent>(TEXT("BoxCollision"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the game starts or when spawned
|
||||||
|
void AAI_RestrictedZone::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
BoxCollision->OnComponentBeginOverlap.AddDynamic(this, &AAI_RestrictedZone::OnBoxOverlapBegin);
|
||||||
|
BoxCollision->OnComponentEndOverlap.AddDynamic(this, &AAI_RestrictedZone::OnBoxOverlapEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AAI_RestrictedZone::OnBoxOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
||||||
|
{
|
||||||
|
if (Cast<AEndlessVendettaCharacter>(OtherActor))
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("Player entered restricted bounds"));
|
||||||
|
Cast<AEndlessVendettaCharacter>(OtherActor)->IncrementRestrictedBoundsCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AAI_RestrictedZone::OnBoxOverlapEnd(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
|
||||||
|
{
|
||||||
|
if (Cast<AEndlessVendettaCharacter>(OtherActor))
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("Player left restricted bounds"));
|
||||||
|
Cast<AEndlessVendettaCharacter>(OtherActor)->DecrementRestrictedBoundsCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called every frame
|
||||||
|
void AAI_RestrictedZone::Tick(float DeltaTime)
|
||||||
|
{
|
||||||
|
Super::Tick(DeltaTime);
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Components/BoxComponent.h"
|
||||||
|
#include "GameFramework/Actor.h"
|
||||||
|
#include "AI_RestrictedZone.generated.h"
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class ENDLESSVENDETTA_API AAI_RestrictedZone : public AActor
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Sets default values for this actor's properties
|
||||||
|
AAI_RestrictedZone();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Called when the game starts or when spawned
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
UBoxComponent* BoxCollision;
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void OnBoxOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
|
||||||
|
UFUNCTION()
|
||||||
|
void OnBoxOverlapEnd(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Called every frame
|
||||||
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
};
|
@ -0,0 +1,27 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "AI_RestrictedZoneModifier.h"
|
||||||
|
|
||||||
|
|
||||||
|
// Sets default values
|
||||||
|
AAI_RestrictedZoneModifier::AAI_RestrictedZoneModifier()
|
||||||
|
{
|
||||||
|
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||||
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
|
BoxCollision = CreateDefaultSubobject<UBoxComponent>(TEXT("BoxCollision"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the game starts or when spawned
|
||||||
|
void AAI_RestrictedZoneModifier::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called every frame
|
||||||
|
void AAI_RestrictedZoneModifier::Tick(float DeltaTime)
|
||||||
|
{
|
||||||
|
Super::Tick(DeltaTime);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Components/BoxComponent.h"
|
||||||
|
#include "GameFramework/Actor.h"
|
||||||
|
#include "AI_RestrictedZoneModifier.generated.h"
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class ENDLESSVENDETTA_API AAI_RestrictedZoneModifier : public AActor
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Sets default values for this actor's properties
|
||||||
|
AAI_RestrictedZoneModifier();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Called when the game starts or when spawned
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
UBoxComponent* BoxCollision;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Called every frame
|
||||||
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
};
|
@ -22,6 +22,11 @@ void AEnemyCharacter::BeginPlay()
|
|||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
CharacterName = "Enemy";
|
CharacterName = "Enemy";
|
||||||
|
|
||||||
|
if (AEndlessVendettaCharacter* PlayerCharacter = Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn()))
|
||||||
|
{
|
||||||
|
PlayerCharacter->RestrictedAreaStatusChanged.AddUniqueDynamic(this, &AEnemyCharacter::SetIfPlayerIsInRestrictedArea);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AEnemyCharacter::OnDeath()
|
void AEnemyCharacter::OnDeath()
|
||||||
@ -51,11 +56,12 @@ void AEnemyCharacter::SetAlertLevel(const int NewAlertLevel) const
|
|||||||
Cast<AAIController>(GetController())->GetBlackboardComponent()->SetValueAsInt("AlertLevel", NewAlertLevel);
|
Cast<AAIController>(GetController())->GetBlackboardComponent()->SetValueAsInt("AlertLevel", NewAlertLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AEnemyCharacter::SetLocalAlertLevel(int NewAlertLevel) const
|
void AEnemyCharacter::SetLocalAlertLevel(int NewAlertLevel)
|
||||||
{
|
{
|
||||||
if (!IsValid(DelegatedControlHub)) return;
|
|
||||||
if (!IsValid(GetController())) return;
|
if (!IsValid(GetController())) return;
|
||||||
Cast<AAIController>(GetController())->GetBlackboardComponent()->SetValueAsBool("IsInvestigating", true);
|
Cast<AAIController>(GetController())->GetBlackboardComponent()->SetValueAsBool("IsInvestigating", true);
|
||||||
|
if (NewAlertLevel >= 2) SetHostilityLevel(EHostilityLevel::Hostile);
|
||||||
|
if (!IsValid(DelegatedControlHub)) return;
|
||||||
DelegatedControlHub->SetAlertLevel(NewAlertLevel);
|
DelegatedControlHub->SetAlertLevel(NewAlertLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,3 +105,9 @@ void AEnemyCharacter::HuntPlayer(FVector PlayerLastKnownLocation)
|
|||||||
EquipWeapon();
|
EquipWeapon();
|
||||||
Cast<AAIController>(GetController())->GetBlackboardComponent()->SetValueAsVector("LastKnownLocation", PlayerLastKnownLocation);
|
Cast<AAIController>(GetController())->GetBlackboardComponent()->SetValueAsVector("LastKnownLocation", PlayerLastKnownLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AEnemyCharacter::SetIfPlayerIsInRestrictedArea(const bool bIsInRestrictedArea)
|
||||||
|
{
|
||||||
|
if (!IsValid(GetController())) return;
|
||||||
|
Cast<AAIController>(GetController())->GetBlackboardComponent()->SetValueAsBool("PlayerIsInRestrictedBounds", bIsInRestrictedArea);
|
||||||
|
}
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
virtual void Tick(float DeltaTime) override;
|
virtual void Tick(float DeltaTime) override;
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void SubscribeToGroupAIEvents(class AAIControlHub* ControlHub);
|
void SubscribeToGroupAIEvents(class AAIControlHub* ControlHub);
|
||||||
void SetLocalAlertLevel(int NewAlertLevel) const;
|
void SetLocalAlertLevel(int NewAlertLevel);
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void SetHostilityLevel(EHostilityLevel NewHostilityLevel);
|
void SetHostilityLevel(EHostilityLevel NewHostilityLevel);
|
||||||
virtual float TakeDamage(float DamageAmount, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) override;
|
virtual float TakeDamage(float DamageAmount, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) override;
|
||||||
@ -67,4 +67,6 @@ private:
|
|||||||
FDelegateHandle HuntPlayerDelegateHandle;
|
FDelegateHandle HuntPlayerDelegateHandle;
|
||||||
void SetAlertLevel(int NewAlertLevel) const;
|
void SetAlertLevel(int NewAlertLevel) const;
|
||||||
void HuntPlayer(FVector PlayerLastKnowLocation);
|
void HuntPlayer(FVector PlayerLastKnowLocation);
|
||||||
|
UFUNCTION()
|
||||||
|
void SetIfPlayerIsInRestrictedArea(bool bIsInRestrictedArea);
|
||||||
};
|
};
|
||||||
|
@ -14,7 +14,7 @@ EBTNodeResult::Type UBTTask_SetLocalAlertLevel::ExecuteTask(UBehaviorTreeCompone
|
|||||||
{
|
{
|
||||||
if (const AAI_EnemyController* const AIEnemyController = Cast<AAI_EnemyController>(OwnerComp.GetAIOwner()))
|
if (const AAI_EnemyController* const AIEnemyController = Cast<AAI_EnemyController>(OwnerComp.GetAIOwner()))
|
||||||
{
|
{
|
||||||
if (const AEnemyCharacter* const EnemyCharacter = Cast<AEnemyCharacter>(AIEnemyController->GetPawn()))
|
if (AEnemyCharacter* const EnemyCharacter = Cast<AEnemyCharacter>(AIEnemyController->GetPawn()))
|
||||||
{
|
{
|
||||||
EnemyCharacter->SetLocalAlertLevel(AlertLevel);
|
EnemyCharacter->SetLocalAlertLevel(AlertLevel);
|
||||||
|
|
||||||
|
@ -47,6 +47,26 @@ AEndlessVendettaCharacter::AEndlessVendettaCharacter()
|
|||||||
Mesh1P->SetRelativeLocation(FVector(-30.f, 0.f, -150.f));
|
Mesh1P->SetRelativeLocation(FVector(-30.f, 0.f, -150.f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AEndlessVendettaCharacter::IncrementRestrictedBoundsCount()
|
||||||
|
{
|
||||||
|
RestrictedBoundsCount++;
|
||||||
|
if (RestrictedBoundsCount > 0)
|
||||||
|
{
|
||||||
|
bIsInRestrictedArea = true;
|
||||||
|
RestrictedAreaStatusChanged.Broadcast(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AEndlessVendettaCharacter::DecrementRestrictedBoundsCount()
|
||||||
|
{
|
||||||
|
RestrictedBoundsCount--;
|
||||||
|
if (RestrictedBoundsCount <= 0)
|
||||||
|
{
|
||||||
|
bIsInRestrictedArea = false;
|
||||||
|
RestrictedAreaStatusChanged.Broadcast(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AEndlessVendettaCharacter::BeginPlay()
|
void AEndlessVendettaCharacter::BeginPlay()
|
||||||
{
|
{
|
||||||
// Call the base class
|
// Call the base class
|
||||||
|
@ -127,7 +127,17 @@ public:
|
|||||||
void StopSecondaryWeaponADS();
|
void StopSecondaryWeaponADS();
|
||||||
UPROPERTY(BlueprintReadWrite)
|
UPROPERTY(BlueprintReadWrite)
|
||||||
bool bIsInDialogue = false;
|
bool bIsInDialogue = false;
|
||||||
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Stats")
|
||||||
|
bool bIsInRestrictedArea = false;
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void IncrementRestrictedBoundsCount();
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void DecrementRestrictedBoundsCount();
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FRestrictedAreaStatusChangedSignature, bool, bIsInRestrictedArea);
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintAssignable, Category = "Restricted Area")
|
||||||
|
FRestrictedAreaStatusChangedSignature RestrictedAreaStatusChanged;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
@ -146,6 +156,9 @@ protected:
|
|||||||
UFUNCTION(BlueprintImplementableEvent)
|
UFUNCTION(BlueprintImplementableEvent)
|
||||||
void PlayFadeScreen();
|
void PlayFadeScreen();
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
int RestrictedBoundsCount = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AGadgetManager* GadgetManager;
|
AGadgetManager* GadgetManager;
|
||||||
bool bIsReloading = false;
|
bool bIsReloading = false;
|
||||||
@ -234,6 +247,7 @@ protected:
|
|||||||
void StartedHoldingInteract(float Duration);
|
void StartedHoldingInteract(float Duration);
|
||||||
UFUNCTION(BlueprintImplementableEvent)
|
UFUNCTION(BlueprintImplementableEvent)
|
||||||
void StoppedHoldingInteract();
|
void StoppedHoldingInteract();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Used by vault it plugin to run vaulting animations
|
// Used by vault it plugin to run vaulting animations
|
||||||
USkeletalMeshComponent* FP_SkeletalMesh = nullptr;
|
USkeletalMeshComponent* FP_SkeletalMesh = nullptr;
|
||||||
@ -282,9 +296,11 @@ private:
|
|||||||
UPROPERTY(EditDefaultsOnly, Category = "Hover Bike")
|
UPROPERTY(EditDefaultsOnly, Category = "Hover Bike")
|
||||||
TSubclassOf<ASpaceShip> SpaceShipClass;
|
TSubclassOf<ASpaceShip> SpaceShipClass;
|
||||||
ASpaceShip* SpaceShip;
|
ASpaceShip* SpaceShip;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool PlayerOnShip = false;
|
bool PlayerOnShip = false;
|
||||||
void HoldInteract();
|
void HoldInteract();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void ExitShip(FTransform ExitLoc);
|
void ExitShip(FTransform ExitLoc);
|
||||||
void EnterShip(FTransform TakeoffLoc);
|
void EnterShip(FTransform TakeoffLoc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user