FK v1.0.0 (build errors)
This commit is contained in:
@@ -15,6 +15,7 @@ void ABuildingBlock::TakeHit() {
|
||||
HitsRemaining -= 1;
|
||||
|
||||
if (HitsRemaining <= 0) {
|
||||
Ripple();
|
||||
DestroyBlock();
|
||||
}
|
||||
}
|
||||
@@ -54,10 +55,34 @@ TArray<ABuildingBlock*> ABuildingBlock::GetSameVariantNeighbours() {
|
||||
}
|
||||
|
||||
void ABuildingBlock::DestroyBlock_Implementation() {
|
||||
IsBeingDestroyed = true;
|
||||
OnBlockDestroyed.ExecuteIfBound();
|
||||
if (!IsBeingDestroyed) {
|
||||
IsBeingDestroyed = true;
|
||||
OnBlockDestroyed.ExecuteIfBound();
|
||||
}
|
||||
}
|
||||
|
||||
void ABuildingBlock::DestroyWithDelay_Implementation() {
|
||||
IsBeingDestroyed = true;
|
||||
OnBlockDestroyed.ExecuteIfBound();
|
||||
}
|
||||
|
||||
void ABuildingBlock::Ripple() {
|
||||
|
||||
TArray<TEnumAsByte<EObjectTypeQuery>> TraceObjectTypes;
|
||||
TraceObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECC_Visibility));
|
||||
|
||||
TArray<AActor*> IgnoreActors;
|
||||
IgnoreActors.Add(this);
|
||||
|
||||
TArray<AActor*> OutActors;
|
||||
|
||||
UKismetSystemLibrary::SphereOverlapActors(GetWorld(), this->GetActorLocation(), RippleRadius, TraceObjectTypes, ABuildingBlock::StaticClass(), IgnoreActors, OutActors);
|
||||
|
||||
for (AActor* OverlappedActor : OutActors) {
|
||||
ABuildingBlock* ThisBlock = Cast<ABuildingBlock>(OverlappedActor);
|
||||
if (ThisBlock && !ThisBlock->IsBeingDestroyed) {
|
||||
float ThisDistance = UKismetMathLibrary::Vector_Distance(this->GetActorLocation(), ThisBlock->GetActorLocation());
|
||||
ThisBlock->RippleEffects(ThisDistance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/StaticMeshComponent.h"
|
||||
#include "DrawDebugHelpers.h"
|
||||
#include "Kismet/KismetSystemLibrary.h"
|
||||
#include "Kismet/KismetMathLibrary.h"
|
||||
#include "BuildingBlock.generated.h"
|
||||
|
||||
DECLARE_DELEGATE(FBlockDestroyed);
|
||||
@@ -37,6 +39,9 @@ public:
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
int32 Variant = 0;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
float RippleRadius = 200.f;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
bool IsBeingDestroyed = false;
|
||||
|
||||
@@ -54,6 +59,12 @@ public:
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||
void DestroyWithDelay();
|
||||
|
||||
UFUNCTION()
|
||||
void Ripple();
|
||||
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void RippleEffects(float Distance);
|
||||
|
||||
// Get neighbouring Blocks with same color variant
|
||||
UFUNCTION(BlueprintCallable)
|
||||
TArray<ABuildingBlock*> GetSameVariantNeighbours();
|
||||
|
||||
Reference in New Issue
Block a user