Merge branch 'fix_camera' of github.com:AnonymusRaccoon/Bomberman into fix_camera

This commit is contained in:
Zoe Roux
2021-06-20 11:50:09 +02:00
4 changed files with 48 additions and 15 deletions
@@ -22,8 +22,6 @@ namespace BBM
bool _animDisabled;
public:
//! @brief Should the next update call be skipped?
bool skipNext = false;
//! @inherit
WAL::Component *clone(WAL::Entity &entity) const override;
+16 -3
View File
@@ -87,6 +87,7 @@ namespace BBM {
auto *bombHolder = entity.tryGetComponent<BombHolderComponent>();
auto *model = entity.tryGetComponent<Drawable3DComponent>();
auto *speed = entity.tryGetComponent<SpeedComponent>();
auto *controllable = entity.tryGetComponent<ControllableComponent>();
auto name = entity.getName();
if (!position || !bombHolder || !model || !speed)
@@ -97,6 +98,7 @@ namespace BBM {
_player << "max_bomb: " << std::to_string(bombHolder->maxBombCount) << std::endl << " ";
_player << "explosion_radius: " << std::to_string(bombHolder->explosionRadius) << std::endl << " ";
_player << "speed: " << std::to_string(speed->speed) << std::endl << " ";
_player << "ia: " << (controllable->layout == ControllableComponent::AI ? "true" : "false") << std::endl << " ";
_player << "position: [" << std::to_string(position->getX()) << "," << std::to_string(position->getY()) << "," << std::to_string(position->getZ()) << "]";
}
@@ -177,8 +179,8 @@ namespace BBM {
});
if ((tmpAssets.find("red.png") == std::string::npos && tmpAssets.find("blue.png") == std::string::npos &&
tmpAssets.find("green.png") == std::string::npos && tmpAssets.find("yellow.png") == std::string::npos &&
tmpAssets.find("ai.png") == std::string::npos) || !std::filesystem::exists(tmpAssets)) {
tmpAssets.find("green.png") == std::string::npos && tmpAssets.find("yellow.png") == std::string::npos)
|| !std::filesystem::exists(tmpAssets)) {
throw (ParserError("One asset is invalid."));
}
auto start = tmpAssets.find_last_of('/') + 1;
@@ -194,7 +196,18 @@ namespace BBM {
auto &ready = resumeScene->addEntity("ready")
.addComponent<PositionComponent>(224 * (countPlayer + 1) + 200 * countPlayer, 1080 / 3, 0)
.addComponent<Drawable2DComponent, RAY::Texture>();
playerLogo.addComponent<ResumeLobbyComponent>(countPlayer, ready, playerTile, colors.at(colorStr));
auto *lobby = playerLogo.addComponent<ResumeLobbyComponent>(countPlayer, ready, playerTile, colors.at(colorStr)).tryGetComponent<ResumeLobbyComponent>();
std::string iaPropertyValue = node.getProperty("ia");
if (iaPropertyValue != "false" && iaPropertyValue != "true") {
throw ParserError("Invalid value for ia property");
}
if (node.getProperty("ia") == "true") {
auto *texture = dynamic_cast<RAY::Texture *>(ready.getComponent<Drawable2DComponent>().drawable.get());
lobby->ready = true;
lobby->layout = ControllableComponent::AI;
if (texture)
texture->use("assets/player/icons/ai.png");
}
}
void ParserYAML::_loadPlayers(std::shared_ptr<WAL::Scene> scene, Node &node)
+20 -9
View File
@@ -5,6 +5,8 @@
#include "AnimationsSystem.hpp"
#include "Component/Animation/AnimationsComponent.hpp"
#include "Model/Model.hpp"
#include "Component/Tag/TagComponent.hpp"
#include "Component/Position/PositionComponent.hpp"
#include "Component/Renderer/Drawable3DComponent.hpp"
namespace BBM
@@ -14,20 +16,29 @@ namespace BBM
: System(wal)
{}
void AnimationsSystem::onFixedUpdate(WAL::ViewEntity<Drawable3DComponent, AnimationsComponent> &entity)
void AnimationsSystem::onUpdate(WAL::ViewEntity<Drawable3DComponent, AnimationsComponent> &entity, std::chrono::nanoseconds)
{
auto &model = entity.get<Drawable3DComponent>();
auto &anim = entity.get<AnimationsComponent>();
if (anim.isAnimDisabled())
return;
auto modelPtr = std::dynamic_pointer_cast<RAY::Drawables::Drawables3D::Model>(model.drawable);
if (modelPtr) {
modelPtr->setAnimation(anim.getCurrentModelAnim());
anim.incCurrentAnimFrameCounter();
anim.incCurrentAnimFrameCounter();
anim.incCurrentAnimFrameCounter();
anim.incCurrentAnimFrameCounter();
anim.incCurrentAnimFrameCounter();
anim.incCurrentAnimFrameCounter();
if (this->animsToSkip <= 0) {
auto &model = entity.get<Drawable3DComponent>();
auto modelPtr = std::dynamic_pointer_cast<RAY::Drawables::Drawables3D::Model>(model.drawable);
if (modelPtr) {
modelPtr->setAnimation(anim.getCurrentModelAnim());
}
}
}
void AnimationsSystem::onSelfUpdate(std::chrono::nanoseconds)
{
this->maxAnimsToSkip = this->_wal.getScene()->view<AnimationsComponent, TagComponent<Player>, PositionComponent>().size() - 1;
if (this->animsToSkip <= 0) {
this->animsToSkip = this->maxAnimsToSkip + 1;
}
this->animsToSkip--;
}
}
+12 -1
View File
@@ -12,9 +12,20 @@ namespace BBM
{
class AnimationsSystem : public WAL::System<Drawable3DComponent, AnimationsComponent>
{
private:
//! @brief used to reset animsToskip
long maxAnimsToSkip = 4;
//! @brief Should the next update call be skipped?
long animsToSkip = maxAnimsToSkip;
public:
//! @inherit
void onFixedUpdate(WAL::ViewEntity<Drawable3DComponent, AnimationsComponent> &entity) override;
void onUpdate(WAL::ViewEntity<Drawable3DComponent, AnimationsComponent> &entity, std::chrono::nanoseconds dtime) override;
//! @inherit
void onSelfUpdate(std::chrono::nanoseconds dtime) override;
//! @brief A default constructor
explicit AnimationsSystem(WAL::Wal &wal);