42 lines
1.3 KiB
C++
42 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <raylib.h>
|
|
#include <unordered_map>
|
|
#include <string>
|
|
#include <cstdint>
|
|
#include "../../render/RenderContext.hpp"
|
|
|
|
class PlayerRenderer {
|
|
private:
|
|
Model localPlayerModel;
|
|
std::unordered_map<uint32_t, Model> remotePlayerModels;
|
|
std::unordered_map<std::string, Texture2D> playerTextures;
|
|
|
|
public:
|
|
PlayerRenderer();
|
|
~PlayerRenderer();
|
|
|
|
// Initialize player models and textures
|
|
void init();
|
|
|
|
// Render local player
|
|
void renderLocalPlayer(RenderContext& ctx, const Vector3& position, const std::string& color);
|
|
|
|
// Render remote players
|
|
void renderRemotePlayers(RenderContext& ctx, const std::unordered_map<uint32_t, struct RemotePlayer>& players);
|
|
|
|
// Update player model for a specific player ID
|
|
void ensurePlayerModel(uint32_t playerId);
|
|
|
|
// Remove model for disconnected player
|
|
void removePlayerModel(uint32_t playerId);
|
|
|
|
// Clean up models for players not in the list
|
|
void cleanupDisconnectedPlayers(const std::unordered_map<uint32_t, struct RemotePlayer>& currentPlayers);
|
|
|
|
// Get texture for a color
|
|
Texture2D getPlayerTexture(const std::string& color) const;
|
|
};
|
|
|
|
// Forward declaration for RemotePlayer struct (defined in NetworkManager)
|
|
struct RemotePlayer; |