Space Plunder
Loading...
Searching...
No Matches
InteractableBox.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 "InteractableBox.generated.h"
8
9
10USTRUCT()
12{
13 GENERATED_BODY()
14
15 UPROPERTY()
16 AActor* Caller = nullptr;
17 // int32 SelectedInteraction = -1;
19 FVector Impulse = FVector(10);
21 {
22
23 }
24
26 {
27 Caller = Actor;
28 SelectedInteraction = Interaction;
29 }
30 FBoxReplicationData(AActor* Actor, const EInteractionType Interaction, const FVector& ImpulseForce)
31 {
32 Caller = Actor;
33 SelectedInteraction = Interaction;
34 Impulse = ImpulseForce;
35 }
36
37};
38
39
40
41UCLASS()
42class INTERACTION_API AInteractableBox : public AInteractableActor
43{
44 GENERATED_BODY()
45
46public:
47 explicit AInteractableBox();
48
49 UFUNCTION(BlueprintImplementableEvent, Category="Box")
50 void OnBoxOpened();
51
52 UFUNCTION(Server, Reliable, Category="Box")
53 void Server_CalculateRandomNumber();
54 UFUNCTION(Server, Reliable, Category="Box")
55 void Server_OpenBox(const FVector& Force);
56#if WITH_EDITOR
57 UFUNCTION(CallInEditor, Category="Box|Editor")
58 void SetNewMesh();
59#endif
60
61protected:
62 virtual void BeginPlay() override;
63
64 virtual void ReceiveOnInteract(AActor* Caller, const EInteractionType InteractionType) override;
65 virtual void ReceiveToggleSwitch(AActor* Caller, const bool bOn) override;
66 // virtual void OnInteract(AActor* Caller, const int32 SelectedInteraction) override;
67 virtual void ReceiveStartFocus(AActor* Caller) override;
68 virtual void ReceiveEndFocus(AActor* Caller) override;
69
70 // virtual void StartFocus(AActor* Caller) override;
71 // virtual void EndFocus(AActor* Caller) override;
72
73 UFUNCTION(BlueprintCallable, Category="Box")
74 void SetMesh();
75 UFUNCTION(BlueprintCallable, Category="Box")
76 void OpenBox(const FVector& Force);
77 UFUNCTION(BlueprintCallable, Category="Box")
78 bool IsValid() const;
79 UFUNCTION(BlueprintCallable, Category="Box")
80 FVector CalculateImpulse(const AActor* Caller) const;
81
82 UFUNCTION()
83 void OnMeshTypeReplicated();
84 UFUNCTION()
85 void OnOpenedReplicated();
86
87 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Box|Mesh")
88 UStaticMeshComponent* BaseMeshComponent;
89 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Box|Mesh")
90 UStaticMeshComponent* LidMeshComponent;
91 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Box|Mesh")
92 class USphereComponent* SphereComponent;
93
94 UPROPERTY(ReplicatedUsing=OnOpenedReplicated, VisibleAnywhere, BlueprintReadOnly, Category="Box|State")
95 bool bOpened = false;
96
97 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Box|Model")
98 bool bUseBoxData = false;
99 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Box|Model")
100 bool bUseRandom = false;
101 UPROPERTY(ReplicatedUsing=OnMeshTypeReplicated, EditAnywhere, BlueprintReadWrite, Category="Box|Model")
102 int32 MeshType = 0;
103 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Box|Model")
104 TArray<UStaticMesh*> BaseMeshes;
105 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Box|Model")
106 TArray<UStaticMesh*> LidMeshes;
107 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Box|Contents")
108 int32 Credits = 0;
109 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Box|Contents")
110 int32 XP = 0;
112 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Box|Effects")
113 float DirectionalForce = 5200.0f;
115 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Box|Effects")
116 float UpForce = 12500.0f;
117 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Box|Effects")
118 class USoundBase* OpenSound;
119
120 UFUNCTION()
121 void OnBoxDataReplicated();
122 UPROPERTY(ReplicatedUsing=OnBoxDataReplicated)
123 FBoxReplicationData BoxReplicationData;
124
125private:
126
127 void DestroyLid();
128 // UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Box|Effects")
129 bool bLidDestroyed = false;
131 UPROPERTY(EditAnywhere, Category="Box|Optimization")
132 float LidDestroyTime = 20.0f;
133 FTimerHandle LidDestroyTimerHandle;
134
135};
EInteractionType
Definition BaseData.h:149
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
Definition InteractableActor.h:15
Definition InteractableBox.h:43
Definition Interaction.Build.cs:6
Definition InteractableBox.h:12
FBoxReplicationData(AActor *Actor, const EInteractionType Interaction, const FVector &ImpulseForce)
Definition InteractableBox.h:30
FBoxReplicationData(AActor *Actor, const EInteractionType Interaction)
Definition InteractableBox.h:25