Skip to content

Commit c5fe8e1

Browse files
fix PlayerEntity
1 parent 934e24e commit c5fe8e1

2 files changed

Lines changed: 25 additions & 18 deletions

File tree

include/game/PlayerEntity.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ struct PlayerAttributes {
3737
// Derived stats
3838
int attack_power = 10;
3939
int defense = 5;
40+
int max_mana = 100;
4041
float critical_chance = 0.05f;
4142
float critical_damage = 1.5f;
4243
float move_speed = 1.0f;
@@ -257,9 +258,9 @@ class PlayerEntity : public GameEntity {
257258
void UnblockPlayer(uint64_t player_id);
258259

259260
// Player systems access
260-
std::shared_ptr<InventorySystem> GetInventorySystem() const { return inventory_system_; }
261-
std::shared_ptr<SkillSystem> GetSkillSystem() const { return skill_system_; }
262-
std::shared_ptr<QuestSystem> GetQuestSystem() const { return quest_system_; }
261+
InventorySystem& GetInventorySystem() const { return inventory_system_; }
262+
SkillSystem& GetSkillSystem() const { return skill_system_; }
263+
QuestSystem& GetQuestSystem() const { return quest_system_; }
263264

264265
// Utility methods
265266
bool IsAlive() const { return stats_.health > 0; }
@@ -350,9 +351,9 @@ class PlayerEntity : public GameEntity {
350351
bool is_sprinting_ = false;
351352

352353
// Systems
353-
std::shared_ptr<InventorySystem> inventory_system_;
354-
std::shared_ptr<SkillSystem> skill_system_;
355-
std::shared_ptr<QuestSystem> quest_system_;
354+
InventorySystem& inventory_system_;
355+
SkillSystem& skill_system_;
356+
QuestSystem& quest_system_;
356357

357358
// Private methods
358359
void OnLevelUp();

src/game/PlayerEntity.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,17 @@ void PlayerSettings::Deserialize(const nlohmann::json& data) {
222222
// =============== PlayerEntity Implementation ===============
223223
PlayerEntity::PlayerEntity(const glm::vec3& position)
224224
: GameEntity(EntityType::PLAYER, position),
225-
player_class_(PlayerClass::WARRIOR),
226-
race_(PlayerRace::HUMAN),
227-
status_(PlayerStatus::IDLE) {
225+
inventory_system_(InventorySystem::GetInstance()),
226+
skill_system_(SkillSystem::GetInstance()),
227+
quest_system_(QuestSystem::GetInstance()),
228+
player_class_(PlayerClass::WARRIOR),
229+
race_(PlayerRace::HUMAN),
230+
status_(PlayerStatus::IDLE) {
228231

229232
// Initialize systems
230-
inventory_system_ = std::make_shared<InventorySystem>();
231-
skill_system_ = std::make_shared<SkillSystem>();
232-
quest_system_ = std::make_shared<QuestSystem>();
233+
// inventory_system_ = std::make_shared<InventorySystem>();
234+
// skill_system_ = std::make_shared<SkillSystem>();
235+
// quest_system_ = std::make_shared<QuestSystem>();
233236

234237
// Apply default bonuses
235238
ApplyRaceBonuses();
@@ -243,14 +246,17 @@ PlayerEntity::PlayerEntity(const glm::vec3& position)
243246

244247
PlayerEntity::PlayerEntity(const glm::vec3& position, PlayerClass player_class, PlayerRace race)
245248
: GameEntity(EntityType::PLAYER, position),
246-
player_class_(player_class),
247-
race_(race),
248-
status_(PlayerStatus::IDLE) {
249+
inventory_system_(InventorySystem::GetInstance()),
250+
skill_system_(SkillSystem::GetInstance()),
251+
quest_system_(QuestSystem::GetInstance()),
252+
player_class_(player_class),
253+
race_(race),
254+
status_(PlayerStatus::IDLE) {
249255

250256
// Initialize systems
251-
inventory_system_ = std::make_shared<InventorySystem>();
252-
skill_system_ = std::make_shared<SkillSystem>();
253-
quest_system_ = std::make_shared<QuestSystem>();
257+
// inventory_system_ = std::make_shared<InventorySystem>();
258+
// skill_system_ = std::make_shared<SkillSystem>();
259+
// quest_system_ = std::make_shared<QuestSystem>();
254260

255261
// Apply bonuses based on class and race
256262
ApplyRaceBonuses();

0 commit comments

Comments
 (0)