Oakfolks Gold_1.14
Oakfolks coop game
Loading...
Searching...
No Matches
TriggerZone.h
1#pragma once
2
3#include "CoreMinimal.h"
4#include "Components/ActorComponent.h"
5#include "Components/SphereComponent.h"
6#include "TriggerZone.generated.h"
7
9
14USTRUCT(BlueprintType)
16{
17 GENERATED_BODY()
18
19 FTriggerData() {}
20
21 FTriggerData(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex,
22 bool bFromSweep, const FHitResult& SweepResult)
23 : OverlappedComp(OverlappedComp)
24 , OtherActor(OtherActor)
25 , OtherComp(OtherComp)
26 , OtherBodyIndex(OtherBodyIndex)
27 , bFromSweep(bFromSweep)
28 , SweepResult(SweepResult)
29 {
30
31 }
32
33 FTriggerData(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
34 : OverlappedComp(OverlappedComp)
35 , OtherActor(OtherActor)
36 , OtherComp(OtherComp)
37 , OtherBodyIndex(OtherBodyIndex)
38 {
39
40 }
41
42 UPROPERTY(BlueprintReadOnly)
43 UPrimitiveComponent* OverlappedComp = nullptr;
44
45 UPROPERTY(BlueprintReadOnly)
46 AActor* OtherActor = nullptr;
47
48 UPROPERTY(BlueprintReadOnly)
49 UPrimitiveComponent* OtherComp = nullptr;
50
51 UPROPERTY(BlueprintReadOnly)
52 int32 OtherBodyIndex = 0;
53
54 UPROPERTY(BlueprintReadOnly)
55 bool bFromSweep = false;
56
57 UPROPERTY(BlueprintReadOnly)
58 FHitResult SweepResult;
59};
60
62
66UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
67class BCR_API UTriggerZone : public USceneComponent
68{
69 GENERATED_BODY()
70
71public:
72
75 virtual void OnRegister() override;
76 virtual void BeginDestroy() override;
77
78 UFUNCTION(BlueprintCallable, BlueprintPure)
79 FORCEINLINE USphereComponent* GetInnerZoneComponent() { return InnerZoneComponent; }
80
81 UFUNCTION(BlueprintCallable, BlueprintPure)
82 FORCEINLINE USphereComponent* GetOuterZoneComponent() { return OuterZoneComponent; }
83
84#if WITH_EDITOR
85 virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
86#endif
87
88protected:
89
92 void SetupZone(USphereComponent* ZoneComponent, const float ZoneSize, const FColor ZoneColor) const;
93 void SetTriggerZoneSize(USphereComponent* ZoneComponent, const float NewZoneSize);
94
97 UFUNCTION()
98 void OnActorEnterInnerZone(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
99 UFUNCTION()
100 void OnActorExitInnerZone(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
101
103 UFUNCTION()
104 void OnActorEnterOuterZone(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
105 UFUNCTION()
106 void OnActorExitOuterZone(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
107
109 UPROPERTY()
110 USphereComponent* InnerZoneComponent;
111 UPROPERTY()
112 USphereComponent* OuterZoneComponent;
113
116 UPROPERTY(EditAnywhere , Category = "Zone Settings", meta = (ClampMin = "0.1"))
117 float InnerZoneSize;
118 UPROPERTY(EditAnywhere , Category = "Zone Settings", meta = (ClampMin = "0.1"))
119 float OuterZoneSize;
120
122 UPROPERTY()
123 TArray<AActor*> PlayersInInnerZone;
124 UPROPERTY()
125 TArray<AActor*> PlayersInOuterZone;
126};
Dual-zone trigger component for player detection.
Definition TriggerZone.h:68
Event data for trigger zone interactions.
Definition TriggerZone.h:16