summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-12-18 19:55:43 +0000
committerPaweł Redman <pawel.redman@gmail.com>2017-12-18 19:55:43 +0000
commitb0cb2054fae07a688174d6b78fd310c986233de3 (patch)
treecc6f480fc2a1f7c0fc0b3de7226d352f5c005f85 /src
parent2d0ca20e5f8775960e1e93add81876ed6fa26707 (diff)
Drastically reduce the number of awake entities.
Diffstat (limited to 'src')
-rw-r--r--src/common.hpp1
-rw-r--r--src/game/game.hpp2
-rw-r--r--src/game/interface.cpp16
-rw-r--r--src/game/units.cpp5
4 files changed, 16 insertions, 8 deletions
diff --git a/src/common.hpp b/src/common.hpp
index f136487..3131b69 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -213,6 +213,7 @@ namespace game {
class state_t {
protected:
friend entity_t;
+ friend interface::state_t;
std::unordered_set<entity_t*> awake_entities;
std::unordered_set<unit_t*> selected_units;
diff --git a/src/game/game.hpp b/src/game/game.hpp
index aea381c..75ac555 100644
--- a/src/game/game.hpp
+++ b/src/game/game.hpp
@@ -109,7 +109,7 @@ namespace game {
void place(world::world_t *world);
void place(world::world_t *world, v2f_t x_);
- bool ignore_waking = false;
+ bool ignore_waking = true; // Most entities won't need this mechanism.
bool awake = false;
double wake_time = -INFINITY;
void wake(void);
diff --git a/src/game/interface.cpp b/src/game/interface.cpp
index f4403ea..d125392 100644
--- a/src/game/interface.cpp
+++ b/src/game/interface.cpp
@@ -180,14 +180,18 @@ void state_t::render_to(render::state_t *render)
x[1] += em;
}
- x = v2f_t(0.0f, h - em * 1.5);
- ss << "World S/T/E: ";
+ x = v2f_t(0.0f, h - em * 4.5);
+ ss << "World S/T:";
ss << game->world.stats.sectors << "/";
- ss << game->world.stats.tiles << "/";
- ss << game->world.stats.entities;
+ ss << game->world.stats.tiles;
render->render_text(x, em, ss.str(), render::ALIGN_LEFT_TOP, sf::Color::White);
- x[1] -= em;
+ x[1] += em;
+ ss.str(std::string());
+ ss << "Awake: " << game->awake_entities.size() << "/" << game->world.stats.entities;
+ render->render_text(x, em, ss.str(), render::ALIGN_LEFT_TOP, sf::Color::White);
+
+ x[1] += em;
ss.str(std::string());
ss << "View S/T/E: ";
ss << render->stats.sectors << "/";
@@ -203,7 +207,7 @@ void state_t::render_to(render::state_t *render)
fps += perf_hist[i];
fps /= count(perf_hist);
- x[1] -= em;
+ x[1] += em;
ss.str(std::string());
ss << std::fixed << std::setprecision(1);
ss << "FPS: " << fps;
diff --git a/src/game/units.cpp b/src/game/units.cpp
index 24b9567..ef7fc6f 100644
--- a/src/game/units.cpp
+++ b/src/game/units.cpp
@@ -277,7 +277,6 @@ unit_soldier_t::unit_soldier_t(game::state_t *game) : unit_t(game, UNIT_SOLDIER)
name = text::get(text::UNIT_NAME_SOLDIER);
- ignore_waking = true; // Always awake.
wake();
friendly = true;
controllable = true;
@@ -484,6 +483,8 @@ unit_spider_t::unit_spider_t(game::state_t *game) : unit_t(game, UNIT_SPIDER)
name = text::get(text::UNIT_NAME_SPIDER);
+ ignore_waking = false;
+
health = max_health = 4;
cs.armor_class = 15;
cs.hit_die = die_t(3, 6);
@@ -564,6 +565,8 @@ unit_nest_t::unit_nest_t(game::state_t *game_) : unit_t(game_, UNIT_NEST)
name = text::get(text::UNIT_NAME_NEST);
+ ignore_waking = false;
+
health = max_health = 45;
cs.armor_class = 5;