summaryrefslogtreecommitdiffhomepage
path: root/editor
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-09-01 22:27:30 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-09-01 22:27:30 +0200
commit31fd5bbc08234686cf798a93a18e0bb73615d1bf (patch)
tree59b964d01885916c5d49fef3c168ff10dcbdd93f /editor
parent053ea3aa1c443c368f8b43591e3e970e12b50c70 (diff)
rename entity -> object
Diffstat (limited to 'editor')
-rw-r--r--editor/app.cpp8
-rw-r--r--editor/app.hpp2
-rw-r--r--editor/camera.cpp2
-rw-r--r--editor/draw.cpp2
-rw-r--r--editor/editor.cpp2
-rw-r--r--editor/imgui.cpp16
-rw-r--r--editor/inspect-draw.cpp4
-rw-r--r--editor/inspect-types.cpp74
-rw-r--r--editor/inspect.hpp4
-rw-r--r--editor/scenery-editor.cpp6
-rw-r--r--editor/update.cpp4
-rw-r--r--editor/vobj-editor.cpp10
-rw-r--r--editor/vobj-editor.hpp8
13 files changed, 71 insertions, 71 deletions
diff --git a/editor/app.cpp b/editor/app.cpp
index e1e4af39..43e3116c 100644
--- a/editor/app.cpp
+++ b/editor/app.cpp
@@ -39,7 +39,7 @@ void app::reset_world()
void app::ensure_player_character(world& w)
{
if (_character_id)
- if (auto C = w.find_entity(_character_id); C && C->type() == entity_type::character)
+ if (auto C = w.find_object(_character_id); C && C->type() == object_type::character)
return;
_character_id = 0;
@@ -47,10 +47,10 @@ void app::ensure_player_character(world& w)
for (const auto& [coord, c] : w.chunks())
{
- for (const auto& e_ : c.entities())
+ for (const auto& e_ : c.objects())
{
const auto& e = *e_;
- if (e.type() == entity_type::character)
+ if (e.type() == object_type::character)
{
const auto& C = static_cast<const character&>(e);
if (C.playable)
@@ -66,7 +66,7 @@ void app::ensure_player_character(world& w)
character_proto cproto;
cproto.name = "Player"_s;
cproto.playable = true;
- _character_id = w.make_entity<character>(w.make_id(), global_coords{}, cproto)->id;
+ _character_id = w.make_object<character>(w.make_id(), global_coords{}, cproto)->id;
}
}
diff --git a/editor/app.hpp b/editor/app.hpp
index 6002c702..d3a02017 100644
--- a/editor/app.hpp
+++ b/editor/app.hpp
@@ -45,7 +45,7 @@ enum class popup_target_type : unsigned char {
};
struct popup_target final {
- object_id id; // todo switch to weak_ptr<entity>
+ object_id id; // todo switch to weak_ptr<object>
popup_target_type target = popup_target_type::none;
bool operator==(const popup_target&) const;
};
diff --git a/editor/camera.cpp b/editor/camera.cpp
index 77e3a149..48a783cc 100644
--- a/editor/camera.cpp
+++ b/editor/camera.cpp
@@ -113,7 +113,7 @@ object_id app::object_at_cursor()
Vector2 min(rect.m_min[0], rect.m_min[1]), max(rect.m_max[0], rect.m_max[1]);
if (t0 >= min && t0 <= max)
{
- if (auto e_ = world.find_entity(x.data);
+ if (auto e_ = world.find_object(x.data);
e_ && Vector2ui(e_->bbox_size).product() != 0)
{
ret = x.data;
diff --git a/editor/draw.cpp b/editor/draw.cpp
index 0b469380..bd0d863d 100644
--- a/editor/draw.cpp
+++ b/editor/draw.cpp
@@ -60,7 +60,7 @@ void app::draw_cursor()
const auto offset = Vector3i(Vector2i(sel.offset), 0);
const auto pos = cursor.tile->to_signed3()*iTILE_SIZE + offset;
auto [ch, t] = w[*cursor.tile];
- if (!ch.can_place_entity(sel, cursor.tile->local()))
+ if (!ch.can_place_object(sel, cursor.tile->local()))
shader.set_tint({1, 0, 1, 0.5f});
anim_mesh.draw(shader, *sel.atlas, sel.r, sel.frame, Vector3(pos), 1);
}
diff --git a/editor/editor.cpp b/editor/editor.cpp
index a1de4b4f..9d283da0 100644
--- a/editor/editor.cpp
+++ b/editor/editor.cpp
@@ -110,7 +110,7 @@ void editor::on_click_(world& world, global_coords pos, button b)
default: break;
case button::place:
if (const auto& sel = mode->get_selected())
- if (auto [ch, t] = world[pos]; ch.can_place_entity(sel.proto, pos.local()))
+ if (auto [ch, t] = world[pos]; ch.can_place_object(sel.proto, pos.local()))
mode->place_tile(world, pos, sel, *_app);
break;
case button::remove:
diff --git a/editor/imgui.cpp b/editor/imgui.cpp
index 50ce0628..b0ac33fa 100644
--- a/editor/imgui.cpp
+++ b/editor/imgui.cpp
@@ -164,7 +164,7 @@ void app::draw_light_info()
for (const auto& x : M->clickable_scenery())
{
- if (x.e->type() == entity_type::light)
+ if (x.e->type() == object_type::light)
{
const auto dest = Math::Range2D<float>(x.dest);
const auto& e = static_cast<const light&>(*x.e);
@@ -210,12 +210,12 @@ void app::do_lightmap_test()
return;
auto& w = M->world();
- auto e_ = w.find_entity(_tested_light);
+ auto e_ = w.find_object(_tested_light);
if (e_)
{
auto& e = *e_;
- fm_assert(e_->type() == entity_type::light);
+ fm_assert(e_->type() == object_type::light);
auto& shader = M->lightmap_shader();
auto ch = e.coord.chunk();
auto z = e.coord.z();
@@ -244,9 +244,9 @@ void app::do_lightmap_test()
if (auto* chunk = w.at(c))
{
auto offset = Vector2(Vector2i(c.x) - Vector2i(ch));
- for (const auto& e_ : chunk->entities())
+ for (const auto& e_ : chunk->objects())
{
- if (e_->type() == entity_type::light)
+ if (e_->type() == object_type::light)
{
const auto& li = static_cast<const light&>(*e_);
light_s L {
@@ -311,7 +311,7 @@ void app::do_popup_menu()
{
const auto [id, target] = _popup_target;
auto& w = M->world();
- auto e_ = w.find_entity(id);
+ auto e_ = w.find_object(id);
if (target == popup_target_type::none || !e_)
{
@@ -343,7 +343,7 @@ void app::do_popup_menu()
ImGui::MenuItem("Inspect", nullptr, !b_ins, b_ins))
inspectors.push_back(std::exchange(_popup_target, {}));
if (bool b_testing = e.id == _tested_light;
- e.type() == entity_type::light)
+ e.type() == object_type::light)
if (ImGui::MenuItem("Test", nullptr, b_testing))
_tested_light = e.id;
ImGui::SeparatorText("Modify");
@@ -351,7 +351,7 @@ void app::do_popup_menu()
ImGui::MenuItem("Rotate", nullptr, false, next_rot != e.r && e.can_rotate(next_rot)))
e.rotate(i, next_rot);
if (ImGui::MenuItem("Delete", nullptr, false))
- e.chunk().remove_entity(e.index());
+ e.chunk().remove_object(e.index());
}
else
_popup_target = {};
diff --git a/editor/inspect-draw.cpp b/editor/inspect-draw.cpp
index be32edf7..fc5cbaab 100644
--- a/editor/inspect-draw.cpp
+++ b/editor/inspect-draw.cpp
@@ -30,7 +30,7 @@ void app::draw_inspector()
for (auto i = inspectors.size()-1; i != -1uz; i--)
{
auto [id, target] = inspectors[i];
- auto e_ = w.find_entity(id);
+ auto e_ = w.find_object(id);
if (!e_)
{
inspectors.erase(inspectors.begin() + ptrdiff_t(i));
@@ -56,7 +56,7 @@ auto z = e.coord.z();
bool is_open = true;
if (auto b2 = begin_window(buf, &is_open))
{
- bool ret = entities::inspect_entity_subtype(e);
+ bool ret = entities::inspect_object_subtype(e);
(void)ret;
}
if (!is_open)
diff --git a/editor/inspect-types.cpp b/editor/inspect-types.cpp
index e29d5df9..84fbbd5d 100644
--- a/editor/inspect-types.cpp
+++ b/editor/inspect-types.cpp
@@ -16,51 +16,51 @@ namespace floormat::entities {
using st = field_status;
template<>
-struct entity_accessors<entity, inspect_intent_t> {
+struct entity_accessors<object, inspect_intent_t> {
static constexpr auto accessors()
{
- using E = Entity<entity>;
+ using E = Entity<object>;
return std::tuple{
E::type<object_id>::field{"id"_s,
- [](const entity& x) { return x.id; },
- [](entity&, object_id) {},
+ [](const object& x) { return x.id; },
+ [](object&, object_id) {},
constantly(st::readonly),
},
E::type<StringView>::field{"atlas"_s,
- [](const entity& x) { return loader.strip_prefix(x.atlas->name()); },
- [](entity&, StringView) {},
+ [](const object& x) { return loader.strip_prefix(x.atlas->name()); },
+ [](object&, StringView) {},
constantly(st::readonly),
},
E::type<rotation>::field{"rotation"_s,
- [](const entity& x) { return x.r; },
- [](entity& x, rotation r) { x.rotate(x.index(), r); },
+ [](const object& x) { return x.r; },
+ [](object& x, rotation r) { x.rotate(x.index(), r); },
},
E::type<uint16_t>::field{"frame"_s,
- [](const entity& x) { return x.frame; },
- [](entity& x, uint16_t value) { x.frame = value; },
- [](const entity& x) {
+ [](const object& x) { return x.frame; },
+ [](object& x, uint16_t value) { x.frame = value; },
+ [](const object& x) {
return constraints::range<uint16_t>{0, !x.atlas ? uint16_t(0) : uint16_t(x.atlas->info().nframes-1)};
},
},
E::type<Vector2i>::field{"offset"_s,
- [](const entity& x) { return Vector2i(x.offset); },
- //[](entity& x, Vector2i value) { x.set_bbox(value, x.bbox_offset, x.bbox_size, x.pass); },
- [](entity& x, Vector2i value) { x.move_to(value - Vector2i(x.offset)); },
+ [](const object& x) { return Vector2i(x.offset); },
+ //[](object& x, Vector2i value) { x.set_bbox(value, x.bbox_offset, x.bbox_size, x.pass); },
+ [](object& x, Vector2i value) { x.move_to(value - Vector2i(x.offset)); },
//constantly(constraints::range{Vector2b(iTILE_SIZE2/-2), Vector2b(iTILE_SIZE2/2)}),
},
E::type<pass_mode>::field{"pass-mode"_s,
- [](const entity& x) { return x.pass; },
- [](entity& x, pass_mode value) { x.set_bbox(x.offset, x.bbox_offset, x.bbox_size, value); },
+ [](const object& x) { return x.pass; },
+ [](object& x, pass_mode value) { x.set_bbox(x.offset, x.bbox_offset, x.bbox_size, value); },
},
E::type<Vector2b>::field{"bbox-offset"_s,
- [](const entity& x) { return x.bbox_offset; },
- [](entity& x, Vector2b value) { x.set_bbox(x.offset, value, x.bbox_size, x.pass); },
- [](const entity& x) { return x.pass == pass_mode::pass ? st::readonly : st::enabled; },
+ [](const object& x) { return x.bbox_offset; },
+ [](object& x, Vector2b value) { x.set_bbox(x.offset, value, x.bbox_size, x.pass); },
+ [](const object& x) { return x.pass == pass_mode::pass ? st::readonly : st::enabled; },
},
E::type<Vector2ub>::field{"bbox-size"_s,
- [](const entity& x) { return x.bbox_size; },
- [](entity& x, Vector2ub value) { x.set_bbox(x.offset, x.bbox_offset, value, x.pass); },
- [](const entity& x) { return x.pass == pass_mode::pass ? st::readonly : st::enabled; },
+ [](const object& x) { return x.bbox_size; },
+ [](object& x, Vector2ub value) { x.set_bbox(x.offset, x.bbox_offset, value, x.pass); },
+ [](const object& x) { return x.pass == pass_mode::pass ? st::readonly : st::enabled; },
},
};
}
@@ -71,7 +71,7 @@ struct entity_accessors<scenery, inspect_intent_t> {
static constexpr auto accessors()
{
using E = Entity<scenery>;
- auto tuple0 = entity_accessors<entity, inspect_intent_t>::accessors();
+ auto tuple0 = entity_accessors<object, inspect_intent_t>::accessors();
auto tuple = std::tuple{
E::type<bool>::field{"interactive"_s,
[](const scenery& x) { return x.interactive; },
@@ -87,15 +87,15 @@ template<typename T, typename = void> struct has_anim_atlas : std::false_type {}
template<typename T>
requires requires (const T& x) { { x.atlas } -> std::convertible_to<const std::shared_ptr<anim_atlas>&>; }
struct has_anim_atlas<T> : std::true_type {
- static const anim_atlas& get_atlas(const entity& x) { return *x.atlas; }
+ static const anim_atlas& get_atlas(const object& x) { return *x.atlas; }
};
#if 0
-template<> struct has_anim_atlas<entity> : std::true_type {
- static const anim_atlas& get_atlas(const entity& x) { return *x.atlas; }
+template<> struct has_anim_atlas<object> : std::true_type {
+ static const anim_atlas& get_atlas(const object& x) { return *x.atlas; }
};
-template<> struct has_anim_atlas<scenery> : has_anim_atlas<entity> {};
-template<> struct has_anim_atlas<character> : has_anim_atlas<entity> {};
+template<> struct has_anim_atlas<scenery> : has_anim_atlas<object> {};
+template<> struct has_anim_atlas<character> : has_anim_atlas<object> {};
#endif
using enum_pair = std::pair<StringView, size_t>;
@@ -178,7 +178,7 @@ struct entity_accessors<character, inspect_intent_t> {
static constexpr auto accessors()
{
using E = Entity<character>;
- auto tuple0 = entity_accessors<entity, inspect_intent_t>::accessors();
+ auto tuple0 = entity_accessors<object, inspect_intent_t>::accessors();
auto tuple = std::tuple{
E::type<String>::field{"name"_s,
[](const character& x) { return x.name; },
@@ -209,7 +209,7 @@ struct entity_accessors<light, inspect_intent_t>
static constexpr auto accessors()
{
using E = Entity<light>;
- auto tuple0 = entity_accessors<entity, inspect_intent_t>::accessors();
+ auto tuple0 = entity_accessors<object, inspect_intent_t>::accessors();
auto tuple = std::tuple{
E::type<Color4ub>::field{"color"_s,
[](const light& x) { return x.color; },
@@ -233,20 +233,20 @@ struct entity_accessors<light, inspect_intent_t>
}
};
-//template bool inspect_type(entity&);
+//template bool inspect_type(object&);
template bool inspect_type(scenery&, inspect_intent_t);
template bool inspect_type(character&, inspect_intent_t);
template bool inspect_type(light&, inspect_intent_t);
-bool inspect_entity_subtype(entity& x)
+bool inspect_object_subtype(object& x)
{
switch (auto type = x.type())
{
- default: fm_warn_once("unknown entity subtype '%d'", (int)type); return false;
- //case entity_type::none: return inspect_type(x);
- case entity_type::scenery: return inspect_type(static_cast<scenery&>(x), inspect_intent_t{});
- case entity_type::character: return inspect_type(static_cast<character&>(x), inspect_intent_t{});
- case entity_type::light: return inspect_type(static_cast<light&>(x), inspect_intent_t{});
+ default: fm_warn_once("unknown object subtype '%d'", (int)type); return false;
+ //case object_type::none: return inspect_type(x);
+ case object_type::scenery: return inspect_type(static_cast<scenery&>(x), inspect_intent_t{});
+ case object_type::character: return inspect_type(static_cast<character&>(x), inspect_intent_t{});
+ case object_type::light: return inspect_type(static_cast<light&>(x), inspect_intent_t{});
}
}
diff --git a/editor/inspect.hpp b/editor/inspect.hpp
index 5bfb7c1f..df543f96 100644
--- a/editor/inspect.hpp
+++ b/editor/inspect.hpp
@@ -1,6 +1,6 @@
#pragma once
#include <utility>
-namespace floormat { struct entity; }
+namespace floormat { struct object; }
namespace floormat::entities {
struct erased_accessor;
@@ -27,7 +27,7 @@ template<typename T> using field_repr_slider = field_repr_<T, field_repr, field_
template<typename T> using field_repr_drag = field_repr_<T, field_repr, field_repr::drag>;
template<typename T> using field_repr_cbx = field_repr_<T, field_repr, field_repr::cbx>;
-bool inspect_entity_subtype(entity& x);
+bool inspect_object_subtype(object& x);
template<typename T> bool inspect_field(void* datum, const entities::erased_accessor& accessor,
const ArrayView<const std::pair<StringView, size_t>>& list,
diff --git a/editor/scenery-editor.cpp b/editor/scenery-editor.cpp
index 66ff94bb..19a24e99 100644
--- a/editor/scenery-editor.cpp
+++ b/editor/scenery-editor.cpp
@@ -85,14 +85,14 @@ void scenery_editor::place_tile(world& w, global_coords pos, const scenery_& s,
if (!s)
{
auto [c, t] = w[pos];
- const auto& es = c.entities();
+ const auto& es = c.objects();
start: while (auto id = a.object_at_cursor())
{
for (auto i = es.size()-1; i != (size_t)-1; i--)
{
if (es[i]->id == id)
{
- c.remove_entity(i);
+ c.remove_object(i);
goto start;
}
}
@@ -101,7 +101,7 @@ start: while (auto id = a.object_at_cursor())
}
else
// todo check collision at pos
- w.make_entity<scenery>(w.make_id(), pos, s.proto);
+ w.make_object<scenery>(w.make_id(), pos, s.proto);
}
} // namespace floormat
diff --git a/editor/update.cpp b/editor/update.cpp
index ae64a2f3..4dacaf8a 100644
--- a/editor/update.cpp
+++ b/editor/update.cpp
@@ -222,7 +222,7 @@ void app::update_world(float dt)
if (!c_)
continue;
auto& c = *c_;
- const auto& es = c.entities();
+ const auto& es = c.objects();
const auto size = es.size();
for (auto i = size-1; i != (size_t)-1; i--)
es[i]->update(i, dt);
@@ -234,7 +234,7 @@ void app::update_character([[maybe_unused]] float dt)
if (_character_id)
{
auto& w = M->world();
- auto c = w.find_entity<character>(_character_id);
+ auto c = w.find_object<character>(_character_id);
if (c && c->playable)
c->set_keys(keys[key_left], keys[key_right], keys[key_up], keys[key_down]);
}
diff --git a/editor/vobj-editor.cpp b/editor/vobj-editor.cpp
index d242f68f..4d3f3f03 100644
--- a/editor/vobj-editor.cpp
+++ b/editor/vobj-editor.cpp
@@ -45,14 +45,14 @@ void vobj_editor::place_tile(world& w, global_coords pos, const vobj_* x, struct
if (!x)
{
auto [c, t] = w[pos];
- const auto& es = c.entities();
+ const auto& es = c.objects();
start: while (auto id = a.object_at_cursor())
{
for (auto i = es.size()-1; i != (size_t)-1; i--)
{
if (es[i]->id == id)
{
- c.remove_entity(i);
+ c.remove_object(i);
goto start;
}
}
@@ -69,7 +69,7 @@ start: while (auto id = a.object_at_cursor())
struct light_factory final : vobj_factory
{
- entity_type type() const override { return entity_type::light; }
+ object_type type() const override { return object_type::light; }
const vobj_info& info() const override
{
@@ -80,9 +80,9 @@ struct light_factory final : vobj_factory
return ret;
}
- std::shared_ptr<entity> make(world& w, object_id id, global_coords pos) const override
+ std::shared_ptr<object> make(world& w, object_id id, global_coords pos) const override
{
- auto ret = w.make_entity<light>(id, pos, light_proto{});
+ auto ret = w.make_object<light>(id, pos, light_proto{});
return ret;
}
};
diff --git a/editor/vobj-editor.hpp b/editor/vobj-editor.hpp
index 46b5dce1..d8477011 100644
--- a/editor/vobj-editor.hpp
+++ b/editor/vobj-editor.hpp
@@ -1,5 +1,5 @@
#pragma once
-#include "src/entity-type.hpp"
+#include "src/object-type.hpp"
#include "src/object-id.hpp"
#include <memory>
#include <map>
@@ -14,7 +14,7 @@ namespace floormat {
struct world;
struct global_coords;
-struct entity;
+struct object;
struct anim_atlas;
struct vobj_info;
struct app;
@@ -29,8 +29,8 @@ struct vobj_factory
vobj_factory();
virtual ~vobj_factory() noexcept;
virtual const vobj_info& info() const = 0;
- virtual entity_type type() const = 0;
- virtual std::shared_ptr<entity> make(world& w, object_id id, global_coords pos) const = 0;
+ virtual object_type type() const = 0;
+ virtual std::shared_ptr<object> make(world& w, object_id id, global_coords pos) const = 0;
StringView name() const;
StringView descr() const;