Otclient 1.0
14/8/2020
animator.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
* of this software and associated documentation files (the "Software"), to deal
6
* in the Software without restriction, including without limitation the rights
7
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
* copies of the Software, and to permit persons to whom the Software is
9
* furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
* THE SOFTWARE.
21
*/
22
23
#ifndef ANIMATOR_H
24
#define ANIMATOR_H
25
26
#include "
declarations.h
"
27
28
#include <
framework/core/declarations.h
>
29
30
enum
AnimationPhase
:
int16
31
{
32
AnimPhaseAutomatic
= -1,
33
AnimPhaseRandom
= 254,
34
AnimPhaseAsync
= 255,
35
};
36
37
enum
AnimationDirection
:
uint8
38
{
39
AnimDirForward
= 0,
40
AnimDirBackward
= 1
41
};
42
43
class
Animator
:
public
stdext::shared_object
44
{
45
public
:
46
Animator
();
47
48
void
unserialize
(
int
animationPhases,
const
FileStreamPtr
& fin);
49
void
serialize
(
const
FileStreamPtr
& fin);
50
void
setPhase
(
int
phase);
51
void
resetAnimation
();
52
53
int
getPhase
();
54
int
getPhaseAt
(
ticks_t
time
);
55
int
getStartPhase
()
const
;
56
int
getAnimationPhases
() {
return
m_animationPhases; }
57
int
getAverageDuration
() {
return
getTotalDuration
() /
getAnimationPhases
(); }
58
59
bool
isAsync
() {
return
m_async; }
60
bool
isComplete
() {
return
m_isComplete; }
61
62
ticks_t
getTotalDuration
();
63
64
private
:
65
int
getPingPongPhase();
66
int
getLoopPhase();
67
int
getPhaseDuration(
int
phase);
68
69
void
calculateSynchronous();
70
71
int
m_currentDuration;
72
int
m_animationPhases;
73
int
m_currentLoop;
74
int
m_startPhase;
75
int
m_loopCount;
76
int
m_phase;
77
78
bool
m_isComplete;
79
bool
m_async;
80
81
std::vector<std::tuple<int, int>> m_phaseDurations;
82
AnimationDirection
m_currentDirection;
83
ticks_t
m_lastPhaseTicks;
84
};
85
86
#endif
AnimDirBackward
@ AnimDirBackward
Definition:
animator.h:40
Animator::isComplete
bool isComplete()
Definition:
animator.h:60
Animator::unserialize
void unserialize(int animationPhases, const FileStreamPtr &fin)
Definition:
animator.cpp:43
Animator::getTotalDuration
ticks_t getTotalDuration()
Definition:
animator.cpp:219
ticks_t
int64 ticks_t
Definition:
types.h:43
Animator::getAnimationPhases
int getAnimationPhases()
Definition:
animator.h:56
AnimDirForward
@ AnimDirForward
Definition:
animator.h:39
Animator::serialize
void serialize(const FileStreamPtr &fin)
Definition:
animator.cpp:62
stdext::time
ticks_t time()
Definition:
time.cpp:33
Animator::getPhaseAt
int getPhaseAt(ticks_t time)
Definition:
animator.cpp:126
declarations.h
declarations.h
AnimPhaseAutomatic
@ AnimPhaseAutomatic
Definition:
animator.h:32
AnimationPhase
AnimationPhase
Definition:
animator.h:30
AnimationDirection
AnimationDirection
Definition:
animator.h:37
Animator::getAverageDuration
int getAverageDuration()
Definition:
animator.h:57
Animator::isAsync
bool isAsync()
Definition:
animator.h:59
stdext::shared_object_ptr< FileStream >
Animator::getStartPhase
int getStartPhase() const
Definition:
animator.cpp:144
Animator::Animator
Animator()
Definition:
animator.cpp:29
AnimPhaseAsync
@ AnimPhaseAsync
Definition:
animator.h:34
int16
int16_t int16
Definition:
types.h:40
Animator
Definition:
animator.h:43
stdext::shared_object
Definition:
shared_object.h:41
AnimPhaseRandom
@ AnimPhaseRandom
Definition:
animator.h:33
uint8
uint8_t uint8
Definition:
types.h:37
Animator::resetAnimation
void resetAnimation()
Definition:
animator.cpp:151
Animator::getPhase
int getPhase()
Definition:
animator.cpp:96
Animator::setPhase
void setPhase(int phase)
Definition:
animator.cpp:74
src
client
animator.h
Generated by
1.8.17
For more information visit
https://forum.opentibia.dev/