Commit b9008682 authored by Tim Scheiber's avatar Tim Scheiber
Browse files

Added a continuous path movement behaviour

parent a0b660a5
Pipeline #3254 failed with stage
in 6 minutes and 51 seconds
{
"Transform": {
"scale": {
"x": 0.3,
"y": 0.3,
"z": 0.3
}
},
"Model": {
"aid": "model:cube"
},
"Shadowcaster": {
},
"Movement": {
"beats_per_step": 1,
"distance_per_step": 1,
"step_time_percentage": 0.2,
"off_beat_threshold": 0.2
},
"ContinuousPath": {
"direction": 270,
"curvature": 0,
}
}
#include "continuous_path_comp.hpp"
namespace phase_shifter::gameplay {
float Continuous_path_comp::next_direction() {
float dir = direction;
direction += curvature;
return dir;
}
}
\ No newline at end of file
#pragma once
#include <mirrage/ecs/ecs.hpp>
namespace phase_shifter::gameplay {
struct Continuous_path_comp : public mirrage::ecs::Component<Continuous_path_comp> {
static constexpr const char* name() { return "ContinuousPath"; }
using Component::Component;
float next_direction();
float direction = 0; // angle of direction with 0 beeing North (-Z)
float curvature = 0; // angle of curvature in degrees
};
sf2_structDef(Continuous_path_comp, direction, curvature);
} // namespace phase_shifter::gameplay
\ No newline at end of file
......@@ -9,6 +9,7 @@ namespace phase_shifter::gameplay {
{
_entity_manager.register_component_type<Fixed_path_comp>();
_entity_manager.register_component_type<Follow_target_comp>();
_entity_manager.register_component_type<Continuous_path_comp>();
}
void Enemy_system::update(mirrage::util::Time dt)
......@@ -38,5 +39,14 @@ namespace phase_shifter::gameplay {
}
}
}
for(auto&& [movement, cont_path] : _entity_manager.list<Movement_comp, Continuous_path_comp>()) {
if(!movement.move) {
float rad_direction = cont_path.next_direction() * mirrage::util::PI / 180.f;
movement.aim.x = std::sin(rad_direction);
movement.aim.y = -std::cos(rad_direction);
movement.move = true;
}
}
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@
#include "fixed_path_comp.hpp"
#include "follow_target_comp.hpp"
#include "continuous_path_comp.hpp"
namespace phase_shifter::gameplay {
......
......@@ -139,6 +139,11 @@ namespace phase_shifter {
entity.process([=](gameplay::Follow_target_comp& target) { target.target = playerhandle; });
})
.create();
entities()
.entity_builder("bullet")
.position({8, 0, 3})
.create();
}
Meta_system::~Meta_system()
......
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