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