X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fui%2FDirectInput.hpp;fp=src%2Fui%2FDirectInput.hpp;h=525c85668c8f03460def706ad3c06faf1042f4b7;hb=b066e776622f96e906600a0c4a08de392bd03676;hp=0000000000000000000000000000000000000000;hpb=e1209ec25c4cc91e13889876106f56bd51aa96e2;p=blank.git diff --git a/src/ui/DirectInput.hpp b/src/ui/DirectInput.hpp new file mode 100644 index 0000000..525c856 --- /dev/null +++ b/src/ui/DirectInput.hpp @@ -0,0 +1,67 @@ +#ifndef BLANK_UI_DIRECTINPUT_HPP_ +#define BLANK_UI_DIRECTINPUT_HPP_ + +#include "PlayerController.hpp" + +#include "../app/IntervalTimer.hpp" +#include "../world/EntityCollision.hpp" +#include "../world/WorldCollision.hpp" + + +namespace blank { + +class Player; +class World; +struct WorldManipulator; + +class DirectInput +: public PlayerController { + +public: + DirectInput(World &, Player &, WorldManipulator &); + + const WorldCollision &BlockFocus() const noexcept { return aim_world; } + const EntityCollision &EntityFocus() const noexcept { return aim_entity; } + + void Update(int dt); + + void SetMovement(const glm::vec3 &) override; + void TurnHead(float pitch, float yaw) override; + void StartPrimaryAction() override; + void StopPrimaryAction() override; + void StartSecondaryAction() override; + void StopSecondaryAction() override; + void StartTertiaryAction() override; + void StopTertiaryAction() override; + void SelectInventory(int) override; + +private: + void UpdatePlayer(); + + void PickBlock(); + void PlaceBlock(); + void RemoveBlock(); + +private: + World &world; + Player &player; + WorldManipulator &manip; + + WorldCollision aim_world; + EntityCollision aim_entity; + + glm::vec3 move_dir; + float pitch; + float yaw; + bool dirty; + + int active_slot; + + IntervalTimer place_timer; + IntervalTimer remove_timer; + +}; + +} + +#endif