1 /* 2 Copyright © 2011-2012 Clint Bellanger 3 Copyright © 2012-2016 Justin Jacobs 4 5 This file is part of FLARE. 6 7 FLARE is free software: you can redistribute it and/or modify it under the terms 8 of the GNU General Public License as published by the Free Software Foundation, 9 either version 3 of the License, or (at your option) any later version. 10 11 FLARE is distributed in the hope that it will be useful, but WITHOUT ANY 12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License along with 16 FLARE. If not, see http://www.gnu.org/licenses/ 17 */ 18 19 /** 20 * class Hazard 21 * 22 * Stand-alone object that can harm the hero or creatures 23 * These are generated whenever something makes any attack 24 */ 25 26 #ifndef HAZARD_H 27 #define HAZARD_H 28 29 class Entity; 30 31 #include "CommonIncludes.h" 32 #include "Utils.h" 33 34 class Animation; 35 class MapCollision; 36 class Power; 37 class StatBlock; 38 39 class Hazard { 40 public: 41 explicit Hazard(MapCollision *_collider); 42 Hazard(const Hazard& other); 43 Hazard & operator= (const Hazard& other); 44 ~Hazard(); 45 46 void logic(); 47 bool hasEntity(Entity*); 48 void addEntity(Entity*); 49 void loadAnimation(const std::string &s); 50 void setAngle(const float& _angle); 51 bool isDangerousNow(); 52 void addRenderable(std::vector<Renderable> &r, std::vector<Renderable> &r_dead); 53 54 bool active; 55 bool remove_now; 56 bool hit_wall; 57 bool relative_pos; 58 bool sfx_hit_played; 59 60 int dmg_min; 61 int dmg_max; 62 int crit_chance; 63 int accuracy; 64 int source_type; 65 float base_speed; 66 int lifespan; // ticks down to zero 67 int animationKind; // either a direction or option/random 68 int delay_frames; 69 float angle; // in radians 70 71 StatBlock *src_stats; 72 Power *power; 73 PowerID power_index; 74 75 FPoint pos; 76 FPoint speed; 77 FPoint pos_offset; 78 79 // for linking hazards together, e.g. repeaters 80 Hazard* parent; 81 std::vector<Hazard*> children; 82 83 FPoint prev_pos; 84 85 private: 86 void reflect(); 87 88 const MapCollision *collider; 89 Animation *activeAnimation; 90 std::string animation_name; 91 92 // Keeps track of entities already hit 93 std::vector<Entity*> entitiesCollided; 94 }; 95 96 #endif 97