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 World &GetWorld() noexcept { return world; }
21 const World &GetWorld() const noexcept { return world; }
22 Player &GetPlayer() noexcept { return player; }
23 const Player &GetPlayer() const noexcept { return player; }
25 WorldCollision &BlockFocus() noexcept { return aim_world; }
26 const WorldCollision &BlockFocus() const noexcept { return aim_world; }
27 EntityCollision &EntityFocus() noexcept { return aim_entity; }
28 const EntityCollision &EntityFocus() const noexcept { return aim_entity; }
30 /// set desired direction of movement
31 /// the magnitude (clamped to [0..1]) can be used to attenuate target velocity
32 void SetMovement(const glm::vec3 &) noexcept;
33 const glm::vec3 &GetMovement() const noexcept { return move_dir; }
34 /// turn the controlled entity's head by given pitch and yaw deltas
35 void TurnHead(float pitch, float yaw) noexcept;
37 /// get player pitch in radians, normalized to [-PI/2,PI/2]
38 float GetPitch() const noexcept { return pitch; }
39 /// get player yaw in radians, normalized to [-PI,PI]
40 float GetYaw() const noexcept { return yaw; }
42 /// start doing primary action
43 /// what exactly this means depends on the active item
44 virtual void StartPrimaryAction() = 0;
45 /// stop doing primary action
46 virtual void StopPrimaryAction() = 0;
48 virtual void StartSecondaryAction() = 0;
49 virtual void StopSecondaryAction() = 0;
50 virtual void StartTertiaryAction() = 0;
51 virtual void StopTertiaryAction() = 0;
53 /// set the item at given inventory slot as active
54 void SelectInventory(int) noexcept;
55 int InventorySlot() const noexcept;
58 void Invalidate() noexcept;
59 void UpdatePlayer() noexcept;
69 WorldCollision aim_world;
70 EntityCollision aim_entity;