Files
Frostbite2D/Game/include/character/CharacterInputRouter.h
Lenheart bb75a57afb feat(character): 实现角色状态机与输入路由系统
新增角色状态机框架,包含空闲、移动、跳跃、攻击等状态
添加输入路由组件,统一处理键盘和手柄输入
引入动作库管理角色动作定义,支持PVF脚本配置
重构角色对象,整合运动器、状态机和输入处理
修复Actor子节点排序时的迭代安全问题
2026-04-03 08:08:23 +08:00

36 lines
996 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(KeyCode keyCode);
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