Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
sigonasr2 | 48b6b7559b | 4 months ago |
@ -1,165 +0,0 @@ |
||||
#pragma region License |
||||
/*
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com> |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above |
||||
copyright notice. This list of conditions and the following disclaimer must be |
||||
reproduced in the documentation and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may |
||||
be used to endorse or promote products derived from this software without specific |
||||
prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
|
||||
Portions of this software are copyright © 2024 The FreeType |
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information. |
||||
All rights reserved. |
||||
*/ |
||||
#pragma endregion |
||||
#include "CppUnitTest.h" |
||||
#include "AdventuresInLestoria.h" |
||||
#include "config.h" |
||||
#include "ItemDrop.h" |
||||
#include "Tutorial.h" |
||||
#include "DamageNumber.h" |
||||
#include "GameHelper.h" |
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework; |
||||
using namespace olc::utils; |
||||
|
||||
INCLUDE_MONSTER_DATA |
||||
INCLUDE_game |
||||
INCLUDE_GFX |
||||
INCLUDE_DAMAGENUMBER_LIST |
||||
INCLUDE_MONSTER_LIST |
||||
INCLUDE_INITIALIZEGAMECONFIGURATIONS |
||||
|
||||
namespace BuffTests |
||||
{ |
||||
TEST_CLASS(BuffTest) |
||||
{ |
||||
public: |
||||
std::unique_ptr<AiL>testGame; |
||||
#pragma region Setup Functions |
||||
void SetupTestMonster(){ |
||||
InitializeGameConfigurations(); |
||||
testGame.reset(new AiL(true)); |
||||
ItemAttribute::Initialize(); |
||||
ItemInfo::InitializeItems(); |
||||
testGame->InitializeGraphics(); |
||||
testGame->InitializeClasses(); |
||||
sig::Animation::InitializeAnimations(); |
||||
testGame->InitializeDefaultKeybinds(); |
||||
testGame->InitializePlayer(); |
||||
sig::Animation::SetupPlayerAnimations(); |
||||
Menu::InitializeMenus(); |
||||
Tutorial::Initialize(); |
||||
Stats::InitializeDamageReductionTable(); |
||||
|
||||
GameState::Initialize(); |
||||
GameState::STATE=GameState::states.at(States::State::GAME_RUN); |
||||
testGame->ResetLevelStates(); |
||||
|
||||
#pragma region Setup a fake test map |
||||
game->MAP_DATA["CAMPAIGN_1_1"]; |
||||
game->_SetCurrentLevel("CAMPAIGN_1_1"); |
||||
ItemDrop::ClearDrops(); |
||||
#pragma endregion |
||||
|
||||
MonsterData testMonsterData{"TestName","Test Monster",30,10,5,{MonsterDropData{"Health Potion",100.f,1,1}},200.f}; |
||||
MONSTER_DATA["TestName"]=testMonsterData; |
||||
|
||||
Menu::themes.SetInitialized(); |
||||
GFX.SetInitialized(); |
||||
DAMAGENUMBER_LIST.clear(); |
||||
} |
||||
void SetupMockMap(){ |
||||
game->MAP_DATA["CAMPAIGN_1_1"]; |
||||
ItemDrop::ClearDrops(); |
||||
} |
||||
#pragma endregion |
||||
|
||||
TEST_METHOD_INITIALIZE(BuffInitialize){ |
||||
SetupTestMonster(); |
||||
SetupMockMap(); |
||||
} |
||||
TEST_METHOD_CLEANUP(CleanupTests){ |
||||
testGame->EndGame(); |
||||
testGame->OnUserUpdate(0.f); |
||||
testGame.reset(); |
||||
} |
||||
TEST_METHOD(AddBuffMonsterCallbackExpireFunctionTest){ |
||||
Monster&m{game->SpawnMonster({},MONSTER_DATA.at("TestName"))}; |
||||
Game::Update(0.f); |
||||
Assert::AreEqual(size_t(0),m.GetBuffs(BuffType::AFFECTED_BY_LIGHTNING_BOLT).size(),L"Monsters do not have any lightning bolt affected buffs when spawning."); |
||||
m.AddBuff(BuffType::AFFECTED_BY_LIGHTNING_BOLT,3.f,1,[](std::weak_ptr<Monster>attachedTarget,Buff&b){attachedTarget.lock()->Hurt(5,attachedTarget.lock()->OnUpperLevel(),attachedTarget.lock()->GetZ());}); |
||||
Assert::AreEqual(size_t(1),m.GetBuffs(BuffType::AFFECTED_BY_LIGHTNING_BOLT).size(),L"Monster now has Affected By Lightning Bolt buff. Should get hurt for 5 damage in 3 seconds..."); |
||||
Game::Update(0.f); |
||||
Game::Update(3.f); |
||||
Assert::AreEqual(25,m.GetHealth(),L"Monster should have taken 5 health from the expired callback provided."); |
||||
} |
||||
TEST_METHOD(AddBuffPlayerCallbackExpireFunctionTest){ |
||||
Assert::AreEqual(size_t(0),game->GetPlayer()->GetBuffs(BuffType::AFFECTED_BY_LIGHTNING_BOLT).size(),L"Player does not have any lightning bolt affected buffs when spawning."); |
||||
game->GetPlayer()->AddBuff(BuffType::AFFECTED_BY_LIGHTNING_BOLT,3.f,1,[](Player*attachedTarget,Buff&b){attachedTarget->Hurt(5,attachedTarget->OnUpperLevel(),attachedTarget->GetZ());}); |
||||
Assert::AreEqual(size_t(1),game->GetPlayer()->GetBuffs(BuffType::AFFECTED_BY_LIGHTNING_BOLT).size(),L"Player is now affected By Lightning Bolt buff. Should get hurt for 5 damage in 3 seconds..."); |
||||
Game::Update(0.f); |
||||
Game::Update(3.f); |
||||
Assert::AreEqual(95,game->GetPlayer()->GetHealth(),L"Player should have taken 5 health from the expired callback provided."); |
||||
} |
||||
TEST_METHOD(MonsterHasBuffFunctionTest){ |
||||
Monster&m{game->SpawnMonster({},MONSTER_DATA.at("TestName"))}; |
||||
Game::Update(0.f); |
||||
Assert::AreEqual(false,m.HasBuff(BuffType::SPEEDBOOST),L"Monster should not have a speedboost buff before being given one."); |
||||
m.AddBuff(BuffType::ADRENALINE_RUSH,1.f,1.f); |
||||
Assert::AreEqual(false,m.HasBuff(BuffType::SPEEDBOOST),L"Monster should not have a speedboost buff when given an unrelated buff."); |
||||
m.AddBuff(BuffType::SPEEDBOOST,1.f,1.f); |
||||
Assert::AreEqual(true,m.HasBuff(BuffType::SPEEDBOOST),L"Monster should now have a speedboost buff."); |
||||
m.AddBuff(BuffType::SPEEDBOOST,2.f,1.f); |
||||
Assert::AreEqual(true,m.HasBuff(BuffType::SPEEDBOOST),L"Monster should still report having a speedboost buff."); |
||||
Game::Update(0.f); |
||||
Game::Update(1.f); |
||||
Assert::AreEqual(true,m.HasBuff(BuffType::SPEEDBOOST),L"Monster should still have one speedboost buff."); |
||||
Game::Update(1.f); |
||||
Assert::AreEqual(false,m.HasBuff(BuffType::SPEEDBOOST),L"Monster should no longer have a speedboost buff."); |
||||
m.AddBuff(BuffType::SPEEDBOOST,1.f,1.f); |
||||
m.RemoveBuff(BuffType::SPEEDBOOST); |
||||
Assert::AreEqual(false,m.HasBuff(BuffType::SPEEDBOOST),L"Monster should no longer have a speedboost buff."); |
||||
} |
||||
TEST_METHOD(PlayerHasBuffFunctionTest){ |
||||
Assert::AreEqual(false,game->GetPlayer()->HasBuff(BuffType::SPEEDBOOST),L"Player should not have a speedboost buff before being given one."); |
||||
game->GetPlayer()->AddBuff(BuffType::ADRENALINE_RUSH,1.f,1.f); |
||||
Assert::AreEqual(false,game->GetPlayer()->HasBuff(BuffType::SPEEDBOOST),L"Player should not have a speedboost buff when given an unrelated buff."); |
||||
game->GetPlayer()->AddBuff(BuffType::SPEEDBOOST,1.f,1.f); |
||||
Assert::AreEqual(true,game->GetPlayer()->HasBuff(BuffType::SPEEDBOOST),L"Player should now have a speedboost buff."); |
||||
game->GetPlayer()->AddBuff(BuffType::SPEEDBOOST,2.f,1.f); |
||||
Assert::AreEqual(true,game->GetPlayer()->HasBuff(BuffType::SPEEDBOOST),L"Player should still report having a speedboost buff."); |
||||
Game::Update(0.f); |
||||
Game::Update(1.f); |
||||
Assert::AreEqual(true,game->GetPlayer()->HasBuff(BuffType::SPEEDBOOST),L"Player should still have one speedboost buff."); |
||||
Game::Update(1.f); |
||||
Assert::AreEqual(false,game->GetPlayer()->HasBuff(BuffType::SPEEDBOOST),L"Player should no longer have a speedboost buff."); |
||||
game->GetPlayer()->AddBuff(BuffType::SPEEDBOOST,1.f,1.f); |
||||
game->GetPlayer()->RemoveBuff(BuffType::SPEEDBOOST); |
||||
Assert::AreEqual(false,game->GetPlayer()->HasBuff(BuffType::SPEEDBOOST),L"Player should no longer have a speedboost buff."); |
||||
} |
||||
}; |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,113 +0,0 @@ |
||||
#pragma region License |
||||
/*
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com> |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above |
||||
copyright notice. This list of conditions and the following disclaimer must be |
||||
reproduced in the documentation and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may |
||||
be used to endorse or promote products derived from this software without specific |
||||
prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
|
||||
Portions of this software are copyright © 2024 The FreeType |
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information. |
||||
All rights reserved. |
||||
*/ |
||||
#pragma endregion |
||||
#include "CppUnitTest.h" |
||||
#include "AdventuresInLestoria.h" |
||||
#include "config.h" |
||||
#include "ItemDrop.h" |
||||
#include "Tutorial.h" |
||||
#include "DamageNumber.h" |
||||
#include "GameHelper.h" |
||||
#include "SaveFile.h" |
||||
#include <ranges> |
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework; |
||||
using namespace olc::utils; |
||||
|
||||
INCLUDE_MONSTER_DATA |
||||
INCLUDE_game |
||||
INCLUDE_GFX |
||||
INCLUDE_DAMAGENUMBER_LIST |
||||
INCLUDE_MONSTER_LIST |
||||
INCLUDE_INITIALIZEGAMECONFIGURATIONS |
||||
|
||||
namespace FileTests |
||||
{ |
||||
TEST_CLASS(FileTest) |
||||
{ |
||||
public: |
||||
std::unique_ptr<AiL>testGame; |
||||
#pragma region Setup Functions |
||||
void SetupTest(){ |
||||
InitializeGameConfigurations(); |
||||
testGame.reset(new AiL(true)); |
||||
ItemAttribute::Initialize(); |
||||
ItemInfo::InitializeItems(); |
||||
testGame->InitializeGraphics(); |
||||
testGame->InitializeClasses(); |
||||
sig::Animation::InitializeAnimations(); |
||||
testGame->InitializeDefaultKeybinds(); |
||||
testGame->InitializePlayer(); |
||||
sig::Animation::SetupPlayerAnimations(); |
||||
Menu::InitializeMenus(); |
||||
Tutorial::Initialize(); |
||||
Stats::InitializeDamageReductionTable(); |
||||
|
||||
GameState::Initialize(); |
||||
GameState::STATE=GameState::states.at(States::State::GAME_RUN); |
||||
testGame->ResetLevelStates(); |
||||
|
||||
#pragma region Setup a fake test map |
||||
game->MAP_DATA["CAMPAIGN_1_1"]; |
||||
game->_SetCurrentLevel("CAMPAIGN_1_1"); |
||||
ItemDrop::ClearDrops(); |
||||
#pragma endregion |
||||
|
||||
MonsterData testMonsterData{"TestName","Test Monster",30,10,5,{MonsterDropData{"Health Potion",100.f,1,1}},200.f}; |
||||
MONSTER_DATA["TestName"]=testMonsterData; |
||||
|
||||
Menu::themes.SetInitialized(); |
||||
GFX.SetInitialized(); |
||||
DAMAGENUMBER_LIST.clear(); |
||||
} |
||||
void SetupMockMap(){ |
||||
game->MAP_DATA["CAMPAIGN_1_1"]; |
||||
ItemDrop::ClearDrops(); |
||||
} |
||||
#pragma endregion |
||||
|
||||
TEST_METHOD_INITIALIZE(FileTestInitialize){ |
||||
SetupTest(); |
||||
SetupMockMap(); |
||||
} |
||||
TEST_METHOD_CLEANUP(CleanupFileTests){ |
||||
testGame->EndGame(); |
||||
testGame->OnUserUpdate(0.f); |
||||
testGame.reset(); |
||||
} |
||||
}; |
||||
} |
@ -1,80 +0,0 @@ |
||||
#pragma region License |
||||
/*
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com> |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above |
||||
copyright notice. This list of conditions and the following disclaimer must be |
||||
reproduced in the documentation and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may |
||||
be used to endorse or promote products derived from this software without specific |
||||
prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
|
||||
Portions of this software are copyright © 2024 The FreeType |
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information. |
||||
All rights reserved. |
||||
*/ |
||||
#pragma endregion |
||||
#pragma once |
||||
|
||||
#include "CppUnitTest.h" |
||||
#include "AdventuresInLestoria.h" |
||||
|
||||
INCLUDE_game |
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework; |
||||
|
||||
namespace Game{ |
||||
enum class CastWaitProperty{ |
||||
WAIT_FOR_CAST_TIME, |
||||
NO_WAIT, |
||||
}; |
||||
inline void Update(const float fElapsedTime){ |
||||
game->SetElapsedTime(fElapsedTime); |
||||
game->OnUserUpdate(fElapsedTime); |
||||
} |
||||
inline void CastAbilityAtLocation(Ability&ability,const vf2d&worldLoc,const CastWaitProperty castWaitTime=CastWaitProperty::WAIT_FOR_CAST_TIME){ //NOTE: screenLoc is the actual screen coordinates, NOT the world coordinates! You are defining the mouse position essentially.
|
||||
game->GetPlayer()->SetTestScreenAimingLocation(worldLoc); |
||||
game->GetPlayer()->PrepareCast(ability); |
||||
game->GetPlayer()->CastSpell(ability); |
||||
Game::Update(ability.precastInfo.castTime); |
||||
} |
||||
inline void ChangeClass(Player*&player_in,const Class&cl){ |
||||
game->ChangePlayerClass(cl); |
||||
player_in=game->GetPlayer(); |
||||
} |
||||
inline std::weak_ptr<Item>GiveAndEquipEnchantedRing(const std::string_view enchantName,const EquipSlot slot=EquipSlot::RING1){ |
||||
std::weak_ptr<Item>nullRing{Inventory::AddItem("Null Ring"s)}; |
||||
Inventory::EquipItem(nullRing,slot); |
||||
nullRing.lock()->_EnchantItem(enchantName); |
||||
return nullRing; |
||||
} |
||||
} |
||||
|
||||
namespace Test |
||||
{ |
||||
template<class T> |
||||
inline static void InRange(T initialVal,std::pair<T,T>range,std::wstring_view assertMessage){ |
||||
Assert::IsTrue(initialVal>=range.first&&initialVal<=range.second,std::format(L"Expected: {}~{} Actual: {} - {}",range.first,range.second,initialVal,assertMessage).c_str()); |
||||
} |
||||
} |
@ -1,79 +0,0 @@ |
||||
#pragma region License |
||||
/*
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com> |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above |
||||
copyright notice. This list of conditions and the following disclaimer must be |
||||
reproduced in the documentation and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may |
||||
be used to endorse or promote products derived from this software without specific |
||||
prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
|
||||
Portions of this software are copyright © 2024 The FreeType |
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information. |
||||
All rights reserved. |
||||
*/ |
||||
#pragma endregion |
||||
|
||||
#include "Arc.h" |
||||
#include "AdventuresInLestoria.h" |
||||
|
||||
INCLUDE_game |
||||
|
||||
Arc::Arc(const vf2d pos,const float radius,const float pointingAngle,const float sweepAngle) |
||||
:pos(pos),radius(radius),pointingAngle(pointingAngle),sweepAngle(sweepAngle){ |
||||
if(sweepAngle<0.f)ERR(std::format("WARNING! Sweep angle must be greater than or equal to 0! Provided Sweep Angle: {}",sweepAngle)); |
||||
GenerateArc(); |
||||
} |
||||
void Arc::Draw(AiL*game,const Pixel col){ |
||||
game->SetDecalStructure(DecalStructure::FAN); |
||||
game->view.DrawPolygonDecal(nullptr,poly.pos,poly.pos,col); |
||||
} |
||||
const bool Arc::overlaps(const vf2d checkPos)const{ |
||||
return geom2d::overlaps(checkPos,poly); |
||||
} |
||||
void Arc::GrowRadius(const float growAmt){ |
||||
radius+=growAmt; |
||||
GenerateArc(); |
||||
} |
||||
void Arc::GenerateArc(){ |
||||
poly.pos.clear(); |
||||
//Use cut-off point between two angles
|
||||
poly.pos.emplace_back(pos); //Always add 0,0
|
||||
float smallestAng{util::radToDeg(pointingAngle-sweepAngle)+90}; |
||||
float largestAng{util::radToDeg(pointingAngle+sweepAngle)+90}; |
||||
while(smallestAng<0.f)smallestAng+=360; |
||||
while(largestAng<0.f)largestAng+=360; |
||||
int startInd{int(std::fmod(smallestAng/4+1,90))}; |
||||
int endInd{int(std::fmod(largestAng/4+1,90))}; |
||||
if(startInd>endInd){ |
||||
startInd=(startInd+3)%90; |
||||
}else{ |
||||
endInd=(endInd+3)%90; |
||||
} |
||||
for(int i=startInd;i!=endInd;i=(i+1)%game->circleCooldownPoints.size()){ |
||||
poly.pos.emplace_back(pos+game->circleCooldownPoints[i]*radius); |
||||
} |
||||
poly.pos.emplace_back(pos); //Connect back to itself.
|
||||
} |
@ -1,59 +0,0 @@ |
||||
#pragma region License |
||||
/*
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com> |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above |
||||
copyright notice. This list of conditions and the following disclaimer must be |
||||
reproduced in the documentation and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may |
||||
be used to endorse or promote products derived from this software without specific |
||||
prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
|
||||
Portions of this software are copyright © 2024 The FreeType |
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information. |
||||
All rights reserved. |
||||
*/ |
||||
#pragma endregion |
||||
#pragma once |
||||
|
||||
#include "olcUTIL_Geometry2D.h" |
||||
#include "Pixel.h" |
||||
|
||||
class AiL; |
||||
|
||||
class Arc{ |
||||
public: |
||||
//Define a sweep angle such that each direction will arc that way. Example: PI/2 means a sweep angle from -PI/2 to PI/2. MUST BE POSITIVE
|
||||
Arc(const vf2d pos,const float radius,const float pointingAngle,const float sweepAngle); |
||||
void Draw(AiL*game,const Pixel col); |
||||
const bool overlaps(const vf2d checkPos)const; |
||||
void GrowRadius(const float growAmt); |
||||
const vf2d pos; |
||||
const float pointingAngle; |
||||
const float sweepAngle; |
||||
float radius; |
||||
geom2d::polygon<float>poly; |
||||
private: |
||||
void GenerateArc(); |
||||
}; |
@ -1,75 +0,0 @@ |
||||
#pragma region License |
||||
/*
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com> |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above |
||||
copyright notice. This list of conditions and the following disclaimer must be |
||||
reproduced in the documentation and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may |
||||
be used to endorse or promote products derived from this software without specific |
||||
prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
|
||||
Portions of this software are copyright © 2024 The FreeType |
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information. |
||||
All rights reserved. |
||||
*/ |
||||
#pragma endregion |
||||
|
||||
#include "Menu.h" |
||||
#include "AdventuresInLestoria.h" |
||||
#include "MenuItemItemButton.h" |
||||
#include "DynamicMenuLabel.h" |
||||
|
||||
INCLUDE_game |
||||
|
||||
void Menu::InitializeArtificerRefineResultWindow(){ |
||||
Menu*artificerRefineResultWindow=CreateMenu(ARTIFICER_REFINE_RESULT,CENTERED,vi2d{144,144}); |
||||
|
||||
auto itemIcon{artificerRefineResultWindow->ADD("Item Icon",MenuItemItemButton)(geom2d::rect<float>{{artificerRefineResultWindow->size.x/2.f-24.f,0.f},{48.f,48.f}},Item::BLANK,DO_NOTHING,"","",IconButtonAttr::NOT_SELECTABLE)END}; |
||||
itemIcon->SetIconScale({2.f,2.f}); |
||||
|
||||
auto refineItemTextdisplay{artificerRefineResultWindow->ADD("Refine Item Text Display",MenuLabel)(geom2d::rect<float>{vf2d{0.f,artificerRefineResultWindow->size.y/2.f},vf2d{artificerRefineResultWindow->size.x,12.f}},"",1.f,ComponentAttr::SHADOW)END}; |
||||
|
||||
auto refineResultDisplay{artificerRefineResultWindow->ADD("Refine Result",DynamicMenuLabel)(geom2d::rect<float>{vf2d{0.f,artificerRefineResultWindow->size.y/2.f+artificerRefineResultWindow->size.y*0.33f},vf2d{artificerRefineResultWindow->size.x,12.f}},[](){return "";},1.f,ComponentAttr::SHADOW)END}; |
||||
|
||||
auto continueButton{artificerRefineResultWindow->ADD("Continue Button",MenuComponent)(geom2d::rect<float>{vf2d{artificerRefineResultWindow->size.x/4.f,artificerRefineResultWindow->size.y-6.f},{artificerRefineResultWindow->size.x/2.f,12.f}},"Continue",[](MenuFuncData data){ |
||||
onClick: |
||||
Menu::CloseMenu(); |
||||
return true; |
||||
})END}; |
||||
|
||||
artificerRefineResultWindow->SetupKeyboardNavigation( |
||||
[](MenuType type,Data&returnData){ //On Open
|
||||
returnData="Continue Button"; |
||||
}, |
||||
{ //Button Key
|
||||
{game->KEY_SCROLL,{"Navigate",[](MenuType type){}}}, |
||||
{game->KEY_BACK,{"Stay",[](MenuType type){ |
||||
Menu::CloseMenu(); |
||||
}}}, |
||||
{game->KEY_CONFIRM,{"Select",[](MenuType type){}}}, |
||||
} |
||||
,{ //Button Navigation Rules
|
||||
}); |
||||
} |
@ -1,59 +0,0 @@ |
||||
#pragma region License |
||||
/*
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com> |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above |
||||
copyright notice. This list of conditions and the following disclaimer must be |
||||
reproduced in the documentation and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may |
||||
be used to endorse or promote products derived from this software without specific |
||||
prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
|
||||
Portions of this software are copyright © 2024 The FreeType |
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information. |
||||
All rights reserved. |
||||
*/ |
||||
#pragma endregion |
||||
#pragma once |
||||
#include "AdventuresInLestoria.h" |
||||
#include "util.h" |
||||
#include "Effect.h" |
||||
|
||||
INCLUDE_MONSTER_LIST |
||||
|
||||
struct BlackHole:FadeInOutEffect{ |
||||
inline BlackHole(Oscillator<vf2d>pos,const std::string&img,float lifetime,bool onUpperLevel,Oscillator<vf2d>size,vf2d spd,Oscillator<Pixel>col,float rotation,float rotationSpd,bool additiveBlending=false,float particleSpawnFreq=0.f,const std::function<Effect(const Effect&self)>&particleGenerator={}) |
||||
:FadeInOutEffect(pos,img,lifetime,onUpperLevel,size,spd,col,rotation,rotationSpd,additiveBlending,particleSpawnFreq,particleGenerator){} |
||||
|
||||
inline bool Update(float fElapsedTime){ |
||||
for(std::shared_ptr<Monster>&m:MONSTER_LIST){ |
||||
float distToMonster{util::distance(pos,m->GetPos())}; |
||||
if(!m->IsSolid()&&m->OnUpperLevel()==OnUpperLevel()&&m->GetZ()<1.f&&distToMonster<="Black Hole"_ENC["PULL IN RADIUS"]/100.f*24){ |
||||
float pullInForce{util::map_range<float>(distToMonster,0,"Black Hole"_ENC["PULL IN RADIUS"]/100.f*24,"Black Hole"_ENC["PULL IN FORCE MAX"],"Black Hole"_ENC["PULL IN FORCE MIN"])}; |
||||
m->AddAddedVelocity(util::pointTo(m->GetPos(),pos)*pullInForce); |
||||
} |
||||
} |
||||
return FadeInOutEffect::Update(fElapsedTime); |
||||
} |
||||
}; |
@ -1,118 +0,0 @@ |
||||
#pragma region License |
||||
/*
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com> |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above |
||||
copyright notice. This list of conditions and the following disclaimer must be |
||||
reproduced in the documentation and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may |
||||
be used to endorse or promote products derived from this software without specific |
||||
prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
|
||||
Portions of this software are copyright © 2024 The FreeType |
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information. |
||||
All rights reserved. |
||||
*/ |
||||
#pragma endregion |
||||
|
||||
#include "MonsterStrategyHelpers.h" |
||||
#include "util.h" |
||||
#include "AdventuresInLestoria.h" |
||||
#include "SoundEffect.h" |
||||
#include "BulletTypes.h" |
||||
|
||||
using A=Attribute; |
||||
|
||||
INCLUDE_game |
||||
|
||||
void Monster::STRATEGY::CRAB(Monster&m,float fElapsedTime,std::string strategy){ |
||||
enum PhaseName{ |
||||
INIT, |
||||
MOVE, |
||||
PREPARE_CHARGE, |
||||
CHARGE, |
||||
}; |
||||
|
||||
switch(PHASE()){ |
||||
case INIT:{ |
||||
m.B(A::RANDOM_DIRECTION)=util::random()%2; |
||||
m.F(A::RANDOM_RANGE)=util::random_range(ConfigPixelsArr("Random Direction Range",0),ConfigPixelsArr("Random Direction Range",1)); |
||||
SETPHASE(MOVE); |
||||
}break;
|
||||
case MOVE:{ |
||||
m.F(A::ATTACK_COOLDOWN)+=fElapsedTime; |
||||
m.F(A::LAST_JUMP_TIMER)+=fElapsedTime; |
||||
|
||||
float distToPlayer=m.GetDistanceFrom(game->GetPlayer()->GetPos()); |
||||
|
||||
const bool outsideMaxShootingRange=distToPlayer>=ConfigPixelsArr("Stand Still and Shoot Range",1); |
||||
|
||||
if(m.F(A::LAST_JUMP_TIMER)>=ConfigFloat("Stop Check Interval")){ |
||||
if(util::random(100)<=ConfigFloat("Stop Percent")){ |
||||
SETPHASE(PREPARE_CHARGE); |
||||
m.PerformAnimation("CHARGEUP",m.GetFacingDirectionToTarget(game->GetPlayer()->GetPos())); |
||||
m.F(A::CASTING_TIMER)=ConfigFloat("Charge Wait Time"); |
||||
m.target=game->GetPlayer()->GetPos()+util::distance(m.GetPos(),game->GetPlayer()->GetPos())*util::pointTo(m.GetPos(),game->GetPlayer()->GetPos()); |
||||
}else |
||||
if(util::random(100)<=ConfigFloat("Change Direction Chance"))m.B(A::RANDOM_DIRECTION)=!m.B(A::RANDOM_DIRECTION); |
||||
m.F(A::LAST_JUMP_TIMER)=0.f; |
||||
}else |
||||
if(outsideMaxShootingRange){ |
||||
m.target=game->GetPlayer()->GetPos(); |
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards"); |
||||
}else |
||||
if(distToPlayer<ConfigPixels("Run Away Range")){ |
||||
m.target=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).upoint(-1); |
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards"); |
||||
}else |
||||
if(distToPlayer>=ConfigPixelsArr("Random Direction Range",0)&&distToPlayer<ConfigPixelsArr("Random Direction Range",1)){ |
||||
#define CW true |
||||
#define CCW false |
||||
//We are going to walk in a circular direction either CW or CCW (determined in windup phase)
|
||||
float dirFromPlayer=util::angleTo(game->GetPlayer()->GetPos(),m.GetPos()); |
||||
float targetDir=m.B(A::RANDOM_DIRECTION)==CW?dirFromPlayer+PI/4:dirFromPlayer-PI/4; |
||||
m.target=game->GetPlayer()->GetPos()+vf2d{m.F(A::RANDOM_RANGE),targetDir}.cart(); |
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
|
||||
m.F(A::CHASE_TIMER)=1.f; |
||||
} |
||||
}break; |
||||
case PREPARE_CHARGE:{ |
||||
m.F(A::CASTING_TIMER)-=fElapsedTime; |
||||
if(m.F(A::CASTING_TIMER)<=0.f){ |
||||
SETPHASE(CHARGE); |
||||
m.F(A::CHASE_TIMER)=ConfigFloat("Charge Max Time"); |
||||
m.PerformAnimation("PINCER"); |
||||
} |
||||
}break; |
||||
case CHARGE:{ |
||||
m.F(A::CHASE_TIMER)-=fElapsedTime; |
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards"); |
||||
if(m.F(A::CHASE_TIMER)<=0.f||m.ReachedTargetPos()){ |
||||
SETPHASE(MOVE); |
||||
m.B(A::RANDOM_DIRECTION)=util::random()%2; |
||||
m.F(A::RANDOM_RANGE)=util::random_range(ConfigPixelsArr("Random Direction Range",0),ConfigPixelsArr("Random Direction Range",1)); |
||||
} |
||||
}break; |
||||
} |
||||
} |
@ -1,57 +0,0 @@ |
||||
#pragma region License |
||||
/*
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com> |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above |
||||
copyright notice. This list of conditions and the following disclaimer must be |
||||
reproduced in the documentation and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may |
||||
be used to endorse or promote products derived from this software without specific |
||||
prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
|
||||
Portions of this software are copyright © 2024 The FreeType |
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information. |
||||
All rights reserved. |
||||
*/ |
||||
#pragma endregion |
||||
#pragma once |
||||
|
||||
#include "MenuLabel.h" |
||||
|
||||
//A class holding a lambda function where you return an updated menu label that is declared on creation to reduce boilerplate for menu labels that just need to update text differently..
|
||||
class DynamicMenuLabel:public MenuLabel{ |
||||
public: |
||||
inline DynamicMenuLabel(geom2d::rect<float>rect,std::function<const std::string()>labelUpdateFunc,float scale=1,ComponentAttr attributes=ComponentAttr::NONE) |
||||
:labelUpdateFunc(labelUpdateFunc),MenuLabel(rect,"",scale,attributes){} |
||||
inline void SetLabelUpdateFunction(std::function<const std::string()>labelUpdateFunc){ |
||||
this->labelUpdateFunc=labelUpdateFunc; |
||||
} |
||||
protected: |
||||
inline virtual void Update(AiL*game)override{ |
||||
SetLabel(labelUpdateFunc()); |
||||
MenuLabel::Update(game); |
||||
} |
||||
private: |
||||
std::function<const std::string()>labelUpdateFunc; |
||||
}; |
@ -1,65 +0,0 @@ |
||||
#pragma region License |
||||
/*
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com> |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above |
||||
copyright notice. This list of conditions and the following disclaimer must be |
||||
reproduced in the documentation and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may |
||||
be used to endorse or promote products derived from this software without specific |
||||
prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
|
||||
Portions of this software are copyright © 2024 The FreeType |
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information. |
||||
All rights reserved. |
||||
*/ |
||||
#pragma endregion |
||||
|
||||
#include "Effect.h" |
||||
#include "AdventuresInLestoria.h" |
||||
#include "DEFINES.h" |
||||
#include "util.h" |
||||
|
||||
INCLUDE_game |
||||
|
||||
FadeInOutEffect::FadeInOutEffect(vf2d pos,const std::string&img,float lifetime,float cycleSpd,bool onUpperLevel,float size,vf2d spd,Pixel col,float rotation,float rotationSpd,bool additiveBlending,float particleSpawnFreq,const std::function<Effect(const Effect&self)>&particleGenerator) |
||||
:FadeInOutEffect({pos,pos,cycleSpd},img,lifetime,onUpperLevel,{{size,size},{size,size},cycleSpd},spd,{col,{col.r,col.g,col.b,0},cycleSpd},rotation,rotationSpd,additiveBlending,particleSpawnFreq,particleGenerator){} |
||||
FadeInOutEffect::FadeInOutEffect(Oscillator<vf2d>pos,const std::string&img,float lifetime,bool onUpperLevel,Oscillator<vf2d>size,vf2d spd,Oscillator<Pixel>col,float rotation,float rotationSpd,bool additiveBlending,float particleSpawnFreq,const std::function<Effect(const Effect&self)>&particleGenerator) |
||||
:particleSpawnFreq(particleSpawnFreq),particleGenerator(particleGenerator),particleSpawnTimer(particleSpawnFreq),originalParticleSpawnTimer(particleSpawnTimer),posOscillator(pos),colOscillator(col),sizeOscillator(size),Effect(pos.first,lifetime,img,onUpperLevel,size.first,0.25f,spd,col.first,rotation,rotationSpd,additiveBlending){} |
||||
bool FadeInOutEffect::Update(float fElapsedTime){ |
||||
if(particleGenerator){ |
||||
particleSpawnTimer-=fElapsedTime; |
||||
if(particleSpawnTimer<=0.f){ |
||||
particleSpawnTimer+=originalParticleSpawnTimer; |
||||
game->AddEffect(std::make_unique<Effect>(particleGenerator(*this))); |
||||
} |
||||
} |
||||
pos=posOscillator.Update(fElapsedTime); |
||||
size=sizeOscillator.Update(fElapsedTime); |
||||
col=colOscillator.Update(fElapsedTime); |
||||
return Effect::Update(fElapsedTime); |
||||
} |
||||
void FadeInOutEffect::Draw(const Pixel blendCol)const{ |
||||
Effect::Draw(blendCol); |
||||
} |
@ -1,84 +0,0 @@ |
||||
#pragma region License |
||||
/*
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com> |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above |
||||
copyright notice. This list of conditions and the following disclaimer must be |
||||
reproduced in the documentation and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may |
||||
be used to endorse or promote products derived from this software without specific |
||||
prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
|
||||
Portions of this software are copyright © 2024 The FreeType |
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information. |
||||
All rights reserved. |
||||
*/ |
||||
#pragma endregion |
||||
|
||||
#include "MonsterStrategyHelpers.h" |
||||
#include "util.h" |
||||
#include "AdventuresInLestoria.h" |
||||
#include "SoundEffect.h" |
||||
#include "BulletTypes.h" |
||||
|
||||
using A=Attribute; |
||||
|
||||
INCLUDE_game |
||||
|
||||
void Monster::STRATEGY::GIANT_CRAB(Monster&m,float fElapsedTime,std::string strategy){ |
||||
enum PhaseName{ |
||||
PREPARE_CHARGE, |
||||
CHARGE, |
||||
}; |
||||
switch(PHASE()){ |
||||
case PREPARE_CHARGE:{ |
||||
m.F(A::CASTING_TIMER)-=fElapsedTime; |
||||
if(m.F(A::CASTING_TIMER)<=0.f){ |
||||
m.AddBuff(BuffType::SPEEDBOOST,ConfigFloat("Charge Time"),0.f); |
||||
m.F(A::SPEED_RAMPUP_TIMER)=0.1f; |
||||
SETPHASE(CHARGE); |
||||
} |
||||
}break; |
||||
case CHARGE:{ |
||||
m.F(A::CHASE_TIMER)+=fElapsedTime; |
||||
m.F(A::SPEED_RAMPUP_TIMER)-=fElapsedTime; |
||||
if(m.F(A::CHASE_TIMER)>=ConfigFloat("Charge Time")||m.ReachedTargetPos()){ |
||||
m.F(A::CHASE_TIMER)=0.f; |
||||
m.target=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).rpoint(util::distance(m.GetPos(),game->GetPlayer()->GetPos())+ConfigPixels("Charge Extend Distance")); |
||||
m.RemoveBuff(BuffType::SPEEDBOOST); |
||||
m.F(A::CASTING_TIMER)=ConfigFloat("Charge Wait Time"); |
||||
SETPHASE(PREPARE_CHARGE); |
||||
} |
||||
if(m.F(A::SPEED_RAMPUP_TIMER)<=0.f){ |
||||
m.F(A::SPEED_RAMPUP_TIMER)=0.1f; |
||||
if(m.HasBuff(BuffType::SPEEDBOOST)){ |
||||
const float buffIntensity{m.GetBuffs(BuffType::SPEEDBOOST)[0].intensity}; |
||||
m.EditBuff(BuffType::SPEEDBOOST,0).intensity=std::min(buffIntensity+ConfigFloat("Movespeed Rampup Final Amount")/100.f/(ConfigFloat("Movespeed Rampup Time")/0.1f),ConfigFloat("Movespeed Rampup Final Amount")/100.f); |
||||
} |
||||
} |
||||
|
||||
RUN_TOWARDS(m,fElapsedTime,"Run Towards"); |
||||
}break; |
||||
} |
||||
} |
@ -1,85 +0,0 @@ |
||||
#pragma region License |
||||
/*
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com> |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above |
||||
copyright notice. This list of conditions and the following disclaimer must be |
||||
reproduced in the documentation and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may |
||||
be used to endorse or promote products derived from this software without specific |
||||
prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
|
||||
Portions of this software are copyright © 2024 The FreeType |
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information. |
||||
All rights reserved. |
||||
*/ |
||||
#pragma endregion |
||||
|
||||
#include "MonsterStrategyHelpers.h" |
||||
#include "util.h" |
||||
#include "AdventuresInLestoria.h" |
||||
#include "SoundEffect.h" |
||||
#include "BulletTypes.h" |
||||
|
||||
using A=Attribute; |
||||
|
||||
INCLUDE_game |
||||
INCLUDE_MONSTER_LIST |
||||
|
||||
void Monster::STRATEGY::GIANT_OCTOPUS(Monster&m,float fElapsedTime,std::string strategy){ |
||||
enum PhaseName{ |
||||
IDENTIFY_ARMS, |
||||
NORMAL, |
||||
}; |
||||
switch(PHASE()){ |
||||
case IDENTIFY_ARMS:{ |
||||
m.F(A::CASTING_TIMER)=util::random_range(ConfigFloatArr("Tentacle Move Timer",0),ConfigFloatArr("Tentacle Move Timer",1)); |
||||
for(std::shared_ptr<Monster>&arm:MONSTER_LIST){ |
||||
const std::string OCTOPUS_ARM_NAME{"Octopus Arm"}; |
||||
if(arm->GetName()==OCTOPUS_ARM_NAME){ |
||||
std::weak_ptr<Monster>armPtr{arm}; |
||||
m.VEC(A::ARM_LIST).emplace_back(armPtr); |
||||
m.VEC(A::ARM_LOCATIONS).emplace_back(armPtr.lock()->GetPos()); |
||||
} |
||||
} |
||||
}break; |
||||
case NORMAL:{ |
||||
m.F(A::CASTING_TIMER)-=fElapsedTime; |
||||
if(m.F(A::CASTING_TIMER)<=0.f){ |
||||
int deadMonsterCount{0}; |
||||
std::vector<vf2d>tempArmLocs; |
||||
for(size_t i=0U;std::any&arm:m.VEC(A::ARM_LIST)){ |
||||
const std::weak_ptr<Monster>&m{std::any_cast<std::weak_ptr<Monster>>(arm)}; |
||||
if(m.expired()||m.lock()->IsDead()){ |
||||
deadMonsterCount++; |
||||
tempArmLocs.emplace_back(std::any_cast<vf2d>(m.lock()->VEC(A::ARM_LOCATIONS))); |
||||
} |
||||
} |
||||
if(deadMonsterCount>0){ |
||||
|
||||
} |
||||
} |
||||
}break; |
||||
} |
||||
} |
@ -1,102 +0,0 @@ |
||||
#pragma region License |
||||
/*
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com> |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above |
||||
copyright notice. This list of conditions and the following disclaimer must be |
||||
reproduced in the documentation and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may |
||||
be used to endorse or promote products derived from this software without specific |
||||
prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
|
||||
Portions of this software are copyright © 2024 The FreeType |
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information. |
||||
All rights reserved. |
||||
*/ |
||||
#pragma endregion |
||||
#include "AdventuresInLestoria.h" |
||||
#include "BulletTypes.h" |
||||
|
||||
INCLUDE_ITEM_SCRIPTS |
||||
INCLUDE_game |
||||
INCLUDE_ANIMATION_DATA |
||||
|
||||
void ItemInfo::InitializeScripts(){ |
||||
|
||||
ITEM_SCRIPTS["Restore"]=[](AiL*game,std::optional<vf2d>targetingPos,ItemProps props){ |
||||
for(const auto&[propName,buffType]:NameToBuffType){ |
||||
int restoreAmt=props.GetInt(propName); |
||||
|
||||
game->GetPlayer()->AddBuff(BuffRestorationType::ONE_OFF,NameToBuffType.at(propName),0.01f,float(restoreAmt),0.0f); |
||||
if(restoreAmt>0&&props.PropCount(propName)==3){ |
||||
game->GetPlayer()->AddBuff(BuffRestorationType::OVER_TIME,NameToBuffType.at(propName),props.GetFloat(propName,2),float(restoreAmt),props.GetFloat(propName,1)); |
||||
} |
||||
} |
||||
return true; |
||||
}; |
||||
|
||||
for(auto&[key,value]:ItemAttribute::attributes){ |
||||
if(!DATA.GetProperty("ItemScript.Buff").HasProperty(key)){ |
||||
ERR("WARNING! Buff Item Script does not support Buff "<<std::quoted(value.Name())<<"!"); |
||||
} |
||||
} |
||||
|
||||
ITEM_SCRIPTS["Buff"]=[](AiL*game,std::optional<vf2d>targetingPos,ItemProps props){ |
||||
for(auto&[key,value]:ItemAttribute::attributes){ |
||||
float intensity=props.GetFloat(key,0); |
||||
if(intensity==0.f)continue; |
||||
if(ItemAttribute::Get(key).DisplayAsPercent())intensity/=100; |
||||
game->GetPlayer()->AddBuff(BuffType::STAT_UP,props.GetFloat(key,1),intensity,{ItemAttribute::Get(key)}); |
||||
} |
||||
return true; |
||||
}; |
||||
ITEM_SCRIPTS["RestoreDuringCast"]=[](AiL*game,std::optional<vf2d>targetingPos,ItemProps props){ |
||||
for(const auto&[propName,buffType]:NameToBuffType){ |
||||
int restoreAmt=props.GetInt(propName); |
||||
|
||||
game->GetPlayer()->AddBuff(BuffRestorationType::ONE_OFF,NameToBuffType.at(propName),0.01f,float(restoreAmt),0.0f); |
||||
if(restoreAmt>0&&props.PropCount(propName)==3){ |
||||
game->GetPlayer()->AddBuff(BuffRestorationType::OVER_TIME_DURING_CAST,NameToBuffType.at(propName),props.GetFloat(propName,2),float(restoreAmt),props.GetFloat(propName,1)); |
||||
} |
||||
} |
||||
return true; |
||||
}; |
||||
ITEM_SCRIPTS["Projectile"]=[](AiL*game,std::optional<vf2d>targetingPos,ItemProps props){ |
||||
const int projectileDamage{props.GetInt("Base Damage")+int(game->GetPlayer()->GetAttack()*props.GetFloat("Player Damage Mult"))}; |
||||
std::optional<LingeringEffect>lingeringEffect{}; |
||||
if(props.GetFloat("Linger Time")>0.f){ |
||||
const int damage{props.GetInt("Tick Base Damage")+int(props.GetFloat("Tick Player Damage Mult")*game->GetPlayer()->GetAttack())}; |
||||
lingeringEffect.emplace(vf2d{},props.GetString("Lingering Effect"),props.GetString("Lingering Sound"),props.GetFloat("Linger Radius")/100.f*24,damage,props.GetFloat("Tick Rate"),HurtType::MONSTER,props.GetFloat("Linger Time"),5.f,game->GetPlayer()->OnUpperLevel(),1.f,vf2d{},DARK_RED,util::random(2*PI),0.f,false,0.2f, |
||||
[](const Effect&self){ |
||||
return Effect{self.pos,0.5f,"fire_ring.png",self.OnUpperLevel(),util::random_range(0.7f,1.f),0.1f,{},PixelLerp(Pixel(0xF7B752),Pixel(0xE74F30),util::random(1.f)),util::random(2*PI),0.f,true}; |
||||
}); |
||||
} |
||||
CreateBullet(ThrownProjectile)(game->GetPlayer()->GetPos(),targetingPos.value(),props.GetString("Image"),props.GetFloat("Cast Size")/100.f*24,game->GetPlayer()->GetZ(),0.3f,8.f,projectileDamage,game->GetPlayer()->OnUpperLevel(),false,INFINITE,true,WHITE,props.GetFloat("Cast Size")/100.f*vf2d{1.f,1.f},0.f, |
||||
Effect{vf2d{},ANIMATION_DATA.at("explosionframes.png").GetTotalAnimationDuration(),"explosionframes.png",game->GetPlayer()->OnUpperLevel(),props.GetFloat("Cast Size")/100.f*vf2d{1.f,1.f}},props.GetString("Explode Sound Effect"),lingeringEffect)EndBullet; |
||||
return true; |
||||
}; |
||||
|
||||
ITEM_SCRIPTS.SetInitialized(); |
||||
LOG(ITEM_SCRIPTS.size()<<" item scripts have been loaded."); |
||||
} |
@ -1,78 +0,0 @@ |
||||
#pragma region License |
||||
/*
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com> |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above |
||||
copyright notice. This list of conditions and the following disclaimer must be |
||||
reproduced in the documentation and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may |
||||
be used to endorse or promote products derived from this software without specific |
||||
prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
|
||||
Portions of this software are copyright © 2024 The FreeType |
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information. |
||||
All rights reserved. |
||||
*/ |
||||
#pragma endregion |
||||
#pragma once |
||||
|
||||
#include "MenuLabel.h" |
||||
|
||||
INCLUDE_DATA |
||||
INCLUDE_ITEM_DATA |
||||
|
||||
class MenuRefineLabel:public MenuLabel{ |
||||
public: |
||||
inline MenuRefineLabel(const geom2d::rect<float>rect,const std::weak_ptr<Item>itemRef,const float scale=1,ComponentAttr attributes=ComponentAttr::NONE) |
||||
:itemRef(itemRef),MenuLabel(rect,"",scale,attributes){} |
||||
|
||||
inline virtual void Update(AiL*game)override{ |
||||
std::string label{}; |
||||
|
||||
if(!ISBLANK(itemRef)){ |
||||
std::string longestStatName{}; |
||||
const Stats&maxStats{ITEM_DATA.at(itemRef.lock()->ActualName()).GetMaxStats()}; |
||||
for(const auto&[attr,val]:maxStats){ |
||||
const std::string displayName{attr.Name()}; |
||||
if(displayName.size()>longestStatName.size())longestStatName=displayName; |
||||
} |
||||
const std::string statNameVFormatStr{"{:"+std::to_string(longestStatName.size()+1)+"}"}; |
||||
|
||||
for(const auto&[attr,val]:itemRef.lock()->RandomStats()){ |
||||
const bool IsMaxedOut{val>=maxStats.A_Read(attr.ActualName())}; |
||||
label+=util::vformat("{}"+statNameVFormatStr+"+{:3}{:1}{}{:>5}\n",IsMaxedOut?Stats::GetShimmeringColor().toHTMLColorCode():"#FFFFFF",attr.Name(),int(round(val)),attr.DisplayAsPercent()?"%":"",IsMaxedOut?"#FF0000":"#00FF00",IsMaxedOut?"MAX":" +???"); |
||||
} |
||||
} |
||||
|
||||
SetLabel(label); |
||||
MenuLabel::Update(game); |
||||
} |
||||
|
||||
inline void SetItem(const std::weak_ptr<Item>itemRef){ |
||||
this->itemRef=itemRef; |
||||
} |
||||
|
||||
private: |
||||
std::weak_ptr<Item>itemRef; |
||||
}; |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue