#include "../common.hpp" namespace game { enum { ET_UNIT }; enum { TILE_NONE, TILE_DIRT, TILE_WALL }; enum { CF_NONE = 0, CF_SOLID = 1, CF_HUMAN = 2 }; extern size_t selection_cookie; void worldgen(world::tile_t *tile, world::tile_index_t x, procgen::perlin_noise_t *perlin); namespace assets { typedef struct { render::oriented_sprite_4M_t head_idle, body_idle; render::oriented_sprite_4M2_t legs_idle, legs_walking; render::animated_texture_t dead; } human_assets_t; typedef struct { render::oriented_sprite_4M_t idle, walking; } alien_assets_t; extern human_assets_t human; extern alien_assets_t alien; void load(void); } class unit_t : public world::entity_t { protected: world::world_t *world; world::cmodel_t make_cmodel(v2f_t at); void compute_bounds(); public: v2f_t x; rectf_t size, render_size; world::cflags_t cflags; size_t selected = 0; typedef enum { UNIT_HUMAN, UNIT_ALIEN } type_t; type_t type; unit_t(type_t type_); virtual void think(double now, double dt) = 0; struct { bool moving = false; v2f_t dst; float angle = 0.0f; std::list path; bool blocked; size_t attempts_left; float next_attempt; } move; void place(world::world_t *world_, v2f_t x_); bool keep_moving(double now, double dt, double speed); bool start_moving(v2f_t dst_, double now); bool awake = false; double wake_time = -INFINITY; virtual void wake(double now, unit_t *by_whom) = 0; virtual void sleep(double now) = 0; bool dead = false; double death_time = -INFINITY; int health = 1; void damage(double now, int points); virtual void die(double now) = 0; const wchar_t *say_text; double say_time = -INFINITY; void say(const wchar_t *wstr, double now); void render_to(render::state_t *render); }; class human_t : public unit_t { public: human_t(); void render_to(render::state_t *render); void wake(double now, unit_t *by_whom); void sleep(double now); void think(double now, double dt); void die(double now); }; class alien_t : public unit_t { double next_targetting = -INFINITY; double next_attack = -INFINITY; void attack(double now, unit_t *target, float range); public: alien_t(); void render_to(render::state_t *render); void wake(double now, unit_t *by_whom); void sleep(double now); void think(double now, double dt); void die(double now); }; };