diff --git a/Plugins/VRGAS/Source/VRGAS/Private/Player/VRAbilitySystemPlayerState.cpp b/Plugins/VRGAS/Source/VRGAS/Private/Player/VRAbilitySystemPlayerState.cpp new file mode 100644 index 0000000..6c9fb38 --- /dev/null +++ b/Plugins/VRGAS/Source/VRGAS/Private/Player/VRAbilitySystemPlayerState.cpp @@ -0,0 +1,24 @@ +// Copyright + + +#include "Player/VRAbilitySystemPlayerState.h" + +#include "AbilitySystemComponent.h" +#include "AbilitySystem/VRAbilitySystemComponent.h" + +AVRAbilitySystemPlayerState::AVRAbilitySystemPlayerState(FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) +{ + VRAbilitySystemComponent = ObjectInitializer.CreateDefaultSubobject(this, TEXT("Ability System Component")); + VRAbilitySystemComponent->SetIsReplicated(true); + VRAbilitySystemComponent->SetReplicationMode(EGameplayEffectReplicationMode::Mixed); + + // Do attribute sets in derived classes + + // If multiplayer, update at a relatively high frequency to update ASC appropriately + NetUpdateFrequency = 100.f; // This is the setting Lyra uses +} + +UAbilitySystemComponent* AVRAbilitySystemPlayerState::GetAbilitySystemComponent() const +{ + return CastChecked(VRAbilitySystemComponent); +} diff --git a/Plugins/VRGAS/Source/VRGAS/Public/Player/VRAbilitySystemPlayerState.h b/Plugins/VRGAS/Source/VRGAS/Public/Player/VRAbilitySystemPlayerState.h new file mode 100644 index 0000000..7451b47 --- /dev/null +++ b/Plugins/VRGAS/Source/VRGAS/Public/Player/VRAbilitySystemPlayerState.h @@ -0,0 +1,32 @@ +// Copyright + +#pragma once + +#include "CoreMinimal.h" +#include "AbilitySystemInterface.h" +#include "GameFramework/PlayerState.h" +#include "VRAbilitySystemPlayerState.generated.h" + +class UVRAbilitySystemComponent; + +/** + * + */ +UCLASS() +class VRGAS_API AVRAbilitySystemPlayerState : public APlayerState, public IAbilitySystemInterface +{ + GENERATED_BODY() + +public: + // ReSharper disable once CppNonExplicitConvertingConstructor + AVRAbilitySystemPlayerState(FObjectInitializer& ObjectInitializer); + + //~ Begin IAbilitySystemInterface + virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override; + //~ End IAbilitySystemInterface + +protected: + UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AbilitySystem") + UVRAbilitySystemComponent* VRAbilitySystemComponent; + +}; diff --git a/Plugins/VRGAS/Source/VRGAS/Public/Player/VRPlayerController.h b/Plugins/VRGAS/Source/VRGAS/Public/Player/VRPlayerController.h index f1a3cd2..b8c0ccf 100644 --- a/Plugins/VRGAS/Source/VRGAS/Public/Player/VRPlayerController.h +++ b/Plugins/VRGAS/Source/VRGAS/Public/Player/VRPlayerController.h @@ -44,10 +44,10 @@ protected: UPROPERTY() TWeakObjectPtr CachedAbilitySystemComponent; - UFUNCTION(BlueprintPure, Category = "Ability System", meta = (HideSelfPin)) + UFUNCTION(BlueprintPure, Category = "AbilitySystem", meta = (HideSelfPin)) UAbilitySystemComponent* GetAbilitySystemComponent(); - UFUNCTION(BlueprintPure, Category = "Ability System", meta = (HideSelfPin)) + UFUNCTION(BlueprintPure, Category = "AbilitySystem", meta = (HideSelfPin)) UVRAbilitySystemComponent* GetVRAbilitySystemComponent(); void Input_AbilityTagPressed(FGameplayTag InTag);