Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
ApiUtils.cpp
Go to the documentation of this file.
1#include "ApiUtils.h"
2
3#include "../IBaseApi.h"
4
5namespace ArkApi
6{
7 // UWorld
8
9 void ApiUtils::SetWorld(UWorld* uworld)
10 {
11 u_world_ = uworld;
12 }
13
15 {
16 return u_world_;
17 }
18
19 // AShooterGameMode
20
22 {
23 shooter_game_mode_ = shooter_game_mode;
24 }
25
27 {
28 return shooter_game_mode_;
29 }
30
31 // Status
32
34 {
35 status_ = status;
36 }
37
39 {
40 return status_;
41 }
42
43 // Cheat Manager
45 {
46 cheatmanager_ = cheatmanager;
47 }
48
50 {
51 if (!player_controller)
52 return;
53
54 const uint64 steam_id = ArkApi::IApiUtils::GetSteamIdFromController(player_controller);
55
56 if (steam_id != 0)
57 {
58 steam_id_map_[steam_id] = player_controller;
59 }
60 }
61
63 {
64 if (!player_controller)
65 return;
66
67 const uint64 steam_id = ArkApi::IApiUtils::GetSteamIdFromController(player_controller);
68
69 if (steam_id != 0)
70 {
71 steam_id_map_.erase(steam_id);
72 }
73 }
74
76 {
77 AShooterPlayerController* found_player = nullptr;
78
79 if (steam_id == 0)
80 return found_player;
81
82 auto iter = steam_id_map_.find(steam_id);
83
84 if (iter != steam_id_map_.end()
85 && iter->first == steam_id)
86 {
87 found_player = iter->second;
88 }
89
90 return found_player;
91 }
92
94 {
95 return cheatmanager_;
96 }
97
98 // Free function
100 {
101 return *API::game_api->GetApiUtils();
102 }
103} // namespace ArkApi
void SetCheatManager(UShooterCheatManager *cheatmanager)
Definition ApiUtils.cpp:44
void SetWorld(UWorld *uworld)
Definition ApiUtils.cpp:9
void SetShooterGameMode(AShooterGameMode *shooter_game_mode)
Definition ApiUtils.cpp:21
UShooterCheatManager * GetCheatManager() const override
Returns a point to URCON CheatManager.
Definition ApiUtils.cpp:93
UWorld * u_world_
Definition ApiUtils.h:34
AShooterGameMode * shooter_game_mode_
Definition ApiUtils.h:35
AShooterGameMode * GetShooterGameMode() const override
Returns a pointer to AShooterGameMode.
Definition ApiUtils.cpp:26
void RemovePlayerController(AShooterPlayerController *player_controller)
Definition ApiUtils.cpp:62
UShooterCheatManager * cheatmanager_
Definition ApiUtils.h:37
void SetPlayerController(AShooterPlayerController *player_controller)
Definition ApiUtils.cpp:49
ServerStatus GetStatus() const override
Returns the current server status.
Definition ApiUtils.cpp:38
AShooterPlayerController * FindPlayerFromSteamId_Internal(uint64 steam_id) const override
Definition ApiUtils.cpp:75
void SetStatus(ServerStatus status)
Definition ApiUtils.cpp:33
UWorld * GetWorld() const override
Returns a pointer to UWorld.
Definition ApiUtils.cpp:14
static uint64 GetSteamIdFromController(AController *controller)
Returns Steam ID from player controller.
IApiUtils & GetApiUtils()
Definition ApiUtils.cpp:99