summaryrefslogtreecommitdiff
path: root/src/game-server/spawnareacomponent.h
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-03-17 21:11:41 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-03-25 20:32:36 +0100
commit8ebd7ef2c200009e6d22b2cfaa3dd0d849155db6 (patch)
treee77633d3d4e2c2538a1044589b5cc927cfa4e125 /src/game-server/spawnareacomponent.h
parent626e4c98353f2111ae21123756396fc845447b57 (diff)
downloadmanaserv-8ebd7ef2c200009e6d22b2cfaa3dd0d849155db6.tar.gz
manaserv-8ebd7ef2c200009e6d22b2cfaa3dd0d849155db6.tar.bz2
manaserv-8ebd7ef2c200009e6d22b2cfaa3dd0d849155db6.tar.xz
manaserv-8ebd7ef2c200009e6d22b2cfaa3dd0d849155db6.zip
Changed SpawnArea and TriggerArea to components of Entity
Well, first visible change is that everything just gets longer to read. Reviewed-by: Yohann Ferreira
Diffstat (limited to 'src/game-server/spawnareacomponent.h')
-rw-r--r--src/game-server/spawnareacomponent.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/game-server/spawnareacomponent.h b/src/game-server/spawnareacomponent.h
new file mode 100644
index 00000000..52399a64
--- /dev/null
+++ b/src/game-server/spawnareacomponent.h
@@ -0,0 +1,62 @@
+/*
+ * The Mana Server
+ * Copyright (C) 2006-2010 The Mana World Development Team
+ * Copyright (C) 2012 The Mana Developers
+ *
+ * This file is part of The Mana Server.
+ *
+ * The Mana Server is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana Server is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana Server. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SPAWNAREACOMPONENT_H
+#define SPAWNAREACOMPONENT_H
+
+#include "game-server/component.h"
+
+#include "utils/point.h"
+
+class MonsterClass;
+
+/**
+ * A spawn area, where monsters spawn. The area is a rectangular field and will
+ * spawn a certain number of a given monster type.
+ */
+class SpawnAreaComponent : public Component
+{
+ public:
+ static const ComponentType type = SpawnArea;
+
+ SpawnAreaComponent(MonsterClass *,
+ const Rectangle &zone,
+ int maxBeings, int spawnRate);
+
+ void update(Entity &entity);
+
+ /**
+ * Keeps track of the number of spawned being.
+ */
+ void decrease(Entity *);
+
+ private:
+ MonsterClass *mSpecy; /**< Specy of monster that spawns in this area. */
+ Rectangle mZone;
+ int mMaxBeings; /**< Maximum population of this area. */
+ int mSpawnRate; /**< Number of beings spawning per minute. */
+ int mNumBeings; /**< Current population of this area. */
+ int mNextSpawn; /**< The time until next being spawn. */
+
+ friend struct SpawnAreaEventDispatch;
+};
+
+#endif // SPAWNAREACOMPONENT_H