Bugfix for effect container refactor. Ref Commit 9d969bcca83e7856d873ac21a49c2b596fe46cce
Some checks failed
Emscripten Build / Build_and_Deploy_Web_Build (push) Failing after 24m21s
Some checks failed
Emscripten Build / Build_and_Deploy_Web_Build (push) Failing after 24m21s
Created templated version of AddEffect to reintroduce class hierarchy conversions for Effect pointers inside the effect containers. Release Build 13031.
This commit is contained in:
parent
9d969bcca8
commit
9f1e701537
@ -392,14 +392,14 @@ namespace EnchantTests
|
||||
Monster testMonster2{{},MONSTER_DATA["TestName"]};
|
||||
testMonster.Hurt(1000,testMonster.OnUpperLevel(),testMonster.GetZ());
|
||||
Game::Update(0.5f);
|
||||
for(Effect*eff:game->GetAllEffects()|std::views::filter([](Effect*eff){return eff->GetType()==EffectType::MONSTER_SOUL;})){
|
||||
for(std::shared_ptr<Effect>&eff:game->GetAllEffects()|std::views::filter([](std::shared_ptr<Effect>&eff){return eff->GetType()==EffectType::MONSTER_SOUL;})){
|
||||
Assert::Fail(L"A Monster Soul should not be generated");
|
||||
}
|
||||
Game::GiveAndEquipEnchantedRing("Reaper of Souls");
|
||||
testMonster2.Hurt(1000,testMonster2.OnUpperLevel(),testMonster2.GetZ());
|
||||
Game::Update(0.5f);
|
||||
bool foundSoul{false};
|
||||
for(const Effect*eff:game->GetAllEffects()|std::views::filter([](const Effect*eff){return eff->GetType()==EffectType::MONSTER_SOUL;})){
|
||||
for(const std::shared_ptr<Effect>&eff:game->GetAllEffects()|std::views::filter([](const std::shared_ptr<Effect>&eff){return eff->GetType()==EffectType::MONSTER_SOUL;})){
|
||||
foundSoul=true;
|
||||
break;
|
||||
}
|
||||
@ -420,7 +420,7 @@ namespace EnchantTests
|
||||
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.
|
||||
Game::Update(0.5f);
|
||||
for(Effect*eff:game->GetAllEffects()|std::views::filter([](Effect*eff){return eff->GetType()==EffectType::MONSTER_SOUL;})){
|
||||
for(std::shared_ptr<Effect>&eff:game->GetAllEffects()|std::views::filter([](std::shared_ptr<Effect>&eff){return eff->GetType()==EffectType::MONSTER_SOUL;})){
|
||||
Assert::Fail(L"A Monster Soul has not disappeared after colliding with a player.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -2243,15 +2243,6 @@ void AiL::RenderCooldowns(){
|
||||
drawutil::DrawAbilityTooltipAtMouseCursor(this);
|
||||
}
|
||||
|
||||
std::pair<ForegroundWrapper,BackgroundWrapper>AiL::AddEffect(Effect&&foreground,Effect&&background){
|
||||
return {AddEffect(std::move(foreground)),AddEffect(std::move(background),true)};
|
||||
}
|
||||
|
||||
std::weak_ptr<Effect>AiL::AddEffect(Effect&&effect,bool back){
|
||||
if(back)return backgroundEffectsToBeInserted.emplace_back(std::make_shared<Effect>(effect));
|
||||
else return foregroundEffectsToBeInserted.emplace_back(std::make_shared<Effect>(effect));
|
||||
}
|
||||
|
||||
vf2d AiL::GetWorldMousePos(){
|
||||
return GetMousePos()+view.GetWorldOffset();
|
||||
}
|
||||
|
||||
@ -199,9 +199,6 @@ public:
|
||||
void RenderHud();
|
||||
void RenderMenu();
|
||||
bool MenuClicksDeactivated()const;
|
||||
std::pair<ForegroundWrapper,BackgroundWrapper>AddEffect(Effect&&foreground,Effect&&background);
|
||||
//If back is true, places the effect in the background.
|
||||
std::weak_ptr<Effect>AddEffect(Effect&&effect,bool back=false);
|
||||
const std::vector<std::shared_ptr<Effect>>GetEffect(EffectType type);
|
||||
std::vector<Entity>GetTargetsInRange(vf2d pos,float radius,bool upperLevel,float z,const HurtType hurtTargets)const;
|
||||
const HurtList Hurt(vf2d pos,float radius,int damage,bool upperLevel,float z,const HurtType hurtTargets,HurtFlag::HurtFlag hurtFlags=HurtFlag::NONE)const;
|
||||
@ -353,6 +350,17 @@ public:
|
||||
|
||||
void PrecacheNewLevels();
|
||||
bool savingFile=false;
|
||||
|
||||
//If back is true, places the effect in the background.
|
||||
template<typename T>
|
||||
inline std::weak_ptr<T>AddEffect(T&&effect,bool back=false){
|
||||
if(back)return DYNAMIC_POINTER_CAST<T>(backgroundEffectsToBeInserted.emplace_back(std::make_shared<T>(std::move(effect))));
|
||||
else return DYNAMIC_POINTER_CAST<T>(foregroundEffectsToBeInserted.emplace_back(std::make_shared<T>(std::move(effect))));
|
||||
}
|
||||
template<typename T>
|
||||
inline std::pair<ForegroundWrapper,BackgroundWrapper>AddEffect(T&&foreground,T&&background){
|
||||
return {AddEffect(std::move(foreground)),AddEffect(std::move(background),true)};
|
||||
}
|
||||
private:
|
||||
std::vector<std::shared_ptr<Effect>>foregroundEffects,backgroundEffects,foregroundEffectsToBeInserted,backgroundEffectsToBeInserted;
|
||||
std::vector<TileRenderData*>tilesWithCollision,tilesWithoutCollision;
|
||||
|
||||
@ -48,9 +48,9 @@ public:
|
||||
BlizzardSnowEmitter(const olc::vf2d pos,const std::string&img_filename,const float radius,std::pair<MinScale,MaxScale>scaleRange,float frequency,float timer,const bool upperLevel);
|
||||
virtual void Emit()override final;
|
||||
private:
|
||||
const olc::vf2d pos;
|
||||
const float radius;
|
||||
const std::pair<MinScale,MaxScale>scaleRange;
|
||||
const std::string img_filename;
|
||||
const bool upperLevel;
|
||||
olc::vf2d pos;
|
||||
float radius;
|
||||
std::pair<MinScale,MaxScale>scaleRange;
|
||||
std::string img_filename;
|
||||
bool upperLevel;
|
||||
};
|
||||
@ -269,12 +269,12 @@ public:
|
||||
Blizzard(const vf2d pos,const float radius,const float lifetime,const int damage,const float tickRate,const std::pair<MinScale,MaxScale>snowSizeRange,const float emitterFreq,const bool upperLevel,const FriendlyType friendly);
|
||||
bool Update(float fElapsedTime)override; //NOTE: In most cases, call Effect::Update() in your overwritten function!
|
||||
private:
|
||||
const int damage;
|
||||
const float tickRate;
|
||||
int damage;
|
||||
float tickRate;
|
||||
float tickTimer;
|
||||
const float radius;
|
||||
const FriendlyType friendly;
|
||||
const std::unique_ptr<BlizzardSnowEmitter>snow;
|
||||
float radius;
|
||||
FriendlyType friendly;
|
||||
std::unique_ptr<BlizzardSnowEmitter>snow;
|
||||
EnvironmentalAudio blizzardSFX;
|
||||
};
|
||||
|
||||
|
||||
@ -56,9 +56,11 @@ class LightningBoltEmitter:public IEmitter{
|
||||
vf2d startPos,endPos;
|
||||
bool upperLevel;
|
||||
void DrawLightningBolt();
|
||||
std::vector<std::weak_ptr<Effect>>activeLightningBolts;
|
||||
public:
|
||||
virtual ~LightningBoltEmitter()=default;
|
||||
LightningBoltEmitter(vf2d startPos,vf2d endPos,float frequency,float timer,bool upperLevel);
|
||||
void SetStartEndPos(vf2d startPos,vf2d endPos);
|
||||
void Emit()override;
|
||||
void ChangeActiveLightningTarget(vf2d newPos);
|
||||
};
|
||||
@ -40,6 +40,7 @@ All rights reserved.
|
||||
#include "util.h"
|
||||
#include "AdventuresInLestoria.h"
|
||||
#include "DEFINES.h"
|
||||
#include<memory>
|
||||
|
||||
INCLUDE_game
|
||||
|
||||
@ -48,9 +49,16 @@ LightningBoltEmitter::LightningBoltEmitter(vf2d startPos,vf2d endPos,float frequ
|
||||
|
||||
|
||||
void LightningBoltEmitter::Emit(){
|
||||
std::erase_if(activeLightningBolts,[](const std::weak_ptr<Effect>&ptr){return ptr.expired();});
|
||||
DrawLightningBolt();
|
||||
}
|
||||
|
||||
void LightningBoltEmitter::ChangeActiveLightningTarget(vf2d newPos){
|
||||
for(std::weak_ptr<Effect>&activeLightningBolt:activeLightningBolts|std::views::filter([](std::weak_ptr<Effect>&ptr){return !ptr.expired();}){
|
||||
activeLightningBolt.lock();
|
||||
}
|
||||
}
|
||||
|
||||
void LightningBoltEmitter::DrawLightningBolt(){
|
||||
vf2d currentPos=startPos;
|
||||
const int MAX_ITERATIONS=100;
|
||||
|
||||
@ -39,7 +39,7 @@ All rights reserved.
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_BUILD 13018
|
||||
#define VERSION_BUILD 13031
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user