14 void Movement::init(bl::engine::Engine&) {
15 jumpSound = bl::audio::AudioSystem::getOrLoadSound(
21 bl::tmap::Position* pos = owner.
engine().ecs().getComponent<bl::tmap::Position>(e);
22 if (!pos)
return false;
30 bl::tmap::Position& pos = mv->position;
33 if (npos.position == pos.position) {
35 pos.direction = npos.direction;
36 bl::event::Dispatcher::dispatch<event::EntityRotated>(event);
45 bl::audio::AudioSystem::playOrRestartSound(jumpSound);
50 mv->
move(dir, fast, isHop);
51 bl::event::Dispatcher::dispatch<event::EntityMoved>({e, npos, pos, fast});
58 void Movement::update(std::mutex&,
float dt,
float,
float,
float) {
59 bl::engine::Engine& engine = owner.
engine();
Core classes and functionality for both the editor and game.
Adding this component to an entity will allow it to move.
bool moving() const
Returns whether or not the entity is moving.
void update(bl::ecs::Entity owner, system::Systems &systems, float dt)
Updates the interpolation of the entity if moving.
void move(bl::tmap::Direction dir, bool fast, bool isLedgeHop)
Starts the entity moving in the given direction. Only updates the interpolated position,...
Fired when an entity rotates without moving.
bl::tmap::Position adjacentTile(const bl::tmap::Position &pos, bl::tmap::Direction dir) const
Returns the adjacent position to the given position when moving in the given direction....
bool isLedgeHop(const bl::tmap::Position &position, bl::tmap::Direction dir) const
Test whether the given movement will be a ledge hop or not.
bool contains(const bl::tmap::Position &position) const
Returns whether or not the map contains the given position.
bool movePossible(const bl::tmap::Position &position, bl::tmap::Direction dir) const
Returns whether or not a particular movement is possible. Does not take into account entities blockin...
static const std::string & SoundPath()
Movement(Systems &owner)
Create the movement system.
bool moveEntity(bl::ecs::Entity entity, bl::tmap::Direction direction, bool fast)
Moves an entity in the given direction using either its fast or slow speed.
bool makeMovable(bl::ecs::Entity entity, float moveSpeed, float fastMoveSpeed)
Adds a Movable component to the given entity if it does not already exist.
bool spaceFree(const bl::tmap::Position &position) const
Returns whether or not a tile is currently occupied.
Owns all primary systems and a reference to the engine.
const bl::engine::Engine & engine() const
Const accessor for the Engine.
Position & position()
Returns a reference to the position system.
World & world()
Modifiable accessor for the world system.
map::Map & activeMap()
Returns a reference to the active map.