diff --git a/Config/DefaultGame.ini b/Config/DefaultGame.ini index 3aac9524..8e0a0027 100644 --- a/Config/DefaultGame.ini +++ b/Config/DefaultGame.ini @@ -192,4 +192,5 @@ CameraZoomLevels=(((TagName="Camera.BoomOffset.Default"), (X=-1200.000000,Y=0.00 +ProfessionExpArray=208000.000000 +ProfessionExpArray=240000.000000 ExpIncreaseEffectClass=/Script/Engine.BlueprintGeneratedClass'/Game/Blueprints/GameEffects/GSE_AddExp_Template.GSE_AddExp_Template_C' +GlobalSettingsDataSheet=/Game/GameData/CSV/GlobalKeyValueSettings.GlobalKeyValueSettings diff --git a/Content/Blueprints/GameplayAbilities/GameplayEffects/GE_AddExp_Template.uasset b/Content/Blueprints/GameplayAbilities/GameplayEffects/GE_AddExp_Template.uasset deleted file mode 100644 index 9d2f9512..00000000 --- a/Content/Blueprints/GameplayAbilities/GameplayEffects/GE_AddExp_Template.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6b1913d04cff3a3193c419cc8bcfb82ed53881caa8188f597a509f8d6114ab80 -size 13131 diff --git a/Content/Blueprints/GameplayAbilities/GameplayEffects/GE_AlchemyEnergyCost.uasset b/Content/Blueprints/GameplayAbilities/GameplayEffects/GE_AlchemyEnergyCost.uasset deleted file mode 100644 index 7ef97cf2..00000000 --- a/Content/Blueprints/GameplayAbilities/GameplayEffects/GE_AlchemyEnergyCost.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:13a86d0a72fd9a0bf84b77509a324ce92ed887ebdae6ca6c5b3bc051b91ca48c -size 13147 diff --git a/Content/Blueprints/GameplayAbilities/GameplayEffects/GE_EatRestoreEnergy.uasset b/Content/Blueprints/GameplayAbilities/GameplayEffects/GE_EatRestoreEnergy.uasset deleted file mode 100644 index b55185ab..00000000 --- a/Content/Blueprints/GameplayAbilities/GameplayEffects/GE_EatRestoreEnergy.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f7b0168ce9f2310a73749ec2be30f0c68f2180ac33c6a2e46e48c78c200416c4 -size 12683 diff --git a/Content/Blueprints/GameplayAbilities/GameplayEffects/GE_HarvestingEnergyCost.uasset b/Content/Blueprints/GameplayAbilities/GameplayEffects/GE_HarvestingEnergyCost.uasset deleted file mode 100644 index b0efccbe..00000000 --- a/Content/Blueprints/GameplayAbilities/GameplayEffects/GE_HarvestingEnergyCost.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f43877fd28a5014d8b758803c0d0cda7a42d1cbbfd75b28d727543647b0fd384 -size 12739 diff --git a/Content/Blueprints/GameplayAbilities/GameplayEffects/GE_PlantingEnergyCost.uasset b/Content/Blueprints/GameplayAbilities/GameplayEffects/GE_PlantingEnergyCost.uasset deleted file mode 100644 index 63877e5f..00000000 --- a/Content/Blueprints/GameplayAbilities/GameplayEffects/GE_PlantingEnergyCost.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fa92d90431d52f1996dcce1cafc4f1017e2599e7f7e87c66810ae5cd1f8a4d5c -size 12711 diff --git a/Content/Blueprints/GameplayAbilities/GameplayEffects/GE_SleepRestoreEnergy.uasset b/Content/Blueprints/GameplayAbilities/GameplayEffects/GE_SleepRestoreEnergy.uasset deleted file mode 100644 index c12723d1..00000000 --- a/Content/Blueprints/GameplayAbilities/GameplayEffects/GE_SleepRestoreEnergy.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b37f9244d6ee5bcbfdba734eaf5912ebef99cd83072fb125f3bd936a2534ea67 -size 13161 diff --git a/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/CT_ProfessionBonuses.uasset b/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/CT_ProfessionBonuses.uasset deleted file mode 100644 index 250481c0..00000000 --- a/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/CT_ProfessionBonuses.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:973261a3190be6e0f31ba35f1158a551dfb390112a14a60c07bb8b915579e90e -size 2295 diff --git a/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/GE_AlchemyBonusesEffect.uasset b/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/GE_AlchemyBonusesEffect.uasset deleted file mode 100644 index b2f3ee39..00000000 --- a/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/GE_AlchemyBonusesEffect.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5bc5ff9a66df2e6de777ac6aa8b91513ffe639765ec1fdb172733fb06b8dcf53 -size 13705 diff --git a/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/GE_EnergyGatherBonus.uasset b/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/GE_EnergyGatherBonus.uasset deleted file mode 100644 index 24ff0163..00000000 --- a/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/GE_EnergyGatherBonus.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f1b4a2d61f2ca029757418a7031a0b2340f4fc2e0e9e5d730ccd384764631c79 -size 28877 diff --git a/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/MagnitudeCalc/AlchemyMultiplierModMagnitudeCalculation.uasset b/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/MagnitudeCalc/AlchemyMultiplierModMagnitudeCalculation.uasset deleted file mode 100644 index f12e5afa..00000000 --- a/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/MagnitudeCalc/AlchemyMultiplierModMagnitudeCalculation.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a47948cbfff20a2d13eaa635b3177828db2c0bfd8930f248e153e9f2582f38a0 -size 40032 diff --git a/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/MagnitudeCalc/EnergyDoubleDropChanceModMagnitudeCalculation.uasset b/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/MagnitudeCalc/EnergyDoubleDropChanceModMagnitudeCalculation.uasset deleted file mode 100644 index e83bac5c..00000000 --- a/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/MagnitudeCalc/EnergyDoubleDropChanceModMagnitudeCalculation.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d71eb55bf736dae0d3786f8cefabe317cc635d05864cb7747215661ab291c344 -size 40054 diff --git a/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/MagnitudeCalc/EnergyFriendPointsModMagnitudeCalculation.uasset b/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/MagnitudeCalc/EnergyFriendPointsModMagnitudeCalculation.uasset deleted file mode 100644 index 23747800..00000000 --- a/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/MagnitudeCalc/EnergyFriendPointsModMagnitudeCalculation.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4d7d36dc4d88e82e3a0ee3861e2b3364b4b4e73c022736c0cc0ff6a00afb34bb -size 40046 diff --git a/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/MagnitudeCalc/EnergyHqChanceModMagnitudeCalculation.uasset b/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/MagnitudeCalc/EnergyHqChanceModMagnitudeCalculation.uasset deleted file mode 100644 index 6197a769..00000000 --- a/Content/Blueprints/GameplayAbilities/GameplayEffects/StatCalculators/MagnitudeCalc/EnergyHqChanceModMagnitudeCalculation.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6e66576c8c3ad221092d3fa0534d4398e3f2171d255ef395b66874105ed4299b -size 39942 diff --git a/Content/Character/Ai/Evaluators/STE_BazarNpcWillEvaluator.uasset b/Content/Character/Ai/Evaluators/STE_BazarNpcWillEvaluator.uasset index d74c5ce6..953000ad 100644 --- a/Content/Character/Ai/Evaluators/STE_BazarNpcWillEvaluator.uasset +++ b/Content/Character/Ai/Evaluators/STE_BazarNpcWillEvaluator.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ce2b1da78da8d1cdfbf24dcc7899e424bdc30b3789c36677577f2fefb7e3aa9b -size 38107 +oid sha256:60db46a1f02d0d95b0d6c6c6dbcd78ba7af82f2de501cb4ffa2bd02ce35159fd +size 35525 diff --git a/Content/GameData/CSV/GlobalKeyValueSettings.csv b/Content/GameData/CSV/GlobalKeyValueSettings.csv new file mode 100644 index 00000000..2c34a367 --- /dev/null +++ b/Content/GameData/CSV/GlobalKeyValueSettings.csv @@ -0,0 +1,6 @@ +Name,Value +AlchemyEnergyCost,1 +FoodEnergyRestore,20 +HarvestingEnergyCost,1 +PlantingEnergyCost,1 +SleepEnergyRestore,70 \ No newline at end of file diff --git a/Content/GameData/CSV/GlobalKeyValueSettings.uasset b/Content/GameData/CSV/GlobalKeyValueSettings.uasset new file mode 100644 index 00000000..c5063a91 --- /dev/null +++ b/Content/GameData/CSV/GlobalKeyValueSettings.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2d3d32a26585e36e55685c947bac869664c85c1adada85674e2536a94fe23255 +size 2643 diff --git a/Content/Scripts/AlchemySystem/AlchemyWindow.uasset b/Content/Scripts/AlchemySystem/AlchemyWindow.uasset index 02c0b92a..770101e9 100644 --- a/Content/Scripts/AlchemySystem/AlchemyWindow.uasset +++ b/Content/Scripts/AlchemySystem/AlchemyWindow.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6231e042ec7d3f807fac8fd8d15ababea04d87fe6d286495adab0dbf7abbd956 -size 1457828 +oid sha256:3b268d096401ea2873b6e436b91422c8170cb2cf28defe327bf7d26cfa161980 +size 1594157 diff --git a/Content/Scripts/AlchemySystem/BP_AlchemyManager.uasset b/Content/Scripts/AlchemySystem/BP_AlchemyManager.uasset index 22b4c68d..578a8266 100644 --- a/Content/Scripts/AlchemySystem/BP_AlchemyManager.uasset +++ b/Content/Scripts/AlchemySystem/BP_AlchemyManager.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1dd68a6e77f0e55e548932a8a818875df93603a88277e20374d95a9a024cdda2 -size 2917697 +oid sha256:0aeb6b6df4525d2d7ecafd21ea48d038f6c8b2d07b2bb797d59052cf45d8097a +size 2916864 diff --git a/Content/Scripts/BP_TimeOfDay.uasset b/Content/Scripts/BP_TimeOfDay.uasset index 71d1ed48..717dbc45 100644 --- a/Content/Scripts/BP_TimeOfDay.uasset +++ b/Content/Scripts/BP_TimeOfDay.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d90417dd2848dbb816cd49bd1e7832817a862190e557f512af49236ce0961bfa -size 484795 +oid sha256:f1aa8faeb735c95d80c93356f8466d2d06e208f8ca14eba0c1f7f0043e5fe32e +size 484800 diff --git a/Content/Scripts/Bazar/BP_BazarNpcSpawnerComponent.uasset b/Content/Scripts/Bazar/BP_BazarNpcSpawnerComponent.uasset index 5f27e714..5c8ac3ba 100644 --- a/Content/Scripts/Bazar/BP_BazarNpcSpawnerComponent.uasset +++ b/Content/Scripts/Bazar/BP_BazarNpcSpawnerComponent.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ffd0d1c8942da249a5a54cd73d11450b1dd223a89a6f2a2f07cd5d2714205742 -size 220201 +oid sha256:d59f255728ed560a3ae0ff9dea16503b8f1913c8517b14b2dd39394d5e285453 +size 217746 diff --git a/Content/Scripts/InventorySystem/ItemManagerBP.uasset b/Content/Scripts/InventorySystem/ItemManagerBP.uasset index 2de59d16..f99946db 100644 --- a/Content/Scripts/InventorySystem/ItemManagerBP.uasset +++ b/Content/Scripts/InventorySystem/ItemManagerBP.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:60c2935f338b614ac485578ec4b44c26d2c5e347ad746f127684039e45d58dd5 -size 597617 +oid sha256:31988e5b3da55f01be8ebacbfc2bec3440b31790b62a4173e2fdbe4d638cd489 +size 605450 diff --git a/Content/Scripts/InventorySystem/Seed/BP_SeedCarousel.uasset b/Content/Scripts/InventorySystem/Seed/BP_SeedCarousel.uasset index 44ca5348..2fa27d86 100644 --- a/Content/Scripts/InventorySystem/Seed/BP_SeedCarousel.uasset +++ b/Content/Scripts/InventorySystem/Seed/BP_SeedCarousel.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f4f2c42790498cc5b2d20cb44c527e0a7e5d630ef6b69820312e66df7c16a576 -size 1261032 +oid sha256:b404db6f4ecccadcc556df0e9e42a794905bab1c3489c90beda49a36bcf9de93 +size 1256379 diff --git a/Content/ThirdPersonBP/Blueprints/BP_ThirdPersonCharacter.uasset b/Content/ThirdPersonBP/Blueprints/BP_ThirdPersonCharacter.uasset index 65674461..8aaa79f9 100644 --- a/Content/ThirdPersonBP/Blueprints/BP_ThirdPersonCharacter.uasset +++ b/Content/ThirdPersonBP/Blueprints/BP_ThirdPersonCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:923df9196e3cd5459cb75bad45317d672f7ef7aa95a2b0ebcc1a68bf1019326e -size 1420421 +oid sha256:92dc48e2b30426ced8b7f6893bc8e36560dc0d3676fa3bd2ad7cef50bcb04327 +size 1405082 diff --git a/Content/UI/MainUI.uasset b/Content/UI/MainUI.uasset index bb67c8bd..1be91066 100644 --- a/Content/UI/MainUI.uasset +++ b/Content/UI/MainUI.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:142c4296d8bd476e53b1c015d8ae64ecdd076e7d5aa4349119f3bc929e757911 -size 549150 +oid sha256:c2af5a7a546c72bd283cd66ddf065e761c28f8db38cee35bc5a5b8520c5712f0 +size 613295 diff --git a/Plugins/StatForge/Source/StatForge/Private/Components/StatForgeComponent.cpp b/Plugins/StatForge/Source/StatForge/Private/Components/StatForgeComponent.cpp index 48c485dc..bac009a8 100644 --- a/Plugins/StatForge/Source/StatForge/Private/Components/StatForgeComponent.cpp +++ b/Plugins/StatForge/Source/StatForge/Private/Components/StatForgeComponent.cpp @@ -236,6 +236,24 @@ bool UStatForgeComponent::RemoveGameplayStatEffect(FGuid EffectId) return false; } +void UStatForgeComponent::RemoveAllGameplayStatEffects() +{ + ActiveEffectsArray.Empty(); +} + +void UStatForgeComponent::ModifyGeDuration(FGuid EffectId, float NewRemainingDuration, float NewNextTickDuration) +{ + for (int32 i = ActiveEffectsArray.Num() - 1; i >= 0; --i) + { + if (ActiveEffectsArray[i].Handle == EffectId) + { + ActiveEffectsArray[i].RemainingDuration = NewRemainingDuration; + ActiveEffectsArray[i].NextTickDuration = NewNextTickDuration; + break; + } + } +} + bool UStatForgeComponent::HasStat(const FName& StatName) const { for (const FStatRuntimeDef& Stat : StatArray) diff --git a/Plugins/StatForge/Source/StatForge/Public/Components/StatForgeComponent.h b/Plugins/StatForge/Source/StatForge/Public/Components/StatForgeComponent.h index 5dd09bce..740423e8 100644 --- a/Plugins/StatForge/Source/StatForge/Public/Components/StatForgeComponent.h +++ b/Plugins/StatForge/Source/StatForge/Public/Components/StatForgeComponent.h @@ -123,6 +123,12 @@ protected: bool CanApplyEffect(const UGameplayStatEffect* StatEffect) const; bool CanTickEffect(const UGameplayStatEffect* StatEffect) const; + // CAUTION, only to be used inside AEleriGameState to load game + void RemoveAllGameplayStatEffects(); + void ModifyGeDuration(FGuid EffectId, float NewRemainingDuration, float NewNextTickDuration); + const TArray& GetStatArray() { return StatArray; } + const TArray& GetActiveEffectsArray() { return ActiveEffectsArray; } + UPROPERTY() TArray StatArray; @@ -136,4 +142,7 @@ protected: UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Stat Forge|Tags") FGameplayTagContainer CharacterGameplayTags; + + friend class AEleriGameState; + friend struct FSaveData; }; diff --git a/ProjectEleri.uproject b/ProjectEleri.uproject index 114e845c..c430b2cf 100644 --- a/ProjectEleri.uproject +++ b/ProjectEleri.uproject @@ -112,10 +112,6 @@ "Enabled": true, "MarketplaceURL": "https://unrealengineresources.com/plugins" }, - { - "Name": "GameplayAbilities", - "Enabled": true - }, { "Name": "UniversalCameraPlugin", "Enabled": true, diff --git a/Source/ProjectEleri/Data/EleriGlobalKeyValueStruct.h b/Source/ProjectEleri/Data/EleriGlobalKeyValueStruct.h new file mode 100644 index 00000000..35ba32de --- /dev/null +++ b/Source/ProjectEleri/Data/EleriGlobalKeyValueStruct.h @@ -0,0 +1,16 @@ + +#pragma once +#include "CoreMinimal.h" +#include "Engine/DataTable.h" + +#include "EleriGlobalKeyValueStruct.generated.h" + +USTRUCT(BlueprintType) +struct FEleriGlobalKeyValueStruct : public FTableRowBase +{ + GENERATED_BODY() + +public: + UPROPERTY(EditAnywhere, BlueprintReadWrite) + float Value; +}; diff --git a/Source/ProjectEleri/GameplayAbilities/Attributes/PrimaryAttributeSet.cpp b/Source/ProjectEleri/GameplayAbilities/Attributes/PrimaryAttributeSet.cpp deleted file mode 100644 index 16247005..00000000 --- a/Source/ProjectEleri/GameplayAbilities/Attributes/PrimaryAttributeSet.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - -#include "PrimaryAttributeSet.h" - -UPrimaryAttributeSet::UPrimaryAttributeSet() - : Energy(100.f) - , HungerSatiation(0.f) - , GatherDoubleDropChance(0.f) - , GatherHqDropChance(0.f) - , FriendPointsMultiplier(1.f) - , AlchemyMultiplier(1.f) - , BazarCustomerSpawnRate(6.f) - , BazarCustomerWill(0.33f) - , AlchemyExp(0.f) - , BotanyExp(0.f) - , GatheringExp(0.f) - , FlyingExp(0.f) - , BargainingExp(0.f) -{} - -void UPrimaryAttributeSet::PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue) { - Super::PreAttributeChange(Attribute, NewValue); - - if (Attribute == GetGatherDoubleDropChanceAttribute()) { - NewValue = FMath::Clamp(NewValue, 0.f, 100.f); - } - - if (Attribute == GetGatherHqDropChanceAttribute()) { - NewValue = FMath::Clamp(NewValue, 0.f, 100.f); - } - - if (Attribute == GetBazarCustomerSpawnRateAttribute()) - { - NewValue = FMath::Clamp(NewValue, 3.f, 6.f); - } - - if (Attribute == GetBazarCustomerWillAttribute()) - { - NewValue = FMath::Clamp(NewValue, 0.f, 1.f); - } - - if (IsExpAttribute(Attribute)) { - NewValue = FMath::Max(NewValue, 0.f); - } -} - -void UPrimaryAttributeSet::PreAttributeBaseChange(const FGameplayAttribute& Attribute, float& NewValue) const { - Super::PreAttributeBaseChange(Attribute, NewValue); - - if (Attribute == GetGatherDoubleDropChanceAttribute()) { - NewValue = FMath::Clamp(NewValue, 0.f, 100.f); - } - - if (Attribute == GetGatherHqDropChanceAttribute()) { - NewValue = FMath::Clamp(NewValue, 0.f, 100.f); - } - - if (Attribute == GetBazarCustomerSpawnRateAttribute()) - { - NewValue = FMath::Clamp(NewValue, 3.f, 6.f); - } - - if (Attribute == GetBazarCustomerWillAttribute()) - { - NewValue = FMath::Clamp(NewValue, 0.f, 1.f); - } - - if (IsExpAttribute(Attribute)) { - NewValue = FMath::Max(NewValue, 0.f); - } -} diff --git a/Source/ProjectEleri/GameplayAbilities/Attributes/PrimaryAttributeSet.h b/Source/ProjectEleri/GameplayAbilities/Attributes/PrimaryAttributeSet.h deleted file mode 100644 index 68f92bd7..00000000 --- a/Source/ProjectEleri/GameplayAbilities/Attributes/PrimaryAttributeSet.h +++ /dev/null @@ -1,94 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once - -#include "CoreMinimal.h" -#include "AttributeSet.h" -#include "AbilitySystemComponent.h" -#include "PrimaryAttributeSet.generated.h" - -// Uses macros from AttributeSet.h -#define ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \ - GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \ - GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \ - GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \ - GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName) - -/** - * - */ -UCLASS() -class PROJECTELERI_API UPrimaryAttributeSet : public UAttributeSet -{ - GENERATED_BODY() -public: - UPrimaryAttributeSet(); -public: - - UPROPERTY(BlueprintReadOnly, SaveGame) - FGameplayAttributeData Energy; - ATTRIBUTE_ACCESSORS(ThisClass, Energy) - - UPROPERTY(BlueprintReadOnly, SaveGame) - FGameplayAttributeData HungerSatiation; - ATTRIBUTE_ACCESSORS(ThisClass, HungerSatiation) - - UPROPERTY(BlueprintReadOnly, SaveGame) - FGameplayAttributeData GatherDoubleDropChance; - ATTRIBUTE_ACCESSORS(ThisClass, GatherDoubleDropChance) - - UPROPERTY(BlueprintReadOnly, SaveGame) - FGameplayAttributeData GatherHqDropChance; - ATTRIBUTE_ACCESSORS(ThisClass, GatherHqDropChance) - - UPROPERTY(BlueprintReadOnly, SaveGame) - FGameplayAttributeData FriendPointsMultiplier; - ATTRIBUTE_ACCESSORS(ThisClass, FriendPointsMultiplier) - - UPROPERTY(BlueprintReadOnly, SaveGame) - FGameplayAttributeData AlchemyMultiplier; - ATTRIBUTE_ACCESSORS(ThisClass, AlchemyMultiplier) - - UPROPERTY(BlueprintReadOnly, SaveGame) - FGameplayAttributeData BazarCustomerSpawnRate; - ATTRIBUTE_ACCESSORS(ThisClass, BazarCustomerSpawnRate) - - UPROPERTY(BlueprintReadOnly, SaveGame) - FGameplayAttributeData BazarCustomerWill; - ATTRIBUTE_ACCESSORS(ThisClass, BazarCustomerWill) - - - UPROPERTY(BlueprintReadOnly, SaveGame) - FGameplayAttributeData AlchemyExp; - ATTRIBUTE_ACCESSORS(ThisClass, AlchemyExp) - - UPROPERTY(BlueprintReadOnly, SaveGame) - FGameplayAttributeData BotanyExp; - ATTRIBUTE_ACCESSORS(ThisClass, BotanyExp) - - UPROPERTY(BlueprintReadOnly, SaveGame) - FGameplayAttributeData GatheringExp; - ATTRIBUTE_ACCESSORS(ThisClass, GatheringExp) - - UPROPERTY(BlueprintReadOnly, SaveGame) - FGameplayAttributeData FlyingExp; - ATTRIBUTE_ACCESSORS(ThisClass, FlyingExp) - - UPROPERTY(BlueprintReadOnly, SaveGame) - FGameplayAttributeData BargainingExp; - ATTRIBUTE_ACCESSORS(ThisClass, BargainingExp) - - virtual void PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue) override; - virtual void PreAttributeBaseChange(const FGameplayAttribute& Attribute, float& NewValue) const override; - -public: - - static bool IsExpAttribute(const FGameplayAttribute& Attribute) { - return - Attribute == GetAlchemyExpAttribute() || - Attribute == GetBotanyExpAttribute() || - Attribute == GetGatheringExpAttribute() || - Attribute == GetFlyingExpAttribute() || - Attribute == GetBargainingExpAttribute(); - } -}; diff --git a/Source/ProjectEleri/GameplayAbilities/EleriAbilitySystemComponent.cpp b/Source/ProjectEleri/GameplayAbilities/EleriAbilitySystemComponent.cpp deleted file mode 100644 index f65b2569..00000000 --- a/Source/ProjectEleri/GameplayAbilities/EleriAbilitySystemComponent.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - -#include "EleriAbilitySystemComponent.h" -#include "GameplayEffect.h" -#include "Attributes/PrimaryAttributeSet.h" -#include "ProjectEleri/System/MainBlueprintFunctionLibrary.h" -#include "ProjectEleri/Settings/EleriGameSettings.h" - - - -void UEleriAbilitySystemComponent::AddExp(UObject* WorldContextObject, FGameplayAttribute GameplayAttribute, float Amount) { - -} - -void UEleriAbilitySystemComponent::AddProfessionExp(UObject* WorldContextObject, EProfessionType Profession, float Amount) { - AddExp(WorldContextObject, GetGameplayAttributeForProfession(Profession), Amount); - - if (UEleriAbilitySystemComponent* ASC = UMainBlueprintFunctionLibrary::GetAbilitySystemComponentFromPlayer(WorldContextObject)) { - if (FActiveGameplayEffectHandle* ActiveEffectHandle = ASC->ProfessionModifierEffectsContainer.Find(Profession)) { - ASC->SetActiveGameplayEffectLevel(*ActiveEffectHandle, GetProfessionLevel(WorldContextObject, Profession)); - } - } -} - -int32 UEleriAbilitySystemComponent::GetProfessionLevel(UObject* WorldContextObject, EProfessionType Profession) { - if (UEleriAbilitySystemComponent* ASC = UMainBlueprintFunctionLibrary::GetAbilitySystemComponentFromPlayer(WorldContextObject)) { - if (const UEleriGameSettings* GameSettings = GetDefault()) { - switch (Profession) { - case EProfessionType::ALCHEMY: - return GameSettings->GetProfessionLevelForExp(ASC->GetNumericAttribute(UPrimaryAttributeSet::GetAlchemyExpAttribute())); - case EProfessionType::BOTANY: - return GameSettings->GetProfessionLevelForExp(ASC->GetNumericAttribute(UPrimaryAttributeSet::GetBotanyExpAttribute())); - case EProfessionType::GATHERING: - return GameSettings->GetProfessionLevelForExp(ASC->GetNumericAttribute(UPrimaryAttributeSet::GetGatheringExpAttribute())); - case EProfessionType::FLYING: - return GameSettings->GetProfessionLevelForExp(ASC->GetNumericAttribute(UPrimaryAttributeSet::GetFlyingExpAttribute())); - default: - break; - } - } - } - return 0; -} - -void UEleriAbilitySystemComponent::BeginPlay() { - Super::BeginPlay(); - - GetGameplayAttributeValueChangeDelegate(UPrimaryAttributeSet::GetEnergyAttribute()).AddUObject(this, &UEleriAbilitySystemComponent::AttributeChanged); - GetGameplayAttributeValueChangeDelegate(UPrimaryAttributeSet::GetHungerSatiationAttribute()).AddUObject(this, &UEleriAbilitySystemComponent::AttributeChanged); - GetGameplayAttributeValueChangeDelegate(UPrimaryAttributeSet::GetGatherDoubleDropChanceAttribute()).AddUObject(this, &UEleriAbilitySystemComponent::AttributeChanged); - GetGameplayAttributeValueChangeDelegate(UPrimaryAttributeSet::GetGatherHqDropChanceAttribute()).AddUObject(this, &UEleriAbilitySystemComponent::AttributeChanged); - GetGameplayAttributeValueChangeDelegate(UPrimaryAttributeSet::GetFriendPointsMultiplierAttribute()).AddUObject(this, &UEleriAbilitySystemComponent::AttributeChanged); - - - for (auto Effect : InitialEffects) { - BP_ApplyGameplayEffectToSelf(Effect, 1.f, MakeEffectContext()); - } - for (auto ProfModEffect : ProfessionModifierEffects) { - FActiveGameplayEffectHandle EffectHandle = BP_ApplyGameplayEffectToSelf(ProfModEffect.Value, 1.f, MakeEffectContext()); - ProfessionModifierEffectsContainer.Add(ProfModEffect.Key, EffectHandle); - } -} - -void UEleriAbilitySystemComponent::AttributeChanged(const FOnAttributeChangeData& AttributeChangeData) { - OnAttributeChange.Broadcast(AttributeChangeData.Attribute, AttributeChangeData.NewValue, AttributeChangeData.OldValue); -} - -FGameplayAttribute UEleriAbilitySystemComponent::GetGameplayAttributeForProfession(EProfessionType Profession) { - switch (Profession) { - case EProfessionType::ALCHEMY: - return UPrimaryAttributeSet::GetAlchemyExpAttribute(); - case EProfessionType::BOTANY: - return UPrimaryAttributeSet::GetBotanyExpAttribute(); - case EProfessionType::GATHERING: - return UPrimaryAttributeSet::GetGatheringExpAttribute(); - case EProfessionType::FLYING: - return UPrimaryAttributeSet::GetFlyingExpAttribute(); - default: - break; - } - return FGameplayAttribute(); -} diff --git a/Source/ProjectEleri/GameplayAbilities/EleriAbilitySystemComponent.h b/Source/ProjectEleri/GameplayAbilities/EleriAbilitySystemComponent.h deleted file mode 100644 index 65cfd73a..00000000 --- a/Source/ProjectEleri/GameplayAbilities/EleriAbilitySystemComponent.h +++ /dev/null @@ -1,59 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once - -#include "CoreMinimal.h" -#include "AbilitySystemComponent.h" - -#include "EleriAbilitySystemComponent.generated.h" - -class UGameplayEffect; - -DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnAttributeChange, FGameplayAttribute, GameplayAttribute, float, NewValue, float, OldValue); - -UENUM(BlueprintType) -enum class EProfessionType : uint8 { - ALCHEMY UMETA(DisplayName="Alchemy"), - BOTANY UMETA(DisplayName = "Botany"), - GATHERING UMETA(DisplayName = "Gathering"), - FLYING UMETA(DisplayName = "Flying"), - MAX UMETA(Hidden) -}; - -/** - * - */ -UCLASS() -class PROJECTELERI_API UEleriAbilitySystemComponent : public UAbilitySystemComponent -{ - GENERATED_BODY() -public: - - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly) - TArray> InitialEffects; - - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly) - TMap> ProfessionModifierEffects; - - UPROPERTY(BlueprintAssignable) - FOnAttributeChange OnAttributeChange; - - UFUNCTION(BlueprintCallable, Category = "Eleri Ability System", meta = (WorldContext = "WorldContextObject")) - static void AddExp(UObject* WorldContextObject, FGameplayAttribute GameplayAttribute, float Amount); - - UFUNCTION(BlueprintCallable, Category = "Eleri Ability System", meta = (WorldContext = "WorldContextObject")) - static void AddProfessionExp(UObject* WorldContextObject, EProfessionType Profession, float Amount); - - UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Eleri Ability System", meta = (WorldContext = "WorldContextObject")) - static int32 GetProfessionLevel(UObject* WorldContextObject, EProfessionType Profession); - -protected: - UPROPERTY() - TMap ProfessionModifierEffectsContainer; - - virtual void BeginPlay() override; - - void AttributeChanged(const FOnAttributeChangeData& AttributeChangeData); - - static FGameplayAttribute GetGameplayAttributeForProfession(EProfessionType Profession); -}; diff --git a/Source/ProjectEleri/Private/AlchemyManager.cpp b/Source/ProjectEleri/Private/AlchemyManager.cpp index fceddfd2..3ae295f8 100644 --- a/Source/ProjectEleri/Private/AlchemyManager.cpp +++ b/Source/ProjectEleri/Private/AlchemyManager.cpp @@ -6,6 +6,8 @@ #include "EleriPlayerController.h" #include "EnhancedInputComponent.h" #include "EnhancedInputSubsystems.h" +#include "Components/StatForgeComponent.h" +#include "ProjectEleri/Data/StatDefinitions.h" #include "ProjectEleri/Public/InventoryComponent.h" #include "ProjectEleri/Items/DataAssets/ItemDataAsset.h" #include "ProjectEleri/System/MainBlueprintFunctionLibrary.h" @@ -34,10 +36,10 @@ void AAlchemyManager::CalculateRewardStack() { } void AAlchemyManager::CalculateFinalMultiplier() { - UEleriAbilitySystemComponent* ASC = UMainBlueprintFunctionLibrary::GetAbilitySystemComponentFromPlayer(this); - check(ASC); + UStatForgeComponent* StatForgeComponent = UMainBlueprintFunctionLibrary::GetStatForgeComponentFromPlayer(this); + check(StatForgeComponent); - FinalHqMultiplier = ASC->GetNumericAttribute(UPrimaryAttributeSet::GetAlchemyMultiplierAttribute()); + FinalHqMultiplier = StatForgeComponent->GetStatValue(FStat::AlchemyMultiplier); if(FinalHqMultiplier <= 0.f) FinalHqMultiplier = 1.f; diff --git a/Source/ProjectEleri/Private/EleriGameState.cpp b/Source/ProjectEleri/Private/EleriGameState.cpp index a2626dad..82c585c8 100644 --- a/Source/ProjectEleri/Private/EleriGameState.cpp +++ b/Source/ProjectEleri/Private/EleriGameState.cpp @@ -6,6 +6,7 @@ #include "MyCharacter.h" #include "../System/Subsystem/ObjectPersistenceSubsystem.h" #include "EngineUtils.h" +#include "Components/StatForgeComponent.h" #include "ProjectEleri/System/MainBlueprintFunctionLibrary.h" #include "ProjectEleri/GameObjects/EleriBaseActor.h" @@ -127,23 +128,23 @@ void AEleriGameState::PropagateSaveData(UEleriSaveGame* InSaveData) { //Load player data PlayerCharacter->SetActorTransform(SaveData.PlayerTransform); - if (UEleriAbilitySystemComponent* ASC = UMainBlueprintFunctionLibrary::GetAbilitySystemComponentFromPlayer(GetWorld())) { - TArray CollectedEffects = ASC->GetActiveEffects(FGameplayEffectQuery::MakeQuery_MatchNoEffectTags(FGameplayTagContainer())); - for (int32 i = CollectedEffects.Num() - 1; i >= 0; --i) { - ASC->RemoveActiveGameplayEffect(CollectedEffects[i], -9999); + if (UStatForgeComponent* StatForgeComponent = UMainBlueprintFunctionLibrary::GetStatForgeComponentFromPlayer(GetWorld())) { + StatForgeComponent->RemoveAllGameplayStatEffects(); + + for (const FStatRuntimeDef& Stat : SaveData.StatData) { + FGameplayStatEffectMod Mod; + Mod.AffectedStat = Stat.StatDef.StatName; + Mod.CalculationType = EGameplayStatEffectModCalculation::Flat; + Mod.FlatValue = Stat.BaseValue; + Mod.ModOperation = EModOperation::Override; + TMap DataValueMap; + StatForgeComponent->ApplyModToStat(Mod, DataValueMap); } - for (auto Attr : SaveData.GameplayAttributes) { - ASC->SetNumericAttributeBase(Attr.Attribute, Attr.BaseValue); - } - - for (auto SavedGe : SaveData.GameplayEffects) { - FGameplayEffectSpecHandle GeHandle = ASC->MakeOutgoingSpec(SavedGe.EffectClass, 1.f, ASC->MakeEffectContext()); - if (!SavedGe.bIsInfinite) { - GeHandle.Data->SetDuration(SavedGe.RemainingTime, false); - } - GeHandle.Data->SetStackCount(SavedGe.StackCount); - ASC->ApplyGameplayEffectSpecToSelf(*GeHandle.Data.Get()); + for (const FActiveGameplayStatEffect_SerializedData& SavedGe : SaveData.GameEffects) + { + const FGuid Id = StatForgeComponent->ApplyGameplayStatEffect(SavedGe.GameplayEffectClass, SavedGe.DataValueMap, SavedGe.StackCount); + StatForgeComponent->ModifyGeDuration(Id, SavedGe.RemainingDuration, SavedGe.NextTickDuration); } } } diff --git a/Source/ProjectEleri/Private/EleriSaveGame.cpp b/Source/ProjectEleri/Private/EleriSaveGame.cpp index 72e9becc..5297a327 100644 --- a/Source/ProjectEleri/Private/EleriSaveGame.cpp +++ b/Source/ProjectEleri/Private/EleriSaveGame.cpp @@ -5,8 +5,8 @@ #include "Kismet/GameplayStatics.h" #include "EngineUtils.h" +#include "Components/StatForgeComponent.h" #include "ProjectEleri/System/MainBlueprintFunctionLibrary.h" -#include "ProjectEleri/GameplayAbilities/EleriAbilitySystemComponent.h" #include "ProjectEleri/GameObjects/EleriBaseActor.h" void FSaveData::Initialize() @@ -18,8 +18,8 @@ void FSaveData::Initialize() PlacedActors.Empty(); ActorSaveData.Empty(); EventDataMap.Empty(); - GameplayAttributes.Empty(); - GameplayEffects.Empty(); + StatData.Empty(); + GameEffects.Empty(); } void FSaveData::SaveQuests(const TArray& Quests) { @@ -93,35 +93,22 @@ void FSaveData::SetPlayerData(const UWorld* World) { void FSaveData::SetAbilitySystemData(const UWorld* World) { if (!World) return; - UEleriAbilitySystemComponent* ASC = UMainBlueprintFunctionLibrary::GetAbilitySystemComponentFromPlayer(World); - if (!ASC) return; - - for (auto Attr : ASC->GetSpawnedAttributes()) { - for (TFieldIterator Prop(Attr->GetClass()); Prop; ++Prop) { - if (FGameplayAttribute AttrData = FGameplayAttribute(*Prop); AttrData.IsValid()) { - FAbilitySystemSerializedData_Attribute AttrSaveDat; - AttrSaveDat.Attribute = AttrData; - AttrSaveDat.BaseValue = ASC->GetNumericAttributeBase(AttrData); - - GameplayAttributes.Add(AttrSaveDat); - } - } + UStatForgeComponent* StatForgeComponent = UMainBlueprintFunctionLibrary::GetStatForgeComponentFromPlayer(World); + if (!StatForgeComponent) return; + + for (const FStatRuntimeDef& StatRuntimeDef : StatForgeComponent->GetStatArray()) + { + StatData.Add(StatRuntimeDef); } - TArray CollectedEffects = ASC->GetActiveEffects(FGameplayEffectQuery::MakeQuery_MatchNoEffectTags(FGameplayTagContainer())); - for (auto Eff : CollectedEffects) { - const FActiveGameplayEffect* Effect = ASC->GetActiveGameplayEffect(Eff); - if (!Effect) continue; - - FAbilitySystemSerializedData_Effect EffData; - EffData.EffectClass = Effect->Spec.Def->GetClass(); - EffData.bIsInfinite = Effect->Spec.Duration == FGameplayEffectConstants::INFINITE_DURATION; - EffData.StackCount = Effect->Spec.GetStackCount(); - - if (!EffData.bIsInfinite) { - EffData.RemainingTime = Effect->GetTimeRemaining(World->GetWorld()->GetTimeSeconds()); - } - - GameplayEffects.Add(EffData); + for (const FActiveGameplayStatEffect& ActiveEffect : StatForgeComponent->GetActiveEffectsArray()) + { + FActiveGameplayStatEffect_SerializedData SerializedData; + SerializedData.GameplayEffectClass = ActiveEffect.GameplayEffectClass; + SerializedData.StackCount = ActiveEffect.StackCount; + SerializedData.DataValueMap = ActiveEffect.GameplayEffectInstance->GetDataValueMap(); + SerializedData.RemainingDuration = ActiveEffect.RemainingDuration; + SerializedData.NextTickDuration = ActiveEffect.NextTickDuration; + GameEffects.Add(SerializedData); } } diff --git a/Source/ProjectEleri/Private/MyCharacter.cpp b/Source/ProjectEleri/Private/MyCharacter.cpp index d588a025..6684cddb 100644 --- a/Source/ProjectEleri/Private/MyCharacter.cpp +++ b/Source/ProjectEleri/Private/MyCharacter.cpp @@ -49,8 +49,6 @@ AMyCharacter::AMyCharacter() InteractableOverlapMesh->SetRelativeScale3D(FVector(2.0f, 2.0f, 4.0f)); InteractableOverlapMesh->SetGenerateOverlapEvents(true); - EleriAbilitySystemComponent = CreateDefaultSubobject(TEXT("EleriAbilitySystemComponent")); - PrimaryAttributeSet = CreateDefaultSubobject(TEXT("PrimaryAttributeSet")); StatForgeComponent = CreateDefaultSubobject(TEXT("StatForgeComponent")); } diff --git a/Source/ProjectEleri/ProjectEleri.Build.cs b/Source/ProjectEleri/ProjectEleri.Build.cs index 22cbdfea..884fc319 100644 --- a/Source/ProjectEleri/ProjectEleri.Build.cs +++ b/Source/ProjectEleri/ProjectEleri.Build.cs @@ -25,7 +25,6 @@ public class ProjectEleri : ModuleRules "HTTP", "Json", "JsonUtilities", - "GameplayAbilities", "GameplayTasks", "UniversalCameraPlugin", "StateTreeModule", diff --git a/Source/ProjectEleri/Public/EleriSaveGame.h b/Source/ProjectEleri/Public/EleriSaveGame.h index 65cf81a1..be2d598a 100644 --- a/Source/ProjectEleri/Public/EleriSaveGame.h +++ b/Source/ProjectEleri/Public/EleriSaveGame.h @@ -13,31 +13,30 @@ #include "ProjectEleri/GameEventSystem/GameEventSubsystem.h" #include "AttributeSet.h" #include "GameplayEffect.h" +#include "Data/GameplayStatEffect.h" +#include "Data/StatForgeDefs.h" #include "ProjectEleri/System/TimeOfDayStruct.h" #include "EleriSaveGame.generated.h" USTRUCT() -struct FAbilitySystemSerializedData_Attribute { +struct FActiveGameplayStatEffect_SerializedData { GENERATED_BODY() public: - UPROPERTY() - FGameplayAttribute Attribute; - UPROPERTY() - float BaseValue = 0; -}; -USTRUCT() -struct FAbilitySystemSerializedData_Effect { - GENERATED_BODY() -public: UPROPERTY() - TSubclassOf EffectClass; + TSubclassOf GameplayEffectClass; + UPROPERTY() - float RemainingTime = 0; + TMap DataValueMap; + UPROPERTY() int32 StackCount = 1; + UPROPERTY() - bool bIsInfinite = false; + float RemainingDuration = -1.f; + + UPROPERTY() + float NextTickDuration = -1.f; }; USTRUCT(BlueprintType) @@ -70,10 +69,11 @@ struct FSaveData { UPROPERTY() FTransform PlayerTransform; + UPROPERTY() - TArray GameplayAttributes; + TArray GameEffects; UPROPERTY() - TArray GameplayEffects; + TArray StatData; void Initialize(); diff --git a/Source/ProjectEleri/Public/MyCharacter.h b/Source/ProjectEleri/Public/MyCharacter.h index 8d933147..2430754e 100644 --- a/Source/ProjectEleri/Public/MyCharacter.h +++ b/Source/ProjectEleri/Public/MyCharacter.h @@ -10,11 +10,8 @@ #include "Components/BoxComponent.h" #include "GlobalEnums.h" #include "Camera/CameraComponent.h" -#include "Components/ChildActorComponent.h" #include "Delegates/Delegate.h" #include "AbilitySystemInterface.h" -#include "ProjectEleri/GameplayAbilities/EleriAbilitySystemComponent.h" -#include "ProjectEleri/GameplayAbilities/Attributes/PrimaryAttributeSet.h" #include "ProjectEleri/Public/Interface/SaveableObjectInterface.h" #include "MyCharacter.generated.h" @@ -34,7 +31,7 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnInteractExit); DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnBookRenderTexUpdate); UCLASS() -class PROJECTELERI_API AMyCharacter : public ACharacter, public IAbilitySystemInterface, public ISaveableObjectInterface +class PROJECTELERI_API AMyCharacter : public ACharacter, public ISaveableObjectInterface { GENERATED_BODY() @@ -73,16 +70,10 @@ protected: UPROPERTY() float CachedHalfHeight; - - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly) - UEleriAbilitySystemComponent* EleriAbilitySystemComponent; UPROPERTY(EditDefaultsOnly, BlueprintReadOnly) UStatForgeComponent* StatForgeComponent; - UPROPERTY() - UPrimaryAttributeSet* PrimaryAttributeSet; - UPROPERTY() TObjectPtr CameraRef; @@ -107,11 +98,6 @@ public: //----- ISaveableObjectInterface ----- virtual FActorSaveData RequestSave() override; virtual void RequestLoad(FActorSaveData& Data) override; - - UFUNCTION(BlueprintCallable, BlueprintPure) - virtual class UAbilitySystemComponent* GetAbilitySystemComponent() const override { return EleriAbilitySystemComponent; } - UFUNCTION(BlueprintCallable, BlueprintPure) - UPrimaryAttributeSet* GetPrimaryAttributeSet() { return PrimaryAttributeSet; } UFUNCTION(BlueprintCallable, BlueprintPure) UStatForgeComponent* GetStatForgeComponent() const { return StatForgeComponent; } diff --git a/Source/ProjectEleri/Settings/EleriGameSettings.cpp b/Source/ProjectEleri/Settings/EleriGameSettings.cpp index 5d80fc73..d5bf8d9a 100644 --- a/Source/ProjectEleri/Settings/EleriGameSettings.cpp +++ b/Source/ProjectEleri/Settings/EleriGameSettings.cpp @@ -5,6 +5,7 @@ #include "ProjectEleri/Items/DataAssets/ItemDataAsset.h" #include "ProjectEleri/Items/ItemDatabase.h" #include "Kismet/GameplayStatics.h" +#include "ProjectEleri/Data/EleriGlobalKeyValueStruct.h" bool UEleriGameSettings::GetCameraZoom(FGameplayTag Tag, FVector& OutBoomLength) { if (const UEleriGameSettings* Settings = GetDefault()) { @@ -55,3 +56,18 @@ int32 UEleriGameSettings::GetProfessionLevelForExp(float Exp) { return 0; } + +float UEleriGameSettings::GetGlobalKeyValue(const FName& Key) +{ + if (!GetEleriGameSettings()->GlobalSettingsDataSheet.IsValid()) + { + GetEleriGameSettings()->GlobalSettingsDataSheet.LoadSynchronous(); + } + + if (const FEleriGlobalKeyValueStruct* RowPtr = GetEleriGameSettings()->GlobalSettingsDataSheet->FindRow(Key, TEXT(""))) + { + return RowPtr->Value; + } + + return -1.f; +} diff --git a/Source/ProjectEleri/Settings/EleriGameSettings.h b/Source/ProjectEleri/Settings/EleriGameSettings.h index a00b836d..aede363c 100644 --- a/Source/ProjectEleri/Settings/EleriGameSettings.h +++ b/Source/ProjectEleri/Settings/EleriGameSettings.h @@ -6,9 +6,12 @@ #include "Engine/DeveloperSettings.h" #include "GameplayTagContainer.h" #include "Data/GameplayStatEffect.h" +#include "Templates/SubclassOf.h" +#include "UObject/SoftObjectPtr.h" #include "EleriGameSettings.generated.h" +class UDataTable; class UNpcDataAsset; class UNpcScheduleAsset; class UItemDataAsset; @@ -37,6 +40,9 @@ public: UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category = "Ai") TArray> NpcDataAssets; + + UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category = "Ability System|Settings") + TSoftObjectPtr GlobalSettingsDataSheet; public: @@ -57,4 +63,7 @@ public: UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Ability System|Professions") static int32 GetProfessionLevelForExp(float Exp); + UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Eleri Game Settingss", meta = (AutoCreateRefTerm = "Key")) + static float GetGlobalKeyValue(const FName& Key); + }; diff --git a/Source/ProjectEleri/System/MainBlueprintFunctionLibrary.h b/Source/ProjectEleri/System/MainBlueprintFunctionLibrary.h index 59dcd156..e341bcd2 100644 --- a/Source/ProjectEleri/System/MainBlueprintFunctionLibrary.h +++ b/Source/ProjectEleri/System/MainBlueprintFunctionLibrary.h @@ -43,12 +43,6 @@ public: UFUNCTION(BlueprintCallable, Category = "Eleri", meta=(WorldContext="WorldContextObject")) static UMainGameWidget* GetMainGameWidget(UObject* WorldContextObject); - - UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Eleri", meta = (WorldContext = "WorldContextObject")) - static UEleriAbilitySystemComponent* GetAbilitySystemComponentFromActor(const AActor* Actor); - - UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Eleri", meta = (WorldContext = "WorldContextObject")) - static UEleriAbilitySystemComponent* GetAbilitySystemComponentFromPlayer(const UObject* WorldContextObject); UFUNCTION(BlueprintCallable, Category = "Eleri") static ARemovableStaticMeshActor* SpawnPlaceable(UWorld* World, UClass* Class, FTransform Transform, FVector ScaleOverride); @@ -79,8 +73,16 @@ public: // STATS UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Eleri|Stats") - static UStatForgeComponent* GetStatForgeComponentFromActor(AActor* Actor); + static UStatForgeComponent* GetStatForgeComponentFromActor(const AActor* Actor); + + UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Eleri|Stats", meta = (WorldContext = "WorldContext")) + static UStatForgeComponent* GetStatForgeComponentFromPlayer(const UObject* WorldContext); UFUNCTION(BlueprintCallable, Category = "Eleri|Stats", meta = (WorldContext = "WorldContext")) static void ModifyExp(const UObject* WorldContext, const EExpType ExpType, const float Amount); + + + // MATH + UFUNCTION(BlueprintPure, Category = "Eleri|Math") + static float NegateFloat(const float& Value) { return Value * -1.f; } }; diff --git a/Source/ProjectEleri/System/MainlBlueprintFunctionLibrary.cpp b/Source/ProjectEleri/System/MainlBlueprintFunctionLibrary.cpp index 7d3dd93e..e466a556 100644 --- a/Source/ProjectEleri/System/MainlBlueprintFunctionLibrary.cpp +++ b/Source/ProjectEleri/System/MainlBlueprintFunctionLibrary.cpp @@ -15,7 +15,6 @@ #include "ProjectEleri/GameObjects/BaseCharacter.h" #include "Runtime/Online/HTTP/Public/HttpModule.h" #include "ProjectEleri/Settings/EleriGameSettings.h" -#include "ProjectEleri/GameplayAbilities/EleriAbilitySystemComponent.h" void UMainBlueprintFunctionLibrary::PostFeedback(const FString& Message) { auto request = FHttpModule::Get().CreateRequest(); @@ -54,22 +53,6 @@ UMainGameWidget* UMainBlueprintFunctionLibrary::GetMainGameWidget(UObject* World return nullptr; } -UEleriAbilitySystemComponent* UMainBlueprintFunctionLibrary::GetAbilitySystemComponentFromActor(const AActor* Actor) { - if (!IsValid(Actor) || !Actor->GetWorld()) - return nullptr; - return Actor->GetComponentByClass(); -} - -UEleriAbilitySystemComponent* UMainBlueprintFunctionLibrary::GetAbilitySystemComponentFromPlayer(const UObject* WorldContextObject) { - if (!WorldContextObject || !WorldContextObject->GetWorld()) - return nullptr; - if (ACharacter* PlayerChar = UGameplayStatics::GetPlayerCharacter(WorldContextObject, 0)) { - return PlayerChar->GetComponentByClass(); - } - return nullptr; -} - - ARemovableStaticMeshActor* UMainBlueprintFunctionLibrary::SpawnPlaceable(UWorld* World, UClass* Class, FTransform Transform, FVector ScaleOverride) { Transform.SetScale3D(FVector::OneVector); return World->SpawnActor(Class, Transform, FActorSpawnParameters()); @@ -168,11 +151,18 @@ float UMainBlueprintFunctionLibrary::GetCharacterHeight(const UObject* WorldCont return 0.f; } -UStatForgeComponent* UMainBlueprintFunctionLibrary::GetStatForgeComponentFromActor(AActor* Actor) +UStatForgeComponent* UMainBlueprintFunctionLibrary::GetStatForgeComponentFromActor(const AActor* Actor) { if (!Actor) return nullptr; - if (const AMyCharacter* MyCharacter = Cast(Actor)) + return Actor->GetComponentByClass(); +} + +UStatForgeComponent* UMainBlueprintFunctionLibrary::GetStatForgeComponentFromPlayer(const UObject* WorldContext) +{ + if (!WorldContext) return nullptr; + + if (const AMyCharacter* MyCharacter = Cast(UGameplayStatics::GetPlayerCharacter(WorldContext, 0))) { return MyCharacter->GetStatForgeComponent(); } @@ -184,7 +174,7 @@ void UMainBlueprintFunctionLibrary::ModifyExp(const UObject* WorldContext, const { if (!WorldContext || !WorldContext->GetWorld()) return; - UStatForgeComponent* StatForgeComponent = GetStatForgeComponentFromActor(UGameplayStatics::GetPlayerCharacter(WorldContext, 0)); + UStatForgeComponent* StatForgeComponent = GetStatForgeComponentFromPlayer(WorldContext); if (!StatForgeComponent) return; const UEleriGameSettings* GameSettings = UEleriGameSettings::GetEleriGameSettings();