mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
introduce local player
This commit is contained in:
parent
b5999fe364
commit
65fec4f4a9
16 changed files with 84 additions and 31 deletions
|
|
@ -20,10 +20,19 @@ Player* Players::get(int64_t id) const {
|
|||
return found->second.get();
|
||||
}
|
||||
|
||||
Player* Players::create() {
|
||||
Player* Players::create(int64_t id) {
|
||||
int64_t& nextPlayerID = level.getWorld()->getInfo().nextPlayerId;
|
||||
if (id == NONE) {
|
||||
id = nextPlayerID++;
|
||||
} else {
|
||||
if (auto player = get(id)) {
|
||||
return player;
|
||||
}
|
||||
nextPlayerID = std::max(id + 1, nextPlayerID);
|
||||
}
|
||||
auto playerPtr = std::make_unique<Player>(
|
||||
level,
|
||||
level.getWorld()->getInfo().nextPlayerId++,
|
||||
id,
|
||||
"",
|
||||
glm::vec3(0, DEF_PLAYER_Y, 0),
|
||||
DEF_PLAYER_SPEED,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue