mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2025-07-07 10:06:45 +02:00
port everything over to organizer
This commit is contained in:
@ -2,34 +2,28 @@
|
||||
|
||||
#include <entt/entity/registry.hpp>
|
||||
|
||||
#include <mm/components/velocity2d.hpp>
|
||||
|
||||
#include <mm/services/input_service.hpp>
|
||||
|
||||
#include <tracy/Tracy.hpp>
|
||||
|
||||
namespace MM::Systems {
|
||||
void PlayerVelocity2D(Scene& scene, float) {
|
||||
ZoneScopedN("MM::Systems::PlayerVelocity2D");
|
||||
|
||||
MM::Engine* engine_ptr = scene.ctx<MM::Engine*>();
|
||||
auto& input_ss = engine_ptr->getService<MM::Services::InputService>();
|
||||
void player_velocity2d(entt::view<entt::exclude_t<>, MM::Input::PlayerID, MM::Components::Velocity2D> view, const MM::Engine* engine) {
|
||||
ZoneScopedN("MM::Systems::PlayerVelocity2D");
|
||||
|
||||
scene.view<MM::Input::PlayerID, MM::Components::Velocity2D>().each(
|
||||
[&input_ss](const MM::Input::PlayerID p_id, MM::Components::Velocity2D& v) {
|
||||
//const float movement_speed = 8.f; // apply via post processing
|
||||
auto& input_ss = engine->getService<MM::Services::InputService>();
|
||||
|
||||
auto vec_force = input_ss.getMoveForce(p_id);
|
||||
view.each([&input_ss](const MM::Input::PlayerID p_id, MM::Components::Velocity2D& v) {
|
||||
//const float movement_speed = 8.f; // apply via post processing
|
||||
|
||||
if (vec_force >= 0.01f) {
|
||||
v.velocity = input_ss.getMoveVec(p_id);
|
||||
v.velocity *= vec_force;
|
||||
//v.velocity *= movement_speed;
|
||||
} else {
|
||||
v.velocity = {0.f, 0.f};
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
auto vec_force = input_ss.getMoveForce(p_id);
|
||||
|
||||
if (vec_force >= 0.01f) {
|
||||
v.velocity = input_ss.getMoveVec(p_id);
|
||||
//v.velocity *= vec_force;
|
||||
} else {
|
||||
v.velocity = {0.f, 0.f};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} // MM::Systems
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
//#include <mm/services/scene_service_interface.hpp>
|
||||
#include <mm/engine_fwd.hpp>
|
||||
#include <entt/entity/utility.hpp>
|
||||
#include <mm/services/input_service.hpp>
|
||||
#include <mm/components/velocity2d.hpp>
|
||||
|
||||
namespace MM::Systems {
|
||||
|
||||
// this system transforms the input from the input_ss into velocity
|
||||
// uses Components::Velocity2D, PlayerID
|
||||
void PlayerVelocity2D(Scene& scene, float delta);
|
||||
// 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);
|
||||
|
||||
} // MM::Systems
|
||||
|
||||
|
Reference in New Issue
Block a user