ScummVM API documentation
fightmoves.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22/*
23 * This code is based on the CRAB engine
24 *
25 * Copyright (c) Arvind Raja Yadav
26 *
27 * Licensed under MIT
28 *
29 */
30
31#ifndef CRAB_FIGHTMOVES_H
32#define CRAB_FIGHTMOVES_H
33
34#include "crab/timer.h"
35#include "crab/animation/fightmove.h"
36
37namespace Crab {
38
39namespace pyrodactyl {
40namespace anim {
41enum FrameUpdateResult {
42 FUR_FAIL,
43 FUR_WAIT,
44 FUR_SUCCESS
45};
46
47// This state value indicates that the move should execute regardless of actual sprite state
48const uint SPRITE_STATE_OVERRIDE = std::numeric_limits<uint>::max();
49
51 // The fighting moves of a sprite
53
54 // The currently selected move
55 int _cur;
56
57 // For AI - the move about to be executed
58 int _next;
59
60 // The timer used for playing animations
61 Timer _timer;
62
63 // We need to instantly show the new frame for a move that has started
64 bool _start;
65
66 // The current frame and total frames
67 uint _frameCur, _frameTotal;
68
69public:
70 FightMoves();
71
72 ~FightMoves() {}
73
74 void reset() {
75 _cur = -1;
76 }
77
78 void load(rapidxml::xml_node<char> *node);
79
80 bool curMove(FightMove &fm);
81 bool nextMove(FightMove &fm);
82
83 FrameUpdateResult updateFrame(const Direction &d);
84 bool curFrame(FightAnimFrame &faf, const Direction &d);
85
86 uint findMove(const pyrodactyl::input::FightAnimationType &type, const int &state);
87
88 void listAttackMoves(Common::Array<uint> &list);
89
90 bool forceUpdate(const uint &index, pyrodactyl::input::FightInput &input, const Direction &d);
91
92 bool lastFrame() {
93 return _frameCur >= _frameTotal;
94 }
95
96 void frameIndex(uint val) {
97 _frameCur = val;
98 }
99
100 void curCombo(pyrodactyl::input::FightInput &input) {
101 input = _move[_cur]._input;
102 }
103
104 bool validMove() {
105 return _cur >= 0 && (uint)_cur < _move.size();
106 }
107
108 bool empty() {
109 return _move.empty();
110 }
111
112 bool flip(TextureFlipType &flip, Direction d);
113
114 const ShadowOffset &shadow(Direction d) {
115 return _move[_cur]._frames[d]._shadow;
116 }
117
118 void next(int val) {
119 _next = val;
120 }
121
122 int next() {
123 return _next;
124 }
125
126 void evaluate(pyrodactyl::event::Info &info);
127};
128} // End of namespace anim
129} // End of namespace pyrodactyl
130
131} // End of namespace Crab
132
133#endif // CRAB_FIGHTMOVES_H
Definition: array.h:52
size_type size() const
Definition: array.h:316
bool empty() const
Definition: array.h:352
Definition: timer.h:43
Definition: fightmoves.h:50
Definition: GameEventInfo.h:44
Definition: fightanim.h:44
Definition: fightmove.h:41
Definition: fightinput.h:59