Select Git revision
FixedArray.cpp

BATON Theau authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
FixedArray.cpp 1.59 KiB
#include "FixedArray.hpp"
#include <kernel/front/Kernel.hpp>
namespace megu::kernel {
std::optional<std::reference_wrapper<const TangibleStatic>> FixedArray::at(const Position & position) const {
if(this->_tangibles.contains(position)) {
return this->_tangibles.at(position);
}
return {};
}
void FixedArray::push(const Fixed & tangible) {
this->_tangibles.insert({tangible.getPosition(), tangible});
}
void FixedArray::erase(const Fixed & tangible) {
this->_tangibles.erase(tangible.getPosition());
}
void FixedArray::erase(const Position & position) {
this->_tangibles.erase(position);
}
void FixedArray::on_collide(Kernel & kernel, const PhysicEngine & engine, Physical & physical, double time) {
auto & tangible = engine.get(physical);
for(auto & [position, fixed] : this->_tangibles) {
if(fixed.isColliding(tangible)) {
physical.on_collide(kernel, engine, fixed, time);
}
}
}
void FixedArray::update_physic(double time) const {
if(this->_update != nullptr) {
this->_update(time);
}
}
void FixedArray::apply(Kernel & kernel, PhysicEngine & engine) {
engine.get().push(0, *this);
}
void FixedArray::unapply(Kernel & kernel, PhysicEngine & engine) {
engine.get().remove(*this);
}
void FixedArray::setCollideLambda(CollideLambda lambda) {
this->_collide = lambda;
}
void FixedArray::setUpdateLambda(UpdateLambda lambda) {
this->_update = lambda;
}
}