Commit b544ba3c authored by Florian Oetke's avatar Florian Oetke
Browse files

fixed gcc/clang compilation errors

parent 306b27cd
Pipeline #3237 failed with stage
in 1 minute and 33 seconds
......@@ -4,23 +4,25 @@
namespace phase_shifter::gameplay {
Camera_system::Camera_system(mirrage::ecs::Entity_manager& entity_manager)
: _entity_manager(entity_manager)
Camera_system::Camera_system(mirrage::ecs::Entity_manager& entity_manager)
: _entity_manager(entity_manager)
{
_entity_manager.register_component_type<Viewtarget_comp>();
_entity_manager.register_component_type<Spring_comp>();
}
void Camera_system::update(mirrage::util::Time dt)
{
for (auto&& [camera, viewtarget, spring] : _entity_manager.list<mirrage::ecs::Entity_facet, Viewtarget_comp, Spring_comp>()) {
auto& target_facet = _entity_manager.get(viewtarget.target);
{
for(auto&& [camera, viewtarget, spring] :
_entity_manager.list<mirrage::ecs::Entity_facet, Viewtarget_comp, Spring_comp>()) {
auto target_facet = _entity_manager.get(viewtarget.target);
if(target_facet.is_some()) {
auto& target_transform = target_facet.get_or_throw().get<mirrage::ecs::components::Transform_comp>();
auto target_transform =
target_facet.get_or_throw().get<mirrage::ecs::components::Transform_comp>();
if(target_transform.is_some()) {
auto& target_position = target_transform.get_or_throw().position;
auto target_position = target_transform.get_or_throw().position;
glm::vec3 offset = viewtarget.offset;
glm::vec3 dest_pos = {target_position.x + offset.x,
target_position.y + offset.y,
......@@ -31,12 +33,12 @@ namespace phase_shifter::gameplay {
camera.process([&](mirrage::ecs::components::Transform_comp& transform) {
glm::vec3 spring_force = spring.spring_constant * (dest_pos - transform.position);
glm::vec3 acceleration = (spring_force + damping_force) / spring.mass;
spring.velocity += dt.value() * acceleration;
transform.position += dt.value() * spring.velocity;
spring.velocity += dt.value() * acceleration;
transform.position += dt.value() * spring.velocity;
transform.direction(-offset);
});
}
}
}
}
}
\ No newline at end of file
} // namespace phase_shifter::gameplay
......@@ -3,8 +3,8 @@
#include "audio/audio_asset.hpp"
#include "game_engine.hpp"
#include "gameplay/beat_system.hpp"
#include "gameplay/movement_system.hpp"
#include "gameplay/camera_system.hpp"
#include "gameplay/movement_system.hpp"
#include "helper/attachment_system.hpp"
#include "input/input_system.hpp"
#include "ui/hud_system.hpp"
......@@ -29,10 +29,10 @@ namespace phase_shifter {
, _model_loading(std::make_unique<renderer::Loading_system>(_entities, engine.assets()))
, _beat_system(std::make_unique<gameplay::Beat_system>())
, _movement_system(std::make_unique<gameplay::Movement_system>(_entities, *_beat_system))
, _camera_system(std::make_unique<gameplay::Camera_system>(_entities))
, _input_system(std::make_unique<input::Input_system>(engine.bus(), _entities))
, _attachment_system(std::make_unique<helper::Attachment_system>(_entities))
, _hud_system(std::make_unique<ui::Hud_system>(engine.gui(), _entities, *_beat_system))
, _camera_system(std::make_unique<gameplay::Camera_system>(_entities))
{
_entities.register_component_type<ecs::components::Transform_comp>();
......@@ -94,7 +94,7 @@ namespace phase_shifter {
mirrage::ecs::Entity_facet player = entities().entity_builder("player").position({0, 1, 0}).create();
auto playerhandle = player.handle();
mirrage::ecs::Entity_facet camera = entities()
entities()
.entity_builder("camera")
.rotation(cam_dir)
.position(glm::rotate(cam_dir, glm::vec3(0, 0, -1)) * 8.f)
......@@ -103,7 +103,8 @@ namespace phase_shifter {
transform.position = transform.direction() * -10.f;
transform.look_at({0, 0, 0});
});
entity.process([=](gameplay::Viewtarget_comp& viewtarget) { viewtarget.target = playerhandle; });
entity.process(
[=](gameplay::Viewtarget_comp& viewtarget) { viewtarget.target = playerhandle; });
})
.create();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment