DoorNroll/src/hub/RestRoom.cpp

74 lines
2 KiB
C++

#include "RestRoom.hpp"
namespace dnr {
RestRoom::RestRoom() = default;
void RestRoom::init(Player& player, int completedFloor) {
m_completedFloor = completedFloor;
m_recharged = false;
// Spawn player in the Safe Haven at (3, 4) facing North toward the recharge matrix
player.setGridPosition(3, 4);
player.setFacing(Direction::NORTH);
}
void RestRoom::update(float dt, Player& player) {
player.update(dt);
}
bool RestRoom::tryMove(int dx, int dy, Player& player) {
int nx = player.getGridX() + dx;
int ny = player.getGridY() + dy;
// Outer boundaries
if (nx < 1 || nx > 5 || ny < 1 || ny > 5) return false;
// Obstacle: Central nanite recharge pod at (3, 3)
if (nx == 3 && ny == 3) return false;
// Obstacle: Terminal at (1, 3)
if (nx == 1 && ny == 3) return false;
player.setGridPosition(nx, ny);
return true;
}
bool RestRoom::isFacingGateway(const Player& player) const {
// Gateway is at North wall (3, 0)
int px = player.getGridX();
int py = player.getGridY();
Direction f = player.getFacing();
return (px == 3 && py == 1 && f == Direction::NORTH);
}
bool RestRoom::isFacingRechargeMatrix(const Player& player) const {
// Central recharge station at (3, 3)
int px = player.getGridX();
int py = player.getGridY();
Direction f = player.getFacing();
if (px == 3 && py == 4 && f == Direction::NORTH) return true;
if (px == 3 && py == 2 && f == Direction::SOUTH) return true;
if (px == 2 && py == 3 && f == Direction::EAST) return true;
if (px == 4 && py == 3 && f == Direction::WEST) return true;
return false;
}
bool RestRoom::isFacingTerminal(const Player& player) const {
// Save terminal at (1, 3)
int px = player.getGridX();
int py = player.getGridY();
Direction f = player.getFacing();
return (px == 2 && py == 3 && f == Direction::WEST);
}
void RestRoom::triggerRecharge(Player& player) {
player.heal(player.getMaxHp());
player.restoreShield(player.getMaxShield());
m_recharged = true;
}
} // namespace dnr