Space Plunder
Loading...
Searching...
No Matches
CommonActorComponent.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 "Components/ActorComponent.h"
8#include "CommonActorComponent.generated.h"
9
10struct FGameplayTag;
11DECLARE_LOG_CATEGORY_CLASS(LogCommonActorComp, Display, All);
12
13DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnComponentSetupComplete);
14
15
16UCLASS(ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent), Abstract)
17class BASEHELPERS_API UCommonActorComponent : public UActorComponent, public ISaveLoad
18{
19 GENERATED_BODY()
20
21public:
22 UCommonActorComponent();
23
24 //~~ ISaveLoad ~~//
25 virtual bool SaveGame() override;
26 virtual bool LoadGame() override;
27 //~~ ISaveLoad ~~//
28
29
30 UPROPERTY(BlueprintAssignable)
31 FOnComponentSetupComplete ComponentSetupCompleteDelegate;
32
33
35 template <class T>
36 T* GetGameInstance() const
37 {
38 static_assert(TPointerIsConvertibleFromTo<T, UGameInstance>::Value, "'T' template parameter to GetGameInstance must be derived from UGameInstance");
39 AActor* Owner = GetOwner();
40 return Owner ? Owner->GetGameInstance<T>() : nullptr;
41 }
42 template <class T>
43 T* GetGameInstanceChecked() const
44 {
45 static_assert(TPointerIsConvertibleFromTo<T, UGameInstance>::Value, "'T' template parameter to GetGameInstance must be derived from UGameInstance");
46 const AActor* Owner = GetOwner();
47 check(Owner);
48 T* GameInstance = Owner->GetGameInstance<T>();
49 check(GameInstance);
50 return GameInstance;
51 }
52
54 class FTimerManager& GetWorldTimerManager() const;
55
57 bool HasAuthority() const;
58
60 void SetupComponent();
61
62
63 virtual void CharacterModeChanged(const FGameplayTag& NewMode);
64
65
66#if WITH_GAMEPLAY_DEBUGGER
67 bool GetDebuggingMode() const{return bDebuggingMode;};
68
69 void SetDebuggingMode(const bool bValue){bDebuggingMode = bValue;};
70#endif
71
72protected:
73 virtual void BeginPlay() override;
74
75 virtual void AutoDetect();
76 UFUNCTION(Server, Reliable)
77 virtual void Server_AutoDetect();
78
80 UFUNCTION()
81 virtual void ComponentActivated(UActorComponent* Component, const bool bReset);
83 UFUNCTION()
84 virtual void ComponentDeactivated(UActorComponent* Component);
85
86 void SetComponentSetup();
87 UFUNCTION(Server, Reliable)
88 void Server_SetComponentSetup();
89 UFUNCTION()
90 void OnRep_ComponentSetup();
91 virtual void ComponentSetupComplete();
92
93
94 void LogDebugError(const FString& Message) const;
95 void LogDebugError(const FString& Message, const int32 Value) const;
96 void LogDebugError(const FString& Message, const float Value) const;
97 void LogDebugWarning(const FString& Message) const;
98 void LogDebugWarning(const FString& Message, const int32 Value) const;
99 void LogDebugWarning(const FString& Message, const float Value) const;
100
101 void LogDebugMessage(const FString& Message, const bool bWarning = false, const bool bError = false) const;
102 void LogDebugMessage(const FString& Message, const int32 Value, const bool bWarning = false, const bool bError = false) const;
103 void LogDebugMessage(const FString& Message, const float Value, const bool bWarning = false, const bool bError = false) const;
104 void LogDebugMessage(const FString& Message, const bool bValue, const bool bWarning, const bool bError) const;
105 void LogOnScreenMessage(const int32 Key, const FString& Message, FColor Color = FColor::Green) const;
106
107 void SetCategoryName(const FLogCategoryBase& Category){CategoryName = Category.GetCategoryName();};
108
109 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Common|Debugging")
110 bool bDebuggingMode = false;
111 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Common|Debugging")
112 bool bCheatsEnabled = false;
113
114 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Common|Setup")
115 bool bAutoDetect = false;
116 UPROPERTY(ReplicatedUsing=OnRep_ComponentSetup, VisibleAnywhere, BlueprintReadOnly, Category = "Common|Setup")
117 bool bComponentSetup = false;
118
119private:
120
121 FLogCategoryName CategoryName = LogCommonActorComp.GetCategoryName();
122
123};
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnComponentSetupComplete)
DECLARE_LOG_CATEGORY_CLASS(LogCommonActorComp, Display, All)
Definition SaveLoad.h:20
const FName CategoryName
Definition CompanionGameplayTags.h:10