diff --git a/Crawler/Crawler.vcxproj b/Crawler/Crawler.vcxproj index 4965199f..d4108078 100644 --- a/Crawler/Crawler.vcxproj +++ b/Crawler/Crawler.vcxproj @@ -307,7 +307,6 @@ - diff --git a/Crawler/Crawler.vcxproj.filters b/Crawler/Crawler.vcxproj.filters index 285214a1..b356cacf 100644 --- a/Crawler/Crawler.vcxproj.filters +++ b/Crawler/Crawler.vcxproj.filters @@ -239,9 +239,6 @@ Source Files\Monster Strategies - - Source Files - diff --git a/Crawler/Monster.cpp b/Crawler/Monster.cpp index fc17b83c..e61300f2 100644 --- a/Crawler/Monster.cpp +++ b/Crawler/Monster.cpp @@ -110,9 +110,6 @@ bool Monster::SetY(float y){ bool Monster::Update(float fElapsedTime){ lastHitTimer=std::max(0.f,lastHitTimer-fElapsedTime); iframe_timer=std::max(0.f,iframe_timer-fElapsedTime); - Set(Attribute::SHOOT_RING_TIMER,std::max(0.f,GetFloat(Attribute::SHOOT_RING_TIMER)-fElapsedTime)); - Set(Attribute::SHOOT_RING_DELAY,std::max(0.f,GetFloat(Attribute::SHOOT_RING_DELAY)-fElapsedTime)); - Set(Attribute::SHOOT_RING_COUNTER,std::max(0.f,GetFloat(Attribute::SHOOT_RING_COUNTER)-fElapsedTime)); if(size!=targetSize){ if(size>targetSize){ size=std::max(targetSize,size-Crawler::SIZE_CHANGE_SPEED*fElapsedTime); @@ -384,54 +381,30 @@ void Monster::SetSize(float newSize,bool immediate){ } } -void Monster::Set(_ATTRIBUTE a,std::variantval){ - attributes[a]=val; - //Error handling below! - //The idea is if we cannot retrieve the value, the program errors out. - switch(a.type){ - case ATTRIBUTE_TYPE::FLOAT:{ - GetFloat(a); - }break; - case ATTRIBUTE_TYPE::INT:{ - GetInt(a); - }break; - case ATTRIBUTE_TYPE::STRING:{ - GetString(a); - }break; - case ATTRIBUTE_TYPE::BOOL:{ - GetBool(a); - }break; +float&Monster::GetFloat(Attribute a){ + if(attributes.count(a)==0){ + attributes[a]=0.f; } + return std::get(attributes[a]); } -float Monster::GetFloat(_ATTRIBUTE a){ - if(attributes.count(a)>0){ - return std::get(attributes[a]); - }else{ - return 0; +int&Monster::GetInt(Attribute a){ + if(attributes.count(a)==0){ + attributes[a]=0; } + return std::get(attributes[a]); } -int Monster::GetInt(_ATTRIBUTE a){ - if(attributes.count(a)>0){ - return std::get(attributes[a]); - }else{ - return 0; +std::string&Monster::GetString(Attribute a){ + if(attributes.count(a)==0){ + attributes[a]=""; } + return std::get(attributes[a]); } -std::string Monster::GetString(_ATTRIBUTE a){ - if(attributes.count(a)>0){ - return std::get(attributes[a]); - }else{ - return 0; - } -} - -bool Monster::GetBool(_ATTRIBUTE a){ - if(attributes.count(a)>0){ - return std::get(attributes[a]); - }else{ - return 0; +bool&Monster::GetBool(Attribute a){ + if(attributes.count(a)==0){ + attributes[a]=false; } + return std::get(attributes[a]); } \ No newline at end of file diff --git a/Crawler/Monster.h b/Crawler/Monster.h index 113fb836..49b73976 100644 --- a/Crawler/Monster.h +++ b/Crawler/Monster.h @@ -90,7 +90,7 @@ private: int phase=0; bool diesNormally=true; //If set to false, the monster death is handled in a special way. Set it to true when it's time to die. float targetSize=0; - std::map<_ATTRIBUTE,std::variant>attributes; + std::map>attributes; protected: public: Monster()=delete; @@ -136,11 +136,10 @@ public: float GetZ(); std::string GetStrategy(); void SetSize(float newSize,bool immediate=true); - void Set(_ATTRIBUTE a,std::variantval); - float GetFloat(_ATTRIBUTE a); - int GetInt(_ATTRIBUTE a); - std::string GetString(_ATTRIBUTE a); - bool GetBool(_ATTRIBUTE a); + float&GetFloat(Attribute a); + int&GetInt(Attribute a); + std::string&GetString(Attribute a); + bool&GetBool(Attribute a); private: struct STRATEGY{ static int _GetInt(Monster&m,std::string param,int strategyNumber,int index=0); diff --git a/Crawler/MonsterAttribute.cpp b/Crawler/MonsterAttribute.cpp deleted file mode 100644 index cd3097e7..00000000 --- a/Crawler/MonsterAttribute.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "MonsterAttribute.h" -#define SETUP(attribute,type) _ATTRIBUTE attribute{ATTRIBUTE_TYPE::type}; - -SETUP(Attribute::IFRAME_TIME_UPON_HIT,FLOAT); -SETUP(Attribute::SHOOT_RING_TIMER,FLOAT); -SETUP(Attribute::SHOOT_RING_DELAY,FLOAT); -SETUP(Attribute::SHOOT_RING_COUNTER,FLOAT); - -int _ATTRIBUTE::internal_id=0; -_ATTRIBUTE::_ATTRIBUTE(ATTRIBUTE_TYPE type) - :type(type),id(internal_id++){} \ No newline at end of file diff --git a/Crawler/MonsterAttribute.h b/Crawler/MonsterAttribute.h index 6e73775f..42a1c4ea 100644 --- a/Crawler/MonsterAttribute.h +++ b/Crawler/MonsterAttribute.h @@ -1,29 +1,15 @@ #pragma once #define VARIANTS float,int,std::string,bool +#include +#define F(attr) GetFloat(attr) +#define I(attr) GetInt(attr) +#define S(attr) GetString(attr) +#define B(attr) GetBool(attr) -enum class ATTRIBUTE_TYPE{ - FLOAT, - INT, - STRING, - BOOL, -}; - -struct _ATTRIBUTE{ - ATTRIBUTE_TYPE type; - _ATTRIBUTE(ATTRIBUTE_TYPE type); -private: - static int internal_id; - int id; -public: - bool operator<(const _ATTRIBUTE&rhs)const{ - return int(id)(m.GetPos(),vf2d{cos(angle),sin(angle)}*bulletSpd,6,ConfigInt("ProjectileDamage"),m.OnUpperLevel(),false,YELLOW,vf2d{6,6})); } - m.Set(Attribute::SHOOT_RING_TIMER,ConfigFloat("Phase1.ShootRepeatTime")); + m.F(A::SHOOT_RING_TIMER)=ConfigFloat("Phase1.ShootRepeatTime"); + m.B(A::SHOOT_RING_RIGHT)=bool(rand()%2); + } + if(m.GetInt(Attribute::SHOOT_RING_COUNTER)>0){ + if(m.GetFloat(Attribute::SHOOT_RING_DELAY)==0){ + m.I(A::SHOOT_RING_COUNTER)--; + } } }break; case 2:{ @@ -47,7 +60,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe case 4:{ if(m.hp<=0){ m.phase=5; - m.Set(Attribute::IFRAME_TIME_UPON_HIT,1.f); + m.F(A::IFRAME_TIME_UPON_HIT)=1; } }break; } diff --git a/Crawler/Version.h b/Crawler/Version.h index 18319868..6ab6c27e 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -2,7 +2,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 0 -#define VERSION_BUILD 1114 +#define VERSION_BUILD 1117 #define stringify(a) stringify_(a) #define stringify_(a) #a