Add combat deplacement inputs

This commit is contained in:
Maxime Maurin 2023-08-25 16:37:20 +02:00
parent 10fc850f11
commit 37d62ed440
12 changed files with 125 additions and 10 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Pawn_Unreal/Content/Input/IA_Move.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Pawn_Unreal/Content/Input/IA_Move_Combat.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Pawn_Unreal/Content/Input/IA_Move_Narrative.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Pawn_Unreal/Content/Input/IMC_Judy_Combat.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

View File

@ -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<UPwnGameplayModeSubsystem>();
check(Subsystem);
return Subsystem->IsNarrativeMode();
}
bool UPwnGameplayModeLibrary::IsCombatMode(UObject* WorldContext) {
const UWorld* World = GEngine->GetWorldFromContextObject(WorldContext, EGetWorldErrorMode::LogAndReturnNull);
const UPwnGameplayModeSubsystem* Subsystem = World->GetSubsystem<UPwnGameplayModeSubsystem>();
check(Subsystem);
return Subsystem->IsCombatMode();
}

View File

@ -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;
}

View File

@ -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);
};

View File

@ -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;
};