16 pplmn::Move::opponentAnimationForeground(mid);
21 pplmn::Move::opponentAnimationBackground(mid);
34 for (
int i = 0; i < 4; ++i) {
37 playerAnims[i].init(engine, scene, User::Player, mid);
41 for (
int i = 0; i < 4; ++i) {
44 opponentAnims[i].init(engine, scene, User::Opponent, mid);
51 auto& toSearch = user == User::Player ? playerAnims : opponentAnims;
52 for (
unsigned int i = 0; i < 4; ++i) {
53 if (toSearch[i].move == move && toSearch[i].valid) {
54 playing = &toSearch[i];
59 if (extraMove.init(engine, scene, user, move)) { playing = &extraMove; }
61 BL_LOG_ERROR <<
"Missing animation for move " << move;
73 if (playing->background.getPlayer().playing()) { playing->background.draw(ctx); }
79 if (playing->foreground.getPlayer().playing()) { playing->foreground.draw(ctx); }
83 MoveAnimation::Anim::Anim()
84 : move(pplmn::
MoveId::Unknown)
87 bool MoveAnimation::Anim::init(bl::engine::Engine& engine, bl::rc::scene::CodeScene* scene,
91 auto bgSrc = AnimationManager::load(getMoveBackground(user, mid));
92 auto fgSrc = AnimationManager::load(getMoveForeground(user, mid));
93 if (bgSrc->frameCount() == 0 || fgSrc->frameCount() == 0) {
98 background.createWithUniquePlayer(engine, bgSrc);
99 foreground.createWithUniquePlayer(engine, fgSrc);
100 background.addToScene(scene, bl::rc::UpdateSpeed::Static);
101 foreground.addToScene(scene, bl::rc::UpdateSpeed::Static);
107 void MoveAnimation::Anim::play() {
109 background.getPlayer().play(
true);
110 foreground.getPlayer().play(
true);
114 bool MoveAnimation::Anim::finished()
const {
115 return !valid || (!background.getPlayer().playing() && !foreground.getPlayer().playing());
Core classes and functionality for both the editor and game.
void renderBackground(bl::rc::scene::CodeScene::RenderContext &ctx)
Renders the move animation background.
void ensureLoaded(const pplmn::BattlePeoplemon &player, const pplmn::BattlePeoplemon &opponent)
Loads the move animations into the resource manager for the given peoplemon.
MoveAnimation(bl::engine::Engine &engine)
Construct a new Move Animation helper.
void playAnimation(User user, pplmn::MoveId move)
Begins playing the given move animation.
bool completed() const
Returns whether or not the animation has completed playing.
void init(bl::rc::scene::CodeScene *scene)
Initializes the animations.
User
Which peoplemon is using the move.
void renderForeground(bl::rc::scene::CodeScene::RenderContext &ctx)
Renders the move animation foreground.
Represents a Peoplemon in battle. Stores some extra state that only exists in battle....
OwnedPeoplemon & base()
Returns the wrapped peoplemon.
static std::string playerAnimationBackground(MoveId move)
Returns the path to the animation for when the local player uses the move.
static std::string playerAnimationForeground(MoveId move)
Returns the path to the animation for when the local player uses the move.
MoveId id
The id of the move.
const OwnedMove * knownMoves() const
Returns the moves known by this Peoplemon.