magic update #2
This commit is contained in:
15
Elistria_Calling/Source/Elistria_Calling.Target.cs
Normal file
15
Elistria_Calling/Source/Elistria_Calling.Target.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class Elistria_CallingTarget : TargetRules
|
||||
{
|
||||
public Elistria_CallingTarget(TargetInfo Target) : base(Target)
|
||||
{
|
||||
Type = TargetType.Game;
|
||||
DefaultBuildSettings = BuildSettingsVersion.V5;
|
||||
|
||||
ExtraModuleNames.AddRange( new string[] { "Elistria_Calling" } );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class Elistria_Calling : ModuleRules
|
||||
{
|
||||
public Elistria_Calling(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore","GameplayAbilities", "GameplayTags", "GameplayTasks" });
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(new string[] { });
|
||||
|
||||
// Uncomment if you are using Slate UI
|
||||
PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
|
||||
|
||||
// Uncomment if you are using online features
|
||||
PrivateDependencyModuleNames.Add("OnlineSubsystem");
|
||||
|
||||
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#include "Elistria_Calling.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, Elistria_Calling, "Elistria_Calling" );
|
||||
@@ -0,0 +1,6 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "ElistriaAbilitySystemComponent.h"
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "HealthAttributeSet.h"
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "MagickPlayerController.h"
|
||||
|
||||
#include "MagickPlayerState.h"
|
||||
|
||||
void AMagickPlayerController::OnPossess(APawn *InPawn)
|
||||
{
|
||||
Super::OnPossess(InPawn);
|
||||
UE_LOG(LogTemp, Display, TEXT("OnPossess"));
|
||||
AMagickPlayerState* PS = GetPlayerState<AMagickPlayerState>();
|
||||
if (PS)
|
||||
{
|
||||
PS->SetupAbilityActorInfo();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "MagickPlayerState.h"
|
||||
|
||||
|
||||
|
||||
|
||||
AMagickPlayerState::AMagickPlayerState()
|
||||
{
|
||||
ElistriaAbilitySystemComponent = CreateDefaultSubobject<UElistriaAbilitySystemComponent>(TEXT("AbilitySystem"));
|
||||
ManaSet = CreateDefaultSubobject<UManaAttributeSet>(TEXT("ManaSet"));
|
||||
}
|
||||
|
||||
UElistriaAbilitySystemComponent* AMagickPlayerState::GetAbilitySystemComponent() const
|
||||
{
|
||||
return ElistriaAbilitySystemComponent;
|
||||
}
|
||||
|
||||
void AMagickPlayerState::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void AMagickPlayerState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
|
||||
{
|
||||
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||
|
||||
DOREPLIFETIME_CONDITION_NOTIFY(AMagickPlayerState, ElistriaAbilitySystemComponent, COND_None, REPNOTIFY_Always);
|
||||
DOREPLIFETIME_CONDITION_NOTIFY(AMagickPlayerState, ManaSet, COND_None, REPNOTIFY_Always);
|
||||
}
|
||||
|
||||
void AMagickPlayerState::SetupAbilityActorInfo()
|
||||
{
|
||||
AMagickPlayerController* PC = Cast<AMagickPlayerController>(GetOwner());
|
||||
if (!PC)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
APawn* Pawn = PC->GetPawn();
|
||||
|
||||
if (!Pawn)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ElistriaAbilitySystemComponent)
|
||||
{
|
||||
ElistriaAbilitySystemComponent->InitAbilityActorInfo(this,Pawn);
|
||||
|
||||
if (ManaSet)
|
||||
{
|
||||
ElistriaAbilitySystemComponent->AddAttributeSetSubobject(ManaSet.Get());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "ManaAttributeSet.h"
|
||||
|
||||
UManaAttributeSet::UManaAttributeSet()
|
||||
{
|
||||
InitMana(100.0f);
|
||||
InitMaxMana(100.0f);
|
||||
}
|
||||
|
||||
void UManaAttributeSet::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
|
||||
{
|
||||
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||
|
||||
DOREPLIFETIME_CONDITION_NOTIFY(UManaAttributeSet, Mana, COND_None, REPNOTIFY_Always);
|
||||
DOREPLIFETIME_CONDITION_NOTIFY(UManaAttributeSet, MaxMana, COND_None, REPNOTIFY_Always);
|
||||
}
|
||||
|
||||
void UManaAttributeSet::OnRep_Mana(const FGameplayAttributeData& OldValue)
|
||||
{
|
||||
GAMEPLAYATTRIBUTE_REPNOTIFY(UManaAttributeSet, Mana, OldValue);
|
||||
const float OldMana = OldValue.GetCurrentValue();
|
||||
const float NewMana = GetMana();
|
||||
OnManaChanged.Broadcast(this, OldMana, NewMana);
|
||||
}
|
||||
|
||||
void UManaAttributeSet::OnRep_MaxMana(const FGameplayAttributeData& OldValue)
|
||||
{
|
||||
GAMEPLAYATTRIBUTE_REPNOTIFY(UManaAttributeSet, MaxMana, OldValue);
|
||||
const float OldMaxMana = OldValue.GetCurrentValue();
|
||||
const float NewMaxMana = GetMaxMana();
|
||||
OnMaxManaChanged.Broadcast(this, OldMaxMana, NewMaxMana);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "ElistriaAbilitySystemComponent.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class ELISTRIA_CALLING_API UElistriaAbilitySystemComponent : public UAbilitySystemComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AttributeSet.h"
|
||||
#include "HealthAttributeSet.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class ELISTRIA_CALLING_API UHealthAttributeSet : public UAttributeSet
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
#include "MagickPlayerController.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class ELISTRIA_CALLING_API AMagickPlayerController : public APlayerController
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
virtual void OnPossess(APawn* InPawn) override;
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/PlayerState.h"
|
||||
#include "AbilitySystemInterface.h"
|
||||
#include "ElistriaAbilitySystemComponent.h"
|
||||
#include "ManaAttributeSet.h"
|
||||
#include "MagickPlayerController.h"
|
||||
#include "MagickPlayerState.generated.h"
|
||||
|
||||
UCLASS(Config=game)
|
||||
class ELISTRIA_CALLING_API AMagickPlayerState : public APlayerState, public IAbilitySystemInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
AMagickPlayerState();
|
||||
|
||||
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
|
||||
virtual UElistriaAbilitySystemComponent* GetAbilitySystemComponent() const override;
|
||||
|
||||
void SetupAbilityActorInfo();
|
||||
|
||||
protected:
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Abilities, Replicated)
|
||||
TObjectPtr<class UElistriaAbilitySystemComponent> ElistriaAbilitySystemComponent;
|
||||
|
||||
UPROPERTY(Replicated)
|
||||
TObjectPtr<class UManaAttributeSet> ManaSet;
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AttributeSet.h"
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "Net/UnrealNetwork.h"
|
||||
#include "ManaAttributeSet.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
#define ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \
|
||||
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \
|
||||
GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \
|
||||
GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \
|
||||
GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName)
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FAttributeChangedEvent, UAttributeSet*, AttributeSet, float, OldValue, float, NewValue);
|
||||
|
||||
UCLASS()
|
||||
class ELISTRIA_CALLING_API UManaAttributeSet : public UAttributeSet
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UManaAttributeSet();
|
||||
|
||||
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, ReplicatedUsing=OnRep_Mana)
|
||||
FGameplayAttributeData Mana;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, ReplicatedUsing=OnRep_MaxMana)
|
||||
FGameplayAttributeData MaxMana;
|
||||
|
||||
ATTRIBUTE_ACCESSORS(UManaAttributeSet, Mana)
|
||||
ATTRIBUTE_ACCESSORS(UManaAttributeSet, MaxMana)
|
||||
|
||||
UFUNCTION()
|
||||
void OnRep_Mana(const FGameplayAttributeData& OldValue);
|
||||
UFUNCTION()
|
||||
void OnRep_MaxMana(const FGameplayAttributeData& OldValue);
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FAttributeChangedEvent OnManaChanged;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FAttributeChangedEvent OnMaxManaChanged;
|
||||
};
|
||||
15
Elistria_Calling/Source/Elistria_CallingEditor.Target.cs
Normal file
15
Elistria_Calling/Source/Elistria_CallingEditor.Target.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class Elistria_CallingEditorTarget : TargetRules
|
||||
{
|
||||
public Elistria_CallingEditorTarget(TargetInfo Target) : base(Target)
|
||||
{
|
||||
Type = TargetType.Editor;
|
||||
DefaultBuildSettings = BuildSettingsVersion.V5;
|
||||
|
||||
ExtraModuleNames.AddRange( new string[] { "Elistria_Calling" } );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user