Fixed dumb forced const_cast on GetPos() for player (converted to const ref return type). Added test for Reaper of Souls to validate collection of souls and healing/cooldown effects work. Release Build 10703.
This commit is contained in:
parent
300e9834c7
commit
4ca3cf4426
@ -380,6 +380,30 @@ namespace EnchantTests
|
||||
break;
|
||||
}
|
||||
if(!foundSoul)Assert::Fail(L"A soul was not generated from a kill with the Reaper of Souls enchant.");
|
||||
testGame->SetElapsedTime(3.5f);
|
||||
testGame->OnUserUpdate(3.5f);
|
||||
player->Hurt(5,player->OnUpperLevel(),player->GetZ());
|
||||
player->ConsumeMana(10);
|
||||
player->GetRightClickAbility().cooldown=player->GetAbility1().cooldown=player->GetAbility2().cooldown=player->GetAbility3().cooldown=player->GetAbility4().cooldown=0.4f;
|
||||
for(int i:std::ranges::iota_view(0,2)){
|
||||
testGame->SetElapsedTime(0.001f);
|
||||
testGame->OnUserUpdate(0.001f);
|
||||
}
|
||||
Assert::AreEqual(98,player->GetHealth(),L"Player should have healed for 3 health from contacting the soul.");
|
||||
Assert::AreEqual(92,player->GetMana(),L"Player should have gained 2 mana from contacting the soul.");
|
||||
Assert::AreEqual(0.f,player->GetRightClickAbility().cooldown,L"Player's ability cooldowns should reduce from contacting the soul.");
|
||||
Assert::AreEqual(0.f,player->GetAbility1().cooldown,L"Player's ability cooldowns should reduce from contacting the soul.");
|
||||
Assert::AreEqual(0.f,player->GetAbility2().cooldown,L"Player's ability cooldowns should reduce from contacting the soul.");
|
||||
Assert::AreEqual(0.f,player->GetAbility3().cooldown,L"Player's ability cooldowns should reduce from contacting the soul.");
|
||||
Assert::AreEqual(0.f,player->GetAbility4().cooldown,L"Player's ability cooldowns should reduce from contacting the soul.");
|
||||
//This should be the moment the wisp is fading out.
|
||||
testGame->SetElapsedTime(0.5f);
|
||||
testGame->OnUserUpdate(0.5f);
|
||||
|
||||
|
||||
for(Effect*eff:game->GetAllEffects()|std::views::filter([](Effect*eff){return eff->GetType()==EffectType::MONSTER_SOUL;})){
|
||||
Assert::Fail(L"A Monster Soul has not disappeared after colliding with a player.");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
@ -64,9 +64,10 @@ bool MonsterSoul::Update(float fElapsedTime){
|
||||
z=util::lerp(7,13,abs(sin(3*PI*lifetime)));
|
||||
moveSpd+=48.f*fElapsedTime;
|
||||
vf2d projectedPos{pos+util::pointTo(pos,game->GetPlayer()->GetPos())*moveSpd*fElapsedTime};
|
||||
const bool TooCloseToPlayer{util::distance(pos,game->GetPlayer()->GetPos())<=8.f*game->GetPlayer()->GetSizeMult()};
|
||||
geom2d::line<float>collisionLine{pos,projectedPos};
|
||||
pos=projectedPos;
|
||||
if(geom2d::overlaps(collisionLine,geom2d::circle<float>(game->GetPlayer()->GetPos(),game->GetPlayer()->GetSizeMult()*8.f))){
|
||||
if(TooCloseToPlayer||geom2d::overlaps(collisionLine,geom2d::circle<float>(game->GetPlayer()->GetPos(),game->GetPlayer()->GetSizeMult()*8.f))){
|
||||
lifetime=0.f;
|
||||
fadeout=fadeoutTime;
|
||||
game->GetPlayer()->Heal("Reaper of Souls"_ENC["HEALTH GAIN"]);
|
||||
|
@ -237,8 +237,8 @@ bool Player::SetPos(vf2d pos,MoveFlag::MoveFlag flags){
|
||||
return resultX||resultY;
|
||||
}
|
||||
|
||||
vf2d&Player::GetPos()const{
|
||||
return const_cast<vf2d&>(pos);
|
||||
const vf2d&Player::GetPos()const{
|
||||
return pos;
|
||||
}
|
||||
|
||||
float Player::GetX(){
|
||||
|
@ -114,7 +114,7 @@ public:
|
||||
//one. It's hackish but it means we can reduce the amount of extra boilerplate when class changing...I don't know how to feel about this.
|
||||
Player(Player*player);
|
||||
static float GROUND_SLAM_SPIN_TIME;
|
||||
vf2d&GetPos()const;
|
||||
const vf2d&GetPos()const;
|
||||
float GetX();
|
||||
float GetY();
|
||||
float GetZ();
|
||||
|
@ -39,7 +39,7 @@ All rights reserved.
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 3
|
||||
#define VERSION_BUILD 10694
|
||||
#define VERSION_BUILD 10703
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
@ -114,7 +114,7 @@ namespace olc::utils
|
||||
}
|
||||
|
||||
// Set tracked point via pointer
|
||||
inline void SetTarget(olc::vf2d& vTarget)
|
||||
inline void SetTarget(const olc::vf2d& vTarget)
|
||||
{
|
||||
m_pTarget = &vTarget;
|
||||
}
|
||||
@ -184,7 +184,7 @@ namespace olc::utils
|
||||
// Directly moves the camera to a new point, useful when transitioning areas.
|
||||
inline void MoveCamera(vf2d pos){
|
||||
Mode prevMode=m_nMode;
|
||||
vf2d&prevTarget=*m_pTarget;
|
||||
const vf2d&prevTarget=*m_pTarget;
|
||||
SetMode(Mode::Simple);
|
||||
SetTarget(pos);
|
||||
Update(0);
|
||||
@ -251,7 +251,7 @@ namespace olc::utils
|
||||
Mode m_nMode = Mode::Simple;
|
||||
|
||||
// Target Vector2D object camera should follow (either ref or ptr)
|
||||
olc::vf2d* m_pTarget = nullptr;
|
||||
const olc::vf2d* m_pTarget = nullptr;
|
||||
olc::vf2d m_vLocalTarget;
|
||||
|
||||
// World Boundary
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user