feat(app): WASDMove script (WASD camera-relative movement)

ScriptBehavior gains App() host access (Application injected via
ScriptRuntime), TryGet<T> and EntityBits for physics facade addressing.
WASDMove maps WASD to the editor camera's horizontal heading (UE
gameplay convention): dynamic bodies go through the physics velocity
facade preserving the vertical component (zeroing Y would cancel
gravity mid-fall), bodiless entities translate their transform directly.
Editor-mode key conflict is naturally avoided: RMB-held flight consumes
WASD, release hands keys to the script.
This commit is contained in:
2026-10-03 18:27:12 +08:00
parent 3403822a52
commit cad0481bc0
5 changed files with 106 additions and 5 deletions
+7 -1
View File
@@ -10,6 +10,12 @@
namespace Engine {
namespace Scripting {
// 宿主门面访问器:Application 完整类型只在脚本 cpp 里需要,
// 这里仅回引成员(避免引擎头循环依赖)
Application& ScriptBehavior::App() const {
return *m_App;
}
void ScriptRuntime::Update(f32 dt) {
Sync();
@@ -61,7 +67,7 @@ namespace Engine {
sc.scriptName, bits);
continue;
}
behavior->Bind(m_Scene, e);
behavior->Bind(m_Scene, e, m_App);
ScriptInstance inst;
inst.behavior = std::move(behavior);