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