Space Plunder
Loading...
Searching...
No Matches
OpenableDoorActor.h
Go to the documentation of this file.
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CoreMinimal.h"
7#include "OpenableDoorActor.generated.h"
8
9
10DECLARE_LOG_CATEGORY_EXTERN(LogDoors, Display, All);
11
12DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnDoorOpened, const int32, Index, const bool, bOpened);
13
14//@TODO Add in Proper Moving of the Door, using EasingBP from BaseHelpers
15UCLASS()
16class INTERACTION_API AOpenableDoorActor : public AInteractableActor
17{
18 GENERATED_BODY()
19
20public:
22
23 UPROPERTY(BlueprintAssignable, Category = "Door")
24 FOnDoorOpened OnDoorOpenedDelegate;
25
26 UFUNCTION(BlueprintCallable, Category="Interactable|Door")
27 virtual void OpenDoor(const bool bOpen);
28 UFUNCTION(BlueprintCallable, Category="Interactable|Door")
29 virtual void DisableDoor(const bool bDisable = true);
30
31 UFUNCTION(BlueprintCallable, Category="Interactable|Door")
32 virtual void SetStatusMaterial(UPrimitiveComponent* StatusComponent);
33
34 UFUNCTION(BlueprintPure, BlueprintCallable, Category="Interactable|Door")
35 bool GetIsDoorOpen() const {return bDoorOpen;};
36 UFUNCTION(BlueprintPure, BlueprintCallable, Category="Interactable|Door")
37 bool GetIsDoorMoving() const{return bDoorMoving;};
38
39
40 UFUNCTION(BlueprintImplementableEvent, Category="Interactable|Door")
41 void OnDoorOpened();
42 UFUNCTION(BlueprintImplementableEvent, Category="Interactable|Door")
43 void OnDoorClosed();
44 UFUNCTION(BlueprintImplementableEvent, Category="Interactable|Door")
45 void OnDoorOpenedComplete();
46 UFUNCTION(BlueprintImplementableEvent, Category="Interactable|Door")
47 void OnDoorClosedComplete();
48 UFUNCTION(BlueprintImplementableEvent, Category="Interactable|Door")
49 void OnDoorLocked(const bool bValue);
50
51 UFUNCTION(BlueprintCallable, Category="Interactable|Door")
52 void SetDoorLocked(const bool bValue);
53 UFUNCTION(BlueprintCallable, Category="Interactable|Door")
54 bool GetIsDoorLocked() const{return bLocked;};
55
56
57 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Door")
58 int32 Index = 0;
59protected:
60
61 virtual void BeginPlay() override;
62 virtual void OnConstruction(const FTransform& Transform) override;
63 virtual void ReceiveOnInteract(AActor* Caller, const EInteractionType InteractionType) override;
64 virtual void ReceiveToggleSwitch(AActor* Caller, const bool bOn) override;
65 // virtual void OnInteract(AActor* Caller, const int32 SelectedInteraction) override;
66 // virtual void ToggleSwitch(AActor* Caller, const bool bOn) override;
67
68 //- Used for when doors should start open //
69 virtual void OpenDoorInstantly();
70 virtual void OpenDoorInstantly(const bool bOpen);
71
72
73 UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Door|Components")
74 USceneComponent* RootSceneComponent;
75 UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Door|Components")
76 UStaticMeshComponent* MainDoorComponent;
77 // UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Door|Components")
78 // UStaticMeshComponent* DoorFrameComponent;
79 UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Door|Components")
80 class UBoxComponent* BoxComponent;
81
82
83
84 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Door|General")
85 bool bHasSwitch = false;
86 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Door|General")
87 bool bIsAutomatic = true;
88 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Door|General")
89 bool bStartOpen = false;
90 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Door|Material")
91 UMaterialInstance* StatusMaterial = nullptr;
92 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Door|Material")
93 UMaterialInstanceDynamic* DynamicMaterial = nullptr;
94 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Door|Material")
95 FLinearColor LockedColor = FLinearColor::Red;
96 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Door|Material")
97 FLinearColor UnlockedColor = FLinearColor::Green;
98 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Door|Material")
99 FLinearColor BrokenColor = FLinearColor::Yellow;
100 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Door|Material")
101 FName MaterialParamName = "Color";
102
103 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Door|Animation")
104 bool bEaseIn = false;
105 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Door|Animation")
106 bool bEaseOut = false;
107
108 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Door|Animation")
109 float TimeToOpen = 1.0f;
110
111 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Door|Sound")
112 USoundBase* DoorOpenSound = nullptr;
113 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Door|Sound")
114 bool bPlayingSound = false;
115
116 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Door|Lock")
117 bool bLockable = false;
118 UPROPERTY(ReplicatedUsing=OnLockedReplicated, EditAnywhere, BlueprintReadWrite, Category="Door|Lock", meta=(EditCondition="bLockable"))
119 bool bLocked = false;
120
121
122 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Door|Location")
123 FVector TargetLocation;
124 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Door|Location")
125 FRotator TargetRotation;
126
127
128 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Door|State")
129 bool bDoorBroken = false;
130 UPROPERTY(ReplicatedUsing=OnDoorOpenReplicated, VisibleAnywhere, BlueprintReadOnly, Category="Door|State")
131 bool bDoorOpen = false;
132 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Door|State")
133 bool bDoorMoving = false;
134 UFUNCTION()
135 void OnDoorOpenReplicated();
136 UFUNCTION()
137 void OnLockedReplicated();
138
139private:
140 UFUNCTION()
141 void OnBoxBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& HitResult);
142 UFUNCTION()
143 void OnBoxEndOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, int32 OtherBodyIndex);
144
145 UFUNCTION()
146 void OnMainDoorOpened();
147 UFUNCTION()
148 void OnMainDoorClosed();
149 void OpenMainDoor();
150 void CloseMainDoor();
151
152 void MoveDoor(const bool bOpen);
153
154 FLinearColor GetStatusColor() const;
155 void UpdateStatusMaterial() const;
156
157 UPROPERTY(Replicated, VisibleAnywhere, Category="Door|Location")
158 FVector MainDoorStartLocation;
159 UPROPERTY(Replicated, VisibleAnywhere, Category="Door|Location")
160 FRotator MainDoorStartRotation;
161
162
163 FTimerHandle RetryMainDoorOpen;
164 FTimerHandle RetryMainDoorClose;
165
166
167};
168
EInteractionType
Definition BaseData.h:149
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
DECLARE_LOG_CATEGORY_EXTERN(LogDoors, Display, All)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnDoorOpened, const int32, Index, const bool, bOpened)
Definition InteractableActor.h:15
Definition OpenableDoorActor.h:17