]> git.localhorst.tv Git - blank.git/blob - src/ui/DirectInput.hpp
split input handling
[blank.git] / src / ui / DirectInput.hpp
1 #ifndef BLANK_UI_DIRECTINPUT_HPP_
2 #define BLANK_UI_DIRECTINPUT_HPP_
3
4 #include "PlayerController.hpp"
5
6 #include "../app/IntervalTimer.hpp"
7 #include "../world/EntityCollision.hpp"
8 #include "../world/WorldCollision.hpp"
9
10
11 namespace blank {
12
13 class Player;
14 class World;
15 struct WorldManipulator;
16
17 class DirectInput
18 : public PlayerController {
19
20 public:
21         DirectInput(World &, Player &, WorldManipulator &);
22
23         const WorldCollision &BlockFocus() const noexcept { return aim_world; }
24         const EntityCollision &EntityFocus() const noexcept { return aim_entity; }
25
26         void Update(int dt);
27
28         void SetMovement(const glm::vec3 &) override;
29         void TurnHead(float pitch, float yaw) override;
30         void StartPrimaryAction() override;
31         void StopPrimaryAction() override;
32         void StartSecondaryAction() override;
33         void StopSecondaryAction() override;
34         void StartTertiaryAction() override;
35         void StopTertiaryAction() override;
36         void SelectInventory(int) override;
37
38 private:
39         void UpdatePlayer();
40
41         void PickBlock();
42         void PlaceBlock();
43         void RemoveBlock();
44
45 private:
46         World &world;
47         Player &player;
48         WorldManipulator &manip;
49
50         WorldCollision aim_world;
51         EntityCollision aim_entity;
52
53         glm::vec3 move_dir;
54         float pitch;
55         float yaw;
56         bool dirty;
57
58         int active_slot;
59
60         IntervalTimer place_timer;
61         IntervalTimer remove_timer;
62
63 };
64
65 }
66
67 #endif