mirror of
https://github.com/zoriya/Bomberman.git
synced 2025-12-21 05:45:10 +00:00
Moving components and systems out of the ecs
This commit is contained in:
28
sources/System/Movable/MovableSystem.cpp
Normal file
28
sources/System/Movable/MovableSystem.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Created by Zoe Roux on 5/17/21.
|
||||
//
|
||||
|
||||
#include "Component/Position/PositionComponent.hpp"
|
||||
#include "MovableSystem.hpp"
|
||||
#include "Component/Movable/MovableComponent.hpp"
|
||||
#include "Wal.hpp"
|
||||
|
||||
namespace Bomberman
|
||||
{
|
||||
MovableSystem::MovableSystem()
|
||||
: System({
|
||||
typeid(MovableComponent),
|
||||
typeid(PositionComponent)
|
||||
})
|
||||
{}
|
||||
|
||||
void MovableSystem::onFixedUpdate(WAL::Entity &entity)
|
||||
{
|
||||
auto &movable = entity.getComponent<MovableComponent>();
|
||||
auto &position = entity.getComponent<PositionComponent>();
|
||||
|
||||
position.position += movable._velocity * WAL::Wal::timestep.count();
|
||||
movable._velocity = movable._acceleration * WAL::Wal::timestep.count();
|
||||
movable._acceleration = Vector3f();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user