OpenGTA/localplayer.h

59 lines
1.5 KiB
C
Raw Normal View History

2015-12-03 00:37:02 +00:00
#ifndef OGTA_LOCAL_PLAYER_H
#define OGTA_LOCAL_PLAYER_H
#include "Singleton.h"
2015-12-03 00:37:37 +00:00
#include "game_objects.h"
#include "entity_controller.h"
#include "id_sys.h"
2015-12-03 00:38:22 +00:00
#include "key_handler.h"
2015-12-03 00:37:02 +00:00
namespace OpenGTA {
2015-12-03 00:38:22 +00:00
class PlayerController : public Util::KeyHandler {
2015-12-03 00:37:02 +00:00
public:
2015-12-03 00:37:37 +00:00
PlayerController() {
2015-12-03 00:38:22 +00:00
reset();
}
void reset() {
2015-12-03 00:37:37 +00:00
playerId = TypeIdBlackBox::getPlayerId();
2015-12-03 00:38:22 +00:00
cash = 0;
wantedLevel = 0;
modifier = 0;
numLives = 0;
2015-12-03 00:37:37 +00:00
pc_ptr = NULL;
}
PedController & getCtrl() {
assert(pc_ptr);
return *pc_ptr;
}
void setCtrl(PedController & pc) {
pc_ptr = &pc;
}
2015-12-03 00:38:22 +00:00
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; }
2015-12-03 00:37:37 +00:00
private:
uint32_t playerId;
2015-12-03 00:38:22 +00:00
uint32_t cash;
int32_t wantedLevel;
uint32_t modifier;
int32_t numLives;
2015-12-03 00:37:37 +00:00
PedController * pc_ptr;
2015-12-03 00:37:02 +00:00
};
2018-09-23 05:57:34 +00:00
typedef Loki::SingletonHolder<PlayerController> LocalPlayer;
2015-12-03 00:37:02 +00:00
}
#endif