Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-03-07 13:57:09 +0000
committerStijn Buys <ingar@osirion.org>2009-03-07 13:57:09 +0000
commit4c53365c16362156529c7669079e31845384589f (patch)
tree193bb5d05299d2acb38311d108c1d39b6e1dd229
parentee2200638be3fcb14097f3e8b0abb93e210f93d9 (diff)
renamed Entity::eventstate() to Entity::state(),
introduced Destroyed state
-rw-r--r--src/client/hud.cc8
-rw-r--r--src/client/input.cc2
-rw-r--r--src/client/map.cc5
-rw-r--r--src/client/playerview.cc12
-rw-r--r--src/client/soundext.cc6
-rw-r--r--src/core/entity.cc26
-rw-r--r--src/core/entity.h22
-rw-r--r--src/game/base/collision.cc5
-rw-r--r--src/game/base/game.cc43
-rw-r--r--src/game/base/game.h1
-rw-r--r--src/game/base/jumppoint.cc6
-rw-r--r--src/game/base/planet.cc2
-rw-r--r--src/game/base/racetrack.cc20
-rw-r--r--src/game/base/ship.cc77
-rw-r--r--src/game/base/ship.h3
-rw-r--r--src/game/base/shipdealer.cc2
-rw-r--r--src/game/base/station.cc2
-rw-r--r--src/render/draw.cc10
-rw-r--r--src/render/particles.cc4
-rw-r--r--src/render/renderext.cc2
20 files changed, 166 insertions, 92 deletions
diff --git a/src/client/hud.cc b/src/client/hud.cc
index 014f4df..c1cd8c1 100644
--- a/src/client/hud.cc
+++ b/src/client/hud.cc
@@ -246,7 +246,7 @@ void HUD::draw()
}
}
- unsigned int state = core::localcontrol()->eventstate();
+ unsigned int state = core::localcontrol()->state();
if (state) {
std::stringstream statestr;
statestr.clear();
@@ -322,13 +322,13 @@ void HUD::draw()
gl::end();
float u = core::localcontrol()->thrust();
- if (core::localcontrol()->eventstate() == core::Entity::Impulse) {
+ if (core::localcontrol()->state() == core::Entity::Impulse) {
u = 1.0;
}
- if (( u > 0) || (core::localcontrol()->eventstate() == core::Entity::Impulse)) {
+ if (( u > 0) || (core::localcontrol()->state() == core::Entity::Impulse)) {
- if (core::localcontrol()->eventstate() == core::Entity::Impulse) {
+ if (core::localcontrol()->state() == core::Entity::Impulse) {
gl::color(0, .8, 0);
} else {
float d = math::absf(input::local_thrust - u);
diff --git a/src/client/input.cc b/src/client/input.cc
index 9293404..3ccf15c 100644
--- a/src/client/input.cc
+++ b/src/client/input.cc
@@ -670,7 +670,7 @@ void frame()
reset();
}
- if (core::localcontrol() && (core::localcontrol()->eventstate() != core::Entity::Normal)) {
+ if (core::localcontrol() && (core::localcontrol()->state() != core::Entity::Normal)) {
local_thrust = core::localcontrol()->thrust();
}
diff --git a/src/client/map.cc b/src/client/map.cc
index e433d40..35a1be7 100644
--- a/src/client/map.cc
+++ b/src/client/map.cc
@@ -61,7 +61,7 @@ void Map::draw()
if (h > s ) {
v.y += (h-s) * 0.5f;
} else {
- v.x += (w-s) * 0.5f;
+ //v.x += (w-s) * 0.5f;
}
gl::color(0,0,blue);
@@ -121,6 +121,9 @@ void Map::draw()
if (entity == core::localcontrol()) {
draw_icon = true;
+ l.x -= s / scale * entity->location().y;
+ l.y -= s / scale * entity->location().x;
+
if (core::application()->time() - floorf(core::application()->time()) < 0.5f) {
draw_icon = false;
}
diff --git a/src/client/playerview.cc b/src/client/playerview.cc
index f129a1e..54d444d 100644
--- a/src/client/playerview.cc
+++ b/src/client/playerview.cc
@@ -144,6 +144,9 @@ void PlayerView::draw()
{
if (core::localplayer()->view()) {
+ // hide hide when a view is set
+ view_hud->hide();
+
// docking view
if (core::localplayer()->view()->menus().size()) {
@@ -154,11 +157,13 @@ void PlayerView::draw()
label_zonename->show();
if (view_lastentity != core::localplayer()->view()) {
- // initialy show the menu
+ // initially show the menu
show_menu("main");
map()->hide();
chat()->hide();
audio::play("ui/menu");
+
+ view_lastentity = core::localplayer()->view();
} else if (!view_menu->visible() && !map()->visible() && (!chat()->visible() || chat()->small_view()) ) {
// show the menu if there's no other window open
menu()->show();
@@ -167,13 +172,12 @@ void PlayerView::draw()
} else {
// entity without menus, plain view
+ view_lastentity = 0;
+
this->hide();
return;
}
- view_hud->hide();
- view_lastentity = core::localplayer()->view();
-
} else {
if (view_menu->visible()) {
view_menu->hide();
diff --git a/src/client/soundext.cc b/src/client/soundext.cc
index 02613e1..dda3a98 100644
--- a/src/client/soundext.cc
+++ b/src/client/soundext.cc
@@ -100,7 +100,7 @@ void SoundExt::frame(float elapsed)
float gain = 0.0;
float r = ( entity->model() ? entity->model()->maxbbox().x : entity->radius());
- if (entity->eventstate() == core::Entity::Impulse) {
+ if (entity->state() == core::Entity::Impulse) {
pitch = 1.0f;
gain = 1.0f;
} else if (entity->thrust() > 0 ) {
@@ -108,7 +108,7 @@ void SoundExt::frame(float elapsed)
gain = 0.8f;
}
- if (entity->eventstate() == core::Entity::ImpulseInitiate ) {
+ if (entity->state() == core::Entity::ImpulseInitiate ) {
if (state_engineeventbuffer != state_impulsestartbuffer) {
audio::update_source(state_engineeventsource,
@@ -117,7 +117,7 @@ void SoundExt::frame(float elapsed)
state_engineeventbuffer = audio::play(state_engineeventsource, state_impulsestartbuffer);
}
- } else if (entity->eventstate() == core::Entity::Impulse) {
+ } else if (entity->state() == core::Entity::Impulse) {
state_engineeventbuffer = state_impulseloopbuffer;
diff --git a/src/core/entity.cc b/src/core/entity.cc
index 649212b..c62a412 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -388,7 +388,7 @@ EntityDynamic::EntityDynamic(unsigned int flags) :
Entity(flags)
{
entity_speed = 0.0f;
- entity_eventstate = Normal;
+ entity_state = Normal;
entity_timer = 0;
}
@@ -396,7 +396,7 @@ EntityDynamic::EntityDynamic(std::istream & is) :
Entity(is)
{
entity_speed = 0.0f;
- entity_eventstate = Normal;
+ entity_state = Normal;
entity_timer = 0;
}
@@ -404,10 +404,10 @@ EntityDynamic::~EntityDynamic()
{
}
-void EntityDynamic::set_eventstate(Event eventstate)
+void EntityDynamic::set_state(int state)
{
- if (entity_eventstate != eventstate) {
- entity_eventstate = eventstate;
+ if (entity_state != state) {
+ entity_state = state;
entity_dirty = true;
}
}
@@ -429,9 +429,9 @@ void EntityDynamic::serialize_server_create(std::ostream & os) const
{
Entity::serialize_server_create(os);
os << roundf(entity_speed * 100.0f) << " "
- << entity_eventstate << " ";
+ << entity_state << " ";
- if (entity_eventstate != Normal) {
+ if (entity_state != Normal) {
os << entity_timer << " ";
}
}
@@ -441,9 +441,9 @@ void EntityDynamic::receive_server_create(std::istream &is)
Entity::receive_server_create(is);
is >> entity_speed;
entity_speed /= 100.0f;
- is >> entity_eventstate;
+ is >> entity_state;
- if (entity_eventstate != Normal) {
+ if (entity_state != Normal) {
is >> entity_timer;
} else {
entity_timer = 0;
@@ -467,9 +467,9 @@ void EntityDynamic::serialize_server_update(std::ostream & os) const
<< entity_axis.forward() << " "
<< entity_axis.left() << " "
<< roundf(entity_speed * 100.0f) << " "
- << entity_eventstate << " ";
+ << entity_state << " ";
- if (entity_eventstate != Normal) {
+ if (entity_state != Normal) {
os << entity_timer << " ";
}
}
@@ -488,9 +488,9 @@ void EntityDynamic::receive_server_update(std::istream &is)
entity_axis[2] = math::crossproduct(entity_axis.forward(), entity_axis.left());
is >> entity_speed;
entity_speed /= 100.0f;
- is >> entity_eventstate;
+ is >> entity_state;
- if (entity_eventstate != Normal) {
+ if (entity_state != Normal) {
is >> entity_timer;
} else {
entity_timer = 0;
diff --git a/src/core/entity.h b/src/core/entity.h
index 596a701..b9ee6bd 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -47,8 +47,8 @@ public:
/// Entity shape constants
enum Shape {Diamond=0, Sphere=1, Cube=2, Axis=3};
- /// EntityDynamic event state classes
- enum Event {Normal=0, NoPower=1, ImpulseInitiate=2, Impulse=3, JumpInitiate=4, Jump=5, Docked=6};
+ /// EntityDynamic State constants
+ enum State {Normal=0, NoPower=1, ImpulseInitiate=2, Impulse=3, JumpInitiate=4, Jump=5, Docked=6, Destroyed=7};
/// entity menus collection typedef
typedef std::list<MenuDescription *> Menus;
@@ -71,7 +71,7 @@ public:
inline unsigned int moduletype() const { return entity_moduletypeid; }
/// core type id
- virtual inline unsigned int type() const { return Default; }
+ virtual inline const unsigned int type() const { return Default; }
/// entity flags
inline unsigned int flags() const { return entity_flags; }
@@ -306,16 +306,16 @@ public:
/*----- inspectors ------------------------------------------------ */
/// core type id
- virtual inline unsigned int type() const { return Entity::Dynamic; }
+ virtual inline const unsigned int type() const { return Entity::Dynamic; }
/// current speed of the entity in game units per second
- inline float speed() const { return entity_speed; }
+ inline const float speed() const { return entity_speed; }
/// event state
- inline unsigned int eventstate() const { return entity_eventstate; }
+ inline const int state() const { return entity_state; }
/// event state timer
- inline float timer() const { return entity_timer; }
+ inline const float timer() const { return entity_timer; }
/*----- serializers ----------------------------------------------- */
@@ -340,7 +340,7 @@ public:
virtual void receive_server_update(std::istream &is);
/// set event state
- virtual void set_eventstate(Event eventstate);
+ virtual void set_state(int state);
/// runs one game frame for the entity
/**
@@ -355,7 +355,7 @@ public:
protected:
float entity_timer;
- int entity_eventstate;
+ int entity_state;
};
@@ -375,7 +375,7 @@ public:
/*----- inspectors ------------------------------------------------ */
/// core type id
- virtual inline unsigned int type() const { return Entity::Controlable; }
+ virtual inline const unsigned int type() const { return Entity::Controlable; }
/// owner of this entity
inline Player *owner() const { return entity_owner; }
@@ -491,7 +491,7 @@ public:
/*----- inspectors ------------------------------------------------ */
/// core type id
- virtual inline unsigned int type() const { return Entity::Globe; }
+ virtual inline const unsigned int type() const { return Entity::Globe; }
std::string entity_texture;
diff --git a/src/game/base/collision.cc b/src/game/base/collision.cc
index e4a312a..3da65d1 100644
--- a/src/game/base/collision.cc
+++ b/src/game/base/collision.cc
@@ -17,7 +17,7 @@ void Collision::distance_test(core::EntityControlable *first, core::Entity *seco
if (!first->owner())
return;
- if (first->eventstate() == core::Entity::Docked)
+ if (first->state() == core::Entity::Docked)
return;
// FIXME - use distancesquared
@@ -29,8 +29,9 @@ void Collision::distance_test(core::EntityControlable *first, core::Entity *seco
if ( (d-r) < 0.0f) {
// crash zone
- if (first->owner()->last_warning() + 5.0f < core::application()->time()) {
+ if ((first->moduletype() == ship_enttype) && (first->state() != core::Entity::Destroyed)) {
first->owner()->send_warning("^RBOOM!^N");
+ static_cast<Ship *>(first)->explode();
}
} else if (first->owner()->last_warning() + 5.0f < core::application()->time()) {
// warning zone: star corona or planet atmosphere
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index 29c36d6..b2824f5 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -85,7 +85,7 @@ void Game::func_join(core::Player *player, std::string const &args)
if (dock) {
ship->entity_location.assign(dock->location() + (dock->axis().forward() * ((ship->radius()+ dock->radius())*2.0f)));
ship->entity_axis.assign(dock->axis());
- ship->set_eventstate(core::Entity::Docked);
+ ship->set_state(core::Entity::Docked);
player->set_view(dock);
}
@@ -183,7 +183,7 @@ void Game::func_dock(core::Player *player, core::Entity *entity)
if ((entity->flags() & core::Entity::Dockable) == 0)
return;
- if (player->control()->eventstate() != core::Entity::Normal)
+ if (player->control()->state() != core::Entity::Normal)
return;
if ((entity->flags() & core::Entity::Dockable) == core::Entity::Dockable) {
@@ -200,7 +200,7 @@ void Game::func_launch(core::Player *player, std::string const &args)
if (!player->view())
return;
- if (player->control()->eventstate() != core::Entity::Docked)
+ if (player->control()->state() != core::Entity::Docked)
return;
assert(player->view()->zone() == player->control()->zone());
@@ -208,12 +208,42 @@ void Game::func_launch(core::Player *player, std::string const &args)
core::Entity *dock = player->view();
player->control()->entity_location.assign(dock->location() + (dock->axis().forward() * (player->control()->radius()+ dock->radius())*2.0f));
player->control()->entity_axis.assign(dock->axis());
- player->control()->set_eventstate(core::Entity::Normal);
+ player->control()->set_state(core::Entity::Normal);
player->set_view(0);
player->send("^BLaunching from " + dock->name());
}
+// respawn
+void Game::func_respawn(core::Player *player, std::string const &args)
+{
+ if (!player->control())
+ return;
+
+ if (!(player->view() == player->control()))
+ return;
+
+ if (player->control()->state() != core::Entity::Destroyed)
+ return;
+
+ player->control()->set_zone(Default::zone);
+ core::Entity *dock = player->control()->zone()->default_view();
+ if (dock) {
+ player->control()->entity_location.assign(dock->location() + (dock->axis().forward() * ((player->control()->radius()+ dock->radius())*2.0f)));
+ player->control()->entity_axis.assign(dock->axis());
+ player->control()->set_state(core::Entity::Docked);
+ player->set_view(dock);
+ player->send("^BRespawning at " + dock->name());
+ } else {
+ player->control()->location().clear();
+ player->control()->axis().clear();
+ player->control()->set_state(core::Entity::Normal);
+ player->set_view(0);
+ player->send("^BRespawning");
+ }
+}
+
+
// instantaniously goto a specified entity within the zone
void Game::func_goto(core::Player *player, const std::string &args)
{
@@ -233,7 +263,7 @@ void Game::func_goto(core::Player *player, const std::string &args)
player->control()->entity_location.assign(dock->location() + (dock->axis().forward() * (player->control()->radius()+dock->radius())*2.0f));
player->control()->entity_axis.assign(dock->axis());
player->control()->entity_axis.change_direction(180.0f);
- player->control()->set_eventstate(core::Entity::Normal);
+ player->control()->set_state(core::Entity::Normal);
player->set_view(0);
player->send("Going to " + dock->name());
} else {
@@ -290,6 +320,9 @@ Game::Game() : core::Module("Project::OSiRiON", true)
func = core::Func::add("launch", Game::func_launch);
func->set_info("launch to space when docked");
+ func = core::Func::add("respawn", Game::func_respawn);
+ func->set_info("respawn when your ship has been destroyed");
+
func = core::Func::add("goto", Game::func_goto);
func->set_info("[string] goto to an entity within the zone");
diff --git a/src/game/base/game.h b/src/game/base/game.h
index 2af71ef..36de8dc 100644
--- a/src/game/base/game.h
+++ b/src/game/base/game.h
@@ -101,6 +101,7 @@ private:
static void func_impulse(core::Player *player, std::string const &args);
static void func_dock(core::Player *player,core::Entity *entity);
static void func_launch(core::Player *player, std::string const &args);
+ static void func_respawn(core::Player *player, std::string const &args);
static void func_goto(core::Player *player, const std::string &args);
};
diff --git a/src/game/base/jumppoint.cc b/src/game/base/jumppoint.cc
index eb51b68..e489055 100644
--- a/src/game/base/jumppoint.cc
+++ b/src/game/base/jumppoint.cc
@@ -81,7 +81,7 @@ JumpGate::JumpGate() : JumpPoint()
entity_radius = 1.0f;
entity_moduletypeid = jumpgate_enttype;
- entity_eventstate = core::Entity::NoPower;
+ entity_state = core::Entity::NoPower;
}
JumpGate::~JumpGate()
@@ -138,7 +138,7 @@ void JumpGate::dock(core::Entity *entity)
void JumpGate::activate()
{
jumpgate_timer = 10.0f;
- entity_eventstate = core::Entity::Normal;
+ set_state(core::Entity::Normal);
}
void JumpGate::frame(float elapsed)
@@ -147,7 +147,7 @@ void JumpGate::frame(float elapsed)
jumpgate_timer -= elapsed;
if (jumpgate_timer < 0) {
- entity_eventstate = core::Entity::NoPower;
+ set_state(core::Entity::NoPower);
jumpgate_timer = 0;
}
}
diff --git a/src/game/base/planet.cc b/src/game/base/planet.cc
index 6bb1f59..3242f15 100644
--- a/src/game/base/planet.cc
+++ b/src/game/base/planet.cc
@@ -53,7 +53,7 @@ void Planet::dock(core::Entity *entity)
}
ship->location().assign(entity->location());
- ship->set_eventstate(core::Entity::Docked);
+ ship->set_state(core::Entity::Docked);
if (ship->owner() && ship->owner()->control() == ship) {
ship->owner()->set_view(this);
diff --git a/src/game/base/racetrack.cc b/src/game/base/racetrack.cc
index f36c047..f54a24b 100644
--- a/src/game/base/racetrack.cc
+++ b/src/game/base/racetrack.cc
@@ -17,7 +17,7 @@ namespace game {
CheckPoint::CheckPoint(RaceTrack *parent)
{
- entity_eventstate = core::Entity::NoPower;
+ set_state(core::Entity::NoPower);
parent_track = parent;
if (parent) {
entity_color = parent->color();
@@ -42,7 +42,7 @@ RaceTrack::RaceTrack() : EntityDynamic()
track_racestart = 0;
track_checkpointtime = 0;
- entity_eventstate = core::Entity::NoPower;
+ set_state(core::Entity::NoPower);
set_flag(core::Entity::Dockable);
}
@@ -66,10 +66,10 @@ void RaceTrack::reset()
track_checkpointtime = 0;
for (CheckPoints::iterator cpit = track_checkpoints.begin(); cpit != track_checkpoints.end(); ++cpit) {
- (*cpit)->set_eventstate(core::Entity::NoPower);
+ (*cpit)->set_state(core::Entity::NoPower);
}
- set_eventstate(core::Entity::NoPower);
+ set_state(core::Entity::NoPower);
}
void RaceTrack::dock(core::Entity *entity)
@@ -91,10 +91,10 @@ void RaceTrack::dock(core::Entity *entity)
track_player = ship->owner();
track_racestart = core::server()->time();
- set_eventstate(core::Entity::Normal);
+ set_state(core::Entity::Normal);
for (CheckPoints::iterator cpit = track_checkpoints.begin(); cpit != track_checkpoints.end(); ++cpit) {
- set_eventstate(core::Entity::Normal);
+ set_state(core::Entity::Normal);
}
entity_timer = 5.0f;
@@ -151,7 +151,7 @@ void RaceTrack::frame(float seconds)
track_racestart = core::server()->time();
} else {
for (CheckPoints::iterator cpit = track_checkpoints.begin(); cpit != track_checkpoints.end(); ++cpit) {
- (*cpit)->set_eventstate(core::Entity::NoPower);
+ (*cpit)->set_state(core::Entity::NoPower);
}
std::string message("^BGo!");
core::server()->broadcast(message);
@@ -159,7 +159,7 @@ void RaceTrack::frame(float seconds)
track_racestart = core::server()->time();
track_checkpointtime = core::server()->time() + 15.0f;
track_checkpoint = track_checkpoints.begin();
- (*track_checkpoint)->set_eventstate(core::Entity::Normal);
+ (*track_checkpoint)->set_state(core::Entity::Normal);
track_player->set_mission_target((*track_checkpoint));
}
}
@@ -184,9 +184,9 @@ void RaceTrack::frame(float seconds)
std::string message("^BCheckpoint!");
core::server()->broadcast(message);
track_checkpointtime = core::server()->time() + 15.0f;
- (*track_checkpoint)->set_eventstate(core::Entity::NoPower);
+ (*track_checkpoint)->set_state(core::Entity::NoPower);
track_checkpoint++;
- (*track_checkpoint)->set_eventstate(core::Entity::Normal);
+ (*track_checkpoint)->set_state(core::Entity::Normal);
track_player->set_mission_target((*track_checkpoint));
} else {
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index edfc949..ba5d7ba 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -63,24 +63,24 @@ void Ship::reset()
}
void Ship::func_impulse()
{
- if (entity_eventstate == core::Entity::Impulse) {
- entity_eventstate = core::Entity::Normal;
+ if (entity_state == core::Entity::Impulse) {
+ entity_state = core::Entity::Normal;
target_thrust = 1.0f;
entity_thrust = 1.0f;
- } else if (entity_eventstate == core::Entity::ImpulseInitiate) {
- entity_eventstate = core::Entity::Normal;
+ } else if (entity_state == core::Entity::ImpulseInitiate) {
+ entity_state = core::Entity::Normal;
- } else if (entity_eventstate != core::Entity::Normal) {
+ } else if (entity_state != core::Entity::Normal) {
return;
} else {
- if (entity_eventstate == core::Entity::JumpInitiate) {
+ if (entity_state == core::Entity::JumpInitiate) {
ship_jumpdrive_timer = 0;
entity_timer = 0;
}
- entity_eventstate = core::Entity::ImpulseInitiate;
+ entity_state = core::Entity::ImpulseInitiate;
if (Game::g_devel->value()) {
entity_timer = 0;
} else {
@@ -104,7 +104,7 @@ void Ship::initiate_jump(JumpPoint *depart)
return;
ship_jumpdepart = depart;
- entity_eventstate = core::Entity::JumpInitiate;
+ entity_state = core::Entity::JumpInitiate;
if (Game::g_devel->value()) {
entity_timer = 0;
@@ -118,7 +118,7 @@ void Ship::initiate_jump(JumpPoint *depart)
void Ship::func_jump(std::string const &args)
{
- if (entity_eventstate == core::Entity::Docked) {
+ if (entity_state == core::Entity::Docked) {
return;
}
@@ -150,7 +150,7 @@ void Ship::func_jump(std::string const &args)
ship_jumpdrive_timer = 0;
entity_timer = 0;
- entity_eventstate = core::Entity::Jump;
+ entity_state = core::Entity::Jump;
entity_dirty = true;
return;
@@ -160,14 +160,14 @@ void Ship::func_jump(std::string const &args)
owner()->send("This ship is not equiped with a hyperspace drive!");
return;
- } else if (entity_eventstate == core::Entity::Jump) {
+ } else if (entity_state == core::Entity::Jump) {
return;
- } else if (entity_eventstate == core::Entity::JumpInitiate) {
+ } else if (entity_state == core::Entity::JumpInitiate) {
owner()->send("Jump aborted, hyperspace drive deactivated");
ship_jumpdrive_timer = 0;
entity_timer = 0;
- entity_eventstate = core::Entity::Normal;
+ entity_state = core::Entity::Normal;
return;
}
initiate_jump(find_closest_jumppoint());
@@ -207,6 +207,24 @@ JumpPoint * Ship::find_closest_jumppoint()
return 0;
}
+void Ship::explode()
+{
+ set_state(core::Entity::Destroyed);
+
+ target_thrust = 0;
+ target_pitch = 0;
+ target_roll = 0;
+ target_direction = 0;
+ target_afterburner = 0.0f;
+ target_thrust = 0;
+ entity_thrust = 0;
+
+ if (owner()) {
+ if (owner()->control() == this)
+ owner()->set_view(this);
+ }
+};
+
void Ship::frame(float seconds)
{
const float direction_change_speed = 2;
@@ -228,7 +246,7 @@ void Ship::frame(float seconds)
// target axis
math::Axis target_axis(entity_axis);
- if (entity_eventstate == core::Entity::Docked) {
+ if (entity_state == core::Entity::Docked) {
target_thrust = 0;
target_pitch = 0;
@@ -238,16 +256,17 @@ void Ship::frame(float seconds)
target_thrust = 0;
entity_speed = 0;
+ entity_thrust = 0;
return;
- } else if (entity_eventstate == core::Entity::JumpInitiate) {
+ } else if (entity_state == core::Entity::JumpInitiate) {
if (ship_jumpdrive_timer + 1.0f <= core::server()->time()) {
entity_timer -= 1.0f;
if (entity_timer <= 0) {
if (ship_jumpdepart && ship_jumpdepart->target()) {
- entity_eventstate = core::Entity::Jump;
+ set_state(core::Entity::Jump);
set_zone(ship_jumpdepart->target()->zone());
if (owner() && owner()->control() == (EntityControlable*) this)
owner()->set_zone(ship_jumpdepart->target()->zone());
@@ -261,7 +280,7 @@ void Ship::frame(float seconds)
}
owner()->send("^BJumping to the " + ship_jumpdepart->target()->zone()->name());
} else {
- entity_eventstate = core::Entity::Normal;
+ set_state(core::Entity::Normal);
}
ship_jumpdrive_timer = 0;
entity_timer = 0;
@@ -282,7 +301,7 @@ void Ship::frame(float seconds)
target_afterburner = 0.0f;
target_thrust = 0.1;
- } else if (entity_eventstate == core::Entity::Jump) {
+ } else if (entity_state == core::Entity::Jump) {
// control is disabled while the jumpdrive is activated
target_thrust = 0;
target_pitch = 0;
@@ -298,12 +317,12 @@ void Ship::frame(float seconds)
// FIXME 5 second cooldown
entity_speed = Game::g_impulsespeed->value();
- entity_eventstate = core::Entity::Normal;
+ entity_state = core::Entity::Normal;
if (owner() && owner()->view() && owner()->control() == (EntityControlable*) this)
owner()->set_view(0);
- } else if (entity_eventstate == core::Entity::ImpulseInitiate) {
+ } else if (entity_state == core::Entity::ImpulseInitiate) {
if (ship_impulsedrive_timer + 1.0f <= core::server()->time()) {
entity_timer -= 1.0f;
@@ -311,7 +330,7 @@ void Ship::frame(float seconds)
if (entity_timer <= 0) {
actual_maxspeed = Game::g_impulsespeed->value();
actual_acceleration = Game::g_impulseacceleration->value();
- entity_eventstate = core::Entity::Impulse;
+ entity_state = core::Entity::Impulse;
entity_timer = 0;
entity_dirty = true;
} else {
@@ -328,7 +347,7 @@ void Ship::frame(float seconds)
math::clamp(target_afterburner, -1.0f, 1.0f);
actual_turnspeed *= 0.5;
- } else if (entity_eventstate == core::Entity::Impulse) {
+ } else if (entity_state == core::Entity::Impulse) {
// clamp input values
target_thrust = 0.0f;
@@ -340,7 +359,7 @@ void Ship::frame(float seconds)
actual_acceleration = Game::g_impulseacceleration->value();
actual_turnspeed *= 0.5;
- } else if (entity_eventstate == core::Entity::Normal) {
+ } else if (entity_state == core::Entity::Normal) {
// clamp input values
math::clamp(target_thrust, 0.0f, 1.0f);
@@ -354,6 +373,16 @@ void Ship::frame(float seconds)
actual_turnspeed *= 0.5;
}
+ } else if (entity_state == core::Entity::Destroyed) {
+
+ target_thrust = 0;
+ target_pitch = 0;
+ target_roll = 0;
+ target_direction = 0;
+ target_afterburner = 0.0f;
+ target_thrust = 0;
+
+ entity_thrust = 0;
}
// update roll
@@ -449,7 +478,7 @@ void Ship::frame(float seconds)
math::clamp(entity_thrust, 0.0f, 1.0f);
float actual_thrust = entity_thrust + current_target_afterburner * 0.15f;
- if ((entity_eventstate == core::Entity::ImpulseInitiate) || (entity_eventstate == core::Entity::Impulse)) {
+ if ((entity_state == core::Entity::ImpulseInitiate) || (entity_state == core::Entity::Impulse)) {
actual_thrust = 1.0f;
}
diff --git a/src/game/base/ship.h b/src/game/base/ship.h
index bed3d1e..37f8b88 100644
--- a/src/game/base/ship.h
+++ b/src/game/base/ship.h
@@ -36,6 +36,9 @@ public:
/// void reset drive controls
void reset();
+ /// explode the ship
+ void explode();
+
/// toggle impulse drive activation
void func_impulse();
diff --git a/src/game/base/shipdealer.cc b/src/game/base/shipdealer.cc
index 5aced0b..e28b922 100644
--- a/src/game/base/shipdealer.cc
+++ b/src/game/base/shipdealer.cc
@@ -133,7 +133,7 @@ void ShipDealer::func_buy(core::Player *player, const std::string &args)
if (dock) {
ship->set_zone(dock->zone());
ship->location().assign(dock->location());
- ship->set_eventstate(core::Entity::Docked);
+ ship->set_state(core::Entity::Docked);
ship->entity_axis.assign(dock->axis());
ship->entity_axis.change_direction(180.0f);
player->set_control(ship);
diff --git a/src/game/base/station.cc b/src/game/base/station.cc
index d39f1c6..69949fb 100644
--- a/src/game/base/station.cc
+++ b/src/game/base/station.cc
@@ -47,7 +47,7 @@ void Station::dock(core::Entity *entity)
}
ship->location().assign(entity->location());
- ship->set_eventstate(core::Entity::Docked);
+ ship->set_state(core::Entity::Docked);
if (ship->owner() && ship->owner()->control() == ship) {
ship->owner()->set_view(this);
diff --git a/src/render/draw.cc b/src/render/draw.cc
index a435eff..a56e1dc 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -556,14 +556,14 @@ void draw_model_fragments(core::Entity *entity)
if ((entity->type() == core::Entity::Dynamic) || (entity->type() == core::Entity::Controlable)) {
- if (static_cast<core::EntityDynamic *>(entity)->eventstate() == core::Entity::NoPower) {
+ if (static_cast<core::EntityDynamic *>(entity)->state() == core::Entity::NoPower) {
power = false;
} else if (entity->type() == core::Entity::Controlable) {
core::EntityControlable *ec = static_cast<core::EntityControlable *>(entity);
- if ((ec->eventstate() == core::Entity::Impulse) || (ec->eventstate() == core::Entity::ImpulseInitiate)) {
+ if ((ec->state() == core::Entity::Impulse) || (ec->state() == core::Entity::ImpulseInitiate)) {
thrust = 1.0f;
} else {
thrust = ec->thrust();
@@ -761,10 +761,10 @@ void draw_pass_model_fx(float elapsed)
power = true;
if ((entity->type() == core::Entity::Dynamic) &&
- (static_cast<core::EntityDynamic *>(entity)->eventstate() == core::Entity::NoPower)) {
+ (static_cast<core::EntityDynamic *>(entity)->state() == core::Entity::NoPower)) {
power = false;
} else if ((entity->type() == core::Entity::Controlable) &&
- (static_cast<core::EntityControlable *>(entity)->eventstate() == core::Entity::NoPower)) {
+ (static_cast<core::EntityControlable *>(entity)->state() == core::Entity::NoPower)) {
power = false;
}
@@ -827,7 +827,7 @@ void draw_pass_model_fx(float elapsed)
thrust = 1.0f;
if (flare->engine() && ( entity->type() == core::Entity::Controlable)) {
core::EntityControlable *ec = static_cast<core::EntityControlable *>(entity);
- if ((ec->eventstate() == core::Entity::ImpulseInitiate) || (ec->eventstate() == core::Entity::Impulse)) {
+ if ((ec->state() == core::Entity::ImpulseInitiate) || (ec->state() == core::Entity::Impulse)) {
thrust = 1.0f;
} else {
thrust = ec->thrust();
diff --git a/src/render/particles.cc b/src/render/particles.cc
index ef6886a..13b69a4 100644
--- a/src/render/particles.cc
+++ b/src/render/particles.cc
@@ -229,7 +229,7 @@ void ParticleSystem::draw(float elapsed)
{
if (particlesystem_entity->type() == core::Entity::Controlable) {
core::EntityControlable *ec = static_cast<core::EntityControlable *>(particlesystem_entity);
- if (ec->eventstate() == core::Entity::Docked) {
+ if (ec->state() == core::Entity::Docked) {
if (particlesystem_stream.size())
clear();
return;
@@ -263,7 +263,7 @@ void ParticleSystem::draw(float elapsed)
}
} else if (particlesystem_entity->type() == core::Entity::Controlable) {
core::EntityControlable *ec = static_cast<core::EntityControlable *>(particlesystem_entity);
- if ((ec->thrust() > 0.0f) || (ec->eventstate() == core::Entity::ImpulseInitiate) || (ec->eventstate() == core::Entity::Impulse)) {
+ if ((ec->thrust() > 0.0f) || (ec->state() == core::Entity::ImpulseInitiate) || (ec->state() == core::Entity::Impulse)) {
ejector_active = true;
}
}
diff --git a/src/render/renderext.cc b/src/render/renderext.cc
index 1e82aa0..6a59870 100644
--- a/src/render/renderext.cc
+++ b/src/render/renderext.cc
@@ -105,7 +105,7 @@ void RenderExt::frame(float elapsed)
state_detailvisible = false;
if ((entity()->type() == core::Entity::Controlable)) {
- if (static_cast<core::EntityDynamic *>(entity())->eventstate() == core::Entity::Docked) {
+ if (static_cast<core::EntityDynamic *>(entity())->state() == core::Entity::Docked) {
state_visible = false;
}
}