2023-11-20 23:25:36 -06:00
# pragma region License
2023-11-14 18:11:32 -06:00
/*
License ( OLC - 3 )
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
2024-01-02 00:46:32 -06:00
Copyright 2024 Joshua Sigona < sigonasr2 @ gmail . com >
2023-11-14 18:11:32 -06:00
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 .
2023-11-29 00:50:00 -06:00
2024-01-30 14:48:49 +00:00
Portions of this software are copyright © 2024 The FreeType
2023-11-29 00:50:00 -06:00
Project ( www . freetype . org ) . Please see LICENSE_FT . txt for more information .
All rights reserved .
2023-11-14 18:11:32 -06:00
*/
2023-11-20 23:25:36 -06:00
# pragma endregion
2023-06-15 00:11:39 -05:00
# pragma once
# include "Animation.h"
2024-03-26 17:31:34 -05:00
# include <unordered_set>
2024-05-18 05:04:52 -05:00
# include <variant>
2024-03-26 17:31:34 -05:00
class Monster ;
2024-05-18 05:04:52 -05:00
class Player ;
using HitList = std : : unordered_set < std : : variant < Monster * , Player * > > ;
2023-06-15 00:11:39 -05:00
2024-06-09 12:33:16 -05:00
enum class EffectType {
NONE ,
SPELL_CIRCLE ,
} ;
2023-06-15 00:11:39 -05:00
struct Effect {
2024-01-04 05:21:56 -06:00
friend class AiL ;
2024-07-15 04:20:55 -05:00
friend struct FallingStone ;
2023-06-16 02:33:12 -05:00
vf2d pos = { 0 , 0 } ;
float lifetime = 0 ;
float fadeout = 0 ;
2023-07-12 00:23:36 -05:00
vf2d size = { 1 , 1 } ;
2023-07-06 03:43:34 -05:00
Pixel col = WHITE ;
2023-06-24 02:14:11 -07:00
vf2d spd = { } ;
2023-07-12 00:23:36 -05:00
float rotation = 0 ;
float rotationSpd = 0 ;
bool additiveBlending = false ;
2023-09-09 04:43:52 -05:00
private :
bool dead = false ;
public :
2023-09-16 07:00:38 -05:00
Effect ( vf2d pos , float lifetime , std : : string imgFile , bool upperLevel , float size = 1.0f , float fadeout = 0.0f , vf2d spd = { } , Pixel col = WHITE , float rotation = 0 , float rotationSpd = 0 , bool additiveBlending = false ) ;
Effect ( vf2d pos , float lifetime , std : : string imgFile , bool upperLevel , vf2d size = { 1 , 1 } , float fadeout = 0.0f , vf2d spd = { } , Pixel col = WHITE , float rotation = 0 , float rotationSpd = 0 , bool additiveBlending = false ) ;
2023-07-13 01:35:51 -05:00
virtual bool Update ( float fElapsedTime ) ;
2024-02-27 03:16:35 -06:00
Animate2D : : Frame GetFrame ( ) const ;
virtual void Draw ( ) const ;
2023-07-07 06:42:49 -05:00
bool OnUpperLevel ( ) ;
2024-06-09 12:33:16 -05:00
const EffectType GetType ( ) const ;
2023-07-21 18:47:45 +00:00
protected :
float original_fadeoutTime ;
2024-06-09 12:33:16 -05:00
EffectType type { EffectType : : NONE } ;
2023-06-15 00:11:39 -05:00
private :
2023-08-06 19:00:09 -05:00
Animate2D : : Animation < std : : string > animation ;
2023-06-15 00:11:39 -05:00
Animate2D : : AnimationState internal_animState ;
2023-07-07 06:42:49 -05:00
bool upperLevel = false ;
2023-07-13 01:35:51 -05:00
} ;
struct Meteor : Effect {
2023-09-16 07:00:38 -05:00
Meteor ( vf2d pos , float lifetime , std : : string imgFile , bool upperLevel , vf2d size = { 1 , 1 } , float fadeout = 0.0f , vf2d spd = { } , Pixel col = WHITE , float rotation = 0 , float rotationSpd = 0 , bool additiveBlending = false ) ;
2023-07-21 18:47:45 +00:00
float startLifetime = 0 ;
bool shakeField = false ;
2023-07-13 01:35:51 -05:00
bool Update ( float fElapsedTime ) override ;
2024-02-27 03:16:35 -06:00
void Draw ( ) const override ;
2023-07-21 17:29:20 -05:00
} ;
struct PulsatingFire : Effect {
2023-09-16 07:00:38 -05:00
PulsatingFire ( vf2d pos , float lifetime , std : : string imgFile , bool upperLevel , vf2d size = { 1 , 1 } , float fadeout = 0.0f , vf2d spd = { } , Pixel col = WHITE , float rotation = 0 , float rotationSpd = 0 , bool additiveBlending = false ) ;
2023-07-21 17:29:20 -05:00
std : : vector < float > pulsatingFireValues ;
float lastParticleTimer = 0 ;
2023-07-22 03:19:52 -05:00
float lastDamageTimer = 0 ;
2023-07-21 17:29:20 -05:00
bool Update ( float fElapsedTime ) override ;
2024-02-27 03:16:35 -06:00
void Draw ( ) const override ;
2024-03-07 05:29:02 -06:00
} ;
struct SwordSlash : Effect {
SwordSlash ( float lifetime , std : : string imgFile , vf2d size = { 1 , 1 } , float fadeout = 0.0f , vf2d spd = { } , Pixel col = WHITE , float rotation = 0 , float rotationSpd = 0 , bool additiveBlending = false ) ;
bool Update ( float fElapsedTime ) override ;
2024-03-26 17:31:34 -05:00
private :
HitList hitList ;
2024-05-29 17:15:03 -05:00
} ;
//This draws effects using screen coordinates instead of world coordinates, useful for applying effects directly on the screen.
struct ForegroundEffect : Effect {
ForegroundEffect ( vf2d pos , float lifetime , std : : string imgFile , bool upperLevel , float size = 1.0f , float fadeout = 0.0f , vf2d spd = { } , Pixel col = WHITE , float rotation = 0 , float rotationSpd = 0 , bool additiveBlending = false ) ;
ForegroundEffect ( vf2d pos , float lifetime , std : : string imgFile , bool upperLevel , vf2d size = { 1 , 1 } , float fadeout = 0.0f , vf2d spd = { } , Pixel col = WHITE , float rotation = 0 , float rotationSpd = 0 , bool additiveBlending = false ) ;
virtual void Draw ( ) const override final ;
2024-06-09 12:33:16 -05:00
} ;
struct SpellCircle : Effect {
2024-07-15 01:14:32 -05:00
SpellCircle ( vf2d pos , float lifetime , std : : string imgFile , std : : string spellInsigniaFile , bool upperLevel , float size = 1.0f , float fadeout = 0.0f , vf2d spd = { } , Pixel col = WHITE , float rotation = 0 , float rotationSpd = 0 , bool additiveBlending = false , float insigniaSize = 1.0f , float insigniaFadeout = 0.0f , vf2d insigniaSpd = { } , Pixel insigniaCol = WHITE , float insigniaRotation = 0 , float insigniaRotationSpd = 0 , bool insigniaAdditiveBlending = false ) ;
SpellCircle ( vf2d pos , float lifetime , std : : string imgFile , std : : string spellInsigniaFile , bool upperLevel , vf2d size = { 1 , 1 } , float fadeout = 0.0f , vf2d spd = { } , Pixel col = WHITE , float rotation = 0 , float rotationSpd = 0 , bool additiveBlending = false , vf2d insigniaSize = { 1 , 1 } , float insigniaFadeout = 0.0f , vf2d insigniaSpd = { } , Pixel insigniaCol = WHITE , float insigniaRotation = 0 , float insigniaRotationSpd = 0 , bool insigniaAdditiveBlending = false ) ;
2024-06-09 12:33:16 -05:00
Effect spellInsignia { vf2d { } , 0.f , " spell_insignia.png " , false , { } } ;
virtual bool Update ( float fElapsedTime ) override final ;
virtual void Draw ( ) const override final ;
2024-07-14 07:59:13 -05:00
} ;
struct RockLaunch : Effect {
//The lifetime is for how long the effect lasts after it's launched. You don't have to calculate extra lifetime to compensate for the delayTime, it is done for you.
RockLaunch ( vf2d pos , float lifetime , std : : string imgFile , float delayTime , float size , float fadeout , vf2d spd , Pixel col , float rotation , float rotationSpd , bool additiveBlending = false ) ;
virtual bool Update ( float fElapsedTime ) override final ;
private :
float delayTime ;
vf2d futureSpd ;
2023-06-15 00:11:39 -05:00
} ;