Space Plunder
Loading...
Searching...
No Matches
GravityComponent.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"
6#include "GravityData.h"
7#include "Components/ActorComponent.h"
9#include "GravityComponent.generated.h"
10
11
12class UCapsuleComponent;
13class USphereComponent;
14class UBoxComponent;
15enum class EGravityDirectionMode : uint8;
16
17UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent))
18class SPACEADVENTURE_API UGravityComponent : public UActorComponent
19{
20 GENERATED_BODY()
21
22public:
23 UGravityComponent();
24
25 UFUNCTION(BlueprintCallable, Category="Gravity")
26 virtual void AddShapeComponent(UShapeComponent* Component);
28 UFUNCTION(BlueprintCallable, Category="Gravity")
29 virtual void SetShapeComponents(TArray<UShapeComponent*> Components);
30
31
32 UFUNCTION(BlueprintCallable, Category="Gravity")
33 virtual void SetSplineComponent(class USplineComponent* Component);
34
35 UFUNCTION(BlueprintCallable, Category="Gravity")
36 virtual void SetGravityActor(class AActor* Actor);
37
38 virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
39
40
41
42 UFUNCTION(BlueprintCallable, Category="Gravity")
43 void CheckForOverlappingActors();
44
45protected:
46 virtual void BeginPlay() override;
47
48
51 UFUNCTION()
52 virtual void ActorEnteredVolume(AActor* Other);
53 UFUNCTION(BlueprintImplementableEvent, Category="Gravity")
54 void OnActorEnteredVolume(AActor* Other);
55
58 UFUNCTION()
59 virtual void ActorLeavingVolume(AActor* Other);
60 UFUNCTION(BlueprintImplementableEvent, Category="Gravity")
61 void OnActorLeavingVolume(AActor* Other);
62
63 UFUNCTION()
64 void CheckShapeForOverlappingActors(const UShapeComponent* Component);
65 UFUNCTION()
66 void CheckBoxForOverlappingActors(const UBoxComponent* Component);
67 UFUNCTION()
68 void CheckSphereForOverlappingActors(const USphereComponent* Component);
69 UFUNCTION()
70 void CheckCapsuleForOverlappingActors(const UCapsuleComponent* Component);
71
72 UFUNCTION()
73 void OnBoxComponentBeginOverlap(UPrimitiveComponent* SelfComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, int32 BodyIndex, bool bFromSweep, const FHitResult& HitResult);
74 UFUNCTION()
75 void OnBoxComponentEndOverlap(UPrimitiveComponent* SelfComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, int32 BodyIndex);
76
77
78 float GetGravityZ() const;
79
83 UFUNCTION(BlueprintPure,Category="Gravity")
84 virtual float GetFinalGravityScale(class USceneComponent* SceneComponent) const;
85
88 UFUNCTION(BlueprintSetter,Category="Gravity")
89 virtual void SetGravityScale(const float NewGravityScale);
90
94 UFUNCTION(BlueprintPure,Category="Gravity")
95 virtual FVector GetGravity(class USceneComponent* SceneComponent) const;
96 UFUNCTION(BlueprintPure,Category="Gravity")
97 virtual bool GetShouldTickBeEnabled() const;
98
101 UFUNCTION(BlueprintPure,Category="Gravity")
102 virtual float GetGravityScale() const;
103
104 UFUNCTION(BlueprintCallable, Category="Gravity")
105 class USplineComponent* GetSplineComponent() const;
106
107 //~ Vars ~//
108
109
111 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Gravity|Debugging")
112 bool bDebuggingMode = false;
113
114 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Gravity|Debugging")
115 bool bRagdollOnTick = false;
116 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Gravity|Debugging")
117 bool bAddForceAllBodies = false;
118 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Gravity|Debugging")
119 float CharacterGravityMultiplier = 5.0f;
120
121
123 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Transient, Category="Gravity|Components")
124 TArray<class UShapeComponent*> AllShapeComponents;
125
126
127 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Transient, Category="Gravity")
128 TArray<FTrackedGravityActor> TrackedGravityActors;
129
130 // /** List of tracked Actors that are affected by gravity settings. */
131 // UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Transient, Category="Gravity")
132 // TArray<TObjectPtr<AActor>> TrackedActors;
133 // /** List of tracked Characters that are affected by gravity settings. */
134 // UPROPERTY()
135 // TArray<class IALSCharacterInterface*> TrackedCharacters;
136 // UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Transient, Category="Gravity")
137 // TArray<class AActor*> TrackedCharacterActors;
138
140 UPROPERTY(EditAnywhere,BlueprintReadWrite,Category="Gravity")
141 FVector CharacterFallVelocity = FVector::ZeroVector;;
143 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gravity")
144 EGravityDirectionMode GravityDirectionMode = EGravityDirectionMode::Fixed;
146 UPROPERTY(EditAnywhere, BlueprintReadOnly,Category="Gravity")
147 FVector GravityVectorA = FVector(0.0f, 0.0f, -1.0f);
149 UPROPERTY(EditAnywhere, BlueprintReadOnly,Category="Gravity")
150 FVector GravityVectorB = FVector::ZeroVector;
152 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Gravity")
153 TObjectPtr<AActor> GravityActor = nullptr;;
155 UPROPERTY(EditAnywhere,BlueprintReadWrite,BlueprintSetter=SetGravityScale,Category="Gravity")
156 float GravityScale = 1.0f;;
157
158private:
160 UPROPERTY()
161 class USplineComponent* SplineComponent = nullptr;
162
164 UPROPERTY(EditAnywhere, Category="Gravity")
165 float ActorCheckDelay = 0.1f;
166
167 FTimerHandle ActorCheckTimerHandle;
168
169};
EGravityDirectionMode
Definition ALSExtraData.h:14
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
Definition GravityData.h:15