Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/base/projectile.cc')
-rw-r--r--src/game/base/projectile.cc71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/game/base/projectile.cc b/src/game/base/projectile.cc
new file mode 100644
index 0000000..992c55b
--- /dev/null
+++ b/src/game/base/projectile.cc
@@ -0,0 +1,71 @@
+/*
+ base/projectile.cc
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
+*/
+
+#include "base/projectile.h"
+#include "base/game.h"
+#include "core/gameserver.h"
+#include "math/functions.h"
+#include "sys/sys.h"
+
+namespace game
+{
+
+Projectile::Projectile(unsigned long lifespan) : EntityDynamic()
+{
+ entity_moduletypeid = projectile_enttype;
+ //set_name("");
+ //set_label("");
+
+ //set_serverside(true);
+ set_flag(core::Entity::KeepAlive);
+ set_shape(core::Entity::Sphere);
+ set_radius(0.02f);
+ set_mass(radius());
+
+ //reset();
+
+ //const float damp = Game::g_damping->value();
+ //body()->setDamping(0.0f, 0.0f);
+
+ projectile_lifespan = lifespan;
+ projectile_timestamp = core::server()->timestamp();
+}
+
+Projectile::~Projectile()
+{
+
+}
+
+void Projectile::upkeep(const unsigned long timestamp)
+{
+ die();
+}
+
+void Projectile::collision(core::Entity *other)
+{
+ if (state() == core::Entity::Destroyed) {
+ return;
+ }
+
+ set_state(core::Entity::Destroyed);
+ // this method is a bullet callback, we can not reset() here
+}
+
+void Projectile::frame(const unsigned long elapsed)
+{
+ EntityDynamic::frame(elapsed);
+
+ if (projectile_timestamp + projectile_lifespan < core::server()->timestamp()) {
+ set_state(core::Entity::Destroyed);
+ }
+
+ if (state() == core::Entity::Destroyed) {
+ die();
+ }
+}
+
+} // namespace game
+