summaryrefslogtreecommitdiff
path: root/src/game/game.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/game.hpp')
-rw-r--r--src/game/game.hpp80
1 files changed, 46 insertions, 34 deletions
diff --git a/src/game/game.hpp b/src/game/game.hpp
index 4cc1077..b9a426b 100644
--- a/src/game/game.hpp
+++ b/src/game/game.hpp
@@ -55,21 +55,36 @@ namespace game {
void load(void);
}
- class unit_t : public world::entity_t {
- protected:
- game::state_t *game;
- world::world_t *world;
+ class entity_t : public world::entity_t {
+ public:
+ game::state_t *game = 0;
+ v2f_t x;
+ rectf_t size, render_size;
+
+ entity_t(game::state_t *game, int type_);
+ ~entity_t(void) {};
+ void destroy(void);
- world::cmodel_t make_cmodel(v2f_t at);
- void compute_bounds();
+ void place(world::world_t *world);
+ void place(world::world_t *world, v2f_t x_);
+ bool always_awake = false;
+ bool awake = false;
+ double wake_time = -INFINITY;
+ void wake(void);
+ void sleep(void);
+
+ virtual void on_think(void) = 0;
+ virtual void on_spawn(void) = 0;
+ virtual void on_wake(void) = 0;
+ };
+
+ class unit_t : public entity_t {
+ protected:
double next_targetting = -INFINITY;
double last_attack = -INFINITY;
public:
- v2f_t x;
- rectf_t size, render_size;
- world::cflags_t cflags;
size_t selected = 0;
typedef enum {
@@ -82,8 +97,6 @@ namespace game {
unit_t(game::state_t *game_, type_t type_);
- virtual void think(void) = 0;
-
struct {
bool moving = false;
v2f_t dst;
@@ -96,15 +109,9 @@ namespace game {
float next_attempt;
} move;
- void place(world::world_t *world_, v2f_t x_);
bool keep_moving(double speed);
bool start_moving(v2f_t dst, world::cflags_t cflags);
- bool awake = false;
- double wake_time = -INFINITY;
- virtual void wake(unit_t *by_whom) = 0;
- virtual void sleep(void) = 0;
-
struct {
size_t armor_class;
roll_params_t hit_roll;
@@ -116,13 +123,13 @@ namespace game {
int health = 1, max_health = 1;
void damage(int points, unit_t *attacker);
void try_attack(unit_t *target);
- virtual void die() = 0;
+ void die(unit_t *killer);
+ virtual void on_death() = 0;
std::string say_text;
double say_time = -INFINITY;
void say(std::string str);
-
void render_to(render::state_t *render);
};
@@ -133,34 +140,37 @@ namespace game {
public:
human_t(game::state_t *game_);
+ ~human_t(void) {};
void render_to(render::state_t *render);
- void wake(unit_t *by_whom);
- void sleep(void);
- void think(void);
- void die(void);
+ void on_think(void);
+ void on_spawn(void) {};
+ void on_wake(void) {};
+ void on_death(void);
};
class alien_t : public unit_t {
- double next_targetting = -INFINITY;
-
public:
alien_t(game::state_t *game_);
+ ~alien_t(void) {};
void render_to(render::state_t *render);
- void wake(unit_t *by_whom);
- void sleep(void);
- void think(void);
- void die(void);
+ void on_think(void);
+ void on_spawn(void) {};
+ void on_wake(void);
+ void on_death(void);
};
- class effect_t : public world::entity_t {
+ class effect_t : public game::entity_t {
public:
- game::state_t *game;
-
double ttl = +INFINITY;
+
effect_t(game::state_t *game_);
virtual ~effect_t() {};
+
+ void on_think(void);
+ void on_spawn(void) {};
+ void on_wake(void) {};
};
class fx_tracer_t : public effect_t {
@@ -168,7 +178,8 @@ namespace game {
public:
fx_tracer_t(game::state_t *game_, v2f_t x0_, v2f_t x1_);
- ~fx_tracer_t(void) = default;
+ ~fx_tracer_t(void) {};
+
void render_to(render::state_t *render);
};
@@ -178,7 +189,8 @@ namespace game {
public:
fx_blood_t(game::state_t *game_, v2f_t x_, bool alien_);
- ~fx_blood_t(void) = default;
+ ~fx_blood_t(void) {};
+
void render_to(render::state_t *render);
};