Merging with develop

This commit is contained in:
Zoe Roux
2021-06-19 13:43:37 +02:00
32 changed files with 290 additions and 129 deletions
+41 -1
View File
@@ -16,7 +16,9 @@
#include "Component/BombHolder/BombHolderComponent.hpp"
#include "Component/Tag/TagComponent.hpp"
#include "Component/Renderer/Drawable3DComponent.hpp"
#include "Component/Shaders/Items/AlphaCtxShaderComponent.hpp"
#include <Drawables/Image.hpp>
#include "Component/Shaders/ShaderComponent.hpp"
#include "Component/Gravity/GravityComponent.hpp"
#include "Component/BumperTimer/BumperTimerComponent.hpp"
#include "Component/Timer/TimerComponent.hpp"
@@ -67,6 +69,44 @@ namespace BBM
.addComponent<AnimationsComponent>("assets/player/player.iqm", 3)
.addComponent<CollisionComponent>(BBM::Vector3f{0.25, 0, 0.25}, BBM::Vector3f{.75, 2, .75})
.addComponent<MovableComponent>()
.addComponent<AlphaVarShaderComponent>()
.addComponent<ShaderComponentModel>("assets/shaders/alpha.fs", "", [](WAL::Entity &myEntity, WAL::Wal &, std::chrono::nanoseconds dtime) {
auto &ctx = myEntity.getComponent<AlphaVarShaderComponent>();
ctx.clock += dtime;
if (duration_cast<std::chrono::milliseconds>(ctx.clock).count() <= 10)
return;
ctx.clock = 0ns;
auto &bonus = myEntity.getComponent<PlayerBonusComponent>();
auto &shader = myEntity.getComponent<ShaderComponentModel>();
if (!bonus.isNoClipOn) {
ctx.alpha = ctx.maxAlpha;
shader.shader.setShaderUniformVar("alpha", ctx.alpha);
return;
}
auto nbMilliSec = duration_cast<std::chrono::milliseconds>(bonus.nextNoClipRate).count();
if (nbMilliSec > 1500) {
ctx.step = ctx.initalStepValue;
} else if (nbMilliSec > 1000) {
ctx.step = 0.15;
} else if (nbMilliSec > 200) {
ctx.step = 0.30;
} else {
ctx.step = 0.5;
}
ctx.alpha += static_cast<float>(ctx.step * ctx.balance);
if (ctx.alpha <= ctx.minAlpha) {
ctx.balance = 1;
}
if (ctx.alpha >= ctx.maxAlpha) {
ctx.balance = -1;
}
shader.shader.setShaderUniformVar("alpha", ctx.alpha);
}, true)
.addComponent<SoundComponent>(soundPath)
.addComponent<MusicComponent>("assets/musics/music_battle.ogg")
.addComponent<BombHolderComponent>()
@@ -80,7 +120,7 @@ namespace BBM
if (entity.hasComponent<TimerComponent>())
return;
entity.getComponent<ControllableComponent>().disabled = true;
entity.addComponent<TimerComponent>(1s, [](WAL::Entity &ent, WAL::Wal &wal) {
entity.addComponent<TimerComponent>(1s, [](WAL::Entity &ent, WAL::Wal &) {
ent.scheduleDeletion();
});
});