Commit f1002aa7 authored by Florian Oetke's avatar Florian Oetke

basis for highlevel gameplay

parent 9f93e3d8
...@@ -13,5 +13,6 @@ ...@@ -13,5 +13,6 @@
"step_time_percentage": 0.2, "step_time_percentage": 0.2,
"off_beat_threshold": 0.2 "off_beat_threshold": 0.2
}, },
"Input_controller": {} "Input_controller": {},
"Player": {}
} }
...@@ -13,11 +13,12 @@ namespace phase_shifter::gameplay { ...@@ -13,11 +13,12 @@ namespace phase_shifter::gameplay {
_acc += dt.value(); _acc += dt.value();
auto beat = _acc >= beat_time; auto beat = _acc >= beat_time;
if(beat) { if(beat) {
_state.beats_left--;
LOG(plog::debug) << "beat"; LOG(plog::debug) << "beat";
_acc = 0; _acc = 0;
} }
_state = {beat, _acc, beat_time - _acc}; _state = {beat, _acc, beat_time - _acc, beat_time, _state.beats_left};
} }
} // namespace phase_shifter::gameplay } // namespace phase_shifter::gameplay
...@@ -9,6 +9,8 @@ namespace phase_shifter::gameplay { ...@@ -9,6 +9,8 @@ namespace phase_shifter::gameplay {
float time_since_beat = 0.f; float time_since_beat = 0.f;
float time_to_beat = 0.f; float time_to_beat = 0.f;
float avg_beat_time = 1.f; float avg_beat_time = 1.f;
int beats_left = 9999.f;
}; };
// TODO: replace placeholder logic with actual beat detection // TODO: replace placeholder logic with actual beat detection
......
#include "combat_system.hpp"
#include "player_comp.hpp"
namespace phase_shifter::gameplay {
Combat_system::Combat_system(mirrage::util::Message_bus& bus, mirrage::ecs::Entity_manager& ecs)
: _mailbox(bus), _ecs(ecs)
{
_ecs.register_component_type<Player_comp>();
_mailbox.subscribe_to([&](Damaged_msg& e) {
_ecs.get(e.entity).process([&](auto& entity) {
//entity.process<>();
// TODO
});
// TODO
});
}
void Combat_system::update(mirrage::util::Time)
{
_mailbox.update_subscriptions();
// TODO
}
} // namespace phase_shifter::gameplay
#pragma once
#include <mirrage/ecs/entity_handle.hpp>
#include <mirrage/utils/messagebus.hpp>
#include <mirrage/utils/units.hpp>
namespace mirrage::ecs {
class Entity_manager;
}
namespace phase_shifter::gameplay {
struct Damaged_msg {
mirrage::ecs::Entity_handle entity;
};
class Combat_system {
public:
Combat_system(mirrage::util::Message_bus&, mirrage::ecs::Entity_manager&);
void update(mirrage::util::Time);
private:
mirrage::util::Mailbox_collection _mailbox;
mirrage::ecs::Entity_manager& _ecs;
};
} // namespace phase_shifter::gameplay
#include "player_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 Player_comp : public mirrage::ecs::Stateless_tag_component<Player_comp> {
static constexpr const char* name() { return "Player"; }
using Stateless_tag_component::Stateless_tag_component;
};
} // namespace phase_shifter::gameplay
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