1 #ifndef BLANK_UI_PLAYERCONTROLLER_HPP_
2 #define BLANK_UI_PLAYERCONTROLLER_HPP_
4 #include "../graphics/glm.hpp"
5 #include "../world/EntityCollision.hpp"
6 #include "../world/EntityController.hpp"
7 #include "../world/WorldCollision.hpp"
15 class PlayerController
16 : public EntityController {
19 PlayerController(World &, Player &);
22 World &GetWorld() noexcept { return world; }
23 const World &GetWorld() const noexcept { return world; }
24 Player &GetPlayer() noexcept { return player; }
25 const Player &GetPlayer() const noexcept { return player; }
27 WorldCollision &BlockFocus() noexcept { return aim_world; }
28 const WorldCollision &BlockFocus() const noexcept { return aim_world; }
29 EntityCollision &EntityFocus() noexcept { return aim_entity; }
30 const EntityCollision &EntityFocus() const noexcept { return aim_entity; }
32 /// set desired direction of movement
33 /// the magnitude (clamped to [0..1]) can be used to attenuate target velocity
34 void SetMovement(const glm::vec3 &) noexcept;
35 const glm::vec3 &GetMovement() const noexcept { return move_dir; }
37 /// turn the controlled entity's head by given pitch and yaw deltas
38 void TurnHead(float pitch, float yaw) noexcept;
40 /// get player pitch in radians, normalized to [-PI/2,PI/2]
41 float GetPitch() const noexcept;
42 /// get player yaw in radians, normalized to [-PI,PI]
43 float GetYaw() const noexcept;
45 /// start doing primary action
46 /// what exactly this means depends on the active item
47 virtual void StartPrimaryAction() = 0;
48 /// stop doing primary action
49 virtual void StopPrimaryAction() = 0;
51 virtual void StartSecondaryAction() = 0;
52 virtual void StopSecondaryAction() = 0;
53 virtual void StartTertiaryAction() = 0;
54 virtual void StopTertiaryAction() = 0;
56 /// set the item at given inventory slot as active
57 void SelectInventory(int) noexcept;
58 int InventorySlot() const noexcept;
61 void Invalidate() noexcept;
62 void UpdatePlayer() noexcept;
70 WorldCollision aim_world;
71 EntityCollision aim_entity;