summaryrefslogtreecommitdiffstats
path: root/src/game-server/autoattack.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game-server/autoattack.cpp')
-rw-r--r--src/game-server/autoattack.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/game-server/autoattack.cpp b/src/game-server/autoattack.cpp
new file mode 100644
index 0000000..dae6b0f
--- /dev/null
+++ b/src/game-server/autoattack.cpp
@@ -0,0 +1,39 @@
+#include "autoattack.hpp"
+
+void AutoAttacks::add(AutoAttack n)
+{
+ mAutoAttacks.push_back(n);
+ // Slow, but safe.
+ mAutoAttacks.sort();
+}
+
+void AutoAttacks::clear()
+{
+ mAutoAttacks.clear();
+}
+
+void AutoAttacks::stop()
+{
+ for (std::list<AutoAttack>::iterator it = mAutoAttacks.begin(); it != mAutoAttacks.end(); ++it)
+ it->halt();
+ mActive = false;
+}
+
+void AutoAttacks::start()
+{
+ for (std::list<AutoAttack>::iterator it = mAutoAttacks.begin(); it != mAutoAttacks.end(); ++it)
+ it->softReset();
+ mActive = true;
+}
+
+void AutoAttacks::tick(std::list<AutoAttack> *ret)
+{
+ for (std::list<AutoAttack>::iterator it = mAutoAttacks.begin(); it != mAutoAttacks.end(); ++it)
+ if (it->tick()) {
+ if (mActive)
+ it->reset();
+ else
+ it->halt();
+ } else if (ret && it->isReady())
+ ret->push_back(*it);
+}