1 /*
2 Copyright © 2011-2012 Clint Bellanger
3 Copyright © 2012 Stefan Beller
4 Copyright © 2013 Henrik Andersson
5 Copyright © 2012-2016 Justin Jacobs
6 
7 This file is part of FLARE.
8 
9 FLARE is free software: you can redistribute it and/or modify it under the terms
10 of the GNU General Public License as published by the Free Software Foundation,
11 either version 3 of the License, or (at your option) any later version.
12 
13 FLARE is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15 PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License along with
18 FLARE.  If not, see http://www.gnu.org/licenses/
19 */
20 
21 /*
22  * class EntityManager
23  */
24 
25 
26 #ifndef ENTITY_MANAGER_H
27 #define ENTITY_MANAGER_H
28 
29 #include "CommonIncludes.h"
30 #include "Utils.h"
31 
32 class Animation;
33 class Entity;
34 
35 class EntityManager {
36 private:
37 
38 	void loadAnimations(Entity *e);
39 
40 	std::vector<std::string> anim_prefixes;
41 	std::vector<std::vector<Animation*> > anim_entities;
42 
43 protected:
44 	/**
45 	 * callee is responsible for deleting returned entity object
46 	 */
47 	size_t loadEntityPrototype(const std::string& type_id);
48 
49 	std::vector<Entity> prototypes;
50 
51 public:
52 	EntityManager();
53 	~EntityManager();
54 
55 	Entity *getEntityPrototype(const std::string& type_id);
56 
57 	void handleNewMap();
58 	void handleSpawn();
59 	bool checkPartyMembers();
60 	void logic();
61 	void addRenders(std::vector<Renderable> &r, std::vector<Renderable> &r_dead);
62 	void checkEnemiesforXP();
63 	bool isCleared();
64 	void spawn(const std::string& entity_type, const Point& target);
65 	Entity *entityFocus(const Point& mouse, const FPoint& cam, bool alive_only);
66 	Entity* getNearestEntity(const FPoint& pos, bool get_corpse, float *saved_distance, float max_range);
67 
68 	// vars
69 	std::vector<Entity*> entities;
70 	int hero_stealth;
71 
72 	bool player_blocked;
73 	Timer player_blocked_timer;
74 
75 	static const bool GET_CORPSE = true;
76 	static const bool IS_ALIVE = true;
77 };
78 
79 
80 #endif
81