- 移除自动回退动作生成逻辑,改为严格检查动作定义 - 增加动作资源缺失时的详细错误报告机制 - 统一输入事件处理接口,优化角色对象生命周期管理 - 改进动画标签管理,移除隐式回退逻辑 - 增强状态机对无效动作的处理能力
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include "character/CharacterDataLoader.h"
|
|
#include "character/CharacterEquipmentManager.h"
|
|
#include <frostbite2D/2d/actor.h>
|
|
#include <frostbite2D/animation/animation.h>
|
|
#include <frostbite2D/base/RefPtr.h>
|
|
#include <map>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace frostbite2D {
|
|
|
|
class CharacterObject;
|
|
|
|
class CharacterAnimation : public Actor {
|
|
public:
|
|
using ActionAnimationList = std::map<std::string, std::vector<RefPtr<Animation>>>;
|
|
|
|
bool Init(CharacterObject* parent,
|
|
const character::CharacterConfig& config,
|
|
const CharacterEquipmentManager& equipmentManager);
|
|
|
|
bool SetAction(const std::string& actionName);
|
|
void SetDirection(int direction);
|
|
const std::string& GetCurrentAction() const { return currentActionTag_; }
|
|
bool HasAction(const std::string& actionName) const {
|
|
return actionAnimations_.count(actionName) > 0;
|
|
}
|
|
std::string DescribeAvailableActions() const;
|
|
|
|
private:
|
|
static std::string FormatImgPath(std::string path, Animation::ReplaceData data);
|
|
|
|
void CreateAnimationBySlot(const std::string& actionName,
|
|
const std::string& slotName,
|
|
const std::string& actionPath,
|
|
const character::CharacterConfig& config,
|
|
const CharacterEquipmentManager& equipmentManager);
|
|
|
|
CharacterObject* parent_ = nullptr;
|
|
ActionAnimationList actionAnimations_;
|
|
std::string currentActionTag_;
|
|
int direction_ = 1;
|
|
};
|
|
|
|
} // namespace frostbite2D
|