#include "InteractiveObjectBase.h" AInteractiveObjectBase::AInteractiveObjectBase() { PrimaryActorTick.bCanEverTick = false; } void AInteractiveObjectBase::SetInteractiveState(EInteractiveObjectState NewState) { if (CurrentState == NewState) return; if (CurrentState == EInteractiveObjectState::Disabled && NewState != EInteractiveObjectState::Normal) return; EInteractiveObjectState OldState = CurrentState; CurrentState = NewState; switch (NewState) { case EInteractiveObjectState::Hovered: OnHovered(); break; case EInteractiveObjectState::Selected: OnSelected(); break; case EInteractiveObjectState::Normal: if (OldState == EInteractiveObjectState::Selected) OnDeselected(); else OnRestored(); break; default: break; } OnStateChanged.Broadcast(NewState); } // --------------------------------------------------------------------------- // 默认实现(子类可重写) // --------------------------------------------------------------------------- FText AInteractiveObjectBase::GetInfoTitle_Implementation() const { return FText::FromString(GetActorLabel()); } FText AInteractiveObjectBase::GetInfoBody_Implementation() const { return FText::FromString(TEXT("")); } UTexture2D* AInteractiveObjectBase::GetInfoIcon_Implementation() const { return nullptr; } void AInteractiveObjectBase::OnHovered_Implementation() {} void AInteractiveObjectBase::OnSelected_Implementation() {} void AInteractiveObjectBase::OnDeselected_Implementation(){} void AInteractiveObjectBase::OnRestored_Implementation() {}