#include "ZeusAttributeComponent.h" #include "Engine/GameInstance.h" #include "ZeusNetworkSubsystem.h" UZeusAttributeComponent::UZeusAttributeComponent() { PrimaryComponentTick.bCanEverTick = false; } void UZeusAttributeComponent::ApplySnapshot(const FZeusAttributesSnapshot& InSnapshot) { const int32 OldHp = Current.Hp; const int32 OldSp = Current.Sp; Current = InSnapshot; OnAttributesChanged.Broadcast(Current); if (OldHp != Current.Hp || OldSp != Current.Sp) { OnHpSpChanged.Broadcast(Current.Hp, Current.Sp); } } void UZeusAttributeComponent::ApplyHpSpUpdate(int32 NewHp, int32 NewSp) { if (Current.Hp == NewHp && Current.Sp == NewSp) { return; } Current.Hp = NewHp; Current.Sp = NewSp; OnHpSpChanged.Broadcast(Current.Hp, Current.Sp); } void UZeusAttributeComponent::NotifyLevelUp(int32 NewBaseLevel, int32 StatusPointDelta) { // O snapshot subsequente vai trazer todos os outros campos atualizados — // aqui apenas dispara o delegate para efeitos visuais imediatos. OnLevelUp.Broadcast(NewBaseLevel, StatusPointDelta); } void UZeusAttributeComponent::NotifyStatAllocReply(bool bAccepted, int32 Reason) { OnStatAllocReply.Broadcast(bAccepted, Reason); } void UZeusAttributeComponent::RequestStatAlloc(int32 StatId, int32 Amount) { UWorld* World = GetWorld(); if (!World) { return; } UGameInstance* GI = World->GetGameInstance(); if (!GI) { return; } UZeusNetworkSubsystem* Net = GI->GetSubsystem(); if (!Net) { return; } Net->SendStatAlloc(StatId, Amount); }