feat(npc): 添加NPC交互高亮效果及复合纹理支持
实现NPC交互时的绿色高亮效果,通过InteractionHighlightSprite类实现 重构NpcAnimation支持复合纹理渲染,优化高亮效果的性能 添加ShaderManager获取所有加载Shader的方法,优化渲染器uniform更新逻辑
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "character/CharacterActionTypes.h"
|
||||
#include "common/InteractionHighlightSprite.h"
|
||||
#include "npc/NpcAnimation.h"
|
||||
#include <frostbite2D/2d/text_sprite.h>
|
||||
#include <frostbite2D/2d/actor.h>
|
||||
#include <frostbite2D/2d/text_sprite.h>
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@@ -21,11 +22,13 @@ public:
|
||||
void SetNpcPosition(const Vec2& pos);
|
||||
void SetWorldPosition(const CharacterWorldPosition& pos);
|
||||
void SetInteractable(bool interactable);
|
||||
void SetInteractionHighlighted(bool highlighted);
|
||||
void BeginInteract();
|
||||
void EndInteract();
|
||||
|
||||
bool CanInteract() const;
|
||||
bool IsInteracting() const { return interacting_; }
|
||||
bool IsInteractionHighlighted() const { return interactionHighlighted_; }
|
||||
int GetNpcId() const { return npcId_; }
|
||||
int GetDirection() const { return direction_; }
|
||||
const std::string& GetName() const;
|
||||
@@ -41,8 +44,10 @@ public:
|
||||
void Update(float deltaTime) override;
|
||||
|
||||
private:
|
||||
void EnsureInteractionHighlight();
|
||||
void EnsureNameLabel();
|
||||
void RefreshNameLabel();
|
||||
void SyncInteractionHighlight();
|
||||
void SyncActorPositionFromWorld();
|
||||
|
||||
int npcId_ = -1;
|
||||
@@ -50,10 +55,13 @@ private:
|
||||
CharacterWorldPosition worldPosition_;
|
||||
std::optional<npc::NpcConfig> config_;
|
||||
RefPtr<NpcAnimation> animation_ = nullptr;
|
||||
RefPtr<InteractionHighlightSprite> interactionHighlight_ = nullptr;
|
||||
std::array<RefPtr<TextSprite>, 8> nameOutlineLabels_;
|
||||
RefPtr<TextSprite> nameLabel_ = nullptr;
|
||||
bool interactable_ = true;
|
||||
bool interacting_ = false;
|
||||
bool interactionHighlighted_ = false;
|
||||
uint64 syncedHighlightCompositeVersion_ = 0;
|
||||
};
|
||||
|
||||
} // namespace frostbite2D
|
||||
|
||||
Reference in New Issue
Block a user