-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAniTransition.cpp
More file actions
134 lines (118 loc) · 2.76 KB
/
Copy pathAniTransition.cpp
File metadata and controls
134 lines (118 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include "AniTransition.h"
#include "AnimationController.h"
#include "AnimationState.h"
#include "TransCondition.h"
AniTransition::AniTransition(AnimationState* _curState, AnimationState* _nextState)
{
curState = _curState;
nextState = _nextState;
}
AniTransition::~AniTransition()
{
}
bool AniTransition::CheckTransiton(bool isBlend)
{
auto Progress = m_ownerController->curAnimationProgress;
//연속전이중 progress가 제대로 초기화안되서 전이가 이상하게됨
if (isBlend)
{
Progress = m_ownerController->nextAnimationProgress;
}
if (hasExitTime) //최소 탈출시간 있을때
{
if (conditions.empty()) //탈출시간은 있는대 조건없으면 탈출시간되면 탈출
{
if (GetExitTime() <= Progress)
return true;
}
else //탈출시간 + 조건있으면 둘다만족해야 탈출
{
if (GetExitTime() <= Progress)
{
for (auto& condition : conditions)
{
if (true == condition.CheckTrans())
return true;
}
}
}
}
else //없을
{
if (conditions.empty()) //탈출시간은 없고 조건없으면 애니메이션 끝나면탈출 loop면 탈출불가
{
if (m_ownerController->endAnimation)
return true;
}
else //탈출 시간없고 조건있으면 조건만족시 탈출
{
for (auto& condition : conditions)
{
if (true == condition.CheckTrans())
return true;
}
}
}
return false;
}
std::vector<TransCondition> AniTransition::GetConditions()
{
return conditions;
}
nlohmann::json AniTransition::Serialize()
{
nlohmann::json j;
j["transName"] = m_name;
j["curStateName"] = curStateName;
j["nextStateName"] = nextStateName;
j["hasExitTime"] = (int)hasExitTime;
j["exitTime"] = exitTime;
j["blendTime"] = blendTime;
nlohmann::json conditionJson = nlohmann::json::array();
for (auto& condition : conditions)
{
conditionJson.push_back(condition.Serialize());
}
j["conditions"] = conditionJson;
return j;
}
AniTransition AniTransition::Deserialize()
{
return AniTransition();
}
void AniTransition::DeleteCondition(int _index)
{
if (_index >= 0 && _index < static_cast<int>(conditions.size())) {
conditions.erase(conditions.begin() + _index);
}
}
void AniTransition::SetCurState(std::string _curStateName)
{
curState = m_ownerController->FindState(_curStateName);
curStateName = _curStateName;
}
void AniTransition::SetCurState(AnimationState* _curState)
{
curState = _curState;
curStateName = curState->m_name;
}
void AniTransition::SetNextState(std::string _nextStateName)
{
nextState = m_ownerController->FindState(_nextStateName);
nextStateName = _nextStateName;
}
void AniTransition::SetNextState(AnimationState* _nextState)
{
nextState = _nextState;
nextStateName = nextState->m_name;
}
std::string AniTransition::GetCurState()
{
if (curState == nullptr)
return "None";
return curState->m_name;
}
std::string AniTransition::GetNextState()
{
return nextState->m_name;
}