feat(attributes/ui): Status Window com alocação STR/AGI/VIT/INT/DEX/LUK + derivados

- ZMMOStatusWindowWidget (UCommonActivatableWidget, modo Menu): grid 2 colunas
  estilo RO. Esquerda: stats primários com botões + por stat (RequestStatAlloc).
  Direita: derivados ATK/MATK/DEF/MDEF/HIT/FLEE/CRIT/ASPD vindos do snapshot
  do server — cliente NUNCA recalcula (anti-cheat foundation).
- Botão + envia C_STAT_ALLOC → server valida cost RO (floor((stat-1)/10)+2),
  aplica + recalcula derivados + SaveCharFull async, manda
  S_ATTRIBUTE_SNAPSHOT_FULL + reply. UI atualiza em tempo real via
  OnAttributesChanged.
- ZMMOAttributeComponent ganha RequestStatAlloc + NotifyStatAllocReply +
  delegate OnStatAllocReply para feedback de rejeição.
- ZMMOAttributeNetworkHandler: HandleStatAllocReply roteia pro componente do
  player local (reply não traz EntityId — sempre quem fez o request).
- PlayerController: hotkey Alt+A (FInputChord legacy + BindKey, sem precisar
  de IA asset). ToggleStatusWindow via UUIInGameFlowSubsystem.
- WBP_StatusWindow: layout 2 colunas via MCP set_widget_tree (43 widgets) +
  BgBorder escuro semi-transparente + centralizado no overlay.
- DA_InGameScreenSet: StatusWindow → WBP_StatusWindow.
This commit is contained in:
2026-05-23 11:22:58 -03:00
parent 396223e2a8
commit f585b0d2b9
10 changed files with 372 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
#include "Engine/GameInstance.h"
#include "Engine/World.h"
#include "GameFramework/GameStateBase.h"
#include "GameFramework/PlayerController.h"
#include "GameFramework/PlayerState.h"
#include "ZMMOAttributeComponent.h"
#include "ZMMOAttributeTypes.h"
@@ -91,6 +92,8 @@ void UZMMOAttributeNetworkHandler::Initialize(FSubsystemCollectionBase& Collecti
this, &UZMMOAttributeNetworkHandler::HandleHpSpUpdate);
LevelUpHandle = Net->OnLevelUp.AddUObject(
this, &UZMMOAttributeNetworkHandler::HandleLevelUp);
StatAllocReplyHandle = Net->OnStatAllocReply.AddUObject(
this, &UZMMOAttributeNetworkHandler::HandleStatAllocReply);
}
}
@@ -113,6 +116,11 @@ void UZMMOAttributeNetworkHandler::Deinitialize()
Net->OnLevelUp.Remove(LevelUpHandle);
LevelUpHandle.Reset();
}
if (StatAllocReplyHandle.IsValid())
{
Net->OnStatAllocReply.Remove(StatAllocReplyHandle);
StatAllocReplyHandle.Reset();
}
}
Super::Deinitialize();
}
@@ -179,3 +187,22 @@ void UZMMOAttributeNetworkHandler::HandleLevelUp(int32 EntityId, int32 NewBaseLe
Comp->NotifyLevelUp(NewBaseLevel, StatusPointDelta);
}
}
void UZMMOAttributeNetworkHandler::HandleStatAllocReply(bool bAccepted, int32 Reason)
{
// S_ATTRIBUTE_STAT_ALLOC_OK nao traz EntityId no payload — sempre do
// player local que fez o request. Busca o AttributeComponent via PC.
if (UZMMOAttributeComponent* Comp = FindLocalPlayerAttributeComponent())
{
Comp->NotifyStatAllocReply(bAccepted, Reason);
}
}
UZMMOAttributeComponent* UZMMOAttributeNetworkHandler::FindLocalPlayerAttributeComponent() const
{
UWorld* World = GetWorld();
if (!World) { return nullptr; }
APlayerController* PC = World->GetFirstPlayerController();
if (!PC || !PC->PlayerState) { return nullptr; }
return PC->PlayerState->FindComponentByClass<UZMMOAttributeComponent>();
}