diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2018-03-30 18:32:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-30 18:32:52 +0200 |
commit | ce873108aa91d19104f46c5acd3350385e7a4541 (patch) | |
tree | 58672a3c803469de71c9ae270beb9a052ba5559a /src/camera.cpp | |
parent | 2c490dddc037d7d1cf211bbf28309e31b0abdadd (diff) | |
download | minetest-ce873108aa91d19104f46c5acd3350385e7a4541.tar.gz minetest-ce873108aa91d19104f46c5acd3350385e7a4541.tar.bz2 minetest-ce873108aa91d19104f46c5acd3350385e7a4541.zip |
Client eventmanager refactor (#7179)
* Drop EventManager from GameDef & do some client cleanups
* EventManager is only used by Client. Don't expose it on Server & GameDef for nothing
* Drop Client::event() in favor of direct calls to getEventManager
* Cleanup some event put from new + put to put(new)
* MtEvent: add Type(u8) enum
* This will enhance event performance & ensure stricter type
* Drop MtEvent::checkIs (unused)
* clang-tidy reported fixes
* Code style
* Move event_manager.h to the client directory as it's only used by client
Add EventManager unittests + switch to unordered_map as order is not important here
Drop a unused function
Diffstat (limited to 'src/camera.cpp')
-rw-r--r-- | src/camera.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/camera.cpp b/src/camera.cpp index 09ff93886..cf96f3308 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -160,15 +160,13 @@ void Camera::step(f32 dtime) (was < 0.5f && m_view_bobbing_anim >= 0.5f) || (was > 0.5f && m_view_bobbing_anim <= 0.5f)); if(step) { - MtEvent *e = new SimpleTriggerEvent("ViewBobbingStep"); - m_client->event()->put(e); + m_client->getEventManager()->put(new SimpleTriggerEvent(MtEvent::VIEW_BOBBING_STEP)); } } } - if (m_digging_button != -1) - { - f32 offset = dtime * 3.5; + if (m_digging_button != -1) { + f32 offset = dtime * 3.5f; float m_digging_anim_was = m_digging_anim; m_digging_anim += offset; if (m_digging_anim >= 1) @@ -179,13 +177,10 @@ void Camera::step(f32 dtime) float lim = 0.15; if(m_digging_anim_was < lim && m_digging_anim >= lim) { - if(m_digging_button == 0) - { - MtEvent *e = new SimpleTriggerEvent("CameraPunchLeft"); - m_client->event()->put(e); + if (m_digging_button == 0) { + m_client->getEventManager()->put(new SimpleTriggerEvent(MtEvent::CAMERA_PUNCH_LEFT)); } else if(m_digging_button == 1) { - MtEvent *e = new SimpleTriggerEvent("CameraPunchRight"); - m_client->event()->put(e); + m_client->getEventManager()->put(new SimpleTriggerEvent(MtEvent::CAMERA_PUNCH_RIGHT)); } } } |