Commit | Line | Data |
---|---|---|
e68f847b PG |
1 | /* |
2 | * Copyright (C) 2008 Patrik Gornicz, Gornicz_P (at) hotmail (dot) com. | |
3 | * | |
4 | * This program is free software: you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation, either version 3 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | */ | |
17 | ||
f206d19d PG |
18 | #include "effectManager.h" |
19 | ||
f103ba70 PG |
20 | #include <set> |
21 | ||
33b8c69b | 22 | #include "Effects/Effect.h" |
f206d19d | 23 | #include "Effects/Gravity.h" |
46e842c7 | 24 | #include "Effects/GravityWell.h" |
2c18685d | 25 | #include "Effects/Screen.h" |
f206d19d | 26 | |
46e842c7 | 27 | #include "Vector2.h" |
a823a800 | 28 | #include "input/inputManager.h" |
a860c0c7 | 29 | #include "config/config.h" |
46e842c7 | 30 | |
33b8c69b | 31 | /// ***** Private Variables ***** |
617dcc71 | 32 | |
f103ba70 PG |
33 | typedef std::set<Effect*> setEffect; |
34 | setEffect active_Effects; | |
33b8c69b | 35 | |
252b36a3 | 36 | GravityWell* pMouseWell; |
a823a800 | 37 | |
617dcc71 | 38 | /// ***** Initializers/Cleaners ***** |
33b8c69b PG |
39 | |
40 | void effect::init() | |
41 | { | |
252b36a3 | 42 | pMouseWell = new GravityWell(Vector2(0,0)); |
a823a800 | 43 | |
f103ba70 PG |
44 | active_Effects.insert(new Screen()); |
45 | active_Effects.insert(new Gravity()); | |
33b8c69b PG |
46 | } |
47 | void effect::clean() | |
48 | { | |
f103ba70 PG |
49 | for( setEffect::iterator it = active_Effects.begin(); |
50 | it != active_Effects.end(); | |
51 | it++ ) | |
33b8c69b | 52 | { |
f103ba70 | 53 | // TODO !!!!!!!!! |
33b8c69b | 54 | } |
33b8c69b | 55 | } |
f206d19d | 56 | |
617dcc71 PG |
57 | /// ***** Public Methods ***** |
58 | ||
a823a800 PG |
59 | void effect::update(float) |
60 | { | |
61 | ||
62 | } | |
63 | void effect::handleInput() | |
64 | { | |
f103ba70 | 65 | if(cfg::mouseWellFollow()) |
252b36a3 | 66 | pMouseWell->setPosition(input::mousePosition()); |
f103ba70 PG |
67 | |
68 | if(cfg::mouseWellOn()) | |
252b36a3 | 69 | active_Effects.insert(pMouseWell); |
f103ba70 | 70 | if(cfg::mouseWellOff()) |
252b36a3 | 71 | active_Effects.erase(pMouseWell); |
a823a800 PG |
72 | } |
73 | ||
252b36a3 | 74 | Vector2 effect::positionDelta(const PhysicsEntity* ppe, float fTimeStep) |
f206d19d | 75 | { |
33b8c69b PG |
76 | Vector2 acc(0,0); |
77 | ||
f103ba70 PG |
78 | for( setEffect::iterator it = active_Effects.begin(); |
79 | it != active_Effects.end(); | |
80 | it++ ) | |
33b8c69b | 81 | { |
252b36a3 | 82 | acc += (*it)->positionDelta(ppe, fTimeStep); |
33b8c69b PG |
83 | } |
84 | ||
85 | return acc; | |
f206d19d | 86 | } |
252b36a3 | 87 | Vector2 effect::velocityDelta(const PhysicsEntity* ppe, float fTimeStep) |
f206d19d | 88 | { |
33b8c69b PG |
89 | Vector2 acc(0,0); |
90 | ||
f103ba70 PG |
91 | for( setEffect::iterator it = active_Effects.begin(); |
92 | it != active_Effects.end(); | |
93 | it++ ) | |
33b8c69b | 94 | { |
252b36a3 | 95 | acc += (*it)->velocityDelta(ppe, fTimeStep); |
33b8c69b PG |
96 | } |
97 | ||
98 | return acc; | |
f206d19d | 99 | } |
252b36a3 | 100 | Vector2 effect::forceDelta(const PhysicsEntity* ppe, float fTimeStep) |
f206d19d | 101 | { |
33b8c69b PG |
102 | Vector2 acc(0,0); |
103 | ||
f103ba70 PG |
104 | for( setEffect::iterator it = active_Effects.begin(); |
105 | it != active_Effects.end(); | |
106 | it++ ) | |
33b8c69b | 107 | { |
252b36a3 | 108 | acc += (*it)->forceDelta(ppe, fTimeStep); |
33b8c69b PG |
109 | } |
110 | ||
111 | return acc; | |
f206d19d | 112 | } |