Adjust collision radius default based on monster's sheet frame size. Use defined collision radius of a monster instead of 12*SizeMult as that is the actual radius for HurtMonsterType() damage calls (fixes large stone hitting pillars a little too wide in the chapter 2 boss fight). Refactored Bullet check systems to include damage flags: DOT, PLAYER_ABILITY, and NONE. Player abilities flags assigned to all auto attack and abilities that players can launch, in preparation for marked target proccing. Mark Target buff detection added, Mark buff added. Reorganized bullet hierarchy, turning the default bullet into an interface and making the normal Bullet class a base child class all Bullets derive from. Added HurtDamageInfo structure, which is passed onto bullets to modify flags before being applied to the Hurt function when bullets hit targets. Changed all storage containers holding Bullet classes to now hold IBullet classes. Release Build 10248.
parent
c656b935e1
commit
3830ba8840
@ -0,0 +1,59 @@ |
||||
#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 |
||||
|
||||
namespace HurtFlag{ |
||||
enum HurtFlag{ |
||||
NONE = 0b00, |
||||
PLAYER_ABILITY = 0b01, //Specifically use this flag for player auto attacks or Abilities only! (Identifies these attacks for the Trapper class)
|
||||
DOT = 0b10, //Damage over time ability.
|
||||
}; |
||||
} |
||||
|
||||
enum class TrueDamageFlag{ |
||||
NORMAL_DAMAGE, |
||||
IGNORE_DAMAGE_RULES, //Deals true damage, ignoring established invulnerability/iframe rules. Will never miss and will not have its damage modified by any buffs/stats.
|
||||
}; |
||||
|
||||
struct HurtDamageInfo{ |
||||
int damage{}; |
||||
bool onUpperLevel{false}; |
||||
float z{}; |
||||
HurtFlag::HurtFlag hurtFlags{HurtFlag::NONE}; |
||||
TrueDamageFlag damageRule{TrueDamageFlag::NORMAL_DAMAGE}; |
||||
}; |
@ -0,0 +1,282 @@ |
||||
#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 "Bullet.h" |
||||
#include "AdventuresInLestoria.h" |
||||
#include "DEFINES.h" |
||||
#include "safemap.h" |
||||
#include "util.h" |
||||
#include "SoundEffect.h" |
||||
|
||||
INCLUDE_ANIMATION_DATA |
||||
INCLUDE_game |
||||
INCLUDE_GFX |
||||
INCLUDE_MONSTER_LIST |
||||
INCLUDE_WINDOW_SIZE |
||||
|
||||
IBullet::IBullet(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly,Pixel col,vf2d scale,float image_angle) |
||||
:pos(pos),vel(vel),radius(radius),damage(damage),col(col),friendly(friendly),upperLevel(upperLevel),scale(scale),image_angle(image_angle){}; |
||||
|
||||
IBullet::IBullet(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,std::string_view hitSound) |
||||
: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),hitSound(std::string(hitSound)){ |
||||
this->animation.AddState(animation,ANIMATION_DATA.at(animation)); |
||||
this->animation.ChangeState(internal_animState,animation); |
||||
}; |
||||
|
||||
Animate2D::Frame IBullet::GetFrame()const{ |
||||
return animation.GetFrame(internal_animState); |
||||
} |
||||
void IBullet::UpdateFadeTime(float fElapsedTime){ |
||||
aliveTime+=fElapsedTime; |
||||
if(fadeInTime>0){ |
||||
if(fadeInTimer<fadeInTime){ |
||||
fadeInTimer=std::min(fadeInTime,fadeInTimer+fElapsedTime); |
||||
} |
||||
} |
||||
if(fadeOutTime>0){ |
||||
if(fadeOutTimer==0){ |
||||
lifetime=fadeOutTime; |
||||
} |
||||
fadeOutTimer+=fElapsedTime; |
||||
} |
||||
} |
||||
|
||||
void IBullet::Update(float fElapsedTime){} |
||||
|
||||
void IBullet::SimulateUpdate(const float fElapsedTime){ |
||||
simulated=true; |
||||
_Update(fElapsedTime); |
||||
simulated=false; |
||||
} |
||||
|
||||
void IBullet::_Update(const float fElapsedTime){ |
||||
if(dead)return; |
||||
UpdateFadeTime(fElapsedTime); |
||||
Update(fElapsedTime); |
||||
animation.UpdateState(internal_animState,fElapsedTime); |
||||
const bool CollisionCheckRequired=IsActivated()&&fadeInTimer==fadeInTime&&radius!=0.f; |
||||
if(CollisionCheckRequired){ |
||||
float totalDistance=(vel*fElapsedTime).mag(); |
||||
int iterations=int(std::max(1.f,(vel*fElapsedTime).mag())); |
||||
int totalIterations=iterations; |
||||
vf2d finalBulletPos=pos+vel*fElapsedTime; |
||||
if(IsPlayerAutoAttackProjectile()){finalBulletPos+=(game->GetWindSpeed()*game->GetElapsedTime())/float(totalIterations);} |
||||
distanceTraveled+=totalDistance/24.f*100.f; |
||||
const auto CollisionCheck=[&](){ |
||||
if(simulated)return true; |
||||
if(friendly){ |
||||
for(std::unique_ptr<Monster>&m:MONSTER_LIST){ |
||||
if(geom2d::overlaps(m->BulletCollisionHitbox(),geom2d::circle(pos,radius))){ |
||||
if(hitList.find(&*m)==hitList.end()){ |
||||
HurtDamageInfo damageData{damage,OnUpperLevel(),z,HurtFlag::NONE}; |
||||
ModifyOutgoingDamageData(damageData.damage,damageData.onUpperLevel,damageData.z,damageData.hurtFlags); |
||||
if(m->Hurt(damageData)){ |
||||
if(!hitsMultiple){ |
||||
if(_MonsterHit(*m)==BulletDestroyState::DESTROY){ |
||||
dead=true; |
||||
} |
||||
return false; |
||||
}else _MonsterHit(*m); |
||||
hitList.insert(&*m); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} else { |
||||
if(geom2d::overlaps(game->GetPlayer()->Hitbox(),geom2d::circle(pos,radius))){ |
||||
if(hitList.find(game->GetPlayer())==hitList.end()){ |
||||
HurtDamageInfo damageData{damage,OnUpperLevel(),z,HurtFlag::NONE}; |
||||
//NOTE: OnHurt() will potentially change the Damage Data, passing it along to bullet children that might need to modify the flags!
|
||||
ModifyOutgoingDamageData(damageData.damage,damageData.onUpperLevel,damageData.z,damageData.hurtFlags); |
||||
if(game->GetPlayer()->Hurt(damageData)){ |
||||
if(!hitsMultiple){ |
||||
if(_PlayerHit(&*game->GetPlayer())==BulletDestroyState::DESTROY){ |
||||
dead=true; |
||||
} |
||||
return false; |
||||
}else _PlayerHit(&*game->GetPlayer()); |
||||
hitList.insert(game->GetPlayer()); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
return true; |
||||
}; |
||||
|
||||
while(iterations>0){ |
||||
iterations--; |
||||
if(IsPlayerAutoAttackProjectile()){pos+=(game->GetWindSpeed()*game->GetElapsedTime())/float(totalIterations);} |
||||
pos+=(vel*fElapsedTime)/float(totalIterations); |
||||
if(!CollisionCheck()){ |
||||
goto DeadBulletCheck; |
||||
} |
||||
} |
||||
pos=finalBulletPos; |
||||
if(!CollisionCheck()){ |
||||
goto DeadBulletCheck; |
||||
} |
||||
}else{ |
||||
if(IsPlayerAutoAttackProjectile()){pos+=game->GetWindSpeed()*game->GetElapsedTime();} |
||||
pos+=vel*fElapsedTime; |
||||
} |
||||
|
||||
DeadBulletCheck: |
||||
if(/*World size in PIXELS!*/vi2d worldSize=game->GetCurrentMapData().MapSize*game->GetCurrentMapData().TileSize;pos.x+radius<-WINDOW_SIZE.x||pos.x-radius>worldSize.x+WINDOW_SIZE.x||pos.y+radius<-WINDOW_SIZE.y||pos.y-radius>worldSize.y+WINDOW_SIZE.y){ |
||||
dead=true; |
||||
return; |
||||
} |
||||
lifetime-=fElapsedTime; |
||||
if(lifetime<=0){ |
||||
dead=true; |
||||
return; |
||||
} |
||||
} |
||||
|
||||
void IBullet::_Draw()const{ |
||||
Pixel blendCol=col; |
||||
|
||||
if(fadeInTime==0&&fadeOutTime==0)blendCol.a=col.a; |
||||
else if(fadeOutTime>0)blendCol.a=uint8_t(util::lerp(col.a,0,1-((fadeOutTime-fadeOutTimer)/fadeOutTime))); |
||||
else if(fadeInTime>0)blendCol.a=uint8_t(util::lerp(col.a,0,((fadeInTime-fadeInTimer)/fadeInTime))); |
||||
|
||||
if(GetZ()>0){ |
||||
vf2d shadowScale=vf2d{8*scale.x/3.f,1}/std::max(1.f,GetZ()/8); |
||||
game->view.DrawDecal(pos-vf2d{3,3}*shadowScale/2+vf2d{0,12*scale.y},GFX["circle.png"].Decal(),shadowScale,BLACK); |
||||
} |
||||
|
||||
const bool NotOnTitleScreen=GameState::STATE!=GameState::states[States::MAIN_MENU]; |
||||
|
||||
if(NotOnTitleScreen |
||||
&&(game->GetPlayer()->HasIframes()||game->GetPlayer()->GetZ()>1)){ |
||||
blendCol.a/=1.59f; //Comes from 255 divided by 160 which is roughly what we want the alpha to be when the bullet has full transparency.
|
||||
} |
||||
Draw(blendCol); |
||||
} |
||||
|
||||
void IBullet::Draw(const Pixel blendCol)const{ |
||||
if(animated){ |
||||
game->view.DrawPartialRotatedDecal(pos-vf2d{0,GetZ()}+drawOffsetY,GetFrame().GetSourceImage()->Decal(),rotates?atan2(vel.y,vel.x)-PI/2+image_angle:image_angle,GetFrame().GetSourceRect().size/2,GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,scale,blendCol); |
||||
}else{ |
||||
game->view.DrawRotatedDecal(pos-vf2d{0,GetZ()}+drawOffsetY,GFX["circle.png"].Decal(),image_angle,GFX["circle.png"].Sprite()->Size()/2.f,scale,blendCol); |
||||
game->view.DrawRotatedDecal(pos-vf2d{0,GetZ()}+drawOffsetY,GFX["circle_outline.png"].Decal(),image_angle,GFX["circle.png"].Sprite()->Size()/2.f,scale,Pixel{WHITE.r,WHITE.g,WHITE.b,blendCol.a}); |
||||
} |
||||
} |
||||
|
||||
BulletDestroyState IBullet::_PlayerHit(Player*player){ |
||||
const BulletDestroyState destroyBullet=PlayerHit(player); |
||||
if(iframeTimerOnHit>0.f)player->ApplyIframes(iframeTimerOnHit); |
||||
if(hitSound)SoundEffect::PlaySFX(hitSound.value(),pos); |
||||
return destroyBullet; |
||||
} |
||||
BulletDestroyState IBullet::_MonsterHit(Monster&monster){ |
||||
const BulletDestroyState destroyBullet=MonsterHit(monster); |
||||
if(iframeTimerOnHit>0.f)monster.ApplyIframes(iframeTimerOnHit); |
||||
if(hitSound)SoundEffect::PlaySFX(hitSound.value(),pos); |
||||
return destroyBullet; |
||||
} |
||||
BulletDestroyState IBullet::PlayerHit(Player*player){ |
||||
if(!hitsMultiple)fadeOutTime=0.15f; |
||||
return BulletDestroyState::KEEP_ALIVE; |
||||
} |
||||
BulletDestroyState IBullet::MonsterHit(Monster&monster){ |
||||
if(!hitsMultiple)fadeOutTime=0.15f; |
||||
return BulletDestroyState::KEEP_ALIVE; |
||||
} |
||||
bool IBullet::OnUpperLevel(){return upperLevel;} |
||||
|
||||
const bool IBullet::IsDead()const{ |
||||
return dead; |
||||
} |
||||
|
||||
const float IBullet::GetZ()const{ |
||||
return z; |
||||
} |
||||
|
||||
IBullet&IBullet::SetIframeTimeOnHit(float iframeTimer){ |
||||
iframeTimerOnHit=iframeTimer; |
||||
return *this; |
||||
} |
||||
IBullet&IBullet::SetFadeinTime(float fadeInTime){ |
||||
const float durationDiff=fadeInTime-fadeInTimer; |
||||
this->fadeInTime=fadeInTime; |
||||
lifetime+=durationDiff; |
||||
return *this; |
||||
} |
||||
|
||||
const float&IBullet::GetFadeoutTimer()const{ |
||||
return fadeOutTimer; |
||||
} |
||||
|
||||
IBullet&IBullet::SetIsPlayerAutoAttackProjectile(){ |
||||
playerAutoAttackProjectile=true; |
||||
return *this; |
||||
} |
||||
|
||||
const bool IBullet::IsPlayerAutoAttackProjectile()const{ |
||||
return playerAutoAttackProjectile; |
||||
} |
||||
|
||||
void IBullet::AddVelocity(vf2d vel){ |
||||
this->vel+=vel*game->GetElapsedTime(); |
||||
} |
||||
|
||||
void IBullet::SetBulletType(const BulletType type){ |
||||
this->type=type; |
||||
} |
||||
|
||||
const BulletType IBullet::GetBulletType()const{ |
||||
return type; |
||||
} |
||||
|
||||
const bool IBullet::IsActivated()const{ |
||||
return !IsDeactivated(); |
||||
} |
||||
const bool IBullet::IsDeactivated()const{ |
||||
return deactivated||fadeOutTime>0.f; |
||||
} |
||||
|
||||
void IBullet::Deactivate(){ |
||||
deactivated=true; |
||||
} |
||||
|
||||
const double IBullet::GetTimeAlive()const{ |
||||
return aliveTime; |
||||
} |
||||
|
||||
const double IBullet::GetAliveTime()const{ |
||||
return aliveTime; |
||||
} |
@ -0,0 +1,133 @@ |
||||
#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 "Animation.h" |
||||
#include "olcUTIL_Animate2D.h" |
||||
#include "Monster.h" |
||||
#include "DEFINES.h" |
||||
using HitList=std::unordered_set<std::variant<Monster*,Player*>>; |
||||
|
||||
enum class BulletType{ |
||||
UNDEFINED, |
||||
FEATHER, |
||||
LARGE_TORNADO, |
||||
}; |
||||
|
||||
enum class BulletDestroyState{ |
||||
KEEP_ALIVE, |
||||
DESTROY, |
||||
}; |
||||
|
||||
struct IBullet{ |
||||
friend class AiL; |
||||
vf2d vel; |
||||
vf2d pos; |
||||
float radius; |
||||
int damage; |
||||
Pixel col; |
||||
float lifetime=float(INFINITE); |
||||
bool hitsMultiple=false; |
||||
bool rotates=false; |
||||
bool animated=false; |
||||
float fadeOutTime=0.f; //Setting the fade out time causes the bullet's lifetime to be set to the fadeout time as well, as that's when the bullet's alpha will reach 0, so it dies.
|
||||
bool friendly=false; //Whether or not it's a player bullet or enemy bullet.
|
||||
bool upperLevel=false; |
||||
bool alwaysOnTop=false; |
||||
float z=0.f; |
||||
float image_angle=0.f; |
||||
protected: |
||||
float distanceTraveled=0.f; |
||||
vf2d scale={1,1}; |
||||
float fadeInTime=0; //Setting the fade in time causes the bullet to be disabled and the bullet's alpha will fade in from zero to the actual alpha of the bullet. When the fade in timer reaches the fade in time automatically, the bullet will be enabled.
|
||||
virtual void Update(float fElapsedTime); |
||||
void Deactivate(); |
||||
private: |
||||
float fadeOutTimer=0; |
||||
float fadeInTimer=0; |
||||
void UpdateFadeTime(float fElapsedTime); |
||||
bool dead=false; //When marked as dead it wil be removed by the next frame.
|
||||
bool simulated=false; //A simulated bullet cannot interact / damage things in the world. It's simply used for simulating the trajectory and potential path of the bullet
|
||||
float iframeTimerOnHit{0.f}; |
||||
bool playerAutoAttackProjectile=false; //Set to true for bullets that are auto attack projectiles to identify them.
|
||||
void _Draw()const; |
||||
BulletType type{BulletType::UNDEFINED}; |
||||
bool deactivated{false}; |
||||
double aliveTime{}; |
||||
float onContactFadeoutTime{}; //What fadeouttime will be set to when the bullet hits a monster.
|
||||
std::optional<std::string>hitSound; |
||||
protected: |
||||
float drawOffsetY{}; |
||||
BulletDestroyState _PlayerHit(Player*player); //Return true to destroy the bullet on hit, return false otherwise. THE BULLET HIT HAS ALREADY OCCURRED.
|
||||
BulletDestroyState _MonsterHit(Monster&monster); //Return true to destroy the bullet on hit, return false otherwise. THE BULLET HIT HAS ALREADY OCCURRED.
|
||||
const float&GetFadeoutTimer()const; |
||||
void SetBulletType(const BulletType type); |
||||
const double GetTimeAlive()const; |
||||
public: |
||||
Animate2D::Animation<std::string>animation; |
||||
Animate2D::AnimationState internal_animState; |
||||
HitList hitList; |
||||
virtual ~IBullet()=default; |
||||
IBullet(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly=false,Pixel col=WHITE,vf2d scale={1,1},float image_angle=0.f); |
||||
//Initializes a bullet with an animation.
|
||||
IBullet(vf2d pos,vf2d vel,float radius,int damage,std::string animation,bool upperLevel,bool hitsMultiple=false,float lifetime=INFINITE,bool rotatesWithAngle=false,bool friendly=false,Pixel col=WHITE,vf2d scale={1,1},float image_angle=0.f,std::string_view hitSound=""); |
||||
public: |
||||
|
||||
void SimulateUpdate(const float fElapsedTime); |
||||
void _Update(const float fElapsedTime); |
||||
//Used by special bullets to control custom despawning behavior! Return true when the bullet should be destroyed. Return false to handle it otherwise (like deactivating it instead). You become responsible for getting rid of the bullet.
|
||||
//DO NOT CALL THIS DIRECTLY! INSTEAD USE _PlayerHit()!!
|
||||
virtual BulletDestroyState PlayerHit(Player*player); |
||||
//Used by special bullets to control custom despawning behavior! Return true when the bullet should be destroyed. Return false to handle it otherwise (like deactivating it instead). You become responsible for getting rid of the bullet.
|
||||
//DO NOT CALL THIS DIRECTLY! INSTEAD USE _MonsterHit()!!
|
||||
virtual BulletDestroyState MonsterHit(Monster&monster); |
||||
Animate2D::Frame GetFrame()const; |
||||
virtual void Draw(const Pixel blendCol)const; |
||||
bool OnUpperLevel(); |
||||
const bool IsDead()const; |
||||
const float GetZ()const; |
||||
IBullet&SetIframeTimeOnHit(float iframeTimer); |
||||
IBullet&SetFadeinTime(float fadeInTime); |
||||
IBullet&SetIsPlayerAutoAttackProjectile(); //Enables the playerAutoAttackProjectile flag.
|
||||
const bool IsPlayerAutoAttackProjectile()const; |
||||
void AddVelocity(vf2d vel); |
||||
const BulletType GetBulletType()const; |
||||
const bool IsActivated()const; |
||||
const bool IsDeactivated()const; |
||||
const double GetAliveTime()const; |
||||
virtual void ModifyOutgoingDamageData(int&damage,bool&onUpperLevel,float&z,HurtFlag::HurtFlag&hurtFlags)=0; |
||||
}; |
Binary file not shown.
Loading…
Reference in new issue