![]() |
ducttape-engine
0.2.0
A universal game engine
|
00001 00002 // ---------------------------------------------------------------------------- 00003 // This file is part of the Ducttape Project (http://ducttape-dev.org) and is 00004 // licensed under the GNU LESSER PUBLIC LICENSE version 3. For the full license 00005 // text, please see the LICENSE file in the root of this project or at 00006 // http://www.gnu.org/licenses/lgpl.html 00007 // ---------------------------------------------------------------------------- 00008 00009 #ifndef DUCTTAPE_ENGINE_COMPONENT_ADVANCEDPLAYERCOMPONENT 00010 #define DUCTTAPE_ENGINE_COMPONENT_ADVANCEDPLAYERCOMPONENT 00011 00012 #include <Config.hpp> 00013 00014 #include <Scene/Component.hpp> 00015 #include <Input/InputManager.hpp> 00016 00017 #include <BulletCollision/CollisionShapes/btConvexHullShape.h> 00018 #include <btBulletDynamicsCommon.h> 00019 #include <btBulletCollisionCommon.h> 00020 #include <BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h> 00021 #include <BulletCollision/CollisionDispatch/btGhostObject.h> 00022 #include <BulletDynamics/Character/btKinematicCharacterController.h> 00023 00024 #define OIS_DYNAMIC_LIB 00025 #include <OIS.h> 00026 00027 #include <QString> 00028 00029 namespace dt { 00030 00034 class DUCTTAPE_API AdvancedPlayerComponent : public Component { 00035 Q_OBJECT 00036 public: 00037 DT_SERIALIZABLE(AdvancedPlayerComponent) 00043 AdvancedPlayerComponent(const QString name = ""); 00044 00045 virtual void onInitialize(); 00046 virtual void onDeinitialize(); 00047 virtual void onEnable(); 00048 virtual void onDisable(); 00049 virtual void onUpdate(double time_diff); 00050 00055 void setKeyboardEnabled(bool is_keyboard_enabled); 00056 00061 bool getKeyboardEnabled() const; 00062 00067 void setMoveSpeed(float move_speed); 00068 00073 float getMoveSpeed() const; 00074 00079 void setMouseEnabled(bool mouse_enabled); 00080 00085 bool getMouseEnabled() const; 00086 00091 void setMouseSensitivity(float mouse_sensitivity); 00092 00097 float getMouseSensitivity() const; 00098 00103 void setMouseYInversed(bool mouse_y_inversed); 00104 00109 bool getMouseYInversed() const; 00110 00115 void setJumpEnabled(bool jump_enabled); 00116 00121 bool getJumpEnabled() const; 00122 00129 bool getIsOneShot(OIS::MouseButtonID mouse_button) const; 00130 00137 void setIsOneShot(bool is_one_shot, OIS::MouseButtonID mouse_button); 00138 00139 protected: 00145 virtual void _onMouseTriggered() {} 00146 00147 private slots: 00153 void _handleButtonDown(dt::InputManager::InputCode input_code, const OIS::EventArg& event); 00154 00159 void _handleMouseMove(const OIS::MouseEvent& event); 00160 00166 void _handleButtonUp(dt::InputManager::InputCode input_code, const OIS::EventArg& event); 00167 00168 signals: 00172 void sMove(); 00173 00177 void sStop(); 00178 00182 void sJump(); 00183 00184 private: 00185 std::shared_ptr<btKinematicCharacterController> mBtController; 00186 std::shared_ptr<btPairCachingGhostObject> mBtGhostObject; 00187 bool mMouseEnabled; 00188 float mMouseSensitivity; 00189 bool mMouseYInversed; 00190 btVector3 mMove; 00191 float mMoveSpeed; 00192 bool mKeyboardEnabled; 00193 bool mJumpEnabled; 00194 bool mIsLeftOneShot; 00195 bool mIsRightOneShot; 00196 bool mIsMoving; 00197 00198 protected: 00199 bool mIsLeftMouseDown; 00200 bool mIsRightMouseDown; 00201 }; 00202 } 00203 00204 #endif
1.8.0