Targets already in the air should not be knocked back. Fix image loading dependencies internally within the engine so they work even during unit testing. Rearrange some item initializing functions to occur after the GFX map is reset so all graphics are loaded properly. Release Build 9835.
This commit is contained in:
parent
6274dcefb1
commit
c879cafe1e
@ -61,7 +61,7 @@ namespace MonsterTests
|
||||
//Makes MONSTER_DATA["TestName"] available.
|
||||
void SetupTestMonster(){
|
||||
testGame.reset(new AiL());
|
||||
testGame->EnableTestingMode();
|
||||
testGame->olc_SetTestingMode(true);
|
||||
ItemAttribute::Initialize();
|
||||
ItemInfo::InitializeItems();
|
||||
testGame->InitializePlayer();
|
||||
|
@ -53,12 +53,16 @@ namespace PlayerTests
|
||||
HWButton*testKey;
|
||||
TEST_METHOD_INITIALIZE(PlayerInitialize){
|
||||
testGame.reset(new AiL());
|
||||
testGame->EnableTestingMode();
|
||||
testGame->InitializeClasses();
|
||||
testGame->InitializeDefaultKeybinds();
|
||||
Tutorial::Initialize();
|
||||
testGame->olc_SetTestingMode(true);
|
||||
ItemAttribute::Initialize();
|
||||
ItemInfo::InitializeItems();
|
||||
testGame->InitializeGraphics();
|
||||
testGame->InitializeClasses();
|
||||
sig::Animation::InitializeAnimations();
|
||||
testGame->InitializeDefaultKeybinds();
|
||||
testGame->InitializePlayer();
|
||||
Menu::InitializeMenus();
|
||||
Tutorial::Initialize();
|
||||
Stats::InitializeDamageReductionTable();
|
||||
player=testGame->GetPlayer();
|
||||
//Setup key "0" as a test input
|
||||
@ -118,5 +122,13 @@ namespace PlayerTests
|
||||
player->GetRightClickAbility().action(player,player->GetPos());
|
||||
Assert::AreEqual(int(State::BLOCK),int(player->GetState()));
|
||||
}
|
||||
TEST_METHOD(WizardCastDoesNotConsumeManaImmediately){
|
||||
testGame->ChangePlayerClass(WIZARD);
|
||||
player=testGame->GetPlayer(); //The player pointer has been reassigned...
|
||||
//Ability 3 is Meteor, which is a cast. Mana should not be consumed for a spell that begins as a cast.
|
||||
testKey->bHeld=true; //Force the key to be held down for testing purposes.
|
||||
player->CheckAndPerformAbility(player->GetAbility3(),testKeyboardInput);
|
||||
Assert::AreEqual(player->GetMaxMana(),player->GetMana());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -267,10 +267,6 @@ bool AiL::OnUserCreate(){
|
||||
|
||||
VisualNovel::Initialize();
|
||||
|
||||
ItemAttribute::Initialize();
|
||||
|
||||
ItemInfo::InitializeItems();
|
||||
|
||||
InitializeGraphics();
|
||||
InitializeClasses();
|
||||
|
||||
@ -3584,6 +3580,15 @@ void AiL::RenderMenu(){
|
||||
}
|
||||
|
||||
void AiL::InitializeGraphics(){
|
||||
circleCooldownPoints.clear();
|
||||
squareCircleCooldownPoints.clear();
|
||||
GFX.Reset();
|
||||
Menu::themes.Reset();
|
||||
|
||||
//These two create item graphics, so they should be after the GFX structure gets reset!
|
||||
ItemAttribute::Initialize();
|
||||
ItemInfo::InitializeItems();
|
||||
|
||||
circleCooldownPoints.push_back({0,0});
|
||||
squareCircleCooldownPoints.push_back({0,0});
|
||||
for(int i=0;i<=360;i+=4){
|
||||
@ -4395,11 +4400,3 @@ void AiL::UsingSteamAPI(const bool usingSteam){
|
||||
void AiL::InitializePlayer(){
|
||||
player=std::make_unique<Warrior>();
|
||||
}
|
||||
|
||||
void AiL::EnableTestingMode(){
|
||||
testingMode=true;
|
||||
}
|
||||
|
||||
const bool AiL::TestingModeEnabled()const{
|
||||
return testingMode;
|
||||
}
|
@ -217,7 +217,6 @@ private:
|
||||
std::optional<vf2d>bossIndicatorPos{};
|
||||
bool steamAPIEnabled{true};
|
||||
Overlay hudOverlay{"pixel.png",BLANK};
|
||||
bool testingMode{false};
|
||||
public:
|
||||
AiL();
|
||||
bool OnUserCreate() override;
|
||||
@ -367,8 +366,6 @@ public:
|
||||
const HurtList HurtMonsterType(vf2d pos,float radius,int damage,bool upperLevel,float z,const std::string_view monsterName)const;
|
||||
void InitializeGameConfigurations();
|
||||
void InitializePlayer();
|
||||
void EnableTestingMode();
|
||||
const bool TestingModeEnabled()const;
|
||||
|
||||
struct TileGroupData{
|
||||
vi2d tilePos;
|
||||
|
@ -46,6 +46,8 @@ INCLUDE_DATA
|
||||
INCLUDE_GFX
|
||||
|
||||
void sig::Animation::InitializeAnimations(){
|
||||
ANIMATION_DATA.Reset();
|
||||
|
||||
auto CreateStillAnimation=[&](std::string imgName,vf2d size,AnimationData data={}){
|
||||
Animate2D::FrameSequence anim(data.frameDuration,data.style);
|
||||
anim.AddFrame({&GFX[imgName],{{0,0},size}});
|
||||
|
@ -52,7 +52,7 @@ Bullet::Bullet(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool fr
|
||||
|
||||
Bullet::Bullet(vf2d pos,vf2d vel,float radius,int damage,std::string animation,bool upperLevel,bool hitsMultiple,float lifetime,bool rotatesWithAngle,bool friendly,Pixel col,vf2d scale,float image_angle)
|
||||
:pos(pos),vel(vel),radius(radius),damage(damage),col(col),animated(true),rotates(rotatesWithAngle),lifetime(lifetime),hitsMultiple(hitsMultiple),friendly(friendly),upperLevel(upperLevel),scale(scale),image_angle(image_angle){
|
||||
this->animation.AddState(animation,ANIMATION_DATA[animation]);
|
||||
this->animation.AddState(animation,ANIMATION_DATA.at(animation));
|
||||
this->animation.ChangeState(internal_animState,animation);
|
||||
};
|
||||
|
||||
|
@ -146,6 +146,7 @@ void Menu::InitializeCharacterMenuWindow(){
|
||||
|
||||
characterMenuWindow->ADD("Character Label",MenuLabel)(geom2d::rect<float>{{0,-4},{float(windowSize.x)-1,24}},"Character",2,ComponentAttr::SHADOW|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND)END;
|
||||
characterMenuWindow->ADD("Equip Slot Outline",MenuComponent)(geom2d::rect<float>{{0,28},{120,windowSize.y-37}},"",DO_NOTHING,ButtonAttr::UNSELECTABLE)END;
|
||||
//Don't load this graphical element if testing mode is enabled.
|
||||
characterMenuWindow->ADD("Character Rotating Display",CharacterRotatingDisplay)(geom2d::rect<float>{{118,18},{130,windowSize.y-28}},GFX[classutils::GetClassInfo(game->GetPlayer()->GetClassName()).classFullImgName].Decal())END;
|
||||
|
||||
characterMenuWindow->ADD("Level Class Display",MenuLabel)(geom2d::rect<float>{vf2d{126.f,windowSize.y-28},{118.f,8.f}},std::format("Lv{} {}",game->GetPlayer()->Level(),game->GetPlayer()->GetClassName()),1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
|
||||
|
@ -45,13 +45,11 @@ INCLUDE_game
|
||||
|
||||
Effect::Effect(vf2d pos,float lifetime,std::string imgFile,bool upperLevel,float size,float fadeout,vf2d spd,Pixel col,float rotation,float rotationSpd,bool additiveBlending)
|
||||
:Effect::Effect(pos,lifetime,imgFile,upperLevel,vf2d{size,size},fadeout,spd,col,rotation,rotationSpd,additiveBlending){
|
||||
if(game->TestingModeEnabled())return;
|
||||
this->animation.AddState(imgFile,ANIMATION_DATA[imgFile]);
|
||||
}
|
||||
|
||||
Effect::Effect(vf2d pos,float lifetime,std::string imgFile,bool upperLevel,vf2d size,float fadeout,vf2d spd,Pixel col,float rotation,float rotationSpd,bool additiveBlending)
|
||||
:pos(pos),lifetime(lifetime),upperLevel(upperLevel),size(size),fadeout(fadeout),original_fadeoutTime(fadeout),spd(spd),col(col),rotation(rotation),rotationSpd(rotationSpd),additiveBlending(additiveBlending){
|
||||
if(game->TestingModeEnabled())return;
|
||||
this->animation.AddState(imgFile,ANIMATION_DATA[imgFile]);
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ enum class IconButtonAttr{
|
||||
|
||||
class MenuIconButton:public MenuComponent{
|
||||
protected:
|
||||
Decal*icon;
|
||||
Decal*icon{nullptr};
|
||||
vf2d iconScale{1,1};
|
||||
Pixel tint=WHITE;
|
||||
public:
|
||||
|
@ -932,7 +932,7 @@ geom2d::circle<float>Monster::BulletCollisionHitbox(){
|
||||
}
|
||||
|
||||
void Monster::Knockback(const vf2d&vel){
|
||||
if(IsSolid())return;
|
||||
if(IsSolid()||GetZ()>=1.f)return;
|
||||
//A new angle will be applied, but will be constrained by whichever applied velocity is strongest (either the current velocity, or the new one). This prevents continuous uncapped velocities to knockbacks applied.
|
||||
if(vel==vf2d{})return;
|
||||
float maxVelThreshold;
|
||||
|
@ -307,7 +307,7 @@ State::State Player::GetState(){
|
||||
|
||||
void Player::Knockback(vf2d vel){
|
||||
//A new angle will be applied, but will be constrained by whichever applied velocity is strongest (either the current velocity, or the new one). This prevents continuous uncapped velocities to knockbacks applied.
|
||||
if(vel==vf2d{})return;
|
||||
if(vel==vf2d{}||GetZ()>=1.f)return;
|
||||
float maxVelThreshold;
|
||||
if(GetState()==State::BLOCK)vel*=1-("Warrior.Right Click Ability.Knockback Reduction"_I/100.f);
|
||||
if(this->vel==vf2d{})maxVelThreshold=vel.mag();
|
||||
@ -811,7 +811,6 @@ void Player::AddAnimation(std::string state){
|
||||
}
|
||||
|
||||
void Player::UpdateAnimation(std::string animState,int specificClass, const float frameMult){
|
||||
if(game->TestingModeEnabled())return;
|
||||
if(specificClass==ANY||specificClass&GetClass()){
|
||||
animation.ChangeState(internal_animState,animState,frameMult);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ All rights reserved.
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 3
|
||||
#define VERSION_BUILD 9814
|
||||
#define VERSION_BUILD 9835
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
@ -1043,6 +1043,7 @@ namespace olc
|
||||
// Gets "screen" size
|
||||
const olc::vi2d& GetScreenSize() const;
|
||||
const bool IsFullscreen()const;
|
||||
const bool TestingModeEnabled()const;
|
||||
// Gets any files dropped this frame
|
||||
const std::vector<std::string>& GetDroppedFiles() const;
|
||||
const olc::vi2d& GetDroppedFilesPoint() const;
|
||||
@ -1359,6 +1360,8 @@ namespace olc
|
||||
bool pMouseOldState[nMouseButtons] = { 0 };
|
||||
HWButton pMouseState[nMouseButtons] = { 0 };
|
||||
|
||||
bool testingMode{false};
|
||||
|
||||
// The main engine thread
|
||||
void EngineThread();
|
||||
|
||||
@ -1387,6 +1390,8 @@ namespace olc
|
||||
void olc_Reanimate();
|
||||
bool olc_IsRunning();
|
||||
|
||||
void olc_SetTestingMode(const bool testingMode);
|
||||
|
||||
// At the very end of this file, chooses which
|
||||
// components to compile
|
||||
virtual void olc_ConfigureSystem();
|
||||
@ -1708,7 +1713,7 @@ namespace olc
|
||||
Decal::Decal(olc::Sprite* spr, bool filter, bool clamp)
|
||||
{
|
||||
id = -1;
|
||||
if (spr == nullptr) return;
|
||||
if (renderer->ptrPGE->TestingModeEnabled()||spr == nullptr) return;
|
||||
sprite = spr;
|
||||
id = renderer->CreateTexture(sprite->width, sprite->height, filter, clamp);
|
||||
Update();
|
||||
@ -1716,13 +1721,13 @@ namespace olc
|
||||
|
||||
Decal::Decal(const uint32_t nExistingTextureResource, olc::Sprite* spr)
|
||||
{
|
||||
if (spr == nullptr) return;
|
||||
if (renderer->ptrPGE->TestingModeEnabled()||spr == nullptr) return;
|
||||
id = nExistingTextureResource;
|
||||
}
|
||||
|
||||
void Decal::Update()
|
||||
{
|
||||
if (sprite == nullptr) return;
|
||||
if (renderer->ptrPGE->TestingModeEnabled()||sprite == nullptr) return;
|
||||
vUVScale = { 1.0f / float(sprite->width), 1.0f / float(sprite->height) };
|
||||
renderer->ApplyTexture(id);
|
||||
renderer->UpdateTexture(id, sprite);
|
||||
@ -1730,7 +1735,7 @@ namespace olc
|
||||
|
||||
void Decal::UpdateSprite()
|
||||
{
|
||||
if (sprite == nullptr) return;
|
||||
if (renderer->ptrPGE->TestingModeEnabled()||sprite == nullptr) return;
|
||||
renderer->ApplyTexture(id);
|
||||
renderer->ReadTexture(id, sprite);
|
||||
}
|
||||
@ -2034,7 +2039,7 @@ namespace olc
|
||||
else
|
||||
{
|
||||
nTargetLayer = 0;
|
||||
pDrawTarget = vLayers[0].pDrawTarget.Sprite();
|
||||
if(!TestingModeEnabled())pDrawTarget = vLayers[0].pDrawTarget.Sprite();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2203,6 +2208,10 @@ namespace olc
|
||||
return bFullScreen;
|
||||
}
|
||||
|
||||
const bool PixelGameEngine::TestingModeEnabled()const{
|
||||
return testingMode;
|
||||
}
|
||||
|
||||
const olc::vi2d& PixelGameEngine::GetWindowMouse() const
|
||||
{ return vMouseWindowPos; }
|
||||
|
||||
@ -3950,6 +3959,7 @@ namespace olc
|
||||
|
||||
olc::vi2d PixelGameEngine::GetTextSizeProp(std::string_view s)
|
||||
{
|
||||
if(vFontSpacing.size()==0)return{}; //Hack to allow for testing mode to just return a default value.
|
||||
olc::vi2d size = { 0,1 };
|
||||
olc::vi2d pos = { 0,1 };
|
||||
for (int skip=0;auto c : s)
|
||||
@ -4565,6 +4575,10 @@ namespace olc
|
||||
bool PixelGameEngine::olc_IsRunning()
|
||||
{ return bAtomActive; }
|
||||
|
||||
void PixelGameEngine::olc_SetTestingMode(const bool testingMode){
|
||||
this->testingMode=testingMode;
|
||||
}
|
||||
|
||||
void PixelGameEngine::olc_Terminate()
|
||||
{ bAtomActive = false; }
|
||||
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user