summaryrefslogtreecommitdiffhomepage
path: root/src/entity.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-03-19 10:42:54 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-03-19 10:42:54 +0100
commit61d46a790cfde35bedf4283cbbcce06639cce1ec (patch)
treeffdbda2cb8fc4e47144aa25458e8191488cea478 /src/entity.hpp
parentb93313e438c7b943e506f3c16675e5d38edd0537 (diff)
src/entity: move type data member to vtable
Diffstat (limited to 'src/entity.hpp')
-rw-r--r--src/entity.hpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/entity.hpp b/src/entity.hpp
index 490f0b7d..d759cbd1 100644
--- a/src/entity.hpp
+++ b/src/entity.hpp
@@ -32,6 +32,8 @@ struct entity_proto
virtual bool operator==(const entity_proto&) const;
virtual ~entity_proto() noexcept;
+
+ entity_type type_of() const noexcept;
};
struct entity
@@ -45,7 +47,6 @@ struct entity
const Vector2b offset, bbox_offset;
const Vector2ub bbox_size;
uint16_t delta = 0, frame = 0;
- const entity_type type;
const rotation r = rotation::N;
const pass_mode pass = pass_mode::see_through;
@@ -59,6 +60,7 @@ struct entity
explicit operator entity_proto() const;
+ virtual entity_type type() const noexcept = 0;
virtual bool can_activate(size_t i) const;
virtual bool activate(size_t i);
virtual bool update(size_t i, float dt) = 0;
@@ -67,18 +69,18 @@ struct entity
virtual bool can_move_to(Vector2i delta, global_coords coord, Vector2b offset, Vector2b bbox_offset, Vector2ub bbox_aize);
virtual void set_bbox(Vector2b offset, Vector2b bbox_offset, Vector2ub bbox_size, pass_mode pass);
+ entity_type type_of() const noexcept;
static Pair<global_coords, Vector2b> normalize_coords(global_coords coord, Vector2b cur_offset, Vector2i delta);
+ bool is_dynamic() const;
bool can_rotate(rotation new_r);
bool can_move_to(Vector2i delta);
size_t move_to(size_t i, Vector2i delta, rotation new_r);
- bool is_dynamic() const;
-
friend struct world;
protected:
- entity(object_id id, struct chunk& c, entity_type type, const entity_proto& proto);
+ entity(object_id id, struct chunk& c, const entity_proto& proto);
void set_bbox_(Vector2b offset, Vector2b bbox_offset, Vector2ub bbox_size, pass_mode pass);
};