feat: initial commit, only bugs remaining
This commit is contained in:
		
							
								
								
									
										140
									
								
								Source/UTAD_UI/SkillTree/CharacterStatsComponent.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										140
									
								
								Source/UTAD_UI/SkillTree/CharacterStatsComponent.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,140 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "CoreMinimal.h" | ||||
| #include "Components/ActorComponent.h" | ||||
| #include "CharacterStatsComponent.generated.h" | ||||
|  | ||||
| DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnHealthChanged, float, CurrentHealth, float, MaxHealth); | ||||
| DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnDamageChanged, float, CurrentDamage); | ||||
| DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnSpeedChanged, float, CurrentSpeed); | ||||
| DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnStatsUpdated); | ||||
|  | ||||
| UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) | ||||
| class UTAD_UI_API UCharacterStatsComponent : public UActorComponent | ||||
| { | ||||
|     GENERATED_BODY() | ||||
|  | ||||
| public: | ||||
|     UCharacterStatsComponent(); | ||||
|  | ||||
| protected: | ||||
|     virtual void BeginPlay() override; | ||||
|  | ||||
|     // Base stats (without any bonuses) | ||||
|     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Base Stats") | ||||
|     float BaseMaxHealth; | ||||
|  | ||||
|     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Base Stats") | ||||
|     float BaseDamage; | ||||
|  | ||||
|     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Base Stats") | ||||
|     float BaseSpeed; | ||||
|  | ||||
|     // Current values | ||||
|     UPROPERTY(BlueprintReadOnly, Category = "Current Stats") | ||||
|     float CurrentHealth; | ||||
|  | ||||
|     // Calculated stats (base + bonuses) | ||||
|     UPROPERTY(BlueprintReadOnly, Category = "Current Stats") | ||||
|     float MaxHealth; | ||||
|  | ||||
|     UPROPERTY(BlueprintReadOnly, Category = "Current Stats") | ||||
|     float CurrentDamage; | ||||
|  | ||||
|     UPROPERTY(BlueprintReadOnly, Category = "Current Stats") | ||||
|     float CurrentSpeed; | ||||
|  | ||||
|     // Skill tree bonuses (flat bonuses) | ||||
|     UPROPERTY(BlueprintReadOnly, Category = "Skill Bonuses") | ||||
|     float SkillHealthBonus; | ||||
|  | ||||
|     UPROPERTY(BlueprintReadOnly, Category = "Skill Bonuses") | ||||
|     float SkillDamageBonus; | ||||
|  | ||||
|     UPROPERTY(BlueprintReadOnly, Category = "Skill Bonuses") | ||||
|     float SkillSpeedBonus; | ||||
|  | ||||
|     // Skill tree bonuses (percentage bonuses) | ||||
|     UPROPERTY(BlueprintReadOnly, Category = "Skill Bonuses") | ||||
|     float SkillHealthBonusPercent; | ||||
|  | ||||
|     UPROPERTY(BlueprintReadOnly, Category = "Skill Bonuses") | ||||
|     float SkillDamageBonusPercent; | ||||
|  | ||||
|     UPROPERTY(BlueprintReadOnly, Category = "Skill Bonuses") | ||||
|     float SkillSpeedBonusPercent; | ||||
|  | ||||
| public: | ||||
|     // Initialize stats | ||||
|     UFUNCTION(BlueprintCallable, Category = "Character Stats") | ||||
|     void InitializeStats(); | ||||
|  | ||||
|     // Update stats from skill tree | ||||
|     UFUNCTION(BlueprintCallable, Category = "Character Stats") | ||||
|     void UpdateStatsFromSkillTree(); | ||||
|  | ||||
|     // Called when a skill is purchased | ||||
|     UFUNCTION() | ||||
|     void OnSkillPurchased(FName SkillID); | ||||
|  | ||||
|     // Calculate final stats | ||||
|     UFUNCTION(BlueprintCallable, Category = "Character Stats") | ||||
|     void RecalculateStats(); | ||||
|  | ||||
|     // Getters for current stats | ||||
|     UFUNCTION(BlueprintPure, Category = "Character Stats") | ||||
|     float GetCurrentHealth() const { return CurrentHealth; } | ||||
|  | ||||
|     UFUNCTION(BlueprintPure, Category = "Character Stats") | ||||
|     float GetMaxHealth() const { return MaxHealth; } | ||||
|  | ||||
|     UFUNCTION(BlueprintPure, Category = "Character Stats") | ||||
|     float GetHealthPercentage() const { return MaxHealth > 0 ? CurrentHealth / MaxHealth : 0.0f; } | ||||
|  | ||||
|     UFUNCTION(BlueprintPure, Category = "Character Stats") | ||||
|     float GetCurrentDamage() const { return CurrentDamage; } | ||||
|  | ||||
|     UFUNCTION(BlueprintPure, Category = "Character Stats") | ||||
|     float GetCurrentSpeed() const { return CurrentSpeed; } | ||||
|  | ||||
|     // Health management | ||||
|     UFUNCTION(BlueprintCallable, Category = "Character Stats") | ||||
|     void TakeDamage(float DamageAmount); | ||||
|  | ||||
|     UFUNCTION(BlueprintCallable, Category = "Character Stats") | ||||
|     void Heal(float HealAmount); | ||||
|  | ||||
|     UFUNCTION(BlueprintCallable, Category = "Character Stats") | ||||
|     void SetHealth(float NewHealth); | ||||
|  | ||||
|     // Get formatted text for UI | ||||
|     UFUNCTION(BlueprintPure, Category = "Character Stats UI") | ||||
|     FText GetHealthText() const; | ||||
|  | ||||
|     UFUNCTION(BlueprintPure, Category = "Character Stats UI") | ||||
|     FText GetDamageText() const; | ||||
|  | ||||
|     UFUNCTION(BlueprintPure, Category = "Character Stats UI") | ||||
|     FText GetSpeedText() const; | ||||
|  | ||||
|     // Events | ||||
|     UPROPERTY(BlueprintAssignable, Category = "Stats Events") | ||||
|     FOnHealthChanged OnHealthChanged; | ||||
|  | ||||
|     UPROPERTY(BlueprintAssignable, Category = "Stats Events") | ||||
|     FOnDamageChanged OnDamageChanged; | ||||
|  | ||||
|     UPROPERTY(BlueprintAssignable, Category = "Stats Events") | ||||
|     FOnSpeedChanged OnSpeedChanged; | ||||
|  | ||||
|     UPROPERTY(BlueprintAssignable, Category = "Stats Events") | ||||
|     FOnStatsUpdated OnStatsUpdated; | ||||
|  | ||||
| private: | ||||
|     // Apply speed to character movement | ||||
|     void ApplySpeedToMovement(); | ||||
|  | ||||
|     // Reference to owner's skill tree component | ||||
|     UPROPERTY() | ||||
|     class USkillTreeComponent* OwnerSkillTree; | ||||
| }; | ||||
		Reference in New Issue
	
	Block a user