1 /** @file clientplayer.h  Client-side player state.
2  *
3  * @authors Copyright (c) 2015-2017 Jaakko Keränen <jaakko.keranen@iki.fi>
4  *
5  * @par License
6  * GPL: http://www.gnu.org/licenses/gpl.html
7  *
8  * <small>This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by the
10  * Free Software Foundation; either version 2 of the License, or (at your
11  * option) any later version. This program is distributed in the hope that it
12  * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14  * Public License for more details. You should have received a copy of the GNU
15  * General Public License along with this program; if not, see:
16  * http://www.gnu.org/licenses</small>
17  */
18 
19 #ifndef CLIENT_CLIENTPLAYER_H
20 #define CLIENT_CLIENTPLAYER_H
21 
22 #include <doomsday/player.h>
23 #include "render/viewports.h"
24 //#include "lzss.h" // legacy demo code
25 
26 struct ConsoleEffectStack;
27 class ViewCompositor;
28 namespace render { class PlayerWeaponAnimator; }
29 
30 /**
31  * Information about a client player.
32  *
33  * @todo This is probably partially obsolete? Rename/revamp. -jk
34  */
35 typedef struct clplayerstate_s {
36     thid_t clMobjId;
37     float forwardMove;
38     float sideMove;
39     int angle;
40     angle_t turnDelta;
41     int friction;
42     int pendingFixes;
43     thid_t pendingFixTargetClMobjId;
44     angle_t pendingAngleFix;
45     float pendingLookDirFix;
46     coord_t pendingOriginFix[3];
47     coord_t pendingMomFix[3];
48 } clplayerstate_t;
49 
50 struct DemoTimer
51 {
52     bool first;
53     int begintime;
54     bool canwrite;  ///< @c false until Handshake packet.
55     int cameratimer;
56     int pausetime;
57     float fov;
58 };
59 
60 /**
61  * Client-side player state.
62  */
63 class ClientPlayer : public Player
64 {
65 public:
66     // Demo recording file (being recorded if not NULL).
67     //LZFILE *demo;
68     bool recording;
69     bool recordPaused;
70 
71     /// @c true if the player is in the void. (Not entirely accurate so should not be used
72     /// for anything critical).
73     bool inVoid;
74 
75 public:
76     ClientPlayer();
77 
78     void setWorld(World *world) override;
79 
80     ViewCompositor &viewCompositor();
81 
82     viewdata_t &viewport();
83     viewdata_t const &viewport() const;
84 
85     clplayerstate_t &clPlayerState();
86     clplayerstate_t const &clPlayerState() const;
87 
88     ConsoleEffectStack &fxStack();
89     ConsoleEffectStack const &fxStack() const;
90 
91     render::PlayerWeaponAnimator &playerWeaponAnimator();
92 
93     DemoTimer &demoTimer();
94 
95     void tick(timespan_t elapsed);
96 
97     /**
98      * Sets the id of the currently active weapon of this player. This is used for
99      * looking up assets related to the weapon (e.g., "model.weapon.(id)").
100      *
101      * @param id  Weapon id, as defined by the game.
102      */
103     void setWeaponAssetId(de::String const &id);
104 
105     void weaponStateChanged(struct state_s const *state);
106 
107 private:
108     DENG2_PRIVATE(d)
109 };
110 
111 #endif // CLIENT_CLIENTPLAYER_H
112