Implemented AMyVICharacterAbilityBase
This commit is contained in:
parent
f6d54647aa
commit
70db6b3a99
@ -0,0 +1,32 @@
|
||||
// Copyright (c) 2019-2022 Drowning Dragons Limited. All Rights Reserved.
|
||||
|
||||
#include "MyVICharacterAbilityBase.h"
|
||||
|
||||
////#include "Pawn/VICharacterAbilityBase.h"
|
||||
#include "GAS/VIAbilitySystemComponent.h"
|
||||
|
||||
AMyVICharacterAbilityBase::AMyVICharacterAbilityBase(const FObjectInitializer& OI)
|
||||
: Super(OI)
|
||||
{
|
||||
AbilitySystem = CreateDefaultSubobject<UVIAbilitySystemComponent>(TEXT("AbilitySystem"));
|
||||
AbilitySystem->SetIsReplicated(true);
|
||||
AbilitySystem->SetReplicationMode(EGameplayEffectReplicationMode::Mixed);
|
||||
AbilitySystemReplicationMode = (EVIGameplayEffectReplicationMode)(uint8)AbilitySystem->ReplicationMode;
|
||||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
void AMyVICharacterAbilityBase::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
|
||||
{
|
||||
Super::PostEditChangeProperty(PropertyChangedEvent);
|
||||
|
||||
if (PropertyChangedEvent.GetPropertyName().IsEqual(GET_MEMBER_NAME_CHECKED(AMyVICharacterAbilityBase, AbilitySystemReplicationMode)))
|
||||
{
|
||||
AbilitySystem->SetReplicationMode((EGameplayEffectReplicationMode)(uint8)AbilitySystemReplicationMode);
|
||||
}
|
||||
}
|
||||
#endif // WITH_EDITOR
|
||||
|
||||
UAbilitySystemComponent* AMyVICharacterAbilityBase::GetAbilitySystemComponent() const
|
||||
{
|
||||
return AbilitySystem;
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
// Copyright (c) 2019-2022 Drowning Dragons Limited. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Pawn/VICharacterBase.h"
|
||||
#include "AbilitySystemInterface.h"
|
||||
#include "MyVICharacterAbilityBase.generated.h"
|
||||
|
||||
class UVIAbilitySystemComponent;
|
||||
|
||||
/**
|
||||
* Adds a UVIAbilitySystemComponent to your character base
|
||||
* Allows switching replication mode in Blueprint for the sake of AI using Minimal instead of Mixed
|
||||
*/
|
||||
UCLASS()
|
||||
class ENDLESSVENDETTA_API AMyVICharacterAbilityBase : public AVICharacterBase, public IAbilitySystemInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(BlueprintReadOnly, Category = Abilities)
|
||||
UVIAbilitySystemComponent* AbilitySystem;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Used by blueprints to allow changing replication mode which is usually
|
||||
* only accessible via C++
|
||||
*
|
||||
* Recommended as follows:
|
||||
* For player characters use Mixed
|
||||
* For AI characters use Minimal
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, Category = Abilities)
|
||||
EVIGameplayEffectReplicationMode AbilitySystemReplicationMode;
|
||||
|
||||
public:
|
||||
AMyVICharacterAbilityBase(const FObjectInitializer& OI);
|
||||
|
||||
#if WITH_EDITOR
|
||||
virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override;
|
||||
#endif // WITH_EDITOR
|
||||
|
||||
protected:
|
||||
// *********************************************** //
|
||||
// ******** Begin IAbilitySystemInterface ******** //
|
||||
// *********************************************** //
|
||||
|
||||
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
|
||||
|
||||
// *********************************************** //
|
||||
// ********* End IAbilitySystemInterface ********* //
|
||||
// *********************************************** //
|
||||
};
|
Loading…
Reference in New Issue
Block a user