-
Notifications
You must be signed in to change notification settings - Fork 6
/
localplayer.h
59 lines (55 loc) · 1.56 KB
/
localplayer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef OGTA_LOCAL_PLAYER_H
#define OGTA_LOCAL_PLAYER_H
#include "Singleton.h"
#include "game_objects.h"
#include "entity_controller.h"
#include "id_sys.h"
#include "key_handler.h"
namespace OpenGTA {
class PlayerController : public Util::KeyHandler {
public:
PlayerController() {
reset();
}
void reset() {
playerId = TypeIdBlackBox::getPlayerId();
cash = 0;
wantedLevel = 0;
modifier = 0;
numLives = 0;
pc_ptr = NULL;
}
PedController & getCtrl() {
assert(pc_ptr);
return *pc_ptr;
}
void setCtrl(PedController & pc) {
pc_ptr = &pc;
}
void giveLives(uint16_t k) {
numLives += k;
}
void disableCtrl(bool soft);
void enableCtrl();
Pedestrian & getPed();
int32_t getNumLives() { return numLives; }
int32_t getWantedLevel() { return wantedLevel; }
uint32_t getCash() { return cash; }
bool up(const uint32_t & key);
bool down(const uint32_t & key);
uint32_t getId() { return playerId; }
void addCash(uint32_t v) { cash += v; }
void setWanted(int32_t v) { wantedLevel = v; }
void addWanted(uint32_t v) { wantedLevel += v; if (wantedLevel > 5) wantedLevel = 5; }
private:
uint32_t playerId;
uint32_t cash;
int32_t wantedLevel;
uint32_t modifier;
int32_t numLives;
PedController * pc_ptr;
};
typedef Loki::SingletonHolder<PlayerController, Loki::CreateUsingNew,
Loki::DefaultLifetime, Loki::SingleThreaded> LocalPlayer;
}
#endif