Commit c0b70eeb authored by Georg Schäfer's avatar Georg Schäfer
Browse files

Merge branch 'develop' into 17-models

parents eb31559d 5694995e
Pipeline #3406 passed with stage
in 6 minutes and 45 seconds
......@@ -2,7 +2,7 @@
"emitters": [{
"spawn": [
{"particles_per_second": 300, "stddev":150, "time": 0.5},
{"particles_per_second": 0, "stddev":0, "time": 999}
{"particles_per_second": 0, "stddev":0, "time": 1}
],
"spawn_loop": false,
......
Subproject commit a75972722af8eef63c531085703c680d535e1a2d
Subproject commit 3e190ffff0e2a684d4ca3f968f2459f225b93b77
......@@ -34,8 +34,8 @@ namespace phase_shifter::gameplay {
void Beat_system::update(mirrage::util::Time dt)
{
_acc += dt.value();
int size = static_cast<int>(_time_stamps.size());
auto beat = _beat_index + 1< size && _acc >= _time_stamps[_beat_index + 1];
int size = static_cast<int>(_time_stamps.size());
auto beat = _beat_index + 1 < size && _acc >= _time_stamps[_beat_index + 1];
int beats_left = _state.beats_left;
if(beat) {
_beat_index++;
......@@ -56,6 +56,9 @@ namespace phase_shifter::gameplay {
auto Beat_system::graphic_time_scale() const -> float
{
if(_beat_index < 0)
return 0.2f;
constexpr auto t1_len = 0.05f;
constexpr auto t2_len = 0.6f;
constexpr auto factor = (1.f - (1.f - t1_len - t2_len) * 0.05f) / (t1_len + t2_len) * 2.f;
......@@ -80,7 +83,8 @@ namespace phase_shifter::gameplay {
}
}
void Beat_system::increase_beats_left(int count) {
void Beat_system::increase_beats_left(int count)
{
_beat_offset += count;
_state.beats_left += count;
}
......
......@@ -4,27 +4,72 @@
#include "../gameplay/player_comp.hpp"
#include "../messages.hpp"
#include <mirrage/ecs/components/transform_comp.hpp>
#include <mirrage/ecs/entity_manager.hpp>
#include <mirrage/ecs/types.hpp>
#include <mirrage/renderer/particle_system.hpp>
namespace phase_shifter::ui {
using namespace mirrage::renderer;
using mirrage::ecs::components::Transform_comp;
using namespace mirrage::util::unit_literals;
namespace {
void disable_tombstone(mirrage::ecs::Entity_facet entity)
{
entity.process([=](Particle_system_comp& particle) {
for(auto& e : particle.particle_system.emitters()) {
e.active(false);
}
});
entity.process(
[=](Transform_comp& transform) { transform.position = glm::vec3(-999.f, 0.f, -999.f); });
}
void enable_tombstone(mirrage::ecs::Entity_facet entity, glm::vec3 pos, glm::vec3 dir)
{
entity.process([=](Particle_system_comp& particle) {
for(auto& e : particle.particle_system.emitters()) {
e.active(true);
}
});
entity.process([=](Transform_comp& transform) {
transform.position = pos;
transform.orientation = glm::rotation(glm::vec3{1.f, 0.f, 0.f}, glm::vec3(dir.x, 0, -dir.z));
});
}
} // namespace
Effect_system::Effect_system(mirrage::util::Message_bus& bus, mirrage::ecs::Entity_manager& ecs)
: _bus(bus), _mailbox(bus), _ecs(ecs)
{
_tombstones.resize(20);
for(auto& t : _tombstones) {
t.entity = _ecs.entity_builder("enemy_tombstone")
.position(glm::vec3{-999.f, 0.f, -999.f})
.post_create([=](mirrage::ecs::Entity_facet entity) {
// disable_tombstone(entity);
})
.create();
};
_mailbox.subscribe_to([&](Enemy_killed_msg& e) {
_bus.send<Play_sound_msg>("enemy_hit"_strid);
auto entity = _ecs.entity_builder("enemy_tombstone")
.rotation(glm::rotation(
glm::vec3{1.f, 0.f, 0.f},
glm::vec3(e.attack_direction.x, 0, -e.attack_direction.z)))
.position(e.position)
.create();
auto first_free =
std::find_if(_tombstones.begin(), _tombstones.end(), [](auto& t) { return t.free; });
if(first_free != _tombstones.end()) {
first_free->free = false;
enable_tombstone(first_free->entity, e.position, e.attack_direction);
_actions.defer(5_s, [&, entity] { _ecs.erase(entity); });
_actions.defer(1_s, [&, iter = &*first_free] {
disable_tombstone(iter->entity);
iter->free = true;
});
}
});
_mailbox.subscribe_to([&](gameplay::Damaged_msg& e) {
......
#pragma once
#include <mirrage/ecs/types.hpp>
#include <mirrage/utils/defer.hpp>
#include <mirrage/utils/messagebus.hpp>
#include <mirrage/utils/units.hpp>
......@@ -17,10 +18,17 @@ namespace phase_shifter::ui {
void update(mirrage::util::Time);
private:
struct Tombstone {
mirrage::ecs::Entity_facet entity;
bool free = true;
};
mirrage::util::Message_bus& _bus;
mirrage::util::Mailbox_collection _mailbox;
mirrage::ecs::Entity_manager& _ecs;
mirrage::util::Deferred_action_container _actions;
std::vector<Tombstone> _tombstones;
};
} // namespace phase_shifter::ui
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