【发布时间】:2022-02-03 12:31:50
【问题描述】:
在 UE4 上制作 RTS 逻辑。我可以将类方法或 lambda 绑定到“OnPressed”、“OnReleased”和“Axis”信号。考虑使用 Guarded State Machine 模式和 Command 模式来定义键连词,但没有简单的方法可以在最后一步确定最终命令。需要类似变形的东西。 例如:
LeftClick = Nothing
LeftClick + Unit under cursor = Select unit
Shift + LeftClick = Nothing
Shift + LeftClick + Unit under cursor = Add unit to selection
Shift + LeftClick + Moving cursor + Units under cursor = Add units to selection
Ctrl + LeftClick + Unit under cursor = Remove unit from selection
RightClick = Nothing
RightClick + Units selected = Move units
也许我应该使用行为树模式而不是状态机模式?但是树会很大(这个例子已经被简化了)。
【问题讨论】:
-
嘿,有必要进一步澄清一下“在最后一步确定最终命令没有简单的方法。需要类似变形的东西。”目前,这似乎是一个输入组合问题,但“变形”和“最终命令”等不常见术语的使用使这一点变得不确定
标签: c++ design-patterns architecture unreal-engine4 game-development