From 37d62ed440174934169812880500e9540b7736de Mon Sep 17 00:00:00 2001 From: Maxime Date: Fri, 25 Aug 2023 16:37:20 +0200 Subject: [PATCH] Add combat deplacement inputs --- Pawn_Unreal/Content/Characters/BP_Judy.uasset | 4 +- .../Content/Core/GM_MainGameMode.uasset | 4 +- .../Input/BP_MainPlayerController.uasset | 4 +- Pawn_Unreal/Content/Input/IA_Move.uasset | 4 +- .../Content/Input/IA_Move_Combat.uasset | 3 ++ .../Content/Input/IA_Move_Narrative.uasset | 3 ++ .../Content/Input/IMC_Judy_Combat.uasset | 3 ++ .../Camera/BP_MainCameraManager.uasset | 4 +- .../GameplayModes/PwnGameplayModeLibrary.cpp | 17 ++++++++ .../PwnGameplayModeSubsystem.cpp | 30 +++++++++++++ .../GameplayModes/PwnGameplayModeLibrary.h | 17 ++++++++ .../GameplayModes/PwnGameplayModeSubsystem.h | 42 +++++++++++++++++++ 12 files changed, 125 insertions(+), 10 deletions(-) create mode 100644 Pawn_Unreal/Content/Input/IA_Move_Combat.uasset create mode 100644 Pawn_Unreal/Content/Input/IA_Move_Narrative.uasset create mode 100644 Pawn_Unreal/Content/Input/IMC_Judy_Combat.uasset create mode 100644 Pawn_Unreal/Source/Pawn/Private/GameplayModes/PwnGameplayModeLibrary.cpp create mode 100644 Pawn_Unreal/Source/Pawn/Private/GameplayModes/PwnGameplayModeSubsystem.cpp create mode 100644 Pawn_Unreal/Source/Pawn/Public/GameplayModes/PwnGameplayModeLibrary.h create mode 100644 Pawn_Unreal/Source/Pawn/Public/GameplayModes/PwnGameplayModeSubsystem.h diff --git a/Pawn_Unreal/Content/Characters/BP_Judy.uasset b/Pawn_Unreal/Content/Characters/BP_Judy.uasset index 43e8b32..572f19c 100644 --- a/Pawn_Unreal/Content/Characters/BP_Judy.uasset +++ b/Pawn_Unreal/Content/Characters/BP_Judy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8c033890c0d930effa93e6446c44c23f69faf3b2d12e66f8b109d9ce4055ed0f -size 217375 +oid sha256:7f8c5ad6bed973bf3664fff6e6fae64d4f38e767908675cf195503b2ed04f3f0 +size 195534 diff --git a/Pawn_Unreal/Content/Core/GM_MainGameMode.uasset b/Pawn_Unreal/Content/Core/GM_MainGameMode.uasset index 1d7491b..4bdc165 100644 --- a/Pawn_Unreal/Content/Core/GM_MainGameMode.uasset +++ b/Pawn_Unreal/Content/Core/GM_MainGameMode.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bcd27310e415faeb631decb6309890d279fce64861667e832f1b0160b15f73bd -size 132074 +oid sha256:bbd5c4177dc9d308fc8c9d6001907b1cf837bb757695a46b7592ced83df41ae9 +size 104584 diff --git a/Pawn_Unreal/Content/Input/BP_MainPlayerController.uasset b/Pawn_Unreal/Content/Input/BP_MainPlayerController.uasset index 91bbf39..c961290 100644 --- a/Pawn_Unreal/Content/Input/BP_MainPlayerController.uasset +++ b/Pawn_Unreal/Content/Input/BP_MainPlayerController.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:59f6f88c3f04664f9b9d9cac6f80458eefab34d68a6144b20fc5a0ecd45b9f71 -size 131907 +oid sha256:7dfbdf3b1f82aae030c65c8cbfa736f41015da589eba38618eaa31f4da3d9447 +size 203009 diff --git a/Pawn_Unreal/Content/Input/IA_Move.uasset b/Pawn_Unreal/Content/Input/IA_Move.uasset index 04f3890..46d7478 100644 --- a/Pawn_Unreal/Content/Input/IA_Move.uasset +++ b/Pawn_Unreal/Content/Input/IA_Move.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8529c76442919178e3b66c5b6de19b4743592b4d57fd87006abecf422c9f2d3e -size 1751 +oid sha256:f40463881e0a223472f08cb5c7056eb1762c1bd337a6c2e722ae90007d018aca +size 1461 diff --git a/Pawn_Unreal/Content/Input/IA_Move_Combat.uasset b/Pawn_Unreal/Content/Input/IA_Move_Combat.uasset new file mode 100644 index 0000000..af16354 --- /dev/null +++ b/Pawn_Unreal/Content/Input/IA_Move_Combat.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d588d1a54ae6205d15689d873b66cbcabfb4b434b66034251d0931c94f8301e +size 1786 diff --git a/Pawn_Unreal/Content/Input/IA_Move_Narrative.uasset b/Pawn_Unreal/Content/Input/IA_Move_Narrative.uasset new file mode 100644 index 0000000..ebe0654 --- /dev/null +++ b/Pawn_Unreal/Content/Input/IA_Move_Narrative.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3968b89e331bfc4e24bb48ee564e52fdf682251b64d632343608938b25e6021f +size 1801 diff --git a/Pawn_Unreal/Content/Input/IMC_Judy_Combat.uasset b/Pawn_Unreal/Content/Input/IMC_Judy_Combat.uasset new file mode 100644 index 0000000..82f3ef6 --- /dev/null +++ b/Pawn_Unreal/Content/Input/IMC_Judy_Combat.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:24f3fe2fa4a4bbcc1e08c15ee14ebc04dd5d06f8802aa37f6664a7f0028dbb1a +size 6190 diff --git a/Pawn_Unreal/Content/Systems/Camera/BP_MainCameraManager.uasset b/Pawn_Unreal/Content/Systems/Camera/BP_MainCameraManager.uasset index b3c92b3..cb12efc 100644 --- a/Pawn_Unreal/Content/Systems/Camera/BP_MainCameraManager.uasset +++ b/Pawn_Unreal/Content/Systems/Camera/BP_MainCameraManager.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6bd8ca3f77137a316ce74162bed0b9ac240fff31c6c11cad2673542e690e4966 -size 232627 +oid sha256:c55ca7abeafc09dc26d84b1b22bbb04a23fef95b0eac4679c761c178e97610a1 +size 248664 diff --git a/Pawn_Unreal/Source/Pawn/Private/GameplayModes/PwnGameplayModeLibrary.cpp b/Pawn_Unreal/Source/Pawn/Private/GameplayModes/PwnGameplayModeLibrary.cpp new file mode 100644 index 0000000..afcc716 --- /dev/null +++ b/Pawn_Unreal/Source/Pawn/Private/GameplayModes/PwnGameplayModeLibrary.cpp @@ -0,0 +1,17 @@ +#include "GameplayModes/PwnGameplayModeLibrary.h" + +#include "GameplayModes/PwnGameplayModeSubsystem.h" + +bool UPwnGameplayModeLibrary::IsNarrativeMode(UObject* WorldContext) { + const UWorld* World = GEngine->GetWorldFromContextObject(WorldContext, EGetWorldErrorMode::LogAndReturnNull); + const UPwnGameplayModeSubsystem* Subsystem = World->GetSubsystem(); + check(Subsystem); + return Subsystem->IsNarrativeMode(); +} + +bool UPwnGameplayModeLibrary::IsCombatMode(UObject* WorldContext) { + const UWorld* World = GEngine->GetWorldFromContextObject(WorldContext, EGetWorldErrorMode::LogAndReturnNull); + const UPwnGameplayModeSubsystem* Subsystem = World->GetSubsystem(); + check(Subsystem); + return Subsystem->IsCombatMode(); +} diff --git a/Pawn_Unreal/Source/Pawn/Private/GameplayModes/PwnGameplayModeSubsystem.cpp b/Pawn_Unreal/Source/Pawn/Private/GameplayModes/PwnGameplayModeSubsystem.cpp new file mode 100644 index 0000000..8cdb663 --- /dev/null +++ b/Pawn_Unreal/Source/Pawn/Private/GameplayModes/PwnGameplayModeSubsystem.cpp @@ -0,0 +1,30 @@ +#include "GameplayModes/PwnGameplayModeSubsystem.h" + +void UPwnGameplayModeSubsystem::Initialize(FSubsystemCollectionBase& Collection) { + Super::Initialize(Collection); + CurrentGameplayMode = EPwnGameplayMode::Narrative; +} + +void UPwnGameplayModeSubsystem::Deinitialize() { + Super::Deinitialize(); +} + +void UPwnGameplayModeSubsystem::SetGameplayMode(EPwnGameplayMode GameplayMode) { + if (GameplayMode != CurrentGameplayMode) { + CurrentGameplayMode = GameplayMode; + if (OnGameplayModeChanged.IsBound()) { + OnGameplayModeChanged.Broadcast(CurrentGameplayMode); + } + } +} + +EPwnGameplayMode UPwnGameplayModeSubsystem::GetCurrentGameplayMode() const { + return CurrentGameplayMode; +} + +bool UPwnGameplayModeSubsystem::IsNarrativeMode() const { + return CurrentGameplayMode == EPwnGameplayMode::Narrative; +} +bool UPwnGameplayModeSubsystem::IsCombatMode() const { + return CurrentGameplayMode == EPwnGameplayMode::Combat; +} diff --git a/Pawn_Unreal/Source/Pawn/Public/GameplayModes/PwnGameplayModeLibrary.h b/Pawn_Unreal/Source/Pawn/Public/GameplayModes/PwnGameplayModeLibrary.h new file mode 100644 index 0000000..b547791 --- /dev/null +++ b/Pawn_Unreal/Source/Pawn/Public/GameplayModes/PwnGameplayModeLibrary.h @@ -0,0 +1,17 @@ +#pragma once + +#include "CoreMinimal.h" +#include "Kismet/BlueprintFunctionLibrary.h" +#include "PwnGameplayModeLibrary.generated.h" + +UCLASS(DisplayName="Gameplay Mode Library") +class PAWN_API UPwnGameplayModeLibrary : public UBlueprintFunctionLibrary { + GENERATED_BODY() + +public: + UFUNCTION(BlueprintCallable, BlueprintPure, Category="Gameplay Modes", meta=(WorldContext="WorldContext", HidePin="WorldContext")) + static bool IsNarrativeMode(UObject* WorldContext); + + UFUNCTION(BlueprintCallable, BlueprintPure, Category="Gameplay Modes", meta=(WorldContext="WorldContext", HidePin="WorldContext")) + static bool IsCombatMode(UObject* WorldContext); +}; diff --git a/Pawn_Unreal/Source/Pawn/Public/GameplayModes/PwnGameplayModeSubsystem.h b/Pawn_Unreal/Source/Pawn/Public/GameplayModes/PwnGameplayModeSubsystem.h new file mode 100644 index 0000000..9ee228d --- /dev/null +++ b/Pawn_Unreal/Source/Pawn/Public/GameplayModes/PwnGameplayModeSubsystem.h @@ -0,0 +1,42 @@ +#pragma once + +#include "CoreMinimal.h" +#include "Subsystems/WorldSubsystem.h" +#include "PwnGameplayModeSubsystem.generated.h" + +UENUM(BlueprintType, DisplayName = "Gameplay Mode") +enum class EPwnGameplayMode : uint8 { + Narrative, + Combat +}; + +DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FGameplayModeChangedDelegate, EPwnGameplayMode, NewMode); + +UCLASS(DisplayName="Gameplay Mode Subsystem") +class PAWN_API UPwnGameplayModeSubsystem : public UWorldSubsystem { + GENERATED_BODY() + +public: + virtual void Initialize(FSubsystemCollectionBase& Collection) override; + + virtual void Deinitialize() override; + + UFUNCTION(BlueprintCallable, Category="Gameplay Modes") + void SetGameplayMode(EPwnGameplayMode GameplayMode); + + UFUNCTION(BlueprintCallable, BlueprintPure, Category="Gameplay Modes") + EPwnGameplayMode GetCurrentGameplayMode() const; + + UFUNCTION(BlueprintCallable, BlueprintPure, Category="Gameplay Modes") + bool IsNarrativeMode() const; + + UFUNCTION(BlueprintCallable, BlueprintPure, Category="Gameplay Modes") + bool IsCombatMode() const; + +public: + UPROPERTY(BlueprintAssignable) + FGameplayModeChangedDelegate OnGameplayModeChanged; + +private: + EPwnGameplayMode CurrentGameplayMode; +};