Commit ac4d5d15 authored by Florian Oetke's avatar Florian Oetke

basis for particle/ui/sound effects

parent b25a522a
Pipeline #3303 passed with stage
in 8 minutes and 16 seconds
......@@ -17,6 +17,7 @@
"step_time_percentage": 0.2,
"off_beat_threshold": 0.0
},
"Fragile": {},
"ContinuousPath": {
"direction": 270,
"curvature": 0
......
......@@ -13,9 +13,9 @@
"Movement": {
"beats_per_step": 1,
"distance_per_step": 5,
"step_time_percentage": 0.3,
"step_time_percentage": 0.5,
"off_beat_threshold": 0.2,
"overshoot": 4
"overshoot": 3
},
"Input_controller": {},
"Player": {},
......
#include "combat_system.hpp"
#include "fragile_comp.hpp"
#include "goal_comp.hpp"
#include "player_comp.hpp"
......@@ -24,12 +25,20 @@ namespace phase_shifter::gameplay {
{
_ecs.register_component_type<Player_comp>();
_ecs.register_component_type<Goal_comp>();
_ecs.register_component_type<Fragile_comp>();
_mailbox.subscribe_to([&](Damaged_msg& e) {
_ecs.get(e.entity).process([&](auto& entity) {
entity.process([&](Player_comp&) { _beat_system.decrease_beats_left(damage_beat_penalty); });
});
});
_mailbox.subscribe_to([&](Entity_hit_wall_msg& e) {
_ecs.get(e.entity).process([&](mirrage::ecs::Entity_facet entity) {
if(entity.has<Fragile_comp>())
_ecs.erase(entity);
});
});
}
void Combat_system::update(mirrage::util::Time)
......
......@@ -3,6 +3,8 @@
#include "killable_comp.hpp"
#include "movement_comp.hpp"
#include "../messages.hpp"
#include <mirrage/ecs/components/transform_comp.hpp>
#include <mirrage/ecs/ecs.hpp>
#include <mirrage/ecs/entity_set_view.hpp>
......@@ -48,7 +50,8 @@ namespace phase_shifter::gameplay {
using mirrage::ecs::Entity_handle;
using mirrage::ecs::components::Transform_comp;
Dash_system::Dash_system(mirrage::ecs::Entity_manager& ecs) : _ecs(ecs)
Dash_system::Dash_system(mirrage::util::Message_bus& bus, mirrage::ecs::Entity_manager& ecs)
: _bus(bus), _ecs(ecs)
{
_ecs.register_component_type<Dash_comp>();
_ecs.register_component_type<Killable_comp>();
......@@ -75,6 +78,8 @@ namespace phase_shifter::gameplay {
_ecs.list<Entity_handle, Transform_comp, Killable_comp>()) {
auto circle = rotate_point({k_transform.position.x, k_transform.position.z}, angle);
if(rect_circle_intersects(topleft.x, topleft.y, width, height, circle.x, circle.y, 1)) {
_bus.send<Enemy_killed_msg>(k_transform.position,
k_transform.position - transform.position);
_ecs.erase(entity);
}
}
......
#pragma once
#include <mirrage/utils/messagebus.hpp>
#include <mirrage/utils/units.hpp>
namespace mirrage::ecs {
......@@ -10,14 +11,15 @@ namespace phase_shifter::gameplay {
class Dash_system {
public:
Dash_system(mirrage::ecs::Entity_manager&);
Dash_system(mirrage::util::Message_bus&, mirrage::ecs::Entity_manager&);
void update(mirrage::util::Time);
private:
mirrage::util::Message_bus& _bus;
mirrage::ecs::Entity_manager& _ecs;
bool _was_move = false;
glm::vec2 _start_position;
};
}
\ No newline at end of file
} // namespace phase_shifter::gameplay
#include "fragile_comp.hpp"
#pragma once
#include <mirrage/ecs/ecs.hpp>
#include <mirrage/utils/sf2_glm.hpp>
#include <mirrage/utils/units.hpp>
namespace phase_shifter::gameplay {
struct Fragile_comp : public mirrage::ecs::Stateless_tag_component<Fragile_comp> {
static constexpr const char* name() { return "Fragile"; }
using Stateless_tag_component::Stateless_tag_component;
};
} // namespace phase_shifter::gameplay
......@@ -92,10 +92,10 @@ namespace phase_shifter::gameplay {
_level_system.check_contacts(pos + offset, body.radius, [&](util::Contact contact) {
if(contact.distance2 <= 0.0001f) {
offset = glm::vec2(0, 0);
_bus.send<Entity_hit_wall>(entity_handle);
_bus.send<Entity_hit_wall_msg>(entity_handle);
} else if(auto normal_vel = glm::dot(offset, contact.normal); normal_vel > 0) {
offset -= normal_vel * contact.normal;
_bus.send<Entity_hit_wall>(entity_handle);
_bus.send<Entity_hit_wall_msg>(entity_handle);
}
});
});
......
......@@ -2,6 +2,9 @@
#include <mirrage/ecs/types.hpp>
#include <glm/vec3.hpp>
namespace phase_shifter {
struct Win_msg {
......@@ -9,8 +12,12 @@ namespace phase_shifter {
struct Lose_msg {
};
struct Entity_hit_wall {
struct Entity_hit_wall_msg {
mirrage::ecs::Entity_handle entity;
};
struct Enemy_killed_msg {
glm::vec3 position;
glm::vec3 attack_direction;
};
} // namespace phase_shifter
......@@ -12,6 +12,7 @@
#include "helper/attachment_system.hpp"
#include "input/input_system.hpp"
#include "level/level_system.hpp"
#include "ui/effect_system.hpp"
#include "ui/hud_system.hpp"
#include <context.hpp>
......@@ -42,7 +43,8 @@ namespace phase_shifter {
, _hud_system(std::make_unique<ui::Hud_system>(engine.gui(), _entities, *_beat_system))
, _camera_system(std::make_unique<gameplay::Camera_system>(_entities))
, _enemy_system(std::make_unique<gameplay::Enemy_system>(_entities))
, _dash_system(std::make_unique<gameplay::Dash_system>(_entities))
, _dash_system(std::make_unique<gameplay::Dash_system>(engine.bus(), _entities))
, _effect_system(std::make_unique<ui::Effect_system>(engine.bus(), _entities))
{
_entities.register_component_type<ecs::components::Transform_comp>();
......@@ -109,6 +111,7 @@ namespace phase_shifter {
_attachment_system->update(dt);
_effect_system->update(dt);
_hud_system->update(dt);
_model_loading->update(dt);
......
......@@ -34,8 +34,9 @@ namespace phase_shifter {
class Input_system;
}
namespace ui {
class Effect_system;
class Hud_system;
}
} // namespace ui
namespace level {
class Level_system;
}
......@@ -73,7 +74,7 @@ namespace phase_shifter {
std::unique_ptr<gameplay::Camera_system> _camera_system;
std::unique_ptr<gameplay::Enemy_system> _enemy_system;
std::unique_ptr<gameplay::Dash_system> _dash_system;
// TODO: add systems here
std::unique_ptr<ui::Effect_system> _effect_system;
mirrage::util::Console_command_container _commands;
};
......
#include "effect_system.hpp"
#include "../messages.hpp"
namespace phase_shifter::ui {
Effect_system::Effect_system(mirrage::util::Message_bus& bus, mirrage::ecs::Entity_manager& ecs)
: _bus(bus), _mailbox(bus), _ecs(ecs)
{
_mailbox.subscribe_to([&](Enemy_killed_msg& e) {
// TODO
});
_mailbox.subscribe_to([&](Win_msg& e) {
// TODO
});
_mailbox.subscribe_to([&](Lose_msg& e) {
// TODO
});
}
void Effect_system::update(mirrage::util::Time) { _mailbox.update_subscriptions(); }
} // namespace phase_shifter::ui
#pragma once
#include <mirrage/utils/messagebus.hpp>
#include <mirrage/utils/units.hpp>
#include <vector>
namespace mirrage::ecs {
class Entity_manager;
}
namespace phase_shifter::ui {
class Effect_system {
public:
Effect_system(mirrage::util::Message_bus&, mirrage::ecs::Entity_manager&);
void update(mirrage::util::Time);
private:
mirrage::util::Message_bus& _bus;
mirrage::util::Mailbox_collection _mailbox;
mirrage::ecs::Entity_manager& _ecs;
};
} // 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