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();
|
||||
CharacterName = "Enemy";
|
||||
|
||||
if (AEndlessVendettaCharacter* PlayerCharacter = Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn()))
|
||||
{
|
||||
PlayerCharacter->RestrictedAreaStatusChanged.AddUniqueDynamic(this, &AEnemyCharacter::SetIfPlayerIsInRestrictedArea);
|
||||
}
|
||||
}
|
||||
|
||||
void AEnemyCharacter::OnDeath()
|
||||
@ -51,11 +56,12 @@ void AEnemyCharacter::SetAlertLevel(const int NewAlertLevel) const
|
||||
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;
|
||||
Cast<AAIController>(GetController())->GetBlackboardComponent()->SetValueAsBool("IsInvestigating", true);
|
||||
if (NewAlertLevel >= 2) SetHostilityLevel(EHostilityLevel::Hostile);
|
||||
if (!IsValid(DelegatedControlHub)) return;
|
||||
DelegatedControlHub->SetAlertLevel(NewAlertLevel);
|
||||
}
|
||||
|
||||
@ -99,3 +105,9 @@ void AEnemyCharacter::HuntPlayer(FVector PlayerLastKnownLocation)
|
||||
EquipWeapon();
|
||||
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;
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SubscribeToGroupAIEvents(class AAIControlHub* ControlHub);
|
||||
void SetLocalAlertLevel(int NewAlertLevel) const;
|
||||
void SetLocalAlertLevel(int NewAlertLevel);
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetHostilityLevel(EHostilityLevel NewHostilityLevel);
|
||||
virtual float TakeDamage(float DamageAmount, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) override;
|
||||
@ -67,4 +67,6 @@ private:
|
||||
FDelegateHandle HuntPlayerDelegateHandle;
|
||||
void SetAlertLevel(int NewAlertLevel) const;
|
||||
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 AEnemyCharacter* const EnemyCharacter = Cast<AEnemyCharacter>(AIEnemyController->GetPawn()))
|
||||
if (AEnemyCharacter* const EnemyCharacter = Cast<AEnemyCharacter>(AIEnemyController->GetPawn()))
|
||||
{
|
||||
EnemyCharacter->SetLocalAlertLevel(AlertLevel);
|
||||
|
||||
|
@ -47,13 +47,33 @@ AEndlessVendettaCharacter::AEndlessVendettaCharacter()
|
||||
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()
|
||||
{
|
||||
// Call the base class
|
||||
Super::BeginPlay();
|
||||
bIsCurrentlyHoldingWeapon = false;
|
||||
UEVGameInstance* GI = Cast<UEVGameInstance>(GetWorld()->GetGameInstance());
|
||||
if (IsValid(GI->MainSaveGameInstanceRef))
|
||||
if (IsValid(GI->MainSaveGameInstanceRef))
|
||||
{
|
||||
PrimaryWeaponClass = GI->MainSaveGameInstanceRef->PrimaryWeaponClassSave;
|
||||
SecondaryWeaponClass = GI->MainSaveGameInstanceRef->SecondaryWeaponClassSave;
|
||||
@ -378,7 +398,7 @@ void AEndlessVendettaCharacter::EquipPrimary()
|
||||
Cast<AEndlessVendettaGameMode>(GetWorld()->GetAuthGameMode())->SendEvent("DeEquip", "Pri");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (IsValid(SecondaryWeapon)) EquipSecondary();
|
||||
|
||||
if (GadgetManager->IsValidReconGadget() && GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;
|
||||
@ -477,7 +497,7 @@ void AEndlessVendettaCharacter::WeaponSwitcher(AActor* Outhit)
|
||||
PrimaryWeaponClass = Outhit->GetClass();
|
||||
if (IsValid(PrimaryWeapon))
|
||||
{
|
||||
if(bIsCurrentlyHoldingWeapon)
|
||||
if (bIsCurrentlyHoldingWeapon)
|
||||
{
|
||||
PrimaryWeaponActor = GetWorld()->SpawnActor<AActor>(PrimaryWeaponClass, spawnParams);
|
||||
UE_LOG(LogTemp, Warning, TEXT("PRIMARY WEAPON SPAWNING IN"));
|
||||
@ -486,7 +506,7 @@ void AEndlessVendettaCharacter::WeaponSwitcher(AActor* Outhit)
|
||||
}
|
||||
bIsWeaponPickedUp = true;
|
||||
UEVGameInstance* GI = Cast<UEVGameInstance>(GetGameInstance());
|
||||
if (IsValid(GI->MainSaveGameInstanceRef))
|
||||
if (IsValid(GI->MainSaveGameInstanceRef))
|
||||
{
|
||||
GI->MainSaveGameInstanceRef->PrimaryWeaponClassSave = Outhit->GetClass();
|
||||
UGameplayStatics::SaveGameToSlot(GI->MainSaveGameInstanceRef, "MainSave", 0);
|
||||
@ -515,7 +535,7 @@ void AEndlessVendettaCharacter::WeaponSwitcher(AActor* Outhit)
|
||||
{
|
||||
if (IsValid(SecondaryWeapon))
|
||||
{
|
||||
if(bIsCurrentlyHoldingWeapon)
|
||||
if (bIsCurrentlyHoldingWeapon)
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Blue, TEXT("bIsCurrentlyHoldingSecondaryCalled, trying to spawn secondary weapon actor"));
|
||||
SecondaryWeaponActor = GetWorld()->SpawnActor<AActor>(SecondaryWeaponClass, spawnParams);
|
||||
@ -525,14 +545,14 @@ void AEndlessVendettaCharacter::WeaponSwitcher(AActor* Outhit)
|
||||
}
|
||||
bIsWeaponPickedUp = true;
|
||||
SecondaryWeaponClass = Outhit->GetClass();
|
||||
|
||||
|
||||
UEVGameInstance* GI = Cast<UEVGameInstance>(GetGameInstance());
|
||||
if (IsValid(GI->MainSaveGameInstanceRef))
|
||||
if (IsValid(GI->MainSaveGameInstanceRef))
|
||||
{
|
||||
GI->MainSaveGameInstanceRef->SecondaryWeaponClassSave = Outhit->GetClass();
|
||||
UGameplayStatics::SaveGameToSlot(GI->MainSaveGameInstanceRef, "MainSave", 0);
|
||||
}
|
||||
|
||||
|
||||
Outhit->Destroy();
|
||||
EquipSecondary();
|
||||
}
|
||||
|
@ -127,14 +127,24 @@ public:
|
||||
void StopSecondaryWeaponADS();
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
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:
|
||||
virtual void BeginPlay() override;
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
bool InPauseMenu = false;
|
||||
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Gadget")
|
||||
TSubclassOf<AGadgetManager> GadgetManagerClass;
|
||||
|
||||
@ -146,6 +156,9 @@ protected:
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void PlayFadeScreen();
|
||||
|
||||
UPROPERTY()
|
||||
int RestrictedBoundsCount = 0;
|
||||
|
||||
public:
|
||||
AGadgetManager* GadgetManager;
|
||||
bool bIsReloading = false;
|
||||
@ -234,6 +247,7 @@ protected:
|
||||
void StartedHoldingInteract(float Duration);
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void StoppedHoldingInteract();
|
||||
|
||||
protected:
|
||||
// Used by vault it plugin to run vaulting animations
|
||||
USkeletalMeshComponent* FP_SkeletalMesh = nullptr;
|
||||
@ -282,9 +296,11 @@ private:
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Hover Bike")
|
||||
TSubclassOf<ASpaceShip> SpaceShipClass;
|
||||
ASpaceShip* SpaceShip;
|
||||
|
||||
protected:
|
||||
bool PlayerOnShip = false;
|
||||
void HoldInteract();
|
||||
|
||||
public:
|
||||
void ExitShip(FTransform ExitLoc);
|
||||
void EnterShip(FTransform TakeoffLoc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user