Test pickup

This commit is contained in:
MarcEricMartel
2023-12-18 14:50:18 -05:00
parent 25b5c1e492
commit 6d07285f43
4 changed files with 21 additions and 5 deletions

View File

@@ -1343,7 +1343,7 @@ void Engine::Render(float elapsedTime) {
static bool leftright = false;
if (pollTime >= .005f) {
Player::Sound snd = m_player.ApplyPhysics(m_player.GetInput(m_keyW, m_keyS, m_keyA, m_keyD, m_keySpace, (bloc == BTYPE_LAST && bulletTime <= 0.f && m_mouseL), elapsedTime), &m_world, elapsedTime, m_boosters);
Player::Sound snd = m_player.ApplyPhysics(m_player.GetInput(m_keyW, m_keyS, m_keyA, m_keyD, m_keySpace, (bloc == BTYPE_LAST && bulletTime <= 0.f && m_mouseL), elapsedTime), &m_world, elapsedTime);
switch (snd) {
case Player::Sound::STEP:
if (leftright)
@@ -1361,6 +1361,9 @@ void Engine::Render(float elapsedTime) {
// son vecteur de velocite (pour l'effet Doppler)
pollTime = 0;
}
uint64_t boostid = m_player.TakeBooster(m_boosters, elapsedTime);
m_boost_manifest.insert(boostid);
m_player.ApplyTransformation(all);
@@ -1511,7 +1514,17 @@ void Engine::Render(float elapsedTime) {
if (Deserialize(&pmod, pck, &bsize)) {
if (m_boosters.count(pmod.id)) {
Booster* boost = m_boosters.at(pmod.id);
std::cout << "Ramassé booster selon serveur " << (pmod.boost.damage ? "damage" : "") << (pmod.boost.hp ? "heal" : "") << (pmod.boost.invincible ? "invincible" : "");
if (m_boost_manifest.count(boost->GetId())) {
std::string str = "Picked up ";
if (pmod.boost.damage)
str.append("Damage Booster");
else if (pmod.boost.hp)
str.append("Healing");
else if (pmod.boost.invincible)
str.append("Invincibility");
else break;
SystemNotification(str);
}
boost->SetAvailability(pmod.available);
}
else {

View File

@@ -259,6 +259,7 @@ private:
netprot::Buffer m_buf, m_bufout;
netprot::ChunkMod* m_chunkmod = nullptr;
std::unordered_map<uint64_t, Booster*> m_boosters;
std::set<uint64_t> m_boost_manifest;
std::unordered_map<uint64_t, netprot::Sync> m_syncs;
std::string m_messageNotification = "";