| 1 | #ifndef GAME_CLIENT_COMPONENTS_MULTIVIEW_H |
| 2 | #define GAME_CLIENT_COMPONENTS_MULTIVIEW_H |
| 3 | |
| 4 | #include <base/vmath.h> |
| 5 | |
| 6 | #include <engine/shared/protocol.h> |
| 7 | |
| 8 | #include <generated/protocol.h> |
| 9 | |
| 10 | #include <game/client/component.h> |
| 11 | |
| 12 | class CMultiView : public CComponent |
| 13 | { |
| 14 | public: |
| 15 | CMultiView(); |
| 16 | int Sizeof() const override { return sizeof(*this); } |
| 17 | |
| 18 | void OnReset() override; |
| 19 | void OnMessage(int MsgType, void *pRawMsg) override; |
| 20 | |
| 21 | void UpdateActivation(); |
| 22 | void UpdateView(); |
| 23 | void CheckReset(); |
| 24 | |
| 25 | bool IsActivated() const { return m_Activated; } |
| 26 | void SetActivated(bool Activated) { m_Activated = Activated; } |
| 27 | bool ShowHud() const { return m_ShowHud; } |
| 28 | int Team() const { return m_Team; } |
| 29 | |
| 30 | bool IsViewed(int ClientId) const { return ClientId >= 0 && ClientId < MAX_CLIENTS && m_aViewedClients[ClientId].m_IsViewed; } |
| 31 | void ViewPlayer(int ClientId); |
| 32 | void ToggleView(int ClientId); |
| 33 | void ClearViews(); |
| 34 | |
| 35 | void AddPersonalZoom(float Amount) { m_PersonalZoom += Amount; } |
| 36 | void SetPersonalZoom(float Zoom) { m_PersonalZoom = Zoom; } |
| 37 | |
| 38 | // Full reset, restoring the camera zoom as well. |
| 39 | void Reset(); |
| 40 | // may return SPEC_FREEVIEW |
| 41 | int FindFirstViewed() const; |
| 42 | void ClearView(int ClientId); |
| 43 | |
| 44 | private: |
| 45 | void OnKillMessage(const CNetMsg_Sv_KillMsg *pKillMessage); |
| 46 | bool IsAnyViewed() const; |
| 47 | bool Init(int Team); |
| 48 | void ClearAll(); |
| 49 | float CalculateMultiplier(vec2 TargetPos); |
| 50 | float CalculateZoom(vec2 MinPos, vec2 MaxPos, float Vel); |
| 51 | |
| 52 | int m_Team; |
| 53 | float m_PersonalZoom; |
| 54 | bool m_ShowHud; |
| 55 | bool m_Activated; |
| 56 | |
| 57 | class CViewedClient |
| 58 | { |
| 59 | public: |
| 60 | CViewedClient() = default; |
| 61 | void Reset(); |
| 62 | bool m_IsViewed = false; |
| 63 | bool m_Vanish = false; |
| 64 | float m_LastFreeze = 0.0f; |
| 65 | }; |
| 66 | CViewedClient m_aViewedClients[MAX_CLIENTS]; |
| 67 | |
| 68 | // runtime state while multi-view is active |
| 69 | bool m_Solo; |
| 70 | bool m_IsInit; |
| 71 | bool m_Teleported; |
| 72 | vec2 m_OldPos; |
| 73 | float m_OldPersonalZoom; |
| 74 | float m_SecondChance; |
| 75 | float m_OldCameraDistance; |
| 76 | }; |
| 77 | |
| 78 | #endif |
| 79 | |