/* 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_damage = 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