Space Plunder
Loading...
Searching...
No Matches
GravityData.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"
8#include "GravityData.generated.h"
9
13USTRUCT(BlueprintType)
15{
16 GENERATED_BODY()
17
18
19 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Gravity")
20 TObjectPtr<AActor> TrackedActor = nullptr;
22 IALSCharacterInterface* ALSCharacter = nullptr;
24 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Gravity")
25 UPrimitiveComponent* PrimitiveRoot = nullptr;
26
28 FTrackedGravityActor(AActor* Actor)
29 {
30 if(Actor == nullptr){return;}
31 TrackedActor = Actor;
32 if(TrackedActor == nullptr){return;}
33 ICharacterBaseInterface* CharacterInterface = Cast<ICharacterBaseInterface>(Actor);
34 if(CharacterInterface == nullptr)
35 {
36 bIsCharacter = false;
37 if(TrackedActor->GetRootComponent() != nullptr)
38 {
39 UPrimitiveComponent* Primitive = Cast<UPrimitiveComponent>(TrackedActor->GetRootComponent());
40 if(Primitive != nullptr)
41 {
42 PrimitiveRoot = Primitive;
43 }
44 }
45 return;
46 }
47 bIsCharacter = true;
48 Character = CharacterInterface;
49 if(Character->GetPrimitiveComponent() != nullptr)
50 {
51 PrimitiveRoot = Character->GetPrimitiveComponent();
52 }
53 IALSCharacterInterface* ALSInterface = Cast<IALSCharacterInterface>(Actor);
54 if(ALSInterface == nullptr){bIsALSCharacter = false; return;}
55 bIsALSCharacter = true;
56 ALSCharacter = ALSInterface;
57 };
58
59 bool IsCharacter() const
60 {
61 return bIsCharacter;
62 }
63
64 bool IsValid() const
65 {
66 if(TrackedActor == nullptr){return false;}
67 if(bIsCharacter && Character == nullptr){return false;}
68 if(PrimitiveRoot == nullptr){return false;}
69 if(bIsCharacter == false)
70 {
71 if(PrimitiveRoot->IsAnySimulatingPhysics() && PrimitiveRoot->IsGravityEnabled())
72 {
73 return true;
74 }
75 return false;
76 }
77 return true;
78 }
79
81 {
82 if(Other.TrackedActor == nullptr || TrackedActor == nullptr){return false;}
83 if(Other.TrackedActor == TrackedActor){return true;}
84 return false;
85 }
86 bool operator==(const AActor* Other) const
87 {
88 if(Other == nullptr || TrackedActor == nullptr){return false;}
89 if(Other == TrackedActor){return true;}
90 return false;
91 }
92
93private:
94 UPROPERTY(VisibleAnywhere, Category="Gravity")
95 bool bIsCharacter = false;
96 UPROPERTY(VisibleAnywhere, Category="Gravity")
97 bool bIsALSCharacter = false;
98
99};
Definition ALSCharacterInterface.h:24
Definition CustomCharacter.h:19
virtual UPrimitiveComponent * GetPrimitiveComponent()=0
Definition GravityData.h:15
FTrackedGravityActor(AActor *Actor)
Definition GravityData.h:28
bool IsValid() const
Definition GravityData.h:64
bool operator==(const FTrackedGravityActor &Other) const
Definition GravityData.h:80
bool IsCharacter() const
Definition GravityData.h:59
bool operator==(const AActor *Other) const
Definition GravityData.h:86