mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2024-12-04 19:23:28 +01:00
update to entt v3.9.0
This commit is contained in:
parent
494912ce8a
commit
81043264d2
2
external/entt
vendored
2
external/entt
vendored
@ -1 +1 @@
|
||||
Subproject commit dd6863f71da1b360ec09c25912617a3423f08149
|
||||
Subproject commit 8e0747fd505beb6861939a141ec0962c376d36f2
|
@ -129,11 +129,19 @@ public:
|
||||
if (registry.valid(e)) {
|
||||
ImGui::SameLine();
|
||||
|
||||
// clone would go here
|
||||
//if (ImGui::Button("Clone")) {
|
||||
//auto old_e = e;
|
||||
//e = registry.create();
|
||||
//}
|
||||
if (ImGui::Button("Clone")) {
|
||||
auto old_e = e;
|
||||
e = registry.create();
|
||||
|
||||
// create a copy of an entity component by component
|
||||
for (auto &&curr: registry.storage()) {
|
||||
if (auto &storage = curr.second; storage.contains(old_e)) {
|
||||
// TODO: do something with the return value. returns false on failure.
|
||||
storage.emplace(e, storage.get(old_e));
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::Dummy({10, 0}); // space destroy a bit, to not accidentally click it
|
||||
ImGui::SameLine();
|
||||
@ -229,8 +237,10 @@ public:
|
||||
|
||||
if (comp_list.empty()) {
|
||||
ImGui::Text("Orphans:");
|
||||
registry.orphans([®istry](auto e){
|
||||
MM_IEEE_ENTITY_WIDGET(e, registry, false);
|
||||
registry.each([®istry](auto e){
|
||||
if (registry.orphan(e)) {
|
||||
MM_IEEE_ENTITY_WIDGET(e, registry, false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
auto view = registry.runtime_view(comp_list.begin(), comp_list.end());
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "entity.hpp"
|
||||
#include "./entity.hpp"
|
||||
|
||||
#include <mm/imgui/imgui_entt_entity_editor.hpp>
|
||||
|
||||
@ -15,9 +15,9 @@ void Entity(MM::Entity& e, MM::Scene& ecs, bool dropTarget) {
|
||||
|
||||
if (ecs.valid(e)) {
|
||||
if (ecs.all_of<MM::Components::Name>(e)) {
|
||||
ImGui::Text(ICON_II_CUBE "E: %d v%d (%s)", entt::to_integral(ecs.entity(e)), ecs.version(e), ecs.get<MM::Components::Name>(e).str.c_str());
|
||||
ImGui::Text(ICON_II_CUBE "E: %d v%d (%s)", entt::to_entity(e), entt::to_version(e), ecs.get<MM::Components::Name>(e).str.c_str());
|
||||
} else {
|
||||
ImGui::Text(ICON_II_CUBE "E: %d v%d", entt::to_integral(ecs.entity(e)), ecs.version(e));
|
||||
ImGui::Text(ICON_II_CUBE "E: %d v%d", entt::to_entity(e), entt::to_version(e));
|
||||
}
|
||||
} else {
|
||||
ImGui::Text(ICON_II_CUBE "E: invalid");
|
||||
@ -26,7 +26,7 @@ void Entity(MM::Entity& e, MM::Scene& ecs, bool dropTarget) {
|
||||
if (ecs.valid(e)) {
|
||||
if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_SourceAllowNullID)) {
|
||||
ImGui::SetDragDropPayload(MM_IEEE_IMGUI_PAYLOAD_TYPE_ENTITY, &e, sizeof(e));
|
||||
ImGui::Text(ICON_II_CUBE "E: %d v%d", entt::to_integral(ecs.entity(e)), ecs.version(e));
|
||||
ImGui::Text(ICON_II_CUBE "E: %d v%d", entt::to_entity(e), entt::to_version(e));
|
||||
ImGui::EndDragDropSource();
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +112,11 @@ namespace MM::Services {
|
||||
ImGui::Text("size: %lu", scene.size());
|
||||
ImGui::Text("alive: %lu", scene.alive());
|
||||
size_t orphans = 0;
|
||||
scene.orphans([&](auto) { orphans++; });
|
||||
scene.each([&orphans, &scene](auto entity) {
|
||||
if (scene.orphan(entity)) {
|
||||
orphans++;
|
||||
}
|
||||
});
|
||||
ImGui::Text("orphans: %lu", orphans);
|
||||
}
|
||||
ImGui::End();
|
||||
|
@ -28,7 +28,7 @@ using namespace entt::literals;
|
||||
|
||||
const char* argv0;
|
||||
|
||||
void update_spritesheet_animation(entt::view<entt::exclude_t<>, MM::OpenGL::SpriteSheetRenderable> view, float& accu, const MM::Components::TimeDelta& td) {
|
||||
void update_spritesheet_animation(entt::view<entt::get_t<MM::OpenGL::SpriteSheetRenderable>> view, float& accu, const MM::Components::TimeDelta& td) {
|
||||
accu += td.tickDelta;
|
||||
|
||||
if (accu >= 1.f/10) {
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
using namespace entt::literals;
|
||||
|
||||
void update_spritesheet_animation(entt::view<entt::exclude_t<>, MM::OpenGL::SpriteSheetRenderable> view, float& accu, const MM::Components::TimeDelta& td) {
|
||||
void update_spritesheet_animation(entt::view<entt::get_t<MM::OpenGL::SpriteSheetRenderable>> view, float& accu, const MM::Components::TimeDelta& td) {
|
||||
accu += td.tickDelta;
|
||||
|
||||
if (accu >= 1.f/10) {
|
||||
|
@ -51,7 +51,7 @@ namespace Systems {
|
||||
}
|
||||
|
||||
// elastic scale easing
|
||||
void elasic_scale_easing(entt::view<entt::exclude_t<>, MM::Components::Transform2D, Components::easing> view, const MM::Components::TimeDelta& td) {
|
||||
void elasic_scale_easing(entt::view<entt::get_t<MM::Components::Transform2D, Components::easing>> view, const MM::Components::TimeDelta& td) {
|
||||
view.each([&td](auto& t, auto& easing_comp) {
|
||||
easing_comp.accumulator += td.tickDelta;
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
namespace MM::Systems {
|
||||
|
||||
void player_velocity2d(entt::view<entt::exclude_t<>, MM::Input::PlayerID, MM::Components::Velocity2D> view, const MM::Engine* engine) {
|
||||
void player_velocity2d(entt::view<entt::get_t<MM::Input::PlayerID, MM::Components::Velocity2D>> view, const MM::Engine* engine) {
|
||||
ZoneScopedN("MM::Systems::PlayerVelocity2D");
|
||||
|
||||
auto& input_ss = engine->getService<MM::Services::InputService>();
|
||||
|
@ -8,7 +8,7 @@
|
||||
namespace MM::Systems {
|
||||
|
||||
// this system transforms the input from the input_service into velocity
|
||||
void player_velocity2d(entt::view<entt::exclude_t<>, MM::Input::PlayerID, MM::Components::Velocity2D> view, const MM::Engine* engine);
|
||||
void player_velocity2d(entt::view<entt::get_t<MM::Input::PlayerID, MM::Components::Velocity2D>> view, const MM::Engine* engine);
|
||||
|
||||
} // MM::Systems
|
||||
|
||||
|
@ -1,15 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(simple_velocity_system CXX)
|
||||
|
||||
set(HPP_FILES
|
||||
add_library(simple_velocity_system
|
||||
src/mm/systems/simple_velocity_system2d.hpp
|
||||
src/mm/systems/simple_velocity_system2d.cpp
|
||||
)
|
||||
|
||||
set(CPP_FILES
|
||||
)
|
||||
|
||||
add_library(simple_velocity_system ${CPP_FILES} ${HPP_FILES})
|
||||
|
||||
target_include_directories(simple_velocity_system PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||
|
||||
target_link_libraries(simple_velocity_system
|
||||
|
@ -0,0 +1,22 @@
|
||||
#include "./simple_velocity_system2d.hpp"
|
||||
|
||||
#include <entt/entity/registry.hpp>
|
||||
|
||||
namespace MM::Systems {
|
||||
|
||||
void simple_velocity(
|
||||
entt::view<entt::get_t<
|
||||
Components::Transform2D,
|
||||
const Components::Velocity2D
|
||||
>> view,
|
||||
const Components::TimeDelta& td
|
||||
) {
|
||||
view.each([delta = td.tickDelta](auto, auto& t, auto& v) {
|
||||
t.position += v.velocity * delta;
|
||||
t.rotation += v.rotation * delta;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
} // MM::Systems
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <mm/components/velocity2d.hpp>
|
||||
#include <mm/components/transform2d.hpp>
|
||||
#include <mm/components/time_delta.hpp>
|
||||
@ -9,12 +7,14 @@
|
||||
#include <mm/services/scene_service_interface.hpp>
|
||||
|
||||
namespace MM::Systems {
|
||||
inline void simple_velocity(entt::view<entt::exclude_t<>, Components::Transform2D, const Components::Velocity2D> view, const Components::TimeDelta& td) {
|
||||
view.each([delta = td.tickDelta](auto, auto& t, auto& v) {
|
||||
t.position += v.velocity * delta;
|
||||
t.rotation += v.rotation * delta;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void simple_velocity(
|
||||
entt::view<entt::get_t<
|
||||
Components::Transform2D,
|
||||
const Components::Velocity2D
|
||||
>> view,
|
||||
const Components::TimeDelta& td
|
||||
);
|
||||
|
||||
} // MM::Systems
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user