Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 6bcbad9e220c9f26179c5377c802f8ad92ca4803 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
   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_ownerid = 0;
}

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