2022-01-31 18:27:35 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
|
|
|
class player_service;
|
|
|
|
class player final
|
|
|
|
{
|
|
|
|
friend player_service;
|
|
|
|
|
|
|
|
CNetGamePlayer* m_net_game_player = nullptr;
|
|
|
|
std::string m_identifier;
|
2022-02-21 00:55:21 +01:00
|
|
|
bool m_is_friend;
|
2022-01-31 18:27:35 +01:00
|
|
|
|
|
|
|
public:
|
2022-06-24 19:48:03 +02:00
|
|
|
explicit player(CNetGamePlayer* net_game_player);
|
|
|
|
~player() = default;
|
|
|
|
|
|
|
|
player(const player&) = default;
|
|
|
|
player(player&&) noexcept = default;
|
|
|
|
player& operator=(const player&) = default;
|
|
|
|
player& operator=(player&&) noexcept = default;
|
2022-01-31 18:27:35 +01:00
|
|
|
|
2022-03-09 00:03:14 +01:00
|
|
|
float screen_position_x = -1.f;
|
|
|
|
float screen_position_y = -1.f;
|
|
|
|
|
2022-06-24 19:48:03 +02:00
|
|
|
[[nodiscard]] CAutomobile* get_current_vehicle() const;
|
|
|
|
[[nodiscard]] const char* get_name() const;
|
|
|
|
[[nodiscard]] rage::netPlayerData* get_net_data() const;
|
|
|
|
[[nodiscard]] CNetGamePlayer* get_net_game_player() const;
|
|
|
|
[[nodiscard]] CPed* get_ped() const;
|
|
|
|
[[nodiscard]] CPlayerInfo* get_player_info() const;
|
2022-01-31 18:27:35 +01:00
|
|
|
|
2022-06-24 19:48:03 +02:00
|
|
|
[[nodiscard]] uint8_t id() const;
|
2022-01-31 18:27:35 +01:00
|
|
|
|
2022-06-24 19:48:03 +02:00
|
|
|
[[nodiscard]] bool is_friend() const;
|
|
|
|
[[nodiscard]] bool is_host() const;
|
|
|
|
[[nodiscard]] bool is_valid() const;
|
2022-01-31 18:27:35 +01:00
|
|
|
|
|
|
|
protected:
|
2022-06-24 19:48:03 +02:00
|
|
|
bool equals(const CNetGamePlayer* net_game_player) const;
|
2022-02-02 01:38:35 +01:00
|
|
|
|
2022-06-24 19:48:03 +02:00
|
|
|
[[nodiscard]] std::string to_lowercase_identifier() const;
|
2022-01-31 18:27:35 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2022-06-24 19:48:03 +02:00
|
|
|
using player_ptr = std::shared_ptr<player>;
|
|
|
|
using players = std::map<std::string, player_ptr>;
|
|
|
|
|
2022-01-31 18:27:35 +01:00
|
|
|
class player_service final
|
|
|
|
{
|
2022-06-24 19:48:03 +02:00
|
|
|
CNetGamePlayer** m_self;
|
|
|
|
|
|
|
|
players m_players;
|
|
|
|
|
|
|
|
player_ptr m_dummy = std::make_shared<player>(nullptr);
|
|
|
|
player_ptr m_selected_player;
|
2022-01-31 18:27:35 +01:00
|
|
|
public:
|
|
|
|
|
|
|
|
player_service();
|
2022-06-24 19:48:03 +02:00
|
|
|
~player_service();
|
|
|
|
|
|
|
|
player_service(const player_service&) = delete;
|
|
|
|
player_service(player_service&&) noexcept = delete;
|
|
|
|
player_service& operator=(const player_service&) = delete;
|
|
|
|
player_service& operator=(player_service&&) noexcept = delete;
|
2022-01-31 18:27:35 +01:00
|
|
|
|
|
|
|
void do_cleanup();
|
|
|
|
|
2022-06-24 19:48:03 +02:00
|
|
|
[[nodiscard]] player_ptr get_self() const;
|
|
|
|
|
|
|
|
[[nodiscard]] player_ptr get_by_name(std::string name);
|
|
|
|
[[nodiscard]] player_ptr get_by_msg_id(uint32_t msg_id) const;
|
|
|
|
[[nodiscard]] player_ptr get_by_host_token(uint64_t token) const;
|
|
|
|
[[nodiscard]] player_ptr get_selected() const;
|
2022-01-31 18:27:35 +01:00
|
|
|
|
|
|
|
void player_join(CNetGamePlayer* net_game_player);
|
|
|
|
void player_leave(CNetGamePlayer* net_game_player);
|
|
|
|
|
2022-06-24 19:48:03 +02:00
|
|
|
players& players()
|
|
|
|
{ return m_players; }
|
|
|
|
|
|
|
|
void set_selected(player_ptr plyr);
|
2022-02-02 01:38:35 +01:00
|
|
|
|
2022-01-31 18:27:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
inline player_service* g_player_service{};
|
|
|
|
}
|