Files
Frostbite2D/Game/include/character/CharacterInputRouter.h
Lenheart 1200cf0181 refactor(character): 重构角色动作与动画系统
- 移除自动回退动作生成逻辑,改为严格检查动作定义
- 增加动作资源缺失时的详细错误报告机制
- 统一输入事件处理接口,优化角色对象生命周期管理
- 改进动画标签管理,移除隐式回退逻辑
- 增强状态机对无效动作的处理能力
2026-04-04 05:53:07 +08:00

36 lines
1004 B
C++

#pragma once
#include "character/CharacterActionTypes.h"
#include <frostbite2D/event/joystick_event.h>
#include <frostbite2D/event/key_event.h>
namespace frostbite2D {
/// 将 SDL 键盘/手柄事件统一转换为角色命令,避免状态机直接依赖设备细节。
class CharacterInputRouter {
public:
bool OnKeyDown(const KeyEvent& event);
bool OnKeyUp(const KeyUpEvent& event);
bool OnJoystickAxis(const JoystickAxisEvent& event);
bool OnJoystickButtonDown(const JoystickButtonDownEvent& event);
bool OnJoystickButtonUp(const JoystickButtonUpEvent& event);
void EmitCommands(CharacterCommandBuffer& commandBuffer);
void ClearFrameState();
private:
bool left_ = false;
bool right_ = false;
bool up_ = false;
bool down_ = false;
bool jumpPressed_ = false;
bool attackPressed_ = false;
bool skill1Pressed_ = false;
bool dashPressed_ = false;
float leftStickX_ = 0.0f;
float leftStickY_ = 0.0f;
float joystickDeadZone_ = 0.2f;
};
} // namespace frostbite2D